Package org.dspace.app.xmlui.wing

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


     * default language.
     *
     */
  protected void renderDescriptiveSection() throws SAXException
    {
      AttributeMap attributes;
     
      // Generate our ids
        String dmdID = getGenericID("dmd_");
        String groupID = getGenericID("group_dmd_");

        // ////////////////////////////////
        // Start a single dmdSec
        attributes = new AttributeMap();
        attributes.put("ID", dmdID);
        attributes.put("GROUPID", groupID);
        startElement(METS,"dmdSec",attributes);

        // ////////////////////////////////
        // Start a metadata wrapper (hardcoded to mods)
        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[Constants.SITE]);
    startElement(DIM,"dim",attributes);
   
    // Entry for dspace.name
    attributes = new AttributeMap();
    attributes.put("mdschema","dspace");
    attributes.put("element", "name");
    startElement(DIM,"field",attributes);
    sendCharacters(ConfigurationManager.getProperty("dspace.name"));
    endElement(DIM,"field");
   
    // Entry for dspace.hostname
    attributes = new AttributeMap();
    attributes.put("mdschema","dspace");
    attributes.put("element", "hostname");
    startElement(DIM,"field",attributes);
    sendCharacters(ConfigurationManager.getProperty("dspace.hostname"));
    endElement(DIM,"field");
   
    // Entry for handle.prefix
    attributes = new AttributeMap();
    attributes.put("mdschema","dspace");
    attributes.put("element", "handle");
    startElement(DIM,"field",attributes);
    sendCharacters(ConfigurationManager.getProperty("handle.prefix"));
    endElement(DIM,"field");
   
    // Entry for default.language
    attributes = new AttributeMap();
    attributes.put("mdschema","dspace");
    attributes.put("element", "default");
    attributes.put("qualifier", "language");
    startElement(DIM,"field",attributes);
    sendCharacters(ConfigurationManager.getProperty("default.language"));
    endElement(DIM,"field");
   
        // ///////////////////////////////
View Full Code Here


     * all the community and collection objects showing how they are related to
     * one another.
     */
  protected void renderStructureMap() throws SQLException, SAXException
    {
      AttributeMap attributes;
       
      // //////////////////////////
      // Start the new struct 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 Repository");
        // add references to the Descriptive metadata
        if (dmdSecIDS != null)
            attributes.put("DMDID", dmdSecIDS);
        startElement(METS,"div",attributes);

        // Put each root level node into the document.
        for (Community community : Community.findAllTop(context))
        {
View Full Code Here

     * @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 insure that our children are also included even if this
        // node allready 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 specefic sections then render them all.
        boolean all = (sections.size() == 0);
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. Further more 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 new dmdSec for each crosswalk.
            attributes = new AttributeMap();
            attributes.put("ID", dmdID);
            attributes.put("GROUPID", groupID);
            startElement(METS,"dmdSec",attributes);
           
            // ////////////////////////////////
            // Start 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[dso.getType()]);
      startElement(DIM,"dim",attributes);

            // Add each field for this collection
            if (dso.getType() == Constants.COLLECTION)
            {
                Collection collection = (Collection) dso;
               
                String description = collection.getMetadata("introductory_text");
                String description_abstract = collection.getMetadata("short_description");
                String description_table = collection.getMetadata("side_bar_text");
                String identifier_uri = "http://hdl.handle.net/" + collection.getHandle();
                String provenance = collection.getMetadata("provenance_description");
                String rights = collection.getMetadata("copyright_text");
                String rights_license = collection.getMetadata("license");
                String title = collection.getMetadata("name");
               
                createField("dc","description",null,null,description);
                createField("dc","description","abstract",null,description_abstract);
                createField("dc","description","tableofcontents",null,description_table);
                createField("dc","identifier","uri",null,identifier_uri);
                createField("dc","provenance",null,null,provenance);
                createField("dc","rights",null,null,rights);
                createField("dc","rights","license",null,rights_license);
                createField("dc","title",null,null,title);
               
                boolean useCache = ConfigurationManager.getBooleanProperty("webui.strengths.cache");
           
                //To improve scalability, XMLUI only adds item counts if they are cached
                if (useCache)
            {
                  try
                  //try to determine Collection size (i.e. # of items)
                    int size = new ItemCounter(this.dspaceContext).getCount(collection);
                    createField("dc","format","extent",null, String.valueOf(size));
                  }
                  catch(ItemCountException e)
                  {
                      IOException ioe = new IOException("Could not obtain Collection item-count");
                      ioe.initCause(e);
                    throw ioe;
                  }
            }
            }
            else if (dso.getType() == Constants.COMMUNITY)
            {
                Community community = (Community) dso;
               
                String description = community.getMetadata("introductory_text");
                String description_abstract = community.getMetadata("short_description");
                String description_table = community.getMetadata("side_bar_text");
                String identifier_uri = "http://hdl.handle.net/" + community.getHandle();
                String rights = community.getMetadata("copyright_text");
                String title = community.getMetadata("name");
               
                createField("dc","description",null,null,description);
                createField("dc","description","abstract",null,description_abstract);
                createField("dc","description","tableofcontents",null,description_table);
                createField("dc","identifier","uri",null,identifier_uri);
                createField("dc","rights",null,null,rights);
                createField("dc","title",null,null,title);
               
                boolean useCache = ConfigurationManager.getBooleanProperty("webui.strengths.cache");
           
                //To improve scalability, XMLUI only adds item counts if they are cached
            if (useCache)
            {
              try
                  //try to determine Community size (i.e. # of items)
                    int size = new ItemCounter(this.dspaceContext).getCount(community);
                    createField("dc","format","extent",null, String.valueOf(size));
                  }
                  catch(ItemCountException e)
                  {
                    IOException ioe = new IOException("Could not obtain Collection item-count");
                    ioe.initCause(e);
                    throw ioe;
                  }
            }
            }
           
            // ///////////////////////////////
      // End the DIM element
      endElement(DIM,"dim");
           
            // ////////////////////////////////
            // End elements
            endElement(METS,"xmlData");
            endElement(METS,"mdWrap");
            endElement(METS, "dmdSec");
         
        }
       
       
       
       
       
       
       
      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(" " + dmdID);

            // ////////////////////////////////
            // Start a new dmdSec for each crosswalk.
            attributes = new AttributeMap();
            attributes.put("ID", dmdID);
            attributes.put("GROUPID", groupID);
            startElement(METS,"dmdSec",attributes);
           
            // ////////////////////////////////
            // Start 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
