Skip to content

Commit

Permalink
Revert "Re-Work true blank-node implementation"
Browse files Browse the repository at this point in the history
This reverts commit ceacc98.

Conflicts:
	fcrepo-http-api/src/main/java/org/fcrepo/http/api/FedoraBaseResource.java
	fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/Deskolemizer.java
  • Loading branch information
Andrew Woods committed May 4, 2015
1 parent b379030 commit ae5aa5d
Show file tree
Hide file tree
Showing 34 changed files with 543 additions and 1,077 deletions.
Expand Up @@ -16,12 +16,10 @@
package org.fcrepo.auth.integration;

import org.apache.http.auth.BasicUserPrincipal;

import org.fcrepo.auth.common.FedoraAuthorizationDelegate;
import org.fcrepo.auth.common.ServletContainerAuthenticationProvider;
import org.fcrepo.kernel.impl.services.ContainerServiceImpl;
import org.fcrepo.kernel.services.ContainerService;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -40,8 +38,8 @@
import javax.servlet.http.HttpServletRequest;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -62,7 +60,7 @@ public class ContainerRolesPrincipalProviderIT {
@Autowired
private FedoraAuthorizationDelegate fad;

private final HttpServletRequest request = mock(HttpServletRequest.class);
private HttpServletRequest request = mock(HttpServletRequest.class);

@Test
public void testFactory() {
Expand Down Expand Up @@ -93,7 +91,7 @@ public void testEmptyPrincipalProvider() throws RepositoryException {
}
final ContainerService os = new ContainerServiceImpl();
os.findOrCreate(session, "/myobject");
verify(fad, atLeastOnce()).hasPermission(any(Session.class), any(Path.class), any(String[].class));
verify(fad, times(9)).hasPermission(any(Session.class), any(Path.class), any(String[].class));
}


Expand Down
Expand Up @@ -16,12 +16,10 @@
package org.fcrepo.auth.integration;

import org.apache.http.auth.BasicUserPrincipal;

import org.fcrepo.auth.common.FedoraAuthorizationDelegate;
import org.fcrepo.auth.common.ServletContainerAuthenticationProvider;
import org.fcrepo.kernel.impl.services.ContainerServiceImpl;
import org.fcrepo.kernel.services.ContainerService;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -40,8 +38,8 @@
import javax.servlet.http.HttpServletRequest;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -62,7 +60,7 @@ public class HttpHeaderPrincipalProviderIT {
@Autowired
private FedoraAuthorizationDelegate fad;

private final HttpServletRequest request = mock(HttpServletRequest.class);
private HttpServletRequest request = mock(HttpServletRequest.class);

@Test
public void testFactory() {
Expand Down Expand Up @@ -93,7 +91,7 @@ public void testEmptyPrincipalProvider() throws RepositoryException {
}
final ContainerService os = new ContainerServiceImpl();
os.findOrCreate(session, "/myobject");
verify(fad, atLeastOnce()).hasPermission(any(Session.class), any(Path.class), any(String[].class));
verify(fad, times(9)).hasPermission(any(Session.class), any(Path.class), any(String[].class));
}

}
Expand Up @@ -16,19 +16,17 @@
package org.fcrepo.auth.integration;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.slf4j.LoggerFactory.getLogger;

import org.apache.http.auth.BasicUserPrincipal;

import org.fcrepo.auth.common.FedoraAuthorizationDelegate;
import org.fcrepo.auth.common.ServletContainerAuthenticationProvider;
import org.fcrepo.kernel.exception.RepositoryRuntimeException;
import org.fcrepo.kernel.services.ContainerService;
import org.fcrepo.kernel.impl.services.ContainerServiceImpl;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -105,7 +103,7 @@ public void testPermissiveFAD() throws RepositoryException {
}
final ContainerService os = new ContainerServiceImpl();
os.findOrCreate(session, "/myobject");
verify(fad, atLeastOnce()).hasPermission(any(Session.class), any(Path.class), any(String[].class));
verify(fad, times(9)).hasPermission(any(Session.class), any(Path.class), any(String[].class));
}

