Skip to content

Commit

Permalink
Fixing handling of content node version lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Oct 20, 2014
1 parent 58e32d1 commit 53cdb7e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Expand Up @@ -376,6 +376,36 @@ public void testVersionOperationAddsVersionableMixin() throws Exception {
createURI(RDF_TYPE), createURI(MIX_NAMESPACE + "versionable")));
}

@Test
public void testDatastreamAutoVersioning() throws IOException {
final String pid = getRandomUniquePid();
createObject(pid);

createDatastream(pid, "ds1", "This is some datastream content");

// datastream should not have fcr:versions endpoint
assertEquals( 404, getStatus(new HttpGet(serverAddress + pid + "/ds1/fcr:versions")) );

// datastream should not be versionable
final GraphStore originalObjectProperties = getContent(serverAddress + pid + "/ds1/fcr:metadata");
assertFalse("Node must not have versionable mixin.",
originalObjectProperties.contains(ANY, createResource(serverAddress + pid + "/ds1").asNode(),
createURI(RDF_TYPE), createURI(MIX_NAMESPACE + "versionable")));

// creating a version should succeed
assertEquals( 204, getStatus(new HttpPost(serverAddress + pid + "/ds1/fcr:versions")) );

// datastream should then have versions endpoint
assertEquals( 200, getStatus(new HttpGet(serverAddress + pid + "/ds1/fcr:versions")) );

// datastream should then be versionable
final GraphStore updatedDSProperties = getContent(serverAddress + pid + "/ds1/fcr:metadata");
assertTrue("Node must have versionable mixin.",
updatedDSProperties.contains(ANY, createResource(serverAddress + pid + "/ds1/fcr:metadata").asNode(),
createURI(RDF_TYPE), createURI(MIX_NAMESPACE + "versionable")));
}


@Test
public void testIndexResponseContentTypes() throws Exception {
final String pid = getRandomUniquePid();
Expand Down
Expand Up @@ -441,7 +441,8 @@ public Version getBaseVersion() {
@Override
public VersionHistory getVersionHistory() {
try {
return getSession().getWorkspace().getVersionManager().getVersionHistory(getPath());
final String versionedPath = (FedoraBinaryImpl.hasMixin(node)) ? node.getParent().getPath() : getPath();
return getSession().getWorkspace().getVersionManager().getVersionHistory(versionedPath);
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
Expand Down

0 comments on commit 53cdb7e

Please sign in to comment.