You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/04/22 18:28:00 UTC
svn commit: r936938 [19/29] - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/
chemistry-opencmis-server-bindings/src/main/java/org/apache/chem...
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java Thu Apr 22 16:27:57 2010
@@ -45,431 +45,431 @@ import org.apache.chemistry.opencmis.inm
*/
public class StoredObjectImpl implements StoredObject {
- protected String fId;
- protected String fName;
- protected String fTypeId;
- protected String fCreatedBy;
- protected String fModifiedBy;
- protected GregorianCalendar fCreatedAt;
- protected GregorianCalendar fModifiedAt;
- protected String fRepositoryId;
- protected Map<String, PropertyData<?>> fProperties;
- protected ObjectStoreImpl fObjStore;
-
- StoredObjectImpl(ObjectStoreImpl objStore) { // visibility should be package
- GregorianCalendar now = getNow();
- now.setTime(new Date());
- fCreatedAt = now;
- fModifiedAt = now;
- fObjStore = objStore;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
- */
- public String getId() {
- return fId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
- */
- public String getName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.
- * lang.String)
- */
- public void setName(String name) {
- fName = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
- */
- public String getTypeId() {
- return fTypeId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java
- * .lang.String)
- */
- public void setTypeId(String type) {
- fTypeId = type;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
- */
- public String getCreatedBy() {
- return fCreatedBy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(
- * java.lang.String)
- */
- public void setCreatedBy(String createdBy) {
- this.fCreatedBy = createdBy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
- */
- public String getModifiedBy() {
- return fModifiedBy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy
- * (java.lang.String)
- */
- public void setModifiedBy(String modifiedBy) {
- this.fModifiedBy = modifiedBy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
- */
- public GregorianCalendar getCreatedAt() {
- return fCreatedAt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(
- * java.util.GregorianCalendar)
- */
- public void setCreatedAt(GregorianCalendar createdAt) {
- this.fCreatedAt = createdAt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
- */
- public GregorianCalendar getModifiedAt() {
- return fModifiedAt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow
- * ()
- */
- public void setModifiedAtNow() {
- this.fModifiedAt = getNow();
- }
-
- public void setRepositoryId(String repositoryId) {
- fRepositoryId = repositoryId;
- }
-
- public String getRepositoryId() {
- return fRepositoryId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties
- * (java.util.Map)
- */
- public void setProperties(Map<String, PropertyData<?>> props) {
- fProperties = props;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
- */
- public Map<String, PropertyData<?>> getProperties() {
- return fProperties;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#
- * getChangeToken()
- */
- public String getChangeToken() {
- GregorianCalendar lastModified = getModifiedAt();
- String token = Long.valueOf(lastModified.getTimeInMillis()).toString();
- return token;
- }
-
- public void rename(String newName) {
- setName(newName);
- persist();
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
- * createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
- */
- public void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user) {
- addSystemBaseProperties(properties, user, true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
- * updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
- */
- public void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user) {
- addSystemBaseProperties(properties, user, false);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties
- * (java.util.List, org.opencmis.client.provider.ProviderObjectFactory,
- * java.util.List)
- */
- public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
- List<String> requestedIds) {
-
- if (FilterParser.isContainedInFilter(PropertyIds.NAME, requestedIds)) {
- properties.put(PropertyIds.NAME, objFactory.createPropertyStringData(PropertyIds.NAME, getName()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_ID, requestedIds)) {
- properties.put(PropertyIds.OBJECT_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_ID, getId()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_TYPE_ID, requestedIds)) {
- properties.put(PropertyIds.OBJECT_TYPE_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID,
- getTypeId()));
- }
- // set the base type id outside becaus it requires the type definition
- // if (FilterParser.isContainedInFilter(PropertyIds.CMIS_BASE_TYPE_ID,
- // requestedIds)) {
- // properties.add(objFactory.createPropertyIdData(PropertyIds.
- // CMIS_BASE_TYPE_ID, getBaseTypeId()));
- // }
- if (FilterParser.isContainedInFilter(PropertyIds.CREATED_BY, requestedIds)) {
- properties.put(PropertyIds.CREATED_BY, objFactory.createPropertyStringData(PropertyIds.CREATED_BY,
- getCreatedBy()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.CREATION_DATE, requestedIds)) {
- properties.put(PropertyIds.CREATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CREATION_DATE,
- getCreatedAt()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFIED_BY, requestedIds)) {
- properties.put(PropertyIds.LAST_MODIFIED_BY, objFactory.createPropertyStringData(
- PropertyIds.LAST_MODIFIED_BY, getModifiedBy()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFICATION_DATE, requestedIds)) {
- properties.put(PropertyIds.LAST_MODIFICATION_DATE, objFactory.createPropertyDateTimeData(
- PropertyIds.LAST_MODIFICATION_DATE, getModifiedAt()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.CHANGE_TOKEN, requestedIds)) {
- String token = getChangeToken();
- properties.put(PropertyIds.CHANGE_TOKEN, objFactory.createPropertyStringData(PropertyIds.CHANGE_TOKEN,
- token));
- }
-
- // add custom properties of type definition to the collection
- if (null != fProperties) {
- for (Entry<String, PropertyData<?>> prop : fProperties.entrySet()) {
- properties.put(prop.getKey(), prop.getValue());
- }
- }
- }
-
- // ///////////////////////////////////////////
- // private helper methods
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties
- * (java.util.Map)
- */
- public void setCustomProperties(Map<String, PropertyData<?>> properties) {
- properties = new HashMap<String, PropertyData<?>>(properties); // get a
- // writable
- // collection
- removeAllSystemProperties(properties);
- setProperties(properties);
- }
-
- private GregorianCalendar getNow() {
- GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
- return now;
- }
-
- /**
- * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
- * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
- * list of properties with current values
- */
- private void addSystemBaseProperties(Map<String, PropertyData<?>> properties, String user, boolean isCreated) {
- if (user == null)
- user = "unknown";
-
- // Note that initial creation and modification date is set in
- // constructor.
- setModifiedBy(user);
- if (isCreated) {
- setCreatedBy(user);
- setName((String) properties.get(PropertyIds.NAME).getFirstValue());
- setTypeId((String) properties.get(PropertyIds.OBJECT_TYPE_ID).getFirstValue());
- } else {
- setModifiedAtNow();
- }
- }
-
- /**
- * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
- * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
- * list of properties with current values
- */
- protected void setSystemBasePropertiesWhenCreatedDirect(String name, String typeId, String user) {
- // Note that initial creation and modification date is set in
- // constructor.
- setModifiedBy(user);
- setCreatedBy(user);
- setName(name);
- setTypeId(typeId);
- }
-
- /*
- * CMIS_NAME CMIS_OBJECT_ID CMIS_OBJECT_TYPE_ID CMIS_BASE_TYPE_ID
- * CMIS_CREATED_BY CMIS_CREATION_DATE CMIS_LAST_MODIFIED_BY
- * CMIS_LAST_MODIFICATION_DATE CMIS_CHANGE_TOKEN
- *
- * // ---- document ---- CMIS_IS_IMMUTABLE CMIS_IS_LATEST_VERSION
- * CMIS_IS_MAJOR_VERSION CMIS_IS_LATEST_MAJOR_VERSION CMIS_VERSION_LABEL
- * CMIS_VERSION_SERIES_ID CMIS_IS_VERSION_SERIES_CHECKED_OUT
- * CMIS_VERSION_SERIES_CHECKED_OUT_BY CMIS_VERSION_SERIES_CHECKED_OUT_ID
- * CMIS_CHECKIN_COMMENT CMIS_CONTENT_STREAM_LENGTH
- * CMIS_CONTENT_STREAM_MIME_TYPE CMIS_CONTENT_STREAM_FILE_NAME
- * CMIS_CONTENT_STREAM_ID
- *
- * // ---- folder ---- CMIS_PARENT_ID CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS
- * CMIS_PATH
- *
- * // ---- relationship ---- CMIS_SOURCE_ID CMIS_TARGET_ID
- *
- * // ---- policy ---- CMIS_POLICY_TEXT
- */
- private void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
- // ---- base ----
- if (properties.containsKey(PropertyIds.NAME))
- properties.remove(PropertyIds.NAME);
- if (properties.containsKey(PropertyIds.OBJECT_ID))
- properties.remove(PropertyIds.OBJECT_ID);
- if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID))
- properties.remove(PropertyIds.OBJECT_TYPE_ID);
- if (properties.containsKey(PropertyIds.BASE_TYPE_ID))
- properties.remove(PropertyIds.BASE_TYPE_ID);
- if (properties.containsKey(PropertyIds.CREATED_BY))
- properties.remove(PropertyIds.CREATED_BY);
- if (properties.containsKey(PropertyIds.CREATION_DATE))
- properties.remove(PropertyIds.CREATION_DATE);
- if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY))
- properties.remove(PropertyIds.LAST_MODIFIED_BY);
- if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE))
- properties.remove(PropertyIds.LAST_MODIFICATION_DATE);
- if (properties.containsKey(PropertyIds.CHANGE_TOKEN))
- properties.remove(PropertyIds.CHANGE_TOKEN);
- // ---- document ----
- if (properties.containsKey(PropertyIds.IS_IMMUTABLE))
- properties.remove(PropertyIds.IS_IMMUTABLE);
- if (properties.containsKey(PropertyIds.IS_LATEST_VERSION))
- properties.remove(PropertyIds.IS_LATEST_VERSION);
- if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION))
- properties.remove(PropertyIds.IS_MAJOR_VERSION);
- if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION))
- properties.remove(PropertyIds.IS_LATEST_MAJOR_VERSION);
- if (properties.containsKey(PropertyIds.VERSION_LABEL))
- properties.remove(PropertyIds.VERSION_LABEL);
- if (properties.containsKey(PropertyIds.VERSION_SERIES_ID))
- properties.remove(PropertyIds.VERSION_SERIES_ID);
- if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT))
- properties.remove(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
- if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY))
- properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
- if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID))
- properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
- if (properties.containsKey(PropertyIds.CHECKIN_COMMENT))
- properties.remove(PropertyIds.CHECKIN_COMMENT);
- if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH))
- properties.remove(PropertyIds.CONTENT_STREAM_LENGTH);
- if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE))
- properties.remove(PropertyIds.CONTENT_STREAM_MIME_TYPE);
- if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME))
- properties.remove(PropertyIds.CONTENT_STREAM_FILE_NAME);
- if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID))
- properties.remove(PropertyIds.CONTENT_STREAM_ID);
- // ---- folder ----
- if (properties.containsKey(PropertyIds.PARENT_ID))
- properties.remove(PropertyIds.PARENT_ID);
- if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS))
- properties.remove(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
- if (properties.containsKey(PropertyIds.PATH))
- properties.remove(PropertyIds.PATH);
- // ---- relationship ----
- if (properties.containsKey(PropertyIds.SOURCE_ID))
- properties.remove(PropertyIds.SOURCE_ID);
- if (properties.containsKey(PropertyIds.TARGET_ID))
- properties.remove(PropertyIds.TARGET_ID);
- // ---- policy ----
- if (properties.containsKey(PropertyIds.POLICY_TEXT))
- properties.remove(PropertyIds.POLICY_TEXT);
- }
-
- public void persist() {
- // in-memory implementation does not need to to anything to persist,
- // but after this call the id should be set.
- fId = fObjStore.storeObject(this);
+ protected String fId;
+ protected String fName;
+ protected String fTypeId;
+ protected String fCreatedBy;
+ protected String fModifiedBy;
+ protected GregorianCalendar fCreatedAt;
+ protected GregorianCalendar fModifiedAt;
+ protected String fRepositoryId;
+ protected Map<String, PropertyData<?>> fProperties;
+ protected ObjectStoreImpl fObjStore;
+
+ StoredObjectImpl(ObjectStoreImpl objStore) { // visibility should be package
+ GregorianCalendar now = getNow();
+ now.setTime(new Date());
+ fCreatedAt = now;
+ fModifiedAt = now;
+ fObjStore = objStore;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
+ */
+ public String getId() {
+ return fId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.
+ * lang.String)
+ */
+ public void setName(String name) {
+ fName = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
+ */
+ public String getTypeId() {
+ return fTypeId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java
+ * .lang.String)
+ */
+ public void setTypeId(String type) {
+ fTypeId = type;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
+ */
+ public String getCreatedBy() {
+ return fCreatedBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(
+ * java.lang.String)
+ */
+ public void setCreatedBy(String createdBy) {
+ this.fCreatedBy = createdBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
+ */
+ public String getModifiedBy() {
+ return fModifiedBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy
+ * (java.lang.String)
+ */
+ public void setModifiedBy(String modifiedBy) {
+ this.fModifiedBy = modifiedBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
+ */
+ public GregorianCalendar getCreatedAt() {
+ return fCreatedAt;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(
+ * java.util.GregorianCalendar)
+ */
+ public void setCreatedAt(GregorianCalendar createdAt) {
+ this.fCreatedAt = createdAt;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
+ */
+ public GregorianCalendar getModifiedAt() {
+ return fModifiedAt;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow
+ * ()
+ */
+ public void setModifiedAtNow() {
+ this.fModifiedAt = getNow();
+ }
+
+ public void setRepositoryId(String repositoryId) {
+ fRepositoryId = repositoryId;
+ }
+
+ public String getRepositoryId() {
+ return fRepositoryId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties
+ * (java.util.Map)
+ */
+ public void setProperties(Map<String, PropertyData<?>> props) {
+ fProperties = props;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
+ */
+ public Map<String, PropertyData<?>> getProperties() {
+ return fProperties;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#
+ * getChangeToken()
+ */
+ public String getChangeToken() {
+ GregorianCalendar lastModified = getModifiedAt();
+ String token = Long.valueOf(lastModified.getTimeInMillis()).toString();
+ return token;
+ }
+
+ public void rename(String newName) {
+ setName(newName);
+ persist();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
+ * createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
+ */
+ public void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user) {
+ addSystemBaseProperties(properties, user, true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
+ * updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
+ */
+ public void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user) {
+ addSystemBaseProperties(properties, user, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties
+ * (java.util.List, org.opencmis.client.provider.ProviderObjectFactory,
+ * java.util.List)
+ */
+ public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+ List<String> requestedIds) {
+
+ if (FilterParser.isContainedInFilter(PropertyIds.NAME, requestedIds)) {
+ properties.put(PropertyIds.NAME, objFactory.createPropertyStringData(PropertyIds.NAME, getName()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_ID, requestedIds)) {
+ properties.put(PropertyIds.OBJECT_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_ID, getId()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_TYPE_ID, requestedIds)) {
+ properties.put(PropertyIds.OBJECT_TYPE_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID,
+ getTypeId()));
+ }
+ // set the base type id outside becaus it requires the type definition
+ // if (FilterParser.isContainedInFilter(PropertyIds.CMIS_BASE_TYPE_ID,
+ // requestedIds)) {
+ // properties.add(objFactory.createPropertyIdData(PropertyIds.
+ // CMIS_BASE_TYPE_ID, getBaseTypeId()));
+ // }
+ if (FilterParser.isContainedInFilter(PropertyIds.CREATED_BY, requestedIds)) {
+ properties.put(PropertyIds.CREATED_BY, objFactory.createPropertyStringData(PropertyIds.CREATED_BY,
+ getCreatedBy()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CREATION_DATE, requestedIds)) {
+ properties.put(PropertyIds.CREATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CREATION_DATE,
+ getCreatedAt()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFIED_BY, requestedIds)) {
+ properties.put(PropertyIds.LAST_MODIFIED_BY, objFactory.createPropertyStringData(
+ PropertyIds.LAST_MODIFIED_BY, getModifiedBy()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFICATION_DATE, requestedIds)) {
+ properties.put(PropertyIds.LAST_MODIFICATION_DATE, objFactory.createPropertyDateTimeData(
+ PropertyIds.LAST_MODIFICATION_DATE, getModifiedAt()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CHANGE_TOKEN, requestedIds)) {
+ String token = getChangeToken();
+ properties.put(PropertyIds.CHANGE_TOKEN, objFactory.createPropertyStringData(PropertyIds.CHANGE_TOKEN,
+ token));
+ }
+
+ // add custom properties of type definition to the collection
+ if (null != fProperties) {
+ for (Entry<String, PropertyData<?>> prop : fProperties.entrySet()) {
+ properties.put(prop.getKey(), prop.getValue());
+ }
+ }
+ }
+
+ // ///////////////////////////////////////////
+ // private helper methods
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties
+ * (java.util.Map)
+ */
+ public void setCustomProperties(Map<String, PropertyData<?>> properties) {
+ properties = new HashMap<String, PropertyData<?>>(properties); // get a
+ // writable
+ // collection
+ removeAllSystemProperties(properties);
+ setProperties(properties);
+ }
+
+ private GregorianCalendar getNow() {
+ GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ return now;
+ }
+
+ /**
+ * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
+ * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
+ * list of properties with current values
+ */
+ private void addSystemBaseProperties(Map<String, PropertyData<?>> properties, String user, boolean isCreated) {
+ if (user == null)
+ user = "unknown";
+
+ // Note that initial creation and modification date is set in
+ // constructor.
+ setModifiedBy(user);
+ if (isCreated) {
+ setCreatedBy(user);
+ setName((String) properties.get(PropertyIds.NAME).getFirstValue());
+ setTypeId((String) properties.get(PropertyIds.OBJECT_TYPE_ID).getFirstValue());
+ } else {
+ setModifiedAtNow();
+ }
+ }
+
+ /**
+ * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
+ * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
+ * list of properties with current values
+ */
+ protected void setSystemBasePropertiesWhenCreatedDirect(String name, String typeId, String user) {
+ // Note that initial creation and modification date is set in
+ // constructor.
+ setModifiedBy(user);
+ setCreatedBy(user);
+ setName(name);
+ setTypeId(typeId);
+ }
+
+ /*
+ * CMIS_NAME CMIS_OBJECT_ID CMIS_OBJECT_TYPE_ID CMIS_BASE_TYPE_ID
+ * CMIS_CREATED_BY CMIS_CREATION_DATE CMIS_LAST_MODIFIED_BY
+ * CMIS_LAST_MODIFICATION_DATE CMIS_CHANGE_TOKEN
+ *
+ * // ---- document ---- CMIS_IS_IMMUTABLE CMIS_IS_LATEST_VERSION
+ * CMIS_IS_MAJOR_VERSION CMIS_IS_LATEST_MAJOR_VERSION CMIS_VERSION_LABEL
+ * CMIS_VERSION_SERIES_ID CMIS_IS_VERSION_SERIES_CHECKED_OUT
+ * CMIS_VERSION_SERIES_CHECKED_OUT_BY CMIS_VERSION_SERIES_CHECKED_OUT_ID
+ * CMIS_CHECKIN_COMMENT CMIS_CONTENT_STREAM_LENGTH
+ * CMIS_CONTENT_STREAM_MIME_TYPE CMIS_CONTENT_STREAM_FILE_NAME
+ * CMIS_CONTENT_STREAM_ID
+ *
+ * // ---- folder ---- CMIS_PARENT_ID CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS
+ * CMIS_PATH
+ *
+ * // ---- relationship ---- CMIS_SOURCE_ID CMIS_TARGET_ID
+ *
+ * // ---- policy ---- CMIS_POLICY_TEXT
+ */
+ private void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
+ // ---- base ----
+ if (properties.containsKey(PropertyIds.NAME))
+ properties.remove(PropertyIds.NAME);
+ if (properties.containsKey(PropertyIds.OBJECT_ID))
+ properties.remove(PropertyIds.OBJECT_ID);
+ if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID))
+ properties.remove(PropertyIds.OBJECT_TYPE_ID);
+ if (properties.containsKey(PropertyIds.BASE_TYPE_ID))
+ properties.remove(PropertyIds.BASE_TYPE_ID);
+ if (properties.containsKey(PropertyIds.CREATED_BY))
+ properties.remove(PropertyIds.CREATED_BY);
+ if (properties.containsKey(PropertyIds.CREATION_DATE))
+ properties.remove(PropertyIds.CREATION_DATE);
+ if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY))
+ properties.remove(PropertyIds.LAST_MODIFIED_BY);
+ if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE))
+ properties.remove(PropertyIds.LAST_MODIFICATION_DATE);
+ if (properties.containsKey(PropertyIds.CHANGE_TOKEN))
+ properties.remove(PropertyIds.CHANGE_TOKEN);
+ // ---- document ----
+ if (properties.containsKey(PropertyIds.IS_IMMUTABLE))
+ properties.remove(PropertyIds.IS_IMMUTABLE);
+ if (properties.containsKey(PropertyIds.IS_LATEST_VERSION))
+ properties.remove(PropertyIds.IS_LATEST_VERSION);
+ if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION))
+ properties.remove(PropertyIds.IS_MAJOR_VERSION);
+ if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION))
+ properties.remove(PropertyIds.IS_LATEST_MAJOR_VERSION);
+ if (properties.containsKey(PropertyIds.VERSION_LABEL))
+ properties.remove(PropertyIds.VERSION_LABEL);
+ if (properties.containsKey(PropertyIds.VERSION_SERIES_ID))
+ properties.remove(PropertyIds.VERSION_SERIES_ID);
+ if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT))
+ properties.remove(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+ if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY))
+ properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
+ if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID))
+ properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
+ if (properties.containsKey(PropertyIds.CHECKIN_COMMENT))
+ properties.remove(PropertyIds.CHECKIN_COMMENT);
+ if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH))
+ properties.remove(PropertyIds.CONTENT_STREAM_LENGTH);
+ if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE))
+ properties.remove(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+ if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME))
+ properties.remove(PropertyIds.CONTENT_STREAM_FILE_NAME);
+ if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID))
+ properties.remove(PropertyIds.CONTENT_STREAM_ID);
+ // ---- folder ----
+ if (properties.containsKey(PropertyIds.PARENT_ID))
+ properties.remove(PropertyIds.PARENT_ID);
+ if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS))
+ properties.remove(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
+ if (properties.containsKey(PropertyIds.PATH))
+ properties.remove(PropertyIds.PATH);
+ // ---- relationship ----
+ if (properties.containsKey(PropertyIds.SOURCE_ID))
+ properties.remove(PropertyIds.SOURCE_ID);
+ if (properties.containsKey(PropertyIds.TARGET_ID))
+ properties.remove(PropertyIds.TARGET_ID);
+ // ---- policy ----
+ if (properties.containsKey(PropertyIds.POLICY_TEXT))
+ properties.remove(PropertyIds.POLICY_TEXT);
+ }
+
+ public void persist() {
+ // in-memory implementation does not need to to anything to persist,
+ // but after this call the id should be set.
+ fId = fObjStore.storeObject(this);
- }
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java Thu Apr 22 16:27:57 2010
@@ -34,151 +34,151 @@ import org.apache.chemistry.opencmis.inm
public class VersionedDocumentImpl extends AbstractMultiFilingImpl implements VersionedDocument {
- private boolean fIsCheckedOut;
- private String fCheckedOutUser;
- private List<DocumentVersion> fVersions;
-
- public VersionedDocumentImpl(ObjectStoreImpl objStore) {
- super(objStore);
- fVersions = new ArrayList<DocumentVersion>();
- fIsCheckedOut = false;
- }
-
- public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
-
- if (isCheckedOut())
- throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
-
- DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
- ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
- // name
- // and
- // type
- // id
- // from
- // version
- // series
- // .
- ver.persist();
- fVersions.add(ver);
- if (verState == VersioningState.CHECKEDOUT) {
- fCheckedOutUser = user;
- fIsCheckedOut = true;
- }
-
- return ver;
- }
-
- public boolean deleteVersion(DocumentVersion version) {
- if (fIsCheckedOut)
- throw new RuntimeException("version cannot be deleted if document is checked-out: " + version.getId());
- boolean found = fVersions.remove(version);
- if (!found)
- throw new RuntimeException("Version is not contained in the document:" + version.getId());
-
- return !fVersions.isEmpty();
- }
-
- public void cancelCheckOut(String user) {
- DocumentVersion pwc = getPwc();
- fVersions.remove(pwc);
- fObjStore.removeVersion(pwc);
- fIsCheckedOut = false;
- fCheckedOutUser = null;
- }
-
- public void checkIn(boolean isMajor, String checkinComment, String user) {
- if (fIsCheckedOut) {
- if (fCheckedOutUser.equals(user)) {
- fIsCheckedOut = false;
- fCheckedOutUser = null;
- } else {
- throw new CmisConstraintException("Error: Can't checkin. Document " + getId() + " user " + user
- + " has not checked out the document");
- }
- } else
- throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId()
- + " is not checked out.");
-
- DocumentVersion pwc = getPwc();
- pwc.setCheckinComment(checkinComment);
- pwc.commit(isMajor);
- }
-
- public DocumentVersion checkOut(ContentStream content, String user) {
- if (fIsCheckedOut) {
- throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
- }
-
- // create PWC
- DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will
- // set
- // check
- // -
- // out
- // flag
- return pwc;
- }
-
- public List<DocumentVersion> getAllVersions() {
- return fVersions;
- }
-
- public DocumentVersion getLatestVersion(boolean major) {
-
- DocumentVersion latest = null;
- if (major) {
- for (DocumentVersion ver : fVersions) {
- if (ver.isMajor())
- latest = ver;
- }
- } else {
- latest = fVersions.get(fVersions.size() - 1);
- }
- return latest;
- }
-
- public boolean isCheckedOut() {
- return fIsCheckedOut;
- }
-
- public String getCheckedOutBy() {
- return fCheckedOutUser;
- }
-
- public DocumentVersion getPwc() {
- for (DocumentVersion ver : fVersions) {
- if (ver.isPwc())
- return ver;
- }
- return null;
- }
-
- public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
- List<String> requestedIds) {
-
- DocumentVersion pwc = getPwc();
-
- super.fillProperties(properties, objFactory, requestedIds);
-
- // overwrite the version related properties
- if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
- properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(
- PropertyIds.VERSION_SERIES_ID, getId()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
- properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(
- PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
- properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(
- PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
- }
- if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
- properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(
- PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
- }
+ private boolean fIsCheckedOut;
+ private String fCheckedOutUser;
+ private List<DocumentVersion> fVersions;
+
+ public VersionedDocumentImpl(ObjectStoreImpl objStore) {
+ super(objStore);
+ fVersions = new ArrayList<DocumentVersion>();
+ fIsCheckedOut = false;
+ }
+
+ public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
+
+ if (isCheckedOut())
+ throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
+
+ DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
+ ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
+ // name
+ // and
+ // type
+ // id
+ // from
+ // version
+ // series
+ // .
+ ver.persist();
+ fVersions.add(ver);
+ if (verState == VersioningState.CHECKEDOUT) {
+ fCheckedOutUser = user;
+ fIsCheckedOut = true;
+ }
+
+ return ver;
+ }
+
+ public boolean deleteVersion(DocumentVersion version) {
+ if (fIsCheckedOut)
+ throw new RuntimeException("version cannot be deleted if document is checked-out: " + version.getId());
+ boolean found = fVersions.remove(version);
+ if (!found)
+ throw new RuntimeException("Version is not contained in the document:" + version.getId());
+
+ return !fVersions.isEmpty();
+ }
+
+ public void cancelCheckOut(String user) {
+ DocumentVersion pwc = getPwc();
+ fVersions.remove(pwc);
+ fObjStore.removeVersion(pwc);
+ fIsCheckedOut = false;
+ fCheckedOutUser = null;
+ }
+
+ public void checkIn(boolean isMajor, String checkinComment, String user) {
+ if (fIsCheckedOut) {
+ if (fCheckedOutUser.equals(user)) {
+ fIsCheckedOut = false;
+ fCheckedOutUser = null;
+ } else {
+ throw new CmisConstraintException("Error: Can't checkin. Document " + getId() + " user " + user
+ + " has not checked out the document");
+ }
+ } else
+ throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId()
+ + " is not checked out.");
+
+ DocumentVersion pwc = getPwc();
+ pwc.setCheckinComment(checkinComment);
+ pwc.commit(isMajor);
+ }
+
+ public DocumentVersion checkOut(ContentStream content, String user) {
+ if (fIsCheckedOut) {
+ throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
+ }
+
+ // create PWC
+ DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will
+ // set
+ // check
+ // -
+ // out
+ // flag
+ return pwc;
+ }
+
+ public List<DocumentVersion> getAllVersions() {
+ return fVersions;
+ }
+
+ public DocumentVersion getLatestVersion(boolean major) {
+
+ DocumentVersion latest = null;
+ if (major) {
+ for (DocumentVersion ver : fVersions) {
+ if (ver.isMajor())
+ latest = ver;
+ }
+ } else {
+ latest = fVersions.get(fVersions.size() - 1);
+ }
+ return latest;
+ }
+
+ public boolean isCheckedOut() {
+ return fIsCheckedOut;
+ }
+
+ public String getCheckedOutBy() {
+ return fCheckedOutUser;
+ }
+
+ public DocumentVersion getPwc() {
+ for (DocumentVersion ver : fVersions) {
+ if (ver.isPwc())
+ return ver;
+ }
+ return null;
+ }
+
+ public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+ List<String> requestedIds) {
+
+ DocumentVersion pwc = getPwc();
+
+ super.fillProperties(properties, objFactory, requestedIds);
+
+ // overwrite the version related properties
+ if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
+ properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(
+ PropertyIds.VERSION_SERIES_ID, getId()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
+ properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(
+ PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
+ properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(
+ PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
+ properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(
+ PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+ }
- }
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java Thu Apr 22 16:27:57 2010
@@ -40,239 +40,239 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.inmemory.TypeCreator;
public class DefaultTypeSystemCreator implements TypeCreator {
- static public List<TypeDefinition> singletonTypes = buildTypesList();
- public static final String COMPLEX_TYPE = "ComplexType";
- public static final String TOPLEVEL_TYPE = "DocumentTopLevel";
- public static final String VERSIONED_TYPE = "VersionableType";
- public static final String LEVEL1_TYPE = "DocumentLevel1";;
- public static final String LEVEL2_TYPE = "DocumentLevel2";
-
- /**
- * in the public interface of this class we return the singleton containing
- * the required types for testing
- */
- public List<TypeDefinition> createTypesList() {
- return singletonTypes;
- }
-
- public static List<TypeDefinition> getTypesList() {
- return singletonTypes;
- }
-
- static public TypeDefinition getTypeById(String typeId) {
- for (TypeDefinition typeDef : singletonTypes)
- if (typeDef.getId().equals(typeId))
- return typeDef;
- return null;
- }
-
- /**
- * create root types and a collection of sample types
- *
- * @return typesMap map filled with created types
- */
- private static List<TypeDefinition> buildTypesList() {
- // always add CMIS default types
- List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
-
- InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
- "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
- typesList.add(cmisType1);
-
- InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
- "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
- typesList.add(cmisType2);
-
- InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
- "My Type 3 Level 2", cmisType1);
- typesList.add(cmisType11);
-
- InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
- "My Type 4 Level 3", cmisType11);
- typesList.add(cmisType111);
-
- InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
- "My Type 5 Level 3", cmisType11);
- typesList.add(cmisType112);
-
- InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
- "My Type 6 Level 2", cmisType1);
- typesList.add(cmisType12);
-
- InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
- "My Type 7 Level 2", cmisType2);
- typesList.add(cmisType21);
-
- InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
- "My Type 8 Level 2", cmisType2);
- typesList.add(cmisType22);
- InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
- "My Type 9 Level 2", cmisType2);
- typesList.add(cmisType23);
- DocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4", "My Type 10 Level 2",
- cmisType2);
- typesList.add(cmisType24);
- InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
- "My Type 11 Level 2", cmisType2);
- typesList.add(cmisType25);
-
- InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
- "My Type 12 Level 2", cmisType2);
- typesList.add(cmisType26);
- InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
- "My Type 13 Level 2", cmisType2);
- typesList.add(cmisType27);
- InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
- "My Type 14 Level 2", cmisType2);
- typesList.add(cmisType28);
- InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
- "My Type 15 Level 2", cmisType2);
- typesList.add(cmisType29);
-
- // create a complex type with properties
- InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
- "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a boolean property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
- "Sample Boolean Property");
- propertyDefinitions.put(prop.getId(), prop);
-
- prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
- "Sample Boolean multi-value Property");
- propertyDefinitions.put(prop.getId(), prop);
-
- PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
- "Sample DateTime Property");
- propertyDefinitions.put(prop2.getId(), prop2);
-
- prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
- "Sample DateTime multi-value Property");
- propertyDefinitions.put(prop2.getId(), prop2);
-
- PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
- "Sample Decimal Property");
- propertyDefinitions.put(prop3.getId(), prop3);
-
- prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property");
- propertyDefinitions.put(prop3.getId(), prop3);
-
- PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
- "Sample Html Property");
- propertyDefinitions.put(prop4.getId(), prop4);
-
- prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property");
- propertyDefinitions.put(prop4.getId(), prop4);
-
- PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property");
- propertyDefinitions.put(prop5.getId(), prop5);
-
- prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property");
- propertyDefinitions.put(prop5.getId(), prop5);
-
- PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
- "Sample Int Property");
- propertyDefinitions.put(prop6.getId(), prop6);
-
- prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property");
- propertyDefinitions.put(prop6.getId(), prop6);
-
- PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
- "Sample String Property");
- propertyDefinitions.put(prop7.getId(), prop7);
-
- PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property");
- propertyDefinitions.put(prop8.getId(), prop8);
-
- prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property");
- propertyDefinitions.put(prop8.getId(), prop8);
-
- PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
- "Sample Pick List Property");
- List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
- ChoiceImpl<String> elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("red"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("green"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("blue"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("black"));
- choiceList.add(elem);
- prop9.setChoices(choiceList);
- prop9.setDefaultValue(Collections.singletonList("blue"));
-
- /*
- * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
- * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
- * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
- * PropertyCreationHelper.addElemToPicklist(prop9, "black");
- * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
- */
-
- cmisComplexType.setPropertyDefinitions(propertyDefinitions);
-
- // add type to types collection
- typesList.add(cmisComplexType);
-
- // create a type hierarchy with inherited properties
- InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
- "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
- "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-
- InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
- "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
- "Sample String Property");
- propertyDefinitions.put(propTop.getId(), propTop);
- cmisDocTypeTopLevel.setPropertyDefinitions(propertyDefinitions);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
- "String Property Level 1");
- propertyDefinitions.put(propLevel1.getId(), propLevel1);
- cmisDocTypeLevel1.setPropertyDefinitions(propertyDefinitions);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
- "String Property Level 2");
- propertyDefinitions.put(propLevel2.getId(), propLevel2);
- cmisDocTypeLevel2.setPropertyDefinitions(propertyDefinitions);
-
- // add type to types collection
- typesList.add(cmisDocTypeTopLevel);
- typesList.add(cmisDocTypeLevel1);
- typesList.add(cmisDocTypeLevel2);
-
- // Create a type that is versionable
- InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
- "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a single String property definition
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
- "Sample String Property");
- propertyDefinitions.put(prop1.getId(), prop1);
+ static public List<TypeDefinition> singletonTypes = buildTypesList();
+ public static final String COMPLEX_TYPE = "ComplexType";
+ public static final String TOPLEVEL_TYPE = "DocumentTopLevel";
+ public static final String VERSIONED_TYPE = "VersionableType";
+ public static final String LEVEL1_TYPE = "DocumentLevel1";;
+ public static final String LEVEL2_TYPE = "DocumentLevel2";
+
+ /**
+ * in the public interface of this class we return the singleton containing
+ * the required types for testing
+ */
+ public List<TypeDefinition> createTypesList() {
+ return singletonTypes;
+ }
+
+ public static List<TypeDefinition> getTypesList() {
+ return singletonTypes;
+ }
+
+ static public TypeDefinition getTypeById(String typeId) {
+ for (TypeDefinition typeDef : singletonTypes)
+ if (typeDef.getId().equals(typeId))
+ return typeDef;
+ return null;
+ }
+
+ /**
+ * create root types and a collection of sample types
+ *
+ * @return typesMap map filled with created types
+ */
+ private static List<TypeDefinition> buildTypesList() {
+ // always add CMIS default types
+ List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+
+ InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
+ "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+ typesList.add(cmisType1);
+
+ InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
+ "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+ typesList.add(cmisType2);
+
+ InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
+ "My Type 3 Level 2", cmisType1);
+ typesList.add(cmisType11);
+
+ InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
+ "My Type 4 Level 3", cmisType11);
+ typesList.add(cmisType111);
+
+ InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
+ "My Type 5 Level 3", cmisType11);
+ typesList.add(cmisType112);
+
+ InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
+ "My Type 6 Level 2", cmisType1);
+ typesList.add(cmisType12);
+
+ InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
+ "My Type 7 Level 2", cmisType2);
+ typesList.add(cmisType21);
+
+ InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
+ "My Type 8 Level 2", cmisType2);
+ typesList.add(cmisType22);
+ InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
+ "My Type 9 Level 2", cmisType2);
+ typesList.add(cmisType23);
+ DocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4", "My Type 10 Level 2",
+ cmisType2);
+ typesList.add(cmisType24);
+ InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
+ "My Type 11 Level 2", cmisType2);
+ typesList.add(cmisType25);
+
+ InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
+ "My Type 12 Level 2", cmisType2);
+ typesList.add(cmisType26);
+ InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
+ "My Type 13 Level 2", cmisType2);
+ typesList.add(cmisType27);
+ InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
+ "My Type 14 Level 2", cmisType2);
+ typesList.add(cmisType28);
+ InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
+ "My Type 15 Level 2", cmisType2);
+ typesList.add(cmisType29);
+
+ // create a complex type with properties
+ InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
+ "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+ // create a boolean property definition
+
+ Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+
+ PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
+ "Sample Boolean Property");
+ propertyDefinitions.put(prop.getId(), prop);
+
+ prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
+ "Sample Boolean multi-value Property");
+ propertyDefinitions.put(prop.getId(), prop);
+
+ PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
+ "Sample DateTime Property");
+ propertyDefinitions.put(prop2.getId(), prop2);
+
+ prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
+ "Sample DateTime multi-value Property");
+ propertyDefinitions.put(prop2.getId(), prop2);
+
+ PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
+ "Sample Decimal Property");
+ propertyDefinitions.put(prop3.getId(), prop3);
+
+ prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property");
+ propertyDefinitions.put(prop3.getId(), prop3);
+
+ PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
+ "Sample Html Property");
+ propertyDefinitions.put(prop4.getId(), prop4);
+
+ prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property");
+ propertyDefinitions.put(prop4.getId(), prop4);
+
+ PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property");
+ propertyDefinitions.put(prop5.getId(), prop5);
+
+ prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property");
+ propertyDefinitions.put(prop5.getId(), prop5);
+
+ PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
+ "Sample Int Property");
+ propertyDefinitions.put(prop6.getId(), prop6);
+
+ prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property");
+ propertyDefinitions.put(prop6.getId(), prop6);
+
+ PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
+ "Sample String Property");
+ propertyDefinitions.put(prop7.getId(), prop7);
+
+ PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property");
+ propertyDefinitions.put(prop8.getId(), prop8);
+
+ prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property");
+ propertyDefinitions.put(prop8.getId(), prop8);
+
+ PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+ "Sample Pick List Property");
+ List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+ ChoiceImpl<String> elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("red"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("green"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("blue"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("black"));
+ choiceList.add(elem);
+ prop9.setChoices(choiceList);
+ prop9.setDefaultValue(Collections.singletonList("blue"));
+
+ /*
+ * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
+ * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
+ * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
+ * PropertyCreationHelper.addElemToPicklist(prop9, "black");
+ * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
+ */
+
+ cmisComplexType.setPropertyDefinitions(propertyDefinitions);
+
+ // add type to types collection
+ typesList.add(cmisComplexType);
+
+ // create a type hierarchy with inherited properties
+ InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
+ "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+ InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
+ "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
+
+ InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
+ "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
+
+ propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
+ "Sample String Property");
+ propertyDefinitions.put(propTop.getId(), propTop);
+ cmisDocTypeTopLevel.setPropertyDefinitions(propertyDefinitions);
+
+ propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
+ "String Property Level 1");
+ propertyDefinitions.put(propLevel1.getId(), propLevel1);
+ cmisDocTypeLevel1.setPropertyDefinitions(propertyDefinitions);
+
+ propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
+ "String Property Level 2");
+ propertyDefinitions.put(propLevel2.getId(), propLevel2);
+ cmisDocTypeLevel2.setPropertyDefinitions(propertyDefinitions);
+
+ // add type to types collection
+ typesList.add(cmisDocTypeTopLevel);
+ typesList.add(cmisDocTypeLevel1);
+ typesList.add(cmisDocTypeLevel2);
+
+ // Create a type that is versionable
+ InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
+ "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+ // create a single String property definition
+
+ propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+
+ PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
+ "Sample String Property");
+ propertyDefinitions.put(prop1.getId(), prop1);
- cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
- cmisVersionedType.setIsVersionable(true); // make it a versionable type;
+ cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisVersionedType.setIsVersionable(true); // make it a versionable type;
- // add type to types collection
- typesList.add(cmisVersionedType);
+ // add type to types collection
+ typesList.add(cmisVersionedType);
- return typesList;
- }
+ return typesList;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java Thu Apr 22 16:27:57 2010
@@ -36,219 +36,219 @@ import org.apache.chemistry.opencmis.com
public class DocumentTypeCreationHelper {
- static private List<TypeDefinition> defaultTypes = createCmisDefaultTypes();
+ static private List<TypeDefinition> defaultTypes = createCmisDefaultTypes();
- static public List<TypeDefinition> createMapWithDefaultTypes() {
- List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
- typesList.addAll(defaultTypes);
- return typesList;
- }
-
- static public final List<TypeDefinition> getDefaultTypes() {
- return defaultTypes;
- }
-
- static private List<TypeDefinition> createCmisDefaultTypes() {
- List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
-
- // create root types:
- TypeDefinition cmisType = InMemoryDocumentTypeDefinition.getRootDocumentType();
- typesList.add(cmisType);
-
- cmisType = InMemoryFolderTypeDefinition.getRootFolderType();
- typesList.add(cmisType);
-
- // cmisType = RelationshipTypeDefinition.getRootRelationshipType();
- // typesList.add(cmisType);
- //
- // cmisType = PolicyTypeDefinition.getRootPolicyType();
- // typesList.add(cmisType);
-
- return typesList;
- }
-
- /**
- * create root types and a collection of sample types
- *
- * @return typesMap map filled with created types
- */
- static public List<TypeDefinition> createDefaultTypes() {
- List<TypeDefinition> typesList = createCmisDefaultTypes();
-
- return typesList;
- }
-
- public static void setBasicPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
-
- PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.NAME,
- "CMIS Name Property");
- propS.setUpdatability(Updatability.READWRITE);
- propertyDefinitions.put(propS.getId(), propS);
-
- PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.OBJECT_ID,
- "CMIS Object Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.OBJECT_TYPE_ID, "CMIS Object Type Id Property");
- propId.setUpdatability(Updatability.ONCREATE);
- propId.setIsRequired(true);
- propertyDefinitions.put(propId.getId(), propId);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.BASE_TYPE_ID, "CMIS Base Type Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CREATED_BY, "CMIS Created By Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- PropertyDateTimeDefinitionImpl propD = PropertyCreationHelper.createDateTimeDefinition(
- PropertyIds.CREATION_DATE, "CMIS Creation Date Property");
- propD.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propD.getId(), propD);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.LAST_MODIFIED_BY,
- "CMIS Last Modified By Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- propD = PropertyCreationHelper.createDateTimeDefinition(PropertyIds.LAST_MODIFICATION_DATE,
- "CMIS Last Modification Date Property");
- propD.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propD.getId(), propD);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CHANGE_TOKEN, "CMIS Change Token Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
- }
-
- public static void setBasicDocumentPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
-
- setBasicPropertyDefinitions(propertyDefinitions);
- PropertyBooleanDefinitionImpl propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_IMMUTABLE,
- "CMIS Is Immutable Property");
- propB.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propB.getId(), propB);
-
- propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_LATEST_VERSION,
- "CMIS Is Latest Version Property");
- propB.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propB.getId(), propB);
-
- propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_MAJOR_VERSION,
- "CMIS Is Major Version Property");
- propB.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propB.getId(), propB);
-
- propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_LATEST_MAJOR_VERSION,
- "CMIS Is Latest Major Version Property");
- propB.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propB.getId(), propB);
-
- PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.VERSION_LABEL,
- "CMIS Version Label Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.VERSION_SERIES_ID,
- "CMIS Version Series Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
- "CMIS Is Version Series Checked Out Property");
- propB.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propB.getId(), propB);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY,
- "CMIS Version Series Checked Out By Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
- "CMIS Version Series Checked Out Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CHECKIN_COMMENT,
- "CMIS Checkin Comment Property");
- propId.setUpdatability(Updatability.READONLY); // Note: spec says
- // read-only, because
- // not set as property
- propertyDefinitions.put(propS.getId(), propS);
-
- PropertyIntegerDefinitionImpl propI = PropertyCreationHelper.createIntegerDefinition(
- PropertyIds.CONTENT_STREAM_LENGTH, "CMIS Content Stream Length Property");
- propI.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propI.getId(), propI);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CONTENT_STREAM_MIME_TYPE,
- "CMIS Content Stream Mime Type Property");
- propS.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CONTENT_STREAM_FILE_NAME,
- "CMIS Content Stream File Name Property");
- propertyDefinitions.put(propS.getId(), propS);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.CONTENT_STREAM_ID, "CMIS Stream Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- }
-
- public static void setBasicFolderPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
-
- setBasicPropertyDefinitions(propertyDefinitions);
- PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.PARENT_ID,
- "CMIS Parent Id Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propId.getId(), propId);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
- "CMIS Allowed Childe Object Type Ids Property");
- propId.setUpdatability(Updatability.READONLY);
- propId.setCardinality(Cardinality.MULTI);
- propertyDefinitions.put(propId.getId(), propId);
-
- PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.PATH,
- "CMIS Path Property");
- propId.setUpdatability(Updatability.READONLY);
- propertyDefinitions.put(propS.getId(), propS);
-
- }
-
- public static void setBasicPolicyPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
-
- setBasicPropertyDefinitions(propertyDefinitions);
- PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.POLICY_TEXT,
- "CMIS Policy Text Property");
- propS.setIsRequired(true);
- propertyDefinitions.put(propS.getId(), propS);
- }
-
- public static void setBasicRelationshipPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
-
- setBasicPropertyDefinitions(propertyDefinitions);
- PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.SOURCE_ID,
- "CMIS Source Id Property");
- propId.setIsRequired(true);
- propertyDefinitions.put(propId.getId(), propId);
-
- propId = PropertyCreationHelper.createIdDefinition(PropertyIds.TARGET_ID, "CMIS Target Id Property");
- propId.setIsRequired(true);
- propertyDefinitions.put(propId.getId(), propId);
- }
-
- public static void mergePropertyDefinitions(Map<String, PropertyDefinition<?>> existingPpropertyDefinitions,
- Map<String, PropertyDefinition<?>> newPropertyDefinitions) {
- for (String propId : newPropertyDefinitions.keySet()) {
- if (existingPpropertyDefinitions.containsKey(propId))
- throw new RuntimeException("You can't set a property with id " + propId
- + ". This property id already exists already or exists in supertype");
- }
- existingPpropertyDefinitions.putAll(newPropertyDefinitions);
- }
+ static public List<TypeDefinition> createMapWithDefaultTypes() {
+ List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+ typesList.addAll(defaultTypes);
+ return typesList;
+ }
+
+ static public final List<TypeDefinition> getDefaultTypes() {
+ return defaultTypes;
+ }
+
+ static private List<TypeDefinition> createCmisDefaultTypes() {
+ List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+
+ // create root types:
+ TypeDefinition cmisType = InMemoryDocumentTypeDefinition.getRootDocumentType();
+ typesList.add(cmisType);
+
+ cmisType = InMemoryFolderTypeDefinition.getRootFolderType();
+ typesList.add(cmisType);
+
+ // cmisType = RelationshipTypeDefinition.getRootRelationshipType();
+ // typesList.add(cmisType);
+ //
+ // cmisType = PolicyTypeDefinition.getRootPolicyType();
+ // typesList.add(cmisType);
+
+ return typesList;
+ }
+
+ /**
+ * create root types and a collection of sample types
+ *
+ * @return typesMap map filled with created types
+ */
+ static public List<TypeDefinition> createDefaultTypes() {
+ List<TypeDefinition> typesList = createCmisDefaultTypes();
+
+ return typesList;
+ }
+
+ public static void setBasicPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+ PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.NAME,
+ "CMIS Name Property");
+ propS.setUpdatability(Updatability.READWRITE);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.OBJECT_ID,
+ "CMIS Object Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.OBJECT_TYPE_ID, "CMIS Object Type Id Property");
+ propId.setUpdatability(Updatability.ONCREATE);
+ propId.setIsRequired(true);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.BASE_TYPE_ID, "CMIS Base Type Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CREATED_BY, "CMIS Created By Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ PropertyDateTimeDefinitionImpl propD = PropertyCreationHelper.createDateTimeDefinition(
+ PropertyIds.CREATION_DATE, "CMIS Creation Date Property");
+ propD.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propD.getId(), propD);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.LAST_MODIFIED_BY,
+ "CMIS Last Modified By Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ propD = PropertyCreationHelper.createDateTimeDefinition(PropertyIds.LAST_MODIFICATION_DATE,
+ "CMIS Last Modification Date Property");
+ propD.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propD.getId(), propD);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CHANGE_TOKEN, "CMIS Change Token Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+ }
+
+ public static void setBasicDocumentPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+ setBasicPropertyDefinitions(propertyDefinitions);
+ PropertyBooleanDefinitionImpl propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_IMMUTABLE,
+ "CMIS Is Immutable Property");
+ propB.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propB.getId(), propB);
+
+ propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_LATEST_VERSION,
+ "CMIS Is Latest Version Property");
+ propB.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propB.getId(), propB);
+
+ propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_MAJOR_VERSION,
+ "CMIS Is Major Version Property");
+ propB.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propB.getId(), propB);
+
+ propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_LATEST_MAJOR_VERSION,
+ "CMIS Is Latest Major Version Property");
+ propB.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propB.getId(), propB);
+
+ PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.VERSION_LABEL,
+ "CMIS Version Label Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.VERSION_SERIES_ID,
+ "CMIS Version Series Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
+ "CMIS Is Version Series Checked Out Property");
+ propB.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propB.getId(), propB);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY,
+ "CMIS Version Series Checked Out By Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
+ "CMIS Version Series Checked Out Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CHECKIN_COMMENT,
+ "CMIS Checkin Comment Property");
+ propId.setUpdatability(Updatability.READONLY); // Note: spec says
+ // read-only, because
+ // not set as property
+ propertyDefinitions.put(propS.getId(), propS);
+
+ PropertyIntegerDefinitionImpl propI = PropertyCreationHelper.createIntegerDefinition(
+ PropertyIds.CONTENT_STREAM_LENGTH, "CMIS Content Stream Length Property");
+ propI.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propI.getId(), propI);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CONTENT_STREAM_MIME_TYPE,
+ "CMIS Content Stream Mime Type Property");
+ propS.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ propS = PropertyCreationHelper.createStringDefinition(PropertyIds.CONTENT_STREAM_FILE_NAME,
+ "CMIS Content Stream File Name Property");
+ propertyDefinitions.put(propS.getId(), propS);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.CONTENT_STREAM_ID, "CMIS Stream Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ }
+
+ public static void setBasicFolderPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+ setBasicPropertyDefinitions(propertyDefinitions);
+ PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.PARENT_ID,
+ "CMIS Parent Id Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
+ "CMIS Allowed Childe Object Type Ids Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propId.setCardinality(Cardinality.MULTI);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.PATH,
+ "CMIS Path Property");
+ propId.setUpdatability(Updatability.READONLY);
+ propertyDefinitions.put(propS.getId(), propS);
+
+ }
+
+ public static void setBasicPolicyPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+ setBasicPropertyDefinitions(propertyDefinitions);
+ PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.POLICY_TEXT,
+ "CMIS Policy Text Property");
+ propS.setIsRequired(true);
+ propertyDefinitions.put(propS.getId(), propS);
+ }
+
+ public static void setBasicRelationshipPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+ setBasicPropertyDefinitions(propertyDefinitions);
+ PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(PropertyIds.SOURCE_ID,
+ "CMIS Source Id Property");
+ propId.setIsRequired(true);
+ propertyDefinitions.put(propId.getId(), propId);
+
+ propId = PropertyCreationHelper.createIdDefinition(PropertyIds.TARGET_ID, "CMIS Target Id Property");
+ propId.setIsRequired(true);
+ propertyDefinitions.put(propId.getId(), propId);
+ }
+
+ public static void mergePropertyDefinitions(Map<String, PropertyDefinition<?>> existingPpropertyDefinitions,
+ Map<String, PropertyDefinition<?>> newPropertyDefinitions) {
+ for (String propId : newPropertyDefinitions.keySet()) {
+ if (existingPpropertyDefinitions.containsKey(propId))
+ throw new RuntimeException("You can't set a property with id " + propId
+ + ". This property id already exists already or exists in supertype");
+ }
+ existingPpropertyDefinitions.putAll(newPropertyDefinitions);
+ }
}