Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract JCR-agnostic resource interfaces out of FedoraResource/Datast…
…ream
- Loading branch information
Showing
7 changed files
with
161 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
fcrepo-kernel/src/main/java/org/fcrepo/kernel/resources/BinarySource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.fcrepo.kernel.resources; | ||
|
||
import java.io.InputStream; | ||
import java.net.URI; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 9/16/14 | ||
*/ | ||
public interface BinarySource<T, V> extends Resource<T> { | ||
/** | ||
* Get the description document for this resource | ||
* @return | ||
*/ | ||
RdfSource<T> getDescription(); | ||
|
||
/** | ||
* @return The InputStream of content associated with this datastream. | ||
*/ | ||
InputStream getContent(); | ||
|
||
/** | ||
* @return The Binary content associated with this datastream. | ||
*/ | ||
V getBinaryContent(); | ||
|
||
/** | ||
* @return The size in bytes of content associated with this datastream. | ||
*/ | ||
long getContentSize(); | ||
|
||
/** | ||
* Get the pre-calculated content digest for the binary payload | ||
* @return a URI with the format algorithm:value | ||
*/ | ||
URI getContentDigest(); | ||
|
||
/** | ||
* @return The MimeType of content associated with this datastream. | ||
*/ | ||
String getMimeType(); | ||
|
||
/** | ||
* Return the file name for the binary content | ||
* @return original file name for the binary content, or the object's id. | ||
*/ | ||
String getFilename(); | ||
} |
11 changes: 11 additions & 0 deletions
11
fcrepo-kernel/src/main/java/org/fcrepo/kernel/resources/Container.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.fcrepo.kernel.resources; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 9/16/14 | ||
*/ | ||
public interface Container<T> extends RdfSource<T>, Collection<Resource> { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
fcrepo-kernel/src/main/java/org/fcrepo/kernel/resources/RdfSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.fcrepo.kernel.resources; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 9/16/14 | ||
*/ | ||
public interface RdfSource<T> extends Resource<T> { | ||
} |
75 changes: 75 additions & 0 deletions
75
fcrepo-kernel/src/main/java/org/fcrepo/kernel/resources/Resource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.fcrepo.kernel.resources; | ||
|
||
import org.fcrepo.kernel.rdf.IdentifierTranslator; | ||
import org.fcrepo.kernel.utils.iterators.RdfStream; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 9/16/14 | ||
*/ | ||
public interface Resource<T> { | ||
|
||
/** | ||
* @return The JCR node that backs this object. | ||
*/ | ||
T getNode(); | ||
|
||
/** | ||
* Get the path to the JCR node | ||
* @return path | ||
*/ | ||
String getPath(); | ||
|
||
/** | ||
* Check if this object uses a given mixin | ||
* @return a collection of mixin names | ||
*/ | ||
boolean hasType(final String type); | ||
|
||
/** | ||
* Check if a resource was created in this session | ||
* @return if resource created in this session | ||
*/ | ||
Boolean isNew(); | ||
|
||
/** | ||
* Get the date this datastream was created | ||
* @return created date | ||
*/ | ||
Date getCreatedDate(); | ||
|
||
/** | ||
* Get the date this datastream was last modified | ||
* @return last modified date | ||
*/ | ||
Date getLastModifiedDate(); | ||
|
||
/** | ||
* Construct an ETag value from the last modified date and path. JCR has a | ||
* mix:etag type, but it only takes into account binary properties. We | ||
* actually want whole-object etag data. TODO : construct and store an ETag | ||
* value on object modify | ||
* | ||
* @return constructed etag value | ||
*/ | ||
String getEtagValue(); | ||
|
||
/** | ||
* Return the RDF properties of this object using the provided context | ||
* @param graphSubjects | ||
* @param context | ||
* @return | ||
*/ | ||
RdfStream getTriples(final IdentifierTranslator graphSubjects, final Class<? extends RdfStream> context); | ||
|
||
/** | ||
* Return the RDF properties of this object using the provided contexts | ||
* @param graphSubjects | ||
* @param contexts | ||
* @return | ||
*/ | ||
RdfStream getTriples(IdentifierTranslator graphSubjects, Iterable<? extends Class<? extends RdfStream>> contexts); | ||
|
||
} |