Class ContentExposingResource

    • Method Detail

      • getContent

        protected javax.ws.rs.core.Response getContent​(int limit,
                                                       FedoraResource resource)
                                                throws IOException
        This method returns an HTTP response with content body appropriate to the following arguments.
        Parameters:
        limit - is the number of child resources returned in the response, -1 for all
        resource - the fedora resource
        Returns:
        HTTP response
        Throws:
        IOException - in case of error extracting content
      • hasLenientPreferHeader

        protected boolean hasLenientPreferHeader()
        Utility to check if the Prefer header contains handling="lenient"
        Returns:
        True if handling="lenient" was sent.
      • getBinaryContent

        protected javax.ws.rs.core.Response getBinaryContent​(String rangeValue,
                                                             FedoraResource resource)
                                                      throws IOException
        Get the binary content of a datastream
        Parameters:
        rangeValue - the range value
        resource - the fedora resource
        Returns:
        Binary blob
        Throws:
        IOException - if io exception occurred
      • buildLink

        protected static String buildLink​(String linkUri,
                                          String relation)
        Utility function for building a Link.
        Parameters:
        linkUri - String of URI for the link.
        relation - the relation string.
        Returns:
        the string version of the link.
      • unpackLinks

        protected List<StringunpackLinks​(List<String> rawLinks)
        Multi-value Link header values parsed by the javax.ws.rs.core are not split out by the framework Therefore we must do this ourselves.
        Parameters:
        rawLinks - the list of unprocessed links
        Returns:
        List of strings containing one link value per string.
      • checkCacheControlHeaders

        protected void checkCacheControlHeaders​(javax.ws.rs.core.Request request,
                                                javax.servlet.http.HttpServletResponse servletResponse,
                                                FedoraResource resource,
                                                Transaction transaction)
        Evaluate the cache control headers for the request to see if it can be served from the cache.
        Parameters:
        request - the request
        servletResponse - the servlet response
        resource - the fedora resource
        transaction - the transaction
      • addCacheControlHeaders

        protected void addCacheControlHeaders​(javax.servlet.http.HttpServletResponse servletResponse,
                                              FedoraResource resource,
                                              Transaction transaction)
        Add ETag and Last-Modified cache control headers to the response

        Note: In this implementation, the HTTP headers for ETags and Last-Modified dates are swapped for fedora:Binary resources and their descriptions. Here, we are drawing a distinction between the HTTP resource and the LDP resource. As an HTTP resource, the last-modified header should reflect when the resource at the given URL was last changed. With fedora:Binary resources and their descriptions, this is a little complicated, for the descriptions have, as their subjects, the binary itself. And the fedora:lastModified property produced by that NonRdfSourceDescription refers to the last-modified date of the binary -- not the last-modified date of the NonRdfSourceDescription.

        Parameters:
        servletResponse - the servlet response
        resource - the fedora resource
        transaction - the transaction
      • evaluateRequestPreconditions

        protected void evaluateRequestPreconditions​(javax.ws.rs.core.Request request,
                                                    javax.servlet.http.HttpServletResponse servletResponse,
                                                    FedoraResource resource,
                                                    Transaction transaction)
        Evaluate request preconditions to ensure the resource is the expected state
        Parameters:
        request - the request
        servletResponse - the servlet response
        resource - the resource
        transaction - the transaction
      • createUpdateResponse

        protected javax.ws.rs.core.Response createUpdateResponse​(FedoraResource resource,
                                                                 boolean created)
        Create the appropriate response after a create or update request is processed. When a resource is created, examine the Prefer and Accept headers to determine whether to include a representation. By default, the URI for the created resource is return as plain text. If a minimal response is requested, then no body is returned. If a non-minimal return is requested, return the RDF for the created resource in the appropriate RDF serialization.
        Parameters:
        resource - The created or updated Fedora resource.
        created - True for a newly-created resource, false for an updated resource.
        Returns:
        204 No Content (for updated resources), 201 Created (for created resources) including the resource URI or content depending on Prefer headers.
      • getBinaryResourceMediaType

        protected javax.ws.rs.core.MediaType getBinaryResourceMediaType​(FedoraResource resource)
        This method returns a MediaType for a binary resource. If the resource's media type is syntactically incorrect, it will return 'application/octet-stream' as the media type.
        Parameters:
        resource - the fedora resource
        Returns:
        the media type of of a binary resource
      • checksumURI

        protected static URI checksumURI​(String checksum)
        Create a checksum URI object.
        Parameters:
        checksum - the checksum
        Returns:
        the new URI, or null
      • getChildrenLimit

        protected int getChildrenLimit()
        Calculate the max number of children to display at once.
        Returns:
        the limit of children to display.
      • hasRestrictedPath

        protected static void hasRestrictedPath​(String externalPath)
        Check if a path has a segment prefixed with fcr: that is not fcr:metadata or fcr:acl
        Parameters:
        externalPath - the path.
      • asNode

        protected org.apache.jena.graph.Node asNode​(FedoraResource resource)
        This is a helper method for using the idTranslator to convert this resource into an associated Jena Node.
        Parameters:
        resource - to be converted into a Jena Node
        Returns:
        the Jena node