Examples of AtomDocumentResponse


Examples of org.purl.sword.base.AtomDocumentResponse

      log.info(LogManager.getHeader(context, "sword_atom_document_request", "username=" + adr.getUsername()));

      // prep the service request, then get the service document out of it
      SWORDService service = new SWORDService(sc);
      MediaEntryManager manager = new MediaEntryManager(service);
      AtomDocumentResponse doc = manager.getMediaEntry(adr.getLocation());

      return doc;
    }
    catch (DSpaceSWORDException e)
    {
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

  public AtomDocumentResponse getMediaEntry(String url)
      throws DSpaceSWORDException, SWORDErrorException
  {
    SWORDUrlManager urlManager = swordService.getUrlManager();

    AtomDocumentResponse response = new AtomDocumentResponse(200);

    if (url == null || urlManager.isBaseMediaLinkUrl(url))
    {
      // 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);
    response.setEntry(entry);
    return response;
  }
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

      // Set the deposit location
      adr.setLocation(getUrl(request));
     
      // Generate the response
      AtomDocumentResponse dr = myRepository.doAtomDocument(adr);
 
      // Print out the Deposit Response
      response.setStatus(dr.getHttpResponse());
      response.setContentType("application/atom+xml; charset=UTF-8");
      PrintWriter out = response.getWriter();
      out.write(dr.marshall());
      out.flush();
    } catch (SWORDAuthenticationException sae) {
      // Ask for credentials again
      String s = "Basic realm=\"SWORD\"";
      response.setHeader("WWW-Authenticate", s);
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

        (!username.equalsIgnoreCase(password))) ) {
      // User not authenticated
      throw new SWORDAuthenticationException("Bad credentials");
    }
   
    return new AtomDocumentResponse(HttpServletResponse.SC_OK);
  }
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

        (!username.equalsIgnoreCase(password))) ) {
      // User not authenticated
      throw new SWORDAuthenticationException("Bad credentials");
    }
   
    return new AtomDocumentResponse(HttpServletResponse.SC_OK);
  }
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

  public AtomDocumentResponse getMediaEntry(String url)
      throws DSpaceSWORDException, SWORDErrorException
  {
    SWORDUrlManager urlManager = swordService.getUrlManager();

    AtomDocumentResponse response = new AtomDocumentResponse(200);

    if (url == null || urlManager.isBaseMediaLinkUrl(url))
    {
      // 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);
    response.setEntry(entry);
    return response;
  }
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

      // Set the deposit location
      adr.setLocation(getUrl(request));
     
      // Generate the response
      AtomDocumentResponse dr = myRepository.doAtomDocument(adr);
 
      // Print out the Deposit Response
      response.setStatus(dr.getHttpResponse());
      response.setContentType("application/atom+xml; charset=UTF-8");
      PrintWriter out = response.getWriter();
      out.write(dr.marshall());
      out.flush();
    } catch (SWORDAuthenticationException sae) {
      // Ask for credentials again
      String s = "Basic realm=\"SWORD\"";
      response.setHeader("WWW-Authenticate", s);
View Full Code Here

Examples of org.purl.sword.base.AtomDocumentResponse

      log.info(LogManager.getHeader(context, "sword_atom_document_request", "username=" + adr.getUsername()));

      // prep the service request, then get the service document out of it
      SWORDService service = new SWORDService(sc);
      MediaEntryManager manager = new MediaEntryManager(service);
      AtomDocumentResponse doc = manager.getMediaEntry(adr.getLocation());

      return doc;
    }
    catch (DSpaceSWORDException e)
    {
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.