Package org.dspace.content

Examples of org.dspace.content.WorkspaceItem


        InputStream bis = null;
        COSDocument cos = null;
        boolean success = false;
        Bundle original = null;
        Bitstream bs = null;
        WorkspaceItem wi = null;

        /** XXX comment out for now
          // XXX for debugging of parameter handling
          if (params != null)
          {
              Enumeration pe = params.propertyNames();
              while (pe.hasMoreElements())
              {
                  String name = (String)pe.nextElement();
                  String v[] = params.getProperties(name);
                  StringBuffer msg = new StringBuffer("PackageParam: ");
                  msg.append(name).append(" = ");
                  for (int i = 0; i < v.length; ++i)
                  {
                      if (i > 0)
                          msg.append(", ");
                      msg.append(v[i]);
                  }
                  log.debug(msg);
              }
          }
        **/
          
        try
        {
            // Save the PDF in a bitstream first, since the parser
            // has to read it as well, and we cannot "rewind" it after that.
            wi = WorkspaceItem.create(context, collection, false);
            Item myitem = wi.getItem();
            original = myitem.createBundle("ORIGINAL");
            bs = original.createBitstream(pkg);
            pkg.close();
            bs.setName("package.pdf");
            setFormatToMIMEType(context, bs, "application/pdf");
            bs.update();
            log.debug("Created bitstream ID="+String.valueOf(bs.getID())+", parsing...");

            crosswalkPDF(context, myitem, bs.retrieve());

            wi.update();
            context.commit();
            success = true;
            log.info(LogManager.getHeader(context, "ingest",
                "Created new Item, db ID="+String.valueOf(myitem.getID())+
                ", WorkspaceItem ID="+String.valueOf(wi.getID())));
            return wi;
        }
        finally
        {
            try
            {
                // Close bitstream input stream and PDF file.
                if (bis != null)
                    bis.close();
                if (cos != null)
                    cos.close();
            }
            catch (IOException ie)
            { }

            // get rid of bitstream and item if ingest fails
            if (!success)
            {
                if (original != null && bs != null)
                    original.removeBitstream(bs);
                if (wi != null)
                    wi.deleteAll();
            }
            context.commit();
        }
    }
View Full Code Here


                + wi.getID() + "item_id=" + wi.getItem().getID()
                + "collection_id=" + wi.getCollection().getID() + "eperson_id="
                + e.getID()));

        // convert into personal workspace
        WorkspaceItem wsi = returnToWorkspace(c, wi);
    }
View Full Code Here

        row.setColumn("item_id", myitem.getID());
        row.setColumn("collection_id", mycollection.getID());
        DatabaseManager.update(c, row);

        int wsi_id = row.getIntColumn("workspace_item_id");
        WorkspaceItem wi = WorkspaceItem.find(c, wsi_id);
        wi.setMultipleFiles(wfi.hasMultipleFiles());
        wi.setMultipleTitles(wfi.hasMultipleTitles());
        wi.setPublishedBefore(wfi.isPublishedBefore());
        wi.update();

        //myitem.update();
        log.info(LogManager.getHeader(c, "return_to_workspace",
                "workflow_item_id=" + wfi.getID() + "workspace_item_id="
                        + wi.getID()));

        // Now remove the workflow object manually from the database
        DatabaseManager.updateQuery(c,
                "DELETE FROM WorkflowItem WHERE workflow_id=" + wfi.getID());
