You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/04/22 18:28:00 UTC
svn commit: r936938 [20/29] - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/
chemistry-opencmis-server-bindings/src/main/java/org/apache/chem...
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java Thu Apr 22 16:27:57 2010
@@ -36,82 +36,82 @@ import org.apache.chemistry.opencmis.inm
public class InMemoryDocumentTypeDefinition extends DocumentTypeDefinitionImpl {
- private static final long serialVersionUID = 1L;
- private static InMemoryDocumentTypeDefinition DOCUMENT_TYPE = new InMemoryDocumentTypeDefinition();
+ private static final long serialVersionUID = 1L;
+ private static InMemoryDocumentTypeDefinition DOCUMENT_TYPE = new InMemoryDocumentTypeDefinition();
- public static InMemoryDocumentTypeDefinition getRootDocumentType() {
- return DOCUMENT_TYPE;
- }
-
- /* This constructor is just for creating the root document */
- public InMemoryDocumentTypeDefinition() {
- init(BaseTypeId.CMIS_DOCUMENT.value(), "CMIS Document");
- setParentTypeId(null);
- // set base properties
- Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
- DocumentTypeCreationHelper.setBasicDocumentPropertyDefinitions(props);
- }
-
- public InMemoryDocumentTypeDefinition(String id, String displayName) {
- init(id, displayName);
- setParentTypeId(DOCUMENT_TYPE.getId());
- }
-
- public InMemoryDocumentTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
- // get root type
- init(id, displayName);
- if (parentType != null)
- setBaseTypeId(parentType.getBaseTypeId());
- else
- throw new IllegalArgumentException("Must provide a parent type when creating a document type definition");
- setParentTypeId(parentType.getId());
- }
-
- /*
- * Set the property definitions for this type. The parameter
- * propertyDefinitions should only contain the custom property definitions
- * for this type. The standard property definitions are added automatically.
- *
- * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
- * setPropertyDefinitions(java.util.Map)
- */
- public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
- DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
- }
-
- // public void setProperties() {
- // Map<String, PropertyDefinition<?>> propertyDefinitions = new
- // HashMap<String, PropertyDefinition<?>>();
- // this.setPropertyDefinitions(propertyDefinitions);
- // }
-
- private void init(String id, String displayName) {
- if (!NameValidator.isValidId(id))
- throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_ID);
-
- setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
- setId(id);
- if (displayName == null)
- displayName = '#' + id + '#';
- setDisplayName(displayName);
- // create some suitable defaults for convenience
- setDescription("Description of " + getDisplayName() + " Type");
- setLocalName(id);
- setLocalNamespace("local");
- setQueryName(id);
- setIsControllableAcl(false);
- setIsControllablePolicy(false);
- setIsCreatable(true);
- setIsFileable(true);
- setIsFulltextIndexed(false);
- setIsIncludedInSupertypeQuery(true);
- setIsQueryable(false);
-
- Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
- setPropertyDefinitions(props); // set initial empty set of properties
-
- // document specifics:
- setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
- setIsVersionable(false);
- }
+ public static InMemoryDocumentTypeDefinition getRootDocumentType() {
+ return DOCUMENT_TYPE;
+ }
+
+ /* This constructor is just for creating the root document */
+ public InMemoryDocumentTypeDefinition() {
+ init(BaseTypeId.CMIS_DOCUMENT.value(), "CMIS Document");
+ setParentTypeId(null);
+ // set base properties
+ Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+ DocumentTypeCreationHelper.setBasicDocumentPropertyDefinitions(props);
+ }
+
+ public InMemoryDocumentTypeDefinition(String id, String displayName) {
+ init(id, displayName);
+ setParentTypeId(DOCUMENT_TYPE.getId());
+ }
+
+ public InMemoryDocumentTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
+ // get root type
+ init(id, displayName);
+ if (parentType != null)
+ setBaseTypeId(parentType.getBaseTypeId());
+ else
+ throw new IllegalArgumentException("Must provide a parent type when creating a document type definition");
+ setParentTypeId(parentType.getId());
+ }
+
+ /*
+ * Set the property definitions for this type. The parameter
+ * propertyDefinitions should only contain the custom property definitions
+ * for this type. The standard property definitions are added automatically.
+ *
+ * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+ * setPropertyDefinitions(java.util.Map)
+ */
+ public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+ DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+ }
+
+ // public void setProperties() {
+ // Map<String, PropertyDefinition<?>> propertyDefinitions = new
+ // HashMap<String, PropertyDefinition<?>>();
+ // this.setPropertyDefinitions(propertyDefinitions);
+ // }
+
+ private void init(String id, String displayName) {
+ if (!NameValidator.isValidId(id))
+ throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_ID);
+
+ setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
+ setId(id);
+ if (displayName == null)
+ displayName = '#' + id + '#';
+ setDisplayName(displayName);
+ // create some suitable defaults for convenience
+ setDescription("Description of " + getDisplayName() + " Type");
+ setLocalName(id);
+ setLocalNamespace("local");
+ setQueryName(id);
+ setIsControllableAcl(false);
+ setIsControllablePolicy(false);
+ setIsCreatable(true);
+ setIsFileable(true);
+ setIsFulltextIndexed(false);
+ setIsIncludedInSupertypeQuery(true);
+ setIsQueryable(false);
+
+ Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+ setPropertyDefinitions(props); // set initial empty set of properties
+
+ // document specifics:
+ setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+ setIsVersionable(false);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java Thu Apr 22 16:27:57 2010
@@ -30,72 +30,72 @@ import org.apache.chemistry.opencmis.inm
public class InMemoryFolderTypeDefinition extends FolderTypeDefinitionImpl {
- private static final long serialVersionUID = 1L;
- private static InMemoryFolderTypeDefinition FOLDER_TYPE = new InMemoryFolderTypeDefinition();
+ private static final long serialVersionUID = 1L;
+ private static InMemoryFolderTypeDefinition FOLDER_TYPE = new InMemoryFolderTypeDefinition();
- public static InMemoryFolderTypeDefinition getRootFolderType() {
- return FOLDER_TYPE;
- }
-
- /* This constructor is just for creating the root document */
- public InMemoryFolderTypeDefinition() {
- init(BaseTypeId.CMIS_FOLDER.value(), "CMIS Folder");
- setParentTypeId(null);
- // set base properties
- Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
- DocumentTypeCreationHelper.setBasicFolderPropertyDefinitions(props);
- }
-
- public InMemoryFolderTypeDefinition(String id, String displayName) {
- init(id, displayName);
- setParentTypeId(FOLDER_TYPE.getId());
- }
-
- public InMemoryFolderTypeDefinition(String id, String displayName, InMemoryFolderTypeDefinition parentType) {
- // get root type
- init(id, displayName);
- if (parentType != null)
- setBaseTypeId(parentType.getBaseTypeId());
- else
- throw new IllegalArgumentException("Must provide a parent type when creating a folder type definition");
- setParentTypeId(parentType.getId());
- }
-
- /*
- * Set the property definitions for this type. The parameter
- * propertyDefinitions should only contain the custom property definitions
- * for this type. The standard property definitions are added automatically.
- *
- * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
- * setPropertyDefinitions(java.util.Map)
- */
- public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
- DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
- }
-
- private void init(String id, String displayName) {
- if (!NameValidator.isValidId(id))
- throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
- setBaseTypeId(BaseTypeId.CMIS_FOLDER);
- setId(id);
- if (displayName == null)
- displayName = '#' + id + '#';
- setDisplayName(displayName);
- // create some suitable defaults for convenience
- setDescription("Description of " + getDisplayName() + " Type");
- setLocalName(id);
- setLocalNamespace("local");
- setQueryName(id);
- setIsControllableAcl(false);
- setIsControllablePolicy(false);
- setIsCreatable(true);
- setIsFileable(true);
- setIsFulltextIndexed(false);
- setIsIncludedInSupertypeQuery(true);
- setIsQueryable(false);
-
- Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
- setPropertyDefinitions(props); // set initial empty set of properties
- }
+ public static InMemoryFolderTypeDefinition getRootFolderType() {
+ return FOLDER_TYPE;
+ }
+
+ /* This constructor is just for creating the root document */
+ public InMemoryFolderTypeDefinition() {
+ init(BaseTypeId.CMIS_FOLDER.value(), "CMIS Folder");
+ setParentTypeId(null);
+ // set base properties
+ Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+ DocumentTypeCreationHelper.setBasicFolderPropertyDefinitions(props);
+ }
+
+ public InMemoryFolderTypeDefinition(String id, String displayName) {
+ init(id, displayName);
+ setParentTypeId(FOLDER_TYPE.getId());
+ }
+
+ public InMemoryFolderTypeDefinition(String id, String displayName, InMemoryFolderTypeDefinition parentType) {
+ // get root type
+ init(id, displayName);
+ if (parentType != null)
+ setBaseTypeId(parentType.getBaseTypeId());
+ else
+ throw new IllegalArgumentException("Must provide a parent type when creating a folder type definition");
+ setParentTypeId(parentType.getId());
+ }
+
+ /*
+ * Set the property definitions for this type. The parameter
+ * propertyDefinitions should only contain the custom property definitions
+ * for this type. The standard property definitions are added automatically.
+ *
+ * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+ * setPropertyDefinitions(java.util.Map)
+ */
+ public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+ DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+ }
+
+ private void init(String id, String displayName) {
+ if (!NameValidator.isValidId(id))
+ throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+ setBaseTypeId(BaseTypeId.CMIS_FOLDER);
+ setId(id);
+ if (displayName == null)
+ displayName = '#' + id + '#';
+ setDisplayName(displayName);
+ // create some suitable defaults for convenience
+ setDescription("Description of " + getDisplayName() + " Type");
+ setLocalName(id);
+ setLocalNamespace("local");
+ setQueryName(id);
+ setIsControllableAcl(false);
+ setIsControllablePolicy(false);
+ setIsCreatable(true);
+ setIsFileable(true);
+ setIsFulltextIndexed(false);
+ setIsIncludedInSupertypeQuery(true);
+ setIsQueryable(false);
+
+ Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+ setPropertyDefinitions(props); // set initial empty set of properties
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java Thu Apr 22 16:27:57 2010
@@ -30,75 +30,75 @@ import org.apache.chemistry.opencmis.inm
public class InMemoryPolicyTypeDefinition extends PolicyTypeDefinitionImpl {
- private static final long serialVersionUID = 1L;
- private static InMemoryPolicyTypeDefinition POLICY_TYPE = new InMemoryPolicyTypeDefinition();
+ private static final long serialVersionUID = 1L;
+ private static InMemoryPolicyTypeDefinition POLICY_TYPE = new InMemoryPolicyTypeDefinition();
- public static InMemoryPolicyTypeDefinition getRootPolicyType() {
- return POLICY_TYPE;
- }
-
- /* This constructor is just for creating the root document */
- public InMemoryPolicyTypeDefinition() {
- init(BaseTypeId.CMIS_POLICY.value(), "CMIS Policy");
- setParentTypeId(null);
-
- Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
- DocumentTypeCreationHelper.setBasicPolicyPropertyDefinitions(props);
- }
-
- public InMemoryPolicyTypeDefinition(String id, String displayName) {
- init(id, displayName);
- setParentTypeId(POLICY_TYPE.getId());
- }
-
- public InMemoryPolicyTypeDefinition(String id, String displayName, InMemoryPolicyTypeDefinition parentType) {
- // get root type
- init(id, displayName);
- if (parentType != null)
- setBaseTypeId(parentType.getBaseTypeId());
- else
- throw new IllegalArgumentException("Must provide a parent type when creating a policy definition");
- setParentTypeId(parentType.getId());
- }
-
- /*
- * Set the property definitions for this type. The parameter
- * propertyDefinitions should only contain the custom property definitions
- * for this type. The standard property definitions are added automatically.
- *
- * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
- * setPropertyDefinitions(java.util.Map)
- */
- public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
- DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
- }
-
- private void init(String id, String displayName) {
- if (!NameValidator.isValidId(id))
- throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
- setBaseTypeId(BaseTypeId.CMIS_POLICY);
- setId(id);
- if (displayName == null)
- displayName = '#' + id + '#';
- setDisplayName(displayName);
- // create some suitable defaults for convenience
- setDescription("Description of " + getDisplayName() + " Type");
- setLocalName(id);
- setLocalNamespace("local");
- setQueryName(id);
- setIsControllableAcl(false);
- setIsControllablePolicy(false);
- setIsCreatable(true);
- setIsFileable(true);
- setIsFulltextIndexed(false);
- setIsIncludedInSupertypeQuery(true);
- setIsQueryable(false);
-
- // set base properties
- Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
- setPropertyDefinitions(props); // set initial empty set of properties
+ public static InMemoryPolicyTypeDefinition getRootPolicyType() {
+ return POLICY_TYPE;
+ }
+
+ /* This constructor is just for creating the root document */
+ public InMemoryPolicyTypeDefinition() {
+ init(BaseTypeId.CMIS_POLICY.value(), "CMIS Policy");
+ setParentTypeId(null);
+
+ Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+ DocumentTypeCreationHelper.setBasicPolicyPropertyDefinitions(props);
+ }
+
+ public InMemoryPolicyTypeDefinition(String id, String displayName) {
+ init(id, displayName);
+ setParentTypeId(POLICY_TYPE.getId());
+ }
+
+ public InMemoryPolicyTypeDefinition(String id, String displayName, InMemoryPolicyTypeDefinition parentType) {
+ // get root type
+ init(id, displayName);
+ if (parentType != null)
+ setBaseTypeId(parentType.getBaseTypeId());
+ else
+ throw new IllegalArgumentException("Must provide a parent type when creating a policy definition");
+ setParentTypeId(parentType.getId());
+ }
+
+ /*
+ * Set the property definitions for this type. The parameter
+ * propertyDefinitions should only contain the custom property definitions
+ * for this type. The standard property definitions are added automatically.
+ *
+ * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+ * setPropertyDefinitions(java.util.Map)
+ */
+ public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+ DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+ }
+
+ private void init(String id, String displayName) {
+ if (!NameValidator.isValidId(id))
+ throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+ setBaseTypeId(BaseTypeId.CMIS_POLICY);
+ setId(id);
+ if (displayName == null)
+ displayName = '#' + id + '#';
+ setDisplayName(displayName);
+ // create some suitable defaults for convenience
+ setDescription("Description of " + getDisplayName() + " Type");
+ setLocalName(id);
+ setLocalNamespace("local");
+ setQueryName(id);
+ setIsControllableAcl(false);
+ setIsControllablePolicy(false);
+ setIsCreatable(true);
+ setIsFileable(true);
+ setIsFulltextIndexed(false);
+ setIsIncludedInSupertypeQuery(true);
+ setIsQueryable(false);
+
+ // set base properties
+ Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+ setPropertyDefinitions(props); // set initial empty set of properties
- // policy specifics: none
- }
+ // policy specifics: none
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java Thu Apr 22 16:27:57 2010
@@ -30,79 +30,79 @@ import org.apache.chemistry.opencmis.inm
public class InMemoryRelationshipTypeDefinition extends RelationshipTypeDefinitionImpl {
- private static final long serialVersionUID = 1L;
- private static InMemoryRelationshipTypeDefinition RELATIONSHIP_TYPE = new InMemoryRelationshipTypeDefinition();
+ private static final long serialVersionUID = 1L;
+ private static InMemoryRelationshipTypeDefinition RELATIONSHIP_TYPE = new InMemoryRelationshipTypeDefinition();
- public static InMemoryRelationshipTypeDefinition getRootRelationshipType() {
- return RELATIONSHIP_TYPE;
- }
-
- /* This constructor is just for creating the root document */
- public InMemoryRelationshipTypeDefinition() {
- init(BaseTypeId.CMIS_RELATIONSHIP.value(), "CMIS Relation");
- setParentTypeId(null);
-
- Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
- DocumentTypeCreationHelper.setBasicRelationshipPropertyDefinitions(props);
- }
-
- public InMemoryRelationshipTypeDefinition(String id, String displayName) {
- init(id, displayName);
- setParentTypeId(RELATIONSHIP_TYPE.getId());
- }
-
- public InMemoryRelationshipTypeDefinition(String id, String displayName,
- InMemoryRelationshipTypeDefinition parentType) {
- // get root type
- init(id, displayName);
- if (parentType != null)
- setBaseTypeId(parentType.getBaseTypeId());
- else
- throw new IllegalArgumentException("Must provide a parent type when creating a relationship definition");
- setParentTypeId(parentType.getId());
- }
-
- /*
- * Set the property definitions for this type. The parameter
- * propertyDefinitions should only contain the custom property definitions
- * for this type. The standard property definitions are added automatically.
- *
- * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
- * setPropertyDefinitions(java.util.Map)
- */
- public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
- DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
- }
-
- private void init(String id, String displayName) {
- if (!NameValidator.isValidId(id))
- throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
- setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
- setId(id);
- if (displayName == null)
- displayName = '#' + id + '#';
- setDisplayName(displayName);
- // create some suitable defaults for convenience
- setDescription("Description of " + getDisplayName() + " Type");
- setLocalName(id);
- setLocalNamespace("local");
- setQueryName(id);
- setIsControllableAcl(false);
- setIsControllablePolicy(false);
- setIsCreatable(true);
- setIsFileable(true);
- setIsFulltextIndexed(false);
- setIsIncludedInSupertypeQuery(true);
- setIsQueryable(false);
-
- // relationship specifics
- setAllowedSourceTypes(null);
- setAllowedTargetTypes(null);
-
- // set base properties
- Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
- setPropertyDefinitions(props); // set initial empty set of properties
- }
+ public static InMemoryRelationshipTypeDefinition getRootRelationshipType() {
+ return RELATIONSHIP_TYPE;
+ }
+
+ /* This constructor is just for creating the root document */
+ public InMemoryRelationshipTypeDefinition() {
+ init(BaseTypeId.CMIS_RELATIONSHIP.value(), "CMIS Relation");
+ setParentTypeId(null);
+
+ Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+ DocumentTypeCreationHelper.setBasicRelationshipPropertyDefinitions(props);
+ }
+
+ public InMemoryRelationshipTypeDefinition(String id, String displayName) {
+ init(id, displayName);
+ setParentTypeId(RELATIONSHIP_TYPE.getId());
+ }
+
+ public InMemoryRelationshipTypeDefinition(String id, String displayName,
+ InMemoryRelationshipTypeDefinition parentType) {
+ // get root type
+ init(id, displayName);
+ if (parentType != null)
+ setBaseTypeId(parentType.getBaseTypeId());
+ else
+ throw new IllegalArgumentException("Must provide a parent type when creating a relationship definition");
+ setParentTypeId(parentType.getId());
+ }
+
+ /*
+ * Set the property definitions for this type. The parameter
+ * propertyDefinitions should only contain the custom property definitions
+ * for this type. The standard property definitions are added automatically.
+ *
+ * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+ * setPropertyDefinitions(java.util.Map)
+ */
+ public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+ DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+ }
+
+ private void init(String id, String displayName) {
+ if (!NameValidator.isValidId(id))
+ throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+ setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
+ setId(id);
+ if (displayName == null)
+ displayName = '#' + id + '#';
+ setDisplayName(displayName);
+ // create some suitable defaults for convenience
+ setDescription("Description of " + getDisplayName() + " Type");
+ setLocalName(id);
+ setLocalNamespace("local");
+ setQueryName(id);
+ setIsControllableAcl(false);
+ setIsControllablePolicy(false);
+ setIsCreatable(true);
+ setIsFileable(true);
+ setIsFulltextIndexed(false);
+ setIsIncludedInSupertypeQuery(true);
+ setIsQueryable(false);
+
+ // relationship specifics
+ setAllowedSourceTypes(null);
+ setAllowedTargetTypes(null);
+
+ // set base properties
+ Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+ setPropertyDefinitions(props); // set initial empty set of properties
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Thu Apr 22 16:27:57 2010
@@ -66,208 +66,208 @@ import org.apache.commons.logging.LogFac
*/
public class PropertyCreationHelper {
- private static Log log = LogFactory.getLog(PropertyCreationHelper.class);
+ private static Log log = LogFactory.getLog(PropertyCreationHelper.class);
- public static PropertyBooleanDefinitionImpl createBooleanDefinition(String id, String displayName) {
- PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyBooleanDefinitionImpl createBooleanMultiDefinition(String id, String displayName) {
- PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyDateTimeDefinitionImpl createDateTimeDefinition(String id, String displayName) {
- PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyDateTimeDefinitionImpl createDateTimeMultiDefinition(String id, String displayName) {
- PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyDecimalDefinitionImpl createDecimalDefinition(String id, String displayName) {
- PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyDecimalDefinitionImpl createDecimalMultiDefinition(String id, String displayName) {
- PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyHtmlDefinitionImpl createHtmlDefinition(String id, String displayName) {
- PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyHtmlDefinitionImpl createHtmlMultiDefinition(String id, String displayName) {
- PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyIdDefinitionImpl createIdDefinition(String id, String displayName) {
- PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyIdDefinitionImpl createIdMultiDefinition(String id, String displayName) {
- PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyIntegerDefinitionImpl createIntegerDefinition(String id, String displayName) {
- PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyIntegerDefinitionImpl createIntegerMultiDefinition(String id, String displayName) {
- PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyStringDefinitionImpl createStringDefinition(String id, String displayName) {
- PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyStringDefinitionImpl createStringMultiDefinition(String id, String displayName) {
- PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static PropertyUriDefinitionImpl createUriDefinition(String id, String displayName) {
- PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.SINGLE);
- return prop;
- }
-
- public static PropertyUriDefinitionImpl createUriMultiDefinition(String id, String displayName) {
- PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
- createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.MULTI);
- return prop;
- }
-
- public static <T> void addElemToPicklist(AbstractPropertyDefinition<T> prop, T value) {
- List<Choice<T>> choiceList = prop.getChoices();
- if (choiceList == null)
- choiceList = new ArrayList<Choice<T>>();
-
- ChoiceImpl<T> elem = new ChoiceImpl<T>();
- elem.setValue(Collections.singletonList(value));
- choiceList.add(elem);
- }
-
- public static <T> void setDefaultValue(AbstractPropertyDefinition<T> prop, T defVal) {
- prop.setDefaultValue(Collections.singletonList(defVal));
- }
-
- // internal helpers
- private static void createStandardDefinition(AbstractPropertyDefinition<?> prop, String id, PropertyType propType,
- String displayName, Cardinality card) {
-
- if (!NameValidator.isValidId(id))
- if (!NameValidator.isValidId(id))
- throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
- prop.setId(id);
- if (displayName == null)
- prop.setDisplayName("Sample " + prop.getId() + " boolean property");
- else
- prop.setDisplayName(displayName);
- prop.setLocalName(id);
- prop.setLocalNamespace("local");
- prop.setQueryName(id);
- prop.setIsInherited(false);
- prop.setCardinality(card);
- prop.setIsOpenChoice(false);
- prop.setIsQueryable(true);
- prop.setIsRequired(false);
- prop.setPropertyType(propType);
- prop.setUpdatability(Updatability.READWRITE);
- }
-
- public static Properties getPropertiesFromObject(String repositoryId, StoredObject so, StoreManager storeManager,
- List<String> requestedIds) {
- // build properties collection
-
- BindingsObjectFactory objectFactory = storeManager.getObjectFactory();
- Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
- so.fillProperties(properties, objectFactory, requestedIds);
-
- String typeId = so.getTypeId();
- // (String) props.getProperties().get(PropertyIds.CMIS_OBJECT_TYPE_ID).
- // getFirstValue();
- if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, requestedIds)) {
- TypeDefinitionContainer typeDefC = storeManager.getTypeById(repositoryId, typeId);
- if (typeDefC == null) {
- log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
- + " is unknown");
- } else {
- TypeDefinition typeDef = typeDefC.getTypeDefinition();
- String baseTypeId = typeDef.getBaseTypeId().value();
- properties.put(PropertyIds.BASE_TYPE_ID, objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID,
- baseTypeId));
- }
- }
- List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>>(properties.values());
- Properties props = objectFactory.createPropertiesData(propertiesList);
- return props;
- }
-
- public static ObjectData getObjectData(StoreManager sm, StoredObject so, String filter, String user,
- Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
- Boolean includePolicyIds, Boolean includeACL, ExtensionsData extension) {
-
- ObjectDataImpl od = new ObjectDataImpl();
-
- if (so == null)
- throw new CmisObjectNotFoundException("Illegal object id: null");
-
- // build properties collection
- List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
- Properties props = getPropertiesFromObject(so.getRepositoryId(), so, sm, requestedIds);
-
- // fill output object
- if (null != includeAllowableActions && includeAllowableActions) {
- ObjectStore objectStore = sm.getObjectStore(so.getRepositoryId());
- AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(objectStore, so, user);
- od.setAllowableActions(allowableActions);
- }
- if (null != includeACL && includeACL)
- od.setAcl(null);
- od.setIsExactAcl(true);
-
- if (null != includePolicyIds && includePolicyIds)
- od.setPolicyIds(DataObjectCreator.fillPolicyIds(so));
-
- if (null != includeRelationships && includeRelationships != IncludeRelationships.NONE)
- od.setRelationships(DataObjectCreator.fillRelationships(includeRelationships, so));
-
- if (renditionFilter != null && renditionFilter.length() > 0)
- od.setRenditions(DataObjectCreator.fillRenditions(so));
-
- od.setProperties(props);
-
- // Note: do not set change event info for this call
- log.debug("stop getObject()");
- return od;
- }
+ public static PropertyBooleanDefinitionImpl createBooleanDefinition(String id, String displayName) {
+ PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyBooleanDefinitionImpl createBooleanMultiDefinition(String id, String displayName) {
+ PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyDateTimeDefinitionImpl createDateTimeDefinition(String id, String displayName) {
+ PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyDateTimeDefinitionImpl createDateTimeMultiDefinition(String id, String displayName) {
+ PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyDecimalDefinitionImpl createDecimalDefinition(String id, String displayName) {
+ PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyDecimalDefinitionImpl createDecimalMultiDefinition(String id, String displayName) {
+ PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyHtmlDefinitionImpl createHtmlDefinition(String id, String displayName) {
+ PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyHtmlDefinitionImpl createHtmlMultiDefinition(String id, String displayName) {
+ PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyIdDefinitionImpl createIdDefinition(String id, String displayName) {
+ PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyIdDefinitionImpl createIdMultiDefinition(String id, String displayName) {
+ PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyIntegerDefinitionImpl createIntegerDefinition(String id, String displayName) {
+ PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyIntegerDefinitionImpl createIntegerMultiDefinition(String id, String displayName) {
+ PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyStringDefinitionImpl createStringDefinition(String id, String displayName) {
+ PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyStringDefinitionImpl createStringMultiDefinition(String id, String displayName) {
+ PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static PropertyUriDefinitionImpl createUriDefinition(String id, String displayName) {
+ PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.SINGLE);
+ return prop;
+ }
+
+ public static PropertyUriDefinitionImpl createUriMultiDefinition(String id, String displayName) {
+ PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
+ createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.MULTI);
+ return prop;
+ }
+
+ public static <T> void addElemToPicklist(AbstractPropertyDefinition<T> prop, T value) {
+ List<Choice<T>> choiceList = prop.getChoices();
+ if (choiceList == null)
+ choiceList = new ArrayList<Choice<T>>();
+
+ ChoiceImpl<T> elem = new ChoiceImpl<T>();
+ elem.setValue(Collections.singletonList(value));
+ choiceList.add(elem);
+ }
+
+ public static <T> void setDefaultValue(AbstractPropertyDefinition<T> prop, T defVal) {
+ prop.setDefaultValue(Collections.singletonList(defVal));
+ }
+
+ // internal helpers
+ private static void createStandardDefinition(AbstractPropertyDefinition<?> prop, String id, PropertyType propType,
+ String displayName, Cardinality card) {
+
+ if (!NameValidator.isValidId(id))
+ if (!NameValidator.isValidId(id))
+ throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+ prop.setId(id);
+ if (displayName == null)
+ prop.setDisplayName("Sample " + prop.getId() + " boolean property");
+ else
+ prop.setDisplayName(displayName);
+ prop.setLocalName(id);
+ prop.setLocalNamespace("local");
+ prop.setQueryName(id);
+ prop.setIsInherited(false);
+ prop.setCardinality(card);
+ prop.setIsOpenChoice(false);
+ prop.setIsQueryable(true);
+ prop.setIsRequired(false);
+ prop.setPropertyType(propType);
+ prop.setUpdatability(Updatability.READWRITE);
+ }
+
+ public static Properties getPropertiesFromObject(String repositoryId, StoredObject so, StoreManager storeManager,
+ List<String> requestedIds) {
+ // build properties collection
+
+ BindingsObjectFactory objectFactory = storeManager.getObjectFactory();
+ Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
+ so.fillProperties(properties, objectFactory, requestedIds);
+
+ String typeId = so.getTypeId();
+ // (String) props.getProperties().get(PropertyIds.CMIS_OBJECT_TYPE_ID).
+ // getFirstValue();
+ if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, requestedIds)) {
+ TypeDefinitionContainer typeDefC = storeManager.getTypeById(repositoryId, typeId);
+ if (typeDefC == null) {
+ log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
+ + " is unknown");
+ } else {
+ TypeDefinition typeDef = typeDefC.getTypeDefinition();
+ String baseTypeId = typeDef.getBaseTypeId().value();
+ properties.put(PropertyIds.BASE_TYPE_ID, objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID,
+ baseTypeId));
+ }
+ }
+ List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>>(properties.values());
+ Properties props = objectFactory.createPropertiesData(propertiesList);
+ return props;
+ }
+
+ public static ObjectData getObjectData(StoreManager sm, StoredObject so, String filter, String user,
+ Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+ Boolean includePolicyIds, Boolean includeACL, ExtensionsData extension) {
+
+ ObjectDataImpl od = new ObjectDataImpl();
+
+ if (so == null)
+ throw new CmisObjectNotFoundException("Illegal object id: null");
+
+ // build properties collection
+ List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+ Properties props = getPropertiesFromObject(so.getRepositoryId(), so, sm, requestedIds);
+
+ // fill output object
+ if (null != includeAllowableActions && includeAllowableActions) {
+ ObjectStore objectStore = sm.getObjectStore(so.getRepositoryId());
+ AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(objectStore, so, user);
+ od.setAllowableActions(allowableActions);
+ }
+ if (null != includeACL && includeACL)
+ od.setAcl(null);
+ od.setIsExactAcl(true);
+
+ if (null != includePolicyIds && includePolicyIds)
+ od.setPolicyIds(DataObjectCreator.fillPolicyIds(so));
+
+ if (null != includeRelationships && includeRelationships != IncludeRelationships.NONE)
+ od.setRelationships(DataObjectCreator.fillRelationships(includeRelationships, so));
+
+ if (renditionFilter != null && renditionFilter.length() > 0)
+ od.setRenditions(DataObjectCreator.fillRenditions(so));
+
+ od.setProperties(props);
+
+ // Note: do not set change event info for this call
+ log.debug("stop getObject()");
+ return od;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java Thu Apr 22 16:27:57 2010
@@ -44,337 +44,339 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class AbstractServiceTst /* extends TestCase */{
- private static Log LOG = LogFactory.getLog(AbstractServiceTst.class);
- protected static final String REPOSITORY_ID = "UnitTestRepository";
- protected BindingsObjectFactory fFactory = new BindingsObjectFactoryImpl();
- protected String fRootFolderId;
- protected String fRepositoryId;
- protected ObjectService fObjSvc;
- protected NavigationService fNavSvc;
- protected RepositoryService fRepSvc;
- protected VersioningService fVerSvc;
- protected MultiFilingService fMultiSvc;
- protected DummyCallContext fTestCallContext;
- private String fTypeCreatorClassName;
- protected boolean fUseClientProviderInterface;
-
- public AbstractServiceTst() {
- // The in-memory server unit tests can either be run directly against the
- // service implementation or against a clocal binding interface. The local
- // binding interfaces offers some benefits like type system caching etc.
- // The default is using the direct implementation. Subclasses may
- // override this behavior.
-
- fUseClientProviderInterface = true;
-
- // Init with default types, can be overridden by subclasses:
- fTypeCreatorClassName = UnitTestTypeSystemCreator.class.getName();
- }
-
- // Subclasses may want to use their own types
- protected void setTypeCreatorClass(String typeCreatorClassName) {
- fTypeCreatorClassName = typeCreatorClassName;
- }
-
- protected void setUp() throws Exception {
- // super.setUp();
- LOG.debug("Initializing InMemory Test with type creator class: " + fTypeCreatorClassName);
- Map<String, String> parameters = new HashMap<String, String>();
-
- // attach repository info to the session:
- parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, fTypeCreatorClassName);
- parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-
- // attach repository info to the session:
- parameters.put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
-
- // give subclasses a chance to provide additional parameters for special
- // tests
- addParameters(parameters);
-
- fTestCallContext = new DummyCallContext();
- // Attach a standatrd CallContext to a thread before the services are
- // initialized.
-// RuntimeContext.attachCfg(fTestCallContext);
-
- if (fUseClientProviderInterface)
- initializeUsingLocalBinding(parameters);
- else
- initializeDirect(parameters);
-
- assertNotNull(fRepSvc);
- assertNotNull(fObjSvc);
- assertNotNull(fNavSvc);
-
- RepositoryInfo rep = fRepSvc.getRepositoryInfo(REPOSITORY_ID, null);
- fRootFolderId = rep.getRootFolderId();
- fRepositoryId = rep.getId();
-
- assertNotNull(fRepositoryId);
- assertNotNull(fRootFolderId);
- }
-
- // Override this method in subclasses if you want to provide additional
- // configuration
- // parameters. Default implementation is empty
- protected void addParameters(Map<String, String> parameters) {
- }
-
- protected void tearDown() throws Exception {
- // super.tearDown();
- }
-
- public void testDummy() {
- // dummy test to make tools happy that complain if there are no tests
- // available in a test class
- }
-
- protected String createFolder(String folderName, String parentFolderId, String typeId) {
- Properties props = createFolderProperties(folderName, typeId);
- String id = null;
- try {
- id = fObjSvc.createFolder(fRepositoryId, props, parentFolderId, null, null, null, null);
- if (null == id)
- fail("createFolder failed.");
- } catch (Exception e) {
- fail("createFolder() failed with exception: " + e);
- }
- return id;
- }
-
- protected String createDocument(String name, String folderId, String typeId, VersioningState versioningState,
- boolean withContent) {
- ContentStream contentStream = null;
- List<String> policies = null;
- Acl addACEs = null;
- Acl removeACEs = null;
- ExtensionsData extension = null;
-
- Properties props = createDocumentProperties(name, typeId);
-
- if (withContent)
- contentStream = createContent();
-
- String id = null;
- try {
- id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState, policies,
- addACEs, removeACEs, extension);
- if (null == id)
- fail("createDocument failed.");
- } catch (Exception e) {
- fail("createDocument() failed with exception: " + e);
- }
- return id;
-
- }
-
- protected String createDocument(String name, String folderId, String typeId, boolean withContent) {
- VersioningState versioningState = VersioningState.NONE;
- return createDocument(name, folderId, typeId, versioningState, withContent);
- }
-
- protected Properties createDocumentProperties(String name, String typeId) {
- List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
- properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, name));
- properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
- Properties props = fFactory.createPropertiesData(properties);
- return props;
- }
-
- protected Properties createFolderProperties(String folderName, String typeId) {
- List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
- properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, folderName));
- properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
- Properties props = fFactory.createPropertiesData(properties);
- return props;
- }
-
- protected ContentStream createContent() {
- ContentStreamDataImpl content = new ContentStreamDataImpl();
- content.setFileName("data.txt");
- content.setMimeType("text/plain");
- int len = 32 * 1024;
- byte[] b = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,
- 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a }; // 32
- // Bytes
- ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
- try {
- for (int i = 0; i < 1024; i++)
- ba.write(b);
- content.setContent(new ByteArrayInputStream(ba.toByteArray()));
- } catch (IOException e) {
- throw new RuntimeException("Failed to fill content stream with data", e);
- }
- return content;
- }
-
- protected ContentStream createContent(char ch) {
- ContentStreamDataImpl content = new ContentStreamDataImpl();
- content.setFileName("data.txt");
- content.setMimeType("text/plain");
- int len = 32 * 1024;
- byte[] b = new byte[32];
- for (int i = 0; i < 32; i++)
- b[i] = (byte) Character.getNumericValue(ch);
- ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
- try {
- for (int i = 0; i < 1024; i++)
- ba.write(b);
- content.setContent(new ByteArrayInputStream(ba.toByteArray()));
- } catch (IOException e) {
- throw new RuntimeException("Failed to fill content stream with data", e);
- }
- return content;
- }
-
- protected void verifyContentResult(ContentStream sd) {
- assertEquals("text/plain", sd.getMimeType());
- assertEquals("data.txt", sd.getFileName());
- assertEquals(32 * 1024, sd.getBigLength().longValue());
- byte[] ba = new byte[32];
- InputStream is = sd.getStream();
- int counter = 0;
- try {
- while (is.read(ba) == ba.length) {
- ++counter;
- assertEquals(0x61, ba[0]);
- assertEquals(0x6e, ba[29]);
- assertEquals(0x0c, ba[30]);
- assertEquals(0x0a, ba[31]);
- }
- } catch (IOException e) {
- fail("reading from content stream failed");
- }
- assertEquals(1024, counter);
- }
-
- protected String getByPath(String id, String path) {
- ObjectData res = null;
- try {
- res = fObjSvc.getObjectByPath(fRepositoryId, path, "*", false, IncludeRelationships.NONE, null, false,
- false, null);
- assertNotNull(res);
- assertEquals(id, res.getId());
- } catch (Exception e) {
- fail("getObject() failed with exception: " + e);
- }
- return res.getId();
- }
-
- @SuppressWarnings("unchecked")
- protected String getPathOfFolder(String id) {
- String path = null;
- try {
- String filter = PropertyIds.PATH;
- Properties res = fObjSvc.getProperties(fRepositoryId, id, filter, null);
- assertNotNull(res);
- PropertyData<String> pd = (PropertyData<String>) res.getProperties().get(PropertyIds.PATH);
- assertNotNull(pd);
- path = pd.getFirstValue();
- assertNotNull(path);
- } catch (Exception e) {
- fail("getProperties() failed with exception: " + e);
- }
- return path;
- }
-
- @SuppressWarnings("unchecked")
- protected String getPathOfDocument(String id) {
- String path = null;
- String filter = "*";
- List<ObjectParentData> parentData = fNavSvc.getObjectParents(fRepositoryId, id, filter, false,
- IncludeRelationships.NONE, null, true, null);
- String name = parentData.get(0).getRelativePathSegment();
- PropertyData<String> pd = (PropertyData<String>) parentData.get(0).getObject().getProperties().getProperties()
- .get(PropertyIds.PATH);
- assertNotNull(pd);
- path = pd.getFirstValue() + "/" + name;
- return path;
- }
-
- protected ObjectData getDocumentObjectData(String id) {
- ObjectData res = null;
- try {
- String returnedId = null;
- res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
- assertNotNull(res);
- returnedId = res.getId();
- testReturnedProperties(returnedId, res.getProperties().getProperties());
- assertEquals(id, returnedId);
- } catch (Exception e) {
- fail("getObject() failed with exception: " + e);
- }
- return res;
- }
-
- protected String getDocument(String id) {
- ObjectData res = getDocumentObjectData(id);
- assertNotNull(res);
- return res.getId();
- }
-
- protected void testReturnedProperties(String objectId, Map<String, PropertyData<?>> props) {
- for (PropertyData<?> pd : props.values()) {
- LOG.debug("return property id: " + pd.getId() + ", value: " + pd.getValues());
- }
-
- PropertyData<?> pd = props.get(PropertyIds.OBJECT_ID);
- assertNotNull(pd);
- assertEquals(objectId, pd.getFirstValue());
- }
-
- /**
- * Instantiates the services by using directly the service implementations.
- *
- * @param parameters
- * configuration parameters for client provider interface and
- * in-memory provider
- */
- private void initializeDirect(Map<String, String> parameters) {
- LOG.info("Initialize unit test using directly the InMemory-classes.");
-
- CmisInMemoryProvider inMemSpi = new CmisInMemoryProvider(parameters);
- fRepSvc = inMemSpi.getRepositoryService();
- fObjSvc = inMemSpi.getObjectService();
- fNavSvc = inMemSpi.getNavigationService();
- fVerSvc = inMemSpi.getVersioningService();
- fMultiSvc = inMemSpi.getMultiFilingService();
- }
-
- /**
- * Instantiates the services by using the client provider interface.
- *
- * @param parameters
- * configuration parameters for client provider interface and
- * in-memory provider
- */
- private void initializeUsingLocalBinding(Map<String, String> parameters) {
-
- LOG.info("Initialize unit test using the local binding interface.");
-
- // add parameters for local binding:
- parameters.put(SessionParameter.BINDING_SPI_CLASS, SessionParameter.LOCAL_FACTORY);
- parameters.put(SessionParameter.LOCAL_FACTORY, InMemoryServiceFactoryImpl.class.getName());
- parameters.put(ConfigConstants.OVERRIDE_CALL_CONTEXT, "true");
- InMemoryServiceFactoryImpl.setOverrideCallContext(fTestCallContext);
-
- // get factory and create binding
- CmisBindingFactory factory = CmisBindingFactory.newInstance();
- CmisBinding binding = factory.createCmisLocalBinding(parameters);
- assertNotNull(binding);
- fFactory = binding.getObjectFactory();
- fRepSvc = binding.getRepositoryService();
- fObjSvc = binding.getObjectService();
- fNavSvc = binding.getNavigationService();
- fVerSvc = binding.getVersioningService();
- fMultiSvc = binding.getMultiFilingService();
- }
-
- protected String getStringProperty(ObjectData objData, String propertyKey) {
- PropertyData<? extends Object> pd = (PropertyData<? extends Object>) objData.getProperties().getProperties()
- .get(PropertyIds.PATH);
- assertNotNull(pd.getFirstValue());
- assertTrue(pd.getFirstValue() instanceof String);
- return (String) pd.getFirstValue();
- }
+ private static Log LOG = LogFactory.getLog(AbstractServiceTst.class);
+ protected static final String REPOSITORY_ID = "UnitTestRepository";
+ protected BindingsObjectFactory fFactory = new BindingsObjectFactoryImpl();
+ protected String fRootFolderId;
+ protected String fRepositoryId;
+ protected ObjectService fObjSvc;
+ protected NavigationService fNavSvc;
+ protected RepositoryService fRepSvc;
+ protected VersioningService fVerSvc;
+ protected MultiFilingService fMultiSvc;
+ protected DummyCallContext fTestCallContext;
+ private String fTypeCreatorClassName;
+ protected boolean fUseClientProviderInterface;
+
+ public AbstractServiceTst() {
+ // The in-memory server unit tests can either be run directly against
+ // the
+ // service implementation or against a clocal binding interface. The
+ // local
+ // binding interfaces offers some benefits like type system caching etc.
+ // The default is using the direct implementation. Subclasses may
+ // override this behavior.
+
+ fUseClientProviderInterface = true;
+
+ // Init with default types, can be overridden by subclasses:
+ fTypeCreatorClassName = UnitTestTypeSystemCreator.class.getName();
+ }
+
+ // Subclasses may want to use their own types
+ protected void setTypeCreatorClass(String typeCreatorClassName) {
+ fTypeCreatorClassName = typeCreatorClassName;
+ }
+
+ protected void setUp() throws Exception {
+ // super.setUp();
+ LOG.debug("Initializing InMemory Test with type creator class: " + fTypeCreatorClassName);
+ Map<String, String> parameters = new HashMap<String, String>();
+
+ // attach repository info to the session:
+ parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, fTypeCreatorClassName);
+ parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
+
+ // attach repository info to the session:
+ parameters.put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
+
+ // give subclasses a chance to provide additional parameters for special
+ // tests
+ addParameters(parameters);
+
+ fTestCallContext = new DummyCallContext();
+ // Attach a standatrd CallContext to a thread before the services are
+ // initialized.
+ // RuntimeContext.attachCfg(fTestCallContext);
+
+ if (fUseClientProviderInterface)
+ initializeUsingLocalBinding(parameters);
+ else
+ initializeDirect(parameters);
+
+ assertNotNull(fRepSvc);
+ assertNotNull(fObjSvc);
+ assertNotNull(fNavSvc);
+
+ RepositoryInfo rep = fRepSvc.getRepositoryInfo(REPOSITORY_ID, null);
+ fRootFolderId = rep.getRootFolderId();
+ fRepositoryId = rep.getId();
+
+ assertNotNull(fRepositoryId);
+ assertNotNull(fRootFolderId);
+ }
+
+ // Override this method in subclasses if you want to provide additional
+ // configuration
+ // parameters. Default implementation is empty
+ protected void addParameters(Map<String, String> parameters) {
+ }
+
+ protected void tearDown() throws Exception {
+ // super.tearDown();
+ }
+
+ public void testDummy() {
+ // dummy test to make tools happy that complain if there are no tests
+ // available in a test class
+ }
+
+ protected String createFolder(String folderName, String parentFolderId, String typeId) {
+ Properties props = createFolderProperties(folderName, typeId);
+ String id = null;
+ try {
+ id = fObjSvc.createFolder(fRepositoryId, props, parentFolderId, null, null, null, null);
+ if (null == id)
+ fail("createFolder failed.");
+ } catch (Exception e) {
+ fail("createFolder() failed with exception: " + e);
+ }
+ return id;
+ }
+
+ protected String createDocument(String name, String folderId, String typeId, VersioningState versioningState,
+ boolean withContent) {
+ ContentStream contentStream = null;
+ List<String> policies = null;
+ Acl addACEs = null;
+ Acl removeACEs = null;
+ ExtensionsData extension = null;
+
+ Properties props = createDocumentProperties(name, typeId);
+
+ if (withContent)
+ contentStream = createContent();
+
+ String id = null;
+ try {
+ id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState, policies,
+ addACEs, removeACEs, extension);
+ if (null == id)
+ fail("createDocument failed.");
+ } catch (Exception e) {
+ fail("createDocument() failed with exception: " + e);
+ }
+ return id;
+
+ }
+
+ protected String createDocument(String name, String folderId, String typeId, boolean withContent) {
+ VersioningState versioningState = VersioningState.NONE;
+ return createDocument(name, folderId, typeId, versioningState, withContent);
+ }
+
+ protected Properties createDocumentProperties(String name, String typeId) {
+ List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+ properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, name));
+ properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
+ Properties props = fFactory.createPropertiesData(properties);
+ return props;
+ }
+
+ protected Properties createFolderProperties(String folderName, String typeId) {
+ List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+ properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, folderName));
+ properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
+ Properties props = fFactory.createPropertiesData(properties);
+ return props;
+ }
+
+ protected ContentStream createContent() {
+ ContentStreamDataImpl content = new ContentStreamDataImpl();
+ content.setFileName("data.txt");
+ content.setMimeType("text/plain");
+ int len = 32 * 1024;
+ byte[] b = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,
+ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a }; // 32
+ // Bytes
+ ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+ try {
+ for (int i = 0; i < 1024; i++)
+ ba.write(b);
+ content.setContent(new ByteArrayInputStream(ba.toByteArray()));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to fill content stream with data", e);
+ }
+ return content;
+ }
+
+ protected ContentStream createContent(char ch) {
+ ContentStreamDataImpl content = new ContentStreamDataImpl();
+ content.setFileName("data.txt");
+ content.setMimeType("text/plain");
+ int len = 32 * 1024;
+ byte[] b = new byte[32];
+ for (int i = 0; i < 32; i++)
+ b[i] = (byte) Character.getNumericValue(ch);
+ ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+ try {
+ for (int i = 0; i < 1024; i++)
+ ba.write(b);
+ content.setContent(new ByteArrayInputStream(ba.toByteArray()));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to fill content stream with data", e);
+ }
+ return content;
+ }
+
+ protected void verifyContentResult(ContentStream sd) {
+ assertEquals("text/plain", sd.getMimeType());
+ assertEquals("data.txt", sd.getFileName());
+ assertEquals(32 * 1024, sd.getBigLength().longValue());
+ byte[] ba = new byte[32];
+ InputStream is = sd.getStream();
+ int counter = 0;
+ try {
+ while (is.read(ba) == ba.length) {
+ ++counter;
+ assertEquals(0x61, ba[0]);
+ assertEquals(0x6e, ba[29]);
+ assertEquals(0x0c, ba[30]);
+ assertEquals(0x0a, ba[31]);
+ }
+ } catch (IOException e) {
+ fail("reading from content stream failed");
+ }
+ assertEquals(1024, counter);
+ }
+
+ protected String getByPath(String id, String path) {
+ ObjectData res = null;
+ try {
+ res = fObjSvc.getObjectByPath(fRepositoryId, path, "*", false, IncludeRelationships.NONE, null, false,
+ false, null);
+ assertNotNull(res);
+ assertEquals(id, res.getId());
+ } catch (Exception e) {
+ fail("getObject() failed with exception: " + e);
+ }
+ return res.getId();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String getPathOfFolder(String id) {
+ String path = null;
+ try {
+ String filter = PropertyIds.PATH;
+ Properties res = fObjSvc.getProperties(fRepositoryId, id, filter, null);
+ assertNotNull(res);
+ PropertyData<String> pd = (PropertyData<String>) res.getProperties().get(PropertyIds.PATH);
+ assertNotNull(pd);
+ path = pd.getFirstValue();
+ assertNotNull(path);
+ } catch (Exception e) {
+ fail("getProperties() failed with exception: " + e);
+ }
+ return path;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String getPathOfDocument(String id) {
+ String path = null;
+ String filter = "*";
+ List<ObjectParentData> parentData = fNavSvc.getObjectParents(fRepositoryId, id, filter, false,
+ IncludeRelationships.NONE, null, true, null);
+ String name = parentData.get(0).getRelativePathSegment();
+ PropertyData<String> pd = (PropertyData<String>) parentData.get(0).getObject().getProperties().getProperties()
+ .get(PropertyIds.PATH);
+ assertNotNull(pd);
+ path = pd.getFirstValue() + "/" + name;
+ return path;
+ }
+
+ protected ObjectData getDocumentObjectData(String id) {
+ ObjectData res = null;
+ try {
+ String returnedId = null;
+ res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
+ assertNotNull(res);
+ returnedId = res.getId();
+ testReturnedProperties(returnedId, res.getProperties().getProperties());
+ assertEquals(id, returnedId);
+ } catch (Exception e) {
+ fail("getObject() failed with exception: " + e);
+ }
+ return res;
+ }
+
+ protected String getDocument(String id) {
+ ObjectData res = getDocumentObjectData(id);
+ assertNotNull(res);
+ return res.getId();
+ }
+
+ protected void testReturnedProperties(String objectId, Map<String, PropertyData<?>> props) {
+ for (PropertyData<?> pd : props.values()) {
+ LOG.debug("return property id: " + pd.getId() + ", value: " + pd.getValues());
+ }
+
+ PropertyData<?> pd = props.get(PropertyIds.OBJECT_ID);
+ assertNotNull(pd);
+ assertEquals(objectId, pd.getFirstValue());
+ }
+
+ /**
+ * Instantiates the services by using directly the service implementations.
+ *
+ * @param parameters
+ * configuration parameters for client provider interface and
+ * in-memory provider
+ */
+ private void initializeDirect(Map<String, String> parameters) {
+ LOG.info("Initialize unit test using directly the InMemory-classes.");
+
+ CmisInMemoryProvider inMemSpi = new CmisInMemoryProvider(parameters);
+ fRepSvc = inMemSpi.getRepositoryService();
+ fObjSvc = inMemSpi.getObjectService();
+ fNavSvc = inMemSpi.getNavigationService();
+ fVerSvc = inMemSpi.getVersioningService();
+ fMultiSvc = inMemSpi.getMultiFilingService();
+ }
+
+ /**
+ * Instantiates the services by using the client provider interface.
+ *
+ * @param parameters
+ * configuration parameters for client provider interface and
+ * in-memory provider
+ */
+ private void initializeUsingLocalBinding(Map<String, String> parameters) {
+
+ LOG.info("Initialize unit test using the local binding interface.");
+
+ // add parameters for local binding:
+ parameters.put(SessionParameter.BINDING_SPI_CLASS, SessionParameter.LOCAL_FACTORY);
+ parameters.put(SessionParameter.LOCAL_FACTORY, InMemoryServiceFactoryImpl.class.getName());
+ parameters.put(ConfigConstants.OVERRIDE_CALL_CONTEXT, "true");
+ InMemoryServiceFactoryImpl.setOverrideCallContext(fTestCallContext);
+
+ // get factory and create binding
+ CmisBindingFactory factory = CmisBindingFactory.newInstance();
+ CmisBinding binding = factory.createCmisLocalBinding(parameters);
+ assertNotNull(binding);
+ fFactory = binding.getObjectFactory();
+ fRepSvc = binding.getRepositoryService();
+ fObjSvc = binding.getObjectService();
+ fNavSvc = binding.getNavigationService();
+ fVerSvc = binding.getVersioningService();
+ fMultiSvc = binding.getMultiFilingService();
+ }
+
+ protected String getStringProperty(ObjectData objData, String propertyKey) {
+ PropertyData<? extends Object> pd = (PropertyData<? extends Object>) objData.getProperties().getProperties()
+ .get(PropertyIds.PATH);
+ assertNotNull(pd.getFirstValue());
+ assertTrue(pd.getFirstValue() instanceof String);
+ return (String) pd.getFirstValue();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java Thu Apr 22 16:27:57 2010
@@ -42,139 +42,139 @@ import org.junit.Test;
public class FolderTest extends TestCase {
- private ObjectStore fStore;
- private FolderImpl fRoot;
- private FolderImpl f1;
- private FolderImpl f2;
- private FolderImpl f3;
- private FolderImpl f4;
- private FolderImpl f11;
- private static final String TEST_REPOSITORY_ID = "TestRepositoryId";
-
- @Before
- protected void setUp() throws Exception {
- fStore = new ObjectStoreImpl(TEST_REPOSITORY_ID);
- createFolders();
- }
-
- @Test
- public void testCreatAndGetFolders() {
- try {
- Folder childFolder = fStore.createFolder("Folder 1");
- fRoot.addChildFolder(childFolder);
- fail("Should throw exception if folder already exists.");
- } catch (Exception e) {
- }
- assertEquals(f1.getName(), "Folder 1");
- assertEquals(f11.getName(), "Folder 1.1");
- assertNull(fRoot.getParent());
- assertEquals(fRoot, f1.getParent());
- assertEquals(f1, f11.getParent());
- assertEquals(Filing.PATH_SEPARATOR, fRoot.getPath());
- assertEquals("/Folder 1", f1.getPath());
- assertEquals("/Folder 1/Folder 1.1", f11.getPath());
- StoredObject fTest = fStore.getObjectByPath("/");
- assertEquals(fRoot, fTest);
- fTest = fStore.getObjectByPath("/Folder 1");
- assertEquals(f1, fTest);
- fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1");
- assertEquals(f11, fTest);
- List<StoredObject> subFolders = fRoot.getChildren(-1, -1);
- assertEquals(4, subFolders.size());
- subFolders = f2.getChildren(-1, -1);
- assertEquals(0, subFolders.size());
- subFolders = f1.getChildren(-1, -1);
- assertEquals(1, subFolders.size());
- }
-
- @Test
- public void testRenameFolder() {
- // rename top level folder
- String newName = "Folder B";
- String oldPath = f2.getPath();
- f2.rename(newName);
- assertEquals(f2.getName(), newName);
- assertEquals(f2.getPath(), Filing.PATH_SEPARATOR + newName);
- assertNull(fStore.getObjectByPath(oldPath));
- assertEquals(f2, fStore.getObjectByPath(Filing.PATH_SEPARATOR + newName));
- try {
- f2.rename("Folder 3");
- fail("Should not allow to rename a folder to an existing name");
- } catch (Exception e) {
- }
-
- // rename sub folder
- oldPath = f11.getPath();
- f11.rename(newName);
- assertEquals(f11.getName(), newName);
- assertEquals(f11.getPath(), "/Folder 1/Folder B");
- assertNull(fStore.getObjectByPath(oldPath));
- assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B"));
- try {
- f2.rename(newName);
- fail("Should not allow to rename a folder to an existing name");
- } catch (Exception e) {
- }
- try {
- f2.rename("illegal/name");
- fail("Should not allow to rename a folder to a name with illegal name");
- } catch (Exception e) {
- }
-
- // rename root folder
- try {
- fRoot.rename("abc");
- fail("Should not be possible to rename root folder");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testMoveFolder() {
- String oldPath = f1.getPath();
- Folder f1Parent = f1.getParent();
- f1.move(f1Parent, f3);
- assertNull(fStore.getObjectByPath(oldPath));
- assertEquals(f1.getPath(), "/Folder 3/Folder 1");
- assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1"));
-
- f2.rename("Folder 1");
- try {
- Folder f2Parent = f2.getParent();
- f2.move(f2Parent, f3);
- fail("Should not be possible to move folder to a folder that has a child with same name");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testDeleteFolder() {
- String oldPath = f2.getPath();
- fStore.deleteObject(f2.getId());
- assertNull(fStore.getObjectByPath(oldPath));
-
- try {
- fStore.deleteObject(f1.getId());
- fail("Should not be possible to move folder that has children");
- } catch (Exception e) {
- }
- }
-
- private void createFolders() {
- fRoot = (FolderImpl) fStore.getRootFolder();
- f1 = (FolderImpl) fStore.createFolder("Folder 1");
- fRoot.addChildFolder(f1);
-
- f2 = (FolderImpl) fStore.createFolder("Folder 2");
- fRoot.addChildFolder(f2);
-
- f3 = (FolderImpl) fStore.createFolder("Folder 3");
- fRoot.addChildFolder(f3);
-
- f4 = (FolderImpl) fStore.createFolder("Folder 4");
- fRoot.addChildFolder(f4);
-
- f11 = (FolderImpl) fStore.createFolder("Folder 1.1");
- f1.addChildFolder(f11);
- }
+ private ObjectStore fStore;
+ private FolderImpl fRoot;
+ private FolderImpl f1;
+ private FolderImpl f2;
+ private FolderImpl f3;
+ private FolderImpl f4;
+ private FolderImpl f11;
+ private static final String TEST_REPOSITORY_ID = "TestRepositoryId";
+
+ @Before
+ protected void setUp() throws Exception {
+ fStore = new ObjectStoreImpl(TEST_REPOSITORY_ID);
+ createFolders();
+ }
+
+ @Test
+ public void testCreatAndGetFolders() {
+ try {
+ Folder childFolder = fStore.createFolder("Folder 1");
+ fRoot.addChildFolder(childFolder);
+ fail("Should throw exception if folder already exists.");
+ } catch (Exception e) {
+ }
+ assertEquals(f1.getName(), "Folder 1");
+ assertEquals(f11.getName(), "Folder 1.1");
+ assertNull(fRoot.getParent());
+ assertEquals(fRoot, f1.getParent());
+ assertEquals(f1, f11.getParent());
+ assertEquals(Filing.PATH_SEPARATOR, fRoot.getPath());
+ assertEquals("/Folder 1", f1.getPath());
+ assertEquals("/Folder 1/Folder 1.1", f11.getPath());
+ StoredObject fTest = fStore.getObjectByPath("/");
+ assertEquals(fRoot, fTest);
+ fTest = fStore.getObjectByPath("/Folder 1");
+ assertEquals(f1, fTest);
+ fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1");
+ assertEquals(f11, fTest);
+ List<StoredObject> subFolders = fRoot.getChildren(-1, -1);
+ assertEquals(4, subFolders.size());
+ subFolders = f2.getChildren(-1, -1);
+ assertEquals(0, subFolders.size());
+ subFolders = f1.getChildren(-1, -1);
+ assertEquals(1, subFolders.size());
+ }
+
+ @Test
+ public void testRenameFolder() {
+ // rename top level folder
+ String newName = "Folder B";
+ String oldPath = f2.getPath();
+ f2.rename(newName);
+ assertEquals(f2.getName(), newName);
+ assertEquals(f2.getPath(), Filing.PATH_SEPARATOR + newName);
+ assertNull(fStore.getObjectByPath(oldPath));
+ assertEquals(f2, fStore.getObjectByPath(Filing.PATH_SEPARATOR + newName));
+ try {
+ f2.rename("Folder 3");
+ fail("Should not allow to rename a folder to an existing name");
+ } catch (Exception e) {
+ }
+
+ // rename sub folder
+ oldPath = f11.getPath();
+ f11.rename(newName);
+ assertEquals(f11.getName(), newName);
+ assertEquals(f11.getPath(), "/Folder 1/Folder B");
+ assertNull(fStore.getObjectByPath(oldPath));
+ assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B"));
+ try {
+ f2.rename(newName);
+ fail("Should not allow to rename a folder to an existing name");
+ } catch (Exception e) {
+ }
+ try {
+ f2.rename("illegal/name");
+ fail("Should not allow to rename a folder to a name with illegal name");
+ } catch (Exception e) {
+ }
+
+ // rename root folder
+ try {
+ fRoot.rename("abc");
+ fail("Should not be possible to rename root folder");
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testMoveFolder() {
+ String oldPath = f1.getPath();
+ Folder f1Parent = f1.getParent();
+ f1.move(f1Parent, f3);
+ assertNull(fStore.getObjectByPath(oldPath));
+ assertEquals(f1.getPath(), "/Folder 3/Folder 1");
+ assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1"));
+
+ f2.rename("Folder 1");
+ try {
+ Folder f2Parent = f2.getParent();
+ f2.move(f2Parent, f3);
+ fail("Should not be possible to move folder to a folder that has a child with same name");
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteFolder() {
+ String oldPath = f2.getPath();
+ fStore.deleteObject(f2.getId());
+ assertNull(fStore.getObjectByPath(oldPath));
+
+ try {
+ fStore.deleteObject(f1.getId());
+ fail("Should not be possible to move folder that has children");
+ } catch (Exception e) {
+ }
+ }
+
+ private void createFolders() {
+ fRoot = (FolderImpl) fStore.getRootFolder();
+ f1 = (FolderImpl) fStore.createFolder("Folder 1");
+ fRoot.addChildFolder(f1);
+
+ f2 = (FolderImpl) fStore.createFolder("Folder 2");
+ fRoot.addChildFolder(f2);
+
+ f3 = (FolderImpl) fStore.createFolder("Folder 3");
+ fRoot.addChildFolder(f3);
+
+ f4 = (FolderImpl) fStore.createFolder("Folder 4");
+ fRoot.addChildFolder(f4);
+
+ f11 = (FolderImpl) fStore.createFolder("Folder 1.1");
+ f1.addChildFolder(f11);
+ }
}