Skip to content

Commit

Permalink
Remove deprecated methods from GraphSubjects
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 2, 2014
1 parent ecc93b8 commit 7f7a3f5
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 77 deletions.
Expand Up @@ -164,7 +164,7 @@ public void testWriteProperty() throws RepositoryException {
"'some-test-name' }";

// Write the properties
object.updatePropertiesDataset(new DefaultGraphSubjects(session),
object.updatePropertiesDataset(new DefaultGraphSubjects(),
sparql);

// Verify
Expand All @@ -178,7 +178,7 @@ public void testWriteProperty() throws RepositoryException {

@Test
public void testRemoveProperty() throws RepositoryException {
Session session = repo.login();
final Session session = repo.login();

final FedoraResource object = nodeService.getObject(session, testFile);
assertNotNull(object);
Expand All @@ -190,7 +190,7 @@ public void testRemoveProperty() throws RepositoryException {
"'some-property-to-remove' }";

// Write the properties
final GraphSubjects graphSubjects = new DefaultGraphSubjects(session);
final GraphSubjects graphSubjects = new DefaultGraphSubjects();
object.updatePropertiesDataset(graphSubjects, sparql);

// Verify property exists
Expand All @@ -206,7 +206,7 @@ public void testRemoveProperty() throws RepositoryException {
"}";

// Remove the properties
final GraphSubjects graphSubjectsRemove = new DefaultGraphSubjects(session);
final GraphSubjects graphSubjectsRemove = new DefaultGraphSubjects();
object.updatePropertiesDataset(graphSubjectsRemove, sparqlRemove);

// Persist the object (although the propery will be removed from memory without this.)
Expand All @@ -216,7 +216,7 @@ public void testRemoveProperty() throws RepositoryException {
boolean thrown = false;
try{
object.getNode().getProperty("fedora:remove");
} catch (PathNotFoundException e){
} catch (final PathNotFoundException e){
thrown = true;
}
assertTrue("Exception expected - property should be missing", thrown);
Expand Down
Expand Up @@ -109,12 +109,6 @@ public Resource getGraphSubject(final String absPath) throws RepositoryException
return super.getGraphSubject(absPath);
}

@Override
@Deprecated
public Resource getGraphSubject(final Node node) throws RepositoryException {
throw new UnsupportedOperationException("Deprecated method!");
}

/**
* For frozen nodes (which represent version snapshots) we translate the
* paths from their frozen storage URI to
Expand Down
Expand Up @@ -18,14 +18,17 @@

import com.google.common.base.Function;
import com.hp.hpl.jena.rdf.model.Resource;
import org.apache.commons.lang.StringUtils;

import org.fcrepo.kernel.exception.RepositoryRuntimeException;
import org.fcrepo.kernel.rdf.GraphSubjects;
import org.fcrepo.kernel.services.functions.GetDefaultWorkspace;
import org.slf4j.Logger;

import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static java.util.Collections.singletonMap;
import static javax.jcr.PropertyType.PATH;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.apache.commons.lang.StringUtils.replaceOnce;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_CONTENT;
import static org.fcrepo.kernel.services.TransactionServiceImpl.getCurrentTransactionId;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
Expand Down Expand Up @@ -111,18 +114,6 @@ public Resource getContext() {
return createResource(context.toString());
}

@Override
@Deprecated
public Resource getGraphSubject(final Node node) throws RepositoryException {
throw new UnsupportedOperationException("Deprecated method!");
}

@Override
@Deprecated
public Node getNodeFromGraphSubject(final Resource subject) throws RepositoryException {
throw new UnsupportedOperationException("Deprecated method!");
}

private static String getResourceURI(final Resource subject) {
if (!subject.isURIResource()) {
LOGGER.debug("RDF resource {} was not a URI resource: returning null.",
Expand Down Expand Up @@ -208,7 +199,7 @@ private boolean isValidJcrPath(final String absPath) {
if (txId != null) {
final String txIdWithSlash = "/" + TX_PREFIX + txId;
/* replace the first occurrence of tx within the path */
pathToValidate = StringUtils.replaceOnce(absPath, txIdWithSlash, StringUtils.EMPTY);
pathToValidate = replaceOnce(absPath, txIdWithSlash, EMPTY);
LOGGER.debug("removed {} from URI {}. Path for JCR validation is now: {}",
txIdWithSlash, absPath, pathToValidate);
}
Expand Down
Expand Up @@ -15,7 +15,6 @@
*/
package org.fcrepo.kernel.rdf;

import javax.jcr.Node;
import javax.jcr.RepositoryException;

import com.hp.hpl.jena.rdf.model.Resource;
Expand All @@ -24,27 +23,10 @@
* Translate internal JCR node identifiers to external Fedora identifiers
* (and vice versa)
* @author barmintor
* @author ajs6f
* @date May 15, 2013
*/
public interface GraphSubjects {
/**
* Translate a JCR node into an RDF Resource
* @param node
* @return an RDF URI resource
* @throws RepositoryException
*/
@Deprecated
Resource getGraphSubject(final Node node) throws RepositoryException;

/**
* Translate an RDF resource into a JCR node
* @param subject an RDF URI resource
* @return a JCR node, or null if one couldn't be found
* @throws RepositoryException
*/
@Deprecated
Node getNodeFromGraphSubject(final Resource subject)
throws RepositoryException;

/**
* Translate an RDF resource into a JCR path
Expand Down
Expand Up @@ -159,7 +159,7 @@ public static JcrRdfTools withContext(final GraphSubjects graphSubjects) {
public static JcrRdfTools withContext(final GraphSubjects graphSubjects,
final Session session) {
if (graphSubjects == null) {
return new JcrRdfTools(new DefaultGraphSubjects(session), session);
return new JcrRdfTools(new DefaultGraphSubjects(), session);
}
return new JcrRdfTools(graphSubjects, session);
}
Expand Down
Expand Up @@ -20,11 +20,11 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_CONTENT;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import javax.jcr.Node;

import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.fcrepo.kernel.rdf.GraphSubjects;

import com.hp.hpl.jena.rdf.model.Resource;

/**
Expand All @@ -46,7 +46,7 @@ public class DefaultGraphSubjects implements GraphSubjects {
/**
* Construct the graph with a placeholder context resource
*/
public DefaultGraphSubjects(final Session session) {
public DefaultGraphSubjects() {
this.context = createResource();
}

Expand All @@ -63,18 +63,6 @@ public Resource getContext() {
return context;
}

@Override
@Deprecated
public Resource getGraphSubject(final Node node) {
throw new UnsupportedOperationException("Deprecated method!");
}

@Override
@Deprecated
public Node getNodeFromGraphSubject(final Resource subject) {
throw new UnsupportedOperationException("Deprecated method!");
}

@Override
public String getPathFromGraphSubject(final Resource subject) throws RepositoryException {
if (!isFedoraGraphSubject(subject)) {
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void testObjectGraph() throws Exception {
final Session session = repo.login();
final FedoraObject object =
objectService.createObject(session, "/graphObject");
final GraphSubjects subjects = new DefaultGraphSubjects(session);
final GraphSubjects subjects = new DefaultGraphSubjects();
final Dataset graphStore = object.getPropertiesDataset(subjects);

final String graphSubject = subjects.getGraphSubject("/graphObject").getURI();
Expand Down Expand Up @@ -161,7 +161,7 @@ public void testObjectGraphWithUriProperty() throws RepositoryException {
final Session session = repo.login();
final FedoraObject object =
objectService.createObject(session, "/graphObject");
final GraphSubjects subjects = new DefaultGraphSubjects(session);
final GraphSubjects subjects = new DefaultGraphSubjects();
final String graphSubject = subjects.getGraphSubject("/graphObject").getURI();
final Dataset graphStore = object.getPropertiesDataset(subjects);

Expand Down
Expand Up @@ -98,7 +98,7 @@ public class FedoraResourceImplIT extends AbstractIT {
@Before
public void setUp() throws RepositoryException {
session = repo.login();
subjects = new DefaultGraphSubjects(session);
subjects = new DefaultGraphSubjects();
}

@After
Expand All @@ -124,7 +124,7 @@ public void testRandomNodeGraph() throws RepositoryException {
nodeService.findOrCreateObject(session, "/testNodeGraph");

logger.warn(object.getPropertiesDataset(
new DefaultGraphSubjects(session)).toString());
new DefaultGraphSubjects()).toString());
final Node s = createGraphSubjectNode("/testNodeGraph");
final Node p = createURI(REPOSITORY_NAMESPACE + "primaryType");
final Node o = createLiteral("nt:unstructured");
Expand Down
Expand Up @@ -356,7 +356,7 @@ public void testIsNotNew() {
public void testReplacePropertiesDataset() throws Exception {

mockStatic(JcrRdfTools.class);
final DefaultGraphSubjects defaultGraphSubjects = new DefaultGraphSubjects(mockSession);
final DefaultGraphSubjects defaultGraphSubjects = new DefaultGraphSubjects();
when(JcrRdfTools.withContext(defaultGraphSubjects, mockSession)).thenReturn(mockJcrRdfTools);

when(mockNode.getPath()).thenReturn("/xyz");
Expand Down
Expand Up @@ -52,7 +52,7 @@ public class DefaultGraphSubjectsTest {
@Before
public void setUp() {
initMocks(this);
testObj = new DefaultGraphSubjects(mockSession);
testObj = new DefaultGraphSubjects();
}

@Test
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class WorkspaceRdfContextTest {
@Before
public void setUp() {
initMocks(this);
subjects = new DefaultGraphSubjects(session);
subjects = new DefaultGraphSubjects();
when(session.getRepository()).thenReturn(repository);
when(session.getWorkspace()).thenReturn(mockWorkspace);
}
Expand Down
Expand Up @@ -143,7 +143,7 @@ public class JcrRdfToolsTest {
@Before
public final void setUp() throws RepositoryException {
initMocks(this);
testSubjects = new DefaultGraphSubjects(mockSession);
testSubjects = new DefaultGraphSubjects();
testObj = new JcrRdfTools(testSubjects, mockSession);
buildMockNodeAndSurroundings();
}
Expand Down
Expand Up @@ -17,6 +17,7 @@

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;

import org.fcrepo.kernel.FedoraResourceImpl;
import org.fcrepo.kernel.rdf.GraphSubjects;
import org.fcrepo.kernel.rdf.impl.DefaultGraphSubjects;
Expand All @@ -27,7 +28,6 @@

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.UriInfo;

Expand All @@ -50,7 +50,7 @@ public void setUp() {
mockResource = new FedoraResourceImpl(mockNode);

uriInfo = TestHelpers.getUriInfoImpl();
mockSubjects = new DefaultGraphSubjects(mock(Session.class));
mockSubjects = new DefaultGraphSubjects();
}

@Test
Expand Down
Expand Up @@ -48,7 +48,7 @@ public class JQLConverterIT {
@Before
public void setUp() throws Exception {
session = repo.login();
subjects = new DefaultGraphSubjects(session);
subjects = new DefaultGraphSubjects();
}

@Test
Expand Down
Expand Up @@ -75,7 +75,7 @@ public void shouldDoStuff() throws RepositoryException {

testObj = new LDPathTransform(stringReader);

final DefaultGraphSubjects subjects = new DefaultGraphSubjects(session);
final DefaultGraphSubjects subjects = new DefaultGraphSubjects();
final Map<String, Collection<Object>> stuff = testObj.apply(object.getPropertiesDataset(subjects));

assertNotNull("Failed to retrieve results!", stuff);
Expand Down
Expand Up @@ -68,7 +68,7 @@ public void shouldDoStuff() throws RepositoryException {

testObj = new SparqlQueryTransform(stringReader);

final QueryExecution qexec = testObj.apply(object.getPropertiesDataset(new DefaultGraphSubjects(session)));
final QueryExecution qexec = testObj.apply(object.getPropertiesDataset(new DefaultGraphSubjects()));

assert(qexec != null);

Expand Down
Expand Up @@ -17,6 +17,7 @@

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;

import org.fcrepo.http.commons.test.util.TestHelpers;
import org.fcrepo.jcr.FedoraJcrTypes;
import org.fcrepo.kernel.FedoraResourceImpl;
Expand All @@ -27,7 +28,6 @@

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.UriInfo;

Expand Down Expand Up @@ -58,7 +58,7 @@ public void setUp() {
mockResource = new FedoraResourceImpl(mockNode);

uriInfo = TestHelpers.getUriInfoImpl();
mockSubjects = new DefaultGraphSubjects(mock(Session.class));
mockSubjects = new DefaultGraphSubjects();
}

@Test
Expand Down
Expand Up @@ -24,7 +24,6 @@

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.UriInfo;

Expand Down Expand Up @@ -57,7 +56,7 @@ public void setUp() {
mockResource = new FedoraResourceImpl(mockNode);

uriInfo = TestHelpers.getUriInfoImpl();
mockSubjects = new DefaultGraphSubjects(mock(Session.class));
mockSubjects = new DefaultGraphSubjects();
}

@Test
Expand Down

0 comments on commit 7f7a3f5

Please sign in to comment.