chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r917425 [2/3] - in /incubator/chemistry/trunk/opencmis/opencmis-client: opencmis-client-api/src/main/java/org/apache/opencmis/client/api/ opencmis-client-api/src/main/java/org/apache/opencmis/client/api/objecttype/ opencmis-client-api/src/m...
Date Mon, 01 Mar 2010 09:06:07 GMT
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=917425&r1=917424&r2=917425&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 Mon Mar  1 09:06:06 2010
@@ -23,32 +23,23 @@
 import java.util.ArrayList;
 import java.util.GregorianCalendar;
 import java.util.List;
-import java.util.TreeMap;
 
 import org.apache.opencmis.client.api.Ace;
 import org.apache.opencmis.client.api.CmisObject;
 import org.apache.opencmis.client.api.ContentStream;
 import org.apache.opencmis.client.api.Document;
+import org.apache.opencmis.client.api.FileableCmisObject;
 import org.apache.opencmis.client.api.Folder;
 import org.apache.opencmis.client.api.Policy;
 import org.apache.opencmis.client.api.Property;
-import org.apache.opencmis.client.api.Relationship;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
-import org.apache.opencmis.client.api.repository.AllowableActions;
-import org.apache.opencmis.client.api.util.AceList;
+import org.apache.opencmis.client.api.util.Container;
 import org.apache.opencmis.client.api.util.PagingList;
 import org.apache.opencmis.commons.PropertyIds;
-import org.apache.opencmis.commons.enums.AclPropagation;
-import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.enums.IncludeRelationships;
-import org.apache.opencmis.commons.enums.RelationshipDirection;
 import org.apache.opencmis.commons.enums.UnfileObjects;
 import org.apache.opencmis.commons.enums.VersioningState;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
-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.provider.AccessControlEntry;
 import org.apache.opencmis.commons.provider.AccessControlList;
 import org.apache.opencmis.commons.provider.FailedToDeleteData;
 import org.apache.opencmis.commons.provider.ObjectData;
@@ -56,399 +47,190 @@
 import org.apache.opencmis.commons.provider.PropertyData;
 import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 