@Test(expected = AccessDeniedException.class)
Expand All @@ -130,6 +128,6 @@ public void testRestrictiveFAD() throws Throwable {
} catch (final RepositoryRuntimeException e) {
throw e.getCause();
}
verify(fad, atLeastOnce()).hasPermission(any(Session.class), any(Path.class), any(String[].class));
verify(fad, times(5)).hasPermission(any(Session.class), any(Path.class), any(String[].class));
}
}
Expand Up @@ -71,7 +71,7 @@ public void testWriteProperty() throws RepositoryException {


// Write the properties
object.updateProperties(new DefaultIdentifierTranslator(session), sparql, new RdfStream(), containerService);
object.updateProperties(new DefaultIdentifierTranslator(session), sparql, new RdfStream());

// Verify
final Property property = object.getNode().getProperty("fedora:name");
Expand All @@ -97,7 +97,7 @@ public void testRemoveProperty() throws RepositoryException {

// Write the properties
final DefaultIdentifierTranslator graphSubjects = new DefaultIdentifierTranslator(session);
object.updateProperties(graphSubjects, sparql, new RdfStream(), containerService);
object.updateProperties(graphSubjects, sparql, new RdfStream());

// Verify property exists
final Property property = object.getNode().getProperty("fedora:remove");
Expand All @@ -114,7 +114,7 @@ public void testRemoveProperty() throws RepositoryException {
// Remove the properties
object.updateProperties(graphSubjects,
sparqlRemove,
object.getTriples(graphSubjects, PropertiesRdfContext.class), containerService);
object.getTriples(graphSubjects, PropertiesRdfContext.class));

// Persist the object (although the propery will be removed from memory without this.)
session.save();
Expand Down
Expand Up @@ -74,7 +74,6 @@
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.kernel.exception.MalformedRdfException;
import org.fcrepo.kernel.exception.RepositoryRuntimeException;
import org.fcrepo.kernel.impl.rdf.Deskolemizer;
import org.fcrepo.kernel.impl.rdf.ManagedRdf;
import org.fcrepo.kernel.impl.rdf.impl.AclRdfContext;
import org.fcrepo.kernel.impl.rdf.impl.BlankNodeRdfContext;
Expand Down Expand Up @@ -117,16 +116,12 @@
* content.
*
* @author Mike Durbin
* @author ajs6f
*/
public abstract class ContentExposingResource extends FedoraBaseResource {

public static final MediaType MESSAGE_EXTERNAL_BODY = MediaType.valueOf("message/external-body");

@Context protected Request request;

private Deskolemizer deskolemizer;

@Context protected HttpServletResponse servletResponse;

@Inject
Expand All @@ -146,13 +141,6 @@ public abstract class ContentExposingResource extends FedoraBaseResource {

protected abstract String externalPath();

private Deskolemizer deskolemizer() {
if (deskolemizer != null) {
return deskolemizer;
}
return deskolemizer = new Deskolemizer(translator(), null);
}

protected Response getContent(final String rangeValue,
final RdfStream rdfStream) throws IOException {
if (resource() instanceof FedoraBinary) {
Expand Down Expand Up @@ -204,7 +192,7 @@ public Triple apply(final Statement input) {
}
servletResponse.addHeader("Vary", "Accept, Range, Accept-Encoding, Accept-Language");

return ok(rdfStream.map(deskolemizer())).build();
return Response.ok(rdfStream).build();
}

protected RdfStream getResourceTriples() {
Expand Down Expand Up @@ -306,7 +294,8 @@ public RdfStream apply(final FedoraResource child) {
httpTripleUtil.addHttpComponentModelsForResourceToStream(rdfStream, resource(), uriInfo, translator());
}

return rdfStream.map(deskolemizer());

return rdfStream;
}

/**
Expand Down Expand Up @@ -606,14 +595,14 @@ protected void replaceResourceWithStream(final FedoraResource resource,
final Model inputModel = createDefaultModel()
.read(requestBodyStream, getUri(resource).toString(), format.getName().toUpperCase());

resource.replaceProperties(translator(), inputModel, resourceTriples, containerService);
resource.replaceProperties(translator(), inputModel, resourceTriples);
}

protected void patchResourcewithSparql(final FedoraResource resource,
final String requestBody,
final RdfStream resourceTriples)
throws MalformedRdfException, AccessDeniedException {
resource.updateProperties(translator(), requestBody, resourceTriples, containerService);
resource.updateProperties(translator(), requestBody, resourceTriples);
}

/**
Expand Down
Expand Up @@ -50,8 +50,9 @@ abstract public class FedoraBaseResource extends AbstractResource {
protected IdentifierConverter<Resource, FedoraResource> translator() {
if (idTranslator == null) {
idTranslator = new HttpResourceConverter(session(),
uriInfo.getBaseUriBuilder().clone().path(FedoraLdp.class));
uriInfo.getBaseUriBuilder().clone().path(FedoraLdp.class));
}

return idTranslator;
}

Expand Down
14 changes: 9 additions & 5 deletions fcrepo-http-api/src/main/java/org/fcrepo/http/api/FedoraLdp.java
Expand Up @@ -324,14 +324,15 @@ public Response createOrReplaceObjectRdf(
*
* @param requestBodyStream the request body stream
* @return 201
* @throws MalformedRdfException if malformed rdf exception occurred
* @throws AccessDeniedException if exception updating property occurred
* @throws IOException if IO exception occurred
*/
@PATCH
@Consumes({contentTypeSPARQLUpdate})
@Timed
public Response updateSparql(@ContentLocation final InputStream requestBodyStream)
throws IOException, AccessDeniedException {
throws IOException, MalformedRdfException, AccessDeniedException {

if (null == requestBodyStream) {
throw new BadRequestException("SPARQL-UPDATE requests must have content!");
Expand Down Expand Up @@ -366,15 +367,13 @@ public Response updateSparql(@ContentLocation final InputStream requestBodyStrea

return noContent().build();
} catch ( final RuntimeException ex ) {
LOGGER.debug("Caught exception:", ex);
final Throwable cause = ex.getCause();
if (cause instanceof PathNotFoundException) {
// the sparql update referred to a repository resource that doesn't exist
throw new BadRequestException(cause.getMessage());
}
throw ex;
} catch (final RepositoryException e) {
LOGGER.debug("Caught exception:", e);
if (e instanceof AccessDeniedException) {
throw new AccessDeniedException(e.getMessage());
}
Expand Down Expand Up @@ -431,8 +430,13 @@ public Response createObject(@QueryParam("checksum") final String checksum,
effectiveContentType,
contentDisposition);

final RdfStream resourceTriples =
result.isNew() ? new RdfStream().session(session) : getResourceTriples().session(session);
final RdfStream resourceTriples;

if (result.isNew()) {
resourceTriples = new RdfStream();
} else {
resourceTriples = getResourceTriples();
}

if (requestBodyStream == null) {
LOGGER.trace("No request body detected");
Expand Down

0 comments on commit ae5aa5d

Please sign in to comment.