chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1605816 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/...
Date Thu, 26 Jun 2014 15:23:56 GMT
Author: fmui
Date: Thu Jun 26 15:23:56 2014
New Revision: 1605816

URL: http://svn.apache.org/r1605816
Log:
code cleanup and minor improvements

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AccessControlPrincipalDataImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yylex.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java
Thu Jun 26 15:23:56 2014
@@ -72,6 +72,7 @@ public class SessionFactoryImpl implemen
      * @deprecated Use
      *             {@link #createSession(Map, ObjectFactory, AuthenticationProvider, Cache)}
      */
+    @Deprecated
     public Session createSession(Map<String, String> parameters, ObjectFactory objectFactory,
             AuthenticationProvider authenticationProvider, Cache cache) {
         return createSession(parameters, objectFactory, authenticationProvider, cache, null);
@@ -115,6 +116,7 @@ public class SessionFactoryImpl implemen
      * @deprecated Use
      *             {@link #getRepositories(Map, ObjectFactory, AuthenticationProvider, Cache,
TypeDefinitionCache)}
      */
+    @Deprecated
     public List<Repository> getRepositories(Map<String, String> parameters, ObjectFactory
objectFactory,
             AuthenticationProvider authenticationProvider, Cache cache) {
         return getRepositories(parameters, objectFactory, authenticationProvider, cache,
null);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
Thu Jun 26 15:23:56 2014
@@ -591,7 +591,7 @@ public class ObjectFactoryImpl implement
         if (objectData.getBaseTypeId() == null) {
             throw new IllegalArgumentException("Base type ID property not set!");
         }
-        
+
         ObjectType type = getTypeFromObjectData(objectData);
 
         /* determine type */
@@ -684,11 +684,11 @@ public class ObjectFactoryImpl implement
 
     private void throwWrongTypeError(Object obj, String type, Class<?> clazz, String
id) {
         String expectedTypes;
-        if (clazz.equals(BigInteger.class)) {
+        if (BigInteger.class.isAssignableFrom(clazz)) {
             expectedTypes = "<BigInteger, Byte, Short, Integer, Long>";
-        } else if (clazz.equals(BigDecimal.class)) {
+        } else if (BigDecimal.class.isAssignableFrom(clazz)) {
             expectedTypes = "<BigDecimal, Double, Float, Byte, Short, Integer, Long>";
-        } else if (clazz.equals(GregorianCalendar.class)) {
+        } else if (GregorianCalendar.class.isAssignableFrom(clazz)) {
             expectedTypes = "<java.util.GregorianCalendar, java.util.Date>";
         } else {
             expectedTypes = clazz.getName();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AccessControlPrincipalDataImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AccessControlPrincipalDataImpl.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AccessControlPrincipalDataImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AccessControlPrincipalDataImpl.java
Thu Jun 26 15:23:56 2014
@@ -56,6 +56,7 @@ public class AccessControlPrincipalDataI
     /**
      * @deprecated use {@link #setId(String)}
      */
+    @Deprecated
     public void setPrincipalId(String principalId) {
         setId(principalId);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java
Thu Jun 26 15:23:56 2014
@@ -180,6 +180,7 @@ public class RepositoryCapabilitiesImpl 
     /**
      * @deprecated use {@link #setCapabilityOrderBy(CapabilityOrderBy)}
      */
+    @Deprecated
     public void setOrderByCapability(CapabilityOrderBy capabilityOrderBy) {
         setCapabilityOrderBy(capabilityOrderBy);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParser.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParser.java
Thu Jun 26 15:23:56 2014
@@ -554,9 +554,6 @@ public class JSONParser {
         } catch (RuntimeException re) {
             status = S_IN_ERROR;
             throw re;
-        } catch (Error e) {
-            status = S_IN_ERROR;
-            throw e;
         }
 
         status = S_IN_ERROR;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yylex.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yylex.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yylex.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yylex.java
Thu Jun 26 15:23:56 2014
@@ -514,17 +514,20 @@ class Yylex {
             switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
             case 11: {
                 sb.append(yytext());
+                break;
             }
             case 25:
                 break;
             case 4: {
                 sb.delete(0, sb.length());
                 yybegin(STRING_BEGIN);
+                break;
             }
             case 26:
                 break;
             case 16: {
                 sb.append('\b');
+                break;
             }
             case 27:
                 break;
@@ -552,6 +555,7 @@ class Yylex {
                 break;
             case 12: {
                 sb.append('\\');
+                break;
             }
             case 32:
                 break;
@@ -574,11 +578,13 @@ class Yylex {
                 break;
             case 19: {
                 sb.append('\r');
+                break;
             }
             case 36:
                 break;
             case 15: {
                 sb.append('/');
+                break;
             }
             case 37:
                 break;
@@ -589,6 +595,7 @@ class Yylex {
                 break;
             case 14: {
                 sb.append('"');
+                break;
             }
             case 39:
                 break;
@@ -599,6 +606,7 @@ class Yylex {
                 break;
             case 17: {
                 sb.append('\f');
+                break;
             }
             case 41:
                 break;
@@ -614,12 +622,12 @@ class Yylex {
                 break;
             case 20: {
                 sb.append('\t');
+                break;
             }
             case 43:
                 break;
-            case 7: {
+            case 7:
                 return new Yytoken(Yytoken.TYPE_LEFT_SQUARE, null);
-            }
             case 44:
                 break;
             case 2: {
@@ -630,16 +638,16 @@ class Yylex {
                 break;
             case 18: {
                 sb.append('\n');
+                break;
             }
             case 46:
                 break;
-            case 9: {
+            case 9:
                 return new Yytoken(Yytoken.TYPE_COMMA, null);
-            }
             case 47:
                 break;
-            case 3: {
-            }
+            case 3:
+                break;
             case 48:
                 break;
             default:

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
Thu Jun 26 15:23:56 2014
@@ -164,20 +164,19 @@ public class CmisAtomPubServlet extends 
     protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
             IOException {
 
-        if (METHOD_HEAD.equals(request.getMethod())) {
-            request = new HEADHttpServletRequestWrapper(request);
-            response = new NoBodyHttpServletResponseWrapper(response);
-        } else {
-            request = new QueryStringHttpServletRequestWrapper(request);
-        }
-
-        // set default headers
-        response.addHeader("Cache-Control", "private, max-age=0");
-        response.addHeader("Server", ServerVersion.OPENCMIS_SERVER);
-
-        // create a context object, dispatch and handle exceptions
         CallContext context = null;
         try {
+            if (METHOD_HEAD.equals(request.getMethod())) {
+                request = new HEADHttpServletRequestWrapper(request);
+                response = new NoBodyHttpServletResponseWrapper(response);
+            } else {
+                request = new QueryStringHttpServletRequestWrapper(request);
+            }
+
+            // set default headers
+            response.addHeader("Cache-Control", "private, max-age=0");
+            response.addHeader("Server", ServerVersion.OPENCMIS_SERVER);
+
             context = createContext(getServletContext(), request, response);
             dispatch(context, request, response);
         } catch (Exception e) {
@@ -194,10 +193,10 @@ public class CmisAtomPubServlet extends 
             } else {
                 printError(e, response);
             }
+        } finally {
+            // we are done.
+            response.flushBuffer();
         }
-
-        // we are done.
-        response.flushBuffer();
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
Thu Jun 26 15:23:56 2014
@@ -213,6 +213,8 @@ public abstract class AbstractBrowserSer
             Cookie transactionCookie = new Cookie(getCookieName(token), cookieValue);
             transactionCookie.setMaxAge(expiry);
             transactionCookie.setPath(request.getContextPath() + request.getServletPath()
+ "/" + repositoryId);
+            transactionCookie.setSecure(request.isSecure());
+
             response.addCookie(transactionCookie);
         }
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
Thu Jun 26 15:23:56 2014
@@ -209,14 +209,13 @@ public class CmisBrowserBindingServlet e
     @Override
     protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
             IOException {
-
-        // set default headers
-        response.addHeader("Cache-Control", "private, max-age=0");
-        response.addHeader("Server", ServerVersion.OPENCMIS_SERVER);
-
-        // create a context object, dispatch and handle exceptions
         CallContext context = null;
+
         try {
+            // set default headers
+            response.addHeader("Cache-Control", "private, max-age=0");
+            response.addHeader("Server", ServerVersion.OPENCMIS_SERVER);
+
             String method = request.getMethod();
 
             if (METHOD_GET.equals(method)) {
@@ -252,10 +251,10 @@ public class CmisBrowserBindingServlet e
             } else {
                 printError(context, e, request, response);
             }
+        } finally {
+            // we are done.
+            response.flushBuffer();
         }
-
-        // we are done.
-        response.flushBuffer();
     }
 
     // --------------------------------------------------------

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
Thu Jun 26 15:23:56 2014
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 
 public final class HttpUtils {
@@ -72,6 +73,14 @@ public final class HttpUtils {
         String[] result = p.substring(1).split("/");
         for (int i = 0; i < result.length; i++) {
             result[i] = IOUtils.decodeURL(result[i]);
+
+            // check for malicious characters
+            for (int j = 0; j < result[i].length(); j++) {
+                char c = result[i].charAt(j);
+                if (c == '\n' || c == '\r' || c == '\b' || c == 0) {
+                    throw new CmisInvalidArgumentException("Invalid path!");
+                }
+            }
         }
 
         return result;

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java?rev=1605816&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java
Thu Jun 26 15:23:56 2014
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.server.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.server.shared.HttpUtils;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class HttpUtilsTest {
+
+    @Test
+    public void testSplitPath() throws Exception {
+        String[] fragments;
+
+        fragments = HttpUtils.splitPath(createRequest("f1/f2/f3/f4"));
+        assertNotNull(fragments);
+        assertEquals(4, fragments.length);
+        assertEquals("f1", fragments[0]);
+        assertEquals("f2", fragments[1]);
+        assertEquals("f3", fragments[2]);
+        assertEquals("f4", fragments[3]);
+
+        fragments = HttpUtils.splitPath(createRequest("f1/" + URLEncoder.encode(" !§$%&/()?@",
"UTF-8") + "/f3"));
+        assertNotNull(fragments);
+        assertEquals(3, fragments.length);
+        assertEquals("f1", fragments[0]);
+        assertEquals(" !§$%&/()?@", fragments[1]);
+        assertEquals("f3", fragments[2]);
+
+        try {
+            HttpUtils.splitPath(createRequest("f1/" + URLEncoder.encode("xxx\nxxx", "UTF-8")
+ "/f3"));
+            fail("CmisInvalidArgumentException expected!");
+        } catch (CmisInvalidArgumentException iae) {
+            // expected
+        }
+
+        try {
+            HttpUtils.splitPath(createRequest("f1/" + URLEncoder.encode("xxx\rxxx", "UTF-8")
+ "/f3"));
+            fail("CmisInvalidArgumentException expected!");
+        } catch (CmisInvalidArgumentException iae) {
+            // expected
+        }
+
+        try {
+            HttpUtils.splitPath(createRequest("f1/" + URLEncoder.encode("xxx\bxxx", "UTF-8")
+ "/f3"));
+            fail("CmisInvalidArgumentException expected!");
+        } catch (CmisInvalidArgumentException iae) {
+            // expected
+        }
+
+        try {
+            HttpUtils.splitPath(createRequest("f1/" + URLEncoder.encode("xxx\u0000xxx", "UTF-8")
+ "/f3"));
+            fail("CmisInvalidArgumentException expected!");
+        } catch (CmisInvalidArgumentException iae) {
+            // expected
+        }
+    }
+
+    private HttpServletRequest createRequest(String path) {
+        HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+        Mockito.when(request.getContextPath()).thenReturn("/context");
+        Mockito.when(request.getServletPath()).thenReturn("/servlet");
+        Mockito.when(request.getRequestURI()).thenReturn("/context/servlet/" + path);
+
+        return request;
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/HttpUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
Thu Jun 26 15:23:56 2014
@@ -30,6 +30,7 @@ import org.apache.chemistry.opencmis.ser
  * 
  * @deprecated use {@link ConformanceCmisServiceWrapper} instead
  */
+@Deprecated
 public class CmisServiceWrapper<T extends CmisService> extends ConformanceCmisServiceWrapper
{
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
Thu Jun 26 15:23:56 2014
@@ -46,8 +46,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 
 public final class TypeValidator {
-    
-    private TypeValidator() {        
+
+    private TypeValidator() {
     }
 
     public static void validateRequiredSystemProperties(Properties properties) {
@@ -114,8 +114,7 @@ public final class TypeValidator {
             // check if value is in list
             if (hasMultiValueChoiceLists) {
                 // do a complex check if this combination of actual values is
-                // allowed
-                // check if value is in list
+                // allowed check if value is in list
                 isAllowedValue = false;
                 List<?> actualValues = prop.getValues();
                 for (Choice<?> allowedValue : propDef.getChoices()) {
@@ -257,7 +256,7 @@ public final class TypeValidator {
                 String propertyId = prop.getId();
                 if (null == propertyId) {
                     throw new CmisInvalidArgumentException("Property id cannot be null");
-                }                
+                }
                 BaseTypeId baseTypeId = typeDef.getBaseTypeId();
 
                 // check that all mandatory attributes are present
@@ -528,7 +527,7 @@ public final class TypeValidator {
             } else if (propertyId.equals(PropertyIds.PATH)) {
                 return true;
             }
-            
+
             return false;
         } else if (baseTypeId.equals(BaseTypeId.CMIS_POLICY)) {
             if (propertyId.equals(PropertyIds.SOURCE_ID)) {
@@ -541,7 +540,7 @@ public final class TypeValidator {
             if (propertyId.equals(PropertyIds.POLICY_TEXT)) {
                 return true;
             }
-            
+
             return false;
         }
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
Thu Jun 26 15:23:56 2014
@@ -20,7 +20,9 @@ package org.apache.chemistry.opencmis.se
 
 public class FunctionReference extends CmisSelector {
 
-    public enum CmisQlFunction { SCORE, }
+    public enum CmisQlFunction {
+        SCORE
+    }
 
     private final CmisQlFunction function;
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
Thu Jun 26 15:23:56 2014
@@ -42,6 +42,7 @@ import org.apache.chemistry.opencmis.ser
  * 
  * @deprecated Use {@link QueryUtilBase} instead.
  */
+@Deprecated
 public class QueryUtil extends QueryUtilBase<CmisQueryWalker> {
     
     public QueryUtil() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java?rev=1605816&r1=1605815&r2=1605816&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
Thu Jun 26 15:23:56 2014
@@ -72,8 +72,8 @@ public class FractalGenerator {
     private static final String COLORS_WARPED = "warped";
     private static final String COLORS_WILD = "wild";
     private static final String COLORS_ZEBRA = "zebra";
-    private final String[] colorSchemes = { COLORS_BLACK_AND_WHITE, COLORS_BLUE_ICE, COLORS_FUNKY,
COLORS_PASTEL,
-            COLORS_PSYCHEDELIC, COLORS_PURPLE_HAZE, COLORS_RADICAL, COLORS_RAINBOW, COLORS_RAINBOWS,
+    private static final String[] colorSchemes = { COLORS_BLACK_AND_WHITE, COLORS_BLUE_ICE,
COLORS_FUNKY,
+            COLORS_PASTEL, COLORS_PSYCHEDELIC, COLORS_PURPLE_HAZE, COLORS_RADICAL, COLORS_RAINBOW,
COLORS_RAINBOWS,
             COLORS_SCINTILLATION, COLORS_WARPED, COLORS_WILD, COLORS_ZEBRA };
     private static final int IMAGE_HEIGHT = 512; // default
     private static final int IMAGE_WIDTH = 512; // default



Mime
View raw message