Class DefaultOcflObjectSession

    • Constructor Detail

      • DefaultOcflObjectSession

        public DefaultOcflObjectSession​(String sessionId,
                                        edu.wisc.library.ocfl.api.MutableOcflRepository ocflRepo,
                                        String ocflObjectId,
                                        Path objectStaging,
                                        com.fasterxml.jackson.databind.ObjectReader headerReader,
                                        com.fasterxml.jackson.databind.ObjectWriter headerWriter,
                                        CommitType commitType,
                                        Cache<String,​ResourceHeaders> headersCache)
    • Method Detail

      • writeResource

        public ResourceHeaders writeResource​(ResourceHeaders headers,
                                             InputStream content)
        Description copied from interface: OcflObjectSession
        Writes a resource to the session.
        Specified by:
        writeResource in interface OcflObjectSession
        Parameters:
        headers - the resource's headers
        content - the resource's content, may be null if the resource has no content
        Returns:
        the resource headers that were written to disk, these may differ from the input headers
      • deleteContentFile

        public void deleteContentFile​(ResourceHeaders headers)
        Description copied from interface: OcflObjectSession
        Deletes a content file from the session, and updates the associated headers. If the resource was added in the current session, then its headers are also deleted and it is as if the resource never existed.
        Specified by:
        deleteContentFile in interface OcflObjectSession
        Parameters:
        headers - the updated resource headers
      • deleteResource

        public void deleteResource​(String resourceId)
        Description copied from interface: OcflObjectSession
        Deletes all files associated to the specified resource. If the resource is the root resource of the object, then the object will be deleted.
        Specified by:
        deleteResource in interface OcflObjectSession
        Parameters:
        resourceId - the Fedora resource id of the resource to delete
      • containsResource

        public boolean containsResource​(String resourceId)
        Description copied from interface: OcflObjectSession
        Indicates if the resource exists in the session
        Specified by:
        containsResource in interface OcflObjectSession
        Parameters:
        resourceId - the Fedora resource id
        Returns:
        true if the resource exists in the session
      • readHeaders

        public ResourceHeaders readHeaders​(String resourceId,
                                           String versionNumber)
        Description copied from interface: OcflObjectSession
        Reads a specific version of a resource's header file.
        Specified by:
        readHeaders in interface OcflObjectSession
        Parameters:
        resourceId - the Fedora resource id to read
        versionNumber - the version to read, or null for HEAD
        Returns:
        the resource's headers
      • readContent

        public ResourceContent readContent​(String resourceId,
                                           String versionNumber)
        Description copied from interface: OcflObjectSession
        Reads a specific version of a resource's content.
        Specified by:
        readContent in interface OcflObjectSession
        Parameters:
        resourceId - the Fedora resource id to read
        versionNumber - the version to read, or null for HEAD
        Returns:
        the resource's content
      • streamResourceHeaders

        public Stream<ResourceHeaders> streamResourceHeaders()
        This method is NOT currently using the ResourceHeader cache. It should not matter because this method is currently only used when reindexing. If it is ever used anywhere else, we may want to figure out how to get it to use the cache.
        Specified by:
        streamResourceHeaders in interface OcflObjectSession
        Returns:
        ResourceHeader stream
      • versionCreationTimestamp

        public void versionCreationTimestamp​(OffsetDateTime timestamp)
        Description copied from interface: OcflObjectSession
        Sets the timestamp that's stamped on the OCFL version. If this value is not set, the current system time at the time the version is created is used.
        Specified by:
        versionCreationTimestamp in interface OcflObjectSession
        Parameters:
        timestamp - version creation timestamp
      • versionAuthor

        public void versionAuthor​(String name,
                                  String address)
        Description copied from interface: OcflObjectSession
        Sets the author the OCFL version is attributed to.
        Specified by:
        versionAuthor in interface OcflObjectSession
        Parameters:
        name - the author's name
        address - the author's address
      • commitType

        public void commitType​(CommitType commitType)
        Description copied from interface: OcflObjectSession
        Sets the commit behavior -- create a new version or update the mutable HEAD.
        Specified by:
        commitType in interface OcflObjectSession
        Parameters:
        commitType - the commit behavior
      • commit

        public void commit()
        Description copied from interface: OcflObjectSession
        Commits the session, persisting all changes to a new OCFL version.
        Specified by:
        commit in interface OcflObjectSession
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface OcflObjectSession
        Returns:
        true if the session is still open