Package org.dspace.app.xmlui.wing

Examples of org.dspace.app.xmlui.wing.AttributeMap


     * @param dso
     *            The DSpace Object to be rendered.
     */
    private void renderStructuralDiv(DSpaceObject dso) throws SAXException, SQLException
    {
      AttributeMap attributes;

        // ////////////////////////////////
        // Start the new div for this repository container
        attributes = new AttributeMap();
        if (dso instanceof Community)
        {
            attributes.put("TYPE", "DSpace Community");
        }
        else if (dso instanceof Collection)
        {
            attributes.put("TYPE", "DSpace Collection");
        }
        startElement(METS,"div",attributes);
       
        // //////////////////////////////////
        // Start a metadata pointer for this container
        attributes = new AttributeMap();
        AttributeMap attributesXLINK = new AttributeMap();
        attributesXLINK.setNamespace(XLINK);
       
        attributes.put("LOCTYPE", "URL");
        attributesXLINK.put("href", "/metadata/handle/"+ dso.getHandle() +"/mets.xml");
        startElement(METS,"mptr",attributes,attributesXLINK);
        endElement(METS,"mptr");
       
        // Recurse to ensure that our children are also included even if this
        // node already existed in the div structure.
View Full Code Here


        contentHandler.startPrefixMapping("xlink", XLINK.URI);
        contentHandler.startPrefixMapping("xsi", XSI.URI);
        contentHandler.startPrefixMapping("dim", DIM.URI);
       
        // Send the METS element
        AttributeMap attributes = new AttributeMap();
        attributes.put("ID", getMETSID());
        attributes.put("PROFILE", getMETSProfile());
        attributes.put("LABEL", getMETSLabel());
        String objid = getMETSOBJID();
        if (objid != null)
            {
                attributes.put("OBJID", objid);
            }

            // Include the link for editing the item
            objid = getMETSOBJEDIT();
            if (objid != null)
            {
                attributes.put("OBJEDIT", objid);
            }

        startElement(METS,"METS",attributes);

        // If the user requested no specific sections then render them all.
View Full Code Here

     *            The IDs of the administrative metadata sections which pertain
     *            to this file
     */
  protected final void renderFile(Item item, Bitstream bitstream, String fileID, String groupID, String admID) throws SAXException
  {
    AttributeMap attributes;
   
    // //////////////////////////////
      // Determine the file attributes
        BitstreamFormat format = bitstream.getFormat();
        String mimeType = null;
        if (format != null)
        {
            mimeType = format.getMIMEType();
        }
        String checksumType = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();
        long size = bitstream.getSize();
     
        // ////////////////////////////////
        // Start the actual file
        attributes = new AttributeMap();
        attributes.put("ID", fileID);
        attributes.put("GROUPID",groupID);
        if (admID != null && admID.length()>0)
        {
            attributes.put("ADMID", admID);
        }
        if (mimeType != null && mimeType.length()>0)
        {
            attributes.put("MIMETYPE", mimeType);
        }
        if (checksumType != null && checksum != null)
        {
          attributes.put("CHECKSUM", checksum);
          attributes.put("CHECKSUMTYPE", checksumType);
        }
        attributes.put("SIZE", String.valueOf(size));
        startElement(METS,"file",attributes);
       
       
        // ////////////////////////////////////
        // Determine the file location attributes
        String name = bitstream.getName();
        String description = bitstream.getDescription();

       
        // If possible, reference this bitstream via a handle, however this may
        // be null if a handle has not yet been assigned. In this case reference the
        // item its internal id. In the last case where the bitstream is not associated
        // with an item (such as a community logo) then reference the bitstreamID directly.
        String identifier = null;
        if (item != null && item.getHandle() != null)
        {
            identifier = "handle/" + item.getHandle();
        }
        else if (item != null)
        {
            identifier = "item/" + item.getID();
        }
        else
        {
            identifier = "id/" + bitstream.getID();
        }
       
       
        String url = contextPath + "/bitstream/"+identifier+"/";
       
        // If we can, append the pretty name of the bitstream to the URL
        try
        {
          if (bitstream.getName() != null)
            {
                url += Util.encodeBitstreamName(bitstream.getName(), "UTF-8");
            }
        }
        catch (UnsupportedEncodingException uee)
        {
            // just ignore it, we don't have to have a pretty
            // name at the end of the URL because the sequence id will
          // locate it. However it means that links in this file might
          // not work....
        }
       
        url += "?sequence="+bitstream.getSequenceID();
       
       
        // //////////////////////
        // Start the file location
        attributes = new AttributeMap();
        AttributeMap attributesXLINK = new AttributeMap();
        attributesXLINK.setNamespace(XLINK);
        attributes.put("LOCTYPE", "URL");
        attributesXLINK.put("type","locator");
        attributesXLINK.put("title", name);
        if (description != null)
        {
            attributesXLINK.put("label", description);
        }
        attributesXLINK.put("href", url);
        startElement(METS,"FLocat",attributes,attributesXLINK);
       

        // ///////////////////////
        // End file location
View Full Code Here

     *  </mdWrap>
     * </dmdSec
     */
    protected void renderDescriptiveSection() throws WingException, SAXException, CrosswalkException, IOException, SQLException
    {
        AttributeMap attributes;
        String groupID = getGenericID("group_dmd_");
        dmdSecIDS = new StringBuffer();

        // Add DIM descriptive metadata if it was requested or if no metadata types
        // were specified. Furthermore, since this is the default type we also use a
        // faster rendering method that the crosswalk API.
        if(dmdTypes.size() == 0 || dmdTypes.contains("DIM"))
        {
                // Metadata element's ID
                String dmdID = getGenericID("dmd_");
                // Keep track of all descriptive sections
                dmdSecIDS.append(dmdID);
               
                        ////////////////////////////////
                        // Start a metadata wrapper
                        attributes = new AttributeMap();
                        attributes.put("ID", dmdID);
                        attributes.put("GROUPID", groupID);
                        startElement(METS, "dmdSec", attributes);
       
                         ////////////////////////////////
                        // Start a metadata wrapper
                        attributes = new AttributeMap();
                        attributes.put("MDTYPE","OTHER");
                        attributes.put("OTHERMDTYPE", "DIM");
                        startElement(METS,"mdWrap",attributes);
                       
                        // ////////////////////////////////
                        // Start the xml data
                        startElement(METS,"xmlData");
       
                       
                        // ///////////////////////////////
                        // Start the DIM element
                        attributes = new AttributeMap();
                        attributes.put("dspaceType", Constants.typeText[item.getType()]);
            if (item.isWithdrawn())
            {
                attributes.put("withdrawn", "y");
            }
            startElement(DIM,"dim",attributes);
                       
                Metadatum[] dcvs = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
                for (Metadatum dcv : dcvs)
                {
                        if (!MetadataExposure.isHidden(context, dcv.schema, dcv.element, dcv.qualifier))
                        {
                        // ///////////////////////////////
                        // Field element for each metadata field.
                        attributes = new AttributeMap();
                        attributes.put("mdschema",dcv.schema);
                        attributes.put("element", dcv.element);
                        if (dcv.qualifier != null)
                        {
                            attributes.put("qualifier", dcv.qualifier);
                        }
                        if (dcv.language != null)
                        {
                            attributes.put("language", dcv.language);
                        }
                        if (dcv.authority != null || dcv.confidence != Choices.CF_UNSET)
                        {
                                attributes.put("authority", dcv.authority);
                                attributes.put("confidence", Choices.getConfidenceText(dcv.confidence));
                        }
                        startElement(DIM,"field",attributes);
                        sendCharacters(dcv.value);
                        endElement(DIM,"field");
                }
                }
                       
                // ///////////////////////////////
                        // End the DIM element
                        endElement(DIM,"dim");
                       
                // ////////////////////////////////
                // End elements
                endElement(METS,"xmlData");
                endElement(METS,"mdWrap");
                endElement(METS,"dmdSec");

        }
               
       
        // Add any extra crosswalks that may configured.
        for (String dmdType : dmdTypes)
        {
                // If DIM was requested then it was generated above without using
                // the crosswalk API. So we can skip this one.
                if ("DIM".equals(dmdType))
                {
                    continue;
                }
               
                DisseminationCrosswalk crosswalk = getDisseminationCrosswalk(dmdType);
               
                if (crosswalk == null)
                {
                    continue;
                }
               
                String dmdID = getGenericID("dmd_");
                // Add our id to the list.
                dmdSecIDS.append(" ").append(dmdID);
               
                ////////////////////////////////
                // Start a metadata wrapper
                attributes = new AttributeMap();
                attributes.put("ID", dmdID);
                attributes.put("GROUPID", groupID);
                startElement(METS, "dmdSec", attributes);

                ////////////////////////////////
                // Start a metadata wrapper
                attributes = new AttributeMap();
                if (isDefinedMETStype(dmdType))
                {
                        attributes.put("MDTYPE", dmdType);
                }
                else
                {
                        attributes.put("MDTYPE","OTHER");
                        attributes.put("OTHERMDTYPE", dmdType);
                }
                startElement(METS,"mdWrap",attributes);
               
                // ////////////////////////////////
                // Start the xml data
                startElement(METS,"xmlData");

               
                // ///////////////////////////////
                // Send the actual XML content
                try {
                        Element dissemination = crosswalk.disseminateElement(item);
       
                        SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
                        // Allow the basics for XML
                        filter.allowElements().allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();
                       
                    SAXOutputter outputter = new SAXOutputter();
                    outputter.setContentHandler(filter);
                    outputter.setLexicalHandler(filter);
                                outputter.output(dissemination);
                        }
            catch (JDOMException jdome)
                        {
                                throw new WingException(jdome);
                        }
                        catch (AuthorizeException ae)
                        {
                                // just ignore the authorize exception and continue on
                                // without parsing the xml document.
                        }
               
           
            // ////////////////////////////////
            // End elements
            endElement(METS,"xmlData");
            endElement(METS,"mdWrap");
            endElement(METS,"dmdSec");
        }


        // Check to see if there is an in-line MODS document
        // stored as a bitstream. If there is then we should also
        // include these metadata in our METS document. However,
        // we don't really know what the document describes, so we
        // but it in its own dmd group.

        Boolean include = ConfigurationManager.getBooleanProperty("xmlui.bitstream.mods");
        if (include && dmdTypes.contains("MODS"))
        {
                // Generate a second group id for any extra metadata added.
                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");
View Full Code Here

     *  </mdWrap>
     * </amdSec>
     */
    protected void renderAdministrativeSection() throws WingException, SAXException, CrosswalkException, IOException, SQLException
    {
        AttributeMap attributes;
        String groupID;

        // Only create an <amdSec>, if we have amdTypes (or sub-sections) specified...
        // (this keeps our METS file small, by default, and hides all our admin metadata)
        if(amdTypes.size() > 0)
        {
          ////////////////////////////////
          // Start an administrative wrapper

          // Administrative element's ID
          String amdID = getGenericID("amd_");
          attributes = new AttributeMap();
          attributes.put("ID", amdID);
          startElement(METS, "amdSec", attributes);

          groupID = getGenericID("group_amd_");
          attributes.put("GROUPID", groupID);
        }

        // For each administrative metadata section specified
        for (String amdSecName : amdTypes.keySet())
        {
View Full Code Here

            throws WingException, SAXException, CrosswalkException, IOException, SQLException
    {
        /////////////////////////////////
        // Start administrative metadata section wrapper
        String amdSecID = getAmdSecID(amdSecName, mdType, dso);
        AttributeMap attributes = new AttributeMap();
        attributes.put("ID", amdSecID);
        startElement(METS, amdSecName, attributes);

        // If this is a bitstream
        if (dso.getType() == Constants.BITSTREAM)
        {
          // Add this to our list of each file's administrative section IDs
          String fileID = getFileID((Bitstream) dso);
          if(fileAmdSecIDs.containsKey(fileID))
          {
              fileAmdSecIDs.get(fileID).append(" " + amdSecID);
          }
          else
          {
              fileAmdSecIDs.put(fileID, new StringBuffer(amdSecID));
          }
        } // else if an Item
        else if (dso.getType() == Constants.ITEM)
        {
           // Add this to our list of item's administrative section IDs
           if(amdSecIDS==null)
           {
               amdSecIDS = new StringBuffer(amdSecID);
           }
           else
           {
               amdSecIDS.append(" ").append(amdSecID);
           }
        }

        ////////////////////////////////
        // Start a metadata wrapper
        attributes = new AttributeMap();
        if (isDefinedMETStype(mdType))
        {
            attributes.put("MDTYPE", mdType);
        }
        else
        {
            attributes.put("MDTYPE","OTHER");
            attributes.put("OTHERMDTYPE", mdType);
        }
        startElement(METS,"mdWrap",attributes);

        //////////////////////////////////
        // Start the xml data
View Full Code Here

     *   </fileGrp>
     * </fileSec>
     */
    protected void renderFileSection() throws SQLException, SAXException
    {
        AttributeMap attributes;
       
        // //////////////////////
        // Start a new file section
        startElement(METS,"fileSec");
       
        // Check if the user is requested a specific bundle or
        // the all bundles.
        List<Bundle> bundles = findEnabledBundles();

        // Suppress license?
        Boolean showLicense = ConfigurationManager.getBooleanProperty("webui.licence_bundle.show");
       
        // Loop over all requested bundles
        for (Bundle bundle : bundles)
        {

            // Use the bitstream's name as the use parameter unless we
            // are the original bundle. In this case rename it to
            // content.
            String use = bundle.getName();
            boolean isContentBundle = false; // remember the content bundle.
            boolean isDerivedBundle = false;
            if ("ORIGINAL".equals(use))
            {
                use = "CONTENT";
                isContentBundle = true;
            }
            if ("TEXT".equals(bundle.getName()) || "THUMBNAIL".equals(bundle.getName()))
            {
                isDerivedBundle = true;
            }
            if ("LICENSE".equals(bundle.getName()) && ! showLicense)
            {
                continue;
            }

            // ///////////////////
            // Start bundle's file group
            attributes = new AttributeMap();
            attributes.put("USE", use);
            startElement(METS,"fileGrp",attributes);
           
            for (Bitstream bitstream : bundle.getBitstreams())
            {
                // //////////////////////////////
View Full Code Here

     *   </div>
     * </structMap>
     */
    protected void renderStructureMap() throws SQLException, SAXException
    {
        AttributeMap attributes;
       
        // ///////////////////////
        // Start a new structure map
        attributes = new AttributeMap();
        attributes.put("TYPE", "LOGICAL");
        attributes.put("LABEL", "DSpace");
        startElement(METS,"structMap",attributes);

        // ////////////////////////////////
        // Start the special first division
        attributes = new AttributeMap();
        attributes.put("TYPE", "DSpace Item");
        // add references to the Descriptive metadata
        if (dmdSecIDS != null)
        {
            attributes.put("DMDID", dmdSecIDS.toString());
        }
        // add references to the Administrative metadata
        if (amdSecIDS != null)
        {
            attributes.put("AMDID", amdSecIDS.toString());
        }
        startElement(METS,"div",attributes);
       
        // add a fptr pointer to the primary bitstream.
        if (primaryBitstream != null)
        {
                // ////////////////////////////////
                // Start & end a reference to the primary bitstream.
                attributes = new AttributeMap();
                String fileID = getFileID(primaryBitstream);
                attributes.put("FILEID", fileID);
               
                startElement(METS,"fptr",attributes);
                endElement(METS,"fptr");
        }

        for (Bitstream bitstream : contentBitstreams)
        {
                // ////////////////////////////////////
                // Start a div for each publicly viewable bitstream
                attributes = new AttributeMap();
                attributes.put("ID", getGenericID("div_"));
                attributes.put("TYPE", "DSpace Content Bitstream");
                startElement(METS,"div",attributes);

                // ////////////////////////////////
                // Start a the actualy pointer to the bitstream FIXME: what?
                attributes = new AttributeMap();
                String fileID = getFileID(bitstream);
                attributes.put("FILEID", fileID);
               
                startElement(METS,"fptr",attributes);
                endElement(METS,"fptr");
               
                // ///////////////////////////////
View Full Code Here

   
    // FIXME: this method is a copy of the one inherited. However the
    // original method is final so we must rename it.
  protected void renderFileWithAllowed(Item item, Bitstream bitstream, String fileID, String groupID, String admID) throws SAXException
  {
    AttributeMap attributes;
   
    // //////////////////////////////
      // Determine the file attributes
        BitstreamFormat format = bitstream.getFormat();
        String mimeType = null;
        if (format != null)
        {
            mimeType = format.getMIMEType();
        }
        String checksumType = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();
        long size = bitstream.getSize();
     
        // ////////////////////////////////
        // Start the actual file
        attributes = new AttributeMap();
        attributes.put("ID", fileID);
        attributes.put("GROUPID",groupID);
        if (admID != null && admID.length()>0)
        {
            attributes.put("ADMID", admID);
        }
        if (mimeType != null && mimeType.length()>0)
        {
            attributes.put("MIMETYPE", mimeType);
        }
        if (checksumType != null && checksum != null)
        {
          attributes.put("CHECKSUM", checksum);
          attributes.put("CHECKSUMTYPE", checksumType);
        }
        attributes.put("SIZE", String.valueOf(size));
        startElement(METS,"file",attributes);
       
       
        // ////////////////////////////////////
        // Determine the file location attributes
        String name = bitstream.getName();
        String description = bitstream.getDescription();

       
        // If possible reference this bitstream via a handle, however this may
        // be null if a handle has not yet been assigned. In this case reference the
        // item its internal id. In the last case where the bitstream is not associated
        // with an item (such as a community logo) then reference the bitstreamID directly.
        String identifier = null;
        if (item != null && item.getHandle() != null)
        {
            identifier = "handle/" + item.getHandle();
        }
        else if (item != null)
        {
            identifier = "item/" + item.getID();
        }
        else
        {
            identifier = "id/" + bitstream.getID();
        }
       
       
        String url = contextPath + "/bitstream/"+identifier+"/";
       
        // If we can put the pretty name of the bitstream on the end of the URL
        try
        {
          if (bitstream.getName() != null)
            {
                url += Util.encodeBitstreamName(bitstream.getName(), "UTF-8");
            }
        }
        catch (UnsupportedEncodingException uee)
        {
            // just ignore it, we don't have to have a pretty
            // name on the end of the URL because the sequence id will
          // locate it. However it means that links in this file might
          // not work....
        }
       
        url += "?sequence="+bitstream.getSequenceID();

  // Test if we are allowed to see this item
  String isAllowed = "n";
  try {
      if (AuthorizeManager.authorizeActionBoolean(context, bitstream, Constants.READ)) {
    isAllowed = "y";
      }
  } catch (SQLException e) {/* Do nothing */}
 
  url += "&isAllowed=" + isAllowed;

        // //////////////////////
        // Start the file location
        attributes = new AttributeMap();
        AttributeMap attributesXLINK = new AttributeMap();
        attributesXLINK.setNamespace(XLINK);
        attributes.put("LOCTYPE", "URL");
        attributesXLINK.put("type","locator");
        attributesXLINK.put("title", name);
        if (description != null)
        {
            attributesXLINK.put("label", description);
        }
        attributesXLINK.put("href", url);
        startElement(METS,"FLocat",attributes,attributesXLINK);
       

        // ///////////////////////
        // End file location
View Full Code Here

     *            to determine the correct prefix for a given namespace URI.
     */
    public void toSAX(ContentHandler contentHandler, LexicalHandler lexicalHandler,
            NamespaceSupport namespaces) throws SAXException
    {
        AttributeMap attributes = new AttributeMap();
        if (this.name != null)
        {
            attributes.put(A_NAME, name);
            attributes.put(A_ID, context.generateID(E_LABEL, name));
        }
        if (this.rend != null)
        {
            attributes.put(A_RENDER, this.rend);
        }

        startElement(contentHandler, namespaces, E_LABEL, attributes);
        super.toSAX(contentHandler, lexicalHandler, namespaces);
        endElement(contentHandler, namespaces, E_LABEL);
View Full Code Here

TOP

Related Classes of org.dspace.app.xmlui.wing.AttributeMap

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.