chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r801782 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/
Date Thu, 06 Aug 2009 19:18:02 GMT
Author: fguillaume
Date: Thu Aug  6 19:18:02 2009
New Revision: 801782

URL: http://svn.apache.org/viewvc?rev=801782&view=rev
Log:
clean up url parsing for types

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=801782&r1=801781&r2=801782&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Thu Aug  6 19:18:02 2009
@@ -366,8 +366,6 @@
         SPI spi = repository.getSPI(); // TODO XXX connection leak
         if ("path".equals(getType())) {
             String path = "/" + resourceName;
-            // TODO decode properly
-            path = path.replace("%20", " ");
             return spi.getObjectByPath(path, null, false, false);
         } else { // object
             String id = resourceName;
@@ -383,7 +381,12 @@
         } else {
             name = "objectid";
         }
-        return request.getTarget().getParameter(name);
+        String resourceName = request.getTarget().getParameter(name);
+        // TODO decode properly
+        resourceName = resourceName.replace("%3a", ":");
+        resourceName = resourceName.replace("%3A", ":");
+        resourceName = resourceName.replace("%20", " ");
+        return resourceName;
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=801782&r1=801781&r2=801782&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
Thu Aug  6 19:18:02 2009
@@ -69,7 +69,7 @@
                 "objectid");
         targetResolver.setPattern("/allowableactions/([^/?]+)",
                 TargetType.TYPE_ENTRY, "objectid"); // XXX entry?
-        targetResolver.setPattern("/type/([^/?]+)", TargetType.TYPE_ENTRY,
+        targetResolver.setPattern("/type/([^/?]+)(\\?.*)?", TargetType.TYPE_ENTRY,
                 "typeid");
         targetResolver.setPattern("/path/([^?]*)", TargetType.TYPE_ENTRY,
                 "path");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=801782&r1=801781&r2=801782&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
Thu Aug  6 19:18:02 2009
@@ -40,6 +40,7 @@
 import org.apache.chemistry.PropertyType;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.abdera.PropertiesElement;
 
@@ -104,10 +105,10 @@
         }
 
         String link = getLink(type, feedIri, request);
-        entry.addLink(link, "self");
-        entry.addLink(link, "edit");
+        entry.addLink(link, AtomPub.LINK_SELF);
+        entry.addLink(link, AtomPub.LINK_EDIT);
         // alternate is mandated by Atom when there is no atom:content
-        entry.addLink(link, "alternate");
+        entry.addLink(link, AtomPub.LINK_ALTERNATE);
         // CMIS links
 
         // CMIS-specific
@@ -342,7 +343,12 @@
 
     @Override
     public String getResourceName(RequestContext request) {
-        return request.getTarget().getParameter("typeid");
+        String resourceName = request.getTarget().getParameter("typeid");
+        // TODO decode properly
+        resourceName = resourceName.replace("%3a", ":");
+        resourceName = resourceName.replace("%3A", ":");
+        resourceName = resourceName.replace("%20", " ");
+        return resourceName;
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java?rev=801782&r1=801781&r2=801782&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
Thu Aug  6 19:18:02 2009
@@ -17,7 +17,6 @@
 package org.apache.chemistry.atompub.abdera;
 
 import java.io.Serializable;
-import java.lang.reflect.Array;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -176,14 +175,18 @@
      * @return the list of serialized strings
      */
     // TODO move this to a helper somewhere else
-    @SuppressWarnings("null")
+    @SuppressWarnings( { "null", "unchecked" })
     public static List<String> getStringsForValue(Serializable value,
             PropertyDefinition propertyDefinition) {
         boolean multi = propertyDefinition.isMultiValued();
         List<String> values = null;
         if (multi) {
             if (value.getClass().isArray()) {
-                values = new ArrayList<String>(Array.getLength(value));
+                // turn it into a list to work with it easily
+                value = (Serializable) Arrays.asList((Serializable[]) value);
+            }
+            if (value instanceof List<?>) {
+                values = new ArrayList<String>(((List<?>) value).size());
             } else {
                 // TODO: complex property don't know how to handle skip it
                 return null;
@@ -194,14 +197,14 @@
         case PropertyType.STRING_ORD:
         case PropertyType.ID_ORD:
             if (multi) {
-                values.addAll(Arrays.asList((String[]) value));
+                values.addAll((List<? extends String>) value);
             } else {
                 values = Collections.singletonList((String) value);
             }
             break;
         case PropertyType.DECIMAL_ORD:
             if (multi) {
-                for (BigDecimal v : (BigDecimal[]) value) {
+                for (BigDecimal v : (List<? extends BigDecimal>) value) {
                     values.add(v.toString());
                 }
             } else {
@@ -210,7 +213,7 @@
             break;
         case PropertyType.INTEGER_ORD:
             if (multi) {
-                for (Number v : (Number[]) value) {
+                for (Number v : (List<? extends Number>) value) {
                     values.add(v.toString());
                 }
             } else {
@@ -219,7 +222,7 @@
             break;
         case PropertyType.BOOLEAN_ORD:
             if (multi) {
-                for (Boolean v : (Boolean[]) value) {
+                for (Boolean v : (List<? extends Boolean>) value) {
                     values.add(v.toString());
                 }
             } else {
@@ -228,7 +231,7 @@
             break;
         case PropertyType.DATETIME_ORD:
             if (multi) {
-                for (Calendar v : (Calendar[]) value) {
+                for (Calendar v : (List<? extends Calendar>) value) {
                     values.add(calendarString(v));
                 }
             } else {



Mime
View raw message