Examples of SwordError


Examples of org.swordapp.server.SwordError

  public void deleteMediaResource(Context context, Item item) throws SwordError, DSpaceSwordException
  {
    WorkflowTools wft = new WorkflowTools();
    if (item.isArchived() || item.isWithdrawn())
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been archived, and can no longer be modified");
    }
    if (wft.isItemInWorkflow(context, item))
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been injected into the review workflow, and can no longer be modified");
    }
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

      for (Bundle bundle : bitstream.getBundles())
      {
                // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
                if (!"ORIGINAL".equals(bundle.getName()))
                {
                    throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The file is not in a bundle which can be modified");
                }

        for (Item item : bundle.getItems())
        {
          this.deleteMediaResource(context, item);
View Full Code Here

Examples of org.swordapp.server.SwordError

        // turned off by default, and strongly advised against.  Nonetheless, it is used
        // by some DepositMO aware extensions, so must be supported (as shown below)
        boolean fileReplace = ConfigurationManager.getBooleanProperty("swordv2-server", "workflowmanagerdefault.file-replace.enable");
        if (!fileReplace)
        {
            throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "DSpace does not support file replace; you should DELETE the original file and PUT the new one");
        }

        // this is equivalent to asking whether the media resource in the item can be deleted
    try
    {
      for (Bundle bundle : bitstream.getBundles())
      {
                // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
                if (!"ORIGINAL".equals(bundle.getName()))
                {
                    throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The file is not in a bundle which can be modified");
                }
               
        for (Item item : bundle.getItems())
        {
          this.replaceResourceContent(context, item);
View Full Code Here

Examples of org.swordapp.server.SwordError

    public void addResourceContent(Context context, Item item) throws SwordError, DSpaceSwordException
  {
    WorkflowTools wft = new WorkflowTools();
    if (item.isArchived() || item.isWithdrawn())
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been archived, and can no longer be modified");
    }
    if (wft.isItemInWorkflow(context, item))
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been injected into the review workflow, and can no longer be modified");
    }
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

        // otherwise, lookup the state of the item
    WorkflowTools wft = new WorkflowTools();
    if (item.isArchived() || item.isWithdrawn())
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been archived, and can no longer be modified");
    }
    if (wft.isItemInWorkflow(context, item))
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been injected into the review workflow, and can no longer be modified");
    }
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

  public void deleteItem(Context context, Item item) throws SwordError, DSpaceSwordException
  {
    WorkflowTools wft = new WorkflowTools();
    if (item.isArchived() || item.isWithdrawn())
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been archived, and can no longer be modified");
    }
    if (wft.isItemInWorkflow(context, item))
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been injected into the review workflow, and can no longer be modified");
    }
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

  public void modifyState(Context context, Item item) throws SwordError, DSpaceSwordException
  {
    WorkflowTools wft = new WorkflowTools();
    if (item.isArchived() || item.isWithdrawn())
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been archived, and can no longer be modified");
    }
    if (wft.isItemInWorkflow(context, item))
    {
      throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The item has already been injected into the review workflow, and can no longer be modified");
    }
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

        // if no ingester, then
        // look to see if there's an ingester for the package format
        ingester = (SwordContentIngester) PluginManager.getNamedPlugin("swordv2-server", SwordContentIngester.class, deposit.getPackaging());
        if (ingester == null)
        {
            throw new SwordError(UriRegistry.ERROR_CONTENT, "No ingester configured for this package type");
        }
        return ingester;
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

            throws DSpaceSwordException, SwordError
    {
    SwordEntryIngester ingester = (SwordEntryIngester) PluginManager.getSinglePlugin("swordv2-server", SwordEntryIngester.class);
    if (ingester == null)
    {
      throw new SwordError(UriRegistry.ERROR_CONTENT, "No ingester configured for handling sword entry documents");
    }
    return ingester;
  }
View Full Code Here

Examples of org.swordapp.server.SwordError

    boolean mediated = ConfigurationManager.getBooleanProperty("swordv2-server", "on-behalf-of.enable");
    if (!mediated && obo != null)
    {
      // user is trying to do a mediated deposit on a repository which does not support it
      log.error("Attempted mediated deposit on service not configured to do so");
      throw new SwordError(UriRegistry.ERROR_MEDIATION_NOT_ALLOWED, "Mediated deposit to this service is not permitted");
    }

    log.info(LogManager.getHeader(context, "sword_authenticate", "username=" + un + ",on_behalf_of=" + obo));
   
    try
    {
      // attempt to authenticate the primary user
      SwordContext sc = new SwordContext();
      EPerson ep = null;
      boolean authenticated = false;
      if (this.authenticates(context, un, pw))
      {
        // if authenticated, obtain the eperson object
        ep = context.getCurrentUser();

        if (ep != null)
        {
          authenticated = true;
          sc.setAuthenticated(ep);
           // Set any special groups - invoke the authentication mgr.
                int[] groupIDs = AuthenticationManager.getSpecialGroups(context, null);

                for (int i = 0; i < groupIDs.length; i++)
                {
                    context.setSpecialGroup(groupIDs[i]);
                    log.debug("Adding Special Group id="+String.valueOf(groupIDs[i]));
                }
         
          sc.setAuthenticatorContext(context);
          sc.setContext(context);
        }

        // if there is an onBehalfOfuser, then find their eperson
        // record, and if it exists set it.  If not, then the
        // authentication process fails
        EPerson epObo = null;
        if (obo != null)
        {
          epObo = EPerson.findByEmail(context, obo);
          if (epObo == null)
          {
            epObo = EPerson.findByNetid(context, obo);
          }

          if (epObo != null)
          {
            sc.setOnBehalfOf(epObo);
            Context oboContext = this.constructContext();
            oboContext.setCurrentUser(epObo);
                    // Set any special groups - invoke the authentication mgr.
                      int[] groupIDs = AuthenticationManager.getSpecialGroups(oboContext, null);

                      for (int i = 0; i < groupIDs.length; i++)
                      {
                          oboContext.setSpecialGroup(groupIDs[i]);
                          log.debug("Adding Special Group id="+String.valueOf(groupIDs[i]));
                      }
            sc.setContext(oboContext);
          }
          else
          {
            authenticated = false;
            throw new SwordError(UriRegistry.ERROR_TARGET_OWNER_UNKNOWN, "unable to identify on-behalf-of user: " + obo);
          }
        }
      }

      if (!authenticated)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.