View Full Code Here

        // Add to item as a DC field
        myitem.addDC("description", "provenance", "en", provDescription);
        myitem.update();

        // convert into personal workspace
        WorkspaceItem wsi = returnToWorkspace(c, wi);

        // notify that it's been rejected
        notifyOfReject(c, wi, e, rejection_message);

        log.info(LogManager.getHeader(c, "reject_workflow", "workflow_item_id="
View Full Code Here

        {
            return -1;
        }
        else
        {
            WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem();
            int i = wi.getPageReached();

            return i;
        }
    }
View Full Code Here

    private void updatePageReached(SubmissionInfo subInfo, int page)
            throws SQLException, AuthorizeException, IOException
    {
        if (!subInfo.isInWorkflow() && subInfo.getSubmissionItem() != null)
        {
            WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem();

            if (page > wi.getPageReached())
            {
                wi.setPageReached(page);
                wi.update();
            }
        }
    }
View Full Code Here

     * @param record a JDOM Element containing the actual PMH record with descriptive metadata.
     * @param OREPrefix the metadataprefix value used by the remote PMH server to disseminate ORE. Only used for collections set up to harvest content.
     */
    private void processRecord(Element record, String OREPrefix) throws SQLException, AuthorizeException, IOException, CrosswalkException, HarvestingException, ParserConfigurationException, SAXException, TransformerException
    {
      WorkspaceItem wi = null;
      Date timeStart = new Date();
           
      // grab the oai identifier
      String itemOaiID = record.getChild("header", OAI_NS).getChild("identifier", OAI_NS).getText();
      Element header = record.getChild("header",OAI_NS);
     
      // look up the item corresponsing to the OAI identifier
      Item item = HarvestedItem.getItemByOAIId(ourContext, itemOaiID, targetCollection.getID());
           
      // Make sure the item hasn't been deleted in the mean time
    if (header.getAttribute("status") != null && header.getAttribute("status").getValue().equals("deleted")) {
      log.info("Item " + itemOaiID + " has been marked as deleted on the OAI server.");
      if (item != null)
        targetCollection.removeItem(item);
     
      ourContext.restoreAuthSystemState();     
      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);
       
        // see if a handle can be exracted for the item
        String handle = extractHandle(item);
       
        if (handle != null)
        {
          DSpaceObject dso = HandleManager.resolveToObject(ourContext, handle);
          if (dso != null)
            throw new HarvestingException("Handle collision: attempted to re-assign handle '" + handle + "' to an incoming harvested item '" + hi.getOaiID() + "'.");                   
        }
       
        try {
          item = InstallItem.installItem(ourContext, wi, handle);
          //item = InstallItem.installItem(ourContext, wi);
        }
        // clean up the workspace item if something goes wrong before
        catch(SQLException se) {
          wi.deleteWrapper();
          throw se;
        }
        catch(IOException ioe) {
          wi.deleteWrapper();
          throw ioe;
        }
        catch(AuthorizeException ae) {
          wi.deleteWrapper();
          throw ae;
        }
      }
     
      // Now create the special ORE bundle and drop the ORE document in it
View Full Code Here

            {
                pis = new CountedInputStream(pis, contentLength);
                log.debug("put: Using CountedInputStream, length="
                        + String.valueOf(contentLength));
            }
            WorkspaceItem wi = sip.ingest(this.context, this.collection, pis,
                    PackageParameters.create(this.request), null);
            WorkflowItem wfi = WorkflowManager.startWithoutNotify(this.context, wi);

            // get new item's location: if workflow completed, then look
            // for handle (but be ready for disappointment); otherwise,
View Full Code Here

        try {
            // make a list of workflow items
            while (tri.hasNext()) {
                TableRow row = tri.next();
                WorkspaceItem wi = WorkspaceItem.find(c, row.getIntColumn("workspace_item_id"));
                wsItems.add(wi);
            }
        } finally {
            if (tri != null) {
                tri.close();
View Full Code Here

            // If the license page was the 1st page in the Submission process,
            // then delete the submission if they reject the license!
            if (!subInfo.isInWorkflow()
                    && (SubmissionController.getStepReached(subInfo) <= SubmissionController.FIRST_STEP))
            {
                WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem();
                wi.deleteAll();

                // commit changes
                context.commit();
            }
View Full Code Here

TOP

Related Classes of org.dspace.content.WorkspaceItem

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.