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 [11/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-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java Thu Apr 22 16:27:57 2010
@@ -64,483 +64,483 @@ import org.apache.commons.logging.LogFac
*
*/
public class TypeManager {
- public final static String DOCUMENT_TYPE_ID = "cmis:document";
- public final static String FOLDER_TYPE_ID = "cmis:folder";
- public final static String RELATIONSHIP_TYPE_ID = "cmis:relationship";
- public final static String POLICY_TYPE_ID = "cmis:policy";
-
- private static final String NAMESPACE = "http://opencmis.org/fileshare";
-
- private static final Log log = LogFactory.getLog(TypeManager.class);
-
- private Map<String, TypeDefinitionContainerImpl> fTypes;
- private List<TypeDefinitionContainer> fTypesList;
-
- public TypeManager() {
- setup();
- }
-
- /**
- * Creates the base types.
- */
- private void setup() {
- fTypes = new HashMap<String, TypeDefinitionContainerImpl>();
- fTypesList = new ArrayList<TypeDefinitionContainer>();
-
- // folder type
- FolderTypeDefinitionImpl folderType = new FolderTypeDefinitionImpl();
- folderType.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
- folderType.setIsControllableAcl(false);
- folderType.setIsControllablePolicy(false);
- folderType.setIsCreatable(true);
- folderType.setDescription("Folder");
- folderType.setDisplayName("Folder");
- folderType.setIsFileable(true);
- folderType.setIsFulltextIndexed(false);
- folderType.setIsIncludedInSupertypeQuery(true);
- folderType.setLocalName("Folder");
- folderType.setLocalNamespace(NAMESPACE);
- folderType.setIsQueryable(false);
- folderType.setQueryName("cmis:folder");
- folderType.setId(FOLDER_TYPE_ID);
-
- addBasePropertyDefinitions(folderType);
- addFolderPropertyDefinitions(folderType);
-
- addTypeInteral(folderType);
-
- // document type
- DocumentTypeDefinitionImpl documentType = new DocumentTypeDefinitionImpl();
- documentType.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
- documentType.setIsControllableAcl(false);
- documentType.setIsControllablePolicy(false);
- documentType.setIsCreatable(true);
- documentType.setDescription("Document");
- documentType.setDisplayName("Document");
- documentType.setIsFileable(true);
- documentType.setIsFulltextIndexed(false);
- documentType.setIsIncludedInSupertypeQuery(true);
- documentType.setLocalName("Document");
- documentType.setLocalNamespace(NAMESPACE);
- documentType.setIsQueryable(false);
- documentType.setQueryName("cmis:document");
- documentType.setId(DOCUMENT_TYPE_ID);
-
- documentType.setIsVersionable(false);
- documentType.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
-
- addBasePropertyDefinitions(documentType);
- addDocumentPropertyDefinitions(documentType);
-
- addTypeInteral(documentType);
-
- // relationship types
- RelationshipTypeDefinitionImpl relationshipType = new RelationshipTypeDefinitionImpl();
- relationshipType.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
- relationshipType.setIsControllableAcl(false);
- relationshipType.setIsControllablePolicy(false);
- relationshipType.setIsCreatable(false);
- relationshipType.setDescription("Relationship");
- relationshipType.setDisplayName("Relationship");
- relationshipType.setIsFileable(false);
- relationshipType.setIsIncludedInSupertypeQuery(true);
- relationshipType.setLocalName("Relationship");
- relationshipType.setLocalNamespace(NAMESPACE);
- relationshipType.setIsQueryable(false);
- relationshipType.setQueryName("cmis:relationship");
- relationshipType.setId(RELATIONSHIP_TYPE_ID);
-
- addBasePropertyDefinitions(relationshipType);
-
- // not supported - don't expose it
- // addTypeInteral(relationshipType);
-
- // policy type
- PolicyTypeDefinitionImpl policyType = new PolicyTypeDefinitionImpl();
- policyType.setBaseTypeId(BaseTypeId.CMIS_POLICY);
- policyType.setIsControllableAcl(false);
- policyType.setIsControllablePolicy(false);
- policyType.setIsCreatable(false);
- policyType.setDescription("Policy");
- policyType.setDisplayName("Policy");
- policyType.setIsFileable(false);
- policyType.setIsIncludedInSupertypeQuery(true);
- policyType.setLocalName("Policy");
- policyType.setLocalNamespace(NAMESPACE);
- policyType.setIsQueryable(false);
- policyType.setQueryName("cmis:policy");
- policyType.setId(POLICY_TYPE_ID);
-
- addBasePropertyDefinitions(policyType);
-
- // not supported - don't expose it
- // addTypeInteral(policyType);
- }
-
- private void addBasePropertyDefinitions(AbstractTypeDefinition type) {
- type.addPropertyDefinition(createPropDef(PropertyIds.BASE_TYPE_ID, "Base Type Id", "Base Type Id",
- PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_ID, "Object Id", "Object Id", PropertyType.ID,
- Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_TYPE_ID, "Type Id", "Type Id", PropertyType.ID,
- Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.NAME, "Name", "Name", PropertyType.STRING,
- Cardinality.SINGLE, Updatability.READWRITE, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CREATED_BY, "Created By", "Created By",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CREATION_DATE, "Creation Date", "Creation Date",
- PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.LAST_MODIFIED_BY, "Last Modified By", "Last Modified By",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type
- .addPropertyDefinition(createPropDef(PropertyIds.LAST_MODIFICATION_DATE, "Last Modification Date",
- "Last Modification Date", PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY,
- false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CHANGE_TOKEN, "Change Token", "Change Token",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
- }
-
- private void addFolderPropertyDefinitions(FolderTypeDefinitionImpl type) {
- type.addPropertyDefinition(createPropDef(PropertyIds.PARENT_ID, "Parent Id", "Parent Id", PropertyType.ID,
- Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
- "Allowed Child Object Type Ids", "Allowed Child Object Type Ids", PropertyType.ID, Cardinality.MULTI,
- Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.PATH, "Path", "Path", PropertyType.STRING,
- Cardinality.SINGLE, Updatability.READONLY, false, false));
- }
-
- private void addDocumentPropertyDefinitions(DocumentTypeDefinitionImpl type) {
- type.addPropertyDefinition(createPropDef(PropertyIds.IS_IMMUTABLE, "Is Immutable", "Is Immutable",
- PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.IS_LATEST_VERSION, "Is Latest Version",
- "Is Latest Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.IS_MAJOR_VERSION, "Is Major Version", "Is Major Version",
- PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.IS_LATEST_MAJOR_VERSION, "Is Latest Major Version",
- "Is Latest Major Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false,
- false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_LABEL, "Version Label", "Version Label",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_SERIES_ID, "Version Series Id",
- "Version Series Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
- "Is Verison Series Checked Out", "Is Verison Series Checked Out", PropertyType.BOOLEAN,
- Cardinality.SINGLE, Updatability.READONLY, false, true));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
- "Version Series Checked Out Id", "Version Series Checked Out Id", PropertyType.ID, Cardinality.SINGLE,
- Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CHECKIN_COMMENT, "Checkin Comment", "Checkin Comment",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type
- .addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_LENGTH, "Content Stream Length",
- "Content Stream Length", PropertyType.INTEGER, Cardinality.SINGLE, Updatability.READONLY,
- false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_MIME_TYPE, "MIME Type", "MIME Type",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_FILE_NAME, "Filename", "Filename",
- PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
-
- type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_ID, "Content Stream Id",
- "Content Stream Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, false));
- }
-
- /**
- * Creates a property definition object.
- */
- private PropertyDefinition<?> createPropDef(String id, String displayName, String description,
- PropertyType datatype, Cardinality cardinality, Updatability updateability, boolean inherited,
- boolean required) {
- AbstractPropertyDefinition<?> result = null;
-
- switch (datatype) {
- case BOOLEAN:
- result = new PropertyBooleanDefinitionImpl();
- break;
- case DATETIME:
- result = new PropertyDateTimeDefinitionImpl();
- break;
- case DECIMAL:
- result = new PropertyDecimalDefinitionImpl();
- break;
- case HTML:
- result = new PropertyHtmlDefinitionImpl();
- break;
- case ID:
- result = new PropertyIdDefinitionImpl();
- break;
- case INTEGER:
- result = new PropertyIntegerDefinitionImpl();
- break;
- case STRING:
- result = new PropertyStringDefinitionImpl();
- break;
- case URI:
- result = new PropertyUriDefinitionImpl();
- break;
- default:
- throw new RuntimeException("Unknown datatype! Spec change?");
- }
-
- result.setId(id);
- result.setLocalName(id);
- result.setDisplayName(displayName);
- result.setDescription(description);
- result.setPropertyType(datatype);
- result.setCardinality(cardinality);
- result.setUpdatability(updateability);
- result.setIsInherited(inherited);
- result.setIsRequired(required);
- result.setIsQueryable(false);
- result.setQueryName(id);
-
- return result;
- }
-
- /**
- * Adds a type to collection with inheriting base type properties.
- */
- public boolean addType(TypeDefinition type) {
- if (type == null) {
- return false;
- }
-
- if (type.getBaseTypeId() == null) {
- return false;
- }
-
- // find base type
- TypeDefinition baseType = null;
- if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
- baseType = copyTypeDefintion(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition());
- } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
- baseType = copyTypeDefintion(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition());
- } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
- baseType = copyTypeDefintion(fTypes.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
- } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
- baseType = copyTypeDefintion(fTypes.get(POLICY_TYPE_ID).getTypeDefinition());
- } else {
- return false;
- }
-
- AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type);
-
- // copy property definition
- for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
- ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true);
- newType.addPropertyDefinition(propDef);
- }
-
- // add it
- addTypeInteral(newType);
-
- log.info("Added type '" + newType.getId() + "'.");
-
- return true;
- }
-
- /**
- * Adds a type to collection.
- */
- private void addTypeInteral(AbstractTypeDefinition type) {
- if (type == null) {
- return;
- }
-
- if (fTypes.containsKey(type.getId())) {
- // can't overwrite a type
- return;
- }
-
- TypeDefinitionContainerImpl tc = new TypeDefinitionContainerImpl();
- tc.setTypeDefinition(type);
-
- // add to parent
- if (type.getParentTypeId() != null) {
- TypeDefinitionContainerImpl tdc = fTypes.get(type.getParentTypeId());
- if (tdc != null) {
- if (tdc.getChildren() == null) {
- tdc.setChildren(new ArrayList<TypeDefinitionContainer>());
- }
- tdc.getChildren().add(tc);
- }
- }
-
- fTypes.put(type.getId(), tc);
- fTypesList.add(tc);
- }
-
- /**
- * CMIS getTypesChildren.
- */
- public TypeDefinitionList getTypesChildren(CallContext context, String typeId, boolean includePropertyDefinitions,
- BigInteger maxItems, BigInteger skipCount) {
- TypeDefinitionListImpl result = new TypeDefinitionListImpl();
- result.setList(new ArrayList<TypeDefinition>());
- result.setHasMoreItems(false);
- result.setNumItems(BigInteger.valueOf(0));
-
- int skip = (skipCount == null ? 0 : skipCount.intValue());
- if (skip < 0) {
- skip = 0;
- }
-
- int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
- if (max < 1) {
- return result;
- }
-
- if (typeId == null) {
- if (skip < 1) {
- result.getList().add(copyTypeDefintion(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition()));
- max--;
- }
- if ((skip < 2) && (max > 0)) {
- result.getList().add(copyTypeDefintion(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
- max--;
- }
-
- result.setHasMoreItems((result.getList().size() + skip) < 2);
- result.setNumItems(BigInteger.valueOf(2));
- } else {
- TypeDefinitionContainer tc = fTypes.get(typeId);
- if ((tc == null) || (tc.getChildren() == null)) {
- return result;
- }
-
- for (TypeDefinitionContainer child : tc.getChildren()) {
- if (skip > 0) {
- skip--;
- continue;
- }
-
- result.getList().add(copyTypeDefintion(child.getTypeDefinition()));
-
- max--;
- if (max == 0) {
- break;
- }
- }
-
- result.setHasMoreItems((result.getList().size() + skip) < tc.getChildren().size());
- result.setNumItems(BigInteger.valueOf(tc.getChildren().size()));
- }
-
- if (!includePropertyDefinitions) {
- for (TypeDefinition type : result.getList()) {
- type.getPropertyDefinitions().clear();
- }
- }
-
- return result;
- }
-
- /**
- * CMIS getTypesDescendants.
- */
- public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth,
- Boolean includePropertyDefinitions) {
- List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
-
- // check depth
- int d = (depth == null ? -1 : depth.intValue());
- if (d == 0) {
- throw new CmisInvalidArgumentException("Depth must not be 0!");
- }
-
- // set property definition flag to default value if not set
- boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());
-
- if (typeId == null) {
- result.add(getTypesDescendants(d, fTypes.get(FOLDER_TYPE_ID), ipd));
- result.add(getTypesDescendants(d, fTypes.get(DOCUMENT_TYPE_ID), ipd));
- // result.add(getTypesDescendants(depth,
- // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions));
- // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID),
- // includePropertyDefinitions));
- } else {
- TypeDefinitionContainer tc = fTypes.get(typeId);
- if (tc != null) {
- result.add(getTypesDescendants(d, tc, ipd));
- }
- }
-
- return result;
- }
-
- /**
- * Gathers the type descendants tree.
- */
- private TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionContainer tc,
- boolean includePropertyDefinitions) {
- TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl();
-
- TypeDefinition type = copyTypeDefintion(tc.getTypeDefinition());
- if (!includePropertyDefinitions) {
- type.getPropertyDefinitions().clear();
- }
-
- result.setTypeDefinition(type);
-
- if (depth != 0) {
- if (tc.getChildren() != null) {
- result.setChildren(new ArrayList<TypeDefinitionContainer>());
- for (TypeDefinitionContainer tdc : tc.getChildren()) {
- result.getChildren().add(
- getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
- }
- }
- }
-
- return result;
- }
-
- /**
- * For internal use.
- */
- public TypeDefinition getType(String typeId) {
- TypeDefinitionContainer tc = fTypes.get(typeId);
- if (tc == null) {
- return null;
- }
-
- return tc.getTypeDefinition();
- }
-
- /**
- * CMIS getTypeDefinition.
- */
- public TypeDefinition getTypeDefinition(CallContext context, String typeId) {
- TypeDefinitionContainer tc = fTypes.get(typeId);
- if (tc == null) {
- throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
- }
-
- return copyTypeDefintion(tc.getTypeDefinition());
- }
-
- private TypeDefinition copyTypeDefintion(TypeDefinition type) {
- return Converter.convert(Converter.convert(type));
- }
+ public final static String DOCUMENT_TYPE_ID = "cmis:document";
+ public final static String FOLDER_TYPE_ID = "cmis:folder";
+ public final static String RELATIONSHIP_TYPE_ID = "cmis:relationship";
+ public final static String POLICY_TYPE_ID = "cmis:policy";
+
+ private static final String NAMESPACE = "http://opencmis.org/fileshare";
+
+ private static final Log log = LogFactory.getLog(TypeManager.class);
+
+ private Map<String, TypeDefinitionContainerImpl> fTypes;
+ private List<TypeDefinitionContainer> fTypesList;
+
+ public TypeManager() {
+ setup();
+ }
+
+ /**
+ * Creates the base types.
+ */
+ private void setup() {
+ fTypes = new HashMap<String, TypeDefinitionContainerImpl>();
+ fTypesList = new ArrayList<TypeDefinitionContainer>();
+
+ // folder type
+ FolderTypeDefinitionImpl folderType = new FolderTypeDefinitionImpl();
+ folderType.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
+ folderType.setIsControllableAcl(false);
+ folderType.setIsControllablePolicy(false);
+ folderType.setIsCreatable(true);
+ folderType.setDescription("Folder");
+ folderType.setDisplayName("Folder");
+ folderType.setIsFileable(true);
+ folderType.setIsFulltextIndexed(false);
+ folderType.setIsIncludedInSupertypeQuery(true);
+ folderType.setLocalName("Folder");
+ folderType.setLocalNamespace(NAMESPACE);
+ folderType.setIsQueryable(false);
+ folderType.setQueryName("cmis:folder");
+ folderType.setId(FOLDER_TYPE_ID);
+
+ addBasePropertyDefinitions(folderType);
+ addFolderPropertyDefinitions(folderType);
+
+ addTypeInteral(folderType);
+
+ // document type
+ DocumentTypeDefinitionImpl documentType = new DocumentTypeDefinitionImpl();
+ documentType.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
+ documentType.setIsControllableAcl(false);
+ documentType.setIsControllablePolicy(false);
+ documentType.setIsCreatable(true);
+ documentType.setDescription("Document");
+ documentType.setDisplayName("Document");
+ documentType.setIsFileable(true);
+ documentType.setIsFulltextIndexed(false);
+ documentType.setIsIncludedInSupertypeQuery(true);
+ documentType.setLocalName("Document");
+ documentType.setLocalNamespace(NAMESPACE);
+ documentType.setIsQueryable(false);
+ documentType.setQueryName("cmis:document");
+ documentType.setId(DOCUMENT_TYPE_ID);
+
+ documentType.setIsVersionable(false);
+ documentType.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+
+ addBasePropertyDefinitions(documentType);
+ addDocumentPropertyDefinitions(documentType);
+
+ addTypeInteral(documentType);
+
+ // relationship types
+ RelationshipTypeDefinitionImpl relationshipType = new RelationshipTypeDefinitionImpl();
+ relationshipType.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
+ relationshipType.setIsControllableAcl(false);
+ relationshipType.setIsControllablePolicy(false);
+ relationshipType.setIsCreatable(false);
+ relationshipType.setDescription("Relationship");
+ relationshipType.setDisplayName("Relationship");
+ relationshipType.setIsFileable(false);
+ relationshipType.setIsIncludedInSupertypeQuery(true);
+ relationshipType.setLocalName("Relationship");
+ relationshipType.setLocalNamespace(NAMESPACE);
+ relationshipType.setIsQueryable(false);
+ relationshipType.setQueryName("cmis:relationship");
+ relationshipType.setId(RELATIONSHIP_TYPE_ID);
+
+ addBasePropertyDefinitions(relationshipType);
+
+ // not supported - don't expose it
+ // addTypeInteral(relationshipType);
+
+ // policy type
+ PolicyTypeDefinitionImpl policyType = new PolicyTypeDefinitionImpl();
+ policyType.setBaseTypeId(BaseTypeId.CMIS_POLICY);
+ policyType.setIsControllableAcl(false);
+ policyType.setIsControllablePolicy(false);
+ policyType.setIsCreatable(false);
+ policyType.setDescription("Policy");
+ policyType.setDisplayName("Policy");
+ policyType.setIsFileable(false);
+ policyType.setIsIncludedInSupertypeQuery(true);
+ policyType.setLocalName("Policy");
+ policyType.setLocalNamespace(NAMESPACE);
+ policyType.setIsQueryable(false);
+ policyType.setQueryName("cmis:policy");
+ policyType.setId(POLICY_TYPE_ID);
+
+ addBasePropertyDefinitions(policyType);
+
+ // not supported - don't expose it
+ // addTypeInteral(policyType);
+ }
+
+ private void addBasePropertyDefinitions(AbstractTypeDefinition type) {
+ type.addPropertyDefinition(createPropDef(PropertyIds.BASE_TYPE_ID, "Base Type Id", "Base Type Id",
+ PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_ID, "Object Id", "Object Id", PropertyType.ID,
+ Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_TYPE_ID, "Type Id", "Type Id", PropertyType.ID,
+ Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.NAME, "Name", "Name", PropertyType.STRING,
+ Cardinality.SINGLE, Updatability.READWRITE, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CREATED_BY, "Created By", "Created By",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CREATION_DATE, "Creation Date", "Creation Date",
+ PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.LAST_MODIFIED_BY, "Last Modified By", "Last Modified By",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type
+ .addPropertyDefinition(createPropDef(PropertyIds.LAST_MODIFICATION_DATE, "Last Modification Date",
+ "Last Modification Date", PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY,
+ false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CHANGE_TOKEN, "Change Token", "Change Token",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
+ }
+
+ private void addFolderPropertyDefinitions(FolderTypeDefinitionImpl type) {
+ type.addPropertyDefinition(createPropDef(PropertyIds.PARENT_ID, "Parent Id", "Parent Id", PropertyType.ID,
+ Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
+ "Allowed Child Object Type Ids", "Allowed Child Object Type Ids", PropertyType.ID, Cardinality.MULTI,
+ Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.PATH, "Path", "Path", PropertyType.STRING,
+ Cardinality.SINGLE, Updatability.READONLY, false, false));
+ }
+
+ private void addDocumentPropertyDefinitions(DocumentTypeDefinitionImpl type) {
+ type.addPropertyDefinition(createPropDef(PropertyIds.IS_IMMUTABLE, "Is Immutable", "Is Immutable",
+ PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.IS_LATEST_VERSION, "Is Latest Version",
+ "Is Latest Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.IS_MAJOR_VERSION, "Is Major Version", "Is Major Version",
+ PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.IS_LATEST_MAJOR_VERSION, "Is Latest Major Version",
+ "Is Latest Major Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, false,
+ false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_LABEL, "Version Label", "Version Label",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_SERIES_ID, "Version Series Id",
+ "Version Series Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
+ "Is Verison Series Checked Out", "Is Verison Series Checked Out", PropertyType.BOOLEAN,
+ Cardinality.SINGLE, Updatability.READONLY, false, true));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
+ "Version Series Checked Out Id", "Version Series Checked Out Id", PropertyType.ID, Cardinality.SINGLE,
+ Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CHECKIN_COMMENT, "Checkin Comment", "Checkin Comment",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type
+ .addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_LENGTH, "Content Stream Length",
+ "Content Stream Length", PropertyType.INTEGER, Cardinality.SINGLE, Updatability.READONLY,
+ false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_MIME_TYPE, "MIME Type", "MIME Type",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_FILE_NAME, "Filename", "Filename",
+ PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
+
+ type.addPropertyDefinition(createPropDef(PropertyIds.CONTENT_STREAM_ID, "Content Stream Id",
+ "Content Stream Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, false));
+ }
+
+ /**
+ * Creates a property definition object.
+ */
+ private PropertyDefinition<?> createPropDef(String id, String displayName, String description,
+ PropertyType datatype, Cardinality cardinality, Updatability updateability, boolean inherited,
+ boolean required) {
+ AbstractPropertyDefinition<?> result = null;
+
+ switch (datatype) {
+ case BOOLEAN:
+ result = new PropertyBooleanDefinitionImpl();
+ break;
+ case DATETIME:
+ result = new PropertyDateTimeDefinitionImpl();
+ break;
+ case DECIMAL:
+ result = new PropertyDecimalDefinitionImpl();
+ break;
+ case HTML:
+ result = new PropertyHtmlDefinitionImpl();
+ break;
+ case ID:
+ result = new PropertyIdDefinitionImpl();
+ break;
+ case INTEGER:
+ result = new PropertyIntegerDefinitionImpl();
+ break;
+ case STRING:
+ result = new PropertyStringDefinitionImpl();
+ break;
+ case URI:
+ result = new PropertyUriDefinitionImpl();
+ break;
+ default:
+ throw new RuntimeException("Unknown datatype! Spec change?");
+ }
+
+ result.setId(id);
+ result.setLocalName(id);
+ result.setDisplayName(displayName);
+ result.setDescription(description);
+ result.setPropertyType(datatype);
+ result.setCardinality(cardinality);
+ result.setUpdatability(updateability);
+ result.setIsInherited(inherited);
+ result.setIsRequired(required);
+ result.setIsQueryable(false);
+ result.setQueryName(id);
+
+ return result;
+ }
+
+ /**
+ * Adds a type to collection with inheriting base type properties.
+ */
+ public boolean addType(TypeDefinition type) {
+ if (type == null) {
+ return false;
+ }
+
+ if (type.getBaseTypeId() == null) {
+ return false;
+ }
+
+ // find base type
+ TypeDefinition baseType = null;
+ if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
+ baseType = copyTypeDefintion(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition());
+ } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
+ baseType = copyTypeDefintion(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition());
+ } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
+ baseType = copyTypeDefintion(fTypes.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
+ } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
+ baseType = copyTypeDefintion(fTypes.get(POLICY_TYPE_ID).getTypeDefinition());
+ } else {
+ return false;
+ }
+
+ AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type);
+
+ // copy property definition
+ for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
+ ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true);
+ newType.addPropertyDefinition(propDef);
+ }
+
+ // add it
+ addTypeInteral(newType);
+
+ log.info("Added type '" + newType.getId() + "'.");
+
+ return true;
+ }
+
+ /**
+ * Adds a type to collection.
+ */
+ private void addTypeInteral(AbstractTypeDefinition type) {
+ if (type == null) {
+ return;
+ }
+
+ if (fTypes.containsKey(type.getId())) {
+ // can't overwrite a type
+ return;
+ }
+
+ TypeDefinitionContainerImpl tc = new TypeDefinitionContainerImpl();
+ tc.setTypeDefinition(type);
+
+ // add to parent
+ if (type.getParentTypeId() != null) {
+ TypeDefinitionContainerImpl tdc = fTypes.get(type.getParentTypeId());
+ if (tdc != null) {
+ if (tdc.getChildren() == null) {
+ tdc.setChildren(new ArrayList<TypeDefinitionContainer>());
+ }
+ tdc.getChildren().add(tc);
+ }
+ }
+
+ fTypes.put(type.getId(), tc);
+ fTypesList.add(tc);
+ }
+
+ /**
+ * CMIS getTypesChildren.
+ */
+ public TypeDefinitionList getTypesChildren(CallContext context, String typeId, boolean includePropertyDefinitions,
+ BigInteger maxItems, BigInteger skipCount) {
+ TypeDefinitionListImpl result = new TypeDefinitionListImpl();
+ result.setList(new ArrayList<TypeDefinition>());
+ result.setHasMoreItems(false);
+ result.setNumItems(BigInteger.valueOf(0));
+
+ int skip = (skipCount == null ? 0 : skipCount.intValue());
+ if (skip < 0) {
+ skip = 0;
+ }
+
+ int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
+ if (max < 1) {
+ return result;
+ }
+
+ if (typeId == null) {
+ if (skip < 1) {
+ result.getList().add(copyTypeDefintion(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition()));
+ max--;
+ }
+ if ((skip < 2) && (max > 0)) {
+ result.getList().add(copyTypeDefintion(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
+ max--;
+ }
+
+ result.setHasMoreItems((result.getList().size() + skip) < 2);
+ result.setNumItems(BigInteger.valueOf(2));
+ } else {
+ TypeDefinitionContainer tc = fTypes.get(typeId);
+ if ((tc == null) || (tc.getChildren() == null)) {
+ return result;
+ }
+
+ for (TypeDefinitionContainer child : tc.getChildren()) {
+ if (skip > 0) {
+ skip--;
+ continue;
+ }
+
+ result.getList().add(copyTypeDefintion(child.getTypeDefinition()));
+
+ max--;
+ if (max == 0) {
+ break;
+ }
+ }
+
+ result.setHasMoreItems((result.getList().size() + skip) < tc.getChildren().size());
+ result.setNumItems(BigInteger.valueOf(tc.getChildren().size()));
+ }
+
+ if (!includePropertyDefinitions) {
+ for (TypeDefinition type : result.getList()) {
+ type.getPropertyDefinitions().clear();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * CMIS getTypesDescendants.
+ */
+ public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth,
+ Boolean includePropertyDefinitions) {
+ List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
+
+ // check depth
+ int d = (depth == null ? -1 : depth.intValue());
+ if (d == 0) {
+ throw new CmisInvalidArgumentException("Depth must not be 0!");
+ }
+
+ // set property definition flag to default value if not set
+ boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());
+
+ if (typeId == null) {
+ result.add(getTypesDescendants(d, fTypes.get(FOLDER_TYPE_ID), ipd));
+ result.add(getTypesDescendants(d, fTypes.get(DOCUMENT_TYPE_ID), ipd));
+ // result.add(getTypesDescendants(depth,
+ // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions));
+ // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID),
+ // includePropertyDefinitions));
+ } else {
+ TypeDefinitionContainer tc = fTypes.get(typeId);
+ if (tc != null) {
+ result.add(getTypesDescendants(d, tc, ipd));
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Gathers the type descendants tree.
+ */
+ private TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionContainer tc,
+ boolean includePropertyDefinitions) {
+ TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl();
+
+ TypeDefinition type = copyTypeDefintion(tc.getTypeDefinition());
+ if (!includePropertyDefinitions) {
+ type.getPropertyDefinitions().clear();
+ }
+
+ result.setTypeDefinition(type);
+
+ if (depth != 0) {
+ if (tc.getChildren() != null) {
+ result.setChildren(new ArrayList<TypeDefinitionContainer>());
+ for (TypeDefinitionContainer tdc : tc.getChildren()) {
+ result.getChildren().add(
+ getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * For internal use.
+ */
+ public TypeDefinition getType(String typeId) {
+ TypeDefinitionContainer tc = fTypes.get(typeId);
+ if (tc == null) {
+ return null;
+ }
+
+ return tc.getTypeDefinition();
+ }
+
+ /**
+ * CMIS getTypeDefinition.
+ */
+ public TypeDefinition getTypeDefinition(CallContext context, String typeId) {
+ TypeDefinitionContainer tc = fTypes.get(typeId);
+ if (tc == null) {
+ throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
+ }
+
+ return copyTypeDefintion(tc.getTypeDefinition());
+ }
+
+ private TypeDefinition copyTypeDefintion(TypeDefinition type) {
+ return Converter.convert(Converter.convert(type));
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/VersioningService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/VersioningService.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/VersioningService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/VersioningService.java Thu Apr 22 16:27:57 2010
@@ -41,115 +41,115 @@ import org.apache.chemistry.opencmis.ser
*/
public class VersioningService implements CmisVersioningService {
- private RepositoryMap fRepositoryMap;
+ private RepositoryMap fRepositoryMap;
- /**
- * Constructor.
- */
- public VersioningService(RepositoryMap repositoryMap) {
- fRepositoryMap = repositoryMap;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.opencmis.server.spi.CmisVersioningService#cancelCheckOut(org
- * .apache.opencmis.server .spi.CallContext , java.lang.String,
- * java.lang.String, org.apache.opencmis.commons.api.ExtensionsData)
- */
- public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
- throw new CmisNotSupportedException("cancelCheckOut not supported!");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.opencmis.server.spi.CmisVersioningService#checkIn(org.apache
- * .opencmis.server.spi .CallContext, java.lang.String,
- * org.apache.opencmis.commons.provider.Holder, java.lang.Boolean,
- * org.apache.opencmis.commons.provider.PropertiesData,
- * org.apache.opencmis.commons.provider.ContentStreamData, java.lang.String,
- * java.util.List, org.apache.opencmis.commons.provider.AccessControlList,
- * org.apache.opencmis.commons.provider.AccessControlList,
- * org.apache.opencmis.commons.api.ExtensionsData,
- * org.apache.opencmis.server.spi.ObjectInfoHolder)
- */
- public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId, Boolean major,
- Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
- Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos) {
- throw new CmisNotSupportedException("checkIn not supported!");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.opencmis.server.spi.CmisVersioningService#checkOut(org.apache
- * .opencmis.server.spi .CallContext, java.lang.String,
- * org.apache.opencmis.commons.provider.Holder,
- * org.apache.opencmis.commons.api.ExtensionsData,
- * org.apache.opencmis.commons.provider.Holder,
- * org.apache.opencmis.server.spi.ObjectInfoHolder)
- */
- public ObjectData checkOut(CallContext context, String repositoryId, Holder<String> objectId,
- ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHolder objectInfos) {
- throw new CmisNotSupportedException("checkOut not supported!");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.opencmis.server.spi.CmisVersioningService#getAllVersions(org
- * .apache.opencmis.server .spi.CallContext , java.lang.String,
- * java.lang.String, java.lang.String, java.lang.Boolean,
- * org.apache.opencmis.commons.api.ExtensionsData,
- * org.apache.opencmis.server.spi.ObjectInfoHolder)
- */
- public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String versionSeriesId,
- String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
- ObjectData theVersion = fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context,
- versionSeriesId, filter, includeAllowableActions, false, objectInfos);
-
- return Collections.singletonList(theVersion);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.opencmis.server.spi.CmisVersioningService#getObjectOfLatestVersion
- * (org.apache.opencmis .server. spi.CallContext, java.lang.String,
- * java.lang.String, java.lang.Boolean, java.lang.String, java.lang.Boolean,
- * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String,
- * java.lang.Boolean, java.lang.Boolean,
- * org.apache.opencmis.commons.api.ExtensionsData,
- * org.apache.opencmis.server.spi.ObjectInfoHolder)
- */
- public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
- Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
- String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
- ObjectInfoHolder objectInfos) {
- return fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context, versionSeriesId,
- filter, includeAllowableActions, includeAcl, objectInfos);
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.apache.opencmis.server.spi.CmisVersioningService#
- * getPropertiesOfLatestVersion(org.apache .opencmis.server
- * .spi.CallContext, java.lang.String, java.lang.String, java.lang.Boolean,
- * java.lang.String, org.apache.opencmis.commons.api.ExtensionsData,
- * org.apache.opencmis.server.spi.ObjectInfoHolder)
- */
- public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
- Boolean major, String filter, ExtensionsData extension) {
- ObjectData object = fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context,
- versionSeriesId, filter, false, false, null);
+ /**
+ * Constructor.
+ */
+ public VersioningService(RepositoryMap repositoryMap) {
+ fRepositoryMap = repositoryMap;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.server.spi.CmisVersioningService#cancelCheckOut(org
+ * .apache.opencmis.server .spi.CallContext , java.lang.String,
+ * java.lang.String, org.apache.opencmis.commons.api.ExtensionsData)
+ */
+ public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
+ throw new CmisNotSupportedException("cancelCheckOut not supported!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.server.spi.CmisVersioningService#checkIn(org.apache
+ * .opencmis.server.spi .CallContext, java.lang.String,
+ * org.apache.opencmis.commons.provider.Holder, java.lang.Boolean,
+ * org.apache.opencmis.commons.provider.PropertiesData,
+ * org.apache.opencmis.commons.provider.ContentStreamData, java.lang.String,
+ * java.util.List, org.apache.opencmis.commons.provider.AccessControlList,
+ * org.apache.opencmis.commons.provider.AccessControlList,
+ * org.apache.opencmis.commons.api.ExtensionsData,
+ * org.apache.opencmis.server.spi.ObjectInfoHolder)
+ */
+ public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId, Boolean major,
+ Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
+ Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+ throw new CmisNotSupportedException("checkIn not supported!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.server.spi.CmisVersioningService#checkOut(org.apache
+ * .opencmis.server.spi .CallContext, java.lang.String,
+ * org.apache.opencmis.commons.provider.Holder,
+ * org.apache.opencmis.commons.api.ExtensionsData,
+ * org.apache.opencmis.commons.provider.Holder,
+ * org.apache.opencmis.server.spi.ObjectInfoHolder)
+ */
+ public ObjectData checkOut(CallContext context, String repositoryId, Holder<String> objectId,
+ ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHolder objectInfos) {
+ throw new CmisNotSupportedException("checkOut not supported!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.server.spi.CmisVersioningService#getAllVersions(org
+ * .apache.opencmis.server .spi.CallContext , java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.Boolean,
+ * org.apache.opencmis.commons.api.ExtensionsData,
+ * org.apache.opencmis.server.spi.ObjectInfoHolder)
+ */
+ public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String versionSeriesId,
+ String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+ ObjectData theVersion = fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context,
+ versionSeriesId, filter, includeAllowableActions, false, objectInfos);
+
+ return Collections.singletonList(theVersion);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.server.spi.CmisVersioningService#getObjectOfLatestVersion
+ * (org.apache.opencmis .server. spi.CallContext, java.lang.String,
+ * java.lang.String, java.lang.Boolean, java.lang.String, java.lang.Boolean,
+ * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String,
+ * java.lang.Boolean, java.lang.Boolean,
+ * org.apache.opencmis.commons.api.ExtensionsData,
+ * org.apache.opencmis.server.spi.ObjectInfoHolder)
+ */
+ public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
+ Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+ String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
+ ObjectInfoHolder objectInfos) {
+ return fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context, versionSeriesId,
+ filter, includeAllowableActions, includeAcl, objectInfos);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.opencmis.server.spi.CmisVersioningService#
+ * getPropertiesOfLatestVersion(org.apache .opencmis.server
+ * .spi.CallContext, java.lang.String, java.lang.String, java.lang.Boolean,
+ * java.lang.String, org.apache.opencmis.commons.api.ExtensionsData,
+ * org.apache.opencmis.server.spi.ObjectInfoHolder)
+ */
+ public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
+ Boolean major, String filter, ExtensionsData extension) {
+ ObjectData object = fRepositoryMap.getAuthenticatedRepository(context, repositoryId).getObject(context,
+ versionSeriesId, filter, false, false, null);
- return object.getProperties();
- }
+ return object.getProperties();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.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/ConfigConstants.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/ConfigConstants.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java Thu Apr 22 16:27:57 2010
@@ -19,21 +19,21 @@
package org.apache.chemistry.opencmis.inmemory;
public class ConfigConstants {
- public static final String REPOSITORY_ID = "InMemoryServer.RepositoryId";
- public static final String TYPE_CREATOR_CLASS = "InMemoryServer.TypesCreatorClass";
- public static final String REPOSITORY_INFO_CREATOR_CLASS = "InMemoryServer.RepositoryInfoCreatorClass";
- public static final String REPOSITORY_CLASS = "InMemoryServer.Class";
- public static final String OVERRIDE_CALL_CONTEXT = "InMemoryServer.OverrideCallContext";
+ public static final String REPOSITORY_ID = "InMemoryServer.RepositoryId";
+ public static final String TYPE_CREATOR_CLASS = "InMemoryServer.TypesCreatorClass";
+ public static final String REPOSITORY_INFO_CREATOR_CLASS = "InMemoryServer.RepositoryInfoCreatorClass";
+ public static final String REPOSITORY_CLASS = "InMemoryServer.Class";
+ public static final String OVERRIDE_CALL_CONTEXT = "InMemoryServer.OverrideCallContext";
- // Helper constants that allow to fill a repository with data on
- // initialization
- public static final String USE_REPOSITORY_FILER = "RepositoryFiller.Enable";
- public static final String FILLER_DOCUMENT_TYPE_ID = "RepositoryFiller.DocumentTypeId";
- public static final String FILLER_FOLDER_TYPE_ID = "RepositoryFiller.FolderTypeId";
- public static final String FILLER_DOCS_PER_FOLDER = "RepositoryFiller.DocsPerFolder";
- public static final String FILLER_FOLDERS_PER_FOLDER = "RepositoryFiller.FolderPerFolder";
- public static final String FILLER_DEPTH = "RepositoryFiller.Depth";
- public static final String FILLER_CONTENT_SIZE = "RepositoryFiller.ContentSizeInKB";
- public static final String FILLER_DOCUMENT_PROPERTY = "RepositoryFiller.DocumentProperty.";
- public static final String FILLER_FOLDER_PROPERTY = "RepositoryFiller.FolderProperty.";
+ // Helper constants that allow to fill a repository with data on
+ // initialization
+ public static final String USE_REPOSITORY_FILER = "RepositoryFiller.Enable";
+ public static final String FILLER_DOCUMENT_TYPE_ID = "RepositoryFiller.DocumentTypeId";
+ public static final String FILLER_FOLDER_TYPE_ID = "RepositoryFiller.FolderTypeId";
+ public static final String FILLER_DOCS_PER_FOLDER = "RepositoryFiller.DocsPerFolder";
+ public static final String FILLER_FOLDERS_PER_FOLDER = "RepositoryFiller.FolderPerFolder";
+ public static final String FILLER_DEPTH = "RepositoryFiller.Depth";
+ public static final String FILLER_CONTENT_SIZE = "RepositoryFiller.ContentSizeInKB";
+ public static final String FILLER_DOCUMENT_PROPERTY = "RepositoryFiller.DocumentProperty.";
+ public static final String FILLER_FOLDER_PROPERTY = "RepositoryFiller.FolderProperty.";
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.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/DataObjectCreator.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/DataObjectCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java Thu Apr 22 16:27:57 2010
@@ -48,112 +48,112 @@ import org.apache.chemistry.opencmis.inm
*/
public class DataObjectCreator {
- public static AllowableActions fillAllowableActions(ObjectStore objStore, StoredObject so, String user) {
+ public static AllowableActions fillAllowableActions(ObjectStore objStore, StoredObject so, String user) {
- boolean isFolder = so instanceof Folder;
- boolean isDocument = so instanceof Content;
- boolean isCheckedOut = false;
- boolean canCheckOut = false;
- boolean canCheckIn = false;
- boolean isVersioned = so instanceof Version || so instanceof VersionedDocument;
- boolean hasContent = so instanceof Content && ((Content) so).hasContent();
-
- if (so instanceof Version) {
- isCheckedOut = ((Version) so).isPwc();
- canCheckIn = isCheckedOut && ((Version) so).getParentDocument().getCheckedOutBy().equals(user);
- } else if (so instanceof VersionedDocument) {
- isCheckedOut = ((VersionedDocument) so).isCheckedOut();
- canCheckOut = !((VersionedDocument) so).isCheckedOut();
- canCheckIn = isCheckedOut && ((VersionedDocument) so).getCheckedOutBy().equals(user);
- }
-
- AllowableActionsImpl allowableActions = new AllowableActionsImpl();
- Set<Action> set = allowableActions.getAllowableActions();
-
- set.add(Action.CAN_DELETE_OBJECT);
- set.add(Action.CAN_UPDATE_PROPERTIES);
-
- if (isFolder || isDocument) {
- set.add(Action.CAN_GET_PROPERTIES);
- if (!so.equals(objStore.getRootFolder())) {
- set.add(Action.CAN_GET_OBJECT_PARENTS);
- }
- set.add(Action.CAN_MOVE_OBJECT);
- }
-
- if (isFolder) {
- if (!so.equals(objStore.getRootFolder())) {
- set.add(Action.CAN_GET_FOLDER_PARENT);
- }
- set.add(Action.CAN_GET_FOLDER_TREE);
- set.add(Action.CAN_GET_DESCENDANTS);
-
- set.add(Action.CAN_ADD_OBJECT_TO_FOLDER);
- set.add(Action.CAN_REMOVE_OBJECT_FROM_FOLDER);
- set.add(Action.CAN_CREATE_DOCUMENT);
- set.add(Action.CAN_CREATE_FOLDER);
- set.add(Action.CAN_GET_CHILDREN);
- set.add(Action.CAN_DELETE_TREE);
- }
-
- if (hasContent) {
- set.add(Action.CAN_DELETE_CONTENT_STREAM);
- set.add(Action.CAN_GET_CONTENT_STREAM);
- }
-
- if (isVersioned) {
- if (canCheckOut) {
- set.add(Action.CAN_CHECK_OUT);
- }
- if (isCheckedOut) {
- set.add(Action.CAN_CANCEL_CHECK_OUT);
- }
- if (canCheckIn) {
- set.add(Action.CAN_CHECK_IN);
- }
- set.add(Action.CAN_GET_ALL_VERSIONS);
- }
-
- if (isDocument) {
- if (!isVersioned || canCheckIn) {
- set.add(Action.CAN_SET_CONTENT_STREAM);
- }
- }
-
- allowableActions.setAllowableActions(set);
- return allowableActions;
- }
-
- public static Acl fillACL(StoredObject so) {
- AccessControlListImpl acl = new AccessControlListImpl();
- List<Ace> aces = new ArrayList<Ace>();
- // TODO to be completed if ACLs are implemented
- acl.setAces(aces);
- return acl;
- }
-
- public static PolicyIdList fillPolicyIds(StoredObject so) {
- // TODO: to be completed if policies are implemented
- PolicyIdListImpl polIds = new PolicyIdListImpl();
- // polIds.setPolicyIds(...);
- return polIds;
- }
-
- public static List<ObjectData> fillRelationships(IncludeRelationships includeRelationships, StoredObject so) {
- // TODO: to be completed if relationships are implemented
- List<ObjectData> relationships = new ArrayList<ObjectData>();
- return relationships;
- }
-
- public static List<RenditionData> fillRenditions(StoredObject so) {
- // TODO: to be completed if renditions are implemented
- List<RenditionData> renditions = new ArrayList<RenditionData>();
- return renditions;
- }
-
- public static ChangeEventInfo fillChangeEventInfo(StoredObject so) {
- // TODO: to be completed if change information is implemented
- ChangeEventInfo changeEventInfo = new ChangeEventInfoDataImpl();
- return changeEventInfo;
- }
+ boolean isFolder = so instanceof Folder;
+ boolean isDocument = so instanceof Content;
+ boolean isCheckedOut = false;
+ boolean canCheckOut = false;
+ boolean canCheckIn = false;
+ boolean isVersioned = so instanceof Version || so instanceof VersionedDocument;
+ boolean hasContent = so instanceof Content && ((Content) so).hasContent();
+
+ if (so instanceof Version) {
+ isCheckedOut = ((Version) so).isPwc();
+ canCheckIn = isCheckedOut && ((Version) so).getParentDocument().getCheckedOutBy().equals(user);
+ } else if (so instanceof VersionedDocument) {
+ isCheckedOut = ((VersionedDocument) so).isCheckedOut();
+ canCheckOut = !((VersionedDocument) so).isCheckedOut();
+ canCheckIn = isCheckedOut && ((VersionedDocument) so).getCheckedOutBy().equals(user);
+ }
+
+ AllowableActionsImpl allowableActions = new AllowableActionsImpl();
+ Set<Action> set = allowableActions.getAllowableActions();
+
+ set.add(Action.CAN_DELETE_OBJECT);
+ set.add(Action.CAN_UPDATE_PROPERTIES);
+
+ if (isFolder || isDocument) {
+ set.add(Action.CAN_GET_PROPERTIES);
+ if (!so.equals(objStore.getRootFolder())) {
+ set.add(Action.CAN_GET_OBJECT_PARENTS);
+ }
+ set.add(Action.CAN_MOVE_OBJECT);
+ }
+
+ if (isFolder) {
+ if (!so.equals(objStore.getRootFolder())) {
+ set.add(Action.CAN_GET_FOLDER_PARENT);
+ }
+ set.add(Action.CAN_GET_FOLDER_TREE);
+ set.add(Action.CAN_GET_DESCENDANTS);
+
+ set.add(Action.CAN_ADD_OBJECT_TO_FOLDER);
+ set.add(Action.CAN_REMOVE_OBJECT_FROM_FOLDER);
+ set.add(Action.CAN_CREATE_DOCUMENT);
+ set.add(Action.CAN_CREATE_FOLDER);
+ set.add(Action.CAN_GET_CHILDREN);
+ set.add(Action.CAN_DELETE_TREE);
+ }
+
+ if (hasContent) {
+ set.add(Action.CAN_DELETE_CONTENT_STREAM);
+ set.add(Action.CAN_GET_CONTENT_STREAM);
+ }
+
+ if (isVersioned) {
+ if (canCheckOut) {
+ set.add(Action.CAN_CHECK_OUT);
+ }
+ if (isCheckedOut) {
+ set.add(Action.CAN_CANCEL_CHECK_OUT);
+ }
+ if (canCheckIn) {
+ set.add(Action.CAN_CHECK_IN);
+ }
+ set.add(Action.CAN_GET_ALL_VERSIONS);
+ }
+
+ if (isDocument) {
+ if (!isVersioned || canCheckIn) {
+ set.add(Action.CAN_SET_CONTENT_STREAM);
+ }
+ }
+
+ allowableActions.setAllowableActions(set);
+ return allowableActions;
+ }
+
+ public static Acl fillACL(StoredObject so) {
+ AccessControlListImpl acl = new AccessControlListImpl();
+ List<Ace> aces = new ArrayList<Ace>();
+ // TODO to be completed if ACLs are implemented
+ acl.setAces(aces);
+ return acl;
+ }
+
+ public static PolicyIdList fillPolicyIds(StoredObject so) {
+ // TODO: to be completed if policies are implemented
+ PolicyIdListImpl polIds = new PolicyIdListImpl();
+ // polIds.setPolicyIds(...);
+ return polIds;
+ }
+
+ public static List<ObjectData> fillRelationships(IncludeRelationships includeRelationships, StoredObject so) {
+ // TODO: to be completed if relationships are implemented
+ List<ObjectData> relationships = new ArrayList<ObjectData>();
+ return relationships;
+ }
+
+ public static List<RenditionData> fillRenditions(StoredObject so) {
+ // TODO: to be completed if renditions are implemented
+ List<RenditionData> renditions = new ArrayList<RenditionData>();
+ return renditions;
+ }
+
+ public static ChangeEventInfo fillChangeEventInfo(StoredObject so) {
+ // TODO: to be completed if change information is implemented
+ ChangeEventInfo changeEventInfo = new ChangeEventInfoDataImpl();
+ return changeEventInfo;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.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/DummyCallContext.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/DummyCallContext.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java Thu Apr 22 16:27:57 2010
@@ -6,43 +6,43 @@ import java.util.Map;
import org.apache.chemistry.opencmis.commons.api.server.CallContext;
public class DummyCallContext implements CallContext {
- private Map<String, String> fParameter = new HashMap<String, String>();
+ private Map<String, String> fParameter = new HashMap<String, String>();
- public DummyCallContext() {
- fParameter.put(USERNAME, "TestUser");
- fParameter.put(PASSWORD, "secret");
- fParameter.put(LOCALE, "en");
- }
-
- public boolean isObjectInfoRequired() {
- return false;
- }
-
- public String get(String key) {
- return fParameter.get(key);
- }
-
- public String getBinding() {
- return BINDING_ATOMPUB;
- }
-
- public String getRepositoryId() {
- return get(REPOSITORY_ID);
- }
-
- public String getLocale() {
- return get(LOCALE);
- }
-
- public String getPassword() {
- return get(PASSWORD);
- }
-
- public String getUsername() {
- return get(USERNAME);
- }
-
- public void put(String key, String value) {
- fParameter.put(key, value);
- }
+ public DummyCallContext() {
+ fParameter.put(USERNAME, "TestUser");
+ fParameter.put(PASSWORD, "secret");
+ fParameter.put(LOCALE, "en");
+ }
+
+ public boolean isObjectInfoRequired() {
+ return false;
+ }
+
+ public String get(String key) {
+ return fParameter.get(key);
+ }
+
+ public String getBinding() {
+ return BINDING_ATOMPUB;
+ }
+
+ public String getRepositoryId() {
+ return get(REPOSITORY_ID);
+ }
+
+ public String getLocale() {
+ return get(LOCALE);
+ }
+
+ public String getPassword() {
+ return get(PASSWORD);
+ }
+
+ public String getUsername() {
+ return get(USERNAME);
+ }
+
+ public void put(String key, String value) {
+ fParameter.put(key, value);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.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/FilterParser.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/FilterParser.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java Thu Apr 22 16:27:57 2010
@@ -28,23 +28,23 @@ import java.util.List;
public class FilterParser {
- public static boolean isContainedInFilter(String propertyId, List<String> requestedIds) {
- if (requestedIds.contains("*"))
- return true;
- return requestedIds.contains(propertyId);
- }
+ public static boolean isContainedInFilter(String propertyId, List<String> requestedIds) {
+ if (requestedIds.contains("*"))
+ return true;
+ return requestedIds.contains(propertyId);
+ }
- public static List<String> getRequestedIdsFromFilter(String filter) {
- if (filter == null || filter.length() == 0)
- return Collections.singletonList("*");
- else {
- List<String> requestedIds = Arrays.asList(filter.split(",\\s*")); // comma
- // plus
- // whitespace
- if (requestedIds.contains("*"))
- requestedIds = Collections.singletonList("*");
- return requestedIds;
- }
- }
+ public static List<String> getRequestedIdsFromFilter(String filter) {
+ if (filter == null || filter.length() == 0)
+ return Collections.singletonList("*");
+ else {
+ List<String> requestedIds = Arrays.asList(filter.split(",\\s*")); // comma
+ // plus
+ // whitespace
+ if (requestedIds.contains("*"))
+ requestedIds = Collections.singletonList("*");
+ return requestedIds;
+ }
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.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/NameValidator.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/NameValidator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.java Thu Apr 22 16:27:57 2010
@@ -20,57 +20,57 @@
package org.apache.chemistry.opencmis.inmemory;
public class NameValidator {
- public static final String ERROR_ILLEGAL_ID = "Id contains illegal characters, allowed are 'a'..'z', 'A'..'Z', '0'..'9', '-', '_'";
+ public static final String ERROR_ILLEGAL_ID = "Id contains illegal characters, allowed are 'a'..'z', 'A'..'Z', '0'..'9', '-', '_'";
- public static final String ERROR_ILLEGAL_NAME = "Id contains illegal characters, allowed are 'a'..'z', 'A'..'Z', '0'..'9', '-', '_', '.', ' '";
+ public static final String ERROR_ILLEGAL_NAME = "Id contains illegal characters, allowed are 'a'..'z', 'A'..'Z', '0'..'9', '-', '_', '.', ' '";
- /**
- * check whether id contains only valid characters Allowed are 'a'..'z',
- * 'A'..'Z', '0'..'9', '.', '-', ' ', '_';
- *
- * @param s
- * string to verify
- */
- static public boolean isValidId(String s) {
- if (s.startsWith("cmis:"))
- s = s.substring(5);
-
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-'
- || c == '_' || c == ' '))
- return false;
- }
- return true;
- }
-
- static public boolean isValidLocalName(String s) {
- return isValidId(s);
- }
-
- /**
- * check whether id contains only valid characters Allowed are 'a'..'z',
- * 'A'..'Z', '0'..'9', '.', '-', ' ', '_';
- *
- * @param s
- * string to verify
- */
- static public boolean isValidName(String s) {
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-'
- || c == '_' || c == ' '))
- return false;
- }
- return true;
- }
-
- static public boolean isValidNamespace(String s) {
- return isValidId(s);
- }
-
- static public boolean isValidQueryName(String s) {
- return isValidId(s);
- }
+ /**
+ * check whether id contains only valid characters Allowed are 'a'..'z',
+ * 'A'..'Z', '0'..'9', '.', '-', ' ', '_';
+ *
+ * @param s
+ * string to verify
+ */
+ static public boolean isValidId(String s) {
+ if (s.startsWith("cmis:"))
+ s = s.substring(5);
+
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-'
+ || c == '_' || c == ' '))
+ return false;
+ }
+ return true;
+ }
+
+ static public boolean isValidLocalName(String s) {
+ return isValidId(s);
+ }
+
+ /**
+ * check whether id contains only valid characters Allowed are 'a'..'z',
+ * 'A'..'Z', '0'..'9', '.', '-', ' ', '_';
+ *
+ * @param s
+ * string to verify
+ */
+ static public boolean isValidName(String s) {
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-'
+ || c == '_' || c == ' '))
+ return false;
+ }
+ return true;
+ }
+
+ static public boolean isValidNamespace(String s) {
+ return isValidId(s);
+ }
+
+ static public boolean isValidQueryName(String s) {
+ return isValidId(s);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/RepositoryInfoCreator.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/RepositoryInfoCreator.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/RepositoryInfoCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/RepositoryInfoCreator.java Thu Apr 22 16:27:57 2010
@@ -30,5 +30,5 @@ import org.apache.chemistry.opencmis.com
*
*/
public interface RepositoryInfoCreator {
- RepositoryInfo createRepositoryInfo();
+ RepositoryInfo createRepositoryInfo();
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeCreator.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/TypeCreator.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/TypeCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeCreator.java Thu Apr 22 16:27:57 2010
@@ -33,5 +33,5 @@ import org.apache.chemistry.opencmis.com
*/
public interface TypeCreator {
- List<TypeDefinition> createTypesList();
+ List<TypeDefinition> createTypesList();
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManager.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/TypeManager.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/TypeManager.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManager.java Thu Apr 22 16:27:57 2010
@@ -47,185 +47,185 @@ import org.apache.chemistry.opencmis.inm
*/
public class TypeManager {
- /**
- * map from repository id to a types map
- */
- private Map<String, TypeDefinitionContainer> fTypesMap = new HashMap<String, TypeDefinitionContainer>();
-
- /**
- * return a type definition from the type definition id
- *
- * @param typeId
- * id of the type definition
- * @return type definition for this id
- */
- public TypeDefinitionContainer getTypeById(String typeId) {
- return fTypesMap.get(typeId);
- }
-
- /**
- * return a list of all types known in this repository
- *
- * @return
- */
- public synchronized Collection<TypeDefinitionContainer> getTypeDefinitionList() {
-
- List<TypeDefinitionContainer> typeRoots = new ArrayList<TypeDefinitionContainer>();
- // iterate types map and return a list collecting the root types:
- for (TypeDefinitionContainer typeDef : fTypesMap.values()) {
- if (typeDef.getTypeDefinition().getParentTypeId() == null)
- typeRoots.add(typeDef);
- }
-
- return typeRoots;
- }
-
- /**
- * return a list of the root types as defined in the CMIS spec (for
- * document, folder, policy and relationship
- *
- * @return
- */
- public List<TypeDefinitionContainer> getRootTypes() {
- // just take first repository
- List<TypeDefinitionContainer> rootTypes = new ArrayList<TypeDefinitionContainer>();
-
- for (TypeDefinitionContainer type : fTypesMap.values())
- if (isRootType(type))
- rootTypes.add(type);
-
- return rootTypes;
- }
-
- /**
- * Initialize the type system with the given types. This list must not
- * contain the CMIS default types. The default type are always contained by
- * default.
- *
- * @param typesList
- * list of types to add to the repository
- *
- */
- public void initTypeSystem(List<TypeDefinition> typesList) {
-
- createCmisDefaultTypes();
-
- // merge all types from the list and build the correct hierachy with
- // children
- // and property lists
- if (null != typesList) {
- for (TypeDefinition typeDef : typesList)
- addTypeDefinition(typeDef);
- }
-
- }
-
- /**
- * Add a type to the type system. Add all properties from inherited types,
- * add type to children of parent types.
- *
- * @param repositoryId
- * repository to which the type is added
- * @param cmisType
- * new type to add
- */
- public void addTypeDefinition(TypeDefinition cmisType) {
- if (fTypesMap.containsKey(cmisType.getId()))
- throw new RuntimeException("You cannot add type with id " + cmisType.getId()
- + " because it already exists.");
-
- TypeDefinitionContainerImpl typeContainer = new TypeDefinitionContainerImpl(cmisType);
-
- if (!fTypesMap.containsKey(cmisType.getParentTypeId()))
- throw new RuntimeException("Cannot add type, because parent with id " + cmisType.getParentTypeId()
- + " does not exist.");
-
- // add new type to children of parent types
- TypeDefinitionContainer parentTypeContainer = fTypesMap.get(cmisType.getParentTypeId());
- parentTypeContainer.getChildren().add(typeContainer);
-
- // recursively add inherited properties
- Map<String, PropertyDefinition<?>> propDefs = typeContainer.getTypeDefinition().getPropertyDefinitions();
- addInheritedProperties(propDefs, parentTypeContainer.getTypeDefinition());
-
- // add type to type map
- fTypesMap.put(cmisType.getId(), typeContainer);
- }
-
- /**
- * Remove all types from the type system. After this call only the default
- * CMIS types are present in the type system. Use this method with care, its
- * mainly intended for unit tests
- *
- * @param repositoryId
- */
- public void clearTypeSystem() {
- fTypesMap.clear();
- createCmisDefaultTypes();
- }
-
- private void addInheritedProperties(Map<String, PropertyDefinition<?>> propDefs, TypeDefinition typeDefinition) {
-
- if (null == typeDefinition)
- return;
-
- if (null != typeDefinition.getPropertyDefinitions())
- addInheritedPropertyDefinitions(propDefs, typeDefinition.getPropertyDefinitions());
- // propDefs.putAll(typeDefinition.getPropertyDefinitions());
-
- TypeDefinitionContainer parentTypeContainer = fTypesMap.get(typeDefinition.getParentTypeId());
- TypeDefinition parentType = (null == parentTypeContainer ? null : parentTypeContainer.getTypeDefinition());
- addInheritedProperties(propDefs, parentType);
- }
-
- private void addInheritedPropertyDefinitions(Map<String, PropertyDefinition<?>> propDefs,
- Map<String, PropertyDefinition<?>> superPropDefs) {
-
- for (Entry<String, PropertyDefinition<?>> superProp : superPropDefs.entrySet()) {
- PropertyDefinition<?> superPropDef = superProp.getValue();
- PropertyDefinition<?> clone = clonePropertyDefinition(superPropDef);
- ((AbstractPropertyDefinition<?>) clone).setIsInherited(true);
- propDefs.put(superProp.getKey(), clone);
- }
- }
-
- private void createCmisDefaultTypes() {
- List<TypeDefinition> typesList = DocumentTypeCreationHelper.createDefaultTypes();
- for (TypeDefinition typeDef : typesList) {
- TypeDefinitionContainerImpl typeContainer = new TypeDefinitionContainerImpl(typeDef);
- fTypesMap.put(typeDef.getId(), typeContainer);
- }
- }
-
- private static boolean isRootType(TypeDefinitionContainer c) {
- if (c.getTypeDefinition().equals(InMemoryFolderTypeDefinition.getRootFolderType())
- || c.getTypeDefinition().equals(InMemoryDocumentTypeDefinition.getRootDocumentType())
- || c.getTypeDefinition().equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType())
- || c.getTypeDefinition().equals(InMemoryPolicyTypeDefinition.getRootPolicyType()))
- return true;
- else
- return false;
- }
-
- private static PropertyDefinition<?> clonePropertyDefinition(PropertyDefinition<?> src) {
- // use JAXB converter to easily clone a property definition
- CmisPropertyDefinitionType tmp = Converter.convert(src);
- PropertyDefinition<?> clone = Converter.convert(tmp);
- return clone;
- }
-
- // private static PropertyDefinition<?>
- // clonePropertyDefinition2(PropertyDefinition<?> src)
- // throws IOException, ClassNotFoundException {
- // ByteArrayOutputStream bout = new ByteArrayOutputStream();
- // ObjectOutputStream oout = new ObjectOutputStream(bout);
- // oout.writeObject(src);
- // byte[] bytes = bout.toByteArray();
- //
- // ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
- // ObjectInputStream oin = new ObjectInputStream(bin);
- // PropertyDefinition<?> clone = (PropertyDefinition<?>) oin.readObject();
- // return clone;
- // }
+ /**
+ * map from repository id to a types map
+ */
+ private Map<String, TypeDefinitionContainer> fTypesMap = new HashMap<String, TypeDefinitionContainer>();
+
+ /**
+ * return a type definition from the type definition id
+ *
+ * @param typeId
+ * id of the type definition
+ * @return type definition for this id
+ */
+ public TypeDefinitionContainer getTypeById(String typeId) {
+ return fTypesMap.get(typeId);
+ }
+
+ /**
+ * return a list of all types known in this repository
+ *
+ * @return
+ */
+ public synchronized Collection<TypeDefinitionContainer> getTypeDefinitionList() {
+
+ List<TypeDefinitionContainer> typeRoots = new ArrayList<TypeDefinitionContainer>();
+ // iterate types map and return a list collecting the root types:
+ for (TypeDefinitionContainer typeDef : fTypesMap.values()) {
+ if (typeDef.getTypeDefinition().getParentTypeId() == null)
+ typeRoots.add(typeDef);
+ }
+
+ return typeRoots;
+ }
+
+ /**
+ * return a list of the root types as defined in the CMIS spec (for
+ * document, folder, policy and relationship
+ *
+ * @return
+ */
+ public List<TypeDefinitionContainer> getRootTypes() {
+ // just take first repository
+ List<TypeDefinitionContainer> rootTypes = new ArrayList<TypeDefinitionContainer>();
+
+ for (TypeDefinitionContainer type : fTypesMap.values())
+ if (isRootType(type))
+ rootTypes.add(type);
+
+ return rootTypes;
+ }
+
+ /**
+ * Initialize the type system with the given types. This list must not
+ * contain the CMIS default types. The default type are always contained by
+ * default.
+ *
+ * @param typesList
+ * list of types to add to the repository
+ *
+ */
+ public void initTypeSystem(List<TypeDefinition> typesList) {
+
+ createCmisDefaultTypes();
+
+ // merge all types from the list and build the correct hierachy with
+ // children
+ // and property lists
+ if (null != typesList) {
+ for (TypeDefinition typeDef : typesList)
+ addTypeDefinition(typeDef);
+ }
+
+ }
+
+ /**
+ * Add a type to the type system. Add all properties from inherited types,
+ * add type to children of parent types.
+ *
+ * @param repositoryId
+ * repository to which the type is added
+ * @param cmisType
+ * new type to add
+ */
+ public void addTypeDefinition(TypeDefinition cmisType) {
+ if (fTypesMap.containsKey(cmisType.getId()))
+ throw new RuntimeException("You cannot add type with id " + cmisType.getId()
+ + " because it already exists.");
+
+ TypeDefinitionContainerImpl typeContainer = new TypeDefinitionContainerImpl(cmisType);
+
+ if (!fTypesMap.containsKey(cmisType.getParentTypeId()))
+ throw new RuntimeException("Cannot add type, because parent with id " + cmisType.getParentTypeId()
+ + " does not exist.");
+
+ // add new type to children of parent types
+ TypeDefinitionContainer parentTypeContainer = fTypesMap.get(cmisType.getParentTypeId());
+ parentTypeContainer.getChildren().add(typeContainer);
+
+ // recursively add inherited properties
+ Map<String, PropertyDefinition<?>> propDefs = typeContainer.getTypeDefinition().getPropertyDefinitions();
+ addInheritedProperties(propDefs, parentTypeContainer.getTypeDefinition());
+
+ // add type to type map
+ fTypesMap.put(cmisType.getId(), typeContainer);
+ }
+
+ /**
+ * Remove all types from the type system. After this call only the default
+ * CMIS types are present in the type system. Use this method with care, its
+ * mainly intended for unit tests
+ *
+ * @param repositoryId
+ */
+ public void clearTypeSystem() {
+ fTypesMap.clear();
+ createCmisDefaultTypes();
+ }
+
+ private void addInheritedProperties(Map<String, PropertyDefinition<?>> propDefs, TypeDefinition typeDefinition) {
+
+ if (null == typeDefinition)
+ return;
+
+ if (null != typeDefinition.getPropertyDefinitions())
+ addInheritedPropertyDefinitions(propDefs, typeDefinition.getPropertyDefinitions());
+ // propDefs.putAll(typeDefinition.getPropertyDefinitions());
+
+ TypeDefinitionContainer parentTypeContainer = fTypesMap.get(typeDefinition.getParentTypeId());
+ TypeDefinition parentType = (null == parentTypeContainer ? null : parentTypeContainer.getTypeDefinition());
+ addInheritedProperties(propDefs, parentType);
+ }
+
+ private void addInheritedPropertyDefinitions(Map<String, PropertyDefinition<?>> propDefs,
+ Map<String, PropertyDefinition<?>> superPropDefs) {
+
+ for (Entry<String, PropertyDefinition<?>> superProp : superPropDefs.entrySet()) {
+ PropertyDefinition<?> superPropDef = superProp.getValue();
+ PropertyDefinition<?> clone = clonePropertyDefinition(superPropDef);
+ ((AbstractPropertyDefinition<?>) clone).setIsInherited(true);
+ propDefs.put(superProp.getKey(), clone);
+ }
+ }
+
+ private void createCmisDefaultTypes() {
+ List<TypeDefinition> typesList = DocumentTypeCreationHelper.createDefaultTypes();
+ for (TypeDefinition typeDef : typesList) {
+ TypeDefinitionContainerImpl typeContainer = new TypeDefinitionContainerImpl(typeDef);
+ fTypesMap.put(typeDef.getId(), typeContainer);
+ }
+ }
+
+ private static boolean isRootType(TypeDefinitionContainer c) {
+ if (c.getTypeDefinition().equals(InMemoryFolderTypeDefinition.getRootFolderType())
+ || c.getTypeDefinition().equals(InMemoryDocumentTypeDefinition.getRootDocumentType())
+ || c.getTypeDefinition().equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType())
+ || c.getTypeDefinition().equals(InMemoryPolicyTypeDefinition.getRootPolicyType()))
+ return true;
+ else
+ return false;
+ }
+
+ private static PropertyDefinition<?> clonePropertyDefinition(PropertyDefinition<?> src) {
+ // use JAXB converter to easily clone a property definition
+ CmisPropertyDefinitionType tmp = Converter.convert(src);
+ PropertyDefinition<?> clone = Converter.convert(tmp);
+ return clone;
+ }
+
+ // private static PropertyDefinition<?>
+ // clonePropertyDefinition2(PropertyDefinition<?> src)
+ // throws IOException, ClassNotFoundException {
+ // ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ // ObjectOutputStream oout = new ObjectOutputStream(bout);
+ // oout.writeObject(src);
+ // byte[] bytes = bout.toByteArray();
+ //
+ // ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+ // ObjectInputStream oin = new ObjectInputStream(bin);
+ // PropertyDefinition<?> clone = (PropertyDefinition<?>) oin.readObject();
+ // return clone;
+ // }
}