This project has retired. For details please refer to its
Attic page.
InMemoryFolderTypeDefinition 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.exceptions.CmisInvalidArgumentException;
28import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
29import org.apache.chemistry.opencmis.inmemory.NameValidator;
3031publicclassInMemoryFolderTypeDefinitionextends FolderTypeDefinitionImpl {
3233privatestaticfinallong serialVersionUID = 1L;
34privatestaticfinalInMemoryFolderTypeDefinition FOLDER_TYPE = newInMemoryFolderTypeDefinition();
3536publicstaticInMemoryFolderTypeDefinition getRootFolderType() {
37return FOLDER_TYPE;
38 }
3940/* This constructor is just for creating the root document */41publicInMemoryFolderTypeDefinition() {
42 init(BaseTypeId.CMIS_FOLDER.value(), "CMIS Folder");
43 setParentTypeId(null);
44// set base properties45 Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
46 DocumentTypeCreationHelper.setBasicFolderPropertyDefinitions(props);
47 }
4849publicInMemoryFolderTypeDefinition(String id, String displayName) {
50 init(id, displayName);
51 setParentTypeId(FOLDER_TYPE.getId());
52 }
5354publicInMemoryFolderTypeDefinition(String id, String displayName, InMemoryFolderTypeDefinition parentType) {
55// get root type56 init(id, displayName);
57if (parentType != null) {
58 setBaseTypeId(parentType.getBaseTypeId());
59 } else {
60thrownew IllegalArgumentException("Must provide a parent type when creating a folder type definition");
61 }
62 setParentTypeId(parentType.getId());
63 }
6465/**66 * Set the property definitions for this type. The parameter67 * propertyDefinitions should only contain the custom property definitions68 * for this type. The standard property definitions are added automatically.69 *70 * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#71 * setPropertyDefinitions(java.util.Map)72 */73publicvoid addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
74 DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
75 }
7677privatevoid init(String id, String displayName) {
78if (!NameValidator.isValidId(id)) {
79thrownew CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
80 }
8182 setBaseTypeId(BaseTypeId.CMIS_FOLDER);
83 setId(id);
84if (displayName == null) {
85 displayName = id;
86 }
87 setDisplayName(displayName);
88// create some suitable defaults for convenience89 setDescription("Description of " + getDisplayName() + " Type");
90 setLocalName(id);
91 setLocalNamespace("local");
92 setQueryName(id);
93 setIsControllableAcl(true);
94 setIsControllablePolicy(false);
95 setIsCreatable(true);
96 setIsFileable(true);
97 setIsFulltextIndexed(false);
98 setIsIncludedInSupertypeQuery(true);
99 setIsQueryable(false);
100101// TODO: add with CMIS 1.1 extensions102// TypeMutabilityCapabilitiesImpl caps = new TypeMutabilityCapabilitiesImpl();103// caps.setSupportsCreate(createAndDeletable);104// caps.setSupportsUpdate(false);105// caps.setSupportsDelete(createAndDeletable);106// super.setTypeMutability(caps);107108 Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
109 setPropertyDefinitions(props); // set initial empty set of properties110 }
111 }