You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/03/24 12:35:45 UTC

svn commit: r1084907 - /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java

Author: fmui
Date: Thu Mar 24 11:35:45 2011
New Revision: 1084907

URL: http://svn.apache.org/viewvc?rev=1084907&view=rev
Log:
CMIS-339: filter unnecessary links

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java?rev=1084907&r1=1084906&r2=1084907&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java Thu Mar 24 11:35:45 2011
@@ -21,7 +21,9 @@ package org.apache.chemistry.opencmis.cl
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.chemistry.opencmis.client.bindings.cache.Cache;
 import org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl;
@@ -30,6 +32,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl;
 import org.apache.chemistry.opencmis.client.bindings.spi.Session;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 
 /**
@@ -39,6 +42,22 @@ public class LinkCache implements Serial
 
     private static final long serialVersionUID = 1L;
 
+    private static final Set<String> KNOWN_LINKS = new HashSet<String>();
+
+    static {
+        KNOWN_LINKS.add(Constants.REL_ACL);
+        KNOWN_LINKS.add(Constants.REL_DOWN);
+        KNOWN_LINKS.add(Constants.REL_UP);
+        KNOWN_LINKS.add(Constants.REL_FOLDERTREE);
+        KNOWN_LINKS.add(Constants.REL_RELATIONSHIPS);
+        KNOWN_LINKS.add(Constants.REL_SELF);
+        KNOWN_LINKS.add(Constants.REL_ALLOWABLEACTIONS);
+        KNOWN_LINKS.add(Constants.REL_EDITMEDIA);
+        KNOWN_LINKS.add(Constants.REL_POLICIES);
+        KNOWN_LINKS.add(Constants.REL_VERSIONHISTORY);
+        KNOWN_LINKS.add(AtomPubParser.LINK_REL_CONTENT);
+    }
+
     private static final int CACHE_SIZE_REPOSITORIES = 10;
     private static final int CACHE_SIZE_TYPES = 100;
     private static final int CACHE_SIZE_OBJECTS = 400;
@@ -72,7 +91,7 @@ public class LinkCache implements Serial
         linkCache.initialize(new String[] {
                 MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository
                 LruCacheLevelImpl.class.getName() + " " + LruCacheLevelImpl.MAX_ENTRIES + "=" + objCount, // id
-                MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=16", // rel
+                MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=12", // rel
                 ContentTypeCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=3,"
                         + MapCacheLevelImpl.SINGLE_VALUE + "=true" // type
         });
@@ -81,7 +100,7 @@ public class LinkCache implements Serial
         typeLinkCache.initialize(new String[] {
                 MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository
                 LruCacheLevelImpl.class.getName() + " " + LruCacheLevelImpl.MAX_ENTRIES + "=" + typeCount, // id
-                MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=16", // rel
+                MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=12", // rel
                 ContentTypeCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=3,"
                         + MapCacheLevelImpl.SINGLE_VALUE + "=true"// type
         });
@@ -109,7 +128,9 @@ public class LinkCache implements Serial
      * Adds a link.
      */
     public void addLink(String repositoryId, String id, String rel, String type, String link) {
-        linkCache.put(link, repositoryId, id, rel, type);
+        if (KNOWN_LINKS.contains(rel)) {
+            linkCache.put(link, repositoryId, id, rel, type);
+        }
     }
 
     /**
@@ -158,7 +179,9 @@ public class LinkCache implements Serial
      * Adds a type link.
      */
     public void addTypeLink(String repositoryId, String id, String rel, String type, String link) {
-        typeLinkCache.put(link, repositoryId, id, rel, type);
+        if (KNOWN_LINKS.contains(rel)) {
+            typeLinkCache.put(link, repositoryId, id, rel, type);
+        }
     }
 
     /**