Package org.dspace.content

Examples of org.dspace.content.WorkspaceItem


   
    String reason = request.getParameter("reason");

    if (reason != null && reason.length() > 1)
    {
            WorkspaceItem wsi = WorkflowManager.reject(context, workflowItem,context.getCurrentUser(), reason);
     
      //Load the Submission Process for the collection this WSI is associated with
            Collection c = wsi.getCollection();
            SubmissionConfigReader subConfigReader = new SubmissionConfigReader();
            SubmissionConfig subConfig = subConfigReader.getSubmissionConfig(c.getHandle(), false);
           
            // Set the "stage_reached" column on the workspace item
            // to the LAST page of the LAST step in the submission process
            // (i.e. the page just before "Complete", which is at NumSteps-1)
            int lastStep = subConfig.getNumberOfSteps()-2;
            wsi.setStageReached(lastStep);
            wsi.setPageReached(AbstractProcessingStep.LAST_PAGE_REACHED);
            wsi.update();
           
            context.commit();
           
            //Submission rejected.  Log this information
            log.info(LogManager.getHeader(context, "reject_workflow", "workflow_item_id="
                    + wsi.getID() + "item_id=" + wsi.getItem().getID()
                    + "collection_id=" + wsi.getCollection().getID()
                    + "eperson_id=" + context.getCurrentUser().getID()));
     
      // Return no errors.
      return null;
    }
View Full Code Here


        if (workspaceID != null)
        {
            try
            {
                // load the workspace item
                WorkspaceItem wi = WorkspaceItem.find(context, Integer
                        .parseInt(workspaceID));

                //load submission information
                SubmissionInfo si = SubmissionInfo.load(request, wi);
               
                //TD: Special case - If a user is resuming a submission
                //where the submission process now has less steps, then
                //we will need to reset the stepReached in the database
                //(Hopefully this will never happen, but just in case!)
                if(getStepReached(si) >= si.getSubmissionConfig().getNumberOfSteps())
                {
                    //update Stage Reached to the last step in the Process
                    int lastStep = si.getSubmissionConfig().getNumberOfSteps()-1;
                    wi.setStageReached(lastStep);
                   
                    //flag that user is on last page of last step
                    wi.setPageReached(AbstractProcessingStep.LAST_PAGE_REACHED);
                   
                    //commit all changes to database immediately
                    wi.update();
                    context.commit();
                   
                    //update submission info
                    si.setSubmissionItem(wi);
                }
View Full Code Here

        }
        else if (buttonPressed.equals("submit_remove"))
        {
            // User wants to cancel and remove
            // Cancellation page only applies to workspace items
            WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem();

            wi.deleteAll();

            JSPManager.showJSP(request, response,
                    "/submit/cancelled-removed.jsp");

            context.complete();
View Full Code Here

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

            if (step > wi.getStageReached())
            {
                wi.setStageReached(step);
                wi.setPageReached(1); // reset page reached back to 1 (since
                                        // it's page 1 of the new step)
                wi.update();
            }
        }
    }
View Full Code Here

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

            wi.setStageReached(step);
            wi.setPageReached(page);
            wi.update();
        }
    }
View Full Code Here

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

            // Uninitialised workspace items give "-1" as the stage reached
            // this is a special value used by the progress bar, so we change
            // it to "FIRST_STEP"
            if (i == -1)
View Full Code Here

     */
    public double getMaxStepAndPageReached() throws SQLException {
       
        if (this.submission instanceof WorkspaceItem)
        {
            WorkspaceItem workspaceItem = (WorkspaceItem) submission;
           
            int step = workspaceItem.getStageReached();
            if(step<0)
                step=0;
           
            int page = workspaceItem.getPageReached();
            if (page < 0)
                page = 0;
           
            return Double.valueOf(step + "." + page).doubleValue();
        }
View Full Code Here

    protected DAVResource[] children() throws SQLException
    {
        EPerson ep = this.context.getCurrentUser();
        if (ep != null)
        {
            WorkspaceItem wi[] = WorkspaceItem.findByEPerson(this.context, ep);
            log.debug("children(): Got " + String.valueOf(wi.length)
                    + " Workspace Items.");
            DAVResource result[] = new DAVResource[wi.length];
            for (int i = 0; i < wi.length; ++i)
            {
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 corresponding 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.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);

        // see if a handle can be extracted 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

{

    public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {
        try
        {
            WorkspaceItem workspaceItem = WorkspaceItem.create(context, nativeItem.getOwningCollection(), false);
            Item itemNew = workspaceItem.getItem();
            itemNew.update();
            return itemNew;
        }catch (SQLException e) {
            throw new RuntimeException(e.getMessage(), e);
        }catch (AuthorizeException e) {
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.