Skip to content

Commit

Permalink
Remove repository autoversioning
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Oct 15, 2014
1 parent caf36e8 commit 23f6c9b
Show file tree
Hide file tree
Showing 18 changed files with 17 additions and 632 deletions.
Expand Up @@ -261,7 +261,6 @@ && isRdfContentType(contentType.toString())) {

try {
session.save();
versionService.nodeUpdated(resource.getNode());
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
Expand Down Expand Up @@ -304,11 +303,6 @@ public Response updateSparql(@ContentLocation final InputStream requestBodyStrea

try {
session.save();
versionService.nodeUpdated(resource().getNode());

if (resource() instanceof Datastream) {
versionService.nodeUpdated(((Datastream) resource()).getContentNode());
}
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
Expand Down Expand Up @@ -390,7 +384,6 @@ && isRdfContentType(contentTypeString)) {

try {
session.save();
versionService.nodeUpdated(result.getNode());
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
Expand Down
Expand Up @@ -125,7 +125,6 @@ public Response copyObject(@HeaderParam("Destination") final String destinationU
nodeService.copyObject(session, source, destination);

session.save();
versionService.nodeUpdated(session, destination);

return created(new URI(destinationUri)).build();
} catch (final RepositoryRuntimeException e) {
Expand Down Expand Up @@ -177,7 +176,6 @@ public Response moveObject(@HeaderParam("Destination") final String destinationU

nodeService.moveObject(session, resource().getPath(), destination);
session.save();
versionService.nodeUpdated(session, destination);
return created(new URI(destinationUri)).build();
} catch (final RepositoryRuntimeException e) {
final Throwable cause = e.getCause();
Expand Down
Expand Up @@ -51,6 +51,7 @@
import static javax.ws.rs.core.MediaType.TEXT_PLAIN;
import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.noContent;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.fcrepo.http.commons.domain.RDFMediaType.JSON_LD;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
Expand Down Expand Up @@ -148,7 +149,7 @@ public Response addVersion(@HeaderParam("Slug") final String slug) throws Reposi
final Collection<String> versions = versionService.createVersion(session.getWorkspace(),
singleton(path));

if (slug != null) {
if (!isBlank(slug)) {
resource().addVersionLabel(slug);
}

Expand Down
Expand Up @@ -30,15 +30,12 @@
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.Collection;

import static java.util.Collections.singleton;
import static javax.ws.rs.core.MediaType.APPLICATION_XHTML_XML;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.MediaType.TEXT_HTML;
Expand Down Expand Up @@ -102,27 +99,6 @@ private void postConstruct() {
this.label = pathListIntoVersion.split("/", 2)[0];
}

/**
* Create a new version checkpoint and tag it with the given label. If
* that label already describes another version it will silently be
* reassigned to describe this version.
*
* @return response
* @throws RepositoryException
*/
@POST
public Response addVersion() throws RepositoryException {
final Collection<String> versions = versionService.createVersion(session.getWorkspace(),
singleton(unversionedResource().getPath()));
if (label != null) {
unversionedResource().addVersionLabel(label);
}

final String version = (label != null) ? label : versions.iterator().next();
return noContent().header("Location", translator().toDomain(
externalPath) + "/fcr:versions/" + version).build();
}

/**
* Reverts the resource at the given path to the version specified by
* the label.
Expand Down
Expand Up @@ -35,7 +35,6 @@
import org.fcrepo.kernel.services.BinaryService;
import org.fcrepo.kernel.services.NodeService;
import org.fcrepo.kernel.services.ObjectService;
import org.fcrepo.kernel.services.VersionService;
import org.fcrepo.kernel.utils.iterators.RdfStream;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -134,9 +133,6 @@ public class FedoraLdpTest {
@Mock
private BinaryService mockBinaryService;

@Mock
private VersionService mockVersionService;

@Before
public void setUp() throws Exception {
initMocks(this);
Expand All @@ -157,7 +153,6 @@ public void setUp() throws Exception {
setField(testObj, "nodeService", mockNodeService);
setField(testObj, "objectService", mockObjectService);
setField(testObj, "binaryService", mockBinaryService);
setField(testObj, "versionService", mockVersionService);

when(mockObject.getNode()).thenReturn(mockObjectNode);
when(mockObject.getEtagValue()).thenReturn("");
Expand Down Expand Up @@ -535,7 +530,6 @@ public void testPutNewObject() throws Exception {
final Response actual = testObj.createOrReplaceObjectRdf(null, null, null, null);

assertEquals(CREATED.getStatusCode(), actual.getStatus());
verify(mockVersionService).nodeUpdated(mockObjectNode);
}

@Test
Expand All @@ -551,7 +545,6 @@ public void testPutNewObjectWithRdf() throws Exception {
toInputStream("_:a <info:x> _:c ."), null, null);

assertEquals(CREATED.getStatusCode(), actual.getStatus());
verify(mockVersionService).nodeUpdated(mockObjectNode);
verify(mockObject).replaceProperties(eq(identifierConverter), any(Model.class), any(RdfStream.class));
}

Expand All @@ -567,7 +560,6 @@ public void testPutNewBinary() throws Exception {
toInputStream("xyz"), null, null);

assertEquals(CREATED.getStatusCode(), actual.getStatus());
verify(mockVersionService).nodeUpdated(mockBinaryNode);
}

@Test
Expand All @@ -585,7 +577,6 @@ public void testPutReplaceRdfObject() throws Exception {
toInputStream("_:a <info:x> _:c ."), null, null);

assertEquals(NO_CONTENT.getStatusCode(), actual.getStatus());
verify(mockVersionService).nodeUpdated(mockObject.getNode());
verify(mockObject).replaceProperties(eq(identifierConverter), any(Model.class), any(RdfStream.class));
}

Expand All @@ -595,7 +586,6 @@ public void testPatchObject() throws Exception {
final FedoraResource mockObject = setResource(FedoraObject.class);

testObj.updateSparql(toInputStream("xyz"));
verify(mockVersionService).nodeUpdated(mockObject.getNode());
}

@Test
Expand All @@ -606,8 +596,6 @@ public void testPatchBinaryDescription() throws Exception {
when(mockObject.getContentNode()).thenReturn(mockBinaryNode);

testObj.updateSparql(toInputStream("xyz"));
verify(mockVersionService).nodeUpdated(mockObject.getNode());
verify(mockVersionService).nodeUpdated(mockObject.getContentNode());
}

@Test(expected = BadRequestException.class)
Expand Down
Expand Up @@ -18,8 +18,6 @@
import static org.fcrepo.http.commons.test.util.TestHelpers.getUriInfoImpl;
import static org.fcrepo.http.commons.test.util.TestHelpers.mockSession;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
Expand All @@ -28,13 +26,10 @@
import static org.mockito.MockitoAnnotations.initMocks;
import static org.springframework.test.util.ReflectionTestUtils.setField;

import java.util.Collection;

import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
Expand All @@ -47,7 +42,6 @@
import org.fcrepo.kernel.services.VersionService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mock;

import com.hp.hpl.jena.query.Dataset;
Expand Down Expand Up @@ -108,17 +102,6 @@ public void setUp() throws Exception {
new UriAwareIdentifierConverter(mockSession, UriBuilder.fromUri("http://localhost/fcrepo/{path: .*}")));
}

@Test
public void testAddVersionLabel() throws RepositoryException {
doReturn(mockResource).when(testObj).unversionedResource();

final Response response = testObj.addVersion();
verify(mockResource).addVersionLabel(anyString());
verify(mockVersions).createVersion(any(Workspace.class),
Matchers.<Collection<String>>any());
assertNotNull(response);
}

@Test
public void testRevertToVersion() throws RepositoryException {
doReturn(mockResource).when(testObj).unversionedResource();
Expand Down

0 comments on commit 23f6c9b

Please sign in to comment.