Skip to content
Permalink
Browse files

Deprecating out GraphSubjects... first part.

  • Loading branch information...
ajs6f committed Apr 2, 2014
1 parent bca6ac2 commit f0ae47c247940f2f099db9b5e6188832075eb2fd
Showing with 62 additions and 80 deletions.
  1. +2 −1 fcrepo-kernel-api/src/main/java/org/fcrepo/kernel/identifiers/ExternalIdentifierTranslator.java
  2. +2 −0 fcrepo-kernel-api/src/main/java/org/fcrepo/kernel/rdf/GraphSubjects.java
  3. +1 −3 fcrepo-kernel/src/main/java/org/fcrepo/kernel/FedoraResourceImpl.java
  4. +2 −3 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/JcrRdfTools.java
  5. +2 −3 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/FixityRdfContext.java
  6. +2 −4 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/HierarchyRdfContext.java
  7. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/JcrGraphProperties.java
  8. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/NodeRdfContext.java
  9. +2 −4 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/PropertiesRdfContext.java
  10. +2 −2 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/VersionsRdfContext.java
  11. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/impl/mappings/PropertyToTriple.java
  12. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/kernel/services/DatastreamServiceImpl.java
  13. +3 −3 fcrepo-kernel/src/test/java/org/fcrepo/kernel/FedoraResourceImplTest.java
  14. +13 −14 fcrepo-kernel/src/test/java/org/fcrepo/kernel/rdf/impl/HierarchyRdfContextTest.java
  15. +4 −6 fcrepo-kernel/src/test/java/org/fcrepo/kernel/rdf/impl/JcrGraphPropertiesTest.java
  16. +1 −2 fcrepo-kernel/src/test/java/org/fcrepo/kernel/rdf/impl/NodeRdfContextTest.java
  17. +3 −4 fcrepo-kernel/src/test/java/org/fcrepo/kernel/rdf/impl/PropertiesRdfContextTest.java
  18. +1 −2 fcrepo-kernel/src/test/java/org/fcrepo/kernel/rdf/impl/mappings/PropertyToTripleTest.java
  19. +1 −1 fcrepo-kernel/src/test/java/org/fcrepo/kernel/services/DatastreamServiceTest.java
  20. +5 −5 fcrepo-kernel/src/test/java/org/fcrepo/kernel/spring/DefaultPropertiesLoaderTest.java
  21. +10 −15 fcrepo-kernel/src/test/java/org/fcrepo/kernel/utils/JcrRdfToolsTest.java
  22. +1 −2 fcrepo-kernel/src/test/java/org/fcrepo/kernel/utils/iterators/RdfAdderTest.java
  23. +1 −2 fcrepo-kernel/src/test/java/org/fcrepo/kernel/utils/iterators/RdfRemoverTest.java
@@ -44,8 +44,9 @@
@Inject
private List<InternalIdentifierTranslator> translationChain;

private Converter<String, String> forward, reverse = identity();
private Converter<String, String> forward = identity();

