Commits

Sam Adams committed 3d9983b

Minor fixes identified by ATs

Comments (0)

Files changed (5)

chempound-api/src/main/java/net/chempound/storage/InMemoryResourceStore.java

 package net.chempound.storage;
 
+import javax.inject.Singleton;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 /**
  * @author Sam Adams
  */
+@Singleton
 public class InMemoryResourceStore implements ResourceStore {
 
     private final Map<String,LocalResource> map = new HashMap<String, LocalResource>();

chempound-app/src/main/java/net/chempound/EntryUriGenerator.java

 import net.chempound.datastore.TripleStore;
 
 import javax.inject.Inject;
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.util.UUID;
 
 /**
         if (slug != null) {
             slug = normalise(slug);
             if (slug.length() != 0) {
-                URI uri = baseUri.resolve(slug + "/");
+                URI uri = baseUri.resolve(urlEncode(slug) + "/");
                 if (tripleStore.containsResource(uri)) {
                     int i = 1;
                     do {
         return slug;
     }
 
+    private static String urlEncode(final String s) {
+        try {
+            return URLEncoder.encode(s, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("UTF-8 encoding error", e);
+        }
+    }
+    
 }

chempound-app/src/main/java/net/chempound/config/DefaultChempoundConfiguration.java

     }
 
     public void setBaseUri(final URI baseUri) {
-        final URI uri;
         if (baseUri.toString().endsWith("/")) {
             this.baseUri = baseUri;
         } else {

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

 
 import com.hp.hpl.jena.tdb.TDBFactory;
 
+import javax.inject.Singleton;
+
 /**
  * @author Sam Adams
  */
+@Singleton
 public class InMemoryJenaTripleStore extends JenaTripleStore {
 
     public InMemoryJenaTripleStore() {

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

         final Collection aggregation = model.getResource(collectionUri.toString()).as(Collection.class);
         o.put("aggregation", aggregation);
         o.put("items", itemMap);
+        o.put("title", aggregation.getTitle());
 
         final StringWriter buffer = new StringWriter();