You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by sk...@apache.org on 2010/02/25 17:23:17 UTC

svn commit: r916337 - in /incubator/chemistry/trunk/opencmis/opencmis-client: opencmis-client-api/src/main/java/org/apache/opencmis/client/api/ opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/

Author: sklevenz
Date: Thu Feb 25 16:23:16 2010
New Revision: 916337

URL: http://svn.apache.org/viewvc?rev=916337&view=rev
Log:
client runtime implementation
- first round trip completed 
- based on InMemory provider
  * create test folder root
  * generate test data using object generator
  * run test
  * clean up all test data
https://issues.apache.org/jira/browse/CMIS-124

Added:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java   (with props)
Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPropertyImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java?rev=916337&r1=916336&r2=916337&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java Thu Feb 25 16:23:16 2010
@@ -52,10 +52,8 @@
 	 * @param context
 	 *            the <code>SessionContext</code> to be used for the session; if
 	 *            <code>null</code>, a default context is used
-	 * @return the old <code>SessionContext</code> used before
-	 *         <code>setContext</code> was called
 	 */
-	SessionContext setContext(SessionContext context);
+	void setContext(SessionContext context);
 
 	// localization
 
@@ -64,51 +62,6 @@
 	 */
 	Locale getLocale();
 
-	// extensions
-
-	// TODO : clarify extension handling
-
-	/*
-	 * basic idea is: Application does something like startup:
-	 * session.setExtensionHandler('action', handler); performing an action:
-	 * session.set('action'); ... do some operations on the session ... -->
-	 * handler.handleExtension('action') is called by runtime
-	 */
-
-	/**
-	 * Get an ID representing an 'extension context' (an action or something)?
-	 */
-	String getExtensionContext();
-
-	/**
-	 * Set an ID representing an 'extension context' (an action or something)?
-	 * (null = default/no context)
-	 * 
-	 * @param context
-	 * @return
-	 */
-	String setExtensionContext(String context);
-
-	/**
-	 * Get the <code>ExtensionHandler</code> for a given 'extension context'.
-	 * (null = default)
-	 * 
-	 * @param context
-	 * @return
-	 */
-	ExtensionHandler getExtensionHandler(String context);
-
-	/**
-	 * Set the <code>ExtensionHandler</code> for a given 'extension context'.
-	 * (null = default)
-	 * 
-	 * @param context
-	 * @param extensionHandler
-	 * @return
-	 */
-	ExtensionHandler setExtensionHandler(String context,
-			ExtensionHandler extensionHandler);
-
 	// services
 
 	/**

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java?rev=916337&r1=916336&r2=916337&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java Thu Feb 25 16:23:16 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.opencmis.client.runtime;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.GregorianCalendar;
 import java.util.List;
@@ -46,13 +48,13 @@
 import org.apache.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
 import org.apache.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 import org.apache.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
-import org.apache.opencmis.commons.impl.dataobjects.PropertiesDataImpl;
-import org.apache.opencmis.commons.impl.dataobjects.PropertyBooleanDataImpl;
 import org.apache.opencmis.commons.provider.AccessControlEntry;
 import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.commons.provider.FailedToDeleteData;
 import org.apache.opencmis.commons.provider.ObjectData;
 import org.apache.opencmis.commons.provider.PropertiesData;
 import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 
 public class PersistentFolderImpl implements Folder {
 
@@ -102,9 +104,16 @@
 		throw new CmisRuntimeException("not implemented");
 	}
 
-	public List<String> deleteTree(boolean allversions, UnfileObjects unfile,
+	public List<String> deleteTree(boolean allVersions, UnfileObjects unfile,
 			boolean continueOnFailure) {
-		throw new CmisRuntimeException("not implemented");
+		String repositoryId = this.session.getRepositoryInfo().getId();
+
+		FailedToDeleteData failed = this.session.getProvider()
+				.getObjectService().deleteTree(repositoryId,
+						this.objectData.getId(), allVersions, unfile,
+						continueOnFailure, null);
+
+		return failed.getIds();
 	}
 
 	public List<ObjectType> getAllowedChildObjectTypes() {
@@ -319,15 +328,6 @@
 	public void create(Folder parent, List<Property<?>> properties,
 			List<Policy> policies, List<Ace> addAce, List<Ace> removeAce) {
 
-	    List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
-	    propList.add(this.session.getProvider().getObjectFactory().createPropertyStringData(PropertyIds.CMIS_NAME, "testfolder"));
-	    propList.add(this.session.getProvider().getObjectFactory().createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID,
-	        "cmis_Folder"));
-
-	    PropertiesData xxx = this.session.getProvider().getObjectFactory().createPropertiesData(propList);
-
-		
-		
 		String repositoryId = this.session.getRepositoryInfo().getId();
 		String parentFolderId = parent.getId();
 		PropertiesData pd = this.convertToPropertiesData(properties);
@@ -382,39 +382,73 @@
 		return pList;
 	}
 
-	private PropertiesData convertToPropertiesData(List<Property<?>> properties) {
-		PropertiesDataImpl pdi = new PropertiesDataImpl();
-		PropertyData<?> pd = null;
+	@SuppressWarnings("unchecked")
+	private PropertiesData convertToPropertiesData(
+			List<Property<?>> origProperties) {
+		ProviderObjectFactory of = this.session.getProvider()
+				.getObjectFactory();
+
+		List<PropertyData<?>> convProperties = new ArrayList<PropertyData<?>>();
+		PropertyData<?> convProperty = null;
+
+		convProperties.add(of.createPropertyStringData(PropertyIds.CMIS_NAME,
+				"testfolder"));
+		convProperties.add(of.createPropertyIdData(
+				PropertyIds.CMIS_OBJECT_TYPE_ID, "cmis_Folder"));
+
+		for (Property<?> origProperty : origProperties) {
 
-		for (Property<?> property : properties) {
-			switch (property.getType()) {
+			switch (origProperty.getType()) {
 			case BOOLEAN:
-//					pd = new PropertyBooleanDataImpl(null, );
-//					pd.
+				Property<Boolean> pb = (Property<Boolean>) origProperty;
+				convProperty = of.createPropertyBooleanData(pb.getId(), pb
+						.getValue());
 				break;
 			case DATETIME:
+				Property<GregorianCalendar> pg = (Property<GregorianCalendar>) origProperty;
+				convProperty = of.createPropertyDateTimeData(pg.getId(), pg
+						.getValue());
 				break;
 			case DECIMAL:
+				Property<BigDecimal> pd = (Property<BigDecimal>) origProperty;
+				convProperty = of.createPropertyDecimalData(pd.getId(), pd
+						.getValue());
 				break;
 			case HTML:
+				Property<String> ph = (Property<String>) origProperty;
+				convProperty = of.createPropertyHtmlData(ph.getId(), ph
+						.getValue());
 				break;
 			case ID:
+				Property<String> pi = (Property<String>) origProperty;
+				convProperty = of.createPropertyIdData(pi.getId(), pi
+						.getValue());
 				break;
 			case INTEGER:
+				Property<BigInteger> pn = (Property<BigInteger>) origProperty;
+				convProperty = of.createPropertyIntegerData(pn.getId(), pn
+						.getValue());
 				break;
 			case STRING:
+				Property<String> ps = (Property<String>) origProperty;
+				convProperty = of.createPropertyStringData(ps.getId(), ps
+						.getValue());
 				break;
 			case URI:
+				Property<String> pu = (Property<String>) origProperty;
+				convProperty = of.createPropertyUriData(pu.getId(), pu
+						.getValue());
 				break;
 			default:
 				throw new CmisRuntimeException("unsupported property type"
-						+ property.getType());
+						+ origProperty.getType());
 			}
-
-			pdi.addProperty(pd);
+			convProperties.add(convProperty);
 		}
 
-		return pdi;
+		PropertiesData pd = of.createPropertiesData(convProperties);
+
+		return pd;
 	}
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPropertyImpl.java?rev=916337&r1=916336&r2=916337&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPropertyImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPropertyImpl.java Thu Feb 25 16:23:16 2010
@@ -33,9 +33,15 @@
 	 * serialization
 	 */
 	private static final long serialVersionUID = -6586532350183649719L;
