Package org.purl.sword.base

Examples of org.purl.sword.base.SWORDErrorException


    //
    // determine if this is an acceptable file format
    if (!swordConfig.isAcceptableContentType(context, deposit.getContentType(), collection))
    {
      log.error("Unacceptable content type detected: " + deposit.getContentType() + " for collection " + collection.getID());
      throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT,
          "Unacceptable content type in deposit request: " + deposit.getContentType());
    }

    // determine if this is an acceptable packaging type for the deposit
    // if not, we throw a 415 HTTP error (Unsupported Media Type, ERROR_CONTENT)
    if (!swordConfig.isSupportedMediaType(deposit.getPackaging(), this.collection))
    {
      log.error("Unacceptable packaging type detected: " + deposit.getPackaging() + "for collection" + collection.getID());
      throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT,
          "Unacceptable packaging type in deposit request: " + deposit.getPackaging());
    }

    String tempDir = swordConfig.getTempDir();
    String tempFile = tempDir + "/" + swordService.getTempFilename();
View Full Code Here


    try
    {
      String baseUrl = this.getBaseDepositUrl();
      if (baseUrl.length() == location.length())
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is incomplete");
      }
      String handle = location.substring(baseUrl.length());
      if (handle.startsWith("/"))
      {
        handle = handle.substring(1);
      }
      if ("".equals(handle))
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is incomplete");
      }

      DSpaceObject dso = HandleManager.resolveToObject(context, handle);

      if (!(dso instanceof Collection))
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL does not resolve to a valid collection");
      }

      return (Collection) dso;
    }
    catch (SQLException e)
View Full Code Here

    try
    {
      String baseUrl = this.getBaseDepositUrl();
      if (baseUrl.length() == location.length())
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is incomplete");
      }
      String handle = location.substring(baseUrl.length());
      if (handle.startsWith("/"))
      {
        handle = handle.substring(1);
      }
      if ("".equals(handle))
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is incomplete");
      }

      DSpaceObject dso = HandleManager.resolveToObject(context, handle);

      if (!(dso instanceof Collection) && !(dso instanceof Item))
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL does not resolve to a valid deposit target");
      }

      return dso;
    }
    catch (SQLException e)
View Full Code Here

        {
          return dso;
        }
        else
        {
          throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL,
              "Service Document request does not refer to a DSpace Collection or Community");
        }
      }
      else if (url.startsWith(mlBase))
      {
        // we are dealing with a bitstream media link

        // find the index of the "/bitstream/" segment of the url
        int bsi = url.indexOf("/bitstream/");

        // subtsring the url from the end of this "/bitstream/" string, to get the bitstream id
        String bsid = url.substring(bsi + 11);

        // strip off extraneous slashes
        if (bsid.endsWith("/"))
        {
          bsid = bsid.substring(0, url.length() - 1);
        }

        Bitstream bitstream = Bitstream.find(context, Integer.parseInt(bsid));
        return bitstream;
      }
      else
      {
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL,
            "Unable to recognise URL as a valid service document: " + url);
      }
    }
    catch (SQLException e)
    {
View Full Code Here

      // we are dealing with a default media-link, indicating that something
      // is wrong

      // FIXME: what do we actually do about this situation?
      // throwing an error for the time being
      throw new SWORDErrorException(DSpaceSWORDErrorCodes.MEDIA_UNAVAILABLE, "The media link you requested is not available");
    }

    // extract the thing that we are trying to get a media entry on
    DSpaceObject dso = urlManager.extractDSpaceObject(url);

    // now, the media entry should always be to an actual file, so we only care that this is a bitstream
    if (!(dso instanceof Bitstream))
    {
      throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The url you provided does not resolve to an appropriate object");
    }

    // now construct the atom entry for the bitstream
    DSpaceATOMEntry dsatom = new BitstreamEntryGenerator(swordService);
    SWORDEntry entry = dsatom.getSWORDEntry(dso);
View Full Code Here

      // ingest the item
      WorkspaceItem wsi = pi.ingest(context, collection, is, params, licence);
      if (wsi == null)
      {
        swordService.message("Failed to ingest the package; throwing exception");
        throw new SWORDErrorException(DSpaceSWORDErrorCodes.UNPACKAGE_FAIL, "METS package ingester failed to unpack package");
      }
     
      // now we can inject the newly constructed item into the workflow
      WorkflowItem wfi = WorkflowManager.startWithoutNotify(context, wsi);
      swordService.message("Workflow process started");
View Full Code Here

    // the throw a 415 (ERROR_CONTENT) until further notice
    //
    // determine if this is an acceptable file format
    if (!swordConfig.isAcceptableContentType(context, deposit.getContentType(), item))
    {
      throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT,
          "Unacceptable content type in deposit request: " + deposit.getContentType());
    }

    // determine if this is an acceptable packaging type for the deposit
    // if not, we throw a 415 HTTP error (Unsupported Media Type, ERROR_CONTENT)
    if (!swordConfig.isSupportedMediaType(deposit.getPackaging(), this.item))
    {
      throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT,
          "Unacceptable packaging type in deposit request: " + deposit.getPackaging());
    }

    String tempDir = swordConfig.getTempDir();
    String tempFile = tempDir + "/" + swordService.getTempFilename();
View Full Code Here

    if (dso instanceof Collection)
    {
      SWORDIngester ingester = (SWORDIngester) PluginManager.getNamedPlugin(SWORDIngester.class, deposit.getPackaging());
      if (ingester == null)
      {
        throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT, "No ingester configured for this package type");
      }
      return ingester;
    }
    else if (dso instanceof Item)
    {
View Full Code Here

   
    // Allow users to force the throwing of a SWORD error exception by setting
    // the OBO user to 'error'
    if ((sdr.getOnBehalfOf() != null) && (sdr.getOnBehalfOf().equals("error"))) {
      // Throw the error exception
      throw new SWORDErrorException(ErrorCodes.MEDIATION_NOT_ALLOWED, "Mediated deposits not allowed");
    }
   
    // Create and return a dummy ServiceDocument
    ServiceDocument document = new ServiceDocument();
    Service service = new Service("1.3", true, true);
View Full Code Here

    }
   
    // Check this is a collection that takes obo deposits, else thrown an error
    if (((deposit.getOnBehalfOf() != null) && (!deposit.getOnBehalfOf().equals(""))) &&
          (!deposit.getLocation().contains("deposit?user="))) {
      throw new SWORDErrorException(ErrorCodes.MEDIATION_NOT_ALLOWED,
                                "Mediated deposit not allowed to this collection");
    }
   
    // Get the filenames
    StringBuffer filenames = new StringBuffer("Deposit file contained: ");
View Full Code Here

TOP

Related Classes of org.purl.sword.base.SWORDErrorException

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.