chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1058588 [2/2] - in /incubator/chemistry/opencmis-cmis11/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/ chemistry-opencmis-client/chemistry-opencmis-clie...
Date Thu, 13 Jan 2011 14:47:40 GMT
Modified: incubator/chemistry/opencmis-cmis11/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-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1058588&r1=1058587&r2=1058588&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
Thu Jan 13 14:47:39 2011
@@ -89,6 +89,12 @@ public class CmisAtomPubServlet extends 
                     "getTypeDescendants");
             dispatcher.addResource(AtomPubUtils.RESOURCE_TYPE, Dispatcher.METHOD_GET, RepositoryService.class,
                     "getTypeDefinition");
+            dispatcher.addResource(AtomPubUtils.RESOURCE_TYPES, Dispatcher.METHOD_POST, RepositoryService.class,
+                    "createTypeDefinition");
+            dispatcher.addResource(AtomPubUtils.RESOURCE_TYPE, Dispatcher.METHOD_PUT, RepositoryService.class,
+                    "updateTypeDefinition");
+            dispatcher.addResource(AtomPubUtils.RESOURCE_TYPE, Dispatcher.METHOD_DELETE,
RepositoryService.class,
+                    "deleteTypeDefinition");
             dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, Dispatcher.METHOD_GET,
NavigationService.class,
                     "getChildren");
             dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, Dispatcher.METHOD_GET,