+	private PersistentSessionImpl session;
+	private CmisProperties cmisProperties;
+	private T value;
 
 	public PersistentPropertyImpl(PersistentSessionImpl session,
 			CmisProperties cmisProperties, T value) {
+		this.session = session;
+		this.cmisProperties = cmisProperties;
+		this.value = value;
 	}
 
 	public PersistentPropertyImpl(PersistentSessionImpl session,
@@ -57,7 +63,7 @@
 	}
 
 	public String getId() {
-		throw new CmisRuntimeException("not implemented");
+		return this.cmisProperties.value();
 	}
 
 	public String getLocalName() {
@@ -69,11 +75,11 @@
 	}
 
 	public PropertyType getType() {
-		throw new CmisRuntimeException("not implemented");
+		return PropertyType.STRING;
 	}
 
 	public T getValue() {
-		throw new CmisRuntimeException("not implemented");
+		return this.value;
 	}
 
 	public String getValueAsString() {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java?rev=916337&r1=916336&r2=916337&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java Thu Feb 25 16:23:16 2010
@@ -63,6 +63,11 @@
 	private static Log log = LogFactory.getLog(PersistentSessionImpl.class);
 
 	/*
+	 * default session context (serializable)
+	 */
+	private SessionContextImpl context = new SessionContextImpl();
+
+	/*
 	 * root folder containing generated test data (not serializable)
 	 */
 	private transient Folder testRootFolder = null;
@@ -91,7 +96,8 @@
 	/*
 	 * helper factory (non serializable)
 	 */
-	private transient PropertyFactory propertyFactory = PropertyFactoryImpl.newInstance(this);
+	private transient PropertyFactory propertyFactory = PropertyFactoryImpl
+			.newInstance(this);
 
 	/*
 	 * Object cache (serializable)
@@ -99,15 +105,15 @@
 	private Cache cache = null;
 
 	/*
-	 * Lazy loaded repository info
-	 * (serializable)
+	 * Lazy loaded repository info (serializable)
 	 */
 	private RepositoryInfo repositoryInfo;
 
 	/*
 	 * helper factory (non serializable)
 	 */
-	private transient ObjectFactory objectFactory = PersistentObjectFactoryImpl.newInstance(this);
+	private transient ObjectFactory objectFactory = PersistentObjectFactoryImpl
+			.newInstance(this);
 
 	/**
 	 * required for serialization
@@ -193,15 +199,7 @@
 	}
 
 	public SessionContext getContext() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getExtensionContext() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ExtensionHandler getExtensionHandler(String context) {
-		throw new CmisRuntimeException("not implemented");
+		return this.context;
 	}
 
 	public Locale getLocale() {
@@ -217,7 +215,7 @@
 	}
 
 	public ObjectFactory getObjectFactory() {
-		return this.objectFactory ;
+		return this.objectFactory;
 	}
 
 	public PropertyFactory getPropertyFactory() {
@@ -226,7 +224,8 @@
 
 	public RepositoryInfo getRepositoryInfo() {
 		if (this.repositoryInfo == null) {
-			RepositoryInfoData riData = this.provider.getRepositoryService().getRepositoryInfo(this.repositoryId, null);
+			RepositoryInfoData riData = this.provider.getRepositoryService()
+					.getRepositoryInfo(this.repositoryId, null);
 			this.repositoryInfo = new RepositoryInfoImpl(this, riData);
 		}
 		return this.repositoryInfo;
@@ -268,8 +267,8 @@
 		throw new CmisRuntimeException("not implemented");
 	}
 
-	public SessionContext setContext(SessionContext context) {
-		throw new CmisRuntimeException("not implemented");
+	public void setContext(SessionContext context) {
+		this.context = (SessionContextImpl) context;
 	}
 
 	public String setExtensionContext(String context) {
@@ -322,6 +321,11 @@
 				.createCmisProperty(CmisProperties.NAME,
 						UUID.randomUUID().toString());
 		properties.add(nameProperty);
+		Property<String> typeProperty = this
+				.getPropertyFactory()
+				.createCmisProperty(CmisProperties.OBJECT_TYPE_ID, folderTypeId);
+		properties.add(typeProperty);
+
 		this.testRootFolder = rootFolder.createFolder(properties, null, null,
 				null);
 
@@ -329,8 +333,8 @@
 		og.setDocumentTypeId(documentTypeId);
 		og.setFolderTypeId(folderTypeId);
 		og.setNumberOfDocumentsToCreatePerFolder(2);
-		og.setDocumentPropertiesToGenerate(null);
-		og.setFolderPropertiesToGenerate(null);
+		og.setDocumentPropertiesToGenerate(new ArrayList<String>());
+		og.setFolderPropertiesToGenerate(new ArrayList<String>());
 
 		og.createFolderHierachy(2, 2, this.testRootFolder.getId());
 	}
@@ -390,7 +394,7 @@
 	private CmisProvider createAtomPubProvider(Map<String, String> parameters) {
 		CmisProviderFactory factory = CmisProviderFactory.newInstance();
 		CmisProvider provider = factory.createCmisAtomPubProvider(parameters);
-		
+
 		return provider;
 	}
 

Added: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java?rev=916337&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java Thu Feb 25 16:23:16 2010
@@ -0,0 +1,105 @@
+/*
+ * 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.opencmis.client.runtime;
+
+import java.io.Serializable;
+
+import org.apache.opencmis.client.api.SessionContext;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.exceptions.CmisFilterNotValidException;
+
+public class SessionContextImpl implements SessionContext, Serializable {
+
+	/**
+	 * serialization
+	 */
+	private static final long serialVersionUID = 5310354977995174876L;
+	
+	private boolean includeAcls = false;
+	private boolean includeAllowableActions = false;
+	private boolean includePathSegments = false;
+	private boolean includesPolicies = false;
+	private String propertiesFilter = null;
+	private IncludeRelationships relationshipsFilter = null;
+	private String renditionsFilter = null;
+
+	public boolean getIncludeAcls() {
+		return this.includeAcls;
+	}
+
+	public boolean getIncludeAllowableActions() {
+		return this.includeAllowableActions;
+	}
+
+	public boolean getIncludePathSegments() {
+		return this.includePathSegments;
+	}
+
+	public boolean getIncludePolicies() {
+		return this.includesPolicies;
+	}
+
+	public String getIncludeProperties() {
+		return this.propertiesFilter;
+	}
+
+	public IncludeRelationships getIncludeRelationships() {
+		return this.relationshipsFilter;
+	}
+
+	public String getIncludeRenditions() {
+		return this.renditionsFilter;
+	}
+
+	public void setIncludeAcls(boolean includeAcls) {
+		this.includeAcls = includeAcls;
+	}
+
+	public void setIncludeAllowableActions(boolean includeAllowableActions) {
+		this.includeAllowableActions = includeAllowableActions;
+	}
+
+	public void setIncludePathSegments(boolean includePathSegments) {
+		this.includePathSegments = includePathSegments; // TODO Auto-generated
+		// method stub
+
+	}
+
+	public void setIncludePolicies(boolean includePolicies) {
+		this.includesPolicies = includePolicies;
+	}
+
+	public void setIncludeProperties(String filter)
+			throws CmisFilterNotValidException {
+		this.propertiesFilter = filter;
+
+	}
+
+	public void setIncludeRelationships(IncludeRelationships filter)
+			throws CmisFilterNotValidException {
+		this.relationshipsFilter = filter;
+	}
+
+	public void setIncludeRenditions(String filter)
+			throws CmisFilterNotValidException {
+		this.renditionsFilter = filter;
+
+	}
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain