Commit 27a75808f14de41154b7a817599b004d88d86e8d

Authored by Alex Mukha
1 parent dfb90aa720
Exists in master

Transfer code from svn to gitlab.alfresco.com

Showing 461 changed files with 140356 additions and 0 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 461 files displayed.

File was created 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2 <modelVersion>4.0.0</modelVersion>
3 <artifactId>alfresco-data-model</artifactId>
4 <name>Alfresco Data model classes</name>
5 <parent>
6 <artifactId>alfresco-parent</artifactId>
7 <groupId>org.alfresco</groupId>
8 <version>5.2.1-SNAPSHOT</version>
9 <relativePath>../../pom.xml</relativePath>
10 </parent>
11
12 <properties>
13 <!-- Files to exclude from SonarQube analysis -->
14 <sonar.exclusions>
15 source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java,
16 source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java,
17 source/java/org/alfresco/repo/search/impl/parsers/FTSLexer.java
18 </sonar.exclusions>
19
20 </properties>
21
22 <build>
23 <plugins>
24 <plugin>
25 <groupId>org.jibx</groupId>
26 <artifactId>maven-jibx-plugin</artifactId>
27 <configuration>
28 <load>true</load>
29 <schemaBindingDirectory>${project.build.sourceDirectory}/org/alfresco/repo/dictionary</schemaBindingDirectory>
30 <includeSchemaBindings>
31 <includeSchemaBinding>m2binding.xml</includeSchemaBinding>
32 </includeSchemaBindings>
33 </configuration>
34 <executions>
35 <execution>
36 <id>bind-sources</id>
37 <goals>
38 <goal>bind</goal>
39 </goals>
40 </execution>
41 </executions>
42 </plugin>
43
44 <!-- ACE-3329 Create _en.properties message files -->
45 <plugin>
46 <artifactId>maven-antrun-plugin</artifactId>
47 <executions>
48 <execution>
49 <id>duplicate-english-messages</id>
50 <phase>generate-resources</phase>
51 <goals>
52 <goal>run</goal>
53 </goals>
54 </execution>
55 </executions>
56 <configuration>
57 <target>
58 <copy todir="${project.build.outputDirectory}">
59 <fileset dir="${basedir}/config" includes="alfresco/messages/**/*.properties" />
60 <mapper type="regexp" from="^([^_]*).properties$" to="\1_en.properties"/>
61 </copy>
62 </target>
63 </configuration>
64 </plugin>
65 </plugins>
66
67 <pluginManagement>
68 <plugins>
69 <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
70 <plugin>
71 <groupId>org.eclipse.m2e</groupId>
72 <artifactId>lifecycle-mapping</artifactId>
73 <version>1.0.0</version>
74 <configuration>
75 <lifecycleMappingMetadata>
76 <pluginExecutions>
77 <pluginExecution>
78 <pluginExecutionFilter>
79 <groupId>org.jibx</groupId>
80 <artifactId>
81 maven-jibx-plugin
82 </artifactId>
83 <versionRange>
84 [1.2.5,)
85 </versionRange>
86 <goals>
87 <goal>bind</goal>
88 </goals>
89 </pluginExecutionFilter>
90 <action>
91 <execute>
92 <runOnConfiguration>true</runOnConfiguration>
93 <runOnIncremental>true</runOnIncremental>
94 </execute>
95 </action>
96 </pluginExecution>
97 </pluginExecutions>
98 </lifecycleMappingMetadata>
99 </configuration>
100 </plugin>
101 </plugins>
102 </pluginManagement>
103 </build>
104
105 <dependencies>
106 <dependency>
107 <groupId>org.alfresco</groupId>
108 <artifactId>alfresco-core</artifactId>
109 </dependency>
110 <!--
111 | provided dependencies (are not transitive and not included in webapps)
112 | see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
113 -->
114 <dependency>
115 <groupId>javax.servlet</groupId>
116 <artifactId>servlet-api</artifactId>
117 <scope>provided</scope>
118 </dependency>
119 <!--
120 | compile dependencies
121 -->
122 <dependency>
123 <groupId>jaxen</groupId>
124 <artifactId>jaxen</artifactId>
125 </dependency>
126 <dependency>
127 <groupId>org.jibx</groupId>
128 <artifactId>jibx-run</artifactId>
129 <version>${dependency.jibx.version}</version>
130 </dependency>
131
132 <dependency>
133 <groupId>org.antlr</groupId>
134 <artifactId>antlr</artifactId>
135 <version>${dependency.antlr.version}</version>
136 </dependency>
137 <dependency>
138 <groupId>org.apache.chemistry.opencmis</groupId>
139 <artifactId>chemistry-opencmis-client-impl</artifactId>
140 <version>${dependency.opencmis.version}</version><!--$NO-MVN-MAN-VER$-->
141 <exclusions>
142 <exclusion>
143 <groupId>junit</groupId>
144 <artifactId>junit</artifactId>
145 </exclusion>
146 <exclusion>
147 <groupId>org.jvnet.staxex</groupId>
148 <artifactId>stax-ex</artifactId>
149 </exclusion>
150 </exclusions>
151 </dependency>
152 <dependency>
153 <groupId>org.apache.chemistry.opencmis</groupId>
154 <artifactId>chemistry-opencmis-commons-impl</artifactId>
155 <version>${dependency.opencmis.version}</version>
156 <exclusions>
157 <exclusion>
158 <groupId>com.sun.xml.messaging.saaj</groupId>
159 <artifactId>saaj-impl</artifactId>
160 </exclusion>
161 <exclusion>
162 <groupId>org.jvnet.staxex</groupId>
163 <artifactId>stax-ex</artifactId>
164 </exclusion>
165 </exclusions>
166 </dependency>
167 <!-- stax-ex is exluded from chemistry and included here, to avoid making constant requests to the repo -->
168 <!-- That's becausde the chemistry-pulled one does not specify a specific version -->
169 <dependency>
170 <groupId>org.jvnet.staxex</groupId>
171 <artifactId>stax-ex</artifactId>
172 <version>1.2</version>
173 </dependency>
174 <dependency>
175 <groupId>org.apache.chemistry.opencmis</groupId>
176 <artifactId>chemistry-opencmis-server-bindings</artifactId>
177 <version>${dependency.opencmis.version}</version>
178 <exclusions>
179 <exclusion>
180 <groupId>org.jvnet.staxex</groupId>
181 <artifactId>stax-ex</artifactId>
182 </exclusion>
183 </exclusions>
184 </dependency>
185 <dependency>
186 <groupId>org.codehaus.woodstox</groupId>
187 <artifactId>woodstox-core-asl</artifactId>
188 <version>4.2.0</version>
189 </dependency>
190 <!-- This is now deployed at:
191 | http://artifacts.alfresco.com/nexus/content/repositories/thirdparty/org/acegisecurity/acegi-security/0.8.2_patched/
192 -->
193 <dependency>
194 <groupId>org.acegisecurity</groupId>
195 <artifactId>acegi-security</artifactId>
196 <version>0.8.2_patched</version>
197 </dependency>
198 <dependency>
199 <groupId>org.alfresco</groupId>
200 <artifactId>alfresco-xmlfactory</artifactId>
201 </dependency>
202 <dependency>
203 <groupId>xpp3</groupId>
204 <artifactId>xpp3</artifactId>
205 <version>1.1.3_8</version>
206 </dependency>
207 <!-- Tika -->
208 <dependency>
209 <groupId>org.apache.tika</groupId>
210 <artifactId>tika-core</artifactId>
211 <version>${dependency.tika.version}</version>
212 </dependency>
213 <dependency>
214 <groupId>org.apache.tika</groupId>
215 <artifactId>tika-parsers</artifactId>
216 <version>${dependency.tika.version}</version>
217 </dependency>
218 <dependency>
219 <groupId>org.gagravarr</groupId>
220 <artifactId>vorbis-java-core</artifactId>
221 <version>${dependency.vorbisJava.version}</version>
222 </dependency>
223 <dependency>
224 <groupId>org.gagravarr</groupId>
225 <artifactId>vorbis-java-tika</artifactId>
226 <version>${dependency.vorbisJava.version}</version>
227 </dependency>
228 <dependency>
229 <groupId>com.googlecode.juniversalchardet</groupId>
230 <artifactId>juniversalchardet</artifactId>
231 <version>1.0.3</version>
232 </dependency>
233
234 <!-- Test dependencies -->
235 <dependency>
236 <groupId>junit</groupId>
237 <artifactId>junit</artifactId>
238 <scope>test</scope>
239 </dependency>
240 <dependency>
241 <groupId>org.antlr</groupId>
242 <artifactId>gunit</artifactId>
243 <version>${dependency.antlr.version}</version>
244 <scope>test</scope>
245 </dependency>
246 <dependency>
247 <groupId>org.mockito</groupId>
248 <artifactId>mockito-all</artifactId>
249 <scope>test</scope>
250 </dependency>
251 </dependencies>
252 </project>
253
src/main/java/org/alfresco/encoding/TikaCharsetFinder.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.encoding;
27
28 import java.nio.charset.Charset;
29 import java.nio.charset.UnsupportedCharsetException;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33 import org.apache.tika.parser.txt.CharsetDetector;
34 import org.apache.tika.parser.txt.CharsetMatch;
35
36 /**
37 * Uses Apache Tika as a fallback encoding detector
38 *
39 * @since 3.4
40 * @author Nick Burch
41 */
42 public class TikaCharsetFinder extends AbstractCharactersetFinder
43 {
44 private static Log logger = LogFactory.getLog(TikaCharsetFinder.class);
45
46 private int threshold = 35;
47
48 @Override
49 protected Charset detectCharsetImpl(byte[] buffer) throws Exception
50 {
51 CharsetDetector detector = new CharsetDetector();
52 detector.setText(buffer);
53 CharsetMatch match = detector.detect();
54
55 if(match != null && match.getConfidence() > threshold)
56 {
57 try
58 {
59 return Charset.forName(match.getName());
60 }
61 catch(UnsupportedCharsetException e)
62 {
63 logger.info("Charset detected as " + match.getName() + " but the JVM does not support this, detection skipped");
64 }
65 }
66 return null;
67 }
68
69 /**
70 * Return the matching threshold before we decide that
71 * what we detected is a good match. In the range
72 * 0-100.
73 */
74 public int getThreshold()
75 {
76 return threshold;
77 }
78
79 /**
80 * At what point do we decide our match is good enough?
81 * In the range 0-100. If we don't reach the threshold,
82 * we'll decline, and either another finder will work on
83 * it or the fallback encoding will be taken.
84 */
85 public void setThreshold(int threshold)
86 {
87 if(threshold < 0)
88 threshold = 0;
89 if(threshold > 100)
90 threshold = 100;
91
92 this.threshold = threshold;
93 }
94
95 }
96
src/main/java/org/alfresco/model/ContentModel.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.model;
27
28 import org.alfresco.api.AlfrescoPublicApi;
29 import org.alfresco.service.namespace.NamespaceService;
30 import org.alfresco.service.namespace.QName;
31
32
33 /**
34 * Content Model Constants
35 */
36 @AlfrescoPublicApi
37 public interface ContentModel
38 {
39 //
40 // System Model Definitions
41 //
42
43 // type for deleted nodes
44 static final QName TYPE_DELETED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "deleted");
45 static final QName PROP_ORIGINAL_ID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "originalId");
46
47 // base type constants
48 static final QName TYPE_BASE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "base");
49 static final QName ASPECT_REFERENCEABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "referenceable");
50 static final QName PROP_STORE_PROTOCOL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-protocol");
51 static final QName PROP_STORE_IDENTIFIER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-identifier");
52 static final QName PROP_NODE_UUID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-uuid");
53 static final QName PROP_NODE_DBID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
54
55 // tag for incomplete nodes
56 static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
57
58 // tag for temporary nodes
59 static final QName ASPECT_TEMPORARY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "temporary");
60
61 // tag for nodes being formed (CIFS)
62 static final QName ASPECT_NO_CONTENT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "noContent");
63
64 // tag for nodes being formed (WebDAV)
65 static final QName ASPECT_WEBDAV_NO_CONTENT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "webdavNoContent");
66
67 static final QName ASPECT_WEBDAV_OBJECT = QName.createQName(NamespaceService.WEBDAV_MODEL_1_0_URI, "object");
68 static final QName PROP_DEAD_PROPERTIES = QName.createQName(NamespaceService.WEBDAV_MODEL_1_0_URI, "deadproperties");
69
70 // tag for localized nodes
71 static final QName ASPECT_LOCALIZED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "localized");
72 static final QName PROP_LOCALE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "locale");
73
74 // tag for hidden nodes
75 static final QName ASPECT_HIDDEN = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "hidden");
76 static final QName PROP_VISIBILITY_MASK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "clientVisibilityMask");
77 static final QName PROP_HIDDEN_FLAG = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "hiddenFlag");
78 static final QName PROP_CASCADE_HIDDEN = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "cascadeHidden");
79 static final QName PROP_CASCADE_INDEX_CONTROL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "cascadeIndexControl");
80 static final QName PROP_CLIENT_CONTROLLED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "clientControlled");
81
82 // tag for soft delete (CIFS rename shuffle)
83 static final QName ASPECT_SOFT_DELETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "softDelete");
84
85 // archived nodes aspect constants
86 static final QName ASPECT_ARCHIVE_ROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archiveRoot");
87 static final QName ASSOC_ARCHIVE_USER_LINK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archiveUserLink");
88 static final QName TYPE_ARCHIVE_USER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archiveUser");
89 static final QName ASSOC_ARCHIVED_LINK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLink");
90 static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
91 static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
92 static final QName PROP_ARCHIVED_BY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedBy");
93 static final QName PROP_ARCHIVED_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedDate");
94 static final QName PROP_ARCHIVED_ORIGINAL_OWNER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalOwner");
95 static final QName ASPECT_ARCHIVED_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived-assocs");
96 static final QName PROP_ARCHIVED_PARENT_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedParentAssocs");
97 static final QName PROP_ARCHIVED_CHILD_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedChildAssocs");
98 static final QName PROP_ARCHIVED_SOURCE_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedSourceAssocs");
99 static final QName PROP_ARCHIVED_TARGET_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedTargetAssocs");
100 static final QName ASPECT_ARCHIVE_LOCKABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLockable");
101 static final QName PROP_ARCHIVED_LOCK_OWNER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLockOwner");
102 static final QName PROP_ARCHIVED_LOCK_TYPE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLockType");
103 static final QName PROP_ARCHIVED_LOCK_LIFETIME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLockLifetime");
104 static final QName PROP_ARCHIVED_EXPIRY_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedExpiryDate");
105 static final QName PROP_ARCHIVED_LOCK_ADDITIONAL_INFO = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedLockAdditionalInfo");
106
107
108 // referenceable aspect constants
109 static final QName TYPE_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
110 static final QName PROP_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
111
112 // container type constants
113 static final QName TYPE_CONTAINER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "container");
114 /** child association type supported by {@link #TYPE_CONTAINER} */
115 static final QName ASSOC_CHILDREN =QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "children");
116
117 // roots
118 static final QName ASPECT_ROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "aspect_root");
119 static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root");
120
121 // for internal use only: see ALF-13066 / ALF-12358
122 static final QName TYPE_LOST_AND_FOUND = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "lost_found");
123 static final QName ASSOC_LOST_AND_FOUND = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "lost_found");
124
125 // descriptor properties
126 static final QName PROP_SYS_NAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "name");
127 static final QName PROP_SYS_VERSION_MAJOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMajor");
128 static final QName PROP_SYS_VERSION_MINOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMinor");
129 static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision");
130 static final QName PROP_SYS_VERSION_LABEL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionLabel");
131 static final QName PROP_SYS_VERSION_BUILD = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionBuild");
132 static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema");
133 static final QName PROP_SYS_VERSION_EDITION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionEdition");
134 static final QName PROP_SYS_VERSION_PROPERTIES = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionProperties");
135 static final QName PROP_SYS_LICENSE_MODE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "licenseMode");
136
137 /**
138 * Aspect for nodes which are by default not deletable.
139 * @since 3.5.0
140 */
141 static final QName ASPECT_UNDELETABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "undeletable");
142
143 /**
144 * Aspect for nodes which are by default not movable.
145 */
146 static final QName ASPECT_UNMOVABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "unmovable");
147
148 /**
149 * Aspects marking nodes that are pending deletion.
150 * This aspect is applied to all nodes that are about to be deleted within a transaction.
151 * The aspect survives only for the duration of calls to delete nodes and their children.
152 */
153 static final QName ASPECT_PENDING_DELETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "pendingDelete");
154
155 /**
156 * Aspect marking nodes for pending set fixed ACL operation and it's contants
157 */
158 static final QName ASPECT_PENDING_FIX_ACL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "pendingFixAcl");
159 static final QName PROP_SHARED_ACL_TO_REPLACE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "sharedAclToReplace");
160 static final QName PROP_INHERIT_FROM_ACL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "inheritFromAcl");
161
162 //
163 // Content Model Definitions
164 //
165
166 // content management type constants
167 static final QName TYPE_CMOBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "cmobject");
168 static final QName PROP_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "name");
169
170 // copy aspect constants
171 static final QName ASPECT_COPIEDFROM = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copiedfrom");
172 static final QName ASSOC_ORIGINAL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "original");
173
174 // working copy aspect contants
175 static final QName ASPECT_CHECKED_OUT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkedOut");
176 static final QName ASSOC_WORKING_COPY_LINK = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingcopylink");
177 static final QName ASPECT_WORKING_COPY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingcopy");
178 static final QName PROP_WORKING_COPY_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingCopyOwner");
179 static final QName PROP_WORKING_COPY_MODE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingCopyMode");
180 static final QName PROP_WORKING_COPY_LABEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingCopyLabel");
181
182 // content type and aspect constants
183 static final QName TYPE_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
184 static final QName PROP_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
185
186 // title aspect
187 static final QName ASPECT_TITLED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "titled");
188 static final QName PROP_TITLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "title");
189 static final QName PROP_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "description");
190
191 // auditable aspect
192 static final QName ASPECT_AUDITABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "auditable");
193 static final QName PROP_CREATED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "created");
194 static final QName PROP_CREATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "creator");
195 static final QName PROP_MODIFIED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modified");
196 static final QName PROP_MODIFIER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modifier");
197 static final QName PROP_ACCESSED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "accessed");
198
199 // author aspect
200 static final QName ASPECT_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
201 static final QName PROP_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
202
203 // categories
204 static final QName TYPE_CATEGORYROOT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category_root");
205 static final QName ASPECT_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "classifiable");
206 //static final QName ASPECT_CATEGORISATION = QName.createQName(NamespaceService.ALFRESCO_URI, "aspect_categorisation");
207 static final QName ASPECT_GEN_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "generalclassifiable");
208 static final QName TYPE_CATEGORY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category");
209 static final QName PROP_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
210 static final QName ASSOC_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
211 static final QName ASSOC_SUBCATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subcategories");
212
213 // tags - a subsection of categories
214 static final QName ASPECT_TAGGABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "taggable");
215 static final QName PROP_TAGS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "taggable");
216
217 // tagscope aspect
218 static final QName ASPECT_TAGSCOPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tagscope");
219 static final QName PROP_TAGSCOPE_CACHE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tagScopeCache");
220 static final QName PROP_TAGSCOPE_SUMMARY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tagScopeSummary");
221
222 // ratings
223 static final QName ASPECT_RATEABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "rateable");
224 static final QName ASPECT_LIKES_RATING_SCHEME_ROLLUPS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "likesRatingSchemeRollups");
225 static final QName ASPECT_FIVESTAR_RATING_SCHEME_ROLLUPS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "fiveStarRatingSchemeRollups");
226 static final QName ASSOC_RATINGS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ratings");
227 static final QName TYPE_RATING = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "rating");
228 static final QName PROP_RATING_SCORE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ratingScore");
229 static final QName PROP_RATING_SCHEME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ratingScheme");
230 static final QName PROP_RATED_AT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ratedAt");
231
232 // lock aspect
233 public final static QName ASPECT_LOCKABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockable");
234 public final static QName PROP_LOCK_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockOwner");
235 public final static QName PROP_LOCK_TYPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockType");
236 public final static QName PROP_LOCK_LIFETIME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockLifetime");
237 public final static QName PROP_EXPIRY_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "expiryDate");
238 public final static QName PROP_LOCK_ADDITIONAL_INFO = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockAdditionalInfo");
239
240 // version aspect
241 static final QName ASPECT_VERSIONABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionable");
242 static final QName PROP_VERSION_LABEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionLabel");
243 static final QName PROP_INITIAL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "initialVersion");
244 static final QName PROP_AUTO_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "autoVersion");
245 static final QName PROP_AUTO_VERSION_PROPS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "autoVersionOnUpdateProps");
246 static final QName PROP_VERSION_TYPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionType");
247
248 // folders
249 static final QName TYPE_SYSTEM_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "systemfolder");
250 static final QName TYPE_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "folder");
251 /** child association type supported by {@link #TYPE_FOLDER} */
252 static final QName ASSOC_CONTAINS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "contains");
253
254 // person
255 static final QName TYPE_PERSON = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "person");
256 static final QName PROP_USERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "userName");
257 static final QName PROP_HOMEFOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "homeFolder");
258 static final QName PROP_FIRSTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "firstName");
259 static final QName PROP_LASTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastName");
260 static final QName PROP_EMAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "email");
261 static final QName PROP_ORGID = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "organizationId");
262 static final QName PROP_HOME_FOLDER_PROVIDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "homeFolderProvider");
263 static final QName PROP_DEFAULT_HOME_FOLDER_PATH = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "defaultHomeFolderPath");
264 static final QName PROP_PRESENCEPROVIDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "presenceProvider");
265 static final QName PROP_PRESENCEUSERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "presenceUsername");
266 static final QName PROP_ORGANIZATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "organization");
267 static final QName PROP_JOBTITLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "jobtitle");
268 static final QName PROP_LOCATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "location");
269 static final QName PROP_PERSONDESC = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "persondescription");
270 static final QName PROP_TELEPHONE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "telephone");
271 static final QName PROP_MOBILE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mobile");
272 static final QName PROP_COMPANYADDRESS1 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companyaddress1");
273 static final QName PROP_COMPANYADDRESS2 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companyaddress2");
274 static final QName PROP_COMPANYADDRESS3 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companyaddress3");
275 static final QName PROP_COMPANYPOSTCODE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companypostcode");
276 static final QName PROP_COMPANYTELEPHONE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companytelephone");
277 static final QName PROP_COMPANYFAX = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companyfax");
278 static final QName PROP_COMPANYEMAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "companyemail");
279 static final QName PROP_SKYPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "skype");
280 static final QName PROP_GOOGLEUSERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "googleusername");
281 static final QName PROP_INSTANTMSG = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "instantmsg");
282 static final QName PROP_USER_STATUS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "userStatus");
283 static final QName PROP_USER_STATUS_TIME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "userStatusTime");
284
285 static final QName PROP_SIZE_CURRENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "sizeCurrent"); // system-maintained
286 static final QName PROP_SIZE_QUOTA = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "sizeQuota");
287
288 static final QName PROP_EMAIL_FEED_ID = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "emailFeedId"); // system-maintained
289 static final QName PROP_EMAIL_FEED_DISABLED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "emailFeedDisabled");
290
291 static final QName PROP_SUBSCRIPTIONS_PRIVATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subscriptionsPrivate");
292
293 static final QName ASPECT_PERSON_DISABLED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "personDisabled");
294
295 static final QName ASPECT_ANULLABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "annullable");
296
297 static final QName ASSOC_AVATAR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avatar");
298
299 // Authority
300 static final QName TYPE_AUTHORITY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "authority");
301
302 static final QName TYPE_AUTHORITY_CONTAINER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "authorityContainer");
303 static final QName PROP_AUTHORITY_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "authorityName");
304 static final QName PROP_AUTHORITY_DISPLAY_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "authorityDisplayName");
305
306 static final QName ASSOC_MEMBER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "member");
307
308 // Zone
309 static final QName TYPE_ZONE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "zone");
310 static final QName ASSOC_IN_ZONE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "inZone");
311
312 // Ownable aspect
313 static final QName ASPECT_OWNABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ownable");
314 static final QName PROP_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "owner");
315
316 // Templatable aspect
317 static final QName ASPECT_TEMPLATABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "templatable");
318 static final QName PROP_TEMPLATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "template");
319
320 // Webscriptable aspect
321 static final QName ASPECT_WEBSCRIPTABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "webscriptable");
322 static final QName PROP_WEBSCRIPT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "webscript");
323
324 // Dictionary model
325 static final QName TYPE_DICTIONARY_MODEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "dictionaryModel");
326 static final QName PROP_MODEL_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelName");
327 static final QName PROP_MODEL_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelDescription");
328 static final QName PROP_MODEL_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelAuthor");
329 static final QName PROP_MODEL_PUBLISHED_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelPublishedDate");
330 static final QName PROP_MODEL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelVersion");
331 static final QName PROP_MODEL_ACTIVE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelActive");
332
333 // referencing aspect
334 static final QName ASPECT_REFERENCING = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "referencing");
335 static final QName ASSOC_REFERENCES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "references");
336
337 // link object
338 static final QName TYPE_LINK = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "link");
339 static final QName PROP_LINK_DESTINATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "destination");
340
341 // attachable aspect
342 static final QName ASPECT_ATTACHABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "attachable");
343 static final QName ASSOC_ATTACHMENTS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "attachments");
344
345 // emailed aspect
346 static final QName ASPECT_EMAILED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "emailed");
347 static final QName PROP_SENTDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "sentdate");
348 static final QName PROP_ORIGINATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "originator");
349 static final QName PROP_ADDRESSEE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressee");
350 static final QName PROP_ADDRESSEES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressees");
351 static final QName PROP_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subjectline");
352
353 // countable aspect
354 static final QName ASPECT_COUNTABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "countable");
355 static final QName PROP_HITS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "hits");
356 static final QName PROP_COUNTER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "counter");
357
358 // References Node Aspect.
359 static final QName ASPECT_REFERENCES_NODE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "referencesnode");
360 static final QName PROP_NODE_REF = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "noderef");
361
362 // Geographic Aspect.
363 static final QName ASPECT_GEOGRAPHIC = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "geographic");
364 static final QName PROP_LATITUDE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "latitude");
365 static final QName PROP_LONGITUDE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "longitude");
366
367 // Multilingual Type
368 static final QName TYPE_MULTILINGUAL_CONTAINER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlContainer");
369 static final QName ASSOC_MULTILINGUAL_CHILD = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlChild");
370 static final QName ASPECT_MULTILINGUAL_DOCUMENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlDocument");
371 static final QName ASPECT_MULTILINGUAL_EMPTY_TRANSLATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlEmptyTranslation");
372
373 // Thumbnail Type
374 static final QName TYPE_THUMBNAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thumbnail");
375 static final QName PROP_THUMBNAIL_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thumbnailName");
376 static final QName PROP_CONTENT_PROPERTY_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "contentPropertyName");
377 static final QName PROP_AUTOMATIC_UPDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "automaticUpdate");
378
379 // Thumbnail modification handling
380 public static final QName ASPECT_THUMBNAIL_MODIFICATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thumbnailModification");
381 public static final QName PROP_LAST_THUMBNAIL_MODIFICATION_DATA = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastThumbnailModification");
382
383 // The below content entities can be used to manage 'failed' thumbnails. These are thumbnails that execute and fail with an
384 // exception that likely means a reattempt will fail. The failedThumbnailSource aspect can be used to mark a node as
385 // having tried and failed to use a particular thumbnail definition. This can then be checked and reattempts at that thumbnail
386 // can be prevented or throttled.
387 static final QName ASPECT_FAILED_THUMBNAIL_SOURCE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "failedThumbnailSource");
388 static final QName ASSOC_FAILED_THUMBNAIL= QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "failedThumbnail");
389 static final QName TYPE_FAILED_THUMBNAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "failedThumbnail");
390 static final QName PROP_FAILED_THUMBNAIL_TIME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "failedThumbnailTime");
391 static final QName PROP_FAILURE_COUNT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "failureCount");
392
393 // Thumbnailed Aspect
394 /**
395 * This aspect type has been deprecated.
396 * From Alfresco 3.3 the {@link RenditionModel#ASPECT_RENDITIONED rn:renditioned}
397 * (which is a child of cm:thumbnailed) should be used instead.
398 */
399 @Deprecated
400 static final QName ASPECT_THUMBNAILED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thumbnailed");
401 /**
402 * This association type has been deprecated.
403 * From Alfresco 3.3 this association no longer exists and has been replaced with
404 * {@link RenditionModel#ASSOC_RENDITION rn:rendition} association. From Alfresco
405 * 3.3 onwards a patch is executed at startup which renames
406 * the cm:thumbnails QName to rn:rendition in the database.
407 * <P/>
408 * This field has been updated to point to that association and references to this
409 * field should be updated to use the new field.
410 */
411 @Deprecated
412 static final QName ASSOC_THUMBNAILS = RenditionModel.ASSOC_RENDITION;
413
414 // StoreSelector Aspect
415 static final QName ASPECT_STORE_SELECTOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "storeSelector");
416 static final QName PROP_STORE_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "storeName");
417
418 // Preference Aspect
419 static final QName ASPECT_PREFERENCES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "preferences");
420 static final QName PROP_PREFERENCE_VALUES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "preferenceValues");
421 static final QName ASSOC_PREFERENCE_IMAGE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "preferenceImage");
422
423 // Syndication Aspect
424 static final QName ASPECT_SYNDICATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "syndication");
425 static final QName PROP_PUBLISHED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "published");
426 static final QName PROP_UPDATED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "updated");
427
428 // Dublin core aspect
429 static final QName ASPECT_DUBLINCORE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "dublincore");
430
431 //
432 // User Model Definitions
433 //
434
435 static final String USER_MODEL_URI = "http://www.alfresco.org/model/user/1.0";
436 static final String USER_MODEL_PREFIX = "usr";
437
438 static final QName TYPE_USER = QName.createQName(USER_MODEL_URI, "user");
439 static final QName PROP_USER_USERNAME = QName.createQName(USER_MODEL_URI, "username");
440 static final QName PROP_PASSWORD = QName.createQName(USER_MODEL_URI, "password");
441 static final QName PROP_PASSWORD_SHA256 = QName.createQName(USER_MODEL_URI, "password2");
442 static final QName PROP_PASSWORD_HASH = QName.createQName(USER_MODEL_URI, "passwordHash");
443 static final QName PROP_ENABLED = QName.createQName(USER_MODEL_URI, "enabled");
444 static final QName PROP_ACCOUNT_EXPIRES = QName.createQName(USER_MODEL_URI, "accountExpires");
445 static final QName PROP_ACCOUNT_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "accountExpiryDate");
446 static final QName PROP_CREDENTIALS_EXPIRE = QName.createQName(USER_MODEL_URI, "credentialsExpire");
447 static final QName PROP_CREDENTIALS_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "credentialsExpiryDate");
448 static final QName PROP_ACCOUNT_LOCKED = QName.createQName(USER_MODEL_URI, "accountLocked");
449 static final QName PROP_SALT = QName.createQName(USER_MODEL_URI, "salt");
450 static final QName PROP_HASH_INDICATOR = QName.createQName(USER_MODEL_URI, "hashIndicator");
451
452 //
453 // Indexing control
454 //
455
456 static final QName ASPECT_INDEX_CONTROL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "indexControl");
457 static final QName PROP_IS_INDEXED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "isIndexed");
458 static final QName PROP_IS_CONTENT_INDEXED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "isContentIndexed");
459
460 // CMIS aspects
461 static final QName ASPECT_CMIS_UPDATE_CONTEXT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "CMISUpdateContext");
462 static final QName PROP_GOT_FIRST_CHUNK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "gotFirstChunk");
463 static final QName ASPECT_CMIS_CREATED_CHECKEDOUT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "cmisCreatedCheckedOut");
464
465 // Cascade Update
466 static final QName ASPECT_CASCADE_UPDATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "cascadeUpdate");
467 static final QName PROP_CASCADE_CRC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "cascadeCRC");
468 static final QName PROP_CASCADE_TX = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "cascadeTx");
469
470 }
471
src/main/java/org/alfresco/model/RenditionModel.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.model;
27
28 import org.alfresco.api.AlfrescoPublicApi;
29 import org.alfresco.service.namespace.NamespaceService;
30 import org.alfresco.service.namespace.QName;
31
32 /**
33 * Rendition Model Constants
34 */
35 @AlfrescoPublicApi
36 public interface RenditionModel
37 {
38 static final QName ASPECT_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "rendition");
39 static final QName ASPECT_HIDDEN_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "hiddenRendition");
40 static final QName ASPECT_VISIBLE_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "visibleRendition");
41
42 static final QName ASPECT_RENDITIONED = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "renditioned");
43 static final QName ASSOC_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "rendition");
44
45 /**
46 * @since 4.0.1
47 */
48 static final QName ASPECT_PREVENT_RENDITIONS = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "preventRenditions");
49 }
50
src/main/java/org/alfresco/opencmis/CMISAccessControlFormatEnum.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis;
27
28 /**
29 * @author andyh
30 *
31 */
32 public enum CMISAccessControlFormatEnum implements EnumLabel
33 {
34 /**
35 * Report only CMIS basic permissions
36 */
37 CMIS_BASIC_PERMISSIONS("onlyBasicPermissions"),
38
39 /**
40 * May report CMIS basic permission, repository specific permissions or a mixture of both.
41 */
42 REPOSITORY_SPECIFIC_PERMISSIONS("repositorySpecificPermissions");
43
44 private String label;
45
46 /**
47 * Construct
48 *
49 * @param label String
50 */
51 CMISAccessControlFormatEnum(String label)
52 {
53 this.label = label;
54 }
55
56 /*
57 * (non-Javadoc)
58 *
59 * @see org.alfresco.cmis.EnumLabel#label()
60 */
61 public String getLabel()
62 {
63 return label;
64 }
65
66 /**
67 * Factory for CMISAclPropagationEnum
68 */
69 public static EnumFactory<CMISAccessControlFormatEnum> FACTORY = new EnumFactory<CMISAccessControlFormatEnum>(CMISAccessControlFormatEnum.class, CMIS_BASIC_PERMISSIONS, true);
70
71 }
72
src/main/java/org/alfresco/opencmis/CMISUtils.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis;
27
28 import java.io.InputStream;
29 import java.io.ObjectInputStream;
30 import java.io.ObjectOutputStream;
31 import java.io.OutputStream;
32
33 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
34
35 public class CMISUtils
36 {
37 @SuppressWarnings("unchecked")
38 public static <T> T copy(T source)
39 {
40 T target = null;
41 try
42 {
43 CopyOutputStream cos = new CopyOutputStream();
44 ObjectOutputStream out = new ObjectOutputStream(cos);
45 out.writeObject(source);
46 out.flush();
47 out.close();
48
49 ObjectInputStream in = new ObjectInputStream(cos.getInputStream());
50 target = (T) in.readObject();
51 } catch (Exception e)
52 {
53 throw new CmisRuntimeException("Object copy failed!", e);
54 }
55
56 return target;
57 }
58
59 private static class CopyOutputStream extends OutputStream
60 {
61 protected byte[] buf = null;
62 protected int size = 0;
63
64 public CopyOutputStream()
65 {
66 this(16 * 1024);
67 }
68
69 public CopyOutputStream(int initSize)
70 {
71 this.size = 0;
72 this.buf = new byte[initSize];
73 }
74
75 private void verifyBufferSize(int sz)
76 {
77 if (sz > buf.length)
78 {
79 byte[] old = buf;
80 buf = new byte[Math.max(sz, 2 * buf.length)];
81 System.arraycopy(old, 0, buf, 0, old.length);
82 old = null;
83 }
84 }
85
86 public final void write(byte b[])
87 {
88 verifyBufferSize(size + b.length);
89 System.arraycopy(b, 0, buf, size, b.length);
90 size += b.length;
91 }
92
93 public final void write(byte b[], int off, int len)
94 {
95 verifyBufferSize(size + len);
96 System.arraycopy(b, off, buf, size, len);
97 size += len;
98 }
99
100 public final void write(int b)
101 {
102 verifyBufferSize(size + 1);
103 buf[size++] = (byte) b;
104 }
105
106 public InputStream getInputStream()
107 {
108 return new CopyInputStream(buf, size);
109 }
110 }
111
112 private static class CopyInputStream extends InputStream
113 {
114 protected byte[] buf = null;
115 protected int count = 0;
116 protected int pos = 0;
117
118 public CopyInputStream(byte[] buf, int count)
119 {
120 this.buf = buf;
121 this.count = count;
122 }
123
124 public final int available()
125 {
126 return count - pos;
127 }
128
129 public final int read()
130 {
131 return (pos < count) ? (buf[pos++] & 0xff) : -1;
132 }
133
134 public final int read(byte[] b, int off, int len)
135 {
136 if (pos >= count)
137 {
138 return -1;
139 }
140
141 if ((pos + len) > count)
142 {
143 len = (count - pos);
144 }
145
146 System.arraycopy(buf, pos, b, off, len);
147 pos += len;
148
149 return len;
150 }
151
152 public final long skip(long n)
153 {
154 if ((pos + n) > count)
155 {
156 n = count - pos;
157 }
158
159 if (n < 0)
160 {
161 return 0;
162 }
163
164 pos += n;
165
166 return n;
167 }
168 }
169 }
170
src/main/java/org/alfresco/opencmis/EnumFactory.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis;
27
28 import java.util.EnumSet;
29 import java.util.HashMap;
30 import java.util.Iterator;
31 import java.util.Map;
32 import java.util.TreeMap;
33
34
35 /**
36 * Enum Factory for managing mapping between Enum name and Enum label
37 *
38 * @author dcaruana
39 *
40 */
41 public class EnumFactory<E extends Enum<E>>
42 {
43 private E defaultEnum;
44 private Map<String, E> labelMap = new HashMap<String, E>(10);
45
46 public EnumFactory(Class<E> enumClass)
47 {
48 this(enumClass, null, false);
49 }
50
51 public EnumFactory(Class<E> enumClass, E defaultEnum)
52 {
53 this(enumClass, defaultEnum, false);
54 }
55
56 /**
57 * @param caseSensitive case-sensitive lookup for Enum label
58 */
59 public EnumFactory(Class<E> enumClass, E defaultEnum, boolean caseSensitive)
60 {
61 this.defaultEnum = defaultEnum;
62
63 // setup label map
64 labelMap = caseSensitive ? new HashMap<String, E>(10) : new TreeMap<String, E>(String.CASE_INSENSITIVE_ORDER);
65 EnumSet<E> enumSet = EnumSet.allOf(enumClass);
66 Iterator<E> iter = enumSet.iterator();
67 while(iter.hasNext())
68 {
69 E e = iter.next();
70 if (e instanceof EnumLabel)
71 {
72 labelMap.put(((EnumLabel)e).getLabel(), e);
73 }
74 }
75 }
76
77 /**
78 * Gets the default enum
79 *
80 * @return default enum (or null, if no default specified)
81 */
82 public Enum<E> getDefaultEnum()
83 {
84 return defaultEnum;
85 }
86
87 /**
88 * Gets the default label
89 *
90 * @return label of default enum (or null, if no default specified)
91 */
92 public String getDefaultLabel()
93 {
94 return label(defaultEnum);
95 }
96
97 /**
98 * Gets the label for the specified enum
99 *
100 * @param e enum
101 * @return label (or null, if no label specified)
102 */
103 public String label(E e)
104 {
105 if (e instanceof EnumLabel)
106 {
107 return ((EnumLabel)e).getLabel();
108 }
109 return null;
110 }
111
112 /**
113 * Is valid label?
114 *
115 * @param label String
116 * @return true => valid, false => does not exist for this enum
117 */
118 public boolean validLabel(String label)
119 {
120 return fromLabel(label) == null ? false : true;
121 }
122
123 /**
124 * Gets enum from label
125 *
126 * @param label String
127 * @return enum (or null, if no enum has specified label)
128 */
129 public E fromLabel(String label)
130 {
131 return labelMap.get(label);
132 }
133
134 /**
135 * Gets enum from label
136 *
137 * NOTE: If specified label is invalid, the default enum is returned
138 *
139 * @param label String
140 * @return enum (or default enum, if label is invalid)
141 */
142 public E toEnum(String label)
143 {
144 E e = (label == null) ? null : fromLabel(label);
145 if (e == null)
146 {
147 e = defaultEnum;
148 }
149 return e;
150 }
151 }
152
src/main/java/org/alfresco/opencmis/EnumLabel.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis;
27
28 /**
29 * Enum label (mapping from Enum name to CMIS name)
30 *
31 * @author davidc
32 */
33 public interface EnumLabel
34 {
35 /**
36 * Gets the enum label (as defined by CMIS)
37 *
38 * @return enum label
39 */
40 public String getLabel();
41 }
42
src/main/java/org/alfresco/opencmis/dictionary/AbstractTypeDefinitionWrapper.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis.dictionary;
27
28 import java.io.Serializable;
29 import java.math.BigDecimal;
30 import java.math.BigInteger;
31 import java.util.ArrayList;
32 import java.util.Collection;
33 import java.util.Collections;
34 import java.util.GregorianCalendar;
35 import java.util.HashMap;
36 import java.util.List;
37 import java.util.Map;
38 import java.util.concurrent.locks.ReadWriteLock;
39 import java.util.concurrent.locks.ReentrantReadWriteLock;
40
41 import org.alfresco.error.AlfrescoRuntimeException;
42 import org.alfresco.opencmis.mapping.CMISMapping;
43 import org.alfresco.repo.dictionary.IndexTokenisationMode;
44 import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
45 import org.alfresco.repo.dictionary.constraint.NumericRangeConstraint;
46 import org.alfresco.repo.dictionary.constraint.StringLengthConstraint;
47 import org.alfresco.service.cmr.dictionary.ClassDefinition;
48 import org.alfresco.service.cmr.dictionary.Constraint;
49 import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
50 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
51 import org.alfresco.service.cmr.dictionary.DictionaryService;
52 import org.alfresco.service.namespace.QName;
53 import org.alfresco.util.ISO8601DateFormat;
54 import org.alfresco.util.ISO9075;
55 import org.apache.chemistry.opencmis.commons.PropertyIds;
56 import org.apache.chemistry.opencmis.commons.definitions.Choice;
57 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
58 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
59 import org.apache.chemistry.opencmis.commons.enums.Action;
60 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
61 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
62 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
63 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
64 import org.apache.chemistry.opencmis.commons.enums.Updatability;
65 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
66 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
67 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
68 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
69 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
70 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
71 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
72 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
73 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
74 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
75 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
76 import org.apache.commons.logging.Log;
77 import org.apache.commons.logging.LogFactory;
78
79 /**
80 * Base class for type definition wrappers.
81 *
82 * @author florian.mueller
83 */
84 public abstract class AbstractTypeDefinitionWrapper implements TypeDefinitionWrapper, Serializable
85 {
86 private static final long serialVersionUID = 1L;
87 private Log logger = LogFactory.getLog(AbstractTypeDefinitionWrapper.class);
88
89 protected AbstractTypeDefinition typeDef;
90 protected AbstractTypeDefinition typeDefInclProperties;
91
92 protected TypeDefinitionWrapper parent;
93 // protected List<TypeDefinitionWrapper> children;
94
95 private String tenantId;
96 private ReadWriteLock lock = new ReentrantReadWriteLock();
97
98 @Override
99 public String getTenantId()
100 {
101 return tenantId;
102 }
103
104 protected QName alfrescoName = null;
105 protected QName alfrescoClass = null;
106 protected Map<Action, CMISActionEvaluator> actionEvaluators;
107
108 protected Map<String, PropertyDefinitionWrapper> propertiesById = new HashMap<String, PropertyDefinitionWrapper>();
109 protected Map<String, PropertyDefinitionWrapper> propertiesByQueryName = new HashMap<String, PropertyDefinitionWrapper>();
110 protected Map<QName, PropertyDefinitionWrapper> propertiesByQName = new HashMap<QName, PropertyDefinitionWrapper>();
111
112 // interface
113
114 public TypeDefinition getTypeDefinition(boolean includePropertyDefinitions)
115 {
116 lock.readLock().lock();
117 try
118 {
119 if (includePropertyDefinitions)
120 {
121 return typeDefInclProperties;
122 }
123 else
124 {
125 return typeDef;
126 }
127 }
128 finally
129 {
130 lock.readLock().unlock();
131 }
132 }
133
134 protected void setTypeDefinition(AbstractTypeDefinition typeDef, AbstractTypeDefinition typeDefInclProperties)
135 {
136 this.typeDef = typeDef;
137 this.typeDefInclProperties = typeDefInclProperties;
138 }
139
140 @Override
141 public String getTypeId()
142 {
143 return typeDef.getId();
144 }
145
146 @Override
147 public BaseTypeId getBaseTypeId()
148 {
149 return typeDef.getBaseTypeId();
150 }
151
152 @Override
153 public boolean isBaseType()
154 {
155 return typeDef.getId().equals(typeDef.getBaseTypeId().value());
156 }
157
158 @Override
159 public QName getAlfrescoName()
160 {
161 return alfrescoName;
162 }
163
164 @Override
165 public QName getAlfrescoClass()
166 {
167 return alfrescoClass;
168 }
169
170 @Override
171 public TypeDefinitionWrapper getParent()
172 {
173 return parent;
174 }
175
176 // @Override
177 // public List<TypeDefinitionWrapper> getChildren()
178 // {
179 // return children;
180 // }
181
182 @Override
183 public Map<Action, CMISActionEvaluator> getActionEvaluators()
184 {
185 return actionEvaluators;
186 }
187
188 @Override
189 public Collection<PropertyDefinitionWrapper> getProperties()
190 {
191 return propertiesById.values();
192 }
193
194 @Override
195 public PropertyDefinitionWrapper getPropertyById(String propertyId)
196 {
197 return propertiesById.get(propertyId);
198 }
199
200 @Override
201 public PropertyDefinitionWrapper getPropertyByQueryName(String queryName)
202 {
203 return propertiesByQueryName.get(queryName);
204 }
205
206 @Override
207 public PropertyDefinitionWrapper getPropertyByQName(QName name)
208 {
209 return propertiesByQName.get(name);
210 }
211
212 @Override
213 public void updateDefinition(DictionaryService dictionaryService)
214 {
215 String name = null;
216 String description = null;
217 ClassDefinition definition = dictionaryService.getClass(alfrescoName);
218
219 if (definition != null)
220 {
221 name = definition.getTitle(dictionaryService);
222 description = definition.getDescription(dictionaryService);
223 }
224 setTypeDefDisplayName(name);
225 setTypeDefDescription(description);
226 }
227
228 public void updateProperties(DictionaryService dictionaryService)
229 {
230 for (PropertyDefinitionWrapper propertyDefWrap : propertiesById.values())
231 {
232 updateProperty(dictionaryService, propertyDefWrap);
233 }
234 }
235
236 public void updateProperty(DictionaryService dictionaryService, PropertyDefinitionWrapper propertyDefWrap)
237 {
238 if (propertyDefWrap != null && propertyDefWrap.getPropertyDefinition().getDisplayName() == null)
239 {
240 AbstractPropertyDefinition<?> property = (AbstractPropertyDefinition<?>) propertyDefWrap.getPropertyDefinition();
241 org.alfresco.service.cmr.dictionary.PropertyDefinition propDef = dictionaryService
242 .getProperty(QName.createQName(property.getLocalNamespace(), property.getLocalName()));
243 if (propDef != null)
244 {
245 String displayName = propDef.getTitle(dictionaryService);
246 String description = propDef.getDescription(dictionaryService);
247 property.setDisplayName(displayName == null ? property.getId() : displayName);
248 property.setDescription(description == null ? property.getDisplayName() : description);
249 }
250 }
251 }
252
253 public void updateTypeDefInclProperties()
254 {
255 for (PropertyDefinition<?> property : typeDefInclProperties.getPropertyDefinitions().values())
256 {
257 if (property.getDisplayName() == null)
258 {
259 typeDefInclProperties.addPropertyDefinition(getPropertyById(property.getId()).getPropertyDefinition());
260 }
261 }
262 }
263
264 public void setTypeDefDisplayName(String name)
265 {
266 lock.writeLock().lock();
267 try
268 {
269 typeDef.setDisplayName(name != null ? name : typeDef.getId());
270 typeDefInclProperties.setDisplayName(name != null ? name : typeDef.getId());
271 }
272 finally
273 {
274 lock.writeLock().unlock();
275 }
276 }
277
278 public void setTypeDefDescription(String desc)
279 {
280 lock.writeLock().lock();
281 try
282 {
283 typeDef.setDescription(desc != null ? desc : typeDef.getId());
284 typeDefInclProperties.setDescription(desc != null ? desc : typeDef.getId());
285 }
286 finally
287 {
288 lock.writeLock().unlock();
289 }
290 }
291
292 // create
293
294 public abstract List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
295 DictionaryService dictionaryService);
296
297 public abstract void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
298 DictionaryService dictionaryService);
299
300 public void assertComplete()
301 {
302 if (typeDef == null)
303 throw new IllegalStateException("typeDef is not set");
304 if (typeDefInclProperties == null)
305 throw new IllegalStateException("typeDefInclProperties is not set");
306 if (alfrescoName == null)
307 throw new IllegalStateException("alfrescoName is not set");
308 if (alfrescoClass == null)
309 throw new IllegalStateException("alfrescoClass is not set");
310 if (propertiesById == null)
311 throw new IllegalStateException("propertiesById is not set");
312 if (propertiesByQueryName == null)
313 throw new IllegalStateException("propertiesByQueryName is not set");
314 if (propertiesByQName == null)
315 throw new IllegalStateException("propertiesByQName is not set");
316 // if (propertiesById.size() == 0)
317 // throw new IllegalStateException("property map empty");
318 if (propertiesById.size() != propertiesByQueryName.size())
319 throw new IllegalStateException("property map mismatch");
320 if (propertiesById.size() != propertiesByQName.size())
321 throw new IllegalStateException("property map mismatch");
322 }
323
324 /**
325 * Adds all property definitions owned by that type.
326 */
327 protected void createOwningPropertyDefinitions(CMISMapping cmisMapping,
328 PropertyAccessorMapping propertyAccessorMapping, PropertyLuceneBuilderMapping luceneBuilderMapping,
329 DictionaryService dictionaryService, ClassDefinition cmisClassDef)
330 {
331 PropertyDefinition<?> propertyDefintion;
332
333 for (org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef : cmisClassDef.getProperties()
334 .values())
335 {
336 if (!isBaseType())
337 {
338 if (!alfrescoPropDef.getContainerClass().equals(cmisClassDef))
339 {
340 continue;
341 }
342 }
343
344 // compile property id
345 String propertyId = cmisMapping.buildPrefixEncodedString(alfrescoPropDef.getName());
346
347 if(propertyId.equals("cmis:secondaryObjectTypeIds") && cmisMapping.getCmisVersion() == CmisVersion.CMIS_1_0)
348 {
349 continue;
350 }
351
352 // create property definition
353 propertyDefintion = createPropertyDefinition(cmisMapping, propertyId, alfrescoPropDef.getName(),
354 dictionaryService, alfrescoPropDef, false);
355
356 // if the datatype is not supported, the property defintion will be
357 // null
358 if (propertyDefintion != null)
359 {
360 CMISPropertyAccessor propertyAccessor = null;
361 if (propertyAccessorMapping != null)
362 {
363 propertyAccessor = propertyAccessorMapping.getPropertyAccessor(propertyId);
364 if (propertyAccessor == null)
365 {
366 propertyAccessor = propertyAccessorMapping.createDirectPropertyAccessor(propertyId,
367 alfrescoPropDef.getName());
368 }
369 }
370
371 CMISPropertyLuceneBuilder luceneBuilder = null;
372 if (luceneBuilderMapping != null)
373 {
374 luceneBuilder = luceneBuilderMapping.getPropertyLuceneBuilder(propertyId);
375 if (luceneBuilder == null)
376 {
377 luceneBuilder = luceneBuilderMapping.createDirectPropertyLuceneBuilder(alfrescoPropDef
378 .getName());
379 }
380 }
381
382 registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), this,
383 propertyAccessor, luceneBuilder));
384 }
385 }
386 }
387
388 /**
389 * Registers a property definition with this type
390 */
391 protected void registerProperty(PropertyDefinitionWrapper propDefWrapper)
392 {
393 if (propDefWrapper == null)
394 {
395 return;
396 }
397
398 if (propertiesById.containsKey(propDefWrapper.getPropertyId()))
399 {
400 throw new AlfrescoRuntimeException("Property defintion " + propDefWrapper.getPropertyId()
401 + " already exists on type " + typeDef.getId());
402 }
403
404 propertiesById.put(propDefWrapper.getPropertyId(), propDefWrapper);
405 propertiesByQueryName.put(propDefWrapper.getPropertyDefinition().getQueryName(), propDefWrapper);
406 propertiesByQName.put(propDefWrapper.getAlfrescoName(), propDefWrapper);
407 typeDefInclProperties.addPropertyDefinition(propDefWrapper.getPropertyDefinition());
408 }
409
410 /**
411 * Creates a property definition object.
412 */
413 protected PropertyDefinition<?> createPropertyDefinition(CMISMapping cmisMapping, String id,
414 QName alfrescoPropName, DictionaryService dictionaryService, org.alfresco.service.cmr.dictionary.PropertyDefinition propDef, boolean inherited)
415 {
416 PropertyType datatype = cmisMapping.getDataType(propDef.getDataType());
417 if (datatype == null)
418 {
419 return null;
420 }
421
422 AbstractPropertyDefinition<?> result = null;
423
424 switch (datatype)
425 {
426 case BOOLEAN:
427 result = new PropertyBooleanDefinitionImpl();
428 break;
429 case DATETIME:
430 result = new PropertyDateTimeDefinitionImpl();
431 break;
432 case DECIMAL:
433 result = new PropertyDecimalDefinitionImpl();
434 break;
435 case HTML:
436 result = new PropertyHtmlDefinitionImpl();
437 break;
438 case ID:
439 result = new PropertyIdDefinitionImpl();
440 break;
441 case INTEGER:
442 result = new PropertyIntegerDefinitionImpl();
443 break;
444 case STRING:
445 result = new PropertyStringDefinitionImpl();
446 break;
447 case URI:
448 result = new PropertyUriDefinitionImpl();
449 break;
450 default:
451 throw new RuntimeException("Unknown datatype! Spec change?");
452 }
453
454 if (id.equals(PropertyIds.OBJECT_TYPE_ID) || id.equals(PropertyIds.SOURCE_ID)
455 || id.equals(PropertyIds.TARGET_ID))
456 {
457 // the CMIS spec requirement
458 result.setUpdatability(Updatability.ONCREATE);
459 } else
460 {
461 result.setUpdatability(propDef.isProtected() ? Updatability.READONLY : Updatability.READWRITE);
462 }
463
464 result.setId(id);
465 result.setLocalName(alfrescoPropName.getLocalName());
466 result.setLocalNamespace(alfrescoPropName.getNamespaceURI());
467 result.setDisplayName(null);
468 result.setDescription(null);
469 result.setPropertyType(datatype);
470 result.setCardinality(propDef.isMultiValued() ? Cardinality.MULTI : Cardinality.SINGLE);
471 result.setIsInherited(inherited);
472 result.setIsRequired(propDef.isMandatory());
473 addDefaultValue(propDef.getDefaultValue(), result);
474
475 // query and order
476 result.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoPropName)));
477 result.setIsQueryable(propDef.isIndexed());
478 result.setIsOrderable(false);
479
480 if (result.isQueryable())
481 {
482 if (result.getCardinality() == Cardinality.SINGLE)
483 {
484 IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
485 if (propDef.getIndexTokenisationMode() != null)
486 {
487 indexTokenisationMode = propDef.getIndexTokenisationMode();
488 }
489
490 switch (indexTokenisationMode)
491 {
492 case BOTH:
493 case FALSE:
494 result.setIsOrderable(true);
495 break;
496 case TRUE:
497 default:
498 if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN)
499 || propDef.getDataType().getName().equals(DataTypeDefinition.DATE)
500 || propDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)
501 || propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE)
502 || propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT)
503 || propDef.getDataType().getName().equals(DataTypeDefinition.INT)
504 || propDef.getDataType().getName().equals(DataTypeDefinition.LONG)
505 || propDef.getDataType().getName().equals(DataTypeDefinition.PATH)
506 )
507 {
508 result.setIsOrderable(true);
509 }
510 }
511 }
512 }
513
514 // MNT-9089 fix, set min/max values for numeric properties
515 // MNT-11304 fix, use default boundaries only for numeric types
516 if (result instanceof PropertyIntegerDefinitionImpl)
517 {
518 if (propDef.getDataType().getName().equals(DataTypeDefinition.INT))
519 {
520 ((PropertyIntegerDefinitionImpl) result).setMinValue(BigInteger.valueOf(Integer.MIN_VALUE));
521 ((PropertyIntegerDefinitionImpl) result).setMaxValue(BigInteger.valueOf(Integer.MAX_VALUE));
522 }
523 if (propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
524 {
525 ((PropertyIntegerDefinitionImpl) result).setMinValue(BigInteger.valueOf(Long.MIN_VALUE));
526 ((PropertyIntegerDefinitionImpl) result).setMaxValue(BigInteger.valueOf(Long.MAX_VALUE));
527 }
528 }
529 // end MNT-9089
530
531 // constraints and choices
532 for (ConstraintDefinition constraintDef : propDef.getConstraints())
533 {
534 Constraint constraint = constraintDef.getConstraint();
535 if (constraint instanceof ListOfValuesConstraint)
536 {
537 addChoiceList((ListOfValuesConstraint) constraint, result);
538 }
539
540 if ((constraint instanceof StringLengthConstraint) && (result instanceof PropertyStringDefinitionImpl))
541 {
542 StringLengthConstraint slc = (StringLengthConstraint) constraint;
543 ((PropertyStringDefinitionImpl) result).setMaxLength(BigInteger.valueOf(slc.getMaxLength()));
544 }
545
546 if (constraint instanceof NumericRangeConstraint)
547 {
548 NumericRangeConstraint nrc = (NumericRangeConstraint) constraint;
549 if (result instanceof PropertyIntegerDefinitionImpl)
550 {
551 ((PropertyIntegerDefinitionImpl) result)
552 .setMinValue(BigInteger.valueOf(((Double) nrc.getMinValue()).longValue()));
553 ((PropertyIntegerDefinitionImpl) result)
554 .setMaxValue(BigInteger.valueOf(((Double) nrc.getMaxValue()).longValue()));
555 }
556 if (result instanceof PropertyDecimalDefinitionImpl)
557 {
558 ((PropertyDecimalDefinitionImpl) result).setMinValue(BigDecimal.valueOf(nrc.getMinValue()));
559 ((PropertyDecimalDefinitionImpl) result).setMaxValue(BigDecimal.valueOf(nrc.getMaxValue()));
560 }
561 }
562 }
563
564 return result;
565 }
566
567 protected void createActionEvaluators(PropertyAccessorMapping propertyAccessorMapping, BaseTypeId baseTypeId)
568 {
569 if (propertyAccessorMapping != null)
570 {
571 actionEvaluators = propertyAccessorMapping.getActionEvaluators(baseTypeId);
572 } else
573 {
574 actionEvaluators = Collections.emptyMap();
575 }
576 }
577
578 @SuppressWarnings("unchecked")
579 private <T> T convertValueFromString(String value, PropertyType datatype)
580 {
581 if (value == null)
582 {
583 return null;
584 }
585
586 try
587 {
588 switch (datatype)
589 {
590 case BOOLEAN:
591 return (T) Boolean.valueOf(value);
592 case DATETIME:
593 GregorianCalendar cal = new GregorianCalendar();
594 cal.setTime(ISO8601DateFormat.parse(value));
595 return (T) cal;
596 case DECIMAL:
597 return (T) new BigDecimal(value);
598 case HTML:
599 return (T) value;
600 case ID:
601 return (T) value;
602 case INTEGER:
603 return (T) new BigInteger(value);
604 case STRING:
605 return (T) value;
606 case URI:
607 return (T) value;
608 default: ;
609 }
610 }
611 catch (Exception e)
612 {
613 logger.error("Failed to convert value " + value + " to " + datatype, e);
614 return null;
615 }
616
617 throw new RuntimeException("Unknown datatype! Spec change?");
618 }
619
620 /**
621 * Adds the default value to a property definition.
622 */
623 private void addDefaultValue(String value, PropertyDefinition<?> propDef)
624 {
625 if (value == null)
626 {
627 return;
628 }
629
630 if (propDef instanceof PropertyBooleanDefinitionImpl)
631 {
632 PropertyBooleanDefinitionImpl propDefImpl = (PropertyBooleanDefinitionImpl) propDef;
633 propDefImpl.setDefaultValue(Collections.singletonList((Boolean) convertValueFromString(value,
634 PropertyType.BOOLEAN)));
635 } else if (propDef instanceof PropertyDateTimeDefinitionImpl)
636 {
637 PropertyDateTimeDefinitionImpl propDefImpl = (PropertyDateTimeDefinitionImpl) propDef;
638 propDefImpl.setDefaultValue(Collections.singletonList((GregorianCalendar) convertValueFromString(value,
639 PropertyType.DATETIME)));
640 } else if (propDef instanceof PropertyDecimalDefinitionImpl)
641 {
642 PropertyDecimalDefinitionImpl propDefImpl = (PropertyDecimalDefinitionImpl) propDef;
643 propDefImpl.setDefaultValue(Collections.singletonList((BigDecimal) convertValueFromString(value,
644 PropertyType.DECIMAL)));
645 } else if (propDef instanceof PropertyHtmlDefinitionImpl)
646 {
647 PropertyHtmlDefinitionImpl propDefImpl = (PropertyHtmlDefinitionImpl) propDef;
648 propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
649 PropertyType.HTML)));
650 } else if (propDef instanceof PropertyIdDefinitionImpl)
651 {
652 PropertyIdDefinitionImpl propDefImpl = (PropertyIdDefinitionImpl) propDef;
653 propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
654 PropertyType.ID)));
655 } else if (propDef instanceof PropertyIntegerDefinitionImpl)
656 {
657 PropertyIntegerDefinitionImpl propDefImpl = (PropertyIntegerDefinitionImpl) propDef;
658 propDefImpl.setDefaultValue(Collections.singletonList((BigInteger) convertValueFromString(value,
659 PropertyType.INTEGER)));
660 } else if (propDef instanceof PropertyStringDefinitionImpl)
661 {
662 PropertyStringDefinitionImpl propDefImpl = (PropertyStringDefinitionImpl) propDef;
663 propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
664 PropertyType.STRING)));
665 } else if (propDef instanceof PropertyUriDefinitionImpl)
666 {
667 PropertyUriDefinitionImpl propDefImpl = (PropertyUriDefinitionImpl) propDef;
668 propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
669 PropertyType.URI)));
670 }
671 }
672
673 /**
674 * Adds choices to the property defintion.
675 */
676 private void addChoiceList(ListOfValuesConstraint lovc, PropertyDefinition<?> propDef)
677 {
678 if (propDef instanceof PropertyBooleanDefinitionImpl)
679 {
680 PropertyBooleanDefinitionImpl propDefImpl = (PropertyBooleanDefinitionImpl) propDef;
681 propDefImpl.setIsOpenChoice(false);
682
683 List<Choice<Boolean>> choiceList = new ArrayList<Choice<Boolean>>();
684 for (String allowed : lovc.getAllowedValues())
685 {
686 ChoiceImpl<Boolean> choice = new ChoiceImpl<Boolean>();
687 choice.setDisplayName(allowed);
688 choice.setValue(Collections.singletonList((Boolean) convertValueFromString(allowed,
689 PropertyType.BOOLEAN)));
690
691 choiceList.add(choice);
692 }
693
694 propDefImpl.setChoices(choiceList);
695 } else if (propDef instanceof PropertyDateTimeDefinitionImpl)
696 {
697 PropertyDateTimeDefinitionImpl propDefImpl = (PropertyDateTimeDefinitionImpl) propDef;
698 propDefImpl.setIsOpenChoice(false);
699
700 List<Choice<GregorianCalendar>> choiceList = new ArrayList<Choice<GregorianCalendar>>();
701 for (String allowed : lovc.getAllowedValues())
702 {
703 ChoiceImpl<GregorianCalendar> choice = new ChoiceImpl<GregorianCalendar>();
704 choice.setDisplayName(allowed);
705 choice.setValue(Collections.singletonList((GregorianCalendar) convertValueFromString(allowed,
706 PropertyType.DATETIME)));
707
708 choiceList.add(choice);
709 }
710
711 propDefImpl.setChoices(choiceList);
712 } else if (propDef instanceof PropertyDecimalDefinitionImpl)
713 {
714 PropertyDecimalDefinitionImpl propDefImpl = (PropertyDecimalDefinitionImpl) propDef;
715 propDefImpl.setIsOpenChoice(false);
716
717 List<Choice<BigDecimal>> choiceList = new ArrayList<Choice<BigDecimal>>();
718 for (String allowed : lovc.getAllowedValues())
719 {
720 ChoiceImpl<BigDecimal> choice = new ChoiceImpl<BigDecimal>();
721 choice.setDisplayName(allowed);
722 choice.setValue(Collections.singletonList((BigDecimal) convertValueFromString(allowed,
723 PropertyType.DECIMAL)));
724
725 choiceList.add(choice);
726 }
727
728 propDefImpl.setChoices(choiceList);
729 } else if (propDef instanceof PropertyHtmlDefinitionImpl)
730 {
731 PropertyHtmlDefinitionImpl propDefImpl = (PropertyHtmlDefinitionImpl) propDef;
732 propDefImpl.setIsOpenChoice(false);
733
734 List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
735 for (String allowed : lovc.getAllowedValues())
736 {
737 ChoiceImpl<String> choice = new ChoiceImpl<String>();
738 choice.setDisplayName(allowed);
739 choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.HTML)));
740
741 choiceList.add(choice);
742 }
743
744 propDefImpl.setChoices(choiceList);
745 } else if (propDef instanceof PropertyIdDefinitionImpl)
746 {
747 PropertyIdDefinitionImpl propDefImpl = (PropertyIdDefinitionImpl) propDef;
748 propDefImpl.setIsOpenChoice(false);
749
750 List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
751 for (String allowed : lovc.getAllowedValues())
752 {
753 ChoiceImpl<String> choice = new ChoiceImpl<String>();
754 choice.setDisplayName(allowed);
755 choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.ID)));
756
757 choiceList.add(choice);
758 }
759
760 propDefImpl.setChoices(choiceList);
761 } else if (propDef instanceof PropertyIntegerDefinitionImpl)
762 {
763 PropertyIntegerDefinitionImpl propDefImpl = (PropertyIntegerDefinitionImpl) propDef;
764 propDefImpl.setIsOpenChoice(false);
765
766 List<Choice<BigInteger>> choiceList = new ArrayList<Choice<BigInteger>>();
767 for (String allowed : lovc.getAllowedValues())
768 {
769 ChoiceImpl<BigInteger> choice = new ChoiceImpl<BigInteger>();
770 choice.setDisplayName(allowed);
771 choice.setValue(Collections.singletonList((BigInteger) convertValueFromString(allowed,
772 PropertyType.INTEGER)));
773
774 choiceList.add(choice);
775 }
776
777 propDefImpl.setChoices(choiceList);
778 } else if (propDef instanceof PropertyStringDefinitionImpl)
779 {
780 PropertyStringDefinitionImpl propDefImpl = (PropertyStringDefinitionImpl) propDef;
781 propDefImpl.setIsOpenChoice(false);
782
783 List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
784 for (String allowed : lovc.getAllowedValues())
785 {
786 ChoiceImpl<String> choice = new ChoiceImpl<String>();
787 choice.setDisplayName(allowed);
788 choice.setValue(Collections
789 .singletonList((String) convertValueFromString(allowed, PropertyType.STRING)));
790
791 choiceList.add(choice);
792 }
793
794 propDefImpl.setChoices(choiceList);
795 } else if (propDef instanceof PropertyUriDefinitionImpl)
796 {
797 PropertyUriDefinitionImpl propDefImpl = (PropertyUriDefinitionImpl) propDef;
798 propDefImpl.setIsOpenChoice(false);
799
800 List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
801 for (String allowed : lovc.getAllowedValues())
802 {
803 ChoiceImpl<String> choice = new ChoiceImpl<String>();
804 choice.setDisplayName(allowed);
805 choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.URI)));
806
807 choiceList.add(choice);
808 }
809
810 propDefImpl.setChoices(choiceList);
811 }
812 }
813 }
814
src/main/java/org/alfresco/opencmis/dictionary/BasePropertyDefintionWrapper.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis.dictionary;
27
28 import java.io.Serializable;
29
30 import org.alfresco.service.namespace.QName;
31 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
32
33 public class BasePropertyDefintionWrapper implements PropertyDefinitionWrapper, Serializable
34 {
35 private static final long serialVersionUID = 1L;
36
37 private PropertyDefinition<?> propDef;
38 private QName alfrescoName;
39 private TypeDefinitionWrapper owningType;
40 private CMISPropertyAccessor accessor;
41 private CMISPropertyLuceneBuilder luceneBuilder;
42
43 public BasePropertyDefintionWrapper(PropertyDefinition<?> propDef, QName alfrescoName,
44 TypeDefinitionWrapper owningType, CMISPropertyAccessor accessor, CMISPropertyLuceneBuilder luceneBuilder)
45 {
46 this.propDef = propDef;
47 this.alfrescoName = alfrescoName;
48 this.owningType = owningType;
49 this.accessor = accessor;
50 this.luceneBuilder = luceneBuilder;
51 }
52
53 @Override
54 public PropertyDefinition<?> getPropertyDefinition()
55 {
56 return propDef;
57 }
58
59 @Override
60 public String getPropertyId()
61 {
62 return propDef.getId();
63 }
64
65 @Override
66 public QName getAlfrescoName()
67 {
68 return alfrescoName;
69 }
70
71 @Override
72 public TypeDefinitionWrapper getOwningType()
73 {
74 return owningType;
75 }
76
77 @Override
78 public CMISPropertyAccessor getPropertyAccessor()
79 {
80 return accessor;
81 }
82
83 @Override
84 public CMISPropertyLuceneBuilder getPropertyLuceneBuilder()
85 {
86 return luceneBuilder;
87 }
88
89 }
90
src/main/java/org/alfresco/opencmis/dictionary/CMISAbstractDictionaryService.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis.dictionary;
27
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.Collections;
31 import java.util.List;
32 import java.util.concurrent.locks.ReentrantReadWriteLock;
33 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
34 import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
35
36 import org.alfresco.opencmis.mapping.CMISMapping;
37 import org.alfresco.repo.cache.SimpleCache;
38 import org.alfresco.repo.dictionary.CompiledModel;
39 import org.alfresco.repo.dictionary.DictionaryDAO;
40 import org.alfresco.repo.dictionary.ExtendedDictionaryListener;
41 import org.alfresco.repo.tenant.TenantService;
42 import org.alfresco.repo.tenant.TenantUtil;
43 import org.alfresco.service.cmr.dictionary.DictionaryService;
44 import org.alfresco.service.namespace.QName;
45 import org.alfresco.util.ISO9075;
46 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
47 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
48 import org.apache.commons.logging.Log;
49 import org.apache.commons.logging.LogFactory;
50 import org.springframework.context.ApplicationEvent;
51 import org.springframework.extensions.surf.util.AbstractLifecycleBean;
52
53 /**
54 * Common CMIS Dictionary Support including registry of Types.
55 *
56 * @author davidc
57 * @author florian.mueller
58 */
59 public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBean implements CMISDictionaryService,
60 ExtendedDictionaryListener
61 {
62 // Logger
63 protected static final Log logger = LogFactory.getLog(CMISAbstractDictionaryService.class);
64
65 // service dependencies
66 protected DictionaryDAO dictionaryDAO;
67 protected DictionaryService dictionaryService;
68 protected CMISMapping cmisMapping;
69 protected PropertyAccessorMapping accessorMapping;
70 protected PropertyLuceneBuilderMapping luceneBuilderMapping;
71 protected TenantService tenantService;
72
73 private final ReentrantReadWriteLock registryLock = new ReentrantReadWriteLock();
74 private final WriteLock registryWriteLock = registryLock.writeLock();
75 private final ReadLock registryReadLock = registryLock.readLock();
76
77 // note: cache is tenant-aware (if using TransctionalCache impl)
78 private SimpleCache<String, CMISDictionaryRegistry> singletonCache; // eg. for openCmisDictionaryRegistry
79 private final String KEY_OPENCMIS_DICTIONARY_REGISTRY = "key.openCmisDictionaryRegistry";
80
81 public void setTenantService(TenantService tenantService)
82 {
83 this.tenantService = tenantService;
84 }
85
86 /**
87 * Set the mapping service
88 *
89 * @param cmisMapping CMISMapping
90 */
91 public void setCmisMapping(CMISMapping cmisMapping)
92 {
93 this.cmisMapping = cmisMapping;
94 }
95
96 /**
97 * Set the property accessor mapping service
98 *
99 * @param accessorMapping mapping
100 */
101 public void setPropertyAccessorMapping(PropertyAccessorMapping accessorMapping)
102 {
103 this.accessorMapping = accessorMapping;
104 }
105
106 /**
107 * Set the property lucene mapping service
108 *
109 * @param luceneBuilderMapping mapping
110 */
111 public void setPropertyLuceneBuilderMapping(PropertyLuceneBuilderMapping luceneBuilderMapping)
112 {
113 this.luceneBuilderMapping = luceneBuilderMapping;
114 }
115
116 /**
117 * Set the dictionary Service
118 *
119 * @param dictionaryService DictionaryService
120 */
121 public void setDictionaryService(DictionaryService dictionaryService)
122 {
123 this.dictionaryService = dictionaryService;
124 }
125
126 /**
127 * Set the dictionary DAO
128 *
129 * @param dictionaryDAO DictionaryDAO
130 */
131 public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
132 {
133 this.dictionaryDAO = dictionaryDAO;
134 }
135
136 public void setSingletonCache(SimpleCache<String, CMISDictionaryRegistry> singletonCache)
137 {
138 this.singletonCache = singletonCache;
139 }
140
141 protected interface DictionaryInitializer
142 {
143 Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry);
144 Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry, CompiledModel model);
145 }
146
147 protected abstract DictionaryInitializer getCoreDictionaryInitializer();
148 protected abstract DictionaryInitializer getTenantDictionaryInitializer();
149
150 protected CMISDictionaryRegistry getRegistry()
151 {
152 String tenant = TenantUtil.getCurrentDomain();
153 return getRegistry(tenant);
154 }
155
156 CMISDictionaryRegistry getRegistry(String tenant)
157 {
158 CMISDictionaryRegistry cmisRegistry = null;
159 boolean readLockReleased = false;
160 //Make sure that DictionaryRegistry exist
161 dictionaryDAO.getDictionaryRegistry(tenant);
162
163 registryReadLock.lock();
164 try
165 {
166 String cacheKey = getCacheKey(tenant);
167 cmisRegistry = singletonCache.get(cacheKey);
168 if(cmisRegistry == null)
169 {
170 registryReadLock.unlock();
171 readLockReleased = true;
172
173 registryWriteLock.lock();
174 try
175 {
176 cmisRegistry = singletonCache.get(cacheKey);
177 if(cmisRegistry == null)
178 {
179 cmisRegistry = createDictionaryRegistry(tenant);
180 }
181 }
182 finally
183 {
184 registryWriteLock.unlock();
185 }
186 }
187 }
188 finally
189 {
190 if(!readLockReleased)
191 {
192 registryReadLock.unlock();
193 }
194 }
195
196 return cmisRegistry;
197 }
198
199 /*
200 * (non-Javadoc)
201 *
202 * @see
203 * org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap
204 * (org.springframework.context.ApplicationEvent)
205 */
206 @Override
207 protected void onBootstrap(ApplicationEvent event)
208 {
209 afterDictionaryInit();
210
211 // TODO revisit (for KS and/or 1.1)
212 if (dictionaryDAO != null)
213 {
214 dictionaryDAO.registerListener(this);
215 }
216 else
217 {
218 logger.error("DictionaryDAO is null - hence CMIS Dictionary not registered for updates");
219 }
220 }
221
222 /*
223 * (non-Javadoc)
224 *
225 * @see
226 * org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown
227 * (org.springframework.context.ApplicationEvent)
228 */
229 @Override
230 protected void onShutdown(ApplicationEvent event)
231 {
232 }
233
234 private String getCacheKey()
235 {
236 String tenant = tenantService.getCurrentUserDomain();
237 return getCacheKey(tenant);
238 }
239
240 private String getCacheKey(String tenant)
241 {
242 String cacheKey = KEY_OPENCMIS_DICTIONARY_REGISTRY + "." + tenant + "." + cmisMapping.getCmisVersion().toString();
243 return cacheKey;
244 }
245
246 protected CMISDictionaryRegistry createCoreDictionaryRegistry()
247 {
248 CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, cmisMapping, dictionaryService,
249 getCoreDictionaryInitializer());
250 cmisRegistry.init();
251 return cmisRegistry;
252 }
253
254 protected CMISDictionaryRegistry createTenantDictionaryRegistry(String tenant)
255 {
256 CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, tenant, "",
257 cmisMapping, dictionaryService, getTenantDictionaryInitializer());
258 cmisRegistry.init();
259 return cmisRegistry;
260 }
261
262 protected CMISDictionaryRegistry createDictionaryRegistryWithWriteLock()
263 {
264 CMISDictionaryRegistry cmisRegistry = null;
265
266 String tenant = TenantUtil.getCurrentDomain();
267
268 registryWriteLock.lock();
269 try
270 {
271 cmisRegistry = createDictionaryRegistry(tenant);
272 }
273 finally
274 {
275 registryWriteLock.unlock();
276 }
277
278 return cmisRegistry;
279 }
280
281 protected CMISDictionaryRegistry createDictionaryRegistry(String tenant)
282 {
283 CMISDictionaryRegistry cmisRegistry = null;
284 String cacheKey = getCacheKey(tenant);
285
286 if(tenant.equals(TenantService.DEFAULT_DOMAIN))
287 {
288 cmisRegistry = createCoreDictionaryRegistry();
289 }
290 else
291 {
292 cmisRegistry = createTenantDictionaryRegistry(tenant);
293 }
294
295 // publish new registry
296 singletonCache.put(cacheKey, cmisRegistry);
297
298 return cmisRegistry;
299 }
300
301 @Override
302 public TypeDefinitionWrapper findType(String typeId)
303 {
304 TypeDefinitionWrapper typeDef = getRegistry().getTypeDefByTypeId(typeId);
305 if (typeDef != null && typeDef.getTypeDefinition(false).getDisplayName() == null)
306 {
307 typeDef.updateDefinition(dictionaryService);
308 }
309 return typeDef;
310 }
311
312 @Override
313 public boolean isExcluded(QName qname)
314 {
315 return cmisMapping.isExcluded(qname);
316 }
317
318 @Override
319 public TypeDefinitionWrapper findTypeForClass(QName clazz, BaseTypeId... matchingScopes)
320 {
321 // searching for relationship
322 boolean scopeByRelationship = false;
323 for (BaseTypeId scope : matchingScopes)
324 {
325 if (scope == BaseTypeId.CMIS_RELATIONSHIP)
326 {
327 scopeByRelationship = true;
328 break;
329 }
330 }
331
332 // locate type in registry
333 clazz = cmisMapping.getCmisType(clazz);
334 TypeDefinitionWrapper typeDef = null;
335 if (scopeByRelationship)
336 {
337 typeDef = getRegistry().getAssocDefByQName(clazz);
338 }
339 else
340 {
341 typeDef = getRegistry().getTypeDefByQName(clazz);
342 if (typeDef == null)
343 {
344 typeDef = getRegistry().getAssocDefByQName(clazz);
345 }
346 }
347
348 // ensure matches one of provided matching scopes
349 TypeDefinitionWrapper matchingTypeDef = (matchingScopes.length == 0) ? typeDef : null;
350 if (typeDef != null)
351 {
352 for (BaseTypeId scope : matchingScopes)
353 {
354 if (typeDef.getBaseTypeId() == scope)
355 {
356 matchingTypeDef = typeDef;
357 break;
358 }
359 }
360 }
361
362 return matchingTypeDef;
363 }
364
365 @Override
366 public TypeDefinitionWrapper findNodeType(QName clazz)
367 {
368 return getRegistry().getTypeDefByQName(cmisMapping.getCmisType(clazz));
369 }
370
371 @Override
372 public TypeDefinitionWrapper findAssocType(QName clazz)
373 {
374 return getRegistry().getAssocDefByQName(cmisMapping.getCmisType(clazz));
375 }
376
377 @Override
378 public TypeDefinitionWrapper findTypeByQueryName(String queryName)
379 {
380 // ISO 9075 name look up should be lower case.
381 return getRegistry().getTypeDefByQueryName(ISO9075.lowerCaseEncodedSQL(queryName));
382 }
383
384 @Override
385 public PropertyDefinitionWrapper findProperty(String propId)
386 {
387 return getRegistry().getPropDefByPropId(propId);
388 }
389
390 @Override
391 public PropertyDefinitionWrapper findPropertyByQueryName(String queryName)
392 {
393 return getRegistry().getPropDefByQueryName(ISO9075.lowerCaseEncodedSQL(queryName));
394 }
395
396 @Override
397 public List<TypeDefinitionWrapper> getBaseTypes()
398 {
399 return getBaseTypes(true);
400 }
401
402 @Override
403 public List<TypeDefinitionWrapper> getBaseTypes(boolean includeParent)
404 {
405 List<TypeDefinitionWrapper> types = getRegistry().getBaseTypes(includeParent);
406
407 for (TypeDefinitionWrapper typeDef : types)
408 {
409 if (typeDef != null && typeDef.getTypeDefinition(false).getDisplayName() == null)
410 {
411 typeDef.updateDefinition(dictionaryService);
412 }
413 }
414
415 return Collections.unmodifiableList(types);
416 }
417
418 @Override
419 public List<TypeDefinitionWrapper> getAllTypes()
420 {
421 // TODO is there a way of not having to reconstruct this every time?
422 return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs()));
423 }
424
425 @Override
426 public List<TypeDefinitionWrapper> getAllTypes(boolean includeParent)
427 {
428 // TODO is there a way of not having to reconstruct this every time?
429 return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs(includeParent)));
430 }
431
432 @Override
433 public PropertyType findDataType(QName dataType)
434 {
435 return cmisMapping.getDataType(dataType);
436 }
437
438 @Override
439 public QName findAlfrescoDataType(PropertyType propertyType)
440 {
441 return cmisMapping.getAlfrescoDataType(propertyType);
442 }
443
444 /*
445 * (non-Javadoc)
446 *
447 * @see org.alfresco.repo.dictionary.DictionaryListener#onInit()
448 */
449 @Override
450 public void onDictionaryInit()
451 {
452 }
453
454 @Override
455 public void modelAdded(CompiledModel model, String tenantDomain)
456 {
457 getRegistry(tenantDomain).addModel(model);
458 }
459
460 /*
461 * (non-Javadoc)
462 *
463 * @see org.alfresco.repo.dictionary.DictionaryListener#afterInit()
464 */
465 @Override
466 public void afterDictionaryInit()
467 {
468 createDictionaryRegistryWithWriteLock();
469 }
470
471 /*
472 * (non-Javadoc)
473 *
474 * @see
475 * org.alfresco.repo.dictionary.DictionaryListener#afterDictionaryDestroy()
476 */
477 @Override
478 public void afterDictionaryDestroy()
479 {
480 registryWriteLock.lock();
481 try
482 {
483 String cacheKey = getCacheKey();
484 singletonCache.remove(cacheKey);
485 }
486 finally
487 {
488 registryWriteLock.unlock();
489 }
490 }
491
492 @Override
493 public List<TypeDefinitionWrapper> getChildren(String typeId)
494 {
495 List<TypeDefinitionWrapper> children = getRegistry().getChildren(typeId);
496
497 for (TypeDefinitionWrapper child : children)
498 {
499 if (child != null && child.getTypeDefinition(false).getDisplayName() == null)
500 {
501 child.updateDefinition(dictionaryService);
502 }
503 }
504
505 return children;
506 }
507 }
508
src/main/java/org/alfresco/opencmis/dictionary/CMISActionEvaluator.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.opencmis.dictionary;
27
28 import org.apache.chemistry.opencmis.commons.enums.Action;
29
30 public interface CMISActionEvaluator
31 {
32 /**
33 * Gets the CMIS Allowed Action
34 *
35 * @return Action
36 */
37 public Action getAction();
38
39 /**
40 * Determines if an action is allowed on an object
41 *
42 * @param nodeInfo CMISNodeInfo
43 * @return boolean