Package org.dspace.content.crosswalk

Examples of org.dspace.content.crosswalk.IngestionCrosswalk


    public void crosswalkItem(Context context, Item item, Element dmd, Mdref callback)
        throws MetadataValidationException,
               CrosswalkException, IOException, SQLException, AuthorizeException
    {
        String type = getMdType(dmd);
        IngestionCrosswalk xwalk = getCrosswalk(type);

        if (xwalk == null)
            throw new MetadataValidationException("Cannot process METS Manifest: "+
                "No crosswalk found for MDTYPE="+type);
        crosswalkMdContent(dmd, callback, xwalk, context, item);
View Full Code Here


            {
                Element techMD = (Element)ti.next();
                if (techMD != null)
                {
                    String type = getMdType(techMD);
                    IngestionCrosswalk xwalk = getCrosswalk(type);
                    log.debug("Got bitstream techMD of type="+type+", for file ID="+fileId);
                    
                    if (xwalk == null)
                        throw new MetadataValidationException("Cannot process METS Manifest: "+
                            "No crosswalk found for techMD MDTYPE="+type);
View Full Code Here

      return;
    }
     
    // If we are only harvesting descriptive metadata, the record should already contain all we need
      List<Element> descMD = record.getChild("metadata", OAI_NS).getChildren();
      IngestionCrosswalk MDxwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey);
     
      // Otherwise, obtain the ORE ReM and initiate the ORE crosswalk
      IngestionCrosswalk ORExwalk = null;
      Element oreREM = null;
      if (harvestRow.getHarvestType() > 1) {
        oreREM = getMDrecord(harvestRow.getOaiSource(), itemOaiID, OREPrefix).get(0);
        ORExwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.ORESeialKey);
      }
     
      // Ignore authorization
      ourContext.turnOffAuthorisationSystem();
     
      HarvestedItem hi;
     
      if (item != null) // found an item so we modify
     
        log.debug("Item " + item.getHandle() + " was found locally. Using it to harvest " + itemOaiID + ".");
       
        // FIXME: check for null pointer if for some odd reason we don't have a matching hi
        hi = HarvestedItem.find(ourContext, item.getID());
       
        // Comprate last-harvest on the item versus the last time the item was updated on the OAI provider side
      // If ours is more recent, forgo this item, since it's probably a left-over from a previous harvesting attempt
      Date OAIDatestamp = Utils.parseISO8601Date(header.getChildText("datestamp", OAI_NS));
      Date itemLastHarvest = hi.getHarvestDate();
      if (itemLastHarvest != null && OAIDatestamp.before(itemLastHarvest)) {
        log.info("Item " + item.getHandle() + " was harvested more recently than the last update time reporetd by the OAI server; skipping.");
        return;
      }
     
      // Otherwise, clear and re-import the metadata and bitstreams
        item.clearMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
        if (descMD.size() == 1)
          MDxwalk.ingest(ourContext, item, descMD.get(0));
        else
          MDxwalk.ingest(ourContext, item, descMD);

        // Import the actual bitstreams
        if (harvestRow.getHarvestType() == 3) {
          log.info("Running ORE ingest on: " + item.getHandle());
         
          Bundle[] allBundles = item.getBundles();
          for (Bundle bundle : allBundles) {
            item.removeBundle(bundle);
          }
          ORExwalk.ingest(ourContext, item, oreREM);
        }
       
        scrubMetadata(item);
      }
      else
        // NOTE: did not find, so we create (presumably, there will never be a case where an item already
        // exists in a harvest collection but does not have an OAI_id)
      {
        wi = WorkspaceItem.create(ourContext, targetCollection, false);
        item = wi.getItem();
       
        hi = HarvestedItem.create(ourContext, item.getID(), itemOaiID);
        //item.setOaiID(itemOaiID);
       
        if (descMD.size() == 1)
          MDxwalk.ingest(ourContext, item, descMD.get(0));
        else
          MDxwalk.ingest(ourContext, item, descMD);
       
        if (harvestRow.getHarvestType() == 3) {
          ORExwalk.ingest(ourContext, item, oreREM);
        }
       
        // see if we can do something about the wonky metadata
        scrubMetadata(item);
       
View Full Code Here

      return;
    }

    // If we are only harvesting descriptive metadata, the record should already contain all we need
      List<Element> descMD = record.getChild("metadata", OAI_NS).getChildren();
      IngestionCrosswalk MDxwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey);

      // Otherwise, obtain the ORE ReM and initiate the ORE crosswalk
      IngestionCrosswalk ORExwalk = null;
      Element oreREM = null;
      if (harvestRow.getHarvestType() > 1) {
        oreREM = getMDrecord(harvestRow.getOaiSource(), itemOaiID, OREPrefix).get(0);
        ORExwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.ORESerialKey);
      }

      // Ignore authorization
      ourContext.turnOffAuthorisationSystem();

      HarvestedItem hi;

      if (item != null) // found an item so we modify
      {
        log.debug("Item " + item.getHandle() + " was found locally. Using it to harvest " + itemOaiID + ".");

        // FIXME: check for null pointer if for some odd reason we don't have a matching hi
        hi = HarvestedItem.find(ourContext, item.getID());

        // Compare last-harvest on the item versus the last time the item was updated on the OAI provider side
      // If ours is more recent, forgo this item, since it's probably a left-over from a previous harvesting attempt
      Date OAIDatestamp = Utils.parseISO8601Date(header.getChildText("datestamp", OAI_NS));
      Date itemLastHarvest = hi.getHarvestDate();
      if (itemLastHarvest != null && OAIDatestamp.before(itemLastHarvest)) {
        log.info("Item " + item.getHandle() + " was harvested more recently than the last update time reporetd by the OAI server; skipping.");
        return;
      }

      // Otherwise, clear and re-import the metadata and bitstreams
        item.clearMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
        if (descMD.size() == 1)
            {
                MDxwalk.ingest(ourContext, item, descMD.get(0));
            }
        else
            {
                MDxwalk.ingest(ourContext, item, descMD);
            }

        // Import the actual bitstreams
        if (harvestRow.getHarvestType() == 3) {
          log.info("Running ORE ingest on: " + item.getHandle());

          Bundle[] allBundles = item.getBundles();
          for (Bundle bundle : allBundles) {
            item.removeBundle(bundle);
          }
          ORExwalk.ingest(ourContext, item, oreREM);
        }

        scrubMetadata(item);
      }
      else
        // NOTE: did not find, so we create (presumably, there will never be a case where an item already
        // exists in a harvest collection but does not have an OAI_id)
      {
        wi = WorkspaceItem.create(ourContext, targetCollection, false);
        item = wi.getItem();

        hi = HarvestedItem.create(ourContext, item.getID(), itemOaiID);
        //item.setOaiID(itemOaiID);

        if (descMD.size() == 1)
            {
                MDxwalk.ingest(ourContext, item, descMD.get(0));
            }
        else
            {
                MDxwalk.ingest(ourContext, item, descMD);
            }

        if (harvestRow.getHarvestType() == 3) {
          ORExwalk.ingest(ourContext, item, oreREM);
        }

        // see if we can do something about the wonky metadata
        scrubMetadata(item);
View Full Code Here

               CrosswalkException, IOException, SQLException, AuthorizeException
    {
        String type = getMdType(xmd);

        //First, try to find the IngestionCrosswalk to use
        IngestionCrosswalk xwalk = (IngestionCrosswalk)getCrosswalk(type, IngestionCrosswalk.class);

        // If metadata is not simply applicable to object,
        // let it go with a warning.
        try
        {
            // If we found the IngestionCrosswalk, crosswalk our XML-based content
            if (xwalk != null)
            {
                // Check if our Crosswalk actually wraps another Packager Plugin
                if(xwalk instanceof AbstractPackagerWrappingCrosswalk)
                {
                    // If this crosswalk wraps another Packager Plugin, we can pass it our Packaging Parameters
                    // (which essentially allow us to customize the ingest process of the crosswalk)
                    AbstractPackagerWrappingCrosswalk wrapper = (AbstractPackagerWrappingCrosswalk) xwalk;
                    wrapper.setPackagingParameters(params);
                }

                xwalk.ingest(context, dso, getMdContentAsXml(xmd,callback));
            }
            // Otherwise, try stream-based crosswalk
            else
            {
                StreamIngestionCrosswalk sxwalk =
View Full Code Here

TOP

Related Classes of org.dspace.content.crosswalk.IngestionCrosswalk

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.