private Converter<String, String> reverse = identity();
@Override
protected Resource doForward(final String a) {
return doRdfForward(forward.convert(a));
@@ -33,6 +33,7 @@
* @return an RDF URI resource
* @throws RepositoryException
*/
@Deprecated
Resource getGraphSubject(final Node node) throws RepositoryException;

/**
@@ -41,6 +42,7 @@
* @return a JCR node, or null if one couldn't be found
* @throws RepositoryException
*/
@Deprecated
Node getNodeFromGraphSubject(final Resource subject)
throws RepositoryException;

@@ -247,9 +247,7 @@ public Dataset getPropertiesDataset(final GraphSubjects graphSubjects,

dataset.addNamedModel(PROBLEMS_MODEL_NAME, problemsModel);

dataset.getContext().set(URI_SYMBOL,
graphSubjects.getGraphSubject(getNode()));

dataset.getContext().set(URI_SYMBOL, graphSubjects.getGraphSubject(getNode().getPath()));


return dataset;
@@ -244,9 +244,8 @@ public RdfStream getJcrPropertiesModel(final Iterator<Node> nodeIterator,
results.concat(new PropertiesRdfContext(node, graphSubjects,
llstore));
if (iteratorSubject != null) {
results.concat(singleton(create(iteratorSubject.asNode(),
HAS_MEMBER_OF_RESULT.asNode(), graphSubjects
.getGraphSubject(node).asNode())));
results.concat(singleton(create(iteratorSubject.asNode(), HAS_MEMBER_OF_RESULT.asNode(), graphSubjects
.getGraphSubject(node.getPath()).asNode())));
}
}
return results;
@@ -79,9 +79,8 @@ public FixityRdfContext(final Node node, final GraphSubjects graphSubjects,
final ImmutableSet.Builder<Triple> b = builder();
try {
b.add(create(resultSubject, RDF.type.asNode(), FIXITY_TYPE.asNode()));
b.add(create(graphSubjects.getGraphSubject(node)
.asNode(), HAS_FIXITY_RESULT.asNode(),
resultSubject));
b.add(create(graphSubjects.getGraphSubject(node.getPath()).asNode(),
HAS_FIXITY_RESULT.asNode(), resultSubject));
final String storeIdentifier = blob.getStoreIdentifier();
final com.hp.hpl.jena.graph.Node contentLocation = createResource(storeIdentifier)
.asNode();
@@ -114,8 +114,7 @@ public HierarchyRdfContext(final javax.jcr.Node node,

private Iterator<Triple> parentContext() throws RepositoryException {
final javax.jcr.Node parentNode = node().getParent();
final Node parentNodeSubject =
graphSubjects().getGraphSubject(parentNode).asNode();
final Node parentNodeSubject = graphSubjects().getGraphSubject(parentNode.getPath()).asNode();
return new PropertiesRdfContext(parentNode, graphSubjects(), lowLevelStorageService())
.concat(new Triple[] {
create(subject(), HAS_PARENT.asNode(),
@@ -146,8 +145,7 @@ public HierarchyRdfContext(final javax.jcr.Node node,
@Override
public Iterator<Triple> apply(final javax.jcr.Node child) {
try {
final Node childSubject =
graphSubjects().getGraphSubject(child).asNode();
final Node childSubject = graphSubjects().getGraphSubject(child.getPath()).asNode();
LOGGER.trace("Creating triples for child node: {}", child);
return new PropertiesRdfContext(child, graphSubjects(),
lowLevelStorageService()).concat(new Triple[] {
@@ -64,7 +64,7 @@ public Dataset getProperties(final Node node, final GraphSubjects subjects,
final Dataset dataset = DatasetFactory.create(model);
dataset.addNamedModel(MODEL_NAME, model);

final Resource subject = subjects.getGraphSubject(node);
final Resource subject = subjects.getGraphSubject(node.getPath());
final String uri = subject.getURI();
final com.hp.hpl.jena.sparql.util.Context context = dataset.getContext();
context.set(URI_SYMBOL,uri);
@@ -72,7 +72,7 @@ public NodeRdfContext(final Node node, final GraphSubjects graphSubjects,
super();
this.node = node;
this.graphSubjects = graphSubjects;
this.subject = graphSubjects.getGraphSubject(node).asNode();
this.subject = graphSubjects.getGraphSubject(node.getPath()).asNode();

// TODO fix GraphProperties to allow for LowLevelStorageServices to pass
// through it
@@ -97,10 +97,8 @@ private void putPropertiesIntoContext() throws RepositoryException {
LOGGER.trace("Access denied to content node", e);
}
if (contentNode != null) {
final Node contentSubject =
graphSubjects().getGraphSubject(contentNode).asNode();
final Node subject =
graphSubjects().getGraphSubject(node()).asNode();
final Node contentSubject = graphSubjects().getGraphSubject(contentNode.getPath()).asNode();
final Node subject = graphSubjects().getGraphSubject(node().getPath()).asNode();
// add triples representing parent-to-content-child relationship
concat(new Triple[] {
create(subject, HAS_CONTENT.asNode(), contentSubject),
@@ -72,7 +72,7 @@ public VersionsRdfContext(final Node node, final GraphSubjects graphSubjects,
super();
this.lowLevelStorageService = lowLevelStorageService;
this.graphSubjects = graphSubjects;
this.subject = graphSubjects.getGraphSubject(node).asNode();
this.subject = graphSubjects.getGraphSubject(node.getPath()).asNode();
versionManager = node.getSession().getWorkspace().getVersionManager();
versionHistory = versionManager.getVersionHistory(node.getPath());

@@ -93,7 +93,7 @@ public VersionsRdfContext(final Node node, final GraphSubjects graphSubjects,
try {
final Node frozenNode = version.getFrozenNode();
final com.hp.hpl.jena.graph.Node versionSubject =
graphSubjects.getGraphSubject(frozenNode).asNode();
graphSubjects.getGraphSubject(frozenNode.getPath()).asNode();

final RdfStream results =
new RdfStream(new PropertiesRdfContext(frozenNode,
@@ -173,7 +173,7 @@ private Node traverseLink(final Property p, final Value v)

private Node getGraphSubject(final javax.jcr.Node n)
throws RepositoryException {
return graphSubjects.getGraphSubject(n).asNode();
return graphSubjects.getGraphSubject(n.getPath()).asNode();
}

}
@@ -205,7 +205,7 @@ public RdfStream getFixityResultsModel(final GraphSubjects subjects,
return JcrRdfTools.withContext(subjects,
datastream.getNode().getSession()).getJcrTriples(
datastream.getNode(), blobs).topic(
subjects.getGraphSubject(datastream.getNode()).asNode());
subjects.getGraphSubject(datastream.getNode().getPath()).asNode());
}

/**
@@ -219,7 +219,7 @@ public void testGetPropertiesDataset() throws Exception {

when(JcrRdfTools.withContext(mockSubjects, mockSession)).thenReturn(mockJcrRdfTools);

when(mockSubjects.getGraphSubject(mockNode)).thenReturn(mockResource);
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream propertiesStream = new RdfStream(mockTriple);
when(mockJcrRdfTools.getJcrTriples(mockNode)).thenReturn(
@@ -247,7 +247,7 @@ public void testGetPropertiesDatasetDefaultLimits()
mockStatic(JcrRdfTools.class);
final GraphSubjects mockSubjects = mock(GraphSubjects.class);
when(JcrRdfTools.withContext(mockSubjects, mockSession)).thenReturn(mockJcrRdfTools);
when(mockSubjects.getGraphSubject(mockNode)).thenReturn(mockResource);
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream propertiesStream = new RdfStream(mockTriple);
when(mockJcrRdfTools.getJcrTriples(mockNode)).thenReturn(propertiesStream);
@@ -271,7 +271,7 @@ public void testGetVersionDataset() throws Exception {
final GraphSubjects mockSubjects = mock(GraphSubjects.class);

when(JcrRdfTools.withContext(mockSubjects, mockSession)).thenReturn(mockJcrRdfTools);
when(mockSubjects.getGraphSubject(mockNode)).thenReturn(mockResource);
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream versionsStream = new RdfStream();
when(mockJcrRdfTools.getVersionTriples(any(Node.class)))
@@ -194,12 +194,9 @@ public void setUp() throws RepositoryException {
when(mockNode.getNodes()).thenReturn(mockNodes);
when(mockParentNode.hasProperties()).thenReturn(false);
when(mockNode.hasProperties()).thenReturn(false);
when(mockGraphSubjects.getGraphSubject(mockNode)).thenReturn(
testSubject);
when(mockGraphSubjects.getGraphSubject(mockParentNode)).thenReturn(
testParentSubject);
when(mockGraphSubjects.getGraphSubject(mockChildNode)).thenReturn(
testChildSubject);
when(mockGraphSubjects.getGraphSubject(mockNode.getPath())).thenReturn(testSubject);
when(mockGraphSubjects.getGraphSubject(mockParentNode.getPath())).thenReturn(testParentSubject);
when(mockGraphSubjects.getGraphSubject(mockChildNode.getPath())).thenReturn(testChildSubject);
when(mockNodeType.isNodeType("mode:system")).thenReturn(false);
when(mockNodeType.getSupertypes()).thenReturn(new NodeType[] {mockNodeType});
when(mockSession.getRepository()).thenReturn(mockRepository);
@@ -251,19 +248,21 @@ private void buildChildNodes() throws RepositoryException {
when(mockChildNode4.getParent()).thenReturn(mockNode);
when(mockChildNode5.getParent()).thenReturn(mockNode);

when(mockChildNode.getPath()).thenReturn(MOCK_CHILD_NODE_PATH);
when(mockChildNode.getPath()).thenReturn(MOCK_NODE_PATH + "/1");
when(mockChildNode2.getPath()).thenReturn(MOCK_NODE_PATH + "/2");
when(mockChildNode3.getPath()).thenReturn(MOCK_NODE_PATH + "3");
when(mockChildNode4.getPath()).thenReturn(MOCK_NODE_PATH + "4");
when(mockChildNode5.getPath()).thenReturn(MOCK_NODE_PATH + "5");
when(mockChildNode3.getPath()).thenReturn(MOCK_NODE_PATH + "/3");
when(mockChildNode4.getPath()).thenReturn(MOCK_NODE_PATH + "/4");
when(mockChildNode5.getPath()).thenReturn(MOCK_NODE_PATH + "/5");

when(mockGraphSubjects.getGraphSubject(mockChildNode2)).thenReturn(
when(mockGraphSubjects.getGraphSubject(mockChildNode.getPath())).thenReturn(
createResource(RESOURCE_PREFIX + "/1"));
when(mockGraphSubjects.getGraphSubject(mockChildNode2.getPath())).thenReturn(
createResource(RESOURCE_PREFIX + "/2"));
when(mockGraphSubjects.getGraphSubject(mockChildNode3)).thenReturn(
when(mockGraphSubjects.getGraphSubject(mockChildNode3.getPath())).thenReturn(
createResource(RESOURCE_PREFIX + "/3"));
when(mockGraphSubjects.getGraphSubject(mockChildNode4)).thenReturn(
when(mockGraphSubjects.getGraphSubject(mockChildNode4.getPath())).thenReturn(
createResource(RESOURCE_PREFIX + "/4"));
when(mockGraphSubjects.getGraphSubject(mockChildNode5)).thenReturn(
when(mockGraphSubjects.getGraphSubject(mockChildNode5.getPath())).thenReturn(
createResource(RESOURCE_PREFIX + "/5"));

when(mockChildNode.getSession()).thenReturn(mockSession);
@@ -80,7 +80,7 @@ public void testGetPropertiesDataset() throws Exception {

final Resource mockResource =
new DummyURIResource(RESTAPI_NAMESPACE + "xyz");
when(mockSubjects.getGraphSubject(mockNode)).thenReturn(mockResource);
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream propertiesStream = new RdfStream();
when(mockJcrRdfTools.getJcrTriples(mockNode)).thenReturn(
@@ -110,7 +110,7 @@ public void testGetPropertiesDefaultLimits()
when(JcrRdfTools.withContext(mockSubjects, mockNode.getSession())).thenReturn(mockJcrRdfTools);
final Resource mockResource =
new DummyURIResource(RESTAPI_NAMESPACE + "xyz");
when(mockSubjects.getGraphSubject(mockNode)).thenReturn(mockResource);
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream propertiesStream = new RdfStream();
when(mockJcrRdfTools.getJcrTriples(mockNode)).thenReturn(
@@ -142,10 +142,8 @@ public void testGetPropertiesDatasetDefaults() throws Exception {
when(JcrRdfTools.withContext(mockSubjects, mockNode.getSession()))
.thenReturn(mockJcrRdfTools);

final Resource mockResource =
new DummyURIResource(RESTAPI_NAMESPACE + "xyz");
when(mockSubjects.getGraphSubject(mockNode)).thenReturn(
mockResource);
final Resource mockResource = new DummyURIResource(RESTAPI_NAMESPACE + "xyz");
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockResource);

final RdfStream propertiesStream = new RdfStream();
when(mockJcrRdfTools.getJcrTriples(mockNode))
@@ -122,8 +122,7 @@ public void setUp() throws RepositoryException {
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
when(mockWorkspace.getNamespaceRegistry()).thenReturn(mockNamespaceRegistry);
when(mockNamespaceRegistry.getURI("jcr")).thenReturn(JCR_NAMESPACE);
when(mockGraphSubjects.getGraphSubject(mockNode)).thenReturn(
mockNodeSubject);
when(mockGraphSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockNodeSubject);
}

@Test
@@ -73,6 +73,7 @@ public void testForLowLevelStorageTriples() throws RepositoryException,
public void setUp() throws RepositoryException {
initMocks(this);
when(mockNode.getSession()).thenReturn(mockSession);
when(mockNode.getPath()).thenReturn("/mockNode");
when(mockContentNode.getSession()).thenReturn(mockSession);
when(mockSession.getRepository()).thenReturn(mockRepository);
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
@@ -90,10 +91,8 @@ public void setUp() throws RepositoryException {
ImmutableSet.of(mockLowLevelCacheEntry));
when(mockLowLevelCacheEntry.getExternalIdentifier()).thenReturn(
MOCK_EXTERNAL_IDENTIFIER);
when(mockGraphSubjects.getGraphSubject(mockNode)).thenReturn(
mockSubject);
when(mockGraphSubjects.getGraphSubject(mockContentNode)).thenReturn(
mockContentSubject);
when(mockGraphSubjects.getGraphSubject(mockNode.getPath())).thenReturn(mockSubject);
when(mockGraphSubjects.getGraphSubject(mockContentNode.getPath())).thenReturn(mockContentSubject);
when(mockNode.getPrimaryNodeType()).thenReturn(mockNodeType);
when(mockContentNode.getPrimaryNodeType()).thenReturn(mockNodeType);
when(mockNodeType.getSupertypes()).thenReturn(new NodeType[] {mockNodeType});
@@ -361,8 +361,7 @@ public void setUp() throws ValueFormatException, RepositoryException {
when(mockProperty.getName()).thenReturn(TEST_PROPERTY_NAME);
when(mockProperty.getSession()).thenReturn(mockSession);
when(mockNode.getPath()).thenReturn(TEST_NODE_PATH);
when(mockGraphSubjects.getGraphSubject(mockNode)).thenReturn(
TEST_NODE_SUBJECT);
when(mockGraphSubjects.getGraphSubject(mockNode.getPath())).thenReturn(TEST_NODE_SUBJECT);
when(mockNode.getNode(TEST_NODE_PATH)).thenReturn(mockNode);
}

@@ -213,7 +213,7 @@ public void testGetFixityResultsModel() throws Exception {
.<Iterable<FixityResult>> any())).thenReturn(
new RdfStream());

when(mockSubjects.getGraphSubject(mockNode)).thenReturn(
when(mockSubjects.getGraphSubject(mockNode.getPath())).thenReturn(
createResource("abc"));
final RdfStream fixityResults =
testObj.getFixityResultsModel(mockSubjects, mockDatastream);
@@ -44,7 +44,7 @@ public void tearDown() throws Exception {
clearProps();
}

private void clearProps() {
private static void clearProps() {
System.clearProperty(PROP_FLAG);
System.clearProperty(PROP_TEST);
System.clearProperty(HOME_PROP);
@@ -81,7 +81,7 @@ public void testCustomHomeDirWithRelativeSubdirs() {

loader.loadSystemProperties();

File home = new File(asTempPath("test"));
final File home = new File(asTempPath("test"));
Assert.assertTrue("Relative subdirs are within fcrepo.home directory.",
containsPath(System.getProperty(PROP_TEST),
home.getAbsolutePath()));
@@ -95,7 +95,7 @@ public void testCustomHomeDirWithAbsoluteSubdirs() {

loader.loadSystemProperties();

File home = new File(asTempPath("test"));
final File home = new File(asTempPath("test"));
Assert.assertFalse("Absolute subdirs are idependent of fcrepo.home.",
containsPath(System.getProperty(PROP_TEST),
home.getAbsolutePath()));
@@ -114,7 +114,7 @@ public void relativePathsWorkForFedoraHome() {
clearProps();
}

private boolean containsPath(String path, String parentPath) {
private static boolean containsPath(final String path, final String parentPath) {
final File parent = new File(parentPath);
for (File f = new File(path) ; f.getParentFile() != null ; f = f.getParentFile()) {
if (f.getParentFile().equals(parent)) {
@@ -124,7 +124,7 @@ private boolean containsPath(String path, String parentPath) {
return false;
}

private String asTempPath(final String file) {
private static String asTempPath(final String file) {
return System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + file;
}
}
Oops, something went wrong.

0 comments on commit f0ae47c

Please sign in to comment.
You can’t perform that action at this time.