Package org.dspace.content

Examples of org.dspace.content.Bitstream


            for (Bitstream bitstream : bundle.getBitstreams()) {
                // //////////////////////////////
                // Determine the file's IDs
                String fileID = getFileID(bitstream);

                Bitstream originalBitstream = null;
                if (isDerivedBundle) {
                    originalBitstream = findOriginalBitstream(item, bitstream);
                }
                String groupID = getGroupFileID((originalBitstream == null) ? bitstream : originalBitstream);
View Full Code Here



        Bundle[] bundles = item.getBundles("METADATA");

        for (Bundle bundle : bundles) {
            Bitstream bitstream = bundle.getBitstreamByName("METS.xml");

            if (bitstream == null) {
                continue;
            }

            // ///////////////////////////////
            // Send the actual XML content
            try {
                SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
                // Allow the basics for XML
                filter.allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();
                // Special option, only allow elements below the second level to pass through. This
                // will trim out the METS declaration and only leave the actual METS parts to be
                // included.
                filter.allowElements(1);


                XMLReader reader = XMLReaderFactory.createXMLReader();
                reader.setContentHandler(filter);
                reader.setProperty("http://xml.org/sax/properties/lexical-handler", filter);
                reader.parse(new InputSource(bitstream.retrieve()));
            } catch (AuthorizeException ae) {
                // just ignore the authorize exception and continue on with
                //out parsing the xml document.
            }
        }
View Full Code Here

                String groupID2 = getGenericID("group_dmd_");
               
                Bundle[] bundles = item.getBundles("METADATA");
                for (Bundle bundle : bundles)
                {
                        Bitstream bitstream = bundle.getBitstreamByName("MODS.xml");
       
                        if (bitstream == null)
                                continue;
                       
                       
                        String dmdID = getGenericID("dmd_");
                       
                       
                        ////////////////////////////////
                        // Start a metadata wrapper
                        attributes = new AttributeMap();
                        attributes.put("ID", dmdID);
                        attributes.put("GROUPID", groupID2);
                        startElement(METS, "dmdSec", attributes);
       
                         ////////////////////////////////
                        // Start a metadata wrapper
                        attributes = new AttributeMap();
                        attributes.put("MDTYPE", "MODS");
                        startElement(METS,"mdWrap",attributes);
                       
                        // ////////////////////////////////
                        // Start the xml data
                        startElement(METS,"xmlData");
                       
                       
                        // ///////////////////////////////
                        // Send the actual XML content
                       
                        SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
                        // Allow the basics for XML
                        filter.allowElements().allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();
                       
                        XMLReader reader = XMLReaderFactory.createXMLReader();
                        reader.setContentHandler(filter);
                        reader.setProperty("http://xml.org/sax/properties/lexical-handler", filter);
                        try {
                                InputStream is = bitstream.retrieve();
                                reader.parse(new InputSource(is));
                        }
                        catch (AuthorizeException ae)
                        {
                                // just ignore the authorize exception and continue on with
View Full Code Here

            {
                // //////////////////////////////
                // Determine the file's IDs
                String fileID = getFileID(bitstream);
               
                Bitstream originalBitstream = null;
                if (isDerivedBundle)
                        originalBitstream = findOriginalBitstream(item, bitstream);
                String groupID = getGroupFileID((originalBitstream == null) ? bitstream : originalBitstream );

                //Check if there were administrative metadata sections corresponding to this file
View Full Code Here

               
        Bundle[] bundles = item.getBundles("METADATA");

        for (Bundle bundle : bundles)
        {
                Bitstream bitstream = bundle.getBitstreamByName("METS.xml");

                if (bitstream == null)
                        continue;

                // ///////////////////////////////
                // Send the actual XML content
                try {
                        SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
                        // Allow the basics for XML
                        filter.allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();
                        // Special option, only allow elements below the second level to pass through. This
                        // will trim out the METS declaration and only leave the actual METS parts to be
                        // included.
                        filter.allowElements(1);
                       
                       
                        XMLReader reader = XMLReaderFactory.createXMLReader();
                        reader.setContentHandler(filter);
                        reader.setProperty("http://xml.org/sax/properties/lexical-handler", filter);
                        reader.parse(new InputSource(bitstream.retrieve()));
                }
                        catch (AuthorizeException ae)
                        {
                                // just ignore the authorize exception and continue on with
                                //out parsing the xml document.
View Full Code Here

            String name = par.getParameter("name", null);
       
            this.isSpider = par.getParameter("userAgent", "").equals("spider");

            // Reslove the bitstream
            Bitstream bitstream = null;
            DSpaceObject dso = null;
           
            if (bitstreamID > -1)
            {
                // Direct refrence to the individual bitstream ID.
                bitstream = Bitstream.find(context, bitstreamID);
            }
            else if (itemID > -1)
            {
                // Referenced by internal itemID
                item = Item.find(context, itemID);
               
                if (sequence > -1)
                {
                        bitstream = findBitstreamBySequence(item, sequence);
                }
                else if (name != null)
                {
                        bitstream = findBitstreamByName(item, name);
                }
            }
            else if (handle != null)
            {
                // Reference by an item's handle.
                dso = HandleManager.resolveToObject(context,handle);

                if (dso instanceof Item)
                {
                    item = (Item)dso;

                    if (sequence > -1)
                    {
                        bitstream = findBitstreamBySequence(item,sequence);
                    }
                    else if (name != null)
                    {
                        bitstream = findBitstreamByName(item,name);
                    }
                }
            }

            //if initial search was by sequence number and found nothing,
            //then try to find bitstream by name (assuming we have a file name)
            if((sequence > -1 && bitstream==null) && name!=null)
            {
                bitstream = findBitstreamByName(item,name);

                //if we found bitstream by name, send a redirect to its new sequence number location
                if(bitstream!=null)
                {
                    String redirectURL = "";

                    //build redirect URL based on whether item has a handle assigned yet
                    if(item.getHandle()!=null && item.getHandle().length()>0)
                      redirectURL = request.getContextPath() + "/bitstream/handle/" + item.getHandle();
                    else
                      redirectURL = request.getContextPath() + "/bitstream/item/" + item.getID();

                        redirectURL += "/" + name + "?sequence=" + bitstream.getSequenceID();

                        HttpServletResponse httpResponse = (HttpServletResponse)
                        objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
                        httpResponse.sendRedirect(redirectURL);
                        return;
                }
            }

            // Was a bitstream found?
            if (bitstream == null)
            {
                throw new ResourceNotFoundException("Unable to locate bitstream");
            }

            // Is there a User logged in and does the user have access to read it?
            boolean isAuthorized = AuthorizeManager.authorizeActionBoolean(context, bitstream, Constants.READ);
            if (item != null && item.isWithdrawn() && !AuthorizeManager.isAdmin(context))
            {
                isAuthorized = false;
                log.info(LogManager.getHeader(context, "view_bitstream", "handle=" + item.getHandle() + ",withdrawn=true"));
            }

            if (!isAuthorized)
            {
                if(context.getCurrentUser() != null){
                        // A user is logged in, but they are not authorized to read this bitstream,
                        // instead of asking them to login again we'll point them to a friendly error
                        // message that tells them the bitstream is restricted.
                        String redictURL = request.getContextPath() + "/handle/";
                        if (item!=null){
                                redictURL += item.getHandle();
                        }
                        else if(dso!=null){
                                redictURL += dso.getHandle();
                        }
                        redictURL += "/restricted-resource?bitstreamId=" + bitstream.getID();

                        HttpServletResponse httpResponse = (HttpServletResponse)
                        objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
                        httpResponse.sendRedirect(redictURL);
                        return;
                }
                else{

                        // The user does not have read access to this bitstream. Inturrupt this current request
                        // and then forward them to the login page so that they can be authenticated. Once that is
                        // successfull they will request will be resumed.
                        AuthenticationUtil.interruptRequest(objectModel, AUTH_REQUIRED_HEADER, AUTH_REQUIRED_MESSAGE, null);

                        // Redirect
                        String redictURL = request.getContextPath() + "/login";

                        HttpServletResponse httpResponse = (HttpServletResponse)
                        objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
                        httpResponse.sendRedirect(redictURL);
                        return;
                }
            }
               
            // Success, bitstream found and the user has access to read it.
            // Store these for later retreval:
            this.bitstreamInputStream = bitstream.retrieve();
            this.bitstreamSize = bitstream.getSize();
            this.bitstreamMimeType = bitstream.getFormat().getMIMEType();
            this.bitstreamName = bitstream.getName();
            if (context.getCurrentUser() == null)
            {
                this.isAnonymouslyReadable = true;
            }
            else
View Full Code Here

                this.add(bitstream);
            }
        }
        else if (dso instanceof Bitstream)
        {
            Bitstream bitstream = (Bitstream) dso;
           
            validityKey.append("Bundle:");
            validityKey.append(bitstream.getID());
            validityKey.append(bitstream.getSequenceID());
            validityKey.append(bitstream.getName());
            validityKey.append(bitstream.getSource());
            validityKey.append(bitstream.getDescription());
            validityKey.append(bitstream.getChecksum());
            validityKey.append(bitstream.getChecksumAlgorithm());
            validityKey.append(bitstream.getSize());
            validityKey.append(bitstream.getUserFormatDescription());
            validityKey.append(bitstream.getFormat().getDescription());
        }
        else if (dso instanceof EPerson)
        {
            EPerson eperson = (EPerson) dso;
           
View Full Code Here

        // Add the trail back to the repository root.
        Stack<DSpaceObject> stack = new Stack<DSpaceObject>();

        if (dso instanceof Bitstream)
        {
          Bitstream bitstream = (Bitstream) dso;
          Bundle[] bundles = bitstream.getBundles();
         
          dso = bundles[0];
        }
       
        if (dso instanceof Bundle)
View Full Code Here

    protected void renderFileSection() throws SAXException
    {
      AttributeMap attributes;
     
        // Get the Community or Collection logo.
        Bitstream logo = getLogo();

        if (logo != null)
        {
            // ////////////////////////////////
            // Start the file section
View Full Code Here

        attributes.put("DMDID", dmdSecIDS.toString());
      startElement(METS,"div",attributes);
     
     
      // add a fptr pointer to the logo.
        Bitstream logo = getLogo();
        if (logo != null)
        {
            // ////////////////////////////////
            // Add a refrence to the logo as the primary bitstream.
          attributes = new AttributeMap();
View Full Code Here

TOP

Related Classes of org.dspace.content.Bitstream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.