You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/03/18 11:44:00 UTC

svn commit: r924694 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-commons/src/main/java/org/apache/chemistry/impl/simpl...

Author: fguillaume
Date: Thu Mar 18 10:43:59 2010
New Revision: 924694

URL: http://svn.apache.org/viewvc?rev=924694&view=rev
Log:
Implementation of NavigationService part of ObjectService, better fault support

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ChemistryHelper.java
    incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/DiscoveryServicePortImpl.java
    incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/NavigationServicePortImpl.java
    incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ObjectServicePortImpl.java
    incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/RepositoryServicePortImpl.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java Thu Mar 18 10:43:59 2010
@@ -330,7 +330,26 @@ public interface SPI {
      */
     Set<QName> getAllowableActions(ObjectId object);
 
-    // TODO 1.0 getObject
+    /**
+     * Gets an object.
+     * <p>
+     * Returns the properties of an object, and optionally associated
+     * information.
+     * <p>
+     * The content stream of the object is not returned, use
+     * {@link #getContentStream} for that.
+     * <p>
+     * If the passed object is an {@link ObjectEntry}, the repository
+     * implementation may fill it with additional data and return the same
+     * object.
+     *
+     * @param object the object
+     * @param inclusion the {@link Inclusion}s to have in the result
+     * @return the object, or {@code null} if the object is not found
+     *
+     * @throws FilterNotValidException if the filter is not valid
+     */
+    ObjectEntry getObject(ObjectId object, Inclusion inclusion);
 
     /**
      * Gets the properties of an object.
@@ -346,10 +365,8 @@ public interface SPI {
      * object.
      *
      * @param object the object
-     * @param inclusion the {@link Inclusion#properties properties},
-     *            {@link Inclusion#allowableActions allowable actions} and
-     *            {@link Inclusion#relationships relationships} to include in
-     *            the result
+     * @param inclusion the {@link Inclusion#properties properties} to include
+     *            in the result
      * @return the properties of the object, or {@code null} if the object is
      *         not found
      *

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java Thu Mar 18 10:43:59 2010
@@ -462,6 +462,10 @@ public class APPConnection implements Co
         return entry.getAllowableActions();
     }
 
+    public ObjectEntry getObject(ObjectId objectId, Inclusion inclusion) {
+        return getProperties(objectId, inclusion);
+    }
+
     public ObjectEntry getProperties(ObjectId object, Inclusion inclusion) {
         // TODO inclusion
         APPObjectEntry current;

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java Thu Mar 18 10:43:59 2010
@@ -482,6 +482,10 @@ public class SimpleConnection implements
         return getProperties(object, null).getAllowableActions();
     }
 
+    public ObjectEntry getObject(ObjectId objectId, Inclusion inclusion) {
+        return getProperties(objectId, inclusion);
+    }
+
     public ObjectEntry getProperties(ObjectId object, Inclusion inclusion) {
         // TODO filter, includeAllowableActions, includeRelationships
         SimpleData data = repository.datas.get(object.getId());

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java Thu Mar 18 10:43:59 2010
@@ -368,6 +368,10 @@ public class JcrConnection implements Co
         throw new UnsupportedOperationException();
     }
 
+    public ObjectEntry getObject(ObjectId objectId, Inclusion inclusion) {
+        return getProperties(objectId, inclusion);
+    }
+
     public ObjectEntry getProperties(ObjectId objectId, Inclusion inclusion) {
 
         try {

Modified: incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ChemistryHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ChemistryHelper.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ChemistryHelper.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ChemistryHelper.java Thu Mar 18 10:43:59 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.chemistry.soap.server;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -25,26 +28,55 @@ import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.GregorianCalendar;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.Map.Entry;
 
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
 import javax.xml.datatype.DatatypeConfigurationException;
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
 
+import org.apache.chemistry.AllowableAction;
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CapabilityJoin;
 import org.apache.chemistry.CapabilityQuery;
+import org.apache.chemistry.ConstraintViolationException;
+import org.apache.chemistry.ContentAlreadyExistsException;
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.FilterNotValidException;
 import org.apache.chemistry.ListPage;
+import org.apache.chemistry.NameConstraintViolationException;
 import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.ObjectNotFoundException;
+import org.apache.chemistry.PermissionDeniedException;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.PropertyType;
+import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Repository;
 import org.apache.chemistry.RepositoryCapabilities;
 import org.apache.chemistry.RepositoryInfo;
+import org.apache.chemistry.StorageException;
+import org.apache.chemistry.StreamNotSupportedException;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.Type;
 import org.apache.chemistry.Updatability;
+import org.apache.chemistry.UpdateConflictException;
+import org.apache.chemistry.VersioningException;
+import org.apache.chemistry.ws.CmisAllowableActionsType;
+import org.apache.chemistry.ws.CmisContentStreamType;
+import org.apache.chemistry.ws.CmisException;
+import org.apache.chemistry.ws.CmisFaultType;
+import org.apache.chemistry.ws.CmisObjectInFolderContainerType;
+import org.apache.chemistry.ws.CmisObjectInFolderListType;
+import org.apache.chemistry.ws.CmisObjectInFolderType;
 import org.apache.chemistry.ws.CmisObjectListType;
+import org.apache.chemistry.ws.CmisObjectParentsType;
 import org.apache.chemistry.ws.CmisObjectType;
 import org.apache.chemistry.ws.CmisPropertiesType;
 import org.apache.chemistry.ws.CmisProperty;
@@ -66,7 +98,9 @@ import org.apache.chemistry.ws.EnumBaseO
 import org.apache.chemistry.ws.EnumCapabilityJoin;
 import org.apache.chemistry.ws.EnumCapabilityQuery;
 import org.apache.chemistry.ws.EnumCardinality;
+import org.apache.chemistry.ws.EnumIncludeRelationships;
 import org.apache.chemistry.ws.EnumPropertyType;
+import org.apache.chemistry.ws.EnumServiceException;
 import org.apache.chemistry.ws.EnumUpdatability;
 import org.apache.chemistry.ws.ObjectFactory;
 import org.apache.chemistry.ws.QueryResponse;
@@ -82,6 +116,40 @@ public class ChemistryHelper {
         // utility class;
     }
 
+    public static CmisException convert(Exception e) {
+        CmisFaultType fault = factory.createCmisFaultType();
+        if (e instanceof ConstraintViolationException) {
+            fault.setType(EnumServiceException.CONSTRAINT);
+        } else if (e instanceof ContentAlreadyExistsException) {
+            fault.setType(EnumServiceException.CONTENT_ALREADY_EXISTS);
+        } else if (e instanceof FilterNotValidException) {
+            fault.setType(EnumServiceException.FILTER_NOT_VALID);
+        } else if (e instanceof IllegalArgumentException) {
+            fault.setType(EnumServiceException.INVALID_ARGUMENT);
+        } else if (e instanceof NameConstraintViolationException) {
+            fault.setType(EnumServiceException.NAME_CONSTRAINT_VIOLATION);
+        } else if (e instanceof UnsupportedOperationException) {
+            fault.setType(EnumServiceException.NOT_SUPPORTED);
+        } else if (e instanceof ObjectNotFoundException) {
+            fault.setType(EnumServiceException.OBJECT_NOT_FOUND);
+        } else if (e instanceof PermissionDeniedException) {
+            fault.setType(EnumServiceException.PERMISSION_DENIED);
+        } else if (e instanceof StorageException) {
+            fault.setType(EnumServiceException.STORAGE);
+        } else if (e instanceof StreamNotSupportedException) {
+            fault.setType(EnumServiceException.STREAM_NOT_SUPPORTED);
+        } else if (e instanceof UpdateConflictException) {
+            fault.setType(EnumServiceException.UPDATE_CONFLICT);
+        } else if (e instanceof VersioningException) {
+            fault.setType(EnumServiceException.VERSIONING);
+        } else {
+            fault.setType(EnumServiceException.RUNTIME);
+        }
+        fault.setCode(BigInteger.ZERO);
+        fault.setMessage(e.getMessage());
+        return new CmisException(e.getMessage(), fault, e);
+    }
+
     public static CmisRepositoryInfoType convert(RepositoryInfo cri) {
         CmisRepositoryInfoType ri = factory.createCmisRepositoryInfoType();
         ri.setRepositoryId(cri.getId());
@@ -210,6 +278,62 @@ public class ChemistryHelper {
         }
     }
 
+    public static RelationshipDirection convert(
+            EnumIncludeRelationships includeRelationships) {
+        if (includeRelationships == null) {
+            return null;
+        }
+        switch (includeRelationships) {
+        case NONE:
+            return null;
+        case SOURCE:
+            return RelationshipDirection.SOURCE;
+        case TARGET:
+            return RelationshipDirection.TARGET;
+        case BOTH:
+            return RelationshipDirection.EITHER;
+        default:
+            throw new RuntimeException(includeRelationships.name());
+        }
+    }
+
+    public static CmisAllowableActionsType convert(Set<QName> set) {
+        if (set == null) {
+            return null;
+        }
+        CmisAllowableActionsType aa = factory.createCmisAllowableActionsType();
+        aa.setCanDeleteObject(Boolean.valueOf(set.contains(AllowableAction.CAN_DELETE_OBJECT)));
+        aa.setCanUpdateProperties(Boolean.valueOf(set.contains(AllowableAction.CAN_UPDATE_PROPERTIES)));
+        aa.setCanGetFolderTree(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_FOLDER_TREE)));
+        aa.setCanGetProperties(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_PROPERTIES)));
+        aa.setCanGetObjectRelationships(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_OBJECT_RELATIONSHIPS)));
+        aa.setCanGetObjectParents(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_OBJECT_PARENTS)));
+        aa.setCanGetFolderParent(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_FOLDER_PARENT)));
+        aa.setCanGetDescendants(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_DESCENDANTS)));
+        aa.setCanMoveObject(Boolean.valueOf(set.contains(AllowableAction.CAN_MOVE_OBJECT)));
+        aa.setCanDeleteContentStream(Boolean.valueOf(set.contains(AllowableAction.CAN_DELETE_CONTENT_STREAM)));
+        aa.setCanCheckOut(Boolean.valueOf(set.contains(AllowableAction.CAN_CHECK_OUT)));
+        aa.setCanCancelCheckOut(Boolean.valueOf(set.contains(AllowableAction.CAN_CANCEL_CHECK_OUT)));
+        aa.setCanCheckIn(Boolean.valueOf(set.contains(AllowableAction.CAN_CHECK_IN)));
+        aa.setCanSetContentStream(Boolean.valueOf(set.contains(AllowableAction.CAN_SET_CONTENT_STREAM)));
+        aa.setCanGetAllVersions(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_ALL_VERSIONS)));
+        aa.setCanAddObjectToFolder(Boolean.valueOf(set.contains(AllowableAction.CAN_ADD_OBJECT_TO_FOLDER)));
+        aa.setCanRemoveObjectFromFolder(Boolean.valueOf(set.contains(AllowableAction.CAN_REMOVE_OBJECT_FROM_FOLDER)));
+        aa.setCanGetContentStream(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_CONTENT_STREAM)));
+        aa.setCanApplyPolicy(Boolean.valueOf(set.contains(AllowableAction.CAN_APPLY_POLICY)));
+        aa.setCanGetAppliedPolicies(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_APPLIED_POLICIES)));
+        aa.setCanRemovePolicy(Boolean.valueOf(set.contains(AllowableAction.CAN_REMOVE_POLICY)));
+        aa.setCanGetChildren(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_CHILDREN)));
+        aa.setCanCreateDocument(Boolean.valueOf(set.contains(AllowableAction.CAN_CREATE_DOCUMENT)));
+        aa.setCanCreateFolder(Boolean.valueOf(set.contains(AllowableAction.CAN_CREATE_FOLDER)));
+        aa.setCanCreateRelationship(Boolean.valueOf(set.contains(AllowableAction.CAN_CREATE_RELATIONSHIP)));
+        aa.setCanDeleteTree(Boolean.valueOf(set.contains(AllowableAction.CAN_DELETE_TREE)));
+        aa.setCanGetRenditions(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_RENDITIONS)));
+        aa.setCanGetACL(Boolean.valueOf(set.contains(AllowableAction.CAN_GET_ACL)));
+        aa.setCanApplyACL(Boolean.valueOf(set.contains(AllowableAction.CAN_APPLY_ACL)));
+        return aa;
+    }
+
     public static CmisPropertyDefinitionType convert(PropertyDefinition cpd) {
         CmisPropertyDefinitionType pd = factory.createCmisPropertyDefinitionType();
         pd.setId(cpd.getId());
@@ -276,28 +400,189 @@ public class ChemistryHelper {
 
     public static CmisObjectType convert(ObjectEntry entry) {
         CmisObjectType object = factory.createCmisObjectType();
+        object.setProperties(convertProperties(entry));
+        // object.setAllowableActions(null);
+        return object;
+    }
+
+    public static CmisObjectInFolderType convertInFolder(ObjectEntry entry) {
+        CmisObjectInFolderType object = factory.createCmisObjectInFolderType();
+        object.getObject().setProperties(convertProperties(entry));
+        object.setPathSegment(entry.getPathSegment());
+        return object;
+    }
+
+    public static List<CmisObjectParentsType> convertParents(
+            Collection<ObjectEntry> entries) {
+        List<CmisObjectParentsType> list = new ArrayList<CmisObjectParentsType>(
+                entries.size());
+        for (ObjectEntry entry : entries) {
+            list.add(convertParent(entry));
+        }
+        return list;
+    }
+
+    public static CmisObjectParentsType convertParent(ObjectEntry entry) {
+        CmisObjectParentsType object = factory.createCmisObjectParentsType();
+        object.setObject(convert(entry));
+        object.setRelativePathSegment(entry.getPathSegment());
+        return object;
+    }
+
+    public static CmisPropertiesType convertProperties(ObjectEntry entry) {
         CmisPropertiesType properties = factory.createCmisPropertiesType();
         List<CmisProperty> list = properties.getProperty();
         for (Entry<String, Serializable> e : entry.getValues().entrySet()) {
             list.add(getWSCmisProperty(e.getKey(), e.getValue()));
         }
-        object.setProperties(properties);
-        // object.setAllowableActions(null);
+        return properties;
+    }
+
+    public static Map<String, Serializable> convert(
+            CmisPropertiesType properties, Repository repository) {
+        Map<String, Serializable> map = new HashMap<String, Serializable>();
+        List<CmisProperty> list = properties.getProperty();
+        for (CmisProperty prop : list) {
+            Serializable value = convert(prop, repository);
+            map.put(prop.getPropertyDefinitionId(), value);
+        }
+        return map;
+    }
+
+    public static CmisObjectListType convert(ListPage<ObjectEntry> entries) {
+        CmisObjectListType list = factory.createCmisObjectListType();
+        for (ObjectEntry entry : entries) {
+            list.getObjects().add(convert(entry));
+        }
+        list.setHasMoreItems(entries.getHasMoreItems());
+        list.setNumItems(BigInteger.valueOf(entries.getNumItems()));
+        return list;
+    }
+
+    public static CmisObjectInFolderListType convertInFolder(
+            ListPage<ObjectEntry> entries) {
+        CmisObjectInFolderListType list = factory.createCmisObjectInFolderListType();
+        for (ObjectEntry entry : entries) {
+            list.getObjects().add(convertInFolder(entry));
+        }
+        list.setHasMoreItems(entries.getHasMoreItems());
+        list.setNumItems(BigInteger.valueOf(entries.getNumItems()));
+        return list;
+    }
+
+    public static List<CmisObjectInFolderContainerType> convertForest(
+            Tree<ObjectEntry> tree) {
+        List<CmisObjectInFolderContainerType> list = new ArrayList<CmisObjectInFolderContainerType>(
+                tree.getChildren().size());
+        for (Tree<ObjectEntry> s : tree.getChildren()) {
+            list.add(convert(s));
+        }
+        return list;
+    }
+
+    public static CmisObjectInFolderContainerType convert(Tree<ObjectEntry> s) {
+        CmisObjectInFolderContainerType object = factory.createCmisObjectInFolderContainerType();
+        object.setObjectInFolder(convertInFolder(s.getNode()));
+        object.getChildren().addAll(convertForest(s));
         return object;
     }
 
-    public static QueryResponse convertQuery(ListPage<ObjectEntry> res) {
+    public static QueryResponse convertQuery(ListPage<ObjectEntry> entries) {
         QueryResponse response = factory.createQueryResponse();
         CmisObjectListType objects = factory.createCmisObjectListType();
         response.setObjects(objects);
-        for (ObjectEntry entry : res) {
+        for (ObjectEntry entry : entries) {
             objects.getObjects().add(convert(entry));
         }
-        objects.setHasMoreItems(res.getHasMoreItems());
-        objects.setNumItems(BigInteger.valueOf(res.getNumItems()));
+        objects.setHasMoreItems(entries.getHasMoreItems());
+        objects.setNumItems(BigInteger.valueOf(entries.getNumItems()));
         return response;
     }
 
+    public static CmisContentStreamType convert(final ContentStream cs) {
+        if (cs == null) {
+            return null;
+        }
+        CmisContentStreamType s = factory.createCmisContentStreamType();
+        s.setMimeType(cs.getMimeType());
+        s.setLength(BigInteger.valueOf(cs.getLength()));
+        s.setFilename(cs.getFileName());
+        s.setStream(new DataHandler(new DataSource() {
+            public InputStream getInputStream() throws IOException {
+                return cs.getStream();
+            }
+
+            public OutputStream getOutputStream() {
+                return null;
+            }
+
+            public String getContentType() {
+                return cs.getMimeType();
+            }
+
+            public String getName() {
+                return cs.getFileName();
+            }
+        }));
+        return s;
+    }
+
+    public static Serializable convert(CmisProperty prop, Repository repository) {
+        PropertyDefinition pd = repository.getPropertyDefinition(prop.getPropertyDefinitionId());
+        boolean multi = pd.isMultiValued();
+        if (prop instanceof CmisPropertyBoolean) {
+            List<Boolean> value = ((CmisPropertyBoolean) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else if (prop instanceof CmisPropertyDateTime) {
+            List<XMLGregorianCalendar> value = ((CmisPropertyDateTime) prop).getValue();
+            return multi ? value.toArray() : convert(value.get(0));
+        } else if (prop instanceof CmisPropertyDecimal) {
+            List<BigDecimal> value = ((CmisPropertyDecimal) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else if (prop instanceof CmisPropertyHtml) {
+            List<String> value = ((CmisPropertyHtml) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else if (prop instanceof CmisPropertyId) {
+            List<String> value = ((CmisPropertyId) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else if (prop instanceof CmisPropertyInteger) {
+            List<BigInteger> value = ((CmisPropertyInteger) prop).getValue();
+            return multi ? convert(value) : convert(value.get(0));
+        } else if (prop instanceof CmisPropertyString) {
+            List<String> value = ((CmisPropertyString) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else if (prop instanceof CmisPropertyUri) {
+            List<String> value = ((CmisPropertyUri) prop).getValue();
+            return multi ? value.toArray() : value.get(0);
+        } else {
+            throw new RuntimeException(prop.getClass().getName());
+        }
+    }
+
+    public static Calendar convert(XMLGregorianCalendar value) {
+        return value.toGregorianCalendar();
+    }
+
+    public static Calendar[] convert(List<XMLGregorianCalendar> values) {
+        List<Calendar> list = new ArrayList<Calendar>(values.size());
+        for (XMLGregorianCalendar value : values) {
+            list.add(convert(value));
+        }
+        return (Calendar[]) list.toArray();
+    }
+
+    public static Long convert(BigInteger value) {
+        return Long.valueOf(value.longValue());
+    }
+
+    public static Long[] convert(List<BigInteger> values) {
+        List<Long> list = new ArrayList<Long>(values.size());
+        for (BigInteger value : values) {
+            list.add(convert(value));
+        }
+        return (Long[]) list.toArray();
+    }
+
     /**
      * Transforms a Chemistry property into a WS one.
      */

Modified: incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/DiscoveryServicePortImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/DiscoveryServicePortImpl.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/DiscoveryServicePortImpl.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/DiscoveryServicePortImpl.java Thu Mar 18 10:43:59 2010
@@ -18,7 +18,6 @@ package org.apache.chemistry.soap.server
 
 import java.io.Serializable;
 import java.math.BigInteger;
-import java.util.List;
 import java.util.Map;
 
 import javax.annotation.Resource;
@@ -38,10 +37,8 @@ import org.apache.chemistry.SPI;
 import org.apache.chemistry.ws.CmisException;
 import org.apache.chemistry.ws.CmisExtensionType;
 import org.apache.chemistry.ws.CmisObjectListType;
-import org.apache.chemistry.ws.CmisObjectType;
 import org.apache.chemistry.ws.DiscoveryServicePort;
 import org.apache.chemistry.ws.EnumIncludeRelationships;
-import org.apache.chemistry.ws.ObjectFactory;
 import org.apache.chemistry.ws.Query;
 import org.apache.chemistry.ws.QueryResponse;
 
@@ -56,54 +53,61 @@ public class DiscoveryServicePortImpl im
     private WebServiceContext wscontext;
 
     public QueryResponse query(Query parameters) throws CmisException {
-        // repository
-        String repositoryId = parameters.getRepositoryId();
-        Repository repository = RepositoryManager.getInstance().getRepository(
-                repositoryId);
-        if (repository == null) {
-            return null; // TODO fault
-        }
-
-        // parameters
-        String statement = parameters.getStatement();
-        JAXBElement<Boolean> searchAllVersionsB = parameters.getSearchAllVersions();
-        boolean searchAllVersions = searchAllVersionsB == null ? false
-                : searchAllVersionsB.getValue().booleanValue();
-
-        JAXBElement<BigInteger> maxItemsBI = parameters.getMaxItems();
-        int maxItems = maxItemsBI == null || maxItemsBI.getValue() == null
-                || maxItemsBI.getValue().intValue() < 0 ? 0
-                : maxItemsBI.getValue().intValue();
-        JAXBElement<BigInteger> skipCountBI = parameters.getSkipCount();
-        int skipCount = skipCountBI == null || skipCountBI.getValue() == null
-                || skipCountBI.getValue().intValue() < 0 ? 0
-                : skipCountBI.getValue().intValue();
-        Paging paging = new Paging(maxItems, skipCount);
-
-        JAXBElement<Boolean> includeAllowableActions = parameters.getIncludeAllowableActions();
-        boolean allowableActions = includeAllowableActions == null
-                || includeAllowableActions.getValue() == null ? false
-                : includeAllowableActions.getValue().booleanValue();
-        JAXBElement<EnumIncludeRelationships> includeRelationships = parameters.getIncludeRelationships();
-        RelationshipDirection relationships = includeRelationships == null
-                || includeRelationships.getValue() == null ? null
-                : RelationshipDirection.fromInclusion(includeRelationships.getValue().name());
-        JAXBElement<String> renditionFilter = parameters.getRenditionFilter();
-        String renditions = renditionFilter == null
-                || renditionFilter.getValue() == null ? null
-                : renditionFilter.getValue();
-        Inclusion inclusion = new Inclusion(null, renditions, relationships,
-                allowableActions, false, false);
-
-        Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
-        SPI spi = repository.getSPI(params);
+        SPI spi = null;
         try {
+            // repository
+            String repositoryId = parameters.getRepositoryId();
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+
+            // parameters
+            String statement = parameters.getStatement();
+            JAXBElement<Boolean> searchAllVersionsB = parameters.getSearchAllVersions();
+            boolean searchAllVersions = searchAllVersionsB == null ? false
+                    : searchAllVersionsB.getValue().booleanValue();
+
+            JAXBElement<BigInteger> maxItemsBI = parameters.getMaxItems();
+            int maxItems = maxItemsBI == null || maxItemsBI.getValue() == null
+                    || maxItemsBI.getValue().intValue() < 0 ? 0
+                    : maxItemsBI.getValue().intValue();
+            JAXBElement<BigInteger> skipCountBI = parameters.getSkipCount();
+            int skipCount = skipCountBI == null
+                    || skipCountBI.getValue() == null
+                    || skipCountBI.getValue().intValue() < 0 ? 0
+                    : skipCountBI.getValue().intValue();
+            Paging paging = new Paging(maxItems, skipCount);
+
+            JAXBElement<Boolean> includeAllowableActions = parameters.getIncludeAllowableActions();
+            boolean allowableActions = includeAllowableActions == null
+                    || includeAllowableActions.getValue() == null ? false
+                    : includeAllowableActions.getValue().booleanValue();
+            JAXBElement<EnumIncludeRelationships> includeRelationships = parameters.getIncludeRelationships();
+            RelationshipDirection relationships = includeRelationships == null
+                    || includeRelationships.getValue() == null ? null
+                    : RelationshipDirection.fromInclusion(includeRelationships.getValue().name());
+            JAXBElement<String> renditionFilter = parameters.getRenditionFilter();
+            String renditions = renditionFilter == null
+                    || renditionFilter.getValue() == null ? null
+                    : renditionFilter.getValue();
+            Inclusion inclusion = new Inclusion(null, renditions,
+                    relationships, allowableActions, false, false);
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
             ListPage<ObjectEntry> res = spi.query(statement, searchAllVersions,
                     inclusion, paging);
 
             return ChemistryHelper.convertQuery(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         } finally {
-            spi.close();
+            if (spi != null) {
+                spi.close();
+            }
         }
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/NavigationServicePortImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/NavigationServicePortImpl.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/NavigationServicePortImpl.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/NavigationServicePortImpl.java Thu Mar 18 10:43:59 2010
@@ -16,13 +16,25 @@
  */
 package org.apache.chemistry.soap.server;
 
+import java.io.Serializable;
 import java.math.BigInteger;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
 import javax.jws.WebService;
 import javax.xml.ws.WebServiceContext;
 
+import org.apache.chemistry.Inclusion;
+import org.apache.chemistry.ListPage;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Paging;
+import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.RepositoryManager;
+import org.apache.chemistry.SPI;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.ws.CmisException;
 import org.apache.chemistry.ws.CmisExtensionType;
 import org.apache.chemistry.ws.CmisObjectInFolderContainerType;
@@ -32,7 +44,6 @@ import org.apache.chemistry.ws.CmisObjec
 import org.apache.chemistry.ws.CmisObjectType;
 import org.apache.chemistry.ws.EnumIncludeRelationships;
 import org.apache.chemistry.ws.NavigationServicePort;
-import org.apache.chemistry.ws.ObjectFactory;
 
 @WebService(name = "NavigationService", //
 targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", //
@@ -41,8 +52,6 @@ portName = "NavigationServicePort", //
 endpointInterface = "org.apache.chemistry.ws.NavigationServicePort")
 public class NavigationServicePortImpl implements NavigationServicePort {
 
-    private static final ObjectFactory factory = new ObjectFactory();
-
     @Resource
     private WebServiceContext wscontext;
 
@@ -52,8 +61,37 @@ public class NavigationServicePortImpl i
             EnumIncludeRelationships includeRelationships,
             String renditionFilter, BigInteger maxItems, BigInteger skipCount,
             CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, false, false);
+            int max = maxItems == null || maxItems.intValue() < 0 ? 0
+                    : maxItems.intValue();
+            int skip = skipCount == null || skipCount.intValue() < 0 ? 0
+                    : skipCount.intValue();
+            Paging paging = new Paging(max, skip);
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            ListPage<ObjectEntry> res = spi.getCheckedOutDocuments(
+                    spi.newObjectId(folderId), inclusion, paging);
+            return ChemistryHelper.convert(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisObjectInFolderListType getChildren(String repositoryId,
@@ -63,8 +101,38 @@ public class NavigationServicePortImpl i
             String renditionFilter, Boolean includePathSegment,
             BigInteger maxItems, BigInteger skipCount,
             CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, false, false);
+            int max = maxItems == null || maxItems.intValue() < 0 ? 0
+                    : maxItems.intValue();
+            int skip = skipCount == null || skipCount.intValue() < 0 ? 0
+                    : skipCount.intValue();
+            Paging paging = new Paging(max, skip);
+            // includePathSegment
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            ListPage<ObjectEntry> res = spi.getChildren(
+                    spi.newObjectId(folderId), inclusion, orderBy, paging);
+            return ChemistryHelper.convertInFolder(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public List<CmisObjectInFolderContainerType> getDescendants(
@@ -73,14 +141,61 @@ public class NavigationServicePortImpl i
             EnumIncludeRelationships includeRelationships,
             String renditionFilter, Boolean includePathSegment,
             CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            int d = depth == null ? -1 : depth.intValue();
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, false, false);
+            // includePathSegment
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            String orderBy = null; // TODO
+            Tree<ObjectEntry> res = spi.getDescendants(
+                    spi.newObjectId(folderId), d, orderBy, inclusion);
+            return ChemistryHelper.convertForest(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisObjectType getFolderParent(String repositoryId, String folderId,
             String filter, CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            ObjectEntry entry = spi.getFolderParent(spi.newObjectId(folderId),
+                    filter);
+            return ChemistryHelper.convert(entry);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public List<CmisObjectInFolderContainerType> getFolderTree(
@@ -89,8 +204,34 @@ public class NavigationServicePortImpl i
             EnumIncludeRelationships includeRelationships,
             String renditionFilter, Boolean includePathSegment,
             CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            int d = depth == null ? -1 : depth.intValue();
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, false, false);
+            // includePathSegment
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            Tree<ObjectEntry> res = spi.getFolderTree(
+                    spi.newObjectId(folderId), d, inclusion);
+            return ChemistryHelper.convertForest(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public List<CmisObjectParentsType> getObjectParents(String repositoryId,
@@ -98,8 +239,33 @@ public class NavigationServicePortImpl i
             EnumIncludeRelationships includeRelationships,
             String renditionFilter, Boolean includeRelativePathSegment,
             CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, false, false); // TODO unused
+            // includeRelativePathSegment
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            Collection<ObjectEntry> res = spi.getObjectParents(
+                    spi.newObjectId(objectId), renditionFilter);
+            return ChemistryHelper.convertParents(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ObjectServicePortImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ObjectServicePortImpl.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ObjectServicePortImpl.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/ObjectServicePortImpl.java Thu Mar 18 10:43:59 2010
@@ -16,14 +16,25 @@
  */
 package org.apache.chemistry.soap.server;
 
+import java.io.Serializable;
 import java.math.BigInteger;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.annotation.Resource;
 import javax.jws.WebService;
+import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceContext;
 
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Inclusion;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.RepositoryManager;
+import org.apache.chemistry.SPI;
 import org.apache.chemistry.ws.CmisAccessControlListType;
 import org.apache.chemistry.ws.CmisAllowableActionsType;
 import org.apache.chemistry.ws.CmisContentStreamType;
@@ -128,16 +139,52 @@ public class ObjectServicePortImpl imple
 
     public CmisAllowableActionsType getAllowableActions(String repositoryId,
             String objectId, CmisExtensionType extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+            Set<QName> res = spi.getAllowableActions(spi.newObjectId(objectId));
+            return ChemistryHelper.convert(res);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisContentStreamType getContentStream(String repositoryId,
             String objectId, String streamId, BigInteger offset,
             BigInteger length, CmisExtensionType extension)
             throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+            ContentStream cs = spi.getContentStream(spi.newObjectId(objectId),
+                    streamId);
+            return ChemistryHelper.convert(cs);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisObjectType getObject(String repositoryId, String objectId,
@@ -146,8 +193,33 @@ public class ObjectServicePortImpl imple
             String renditionFilter, Boolean includePolicyIds,
             Boolean includeACL, CmisExtensionType extension)
             throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            boolean incpol = Boolean.TRUE.equals(includePolicyIds);
+            boolean incacls = Boolean.TRUE.equals(includeACL);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, incpol, incacls);
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+            ObjectEntry entry = spi.getProperties(spi.newObjectId(objectId),
+                    inclusion);
+            return ChemistryHelper.convert(entry);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisObjectType getObjectByPath(String repositoryId, String path,
@@ -156,15 +228,60 @@ public class ObjectServicePortImpl imple
             String renditionFilter, Boolean includePolicyIds,
             Boolean includeACL, CmisExtensionType extension)
             throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RelationshipDirection inclrel = ChemistryHelper.convert(includeRelationships);
+            boolean inclaa = Boolean.TRUE.equals(includeAllowableActions);
+            boolean incpol = Boolean.TRUE.equals(includePolicyIds);
+            boolean incacls = Boolean.TRUE.equals(includeACL);
+            Inclusion inclusion = new Inclusion(filter, renditionFilter,
+                    inclrel, inclaa, incpol, incacls);
+
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+            ObjectEntry entry = spi.getObjectByPath(path, inclusion);
+            return ChemistryHelper.convert(entry);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public CmisPropertiesType getProperties(String repositoryId,
             String objectId, String filter, CmisExtensionType extension)
             throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+
+            Inclusion inclusion = new Inclusion(filter, null, null, false,
+                    false, false);
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+            ObjectEntry entry = spi.getProperties(spi.newObjectId(objectId),
+                    inclusion);
+            return ChemistryHelper.convertProperties(entry);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
     public List<CmisRenditionType> getRenditions(String repositoryId,
@@ -193,8 +310,34 @@ public class ObjectServicePortImpl imple
     public void updateProperties(String repositoryId, Holder<String> objectId,
             Holder<String> changeToken, CmisPropertiesType properties,
             Holder<CmisExtensionType> extension) throws CmisException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SPI spi = null;
+        try {
+            Repository repository = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repository == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            if (objectId == null || objectId.value == null) {
+                String msg = "Missing objectId";
+                throw new CmisException(msg, null, null);
+            }
+            String id = objectId.value;
+            String token = changeToken == null ? null : changeToken.value;
+            Map<String, Serializable> params = CallContext.mapFromWebServiceContext(wscontext);
+            spi = repository.getSPI(params);
+
+            Map<String, Serializable> props = ChemistryHelper.convert(
+                    properties, repository);
+
+            spi.updateProperties(spi.newObjectId(id), token, props);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
+        } finally {
+            if (spi != null) {
+                spi.close();
+            }
+        }
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/RepositoryServicePortImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/RepositoryServicePortImpl.java?rev=924694&r1=924693&r2=924694&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/RepositoryServicePortImpl.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-soap-server/src/main/java/org/apache/chemistry/soap/server/RepositoryServicePortImpl.java Thu Mar 18 10:43:59 2010
@@ -17,29 +17,21 @@
 package org.apache.chemistry.soap.server;
 
 import java.math.BigInteger;
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import javax.annotation.Resource;
 import javax.jws.WebService;
-import javax.xml.bind.JAXBElement;
-import javax.xml.ws.WebServiceContext;
 
 import org.apache.chemistry.ListPage;
 import org.apache.chemistry.Paging;
-import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.Repository;
-import org.apache.chemistry.RepositoryCapabilities;
 import org.apache.chemistry.RepositoryEntry;
 import org.apache.chemistry.RepositoryInfo;
 import org.apache.chemistry.RepositoryManager;
 import org.apache.chemistry.Type;
 import org.apache.chemistry.ws.CmisException;
 import org.apache.chemistry.ws.CmisExtensionType;
-import org.apache.chemistry.ws.CmisPropertyDefinitionType;
-import org.apache.chemistry.ws.CmisRepositoryCapabilitiesType;
 import org.apache.chemistry.ws.CmisRepositoryEntryType;
 import org.apache.chemistry.ws.CmisRepositoryInfoType;
 import org.apache.chemistry.ws.CmisTypeContainer;
@@ -48,8 +40,6 @@ import org.apache.chemistry.ws.CmisTypeD
 import org.apache.chemistry.ws.ObjectFactory;
 import org.apache.chemistry.ws.RepositoryServicePort;
 
-import sun.security.pkcs11.Secmod.DbMode;
-
 @WebService(name = "RepositoryServicePort", //
 targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", //
 serviceName = "RepositoryService", //
@@ -59,85 +49,96 @@ public class RepositoryServicePortImpl i
 
     private static final ObjectFactory factory = new ObjectFactory();
 
-    @Resource
-    private WebServiceContext wscontext;
-
     public List<CmisRepositoryEntryType> getRepositories(
             CmisExtensionType extension) throws CmisException {
-        Collection<RepositoryEntry> repos = RepositoryManager.getInstance().getRepositories();
-        List<CmisRepositoryEntryType> entries = new ArrayList<CmisRepositoryEntryType>(
-                repos.size());
-        for (RepositoryEntry repo : repos) {
-            CmisRepositoryEntryType entry = factory.createCmisRepositoryEntryType();
-            entry.setRepositoryId(repo.getId());
-            entry.setRepositoryName(repo.getName());
-            entries.add(entry);
+        try {
+            Collection<RepositoryEntry> repos = RepositoryManager.getInstance().getRepositories();
+            List<CmisRepositoryEntryType> entries = new ArrayList<CmisRepositoryEntryType>(
+                    repos.size());
+            for (RepositoryEntry repo : repos) {
+                CmisRepositoryEntryType entry = factory.createCmisRepositoryEntryType();
+                entry.setRepositoryId(repo.getId());
+                entry.setRepositoryName(repo.getName());
+                entries.add(entry);
+            }
+            return entries;
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         }
-        return entries;
     }
 
     public CmisRepositoryInfoType getRepositoryInfo(String repositoryId,
             CmisExtensionType extension) throws CmisException {
-        Repository repo = RepositoryManager.getInstance().getRepository(
-                repositoryId);
-        if (repo == null) {
-            return null; // TODO or fault?
+        try {
+            Repository repo = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repo == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            RepositoryInfo info = repo.getInfo();
+            return ChemistryHelper.convert(info);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         }
-
-        RepositoryInfo info = repo.getInfo();
-
-        return ChemistryHelper.convert(info);
     }
 
     public CmisTypeDefinitionType getTypeDefinition(String repositoryId,
             String typeId, CmisExtensionType extension) throws CmisException {
-        Repository repo = RepositoryManager.getInstance().getRepository(
-                repositoryId);
-        if (repo == null) {
-            return null; // TODO or fault?
+        try {
+            Repository repo = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repo == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            Type type = repo.getType(typeId);
+            return ChemistryHelper.convert(type);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         }
-
-        Type type = repo.getType(typeId);
-
-        return ChemistryHelper.convert(type);
     }
 
     public CmisTypeDefinitionListType getTypeChildren(String repositoryId,
             String typeId, Boolean includePropertyDefinitions,
             BigInteger maxItems, BigInteger skipCount,
             CmisExtensionType extension) throws CmisException {
-        Repository repo = RepositoryManager.getInstance().getRepository(
-                repositoryId);
-        if (repo == null) {
-            return null; // TODO or fault?
+        try {
+            Repository repo = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repo == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            boolean ipd = Boolean.TRUE.equals(includePropertyDefinitions);
+            int mi = maxItems == null ? -1 : maxItems.intValue();
+            int sc = skipCount == null ? -1 : skipCount.intValue();
+            Paging paging = new Paging(mi, sc);
+            ListPage<Type> types = repo.getTypeChildren(typeId, ipd, paging);
+            return ChemistryHelper.convert(types);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         }
-
-        boolean ipd = Boolean.TRUE.equals(includePropertyDefinitions);
-        int mi = maxItems == null ? -1 : maxItems.intValue();
-        int sc = skipCount == null ? -1 : skipCount.intValue();
-        Paging paging = new Paging(mi, sc);
-
-        ListPage<Type> types = repo.getTypeChildren(typeId, ipd, paging);
-
-        return ChemistryHelper.convert(types);
     }
 
     public List<CmisTypeContainer> getTypeDescendants(String repositoryId,
             String typeId, BigInteger depth,
             Boolean includePropertyDefinitions, CmisExtensionType extension)
             throws CmisException {
-        Repository repo = RepositoryManager.getInstance().getRepository(
-                repositoryId);
-        if (repo == null) {
-            return null; // TODO or fault?
+        try {
+            Repository repo = RepositoryManager.getInstance().getRepository(
+                    repositoryId);
+            if (repo == null) {
+                String msg = "Unknown repository: " + repositoryId;
+                throw new CmisException(msg, null, null);
+            }
+            boolean ipd = Boolean.TRUE.equals(includePropertyDefinitions);
+            int d = depth == null ? -1 : depth.intValue();
+            Collection<Type> ctl = repo.getTypeDescendants(typeId, d, ipd);
+            return ChemistryHelper.convert(ctl);
+        } catch (Exception e) {
+            throw ChemistryHelper.convert(e);
         }
-
-        boolean ipd = Boolean.TRUE.equals(includePropertyDefinitions);
-        int d = depth == null ? -1 : depth.intValue();
-
-        Collection<Type> ctl = repo.getTypeDescendants(typeId, d, ipd);
-
-        return ChemistryHelper.convert(ctl);
     }
 
 }