View Full Code Here

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

        if (logo != null)
        {
            // ////////////////////////////////
            // Start the file section
          startElement(METS,"fileSec");

            // ////////////////////////////////
            // Start a new fileGrp for the logo.
            attributes = new AttributeMap();
            attributes.put("USE", "LOGO");
            startElement(METS,"fileGrp",attributes);
           
            // ////////////////////////////////
            // Add the actual file element
            String fileID = getFileID(logo);
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", getMETSLabel());
      // add references to the Descriptive metadata
      if (dmdSecIDS != null)
        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();
          attributes.put("FILEID",getFileID(logo));
          startElement(METS,"fptr",attributes);
          endElement(METS,"fptr");
       
           
            // ///////////////////////////////////////////////
            // Add a div for the publicaly viewable bitstreams (i.e. the logo)
          attributes = new AttributeMap();
            attributes.put("ID", getGenericID("div_"));
            attributes.put("TYPE", "DSpace Content Bitstream");
          startElement(METS,"div",attributes);
         
            // ////////////////////////////////
            // Add a refrence to the logo as the primary bitstream.
          attributes = new AttributeMap();
          attributes.put("FILEID",getFileID(logo));
          startElement(METS,"fptr",attributes);
          endElement(METS,"fptr");
         
          // //////////////////////////
          // End the logo division
View Full Code Here

     */
    private void createField(String schema, String element, String qualifier, String language, String value) throws SAXException
    {
      // ///////////////////////////////
      // Field element for each metadata field.
      AttributeMap attributes = new AttributeMap();
    attributes.put("mdschema",schema);
    attributes.put("element", element);
    if (qualifier != null)
      attributes.put("qualifier", qualifier);
    if (language != null)
      attributes.put("language", language);
    startElement(DIM,"field",attributes);
   
    // Only try and add the metadata's value, but only if it is non null.
      if (value != null)
      {
View Full Code Here

     *            to this file
     * @return The METS file element.
     */
  protected 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 refrence this bitstream via a handle, however this may
        // be null if a handle has not yet been assigned. In this case refrence the
        // item its internal id. In the last case where the bitstream is not associated
        // with an item (such as a community logo) then refrence 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();
       
       
        // //////////////////////
        // 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. Further more 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);
                       
                DCValue[] dcvs = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
                for (DCValue 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(" " + 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 with
                                //out 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 it's 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

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.