This project has retired. For details please refer to its
Attic page.
InMemoryDocumentTypeDefinition xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */1920package org.apache.chemistry.opencmis.inmemory.types;
2122import java.util.HashMap;
23import java.util.Map;
2425import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
26import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
27import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
28import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
29import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
30import org.apache.chemistry.opencmis.inmemory.NameValidator;
3132/**33 * A small convenience class simplifying document type creation34 */35publicclassInMemoryDocumentTypeDefinitionextends DocumentTypeDefinitionImpl {
3637privatestaticfinallong serialVersionUID = 1L;
38privatestaticfinalInMemoryDocumentTypeDefinition DOCUMENT_TYPE = newInMemoryDocumentTypeDefinition();
3940publicstaticInMemoryDocumentTypeDefinition getRootDocumentType() {
41return DOCUMENT_TYPE;
42 }
4344/* This constructor is just for creating the root document */45publicInMemoryDocumentTypeDefinition() {
46 init(BaseTypeId.CMIS_DOCUMENT.value(), "CMIS Document");
47 setParentTypeId(null);
48// set base properties49 Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
50 DocumentTypeCreationHelper.setBasicDocumentPropertyDefinitions(props);
51 }
5253publicInMemoryDocumentTypeDefinition(String id, String displayName) {
54 init(id, displayName);
55 setParentTypeId(DOCUMENT_TYPE.getId());
56 }
5758publicInMemoryDocumentTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
59// get root type60 init(id, displayName);
61if (parentType != null) {
62 setBaseTypeId(parentType.getBaseTypeId());
63 } else {
64thrownew IllegalArgumentException("Must provide a parent type when creating a document type definition");
65 }
66 setParentTypeId(parentType.getId());
67 }
6869/**70 * Set the property definitions for this type. The parameter71 * propertyDefinitions should only contain the custom property definitions72 * for this type. The standard property definitions are added automatically.73 *74 * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#75 * setPropertyDefinitions(java.util.Map)76 */77publicvoid addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
78 DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
79 }
8081privatevoid init(String id, String displayName) {
82if (!NameValidator.isValidId(id)) {
83thrownew CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_ID);
84 }
8586 setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
87 setId(id);
88if (displayName == null) {
89 displayName = id;
90 }
91 setDisplayName(displayName);
92// create some suitable defaults for convenience93 setDescription("Description of " + getDisplayName() + " Type");
94 setLocalName(id);
95 setLocalNamespace("local");
96 setQueryName(id);
97 setIsControllableAcl(true);
98 setIsControllablePolicy(false);
99 setIsCreatable(true);
100 setIsFileable(true);
101 setIsFulltextIndexed(false);
102 setIsIncludedInSupertypeQuery(true);
103 setIsQueryable(false);
104105// TODO: add with CMIS 1.1 extensions106// TypeMutabilityCapabilitiesImpl caps = new TypeMutabilityCapabilitiesImpl();107// caps.setSupportsCreate(createAndDeletable);108// caps.setSupportsUpdate(false);109// caps.setSupportsDelete(createAndDeletable);110// super.setTypeMutability(caps);111112 Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
113 setPropertyDefinitions(props); // set initial empty set of properties114115// document specifics:116 setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
117 setIsVersionable(false);
118 }
119 }