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 2010/10/05 16:35:25 UTC
svn commit: r1004655 - in /incubator/chemistry/opencmis/trunk:
chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/
chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/ja...
Author: fmui
Date: Tue Oct 5 14:35:24 2010
New Revision: 1004655
URL: http://svn.apache.org/viewvc?rev=1004655&view=rev
Log:
- moved more code around for the browser binding (should have no effect on APIs and implementations)
Added:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java (with props)
Removed:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/Dispatcher.java
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomPubUtils.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java Tue Oct 5 14:35:24 2010
@@ -112,6 +112,7 @@ public final class Constants {
public static final String PARAM_ID = "id";
public static final String PARAM_MAJOR = "major";
public static final String PARAM_MAX_ITEMS = "maxItems";
+ public static final String PARAM_OBJECT_ID = "objectId";
public static final String PARAM_ONLY_BASIC_PERMISSIONS = "onlyBasicPermissions";
public static final String PARAM_ORDER_BY = "orderBy";
public static final String PARAM_OVERWRITE_FLAG = "overwriteFlag";
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java Tue Oct 5 14:35:24 2010
@@ -30,17 +30,15 @@ import org.apache.chemistry.opencmis.com
/**
* Utility class that helps building URLs.
- *
- * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
*/
public class UrlBuilder {
- private StringBuilder fUrl;
- private StringBuilder fQuery;
+ private StringBuilder urlPart;
+ private StringBuilder queryPart;
/**
* Constructor.
- *
+ *
* @param url
* initial URL
*/
@@ -49,23 +47,23 @@ public class UrlBuilder {
throw new IllegalArgumentException("URL must be set");
}
- fUrl = new StringBuilder();
- fQuery = new StringBuilder();
+ urlPart = new StringBuilder();
+ queryPart = new StringBuilder();
int qm = url.indexOf('?');
if (qm == -1) {
- fUrl.append(url);
+ urlPart.append(url);
} else {
- fUrl.append(url.substring(0, qm));
+ urlPart.append(url.substring(0, qm));
if (qm < url.length()) {
- fQuery.append(url.substring(qm + 1));
+ queryPart.append(url.substring(qm + 1));
}
}
}
/**
* Constructor.
- *
+ *
* @param scheme
* scheme
* @param host
@@ -84,17 +82,17 @@ public class UrlBuilder {
port = -1;
}
- fUrl = new StringBuilder();
- fQuery = new StringBuilder();
+ urlPart = new StringBuilder();
+ queryPart = new StringBuilder();
- fUrl.append(scheme);
- fUrl.append("://");
- fUrl.append(host);
+ urlPart.append(scheme);
+ urlPart.append("://");
+ urlPart.append(host);
if (port > 0) {
- fUrl.append(":" + port);
+ urlPart.append(":" + port);
}
if (path != null) {
- fUrl.append(path);
+ urlPart.append(path);
}
}
@@ -102,66 +100,71 @@ public class UrlBuilder {
* Copy constructor.
*/
public UrlBuilder(UrlBuilder urlBuilder) {
- fUrl = new StringBuilder(urlBuilder.fUrl);
- fQuery = new StringBuilder(urlBuilder.fQuery);
+ urlPart = new StringBuilder(urlBuilder.urlPart);
+ queryPart = new StringBuilder(urlBuilder.queryPart);
}
/**
* Adds a parameter to the URL.
- *
+ *
* @param name
* parameter name
* @param value
* parameter value
*/
- public void addParameter(String name, Object value) {
+ public UrlBuilder addParameter(String name, Object value) {
if ((name == null) || (value == null)) {
- return;
+ return this;
}
String valueStr = normalizeParameter(value);
- if (fQuery.length() > 0) {
- fQuery.append('&');
+ if (queryPart.length() > 0) {
+ queryPart.append('&');
}
- fQuery.append(name);
- fQuery.append("=");
+ queryPart.append(name);
+ queryPart.append("=");
try {
- fQuery.append(URLEncoder.encode(valueStr, "UTF-8"));
+ queryPart.append(URLEncoder.encode(valueStr, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
+
+ return this;
}
/**
* Adds a path segment to the URL.
- *
+ *
* @param pathSegment
* the path segment.
*/
- public void addPathSegment(String pathSegment) {
- addPathPart(pathSegment, true);
+ public UrlBuilder addPathSegment(String pathSegment) {
+ return addPathPart(pathSegment, true);
}
/**
* Adds a path to the URL.
- *
- * @param path the path
+ *
+ * @param path
+ * the path
*/
- public void addPath(String path) {
- addPathPart(path, false);
+ public UrlBuilder addPath(String path) {
+ return addPathPart(path, false);
}
- protected void addPathPart(String part, boolean quoteSlash) {
+ protected UrlBuilder addPathPart(String part, boolean quoteSlash) {
if (part == null || part.length() == 0) {
- return;
+ return this;
}
- if (fUrl.charAt(fUrl.length() - 1) != '/') {
- fUrl.append('/');
+ if (urlPart.charAt(urlPart.length() - 1) != '/') {
+ urlPart.append('/');
}
if (part.charAt(0) == '/') {
part = part.substring(1);
}
- fUrl.append(quoteURIPathComponent(part, quoteSlash));
+ urlPart.append(quoteURIPathComponent(part, quoteSlash));
+
+ return this;
}
public static char[] RFC7232_RESERVED = ";?:@&=+$,[]".toCharArray();
@@ -182,7 +185,7 @@ public class UrlBuilder {
// quote some additional reserved characters to be safe
for (char c : RFC7232_RESERVED) {
if (r.indexOf(c) >= 0) {
- r = r.replace(""+c, "%" + Integer.toHexString(c));
+ r = r.replace("" + c, "%" + Integer.toHexString(c));
}
}
if (quoteSlash && r.indexOf('/') >= 0) {
@@ -216,6 +219,6 @@ public class UrlBuilder {
@Override
public String toString() {
- return fUrl.toString() + (fQuery.length() == 0 ? "" : "?" + fQuery.toString());
+ return urlPart.toString() + (queryPart.length() == 0 ? "" : "?" + queryPart.toString());
}
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java Tue Oct 5 14:35:24 2010
@@ -19,9 +19,9 @@
package org.apache.chemistry.opencmis.server.impl.atompub;
import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomPubUtils.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomPubUtils.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomPubUtils.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomPubUtils.java Tue Oct 5 14:35:24 2010
@@ -22,11 +22,9 @@
*/
package org.apache.chemistry.opencmis.server.impl.atompub;
-import java.lang.reflect.Method;
import java.math.BigInteger;
import java.util.GregorianCalendar;
import java.util.List;
-import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBException;
@@ -34,12 +32,9 @@ import javax.xml.stream.XMLStreamExcepti
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
@@ -122,138 +117,6 @@ public final class AtomPubUtils {
}
// -------------------------------------------------------------------------
- // --- parameters ---
- // -------------------------------------------------------------------------
-
- /**
- * Extracts a string parameter.
- */
- @SuppressWarnings("unchecked")
- public static String getStringParameter(HttpServletRequest request, String name) {
- if (name == null) {
- return null;
- }
-
- Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap();
- for (Map.Entry<String, String[]> parameter : parameters.entrySet()) {
- if (name.equalsIgnoreCase(parameter.getKey())) {
- if (parameter.getValue() == null) {
- return null;
- }
- return parameter.getValue()[0];
- }
- }
-
- return null;
- }
-
- /**
- * Extracts a boolean parameter (with default).
- */
- public static boolean getBooleanParameter(HttpServletRequest request, String name, boolean def) {
- String value = getStringParameter(request, name);
- if (value == null) {
- return def;
- }
-
- return Boolean.valueOf(value);
- }
-
- /**
- * Extracts a boolean parameter.
- */
- public static Boolean getBooleanParameter(HttpServletRequest request, String name) {
- String value = getStringParameter(request, name);
- if (value == null) {
- return null;
- }
-
- return Boolean.valueOf(value);
- }
-
- /**
- * Extracts an integer parameter (with default).
- */
- public static BigInteger getBigIntegerParameter(HttpServletRequest request, String name, long def) {
- BigInteger result = getBigIntegerParameter(request, name);
- if (result == null) {
- result = BigInteger.valueOf(def);
- }
-
- return result;
- }
-
- /**
- * Extracts an integer parameter.
- */
- public static BigInteger getBigIntegerParameter(HttpServletRequest request, String name) {
- String value = getStringParameter(request, name);
- if (value == null) {
- return null;
- }
-
- try {
- return new BigInteger(value);
- } catch (Exception e) {
- throw new CmisInvalidArgumentException("Invalid parameter '" + name + "'!");
- }
- }
-
- /**
- * Extracts an enum parameter.
- */
- @SuppressWarnings("unchecked")
- public static <T> T getEnumParameter(HttpServletRequest request, String name, Class<T> clazz) {
- String value = getStringParameter(request, name);
- if ((value == null) || (value.length() == 0)) {
- return null;
- }
-
- try {
- Method m = clazz.getMethod("fromValue", new Class[] { String.class });
- return (T) m.invoke(null, new Object[] { value });
- } catch (Exception e) {
- if (e instanceof IllegalArgumentException) {
- throw new CmisInvalidArgumentException("Invalid parameter '" + name + "'!");
- }
-
- throw new CmisRuntimeException(e.getMessage(), e);
- }
- }
-
- /**
- * Extracts a property from an object.
- */
- @SuppressWarnings("unchecked")
- public static <T> T getProperty(ObjectData object, String name, Class<T> clazz) {
- if (object == null) {
- return null;
- }
-
- Properties propData = object.getProperties();
- if (propData == null) {
- return null;
- }
-
- Map<String, PropertyData<?>> properties = propData.getProperties();
- if (properties == null) {
- return null;
- }
-
- PropertyData<?> property = properties.get(name);
- if (property == null) {
- return null;
- }
-
- Object value = property.getFirstValue();
- if (!clazz.isInstance(value)) {
- return null;
- }
-
- return (T) value;
- }
-
- // -------------------------------------------------------------------------
// --- entry builder ---
// -------------------------------------------------------------------------
Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java Tue Oct 5 14:35:24 2010
@@ -45,6 +45,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
import org.apache.chemistry.opencmis.server.shared.CallContextHandler;
+import org.apache.chemistry.opencmis.server.shared.Dispatcher;
import org.apache.chemistry.opencmis.server.shared.HttpUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -58,11 +59,6 @@ public class CmisAtomPubServlet extends
public static final String PARAM_CALL_CONTEXT_HANDLER = "callContextHandler";
- private static final String METHOD_GET = "GET";
- private static final String METHOD_POST = "POST";
- private static final String METHOD_PUT = "PUT";
- private static final String METHOD_DELETE = "DELETE";
-
private static final Log LOG = LogFactory.getLog(CmisAtomPubServlet.class.getName());
private Dispatcher dispatcher;
@@ -87,55 +83,69 @@ public class CmisAtomPubServlet extends
dispatcher = new Dispatcher();
try {
- dispatcher.addResource(AtomPubUtils.RESOURCE_TYPES, METHOD_GET, RepositoryService.class, "getTypeChildren");
- dispatcher.addResource(AtomPubUtils.RESOURCE_TYPESDESC, METHOD_GET, RepositoryService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_TYPES, Dispatcher.METHOD_GET, RepositoryService.class,
+ "getTypeChildren");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_TYPESDESC, Dispatcher.METHOD_GET, RepositoryService.class,
"getTypeDescendants");
- dispatcher
- .addResource(AtomPubUtils.RESOURCE_TYPE, METHOD_GET, RepositoryService.class, "getTypeDefinition");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, METHOD_GET, NavigationService.class, "getChildren");
- dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, METHOD_GET, NavigationService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_TYPE, Dispatcher.METHOD_GET, RepositoryService.class,
+ "getTypeDefinition");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, Dispatcher.METHOD_GET, NavigationService.class,
+ "getChildren");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, Dispatcher.METHOD_GET, NavigationService.class,
"getDescendants");
- dispatcher.addResource(AtomPubUtils.RESOURCE_FOLDERTREE, METHOD_GET, NavigationService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_FOLDERTREE, Dispatcher.METHOD_GET, NavigationService.class,
"getFolderTree");
- dispatcher.addResource(AtomPubUtils.RESOURCE_PARENTS, METHOD_GET, NavigationService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_PARENTS, Dispatcher.METHOD_GET, NavigationService.class,
"getObjectParents");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CHECKEDOUT, METHOD_GET, NavigationService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CHECKEDOUT, Dispatcher.METHOD_GET, NavigationService.class,
"getCheckedOutDocs");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, METHOD_GET, ObjectService.class, "getObject");
- dispatcher.addResource(AtomPubUtils.RESOURCE_OBJECTBYID, METHOD_GET, ObjectService.class, "getObject");
- dispatcher.addResource(AtomPubUtils.RESOURCE_OBJECTBYPATH, METHOD_GET, ObjectService.class,
+ dispatcher
+ .addResource(AtomPubUtils.RESOURCE_ENTRY, Dispatcher.METHOD_GET, ObjectService.class, "getObject");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_OBJECTBYID, Dispatcher.METHOD_GET, ObjectService.class,
+ "getObject");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_OBJECTBYPATH, Dispatcher.METHOD_GET, ObjectService.class,
"getObjectByPath");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ALLOWABLEACIONS, METHOD_GET, ObjectService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_ALLOWABLEACIONS, Dispatcher.METHOD_GET, ObjectService.class,
"getAllowableActions");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, METHOD_GET, ObjectService.class, "getContentStream");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, METHOD_PUT, ObjectService.class, "setContentStream");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, METHOD_DELETE, ObjectService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, Dispatcher.METHOD_GET, ObjectService.class,
+ "getContentStream");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, Dispatcher.METHOD_PUT, ObjectService.class,
+ "setContentStream");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CONTENT, Dispatcher.METHOD_DELETE, ObjectService.class,
"deleteContentStream");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, METHOD_POST, ObjectService.class, "create");
- dispatcher.addResource(AtomPubUtils.RESOURCE_RELATIONSHIPS, METHOD_POST, ObjectService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, Dispatcher.METHOD_POST, ObjectService.class,
+ "create");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_RELATIONSHIPS, Dispatcher.METHOD_POST, ObjectService.class,
"createRelationship");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, METHOD_PUT, ObjectService.class, "updateProperties");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, METHOD_DELETE, ObjectService.class, "deleteObject");
- dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, METHOD_DELETE, ObjectService.class, "deleteTree");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CHECKEDOUT, METHOD_POST, VersioningService.class, "checkOut");
- dispatcher.addResource(AtomPubUtils.RESOURCE_VERSIONS, METHOD_GET, VersioningService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, Dispatcher.METHOD_PUT, ObjectService.class,
+ "updateProperties");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, Dispatcher.METHOD_DELETE, ObjectService.class,
+ "deleteObject");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, Dispatcher.METHOD_DELETE, ObjectService.class,
+ "deleteTree");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CHECKEDOUT, Dispatcher.METHOD_POST, VersioningService.class,
+ "checkOut");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_VERSIONS, Dispatcher.METHOD_GET, VersioningService.class,
"getAllVersions");
- dispatcher.addResource(AtomPubUtils.RESOURCE_VERSIONS, METHOD_DELETE, VersioningService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_VERSIONS, Dispatcher.METHOD_DELETE, VersioningService.class,
"deleteAllVersions");
- dispatcher.addResource(AtomPubUtils.RESOURCE_QUERY, METHOD_GET, DiscoveryService.class, "query");
- dispatcher.addResource(AtomPubUtils.RESOURCE_QUERY, METHOD_POST, DiscoveryService.class, "query");
- dispatcher.addResource(AtomPubUtils.RESOURCE_CHANGES, METHOD_GET, DiscoveryService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_QUERY, Dispatcher.METHOD_GET, DiscoveryService.class, "query");
+ dispatcher
+ .addResource(AtomPubUtils.RESOURCE_QUERY, Dispatcher.METHOD_POST, DiscoveryService.class, "query");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_CHANGES, Dispatcher.METHOD_GET, DiscoveryService.class,
"getContentChanges");
- dispatcher.addResource(AtomPubUtils.RESOURCE_RELATIONSHIPS, METHOD_GET, RelationshipService.class,
- "getObjectRelationships");
- dispatcher.addResource(AtomPubUtils.RESOURCE_UNFILED, METHOD_POST, MultiFilingService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_RELATIONSHIPS, Dispatcher.METHOD_GET,
+ RelationshipService.class, "getObjectRelationships");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_UNFILED, Dispatcher.METHOD_POST, MultiFilingService.class,
"removeObjectFromFolder");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ACL, METHOD_GET, AclService.class, "getAcl");
- dispatcher.addResource(AtomPubUtils.RESOURCE_ACL, METHOD_PUT, AclService.class, "applyAcl");
- dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, METHOD_GET, PolicyService.class,
+ dispatcher.addResource(AtomPubUtils.RESOURCE_ACL, Dispatcher.METHOD_GET, AclService.class, "getAcl");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_ACL, Dispatcher.METHOD_PUT, AclService.class, "applyAcl");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, Dispatcher.METHOD_GET, PolicyService.class,
"getAppliedPolicies");
- dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, METHOD_POST, PolicyService.class, "applyPolicy");
- dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, METHOD_DELETE, PolicyService.class, "removePolicy");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, Dispatcher.METHOD_POST, PolicyService.class,
+ "applyPolicy");
+ dispatcher.addResource(AtomPubUtils.RESOURCE_POLICIES, Dispatcher.METHOD_DELETE, PolicyService.class,
+ "removePolicy");
} catch (NoSuchMethodException e) {
LOG.error("Cannot initialize dispatcher!", e);
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java Tue Oct 5 14:35:24 2010
@@ -23,11 +23,11 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_QUERY;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.math.BigInteger;
import java.util.GregorianCalendar;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java Tue Oct 5 14:35:24 2010
@@ -21,8 +21,8 @@ package org.apache.chemistry.opencmis.se
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_ENTRY;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java Tue Oct 5 14:35:24 2010
@@ -33,11 +33,11 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.math.BigInteger;
import java.util.GregorianCalendar;
@@ -108,8 +108,8 @@ public final class NavigationService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
- .getLastModificationDate(), null, children.getNumItems());
+ feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(),
+ folderInfo.getLastModificationDate(), null, children.getNumItems());
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
@@ -139,8 +139,8 @@ public final class NavigationService {
if (folderInfo.getRenditionInfos() != null) {
for (RenditionInfo ri : folderInfo.getRenditionInfos()) {
- feed.writeAlternateLink(compileUrl(baseUrl, RESOURCE_CONTENT, ri.getId()), ri.getContenType(), ri
- .getKind(), ri.getTitle(), ri.getLength());
+ feed.writeAlternateLink(compileUrl(baseUrl, RESOURCE_CONTENT, ri.getId()), ri.getContenType(),
+ ri.getKind(), ri.getTitle(), ri.getLength());
}
}
@@ -225,8 +225,8 @@ public final class NavigationService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
- .getLastModificationDate(), null, null);
+ feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(),
+ folderInfo.getLastModificationDate(), null, null);
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
@@ -300,8 +300,8 @@ public final class NavigationService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
- .getLastModificationDate(), null, null);
+ feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(),
+ folderInfo.getLastModificationDate(), null, null);
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
@@ -375,8 +375,8 @@ public final class NavigationService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(), objectInfo
- .getLastModificationDate(), null, null);
+ feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+ objectInfo.getLastModificationDate(), null, null);
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
@@ -392,8 +392,8 @@ public final class NavigationService {
if ((object == null) || (object.getObject() == null)) {
continue;
}
- writeObjectEntry(service, entry, object.getObject(), null, repositoryId, null, object
- .getRelativePathSegment(), baseUrl, false);
+ writeObjectEntry(service, entry, object.getObject(), null, repositoryId, null,
+ object.getRelativePathSegment(), baseUrl, false);
}
}
@@ -456,8 +456,8 @@ public final class NavigationService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
- .getLastModificationDate(), null, checkedOut.getNumItems());
+ feed.writeFeedElements(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(),
+ folderInfo.getLastModificationDate(), null, checkedOut.getNumItems());
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Tue Oct 5 14:35:24 2010
@@ -22,10 +22,10 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_ENTRY;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java Tue Oct 5 14:35:24 2010
@@ -23,7 +23,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.util.List;
@@ -75,8 +75,8 @@ public class PolicyService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(), objectInfo
- .getLastModificationDate(), null, null);
+ feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+ objectInfo.getLastModificationDate(), null, null);
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java Tue Oct 5 14:35:24 2010
@@ -22,11 +22,11 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.math.BigInteger;
@@ -87,8 +87,8 @@ public class RelationshipService {
feed.startFeed(true);
// write basic Atom feed elements
- feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(), objectInfo
- .getLastModificationDate(), null, relationships.getNumItems());
+ feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+ objectInfo.getLastModificationDate(), null, relationships.getNumItems());
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java Tue Oct 5 14:35:24 2010
@@ -35,10 +35,10 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeTypeEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.math.BigInteger;
import java.util.Collections;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java Tue Oct 5 14:35:24 2010
@@ -22,9 +22,9 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_VERSIONS;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
-import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.util.List;
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java?rev=1004655&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java Tue Oct 5 14:35:24 2010
@@ -0,0 +1,104 @@
+/*
+ * 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.shared;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Dispatcher for the AtomPub and Browser binding servlet.
+ */
+public class Dispatcher {
+ public static final String METHOD_GET = "GET";
+ public static final String METHOD_POST = "POST";
+ public static final String METHOD_PUT = "PUT";
+ public static final String METHOD_DELETE = "DELETE";
+
+ private static final Log LOG = LogFactory.getLog(Dispatcher.class.getName());
+
+ private Map<String, Method> methodMap = new HashMap<String, Method>();
+
+ public Dispatcher() {
+ }
+
+ /**
+ * Connects a resource and HTTP method with a class and a class method.
+ */
+ public synchronized void addResource(String resource, String httpMethod, Class<?> clazz, String classmethod)
+ throws NoSuchMethodException {
+
+ Method m = clazz.getMethod(classmethod, CallContext.class, CmisService.class, String.class,
+ HttpServletRequest.class, HttpServletResponse.class);
+
+ methodMap.put(getKey(resource, httpMethod), m);
+ }
+
+ /**
+ * Find the appropriate method an call it.
+ *
+ * @return <code>true</code> if the method was found, <code>false</code>
+ * otherwise.
+ */
+ public boolean dispatch(String resource, String httpMethod, CallContext context, CmisService service,
+ String repositoryId, HttpServletRequest request, HttpServletResponse response) {
+ Method m = methodMap.get(getKey(resource, httpMethod));
+ if (m == null) {
+ return false;
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(repositoryId + " / " + resource + ", " + httpMethod + " -> " + m.getName());
+ }
+
+ try {
+ m.invoke(null, context, service, repositoryId, request, response);
+ } catch (IllegalArgumentException e) {
+ throw e;
+ } catch (IllegalAccessException e) {
+ throw new CmisRuntimeException("Internal error!", e);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof CmisBaseException) {
+ throw (CmisBaseException) e.getCause();
+ } else {
+ throw new CmisRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Generates a map key from a resource and an HTTP method.
+ */
+ private String getKey(String resource, String httpMethod) {
+ return resource + "/" + httpMethod;
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/Dispatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1004655&r1=1004654&r2=1004655&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java Tue Oct 5 14:35:24 2010
@@ -18,11 +18,14 @@
*/
package org.apache.chemistry.opencmis.server.shared;
+import java.lang.reflect.Method;
import java.math.BigInteger;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
@@ -104,4 +107,104 @@ public class HttpUtils {
return p.substring(1).split("/");
}
+
+ // -------------------------------------------------------------------------
+ // --- parameters ---
+ // -------------------------------------------------------------------------
+
+ /**
+ * Extracts a string parameter.
+ */
+ @SuppressWarnings("unchecked")
+ public static String getStringParameter(HttpServletRequest request, String name) {
+ if (name == null) {
+ return null;
+ }
+
+ Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap();
+ for (Map.Entry<String, String[]> parameter : parameters.entrySet()) {
+ if (name.equalsIgnoreCase(parameter.getKey())) {
+ if (parameter.getValue() == null) {
+ return null;
+ }
+ return parameter.getValue()[0];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Extracts a boolean parameter (with default).
+ */
+ public static boolean getBooleanParameter(HttpServletRequest request, String name, boolean def) {
+ String value = getStringParameter(request, name);
+ if (value == null) {
+ return def;
+ }
+
+ return Boolean.valueOf(value);
+ }
+
+ /**
+ * Extracts a boolean parameter.
+ */
+ public static Boolean getBooleanParameter(HttpServletRequest request, String name) {
+ String value = getStringParameter(request, name);
+ if (value == null) {
+ return null;
+ }
+
+ return Boolean.valueOf(value);
+ }
+
+ /**
+ * Extracts an integer parameter (with default).
+ */
+ public static BigInteger getBigIntegerParameter(HttpServletRequest request, String name, long def) {
+ BigInteger result = getBigIntegerParameter(request, name);
+ if (result == null) {
+ result = BigInteger.valueOf(def);
+ }
+
+ return result;
+ }
+
+ /**
+ * Extracts an integer parameter.
+ */
+ public static BigInteger getBigIntegerParameter(HttpServletRequest request, String name) {
+ String value = getStringParameter(request, name);
+ if (value == null) {
+ return null;
+ }
+
+ try {
+ return new BigInteger(value);
+ } catch (Exception e) {
+ throw new CmisInvalidArgumentException("Invalid parameter '" + name + "'!");
+ }
+ }
+
+ /**
+ * Extracts an enum parameter.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T getEnumParameter(HttpServletRequest request, String name, Class<T> clazz) {
+ String value = getStringParameter(request, name);
+ if ((value == null) || (value.length() == 0)) {
+ return null;
+ }
+
+ try {
+ Method m = clazz.getMethod("fromValue", new Class[] { String.class });
+ return (T) m.invoke(null, new Object[] { value });
+ } catch (Exception e) {
+ if (e instanceof IllegalArgumentException) {
+ throw new CmisInvalidArgumentException("Invalid parameter '" + name + "'!");
+ }
+
+ throw new CmisRuntimeException(e.getMessage(), e);
+ }
+ }
}