Revision: 44
Author:
mark....@alfresco.com
Date: Thu Aug 14 17:19:40 2014 UTC
Log: Created tag 1.0
http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/source/detail?r=44
Added:
/tags/1.0
Deleted:
/tags/1.0/src/main/java/org/alfresco/cmis/client/TransientAlfrescoDocument.java
/tags/1.0/src/main/java/org/alfresco/cmis/client/TransientAlfrescoFolder.java
/tags/1.0/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoAspectsImpl.java
/tags/1.0/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoDocumentImpl.java
/tags/1.0/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoFolderImpl.java
Replaced:
/tags/1.0/pom.xml
/tags/1.0/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentImpl.java
/tags/1.0/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderImpl.java
=======================================
---
/trunk/src/main/java/org/alfresco/cmis/client/TransientAlfrescoDocument.java
Mon Apr 4 11:55:46 2011 UTC
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2005-2011 Alfresco Software Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.alfresco.cmis.client;
-
-import org.apache.chemistry.opencmis.client.api.TransientDocument;
-
-public interface TransientAlfrescoDocument extends TransientDocument,
AlfrescoAspects
-{
-}
=======================================
---
/trunk/src/main/java/org/alfresco/cmis/client/TransientAlfrescoFolder.java
Mon Apr 4 11:55:46 2011 UTC
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2005-2011 Alfresco Software Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.alfresco.cmis.client;
-
-import org.apache.chemistry.opencmis.client.api.TransientFolder;
-
-public interface TransientAlfrescoFolder extends TransientFolder,
AlfrescoAspects
-{
-}
=======================================
---
/trunk/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoAspectsImpl.java
Tue Jul 9 07:15:24 2013 UTC
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2005-2011 Alfresco Software Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.alfresco.cmis.client.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.alfresco.cmis.client.AlfrescoAspects;
-import org.alfresco.cmis.client.AlfrescoDocument;
-import org.alfresco.cmis.client.AlfrescoFolder;
-import org.apache.chemistry.opencmis.client.api.CmisObject;
-import org.apache.chemistry.opencmis.client.api.ObjectType;
-import org.apache.chemistry.opencmis.client.api.Session;
-import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
-import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
-import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel;
-
-public class TransientAlfrescoAspectsImpl implements AlfrescoAspects {
- private Session session;
- private CmisObject object;
- private Map<String, ObjectType> aspectTypes;
- private Map<String, ObjectType> addAspectTypes;
- private Map<String, ObjectType> removeAspectTypes;
-
- public TransientAlfrescoAspectsImpl(Session session, CmisObject object) {
- this.session = session;
- this.object = object;
-
- List<CmisExtensionElement> alfrescoExtensions = AlfrescoUtils
- .findAlfrescoExtensions(object
- .getExtensions(ExtensionLevel.PROPERTIES));
-
- if (alfrescoExtensions == null) {
- aspectTypes = Collections.emptyMap();
- } else {
- aspectTypes = new HashMap<String, ObjectType>();
- for (ObjectType type : AlfrescoUtils.getAspectTypes(session,
- alfrescoExtensions)) {
- if (type != null) {
- aspectTypes.put(type.getId(), type);
- }
- }
- }
-
- addAspectTypes = new HashMap<String, ObjectType>();
- removeAspectTypes = new HashMap<String, ObjectType>();
- }
-
- public ObjectType getTypeWithAspects() {
- if (object instanceof AlfrescoDocument) {
- return new AlfrescoDocumentTypeImpl((AlfrescoDocument) object);
- } else if (object instanceof AlfrescoFolder) {
- return new AlfrescoFolderTypeImpl((AlfrescoFolder) object);
- } else {
- return object.getType();
- }
- }
-
- public boolean hasAspect(String id) {
- return (aspectTypes.containsKey(id) || addAspectTypes.containsKey(id))
- && (!removeAspectTypes.containsKey(id));
- }
-
- public boolean hasAspect(ObjectType type) {
- return type == null ? false : hasAspect(type.getId());
- }
-
- public Collection<ObjectType> getAspects() {
- Collection<ObjectType> result = new ArrayList<ObjectType>();
- Set<String> addTypes = new HashSet<String>(addAspectTypes.keySet());
-
- for (String typeId : aspectTypes.keySet()) {
- if (!removeAspectTypes.containsKey(typeId)) {
- result.add(aspectTypes.get(typeId));
- }
- addTypes.remove(typeId);
- }
-
- for (String typeId : addTypes) {
- result.add(addAspectTypes.get(typeId));
- }
-
- return result;
- }
-
- public ObjectType findAspect(String propertyId) {
- return AlfrescoUtils.findAspect(getAspects(), propertyId);
- }
-
- public CmisObject addAspect(String... id) {
- if (id == null || id.length == 0) {
- throw new IllegalArgumentException("Id must be set!");
- }
-
- ObjectType[] types = new ObjectType[id.length];
- for (int i = 0; i < id.length; i++) {
- types[i] = session.getTypeDefinition(id[i]);
- }
-
- return addAspect(types);
- }
-
- public CmisObject addAspect(ObjectType... type) {
- if (type == null || type.length == 0) {
- throw new IllegalArgumentException("Type must be set!");
- }
-
- for (ObjectType t : type) {
- if (t != null) {
- addAspectTypes.put(t.getId(), t);
- removeAspectTypes.remove(t.getId());
- }
- }
-
- return object;
- }
-
- public void setPropertyValues(TransientCmisObject object,
- Map<String, ?> properties) {
- if (properties == null || properties.isEmpty()) {
- return;
- }
-
- for (Map.Entry<String, ?> property : properties.entrySet()) {
- object.setPropertyValue(property.getKey(), property.getValue());
- }
- }
-
- public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
- return addAspect(type);
- }
-
- public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
- return addAspect(type);
- }
-
- public CmisObject addAspect(String id, Map<String, ?> properties) {
- return addAspect(id);
- }
-
- public CmisObject addAspect(String[] id, Map<String, ?> properties) {
- return addAspect(id);
- }
-
- public CmisObject removeAspect(String... id) {
- if (id == null || id.length == 0) {
- throw new IllegalArgumentException("Id must be set!");
- }
-
- ObjectType[] types = new ObjectType[id.length];
- for (int i = 0; i < id.length; i++) {
- types[i] = session.getTypeDefinition(id[i]);
- }
-
- return removeAspect(types);
- }
-
- public CmisObject removeAspect(ObjectType... type) {
- if (type == null || type.length == 0) {
- throw new IllegalArgumentException("Type must be set!");
- }
-
- for (ObjectType t : type) {
- if (t != null) {
- addAspectTypes.remove(t.getId());
- removeAspectTypes.put(t.getId(), t);
- }
- }
- return object;
- }
-
- public void save() {
- if (addAspectTypes.isEmpty() && removeAspectTypes.isEmpty()) {
- return;
- }
-
- AlfrescoUtils.updateAspects(session, object,
- addAspectTypes.values().toArray(new ObjectType[0]),
- removeAspectTypes.values().toArray(new ObjectType[0]), null);
- }
-}
=======================================
---
/trunk/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoDocumentImpl.java
Tue Jul 9 07:15:24 2013 UTC
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2005-2011 Alfresco Software Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.alfresco.cmis.client.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.alfresco.cmis.client.TransientAlfrescoDocument;
-import org.apache.chemistry.opencmis.client.api.CmisObject;
-import org.apache.chemistry.opencmis.client.api.ObjectId;
-import org.apache.chemistry.opencmis.client.api.ObjectType;
-import org.apache.chemistry.opencmis.client.api.Property;
-import org.apache.chemistry.opencmis.client.api.Session;
-import org.apache.chemistry.opencmis.client.runtime.TransientDocumentImpl;
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.enums.Updatability;
-
-public class TransientAlfrescoDocumentImpl extends TransientDocumentImpl
- implements TransientAlfrescoDocument {
- protected TransientAlfrescoAspectsImpl aspects;
-
- @Override
- protected void initialize(Session session, CmisObject object) {
- super.initialize(session, object);
- aspects = new TransientAlfrescoAspectsImpl(session, object);
- }
-
- public ObjectType getTypeWithAspects()
- {
- return aspects.getTypeWithAspects();
- }
-
- @SuppressWarnings("unchecked")
- public <T> void setPropertyValue(String id, Object value) {
- ObjectType aspectType = aspects.findAspect(id);
-
- if (aspectType == null) {
- super.setPropertyValue(id, value);
- return;
- }
-
- PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>)
aspectType
- .getPropertyDefinitions().get(id);
- if (propertyDefinition == null) {
- throw new IllegalArgumentException("Unknown property '" + id + "'!");
- }
- // check updatability
- if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
- throw new IllegalArgumentException("Property is read-only!");
- }
-
- List<T> values = AlfrescoUtils.checkProperty(propertyDefinition,
- value);
-
- // create and set property
- Property<T> newProperty = getObjectFactory().createProperty(
- propertyDefinition, values);
- properties.put(id, newProperty);
-
- isPropertyUpdateRequired = true;
- isModified = true;
- }
-
- public boolean hasAspect(String id) {
- return aspects.hasAspect(id);
- }
-
- public boolean hasAspect(ObjectType type) {
- return aspects.hasAspect(type);
- }
-
- public Collection<ObjectType> getAspects() {
- return aspects.getAspects();
- }
-
- public ObjectType findAspect(String propertyId) {
- return aspects.findAspect(propertyId);
- }
-
- public CmisObject addAspect(String... id) {
- return aspects.addAspect(id);
- }
-
- public CmisObject addAspect(ObjectType... type) {
- return aspects.addAspect(type);
- }
-
- public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
- CmisObject cmisObject = aspects.addAspect(type);
- aspects.setPropertyValues(this, properties);
- return cmisObject;
- }
-
- public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
- CmisObject cmisObject = aspects.addAspect(type);
- aspects.setPropertyValues(this, properties);
- return cmisObject;
- }
-
- public CmisObject addAspect(String id, Map<String, ?> properties) {
- CmisObject cmisObject = aspects.addAspect(id);
- aspects.setPropertyValues(this, properties);
- return cmisObject;
- }
-
- public CmisObject addAspect(String[] id, Map<String, ?> properties) {
- CmisObject cmisObject = aspects.addAspect(id);
- aspects.setPropertyValues(this, properties);
- return cmisObject;
- }
-
- public CmisObject removeAspect(String... id) {
- return aspects.removeAspect(id);
- }
-
- public CmisObject removeAspect(ObjectType... type) {
- return aspects.removeAspect(type);
- }
-
- @Override
- public ObjectId save() {
- ObjectId id = super.save();
- if (!isMarkedForDelete) {
- aspects.save();
- }
-
- return id;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected Properties prepareProperties() {
- ObjectType type = getType();
- PropertyDefinition<String> propDef = (PropertyDefinition<String>) type
- .getPropertyDefinitions().get(PropertyIds.OBJECT_TYPE_ID);
- String objectTypeIdValue = AlfrescoUtils
- .createObjectTypeIdValue(type, getAspects());
- Property<String> objectTypeIdProperty = getObjectFactory()
- .createProperty(propDef,
- Collections.singletonList(objectTypeIdValue));
-
- properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeIdProperty);
-
- return super.prepareProperties();
- }
-}
=======================================
---
/trunk/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoFolderImpl.java
Tue Jul 9 07:15:24 2013 UTC
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2005-2011 Alfresco Software Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.alfresco.cmis.client.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.alfresco.cmis.client.AlfrescoAspects;
-import org.apache.chemistry.opencmis.client.api.CmisObject;
-import org.apache.chemistry.opencmis.client.api.ObjectId;
-import org.apache.chemistry.opencmis.client.api.ObjectType;
-import org.apache.chemistry.opencmis.client.api.Property;
-import org.apache.chemistry.opencmis.client.api.Session;
-import org.apache.chemistry.opencmis.client.runtime.TransientFolderImpl;
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.enums.Updatability;
-
-public class TransientAlfrescoFolderImpl extends TransientFolderImpl
implements AlfrescoAspects
-{
- protected TransientAlfrescoAspectsImpl aspects;
-
- @Override
- protected void initialize(Session session, CmisObject object)
- {
- super.initialize(session, object);
- aspects = new TransientAlfrescoAspectsImpl(session, object);
- }
-
- public ObjectType getTypeWithAspects()
- {
- return aspects.getTypeWithAspects();
- }
-
- @SuppressWarnings("unchecked")
- public <T> void setPropertyValue(String id, Object value)
- {
- ObjectType aspectType = aspects.findAspect(id);
-
- if (aspectType == null)
- {
- super.setPropertyValue(id, value);
- return;
- }
-
- PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>)
aspectType.getPropertyDefinitions().get(id);
- if (propertyDefinition == null)
- {
- throw new IllegalArgumentException("Unknown property '" + id
+ "'!");
- }
- // check updatability
- if (propertyDefinition.getUpdatability() == Updatability.READONLY)
- {
- throw new IllegalArgumentException("Property is read-only!");
- }
-
- List<T> values = AlfrescoUtils.checkProperty(propertyDefinition,
value);
-
- // create and set property
- Property<T> newProperty =
getObjectFactory().createProperty(propertyDefinition, values);
- properties.put(id, newProperty);
-
- isPropertyUpdateRequired = true;
- isModified = true;
- }
-
- public boolean hasAspect(String id)
- {
- return aspects.hasAspect(id);
- }
-
- public boolean hasAspect(ObjectType type)
- {
- return aspects.hasAspect(type);
- }
-
- public Collection<ObjectType> getAspects()
- {
- return aspects.getAspects();
- }
-
- public ObjectType findAspect(String propertyId)
- {
- return aspects.findAspect(propertyId);
- }
-
- public CmisObject addAspect(String... id)
- {
- return aspects.addAspect(id);
- }
-
- public CmisObject addAspect(ObjectType... type)
- {
- return aspects.addAspect(type);
- }
-
- public CmisObject removeAspect(String... id)
- {
- return aspects.removeAspect(id);
- }
-
- public CmisObject addAspect(ObjectType type, Map<String, ?> properties)
- {
- CmisObject ret = aspects.addAspect(type);
- aspects.setPropertyValues(this, properties);
- return ret;
- }
-
- public CmisObject addAspect(ObjectType[] type, Map<String, ?>
properties)
- {
- CmisObject ret = aspects.addAspect(type);
- aspects.setPropertyValues(this, properties);
- return ret;
- }
-
- public CmisObject addAspect(String id, Map<String, ?> properties)
- {
- CmisObject ret = aspects.addAspect(id);
- aspects.setPropertyValues(this, properties);
- return ret;
- }
-
- public CmisObject addAspect(String[] id, Map<String, ?> properties)
- {
- CmisObject ret = aspects.addAspect(id);
- aspects.setPropertyValues(this, properties);
- return ret;
- }
-
- public CmisObject removeAspect(ObjectType... type)
- {
- return aspects.removeAspect(type);
- }
-
- @Override
- public ObjectId save()
- {
- ObjectId id = super.save();
- if (!isMarkedForDelete)
- {
- aspects.save();
- }
-
- return id;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected Properties prepareProperties()
- {
- ObjectType type = getType();
- PropertyDefinition<String> propDef = (PropertyDefinition<String>)
type.getPropertyDefinitions().get(
- PropertyIds.OBJECT_TYPE_ID);
- String objectTypeIdValue =
AlfrescoUtils.createObjectTypeIdValue(type, getAspects());
- Property<String> objectTypeIdProperty =
getObjectFactory().createProperty(propDef,
- Collections.singletonList(objectTypeIdValue));
-
- properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeIdProperty);
-
- return super.prepareProperties();
- }
-}