Skip to content

Commit

Permalink
Allow updating mimeType and filename properties
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed May 11, 2015
1 parent 31e068b commit 538c431
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Expand Up @@ -57,8 +57,10 @@
import static org.fcrepo.kernel.RdfLexicon.FIRST_PAGE;
import static org.fcrepo.kernel.RdfLexicon.HAS_CHILD;
import static org.fcrepo.kernel.RdfLexicon.HAS_MEMBER_RELATION;
import static org.fcrepo.kernel.RdfLexicon.HAS_MIME_TYPE;
import static org.fcrepo.kernel.RdfLexicon.HAS_OBJECT_COUNT;
import static org.fcrepo.kernel.RdfLexicon.HAS_OBJECT_SIZE;
import static org.fcrepo.kernel.RdfLexicon.HAS_ORIGINAL_NAME;
import static org.fcrepo.kernel.RdfLexicon.HAS_PRIMARY_IDENTIFIER;
import static org.fcrepo.kernel.RdfLexicon.HAS_PRIMARY_TYPE;
import static org.fcrepo.kernel.RdfLexicon.INBOUND_REFERENCES;
Expand Down Expand Up @@ -618,6 +620,31 @@ public void testPatchBinaryDescriptionWithBinaryProperties() throws Exception {
createLiteral("this is an identifier")));
}

@Test
public void testPatchBinaryNameAndType() throws Exception {
final String pid = getRandomUniquePid();

createDatastream(pid, "x", "some content");

final String location = serverAddress + pid + "/x/fcr:metadata";
final HttpPatch patch = new HttpPatch(location);
patch.addHeader("Content-Type", "application/sparql-update");
final BasicHttpEntity e = new BasicHttpEntity();
final String sparql = "INSERT DATA { <" + serverAddress + pid + "/x> <" + HAS_MIME_TYPE + "> \"text/plain\""
+ " . <" + serverAddress + pid + "/x> <" + HAS_ORIGINAL_NAME + "> \"x.txt\" }";
e.setContent(new ByteArrayInputStream(sparql.getBytes()));
patch.setEntity(e);
final HttpResponse response = client.execute(patch);
assertEquals(NO_CONTENT.getStatusCode(), response.getStatusLine()
.getStatusCode());

final GraphStore graphStore = getGraphStore(new HttpGet(location));
assertTrue(graphStore.contains(ANY, createURI(serverAddress + pid + "/x"),
HAS_MIME_TYPE.asNode(), createLiteral("text/plain")));
assertTrue(graphStore.contains(ANY, createURI(serverAddress + pid + "/x"),
HAS_ORIGINAL_NAME.asNode(), createLiteral("x.txt")));
}

@Test
public void testPatchWithBlankNode() throws Exception {
final String pid = getRandomUniquePid();
Expand Down
6 changes: 4 additions & 2 deletions fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java
Expand Up @@ -54,6 +54,8 @@ public final class RdfLexicon {

public static final String JCR_NT_NAMESPACE = "http://www.jcp.org/jcr/nt/1.0";

public static final String EBUCORE_NAMESPACE = "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#";

/**
* Fedora configuration namespace "fedora-config", used for user-settable
* configuration properties.
Expand Down Expand Up @@ -240,12 +242,12 @@ public final class RdfLexicon {
public static final Property HAS_CONTENT_LOCATION_VALUE =
createProperty(PREMIS_NAMESPACE + "hasContentLocationValue");
public static final Property HAS_MIME_TYPE =
createProperty(REPOSITORY_NAMESPACE + "mimeType");
createProperty(EBUCORE_NAMESPACE + "hasMimeType");
public static final Property HAS_ORIGINAL_NAME =
createProperty(PREMIS_NAMESPACE + "hasOriginalName");

public static final Set<Property> contentProperties = of(HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE,
HAS_MIME_TYPE, HAS_ORIGINAL_NAME, HAS_SIZE);
HAS_SIZE);


// VERSIONING
Expand Down

0 comments on commit 538c431

Please sign in to comment.