-public class PersistentFolderImpl implements Folder {
+public class PersistentFolderImpl extends AbstractPersistentFilableCmisObject implements Folder {
 
-	private PersistentSessionImpl session;
-	private ObjectData objectData;
+  /**
+   * Constructor.
+   */
+  public PersistentFolderImpl(PersistentSessionImpl session, ObjectType objectType,
+      ObjectData objectData) {
+    initialize(session, objectType, objectData);
+  }
+
+  public PersistentFolderImpl(PersistentSessionImpl session) {
+    initialize(session, null, null);
+  }
+
+  public Document createDocument(String name) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public Document createDocument(String name, String typeId) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public Document createDocument(List<Property<?>> properties, ContentStream contentstream,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
+      List<Ace> removeACEs) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public Document createDocumentFromSource(Document source, List<Property<?>> properties,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
+      List<Ace> removeACEs) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public Folder createFolder(List<Property<?>> properties, List<Policy> policies,
+      List<Ace> addACEs, List<Ace> removeACEs) {
+
+    Folder f = getSession().getObjectFactory().createFolder(this, properties, policies, addACEs,
+        removeACEs);
+    return f;
+  }
+
+  public Policy createPolicy(List<Property<?>> properties, List<Policy> policies,
+      List<Ace> addACEs, List<Ace> removeACEs) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public List<String> deleteTree(boolean allVersions, UnfileObjects unfile,
+      boolean continueOnFailure) {
+    String repositoryId = getRepositoryId();
+    String objectId = getObjectId();
+
+    FailedToDeleteData failed = getProvider().getObjectService().deleteTree(repositoryId, objectId,
+        allVersions, unfile, continueOnFailure, null);
+
+    return failed.getIds();
+  }
+
+  public List<ObjectType> getAllowedChildObjectTypes() {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public PagingList<Document> getCheckedOutDocs(String orderby, int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public PagingList<CmisObject> getChildren(String orderby, int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public List<Container<FileableCmisObject>> getFolderTree(int depth) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public List<Container<FileableCmisObject>> getDescendants(int depth) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public Folder getFolderParent() {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public String getPath() {
+    List<String> paths = getPaths();
+    if ((paths == null) || (paths.isEmpty())) {
+      return null;
+    }
+
+    return paths.get(0);
+  }
+
+  /**
+   * Create folder in backend
+   * 
+   * @param parent
+   * @param properties
+   * @param policies
+   * @param addACEs
+   * @param removeACEs
+   */
+  public void create(Folder parent, List<Property<?>> properties, List<Policy> policies,
+      List<Ace> addAce, List<Ace> removeAce) {
+
+    String repositoryId = getRepositoryId();
+    String parentFolderId = parent.getId();
+    PropertiesData pd = this.convertToPropertiesData(properties);
+    List<String> pol = this.convertToPoliciesData(policies);
+    AccessControlList addAcl = SessionUtil.convertAces(getSession(), addAce);
+    AccessControlList removeAcl = SessionUtil.convertAces(getSession(), removeAce);
+
+    String objectId = getProvider().getObjectService().createFolder(repositoryId, pd,
+        parentFolderId, pol, addAcl, removeAcl, null);
+    ObjectData newObjectData = getProvider().getObjectService().getObject(repositoryId, objectId,
+        null, false, IncludeRelationships.NONE, null, true, true, null);
+
+    getSession().getCache().put(this);
+  }
+
+  private List<String> convertToPoliciesData(List<Policy> policies) {
+    List<String> pList = null;
+
+    if (policies != null) {
+      pList = new ArrayList<String>();
+      for (Policy pol : policies) {
+        pList.add(pol.getId());
+      }
+    }
+    return pList;
+  }
+
+  @SuppressWarnings("unchecked")
+  private PropertiesData convertToPropertiesData(List<Property<?>> origProperties) {
+    ProviderObjectFactory of = 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) {
+
+      switch (origProperty.getType()) {
+      case BOOLEAN:
+        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" + origProperty.getType());
+      }
+      convProperties.add(convProperty);
+    }
 
-	public PersistentFolderImpl(PersistentSessionImpl session, ObjectData od) {
+    PropertiesData pd = of.createPropertiesData(convProperties);
 
-		this.session = session;
-		this.objectData = od;
-	}
-
-	public PersistentFolderImpl(PersistentSessionImpl session) {
-		this.session = session;
-	}
-
-	public Document createDocument(String name) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public Document createDocument(String name, String typeId) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public Document createDocument(List<Property<?>> properties,
-			ContentStream contentstream, VersioningState versioningState,
-			List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public Document createDocumentFromSource(Document source,
-			List<Property<?>> properties, VersioningState versioningState,
-			List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public Folder createFolder(List<Property<?>> properties,
-			List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-
-		Folder f = this.session.getObjectFactory().createFolder(this,
-				properties, policies, addACEs, removeACEs);
-		return f;
-	}
-
-	public Policy createPolicy(List<Property<?>> properties,
-			List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<String> deleteTree(boolean allVersions, UnfileObjects unfile,
-			boolean continueOnFailure) {
-		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() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PagingList<Document> getCheckedOutDocs(String orderby,
-			int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PagingList<CmisObject> getChildren(String orderby, int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public TreeMap<String, CmisObject> getDescendants(int depth) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public Folder getFolderParent() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public TreeMap<String, CmisObject> getFolderTree(int depth) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void addAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void addToFolder(Folder folder, boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public AceList applyAcl(List<Ace> addAces, List<Ace> removeAces,
-			AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void applyPolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void applyPolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void delete(boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Ace> getAcl() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public AceList getAcl(boolean onlyBasicPermissions) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public AllowableActions getAllowableActions() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ObjectType getBaseType() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public BaseObjectTypeIds getBaseTypeId() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getChangeToken() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getCreatedBy() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public GregorianCalendar getCreationDate() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getId() {
-		return this.objectData.getId();
-	}
-
-	public GregorianCalendar getLastModificationDate() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getLastModifiedBy() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getName() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Folder> getParents() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getPath() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getPathSegment() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Policy> getPolicies() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Property<?>> getProperties() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Property<?>> getProperties(String filter) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public <T> Property<T> getProperty(String id) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public <T> List<T> getPropertyMultivalue(String id) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public <T> T getPropertyValue(String id) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Relationship> getRelationships() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<Relationship> getRelationships(
-			boolean includeSubRelationshipTypes,
-			RelationshipDirection relationshipDirection, ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ObjectType getType() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public boolean isChanged() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public boolean isExactAcl() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public CmisObject move(Folder targetfolder) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void removeAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void removeFromFolder(Folder folder) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void removePolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void removePolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void setName(String name) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public <T> void setProperty(String id, T value) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public <T> void setPropertyMultivalue(String id, List<T> value) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void setType(ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void setTypeId(String typeId) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void updateProperties(List<Property<?>> properties) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	/**
-	 * Create folder in backend
-	 * 
-	 * @param parent
-	 * @param properties
-	 * @param policies
-	 * @param addACEs
-	 * @param removeACEs
-	 */
-	public void create(Folder parent, List<Property<?>> properties,
-			List<Policy> policies, List<Ace> addAce, List<Ace> removeAce) {
-
-		String repositoryId = this.session.getRepositoryInfo().getId();
-		String parentFolderId = parent.getId();
-		PropertiesData pd = this.convertToPropertiesData(properties);
-		List<String> pol = this.convertToPoliciesData(policies);
-		AccessControlList addAcl = this.convertToAcl(addAce);
-		AccessControlList removeAcl = this.convertToAcl(removeAce);
-
-		String objectId = this.session.getProvider().getObjectService()
-				.createFolder(repositoryId, pd, parentFolderId, pol, addAcl,
-						removeAcl, null);
-		this.objectData = this.session.getProvider().getObjectService()
-				.getObject(repositoryId, objectId, null, false,
-						IncludeRelationships.NONE, null, true, true, null);
-
-		this.session.getCache().put(this);
-	}
-
-	private AccessControlList convertToAcl(List<Ace> aceList) {
-		AccessControlListImpl acli = null;
-		AccessControlEntryImpl acei;
-		List<AccessControlEntry> aceiList = null;
-		AccessControlPrincipalDataImpl acpdi = null;
-
-		if (aceList != null) {
-			acli = new AccessControlListImpl();
-			aceiList = new ArrayList<AccessControlEntry>();
-
-			for (Ace aceEntry : aceList) {
-				acei = new AccessControlEntryImpl();
-				acei.setPermissions(aceEntry.getPermissionsNames());
-				acpdi = new AccessControlPrincipalDataImpl(aceEntry
-						.getPrincipalId());
-				acei.setPrincipal(acpdi);
-
-				aceiList.add(acei);
-			}
-
-			acli.setAces(aceiList);
-		}
-		return acli;
-	}
-
-	private List<String> convertToPoliciesData(List<Policy> policies) {
-		List<String> pList = null;
-
-		if (policies != null) {
-			pList = new ArrayList<String>();
-			for (Policy pol : policies) {
-				pList.add(pol.getPolicyText());
-			}
-		}
-		return pList;
-	}
-
-	@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) {
-
-			switch (origProperty.getType()) {
-			case BOOLEAN:
-				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"
-						+ origProperty.getType());
-			}
-			convProperties.add(convProperty);
-		}
-
-		PropertiesData pd = of.createPropertiesData(convProperties);
-
-		return pd;
-	}
+    return pd;
+  }
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java?rev=917425&r1=917424&r2=917425&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java Mon Mar  1 09:06:06 2010
@@ -18,245 +18,23 @@
  */
 package org.apache.opencmis.client.runtime;
 
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import org.apache.opencmis.client.api.Ace;
-import org.apache.opencmis.client.api.CmisObject;
-import org.apache.opencmis.client.api.Folder;
 import org.apache.opencmis.client.api.Policy;
-import org.apache.opencmis.client.api.Property;
-import org.apache.opencmis.client.api.Relationship;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
-import org.apache.opencmis.client.api.repository.AllowableActions;
-import org.apache.opencmis.client.api.util.AceList;
-import org.apache.opencmis.commons.enums.AclPropagation;
-import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
-import org.apache.opencmis.commons.enums.RelationshipDirection;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.opencmis.commons.provider.ObjectData;
 
-public class PersistentPolicyImpl implements Policy {
-
-	public PersistentPolicyImpl(PersistentSessionImpl persistentSessionImpl,
-			ObjectData od) {
-		// TODO Auto-generated constructor stub
-	}
-
-	public List<String> getPaths() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getPolicyText() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public void addAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void addToFolder(Folder folder, boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public AceList applyAcl(List<Ace> addAces, List<Ace> removeAces,
-			AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public void applyPolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void applyPolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void delete(boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Ace> getAcl() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public AceList getAcl(boolean onlyBasicPermissions) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public AllowableActions getAllowableActions() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public ObjectType getBaseType() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public BaseObjectTypeIds getBaseTypeId() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getChangeToken() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getCreatedBy() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public GregorianCalendar getCreationDate() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getId() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public GregorianCalendar getLastModificationDate() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getLastModifiedBy() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public String getName() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Folder> getParents() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Policy> getPolicies() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Property<?>> getProperties() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Property<?>> getProperties(String filter) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public <T> Property<T> getProperty(String id) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public <T> List<T> getPropertyMultivalue(String id) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public <T> T getPropertyValue(String id) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Relationship> getRelationships() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public List<Relationship> getRelationships(
-			boolean includeSubRelationshipTypes,
-			RelationshipDirection relationshipDirection, ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public ObjectType getType() {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public boolean isChanged() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public boolean isExactAcl() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public CmisObject move(Folder targetfolder) {
-		throw new CmisRuntimeException("not implemented");
-		
-	}
-
-	public void removeAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removeFromFolder(Folder folder) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removePolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removePolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setName(String name) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> void setProperty(String id, T value) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> void setPropertyMultivalue(String id, List<T> value) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setType(ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setTypeId(String typeId) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void updateProperties(List<Property<?>> properties) {
-		throw new CmisRuntimeException("not implemented");
+public class PersistentPolicyImpl extends AbstractPersistentFilableCmisObject implements Policy {
 
-	}
+  /**
+   * Constructor.
+   */
+  public PersistentPolicyImpl(PersistentSessionImpl session, ObjectType objectType,
+      ObjectData objectData) {
+    initialize(session, objectType, objectData);
+  }
+
+  public String getPolicyText() {
+    throw new CmisRuntimeException("not implemented");
+  }
 
 }

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=917425&r1=917424&r2=917425&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 Mon Mar  1 09:06:06 2010
@@ -19,79 +19,102 @@
 package org.apache.opencmis.client.runtime;
 
 import java.io.Serializable;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.opencmis.client.api.Property;
 import org.apache.opencmis.commons.api.PropertyDefinition;
-import org.apache.opencmis.commons.enums.CmisProperties;
+import org.apache.opencmis.commons.enums.Cardinality;
 import org.apache.opencmis.commons.enums.PropertyType;
-import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 
+/**
+ * Property Implementation.
+ */
 public class PersistentPropertyImpl<T> implements Property<T>, Serializable {
 
-	/**
-	 * 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,
-			PropertyType type, T value) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PersistentPropertyImpl(PersistentSessionImpl session,
-			PropertyType type, List<T> value) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PropertyDefinition<T> getDefinition() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getDisplayName() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getId() {
-		return this.cmisProperties.value();
-	}
-
-	public String getLocalName() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public String getQueryName() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PropertyType getType() {
-		return PropertyType.STRING;
-	}
-
-	public T getValue() {
-		return this.value;
-	}
-
-	public String getValueAsString() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public List<T> getValues() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public boolean isMultiValued() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
+  /**
+   * serialization
+   */
+  private static final long serialVersionUID = -6586532350183649719L;
+  private PropertyDefinition<T> type;
+  private List<T> values;
+
+  /**
+   * Constructs a single-value property.
+   */
+  public PersistentPropertyImpl(PropertyDefinition<T> type, T value) {
+    if (type == null) {
+      throw new IllegalArgumentException("Type must be set!");
+    }
+
+    if (value == null) {
+      throw new IllegalArgumentException("Value must be set!");
+    }
+
+    this.type = type;
+    this.values = Collections.singletonList(value);
+  }
+
+  /**
+   * Constructs a multi-value property.
+   */
+  public PersistentPropertyImpl(PropertyDefinition<T> type, List<T> values) {
+    if (type == null) {
+      throw new IllegalArgumentException("Type must be set!");
+    }
+
+    if (values == null) {
+      throw new IllegalArgumentException("Values must be set!");
+    }
+
+    if (values.isEmpty()) {
+      throw new IllegalArgumentException("Values must not be empyt!");
+    }
+
+    this.type = type;
+    this.values = values;
+  }
+
+  public PropertyDefinition<T> getDefinition() {
+    return this.type;
+  }
+
+  public String getDisplayName() {
+    return this.type.getDisplayName();
+  }
+
+  public String getId() {
+    return this.type.getId();
+  }
+
+  public String getLocalName() {
+    return this.type.getLocalName();
+  }
+
+  public String getQueryName() {
+    return this.type.getQueryName();
+  }
+
+  public PropertyType getType() {
+    return this.type.getPropertyType();
+  }
+
+  public T getValue() {
+    return this.values.get(0);
+  }
+
+  public String getValueAsString() {
+    switch (this.type.getPropertyType()) {
+    default:
+      return this.values.get(0).toString();
+    }
+  }
+
+  public List<T> getValues() {
+    return this.values;
+  }
+
+  public boolean isMultiValued() {
+    return this.type.getCardinality() == Cardinality.MULTI;
+  }
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java?rev=917425&r1=917424&r2=917425&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java Mon Mar  1 09:06:06 2010
@@ -18,245 +18,30 @@
  */
 package org.apache.opencmis.client.runtime;
 
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import org.apache.opencmis.client.api.Ace;
 import org.apache.opencmis.client.api.CmisObject;
-import org.apache.opencmis.client.api.Folder;
-import org.apache.opencmis.client.api.Policy;
-import org.apache.opencmis.client.api.Property;
 import org.apache.opencmis.client.api.Relationship;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
-import org.apache.opencmis.client.api.repository.AllowableActions;
-import org.apache.opencmis.client.api.util.AceList;
-import org.apache.opencmis.commons.enums.AclPropagation;
-import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
-import org.apache.opencmis.commons.enums.RelationshipDirection;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.opencmis.commons.provider.ObjectData;
 
-public class PersistentRelationshipImpl implements Relationship {
-
-	public PersistentRelationshipImpl(
-			PersistentSessionImpl persistentSessionImpl, ObjectData od) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public CmisObject getSource() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public CmisObject getTarget() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void addAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void addToFolder(Folder folder, boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public AceList applyAcl(List<Ace> addAces, List<Ace> removeAces,
-			AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void applyPolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void applyPolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void delete(boolean allVersions) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Ace> getAcl() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public AceList getAcl(boolean onlyBasicPermissions) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public AllowableActions getAllowableActions() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public ObjectType getBaseType() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public BaseObjectTypeIds getBaseTypeId() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public String getChangeToken() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public String getCreatedBy() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public GregorianCalendar getCreationDate() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public String getId() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public GregorianCalendar getLastModificationDate() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public String getLastModifiedBy() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public String getName() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Folder> getParents() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Policy> getPolicies() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Property<?>> getProperties() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Property<?>> getProperties(String filter) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> Property<T> getProperty(String id) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> List<T> getPropertyMultivalue(String id) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> T getPropertyValue(String id) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Relationship> getRelationships() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public List<Relationship> getRelationships(
-			boolean includeSubRelationshipTypes,
-			RelationshipDirection relationshipDirection, ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public ObjectType getType() {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public boolean isChanged() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public boolean isExactAcl() {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public CmisObject move(Folder targetfolder) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removeAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removeFromFolder(Folder folder) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removePolicy(Policy policy) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void removePolicy(String policyId) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setName(String name) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> void setProperty(String id, T value) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public <T> void setPropertyMultivalue(String id, List<T> value) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setType(ObjectType type) {
-		throw new CmisRuntimeException("not implemented");
-
-	}
-
-	public void setTypeId(String typeId) {
-		throw new CmisRuntimeException("not implemented");
+public class PersistentRelationshipImpl extends AbstractPersistentCmisObject implements
+    Relationship {
 
-	}
+  /**
+   * Constructor.
+   */
+  public PersistentRelationshipImpl(PersistentSessionImpl session, ObjectType objectType,
+      ObjectData objectData) {
+    initialize(session, objectType, objectData);
+  }
+
+  public CmisObject getSource() {
+    throw new CmisRuntimeException("not implemented");
 
-	public void updateProperties(List<Property<?>> properties) {
-		throw new CmisRuntimeException("not implemented");
+  }
 
-	}
+  public CmisObject getTarget() {
+    throw new CmisRuntimeException("not implemented");
 
+  }
 }

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=917425&r1=917424&r2=917425&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 Mon Mar  1 09:06:06 2010
@@ -39,427 +39,459 @@
 import org.apache.opencmis.client.api.repository.ObjectFactory;
 import org.apache.opencmis.client.api.repository.PropertyFactory;
 import org.apache.opencmis.client.api.repository.RepositoryInfo;
+import org.apache.opencmis.client.api.util.Container;
 import org.apache.opencmis.client.api.util.PagingList;
 import org.apache.opencmis.client.api.util.Testable;
 import org.apache.opencmis.client.provider.factory.CmisProviderFactory;
 import org.apache.opencmis.client.runtime.cache.Cache;
 import org.apache.opencmis.client.runtime.cache.CacheImpl;
 import org.apache.opencmis.client.runtime.repository.PersistentObjectFactoryImpl;
-import org.apache.opencmis.client.runtime.repository.PropertyFactoryImpl;
+import org.apache.opencmis.client.runtime.repository.PersistentPropertyFactoryImpl;
+import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.SessionParameter;
 import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.api.TypeDefinition;
 import org.apache.opencmis.commons.enums.BindingType;
+import org.apache.opencmis.commons.enums.Cardinality;
 import org.apache.opencmis.commons.enums.CmisProperties;
 import org.apache.opencmis.commons.enums.IncludeRelationships;
 import org.apache.opencmis.commons.enums.UnfileObjects;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.opencmis.commons.provider.CmisProvider;
 import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.PropertyIdData;
 import org.apache.opencmis.util.repository.ObjectGenerator;
 
-public class PersistentSessionImpl implements PersistentSession, Testable,
-		Serializable {
+public class PersistentSessionImpl implements PersistentSession, Testable, Serializable {
 
-	private static Log log = LogFactory.getLog(PersistentSessionImpl.class);
+  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;
-
-	/*
-	 * session parameter (serializable)
-	 */
-	private Map<String, String> parameters = null;
-
-	/*
-	 * CMIS provider (serializable)
-	 */
-	private CmisProvider provider = null;
-
-	/*
-	 * Session Locale, determined from session parameter (serializable)
-	 */
-	private Locale locale = null;
-
-	/*
-	 * helper factory (non serializable)
-	 */
-	private transient PropertyFactory propertyFactory = PropertyFactoryImpl
-			.newInstance(this);
-
-	/*
-	 * Object cache (serializable)
-	 */
-	private Cache cache = null;
-
-	/*
-	 * Lazy loaded repository info. Will be invalid after clear(). Access by
-	 * getter always. (serializable)
-	 */
-	private RepositoryInfoImpl repositoryInfo;
-
-	/*
-	 * helper factory (non serializable)
-	 */
-	private transient ObjectFactory objectFactory = PersistentObjectFactoryImpl
-			.newInstance(this);
-
-	/**
-	 * required for serialization
-	 */
-	private static final long serialVersionUID = -4287481628831198383L;
-
-	public PersistentSessionImpl(Map<String, String> parameters) {
-		this.parameters = parameters;
-		PersistentSessionImpl.log.info("Session Parameters: " + parameters);
-
-		this.locale = this.determineLocale(parameters);
-		PersistentSessionImpl.log.info("Session Locale: "
-				+ this.locale.toString());
-
-		int cacheSize = this.determineCacheSize(parameters);
-
-		if (cacheSize == -1) {
-			this.cache = CacheImpl.newInstance();
-		} else {
-			this.cache = CacheImpl.newInstance(cacheSize);
-		}
-		PersistentSessionImpl.log.info("Session Cache Size: "
-				+ this.cache.size());
-	}
-
-	private int determineCacheSize(Map<String, String> parameters) {
-		int size = -1;
-
-		return size;
-	}
-
-	private String determineRepositoryId(Map<String, String> parameters) {
-		String repositoryId = parameters.get(SessionParameter.REPOSITORY_ID);
-		// if null then the provider will return a repository id (lazy)
-		return repositoryId;
-	}
-
-	private Locale determineLocale(Map<String, String> parameters) {
-		Locale locale = null;
-
-		String language = parameters
-				.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
-		String country = parameters
-				.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
-		String variant = parameters.get(SessionParameter.LOCALE_VARIANT);
-
-		if (variant != null) {
-			// all 3 parameter must not be null and valid
-			locale = new Locale(language, country, variant);
-		} else {
-			if (country != null) {
-				// 2 parameter must not be null and valid
-				locale = new Locale(language, country);
-			} else {
-				if (language != null) {
-					// 1 parameter must not be null and valid
-					locale = new Locale(language);
-				} else {
-					locale = Locale.getDefault();
-				}
-			}
-		}
-
-		return locale;
-	}
-
-	public void clear() {
-		/*
-		 * clear cache
-		 */
-
-		int cacheSize = this.determineCacheSize(this.parameters);
-		if (cacheSize == -1) {
-			this.cache = CacheImpl.newInstance();
-		} else {
-			this.cache = CacheImpl.newInstance(cacheSize);
-		}
-		PersistentSessionImpl.log.info("Session Cache Size: "
-				+ this.cache.size());
-
-		/*
-		 * clear repository info
-		 */
-
-		this.repositoryInfo.clear();
-	}
-
-	public PagingList<Document> getCheckedOutDocs(Folder folder,
-			String orderby, int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PagingList<ChangeEvent> getContentChanges(String changeLogToken,
-			int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public SessionContext getContext() {
-		return this.context;
-	}
-
-	public Locale getLocale() {
-		return this.locale;
-	}
-
-	public CmisObject getObject(String objectId) {
-		CmisObject obj = null;
-		if (this.cache.containsId(objectId)) {
-			obj = this.cache.get(objectId);
-		} else {
-			/* query context */
-			String filter = this.context.getIncludeProperties();
-			boolean includeAllowableActions = this.context
-					.getIncludeAllowableActions();
-			IncludeRelationships includeRelationships = this.context
-					.getIncludeRelationships();
-			String renditionFilter = this.context.getIncludeRenditions();
-			boolean includePolicyIds = this.context.getIncludePolicies();
-			boolean includeAcl = this.context.getIncludeAcls();
-			ExtensionsData extension = null;
-
-			/* ask backend */
-			String repositoryId = this.getRepositoryId();
-			ObjectData od = this.provider.getObjectService().getObject(
-					repositoryId, objectId, filter, includeAllowableActions,
-					includeRelationships, renditionFilter, includePolicyIds,
-					includeAcl, extension);
-
-			/* determine type */
-			switch (od.getBaseTypeId()) {
-			case CMIS_DOCUMENT:
-				obj = new PersistentDocumentImpl(this, od);
-				break;
-			case CMIS_FOLDER:
-				obj = new PersistentFolderImpl(this, od);
-				break;
-			case CMIS_POLICY:
-				obj = new PersistentPolicyImpl(this, od);
-			case CMIS_RELATIONSHIP:
-				obj = new PersistentRelationshipImpl(this, od);
-			default:
-				throw new CmisRuntimeException("unsupported type: "
-						+ od.getBaseTypeId());
-			}
-
-			this.cache.put(obj);
-		}
-		return obj;
-	}
-
-	public CmisObject getObjectByPath(String path) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ObjectFactory getObjectFactory() {
-		return this.objectFactory;
-	}
-
-	public PropertyFactory getPropertyFactory() {
-		return this.propertyFactory;
-	}
-
-	public RepositoryInfo getRepositoryInfo() {
-		if (this.repositoryInfo == null) {
-			/* get initial repository id from session parameter */
-			String repositoryId = this.determineRepositoryId(this.parameters);
-			RepositoryInfoImpl rii = new RepositoryInfoImpl(this, repositoryId);
-			this.repositoryInfo = rii;
-		}
-		return this.repositoryInfo;
-	}
-
-	public Folder getRootFolder() {
-		Folder rootFolder = null;
-
-		if (this.cache.containsPath("/")) {
-			rootFolder = (Folder) this.cache.getByPath("/");
-		} else {
-			String rootFolderId = this.getRepositoryInfo().getRootFolderId();
-			String repositoryId = this.getRepositoryId();
-			ObjectData od = this.provider.getObjectService().getObject(
-					repositoryId, rootFolderId, null, false,
-					IncludeRelationships.NONE, null, false, false, null);
-			rootFolder = new PersistentFolderImpl(this, od);
-			this.cache.put(rootFolder);
-		}
-
-		return rootFolder;
-	}
-
-	public PagingList<ObjectType> getTypeChildren(ObjectType t,
-			boolean includePropertyDefinitions, int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ObjectType getTypeDefinition(String typeId) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PagingList<ObjectType> getTypeDescendants(ObjectType t, int depth,
-			boolean includePropertyDefinitions, int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public PagingList<CmisObject> query(String statement,
-			boolean searchAllVersions, int itemsPerPage) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void setContext(SessionContext context) {
-		this.context = (SessionContextImpl) context;
-	}
-
-	public String setExtensionContext(String context) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public ExtensionHandler setExtensionHandler(String context,
-			ExtensionHandler extensionHandler) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	public void generateTestData(Map<String, String> parameter) {
-		String repositoryId = this.getRepositoryId();
-		ObjectGenerator og = new ObjectGenerator(this.provider
-				.getObjectFactory(), this.provider.getNavigationService(),
-				this.provider.getObjectService(), repositoryId);
-		Folder rootFolder = null;
-		String documentTypeId = null;
-		String folderTypeId = null;
-
-		// check preconditions (mandatory parameter)
-		if (!parameter.containsKey(Testable.DOCUMENT_TYPE_ID_PARAMETER)) {
-			throw new CmisRuntimeException(
-					"Can't genereate test data! Paramter missing: "
-							+ Testable.DOCUMENT_TYPE_ID_PARAMETER);
-		} else {
-			documentTypeId = parameter.get(Testable.DOCUMENT_TYPE_ID_PARAMETER);
-		}
-		if (!parameter.containsKey(Testable.FOLDER_TYPE_ID_PARAMETER)) {
-			throw new CmisRuntimeException(
-					"Can't genereate test data! Paramter missing: "
-							+ Testable.FOLDER_TYPE_ID_PARAMETER);
-		} else {
-			folderTypeId = parameter.get(Testable.FOLDER_TYPE_ID_PARAMETER);
-		}
-
-		// optional test root folder:
-		if (parameter.containsKey(Testable.ROOT_FOLDER_ID_PARAMETER)) {
-			// test root folder
-			String testRootId = parameter
-					.get(Testable.ROOT_FOLDER_ID_PARAMETER);
-			rootFolder = (Folder) this.getObject(testRootId);
-		} else {
-			// repository root
-			rootFolder = this.getRootFolder();
-		}
-
-		// create test root folder
-		List<Property<?>> properties = new ArrayList<Property<?>>();
-		Property<String> nameProperty = this.getPropertyFactory()
-				.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);
-
-		og.setContentSizeInKB(10);
-		og.setDocumentTypeId(documentTypeId);
-		og.setFolderTypeId(folderTypeId);
-		og.setNumberOfDocumentsToCreatePerFolder(2);
-		og.setDocumentPropertiesToGenerate(new ArrayList<String>());
-		og.setFolderPropertiesToGenerate(new ArrayList<String>());
-
-		og.createFolderHierachy(2, 2, this.testRootFolder.getId());
-	}
-
-	public void cleanUpTestData() {
-		if (this.testRootFolder != null) {
-			this.testRootFolder.deleteTree(true, UnfileObjects.DELETE, true);
-			this.testRootFolder = null;
-		}
-	}
-
-	/**
-	 * Connect session object to the provider. This is the very first call after
-	 * a session is created.
-	 * <p>
-	 * In dependency of the parameter set an {@code AtomPub}, a {@code
-	 * WebService} or an {@code InMemory} provider is selected.
-	 */
-	public void connect() {
-		if (this.parameters == null || this.parameters.isEmpty()) {
-			throw new CmisRuntimeException("Session parameter not set!");
-		}
-
-		BindingType bt = BindingType.fromValue(this.parameters
-				.get(SessionParameter.BINDING_TYPE));
-
-		switch (bt) {
-		case ATOMPUB:
-			this.provider = this.createAtomPubProvider(this.parameters);
-			break;
-		case WEBSERVICES:
-			this.provider = this.createWebServiceProvider(this.parameters);
-			break;
-		case UNSPECIFIC:
-			this.provider = this.createUnspecificProvider(this.parameters);
-			break;
-		default:
-			throw new CmisRuntimeException("Ambiguous session parameter: "
-					+ this.parameters);
-		}
-	}
-
-	private CmisProvider createUnspecificProvider(Map<String, String> parameters) {
-		CmisProviderFactory factory = CmisProviderFactory.newInstance();
-		CmisProvider provider = factory.createCmisProvider(parameters);
-		return provider;
-	}
-
-	private CmisProvider createWebServiceProvider(Map<String, String> parameters) {
-		CmisProviderFactory factory = CmisProviderFactory.newInstance();
-		CmisProvider provider = factory
-				.createCmisWebServicesProvider(parameters);
-
-		return provider;
-	}
-
-	private CmisProvider createAtomPubProvider(Map<String, String> parameters) {
-		CmisProviderFactory factory = CmisProviderFactory.newInstance();
-		CmisProvider provider = factory.createCmisAtomPubProvider(parameters);
-
-		return provider;
-	}
-
-	public CmisProvider getProvider() {
-		return this.provider;
-	}
-
-	public Cache getCache() {
-		return this.cache;
-	}
-
-	public String getRepositoryId() {
-		return this.getRepositoryInfo().getId();
-	}
+  /*
+   * default session context (serializable)
+   */
+  private SessionContextImpl context = new SessionContextImpl();
+
+  /*
+   * root folder containing generated test data (not serializable)
+   */
+  private transient Folder testRootFolder = null;
+
+  /*
+   * session parameter (serializable)
+   */
+  private Map<String, String> parameters = null;
+
+  /*
+   * CMIS provider (serializable)
+   */
+  private CmisProvider provider = null;
+
+  /*
+   * Session Locale, determined from session parameter (serializable)
+   */
+  private Locale locale = null;
+
+  /*
+   * helper factory (non serializable)
+   */
+  private transient PropertyFactory propertyFactory = PersistentPropertyFactoryImpl
+      .newInstance(this);
+
+  /*
+   * Object cache (serializable)
+   */
+  private Cache cache = null;
+
+  /*
+   * Lazy loaded repository info. Will be invalid after clear(). Access by getter always.
+   * (serializable)
+   */
+  private RepositoryInfoImpl repositoryInfo;
+
+  /*
+   * helper factory (non serializable)
+   */
+  private transient ObjectFactory objectFactory = PersistentObjectFactoryImpl.newInstance(this);
+
+  /**
+   * required for serialization
+   */
+  private static final long serialVersionUID = -4287481628831198383L;
+
+  public PersistentSessionImpl(Map<String, String> parameters) {
+    this.parameters = parameters;
+    PersistentSessionImpl.log.info("Session Parameters: " + parameters);
+
+    this.locale = this.determineLocale(parameters);
+    PersistentSessionImpl.log.info("Session Locale: " + this.locale.toString());
+
+    int cacheSize = this.determineCacheSize(parameters);
+
+    if (cacheSize == -1) {
+      this.cache = CacheImpl.newInstance();
+    }
+    else {
+      this.cache = CacheImpl.newInstance(cacheSize);
+    }
+    PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.size());
+  }
+
+  private int determineCacheSize(Map<String, String> parameters) {
+    int size = -1;
+
+    return size;
+  }
+
+  private String determineRepositoryId(Map<String, String> parameters) {
+    String repositoryId = parameters.get(SessionParameter.REPOSITORY_ID);
+    // if null then the provider will return a repository id (lazy)
+    return repositoryId;
+  }
+
+  private Locale determineLocale(Map<String, String> parameters) {
+    Locale locale = null;
+
+    String language = parameters.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
+    String country = parameters.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
+    String variant = parameters.get(SessionParameter.LOCALE_VARIANT);
+
+    if (variant != null) {
+      // all 3 parameter must not be null and valid
+      locale = new Locale(language, country, variant);
+    }
+    else {
+      if (country != null) {
+        // 2 parameter must not be null and valid
+        locale = new Locale(language, country);
+      }
+      else {
+        if (language != null) {
+          // 1 parameter must not be null and valid
+          locale = new Locale(language);
+        }
+        else {
+          locale = Locale.getDefault();
+        }
+      }
+    }
+
+    return locale;
+  }
+
+  public void clear() {
+    /*
+     * clear cache
+     */
+
+    int cacheSize = this.determineCacheSize(this.parameters);
+    if (cacheSize == -1) {
+      this.cache = CacheImpl.newInstance();
+    }
+    else {
+      this.cache = CacheImpl.newInstance(cacheSize);
+    }
+    PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.size());
+
+    /*
+     * clear repository info
+     */
+
+    this.repositoryInfo.clear();
+  }
+
+  public PagingList<Document> getCheckedOutDocs(Folder folder, String orderby, int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public PagingList<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public SessionContext getContext() {
+    return this.context;
+  }
+
+  public Locale getLocale() {
+    return this.locale;
+  }
+
+  public CmisObject getObject(String objectId) {
+    CmisObject obj = null;
+    if (this.cache.containsId(objectId)) {
+      obj = this.cache.get(objectId);
+    }
+    else {
+      /* query context */
+      String filter = this.context.getIncludeProperties();
+      boolean includeAllowableActions = this.context.getIncludeAllowableActions();
+      IncludeRelationships includeRelationships = this.context.getIncludeRelationships();
+      String renditionFilter = this.context.getIncludeRenditions();
+      boolean includePolicyIds = this.context.getIncludePolicies();
+      boolean includeAcl = this.context.getIncludeAcls();
+      ExtensionsData extension = null;
+
+      // add object id, base type id and type id to filter
+      if ((filter != null) && (filter.indexOf('*') == -1)) {
+        if (filter.indexOf(PropertyIds.CMIS_OBJECT_ID) == -1) {
+          filter = PropertyIds.CMIS_OBJECT_ID + "," + filter;
+        }
+        if (filter.indexOf(PropertyIds.CMIS_BASE_TYPE_ID) == -1) {
+          filter = PropertyIds.CMIS_BASE_TYPE_ID + "," + filter;
+        }
+        if (filter.indexOf(PropertyIds.CMIS_OBJECT_TYPE_ID) == -1) {
+          filter = PropertyIds.CMIS_OBJECT_TYPE_ID + "," + filter;
+        }
+      }
+
+      /* ask backend */
+      String repositoryId = this.getRepositoryId();
+      ObjectData od = this.provider.getObjectService().getObject(repositoryId, objectId, filter,
+          includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds,
+          includeAcl, extension);
+
+      /* determine type */
+      switch (od.getBaseTypeId()) {
+      case CMIS_DOCUMENT:
+        obj = new PersistentDocumentImpl(this, getType(od), od);
+        break;
+      case CMIS_FOLDER:
+        obj = new PersistentFolderImpl(this, getType(od), od);
+        break;
+      case CMIS_POLICY:
+        obj = new PersistentPolicyImpl(this, getType(od), od);
+      case CMIS_RELATIONSHIP:
+        obj = new PersistentRelationshipImpl(this, getType(od), od);
+      default:
+        throw new CmisRuntimeException("unsupported type: " + od.getBaseTypeId());
+      }
+
+      this.cache.put(obj);
+    }
+    return obj;
+  }
+
+  public CmisObject getObjectByPath(String path) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public ObjectFactory getObjectFactory() {
+    return this.objectFactory;
+  }
+
+  public PropertyFactory getPropertyFactory() {
+    return this.propertyFactory;
+  }
+
+  public RepositoryInfo getRepositoryInfo() {
+    if (this.repositoryInfo == null) {
+      /* get initial repository id from session parameter */
+      String repositoryId = this.determineRepositoryId(this.parameters);
+      RepositoryInfoImpl rii = new RepositoryInfoImpl(this, repositoryId);
+      this.repositoryInfo = rii;
+    }
+    return this.repositoryInfo;
+  }
+
+  public Folder getRootFolder() {
+    Folder rootFolder = null;
+
+    if (this.cache.containsPath("/")) {
+      rootFolder = (Folder) this.cache.getByPath("/");
+    }
+    else {
+      String rootFolderId = this.getRepositoryInfo().getRootFolderId();
+      String repositoryId = this.getRepositoryId();
+      ObjectData od = this.provider.getObjectService().getObject(repositoryId, rootFolderId, null,
+          false, IncludeRelationships.NONE, null, false, false, null);
+
+      rootFolder = new PersistentFolderImpl(this, getType(od), od);
+      this.cache.put(rootFolder);
+    }
+
+    return rootFolder;
+  }
+
+  public PagingList<ObjectType> getTypeChildren(ObjectType t, boolean includePropertyDefinitions,
+      int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public ObjectType getTypeDefinition(String typeId) {
+    TypeDefinition typeDefinition = getProvider().getRepositoryService().getTypeDefinition(
+        getRepositoryId(), typeId, null);
+    return SessionUtil.convertTypeDefinition(this, typeDefinition);
+  }
+
+  public List<Container<ObjectType>> getTypeDescendants(ObjectType t, int depth,
+      boolean includePropertyDefinitions) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public PagingList<CmisObject> query(String statement, boolean searchAllVersions, int itemsPerPage) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public void setContext(SessionContext context) {
+    this.context = (SessionContextImpl) context;
+  }
+
+  public String setExtensionContext(String context) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public ExtensionHandler setExtensionHandler(String context, ExtensionHandler extensionHandler) {
+    throw new CmisRuntimeException("not implemented");
+  }
+
+  public void generateTestData(Map<String, String> parameter) {
+    String repositoryId = this.getRepositoryId();
+    ObjectGenerator og = new ObjectGenerator(this.provider.getObjectFactory(), this.provider
+        .getNavigationService(), this.provider.getObjectService(), repositoryId);
+    Folder rootFolder = null;
+    String documentTypeId = null;
+    String folderTypeId = null;
+
+    // check preconditions (mandatory parameter)
+    if (!parameter.containsKey(Testable.DOCUMENT_TYPE_ID_PARAMETER)) {
+      throw new CmisRuntimeException("Can't genereate test data! Paramter missing: "
+          + Testable.DOCUMENT_TYPE_ID_PARAMETER);
+    }
+    else {
+      documentTypeId = parameter.get(Testable.DOCUMENT_TYPE_ID_PARAMETER);
+    }
+    if (!parameter.containsKey(Testable.FOLDER_TYPE_ID_PARAMETER)) {
+      throw new CmisRuntimeException("Can't genereate test data! Paramter missing: "
+          + Testable.FOLDER_TYPE_ID_PARAMETER);
+    }
+    else {
+      folderTypeId = parameter.get(Testable.FOLDER_TYPE_ID_PARAMETER);
+    }
+
+    // optional test root folder:
+    if (parameter.containsKey(Testable.ROOT_FOLDER_ID_PARAMETER)) {
+      // test root folder
+      String testRootId = parameter.get(Testable.ROOT_FOLDER_ID_PARAMETER);
+      rootFolder = (Folder) this.getObject(testRootId);
+    }
+    else {
+      // repository root
+      rootFolder = this.getRootFolder();
+    }
+
+    PropertyIdDefinitionImpl objectIdPropertyType = new PropertyIdDefinitionImpl();
+    objectIdPropertyType.setId(CmisProperties.OBJECT_ID.value());
+    objectIdPropertyType.setCardinality(Cardinality.SINGLE);
+
+    PropertyStringDefinitionImpl namePropertyType = new PropertyStringDefinitionImpl();
+    namePropertyType.setId(CmisProperties.NAME.value());
+    namePropertyType.setCardinality(Cardinality.SINGLE);
+
+    // create test root folder
+    List<Property<?>> properties = new ArrayList<Property<?>>();
+    Property<String> nameProperty = this.getPropertyFactory().createProperty(namePropertyType,
+        UUID.randomUUID().toString());
+    properties.add(nameProperty);
+    Property<String> typeProperty = this.getPropertyFactory().createProperty(objectIdPropertyType,
+        folderTypeId);
+    properties.add(typeProperty);
+
+    this.testRootFolder = rootFolder.createFolder(properties, null, null, null);
+
+    og.setContentSizeInKB(10);
+    og.setDocumentTypeId(documentTypeId);
+    og.setFolderTypeId(folderTypeId);
+    og.setNumberOfDocumentsToCreatePerFolder(2);
+    og.setDocumentPropertiesToGenerate(new ArrayList<String>());
+    og.setFolderPropertiesToGenerate(new ArrayList<String>());
+
+    og.createFolderHierachy(2, 2, this.testRootFolder.getId());
+  }
+
+  public void cleanUpTestData() {
+    if (this.testRootFolder != null) {
+      this.testRootFolder.deleteTree(true, UnfileObjects.DELETE, true);
+      this.testRootFolder = null;
+    }
+  }
+
+  /**
+   * Connect session object to the provider. This is the very first call after a session is created.
+   * <p>
+   * In dependency of the parameter set an {@code AtomPub}, a {@code WebService} or an {@code
+   * InMemory} provider is selected.
+   */
+  public void connect() {
+    if (this.parameters == null || this.parameters.isEmpty()) {
+      throw new CmisRuntimeException("Session parameter not set!");
+    }
+
+    BindingType bt = BindingType.fromValue(this.parameters.get(SessionParameter.BINDING_TYPE));
+
+    switch (bt) {
+    case ATOMPUB:
+      this.provider = this.createAtomPubProvider(this.parameters);
+      break;
+    case WEBSERVICES:
+      this.provider = this.createWebServiceProvider(this.parameters);
+      break;
+    case UNSPECIFIC:
+      this.provider = this.createUnspecificProvider(this.parameters);
+      break;
+    default:
+      throw new CmisRuntimeException("Ambiguous session parameter: " + this.parameters);
+    }
+  }
+
+  private CmisProvider createUnspecificProvider(Map<String, String> parameters) {
+    CmisProviderFactory factory = CmisProviderFactory.newInstance();
+    CmisProvider provider = factory.createCmisProvider(parameters);
+
+    return provider;
+  }
+
+  private CmisProvider createWebServiceProvider(Map<String, String> parameters) {
+    CmisProviderFactory factory = CmisProviderFactory.newInstance();
+    CmisProvider provider = factory.createCmisWebServicesProvider(parameters);
+
+    return provider;
+  }
+
+  private CmisProvider createAtomPubProvider(Map<String, String> parameters) {
+    CmisProviderFactory factory = CmisProviderFactory.newInstance();
+    CmisProvider provider = factory.createCmisAtomPubProvider(parameters);
+
+    return provider;
+  }
+
+  public CmisProvider getProvider() {
+    return this.provider;
+  }
+
+  public Cache getCache() {
+    return this.cache;
+  }
+
+  public String getRepositoryId() {
+    return this.getRepositoryInfo().getId();
+  }
+
+  // --- internal ---
+
+  private ObjectType getType(ObjectData objectData) {
+    if ((objectData == null) || (objectData.getProperties() == null)
+        || (objectData.getProperties().getProperties() == null)) {
+      return null;
+    }
+
+    PropertyData<?> typeProperty = objectData.getProperties().getProperties().get(
+        PropertyIds.CMIS_OBJECT_TYPE_ID);
+    if (!(typeProperty instanceof PropertyIdData)) {
+      return null;
+    }
 
+    return getTypeDefinition((String) typeProperty.getFirstValue());
+  }
 }

Added: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java?rev=917425&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java Mon Mar  1 09:06:06 2010
@@ -0,0 +1,272 @@
+/*
+ * 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.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.GregorianCalendar;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.opencmis.client.api.Ace;
+import org.apache.opencmis.client.api.Acl;
+import org.apache.opencmis.client.api.AllowableActions;
+import org.apache.opencmis.client.api.Property;
+import org.apache.opencmis.client.api.Session;
+import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.client.api.repository.ObjectFactory;
+import org.apache.opencmis.client.runtime.objecttype.DocumentTypeImpl;
+import org.apache.opencmis.client.runtime.objecttype.FolderTypeImpl;
+import org.apache.opencmis.client.runtime.objecttype.PolicyTypeImpl;
+import org.apache.opencmis.client.runtime.objecttype.RelationshipTypeImpl;
+import org.apache.opencmis.commons.api.DocumentTypeDefinition;
+import org.apache.opencmis.commons.api.FolderTypeDefinition;
+import org.apache.opencmis.commons.api.PolicyTypeDefinition;
+import org.apache.opencmis.commons.api.PropertyBooleanDefinition;
+import org.apache.opencmis.commons.api.PropertyDateTimeDefinition;
+import org.apache.opencmis.commons.api.PropertyDecimalDefinition;
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.api.PropertyHtmlDefinition;
+import org.apache.opencmis.commons.api.PropertyIdDefinition;
+import org.apache.opencmis.commons.api.PropertyIntegerDefinition;
+import org.apache.opencmis.commons.api.PropertyStringDefinition;
+import org.apache.opencmis.commons.api.PropertyUriDefinition;
+import org.apache.opencmis.commons.api.RelationshipTypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.provider.AccessControlEntry;
+import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.commons.provider.AllowableActionsData;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+
+/**
+ * Utility methods.
+ */
+public final class SessionUtil {
+
+  private SessionUtil() {
+  }
+
+  /**
+   * Converts a type definition.
+   */
+  public static ObjectType convertTypeDefinition(Session session, TypeDefinition typeDefinition) {
+    if (typeDefinition instanceof DocumentTypeDefinition) {
+      return new DocumentTypeImpl(session, typeDefinition);
+    }
+    else if (typeDefinition instanceof FolderTypeDefinition) {
+      return new FolderTypeImpl(session, typeDefinition);
+    }
+    else if (typeDefinition instanceof RelationshipTypeDefinition) {
+      return new RelationshipTypeImpl(session, typeDefinition);
+    }
+    else if (typeDefinition instanceof PolicyTypeDefinition) {
+      return new PolicyTypeImpl(session, typeDefinition);
+    }
+    else {
+      throw new CmisRuntimeException("Unknown base type!");
+    }
+  }
+
+  /**
+   * Converts properties.
+   */
+  @SuppressWarnings("unchecked")
+  public static Map<String, Property<?>> convertProperties(Session session, ObjectType objectType,
+      PropertiesData properties) {
+    // check input
+    if (objectType == null) {
+      throw new IllegalArgumentException("Object type must set!");
+    }
+
+    if (objectType.getPropertyDefintions() == null) {
+      throw new IllegalArgumentException("Object type has no property defintions!");
+    }
+
+    if ((properties == null) || (properties.getProperties() == null)) {
+      throw new IllegalArgumentException("Properties must be set!");
+    }
+
+    // iterate through properties and convert them
+    Map<String, Property<?>> result = new LinkedHashMap<String, Property<?>>();
+    for (Map.Entry<String, PropertyData<?>> property : properties.getProperties().entrySet()) {
+      // find property definition
+      PropertyDefinition<?> definition = objectType.getPropertyDefintions().get(property.getKey());
+      if (definition == null) {
+        // property without definition
+        throw new CmisRuntimeException("Property '" + property.getKey() + "' doesn't exist!");
+      }
+
+      Property<?> apiProperty = null;
+
+      if (definition instanceof PropertyStringDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyStringDefinition) definition, (List<String>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyIdDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyIdDefinition) definition, (List<String>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyHtmlDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyHtmlDefinition) definition, (List<String>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyUriDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyUriDefinition) definition, (List<String>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyIntegerDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyIntegerDefinition) definition,
+            (List<BigInteger>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyBooleanDefinition) {
+        apiProperty = session.getPropertyFactory()
+            .createPropertyMultivalue((PropertyBooleanDefinition) definition,
+                (List<Boolean>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyDecimalDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyDecimalDefinition) definition,
+            (List<BigDecimal>) property.getValue().getValues());
+      }
+      else if (definition instanceof PropertyDateTimeDefinition) {
+        apiProperty = session.getPropertyFactory().createPropertyMultivalue(
+            (PropertyDateTimeDefinition) definition,
+            (List<GregorianCalendar>) property.getValue().getValues());
+      }
+
+      result.put(property.getKey(), apiProperty);
+    }
+
+    return result;
+  }
+
+  /**
+   * Converts properties.
+   */
+  @SuppressWarnings("unchecked")
+  public static PropertiesData convertProperties(Session session, Collection<Property<?>> properties) {
+    // check input
+    if (properties == null) {
+      throw new IllegalArgumentException("Properties must be set!");
+    }
+
+    ProviderObjectFactory pof = session.getProvider().getObjectFactory();
+
+    // iterate through properties and convert them
+    List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
+    for (Property<?> property : properties) {
+
+      PropertyDefinition<?> definition = property.getDefinition();
+      if (definition instanceof PropertyStringDefinition) {
+        propertyList.add(pof.createPropertyStringData(property.getId(), (List<String>) property
+            .getValues()));
+      }
+      else if (definition instanceof PropertyIdDefinition) {
+        propertyList.add(pof.createPropertyIdData(property.getId(), (List<String>) property
+            .getValues()));
+      }
+      else if (definition instanceof PropertyHtmlDefinition) {
+        propertyList.add(pof.createPropertyHtmlData(property.getId(), (List<String>) property
+            .getValues()));
+      }
+      else if (definition instanceof PropertyUriDefinition) {
+        propertyList.add(pof.createPropertyUriData(property.getId(), (List<String>) property
+            .getValues()));
+      }
+      else if (definition instanceof PropertyIntegerDefinition) {
+        propertyList.add(pof.createPropertyIntegerData(property.getId(),
+            (List<BigInteger>) property.getValues()));
+      }
+      else if (definition instanceof PropertyBooleanDefinition) {
+        propertyList.add(pof.createPropertyBooleanData(property.getId(), (List<Boolean>) property
+            .getValues()));
+      }
+      else if (definition instanceof PropertyDecimalDefinition) {
+        propertyList.add(pof.createPropertyDecimalData(property.getId(),
+            (List<BigDecimal>) property.getValues()));
+      }
+      else if (definition instanceof PropertyDateTimeDefinition) {
+        propertyList.add(pof.createPropertyDateTimeData(property.getId(),
+            (List<GregorianCalendar>) property.getValues()));
+      }
+    }
+
+    return pof.createPropertiesData(propertyList);
+  }
+
+  /**
+   * Converts allowable actions.
+   */
+  public static AllowableActions convertAllowableActions(Session session,
+      AllowableActionsData allowableActions) {
+    if ((allowableActions == null) || (allowableActions.getAllowableActions() == null)) {
+      throw new IllegalArgumentException("Allowable actions must be set!");
+    }
+
+    return session.getObjectFactory().createAllowableAction(allowableActions.getAllowableActions());
+  }
+
+  /**
+   * Converts ACL.
+   */
+  public static AccessControlList convertAces(Session session, List<Ace> aces) {
+    if (aces == null) {
+      throw new IllegalArgumentException("ACEs must be set!");
+    }
+
+    ProviderObjectFactory pof = session.getProvider().getObjectFactory();
+
+    List<AccessControlEntry> providerAces = new ArrayList<AccessControlEntry>();
+    for (Ace ace : aces) {
+      providerAces.add(pof.createAccessControlEntry(ace.getPrincipalId(), ace.getPermissions()));
+    }
+
+    return pof.createAccessControlList(providerAces);
+  }
+
+  /**
+   * Converts ACL.
+   */
+  public static Acl convertAcl(Session session, AccessControlList acl) {
+    if (acl == null) {
+      throw new IllegalArgumentException("ACL must be set!");
+    }
+
+    ObjectFactory of = session.getObjectFactory();
+    List<Ace> aces = new ArrayList<Ace>();
+    if (acl.getAces() != null) {
+      for (AccessControlEntry ace : acl.getAces()) {
+        if (ace.getPrincipal() == null) {
+          continue;
+        }
+        aces.add(of.createAce(ace.getPrincipal().getPrincipalId(), ace.getPermissions(), ace
+            .isDirect()));
+      }
+    }
+
+    return of.createAcl(aces, acl.isExact());
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message