Sam Adams avatar Sam Adams committed f2eacd3

Added constants

Comments (0)

Files changed (11)

chempound-app/src/main/java/net/chempound/datastore/JenaTripleStore.java

 import com.hp.hpl.jena.tdb.TDBFactory;
 import com.hp.hpl.jena.vocabulary.RDF;
 import net.chempound.config.ChempoundConfiguration;
+import net.chempound.rdf.CPTerms;
 import net.chempound.rdf.ORE;
 import org.apache.commons.io.FileUtils;
 
 
     @Override
     public URI getAggregationUriForResourceMap(final Resource resource) {
+        if (containsTriple(resource, RDF.type, CPTerms.Item)) {
+            return URI.create(resource.getURI());
+        }
         final DatasetGraph datasetGraph = getDataset().asDatasetGraph();
         final Iterator<Quad> it = datasetGraph.find(Node.ANY, resource.asNode(), ORE.describes.asNode(), Node.ANY);
         if (it.hasNext()) {

chempound-client/pom.xml

         <dependency>
             <groupId>org.swordapp</groupId>
             <artifactId>sword-client</artifactId>
-            <version>2.0-r339</version>
+            <version>${sword.version}</version>
         </dependency>
 
     </dependencies>

chempound-webapp/pom.xml

             <artifactId>org.restlet.ext.json</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20080701</version>
+        </dependency>
+        <dependency>
             <groupId>org.restlet.jee</groupId>
             <artifactId>org.restlet.ext.servlet</artifactId>
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>1.8.5</version>
             <scope>test</scope>
         </dependency>
         <dependency>

chempound-webapp/src/main/java/net/chempound/webapp/RestletConstants.java

+package net.chempound.webapp;
+
+import org.restlet.engine.http.header.HeaderConstants;
+
+/**
+ * @author Sam Adams
+ */
+public class RestletConstants {
+
+    public static final String ATTRIBUTE_HEADERS = HeaderConstants.ATTRIBUTE_HEADERS;
+
+}

chempound-webapp/src/main/java/net/chempound/webapp/content/CollectionResource.java

 import java.io.IOException;
 import java.io.InputStream;
 
+import static net.chempound.webapp.RestletConstants.ATTRIBUTE_HEADERS;
 import static org.restlet.data.MediaType.APPLICATION_ATOM;
-import static org.restlet.engine.http.header.HeaderConstants.ATTRIBUTE_HEADERS;
 
 /**
  * @author Sam Adams

chempound-webapp/src/main/java/net/chempound/webapp/content/ResourceMapResource.java

 import java.util.Iterator;
 import java.util.Map;
 
-import static org.restlet.engine.http.header.HeaderConstants.ATTRIBUTE_HEADERS;
+import static net.chempound.webapp.RestletConstants.ATTRIBUTE_HEADERS;
 
 /**
  * @author Sam Adams

chempound-webapp/src/main/java/net/chempound/webapp/pingback/PingbackService.java

     }
 
     private boolean alreadyRegistered(final URI sourceUri, final URI targetUri) {
-        // TODO check whether URI already registered
-        return false;
+        final Resource sourceResource = ResourceFactory.createResource(sourceUri.toString());
+        final Resource targetResource = ResourceFactory.createResource(targetUri.toString());
+        return tripleStore.containsTriple(targetResource, CPTerms.pingback, sourceResource);
     }
 
     private void registerPingback(final URI sourceUri, final URI targetUri) {

chempound-webapp/src/main/java/net/chempound/webapp/splashpage/SplashPageGenerator.java

         return new TemplateRepresentation(template, map, MediaType.TEXT_HTML);
     }
 
-    private boolean isCollection(final Model model, final URI aggregationUri) {
+    private static boolean isCollection(final Model model, final URI aggregationUri) {
         final Resource resource = ResourceFactory.createResource(aggregationUri.toString());
         return model.contains(resource, RDF.type, CPTerms.Collection);
     }

chempound-webapp/src/main/java/net/chempound/webapp/sword/CollectionResource.java

 import java.io.InputStream;
 
 import static org.restlet.data.MediaType.APPLICATION_ATOM;
-import static org.restlet.engine.http.header.HeaderConstants.ATTRIBUTE_HEADERS;
+import static net.chempound.webapp.RestletConstants.ATTRIBUTE_HEADERS;
 
 /**
  * @author sea36

chempound-webapp/src/test/java/net/chempound/webapp/content/ResourceMapResourceTest.java

 
         SplashPageGenerator splashPageGenerator = mock(SplashPageGenerator.class);
         when(splashPageGenerator.createSplashPage(Matchers.<URI>any())).thenReturn(new StringRepresentation("<html></html>", MediaType.TEXT_HTML));
-        splashProvider = mock(Provider.class);
+        splashProvider = mockSplashPageGeneratorProvider();
         when(splashProvider.get()).thenReturn(splashPageGenerator);
 
         Application application = new Application();
         aggregation.addResourceMap(rem);
     }
 
+    @SuppressWarnings("unchecked")
+    private static Provider<SplashPageGenerator> mockSplashPageGeneratorProvider() {
+        return mock(Provider.class);
+    }
 }
             <dependency>
                 <groupId>org.swordapp</groupId>
                 <artifactId>server</artifactId>
-                <version>2.0-r339</version>
+                <version>${sword.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.swordapp</groupId>
                 <artifactId>sword-client</artifactId>
-                <version>2.0-r339</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.freemarker</groupId>
-                <artifactId>freemarker</artifactId>
-                <version>2.3.18</version>
+                <version>${sword.version}</version>
             </dependency>
 
             <dependency>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.