NavigationService.class,
@@ -158,8 +164,8 @@ public class CmisAtomPubServlet extends 
         // create a context object, dispatch and handle exceptions
         CallContext context = null;
         try {
-            context = HttpUtils.createContext(request, getServletContext(),
-                    CallContext.BINDING_ATOMPUB, callContextHandler);
+            context = HttpUtils.createContext(request, getServletContext(), CallContext.BINDING_ATOMPUB,
+                    callContextHandler);
             dispatch(context, request, response);
         } catch (Exception e) {
             if (e instanceof CmisPermissionDeniedException) {

Modified: incubator/chemistry/opencmis-cmis11/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-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java?rev=1058588&r1=1058587&r2=1058588&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java
Thu Jan 13 14:47:39 2011
@@ -55,10 +55,12 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
 
 /**
@@ -416,4 +418,70 @@ public final class RepositoryService {
         writeTypeEntry(entry, type, null, repositoryId, compileBaseUrl(request, repositoryId),
true);
         entry.endDocument();
     }
+
+    public static void createTypeDefinition(CallContext context, CmisService service, String
repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+
+        AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+        TypeDefinition typeDefinition = parser.getTypeDefinition();
+        if ((typeDefinition == null) || !typeId.equals(typeDefinition.getParentTypeId()))
{
+            throw new CmisInvalidArgumentException("No or invalid type defintion submitted!");
+        }
+
+        Holder<TypeDefinition> typeDefinitionHolder = new Holder<TypeDefinition>(typeDefinition);
+
+        // execute
+        service.createTypeDefinition(repositoryId, typeDefinitionHolder, null);
+
+        // write XML
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeTypeEntry(entry, typeDefinitionHolder.getValue(), null, repositoryId,
+                compileBaseUrl(request, repositoryId), true);
+        entry.endDocument();
+    }
+
+    public static void updateTypeDefinition(CallContext context, CmisService service, String
repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+
+        AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+        TypeDefinition typeDefinition = parser.getTypeDefinition();
+        if ((typeDefinition == null) || !typeId.equals(typeDefinition.getId())) {
+            throw new CmisInvalidArgumentException("No or invalid type defintion submitted!");
+        }
+
+        Holder<TypeDefinition> typeDefinitionHolder = new Holder<TypeDefinition>(typeDefinition);
+
+        // execute
+        service.updateTypeDefinition(repositoryId, typeDefinitionHolder, null);
+
+        // write XML
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeTypeEntry(entry, typeDefinitionHolder.getValue(), null, repositoryId,
+                compileBaseUrl(request, repositoryId), true);
+        entry.endDocument();
+    }
+
+    public static void deleteTypeDefinition(CallContext context, CmisService service, String
repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_ID);
+
+        // execute
+        service.deleteTypeDefinition(repositoryId, typeId, null);
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+    }
 }

Modified: incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/RepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/RepositoryService.java?rev=1058588&r1=1058587&r2=1058588&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/RepositoryService.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/RepositoryService.java
Thu Jan 13 14:47:39 2011
@@ -19,7 +19,9 @@
 package org.apache.chemistry.opencmis.server.impl.webservices;
 
 import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
+import static org.apache.chemistry.opencmis.commons.impl.Converter.convertExtensionHolder;
 import static org.apache.chemistry.opencmis.commons.impl.Converter.convertTypeContainerList;
+import static org.apache.chemistry.opencmis.commons.impl.Converter.setExtensionValues;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -27,9 +29,12 @@ import java.util.List;
 
 import javax.annotation.Resource;
 import javax.jws.WebService;
+import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceContext;
 
+import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryEntryType;
@@ -137,4 +142,71 @@ public class RepositoryService extends A
             closeService(service);
         }
     }
+
+    public void createTypeDefinition(String repositoryId, Holder<CmisTypeDefinitionType>
type,
+            CmisExtensionType extension) throws CmisException {
+        CmisService service = null;
+        try {
+            service = getService(wsContext, repositoryId);
+
+            org.apache.chemistry.opencmis.commons.spi.Holder<TypeDefinition> typeDefHolder
= null;
+            if (type != null) {
+                typeDefHolder = new org.apache.chemistry.opencmis.commons.spi.Holder<TypeDefinition>(
+                        convert(type.value));
+            }
+
+            service.createTypeDefinition(repositoryId, typeDefHolder, convert(extension));
+
+            if (type != null) {
+                type.value = convert(typeDefHolder.getValue());
+            }
+        } catch (Exception e) {
+            throw convertException(e);
+        } finally {
+            closeService(service);
+        }
+    }
+
+    public void updateTypeDefinition(String repositoryId, Holder<CmisTypeDefinitionType>
type,
+            CmisExtensionType extension) throws CmisException {
+        CmisService service = null;
+        try {
+            service = getService(wsContext, repositoryId);
+
+            org.apache.chemistry.opencmis.commons.spi.Holder<TypeDefinition> typeDefHolder
= null;
+            if (type != null) {
+                typeDefHolder = new org.apache.chemistry.opencmis.commons.spi.Holder<TypeDefinition>(
+                        convert(type.value));
+            }
+
+            service.updateTypeDefinition(repositoryId, typeDefHolder, convert(extension));
+
+            if (type != null) {
+                type.value = convert(typeDefHolder.getValue());
+            }
+        } catch (Exception e) {
+            throw convertException(e);
+        } finally {
+            closeService(service);
+        }
+    }
+
+    public void deleteTypeDefinition(String repositoryId, String typeId, Holder<CmisExtensionType>
extension)
+            throws CmisException {
+
+        CmisService service = null;
+        try {
+            service = getService(wsContext, repositoryId);
+
+            ExtensionsData extData = convertExtensionHolder(extension);
+
+            service.deleteTypeDefinition(repositoryId, typeId, extData);
+
+            setExtensionValues(extData, extension);
+        } catch (Exception e) {
+            throw convertException(e);
+        } finally {
+            closeService(service);
+        }
+    }
 }

Modified: incubator/chemistry/opencmis-cmis11/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/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java?rev=1058588&r1=1058587&r2=1058588&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
Thu Jan 13 14:47:39 2011
@@ -49,6 +49,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
 import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
@@ -529,6 +530,39 @@ public class CmisServiceWrapper<T extend
             throw createCmisException(e);
         }
     }
+    
+    public void createTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+        checkRepositoryId(repositoryId);
+        // TODO: check type
+
+        try {
+             service.createTypeDefinition(repositoryId,  type, extension);
+        } catch (Exception e) {
+            throw createCmisException(e);
+        }
+    }
+
+    public void updateTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+        checkRepositoryId(repositoryId);
+        // TODO: check type
+
+        try {
+             service.updateTypeDefinition(repositoryId,  type, extension);
+        } catch (Exception e) {
+            throw createCmisException(e);
+        }
+    }
+
+    public void deleteTypeDefinition(String repositoryId, String typeId, ExtensionsData extension)
{
+        checkRepositoryId(repositoryId);
+        // TODO: check typeId
+
+        try {
+             service.deleteTypeDefinition(repositoryId,  typeId, extension);
+        } catch (Exception e) {
+            throw createCmisException(e);
+        }
+    }
 
     // --- navigation service ---
 



Mime
View raw message