You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by sf...@apache.org on 2011/04/24 18:12:31 UTC
svn commit: r1096340 [3/7] - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/j...
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java Sun Apr 24 16:12:27 2011
@@ -34,16 +34,16 @@ import org.apache.chemistry.opencmis.inm
public class BaseServiceValidatorImpl implements CmisServiceValidator {
protected final StoreManager fStoreManager;
-
+
public BaseServiceValidatorImpl(StoreManager sm) {
fStoreManager = sm;
}
/**
- * check if repository is known and that object exists. To avoid later calls
+ * Check if repository is known and that object exists. To avoid later calls
* to again retrieve the object from the id return the retrieved object for
* later use.
- *
+ *
* @param repositoryId
* repository id
* @param objectId
@@ -51,22 +51,25 @@ public class BaseServiceValidatorImpl im
* @return object for objectId
*/
protected StoredObject checkStandardParameters(String repositoryId, String objectId) {
-
- if (null == repositoryId)
+ if (null == repositoryId) {
throw new CmisInvalidArgumentException("Repository Id cannot be null.");
+ }
- if (null == objectId)
+ if (null == objectId) {
throw new CmisInvalidArgumentException("Object Id cannot be null.");
+ }
ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
- if (objStore == null)
+ if (objStore == null) {
throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId);
+ }
StoredObject so = objStore.getObjectById(objectId);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
return so;
}
@@ -74,21 +77,24 @@ public class BaseServiceValidatorImpl im
protected StoredObject checkStandardParametersAllowNull(String repositoryId, String objectId) {
StoredObject so = null;
-
- if (null == repositoryId)
+
+ if (null == repositoryId) {
throw new CmisInvalidArgumentException("Repository Id cannot be null.");
+ }
if (null != objectId) {
ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
- if (objStore == null)
+ if (objStore == null) {
throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId);
+ }
so = objStore.getObjectById(objectId);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
}
return so;
@@ -96,25 +102,29 @@ public class BaseServiceValidatorImpl im
protected StoredObject checkExistingObjectId(ObjectStore objStore, String objectId) {
- if (null == objectId)
+ if (null == objectId) {
throw new CmisInvalidArgumentException("Object Id cannot be null.");
+ }
StoredObject so = objStore.getObjectById(objectId);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
return so;
}
protected void checkRepositoryId(String repositoryId) {
- if (null == repositoryId)
+ if (null == repositoryId) {
throw new CmisInvalidArgumentException("Repository Id cannot be null.");
-
+ }
+
ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
- if (objStore == null)
+ if (objStore == null) {
throw new CmisInvalidArgumentException("Unknown repository id: " + repositoryId);
+ }
}
protected StoredObject[] checkParams(String repositoryId, String objectId1, String objectId2) {
@@ -124,12 +134,12 @@ public class BaseServiceValidatorImpl im
so[1] = checkExistingObjectId(objectStore, objectId2);
return so;
}
-
- public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
+
+ public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
}
public void getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
-
+
checkRepositoryId(repositoryId);
}
@@ -170,22 +180,22 @@ public class BaseServiceValidatorImpl im
public StoredObject getObjectParents(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject getFolderParent(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, folderId);
}
public StoredObject getCheckedOutDocs(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
-
- if (null != folderId)
+
+ if (null != folderId) {
return checkStandardParameters(repositoryId, folderId);
- else {
+ } else {
checkRepositoryId(repositoryId);
return null;
}
@@ -193,7 +203,7 @@ public class BaseServiceValidatorImpl im
}
public StoredObject createDocument(CallContext context, String repositoryId, String folderId,
- ExtensionsData extension) {
+ ExtensionsData extension) {
return checkStandardParametersAllowNull(repositoryId, folderId);
}
@@ -217,47 +227,47 @@ public class BaseServiceValidatorImpl im
public StoredObject getAllowableActions(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
- //
+ //
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject getObject(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject getProperties(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject getRenditions(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public void getObjectByPath(CallContext context, String repositoryId, String path, ExtensionsData extension) {
-
+
checkRepositoryId(repositoryId);
}
public StoredObject getContentStream(CallContext context, String repositoryId, String objectId, String streamId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject updateProperties(CallContext context, String repositoryId, Holder<String> objectId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId.getValue());
}
public StoredObject[] moveObject(CallContext context, String repositoryId, Holder<String> objectId,
String targetFolderId, String sourceFolderId, ExtensionsData extension) {
-
+
StoredObject[] res = new StoredObject[3];
res [0] = checkStandardParameters(repositoryId, objectId.getValue());
res[1] = checkExistingObjectId(fStoreManager.getObjectStore(repositoryId), sourceFolderId);
@@ -278,7 +288,7 @@ public class BaseServiceValidatorImpl im
public StoredObject setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
Boolean overwriteFlag, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId.getValue());
}
@@ -295,7 +305,7 @@ public class BaseServiceValidatorImpl im
public StoredObject cancelCheckOut(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
@@ -306,7 +316,7 @@ public class BaseServiceValidatorImpl im
public StoredObject getObjectOfLatestVersion(CallContext context, String repositoryId, String objectId,
String versionSeriesId, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, versionSeriesId == null ? objectId : versionSeriesId);
}
@@ -318,46 +328,46 @@ public class BaseServiceValidatorImpl im
public StoredObject getAllVersions(CallContext context, String repositoryId, String objectId,
String versionSeriesId, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, versionSeriesId == null ? objectId : versionSeriesId);
}
public void query(CallContext context, String repositoryId, ExtensionsData extension) {
-
+
checkRepositoryId(repositoryId);
}
public void getContentChanges(CallContext context, String repositoryId, ExtensionsData extension) {
-
+
checkRepositoryId(repositoryId);
}
public StoredObject[] addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId,
Boolean allVersions, ExtensionsData extension) {
-
+
return checkParams(repositoryId, objectId, folderId);
}
public StoredObject[] removeObjectFromFolder(CallContext context, String repositoryId, String objectId,
String folderId, ExtensionsData extension) {
-
+
return checkParams(repositoryId, objectId, folderId);
}
public StoredObject getObjectRelationships(CallContext context, String repositoryId, String objectId,
RelationshipDirection relationshipDirection, String typeId, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject getAcl(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
public StoredObject applyAcl(CallContext context, String repositoryId, String objectId,
AclPropagation aclPropagation, ExtensionsData extension) {
-
+
return checkStandardParameters(repositoryId, objectId);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -33,9 +33,9 @@ import org.apache.chemistry.opencmis.inm
/**
* Common functionality for all service implementations
- *
+ *
* @author Jens
- *
+ *
*/
public class InMemoryAbstractServiceImpl {
@@ -49,14 +49,15 @@ public class InMemoryAbstractServiceImpl
protected InMemoryAbstractServiceImpl(StoreManager storeManager) {
this.fStoreManager = storeManager;
- this.validator = storeManager.getServiceValidator();
+ this.validator = storeManager.getServiceValidator();
}
protected TypeDefinition getTypeDefinition(String repositoryId, Properties properties) {
String typeId = (String) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue();
TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
- if (typeDefC == null)
+ if (typeDefC == null) {
throw new CmisInvalidArgumentException("Cannot create object, a type with id " + typeId + " is unknown");
+ }
return typeDefC.getTypeDefinition();
}
@@ -71,7 +72,7 @@ public class InMemoryAbstractServiceImpl
* We allow checkin, cancel, checkout operations on a single version as well
* as on a version series This method returns the versioned document
* (version series) in each case
- *
+ *
* @param value
* version or version series id of a document
* @return version series id
@@ -92,8 +93,9 @@ public class InMemoryAbstractServiceImpl
protected VersionedDocument testIsNotCheckedOutBySomeoneElse(StoredObject so, String user) {
checkIsVersionableObject(so);
VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
- if (verDoc.isCheckedOut())
+ if (verDoc.isCheckedOut()) {
testCheckedOutByCurrentUser(user, verDoc);
+ }
return verDoc;
}
@@ -112,25 +114,29 @@ public class InMemoryAbstractServiceImpl
}
protected void checkIsVersionableObject(StoredObject so) {
- if (!(so instanceof VersionedDocument || so instanceof DocumentVersion))
+ if (!(so instanceof VersionedDocument || so instanceof DocumentVersion)) {
throw new CmisInvalidArgumentException(
"Object is of a versionable type but not instance of VersionedDocument or DocumentVersion.");
+ }
}
protected void checkHasUser(String user) {
- if (null == user || user.length() == 0)
+ if (null == user || user.length() == 0) {
throw new CmisPermissionDeniedException("Object can't be checked-in, no user is given.");
+ }
}
protected void testCheckedOutByCurrentUser(String user, VersionedDocument verDoc) {
- if (!user.equals(verDoc.getCheckedOutBy()))
+ if (!user.equals(verDoc.getCheckedOutBy())) {
throw new CmisUpdateConflictException("Object can't be checked-in, user " + verDoc.getCheckedOutBy()
+ " has checked out the document.");
+ }
}
protected void testIsCheckedOut(VersionedDocument verDoc) {
- if (!verDoc.isCheckedOut())
+ if (!verDoc.isCheckedOut()) {
throw new CmisUpdateConflictException("Canot check-in: Document " + verDoc.getId() + " is not checked out.");
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -48,11 +48,12 @@ public class InMemoryMultiFilingServiceI
LOG.debug("Begin addObjectToFolder()");
- StoredObject[] sos = validator.addObjectToFolder(context, repositoryId, objectId, folderId, allVersions, extension);
+ StoredObject[] sos = validator.addObjectToFolder(context, repositoryId, objectId, folderId, allVersions, extension);
- if (allVersions != null && allVersions.booleanValue() == false)
+ if (allVersions != null && allVersions.booleanValue() == false) {
throw new CmisNotSupportedException(
"Cannot add object to folder, version specific filing is not supported.");
+ }
StoredObject so = sos[0];
StoredObject folder = sos[1];
checkObjects(so, folder);
@@ -76,9 +77,9 @@ public class InMemoryMultiFilingServiceI
LOG.debug("Begin removeObjectFromFolder()");
- StoredObject[] sos = validator.removeObjectFromFolder(context, repositoryId, objectId, folderId, extension);
+ StoredObject[] sos = validator.removeObjectFromFolder(context, repositoryId, objectId, folderId, extension);
StoredObject so = sos[0];
-
+
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
StoredObject folder = sos[1];
@@ -99,18 +100,21 @@ public class InMemoryMultiFilingServiceI
LOG.debug("End removeObjectFromFolder()");
}
- private void checkObjects(StoredObject so, StoredObject folder) {
- if (!(so instanceof MultiFiling))
+ private static void checkObjects(StoredObject so, StoredObject folder) {
+ if (!(so instanceof MultiFiling)) {
throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId()
+ " is not a multi-filed object.");
+ }
- if ((so instanceof Folder))
+ if ((so instanceof Folder)) {
throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId()
+ " is a folder and folders are not multi-filed.");
+ }
- if (!(folder instanceof Folder))
+ if (!(folder instanceof Folder)) {
throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId()
+ " does not refer to a folder.");
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -130,7 +130,7 @@ public class InMemoryNavigationServiceIm
LOG.debug("start getChildren()");
- validator.getChildren(repositoryId, folderId, extension);
+ validator.getChildren(repositoryId, folderId, extension);
int maxItemsInt = maxItems == null ? -1 : maxItems.intValue();
int skipCountInt = skipCount == null ? -1 : skipCount.intValue();
@@ -152,13 +152,13 @@ public class InMemoryNavigationServiceIm
validator.getDescendants(context, repositoryId, folderId, extension);
int levels;
- if (depth == null)
+ if (depth == null) {
levels = 2; // one of the recommended defaults (should it be
- // -1?)
- else if (depth.intValue() == 0)
+ } else if (depth.intValue() == 0) {
throw new CmisInvalidArgumentException("A zero depth is not allowed for getDescendants().");
- else
+ } else {
levels = depth.intValue();
+ }
int level = 0;
String user = context.getUsername();
@@ -175,18 +175,20 @@ public class InMemoryNavigationServiceIm
LOG.debug("start getFolderParent()");
- StoredObject so = validator.getFolderParent(context, repositoryId, folderId, extension);
+ StoredObject so = validator.getFolderParent(context, repositoryId, folderId, extension);
Folder folder = null;
- if (so instanceof Folder)
+ if (so instanceof Folder) {
folder = (Folder) so;
- else
+ } else {
throw new CmisInvalidArgumentException("Can't get folder parent, id does not refer to a folder: "
+ folderId);
+ }
ObjectData res = getFolderParentIntern(repositoryId, folder, filter, context.isObjectInfoRequired() ? objectInfos : null);
- if (res == null)
+ if (res == null) {
throw new CmisInvalidArgumentException("Cannot get parent of a root folder");
+ }
// To be able to provide all Atom links in the response we need
// additional information:
@@ -209,8 +211,9 @@ public class InMemoryNavigationServiceIm
validator.getFolderTree(context, repositoryId, folderId, extension);
- if (depth != null && depth.intValue() == 0)
+ if (depth != null && depth.intValue() == 0) {
throw new CmisInvalidArgumentException("A zero depth is not allowed for getFolderTree().");
+ }
int levels = depth == null ? 2 : depth.intValue();
int level = 0;
@@ -230,7 +233,7 @@ public class InMemoryNavigationServiceIm
LOG.debug("start getObjectParents()");
- StoredObject so = validator.getObjectParents(context, repositoryId, objectId, extension);
+ StoredObject so = validator.getObjectParents(context, repositoryId, objectId, extension);
// for now we have only folders that have a parent and the in-memory
// provider only has one
@@ -238,10 +241,11 @@ public class InMemoryNavigationServiceIm
List<ObjectParentData> result = null;
Filing spo = null;
- if (so instanceof Filing)
+ if (so instanceof Filing) {
spo = (Filing) so;
- else
+ } else {
return Collections.emptyList();
+ }
result = getObjectParentsIntern(repositoryId, spo, filter, context.isObjectInfoRequired() ? objectInfos : null);
@@ -270,13 +274,16 @@ public class InMemoryNavigationServiceIm
StoredObject so = fs.getObjectById(folderId);
Folder folder = null;
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + folderId);
+ }
- if (so instanceof Folder)
+ if (so instanceof Folder) {
folder = (Folder) so;
- else
+ }
+ else {
return null; // it is a document and has no children
+ }
List<? extends StoredObject> children = folderOnly ? folder.getFolderChildren(maxItems, skipCount) : folder
.getChildren(maxItems, skipCount);
@@ -286,8 +293,9 @@ public class InMemoryNavigationServiceIm
for (StoredObject spo : children) {
ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
ObjectDataImpl objectData = new ObjectDataImpl();
- if (includePathSegments != null && includePathSegments)
+ if (includePathSegments != null && includePathSegments) {
oifd.setPathSegment(spo.getName());
+ }
if (includeAllowableActions != null && includeAllowableActions) {
AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(spo, user);
objectData.setAllowableActions(allowableActions);
@@ -352,8 +360,9 @@ public class InMemoryNavigationServiceIm
level + 1, maxLevels, folderOnly, objectInfos, user);
oifc.setObject(child);
- if (null != subChildren)
+ if (null != subChildren) {
oifc.setChildren(subChildren);
+ }
childrenOfFolderId.add(oifc);
}
}
@@ -381,13 +390,14 @@ public class InMemoryNavigationServiceIm
String relPathSeg = path.substring(beginIndex, path.length());
parentData.setRelativePathSegment(relPathSeg);
result = Collections.singletonList((ObjectParentData) parentData);
- } else
+ } else {
result = Collections.emptyList();
+ }
} else if (sop instanceof MultiFiling) {
result = new ArrayList<ObjectParentData>();
MultiFiling multiParentObj = (MultiFiling) sop;
List<Folder> parents = multiParentObj.getParents();
- if (null != parents)
+ if (null != parents) {
for (Folder parent : parents) {
ObjectParentDataImpl parentData = new ObjectParentDataImpl();
ObjectDataImpl objData = new ObjectDataImpl();
@@ -401,6 +411,7 @@ public class InMemoryNavigationServiceIm
objectInfos.addObjectInfo(objectInfo);
}
}
+ }
}
return result;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -113,13 +113,14 @@ public class InMemoryObjectServiceImpl e
Acl addAces, Acl removeAces, ExtensionsData extension) {
LOG.debug("start createDocumentFromSource()");
- StoredObject so = validator.createDocumentFromSource(context, repositoryId, sourceId, folderId, extension);
+ StoredObject so = validator.createDocumentFromSource(context, repositoryId, sourceId, folderId, extension);
ContentStream content = getContentStream(context, repositoryId, sourceId, null, BigInteger.valueOf(-1),
BigInteger.valueOf(-1), null);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + sourceId);
+ }
// build properties collection
List<String> requestedIds = FilterParser.getRequestedIdsFromFilter("*");
@@ -179,19 +180,22 @@ public class InMemoryObjectServiceImpl e
ContentStream contentStream, VersioningState versioningState, List<String> policies,
ExtensionsData extension, ObjectInfoHandler objectInfos) {
- if (null == properties || null == properties.getProperties())
+ if (null == properties || null == properties.getProperties()) {
throw new CmisInvalidArgumentException("Cannot create object, without properties.");
+ }
// Find out what kind of object needs to be created
PropertyData<String> pd = (PropertyData<String>) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
String typeId = pd == null ? null : pd.getFirstValue();
- if (null == typeId)
+ if (null == typeId) {
throw new CmisInvalidArgumentException(
"Cannot create object, without a type (no property with id CMIS_OBJECT_TYPE_ID).");
+ }
TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
- if (typeDefC == null)
+ if (typeDefC == null) {
throw new CmisInvalidArgumentException("Cannot create object, a type with id " + typeId + " is unknown");
+ }
// check if the given type is a document type
BaseTypeId typeBaseId = typeDefC.getTypeDefinition().getBaseTypeId();
@@ -205,8 +209,9 @@ public class InMemoryObjectServiceImpl e
so = createPolicyIntern(context, repositoryId, properties, folderId, null, null, null, null);
} else if (typeBaseId.equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType().getBaseTypeId())) {
so = createRelationshipIntern(context, repositoryId, properties, null, null, null, null);
- } else
+ } else {
LOG.error("The type contains an unknown base object id, object can't be created");
+ }
// Make a call to getObject to convert the resulting id into an
// ObjectData
@@ -226,14 +231,16 @@ public class InMemoryObjectServiceImpl e
Holder<String> changeToken, ExtensionsData extension) {
LOG.debug("start deleteContentStream()");
- StoredObject so = validator.deleteContentStream(context, repositoryId, objectId, extension);
+ StoredObject so = validator.deleteContentStream(context, repositoryId, objectId, extension);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
- if (!(so instanceof Content))
+ if (!(so instanceof Content)) {
throw new CmisObjectNotFoundException("Id" + objectId
+ " does not refer to a document, but only documents can have content");
+ }
((Content) so).setContent(null, true);
LOG.debug("stop deleteContentStream()");
@@ -248,8 +255,9 @@ public class InMemoryObjectServiceImpl e
LOG.debug("delete object for id: " + objectId);
// check if it is the root folder
- if (objectId.equals(objectStore.getRootFolder().getId()))
+ if (objectId.equals(objectStore.getRootFolder().getId())) {
throw new CmisNotSupportedException("You can't delete a root folder");
+ }
objectStore.deleteObject(objectId);
LOG.debug("stop deleteObject()");
@@ -259,32 +267,39 @@ public class InMemoryObjectServiceImpl e
Boolean allVersions, UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
LOG.debug("start deleteTree()");
- StoredObject so = validator.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects, extension);
+ StoredObject so = validator.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects, extension);
List<String> failedToDeleteIds = new ArrayList<String>();
FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
- if (null == allVersions)
+ if (null == allVersions) {
allVersions = true;
- if (null == unfileObjects)
+ }
+ if (null == unfileObjects) {
unfileObjects = UnfileObject.DELETE;
- if (null == continueOnFailure)
+ }
+ if (null == continueOnFailure) {
continueOnFailure = false;
+ }
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
- if (null == so)
+ if (null == so) {
throw new CmisInvalidArgumentException("Cannot delete object with id " + folderId + ". Object does not exist.");
+ }
- if (!(so instanceof Folder))
+ if (!(so instanceof Folder)) {
throw new CmisInvalidArgumentException("deleteTree can only be invoked on a folder, but id " + folderId
+ " does not refer to a folder");
+ }
- if (unfileObjects == UnfileObject.UNFILE)
+ if (unfileObjects == UnfileObject.UNFILE) {
throw new CmisNotSupportedException("This repository does not support unfile operations.");
+ }
// check if it is the root folder
- if (folderId.equals(objectStore.getRootFolder().getId()))
+ if (folderId.equals(objectStore.getRootFolder().getId())) {
throw new CmisNotSupportedException("You can't delete a root folder");
+ }
// recursively delete folder
deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds);
@@ -298,12 +313,13 @@ public class InMemoryObjectServiceImpl e
ExtensionsData extension) {
LOG.debug("start getAllowableActions()");
- StoredObject so = validator.getAllowableActions(context, repositoryId, objectId, extension);
-
+ StoredObject so = validator.getAllowableActions(context, repositoryId, objectId, extension);
+
fStoreManager.getObjectStore(repositoryId);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
String user = context.getUsername();
AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(so, user);
@@ -315,20 +331,23 @@ public class InMemoryObjectServiceImpl e
BigInteger offset, BigInteger length, ExtensionsData extension) {
LOG.debug("start getContentStream()");
- StoredObject so = validator.getContentStream(context, repositoryId, objectId, streamId, extension);
-
+ StoredObject so = validator.getContentStream(context, repositoryId, objectId, streamId, extension);
+
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
- if (!(so instanceof Content))
+ if (!(so instanceof Content)) {
throw new CmisConstraintException("Id" + objectId
+ " does not refer to a document or version, but only those can have content");
+ }
ContentStream csd = getContentStream(so, streamId, offset, length);
- if (null == csd)
+ if (null == csd) {
throw new CmisConstraintException("Object " + so.getId() + " does not have content.");
+ }
LOG.debug("stop getContentStream()");
return csd;
@@ -340,10 +359,11 @@ public class InMemoryObjectServiceImpl e
LOG.debug("start getObject()");
- StoredObject so = validator.getObject(context, repositoryId, objectId, extension);
+ StoredObject so = validator.getObject(context, repositoryId, objectId, extension);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
String user = context.getUsername();
TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
@@ -379,12 +399,13 @@ public class InMemoryObjectServiceImpl e
LOG.debug("start getObjectByPath()");
validator.getObjectByPath(context, repositoryId, path, extension);
-
+
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
StoredObject so = objectStore.getObjectByPath(path);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown path: " + path);
+ }
String user = context.getUsername();
TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
@@ -408,10 +429,11 @@ public class InMemoryObjectServiceImpl e
ExtensionsData extension) {
LOG.debug("start getProperties()");
- StoredObject so = validator.getProperties(context, repositoryId, objectId, extension);
+ StoredObject so = validator.getProperties(context, repositoryId, objectId, extension);
- if (so == null)
+ if (so == null) {
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+ }
// build properties collection
List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
@@ -427,7 +449,7 @@ public class InMemoryObjectServiceImpl e
// TODO to be completed if renditions are implemented
LOG.debug("start getRenditions()");
validator.getRenditions(context, repositoryId, objectId, extension);
-
+
LOG.debug("stop getRenditions()");
return null;
}
@@ -436,36 +458,39 @@ public class InMemoryObjectServiceImpl e
String targetFolderId, String sourceFolderId, ExtensionsData extension, ObjectInfoHandler objectInfos) {
LOG.debug("start moveObject()");
- StoredObject[] sos = validator.moveObject(context, repositoryId, objectId, targetFolderId, sourceFolderId, extension);
+ StoredObject[] sos = validator.moveObject(context, repositoryId, objectId, targetFolderId, sourceFolderId, extension);
StoredObject so = sos[0];
Folder targetFolder = null;
Folder sourceFolder = null;
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
Filing spo = null;
- if (null == so)
+ if (null == so) {
throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
- else if (so instanceof Filing)
+ } else if (so instanceof Filing) {
spo = (Filing) so;
- else
+ } else {
throw new CmisInvalidArgumentException("Object must be folder or document: " + objectId.getValue());
+ }
StoredObject soTarget = objectStore.getObjectById(targetFolderId);
- if (null == soTarget)
+ if (null == soTarget) {
throw new CmisObjectNotFoundException("Unknown target folder: " + targetFolderId);
- else if (soTarget instanceof Folder)
+ } else if (soTarget instanceof Folder) {
targetFolder = (Folder) soTarget;
- else
+ } else {
throw new CmisNotSupportedException("Destination " + targetFolderId
+ " of a move operation must be a folder");
+ }
StoredObject soSource = objectStore.getObjectById(sourceFolderId);
- if (null == soSource)
+ if (null == soSource) {
throw new CmisObjectNotFoundException("Unknown source folder: " + sourceFolderId);
- else if (soSource instanceof Folder)
+ } else if (soSource instanceof Folder) {
sourceFolder = (Folder) soSource;
- else
+ } else {
throw new CmisNotSupportedException("Source " + sourceFolderId + " of a move operation must be a folder");
+ }
boolean foundOldParent = false;
for (Folder parent : spo.getParents()) {
@@ -474,9 +499,10 @@ public class InMemoryObjectServiceImpl e
break;
}
}
- if (!foundOldParent)
+ if (!foundOldParent) {
throw new CmisNotSupportedException("Cannot move object, source folder " + sourceFolderId
+ "is not a parent of object " + objectId.getValue());
+ }
if (so instanceof Folder && hasDescendant((Folder) so, targetFolder)) {
throw new CmisNotSupportedException("Destination of a move cannot be a subfolder of the source");
@@ -510,23 +536,26 @@ public class InMemoryObjectServiceImpl e
StoredObject so = validator.setContentStream(context, repositoryId, objectId, overwriteFlag, extension);
- if (!(so instanceof Document || so instanceof VersionedDocument || so instanceof DocumentVersion))
+ if (!(so instanceof Document || so instanceof VersionedDocument || so instanceof DocumentVersion)) {
throw new CmisObjectNotFoundException("Id" + objectId
+ " does not refer to a document, but only documents can have content");
+ }
- if (so instanceof Document)
+ if (so instanceof Document) {
content = ((Document) so);
- else if (so instanceof DocumentVersion) {
+ } else if (so instanceof DocumentVersion) {
// something that is versionable check the proper status of the
// object
String user = context.getUsername();
testHasProperCheckedOutStatus(so, user);
content = (DocumentVersion) so;
- } else
+ } else {
throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
+ }
- if (!overwriteFlag && content.getContent(0, -1) != null)
+ if (!overwriteFlag && content.getContent(0, -1) != null) {
throw new CmisContentAlreadyExistsException("cannot overwrite existing content if overwrite flag is not set");
+ }
content.setContent(contentStream, true);
LOG.debug("stop setContentStream()");
@@ -537,7 +566,7 @@ public class InMemoryObjectServiceImpl e
ObjectInfoHandler objectInfos) {
LOG.debug("start updateProperties()");
- StoredObject so = validator.updateProperties(context, repositoryId, objectId, extension);
+ StoredObject so = validator.updateProperties(context, repositoryId, objectId, extension);
// Validation
TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
@@ -558,8 +587,9 @@ public class InMemoryObjectServiceImpl e
TypeValidator.validateProperties(typeDef, properties, false);
if (changeToken != null && changeToken.getValue() != null
- && Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue()))
+ && Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue())) {
throw new CmisUpdateConflictException(" updateProperties failed: outdated changeToken");
+ }
// update properties
boolean hasUpdatedName = false;
@@ -567,28 +597,32 @@ public class InMemoryObjectServiceImpl e
for (String key : properties.getProperties().keySet()) {
if (key.equals(PropertyIds.NAME))
+ {
continue; // ignore here
+ }
PropertyData<?> value = properties.getProperties().get(key);
PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(key);
if (value.getValues() == null || value.getFirstValue() == null) {
// delete property
// check if a required a property
- if (propDef.isRequired())
+ if (propDef.isRequired()) {
throw new CmisConstraintException(
"updateProperties failed, following property can't be deleted, because it is required: "
+ key);
+ }
oldProperties.remove(key);
hasUpdatedOtherProps = true;
} else {
- if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT) && !isCheckedOut)
+ if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT) && !isCheckedOut) {
throw new CmisConstraintException(
"updateProperties failed, following property can't be updated, because it is not checked-out: "
+ key);
- else if (!propDef.getUpdatability().equals(Updatability.READWRITE))
+ } else if (!propDef.getUpdatability().equals(Updatability.READWRITE)) {
throw new CmisConstraintException(
"updateProperties failed, following property can't be updated, because it is not writable: "
+ key);
+ }
oldProperties.put(key, value);
hasUpdatedOtherProps = true;
}
@@ -600,10 +634,12 @@ public class InMemoryObjectServiceImpl e
if (pd != null && so instanceof Filing) {
String newName = (String) pd.getFirstValue();
List<Folder> parents = ((Filing) so).getParents();
- if (so instanceof Folder && parents.isEmpty())
+ if (so instanceof Folder && parents.isEmpty()) {
throw new CmisConstraintException("updateProperties failed, you cannot rename the root folder");
- if (newName == null || newName.equals(""))
+ }
+ if (newName == null || newName.equals("")) {
throw new CmisConstraintException("updateProperties failed, name must not be empty.");
+ }
so.rename((String) pd.getFirstValue()); // note: this does persist
hasUpdatedName = true;
@@ -613,8 +649,9 @@ public class InMemoryObjectServiceImpl e
// set user, creation date, etc.
String user = context.getUsername();
- if (user == null)
+ if (user == null) {
user = "unknown";
+ }
so.updateSystemBasePropertiesWhenModified(properties.getProperties(), user);
// set changeToken
so.persist();
@@ -659,9 +696,9 @@ public class InMemoryObjectServiceImpl e
private StoredObject createDocumentIntern(CallContext context, String repositoryId, Properties properties, String folderId,
ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addACEs,
Acl removeACEs, ExtensionsData extension) {
-
+
String user = context.getUsername();
- validator.createDocument(context, repositoryId, folderId, extension);
+ validator.createDocument(context, repositoryId, folderId, extension);
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
Map<String, PropertyData<?>> propMap = properties.getProperties();
@@ -677,25 +714,29 @@ public class InMemoryObjectServiceImpl e
if (null != folderId) {
StoredObject so = objectStore.getObjectById(folderId);
- if (null == so)
+ if (null == so) {
throw new CmisInvalidArgumentException(" Cannot create document, folderId: " + folderId + " is invalid");
+ }
- if (so instanceof Folder)
+ if (so instanceof Folder) {
folder = (Folder) so;
- else
+ } else {
throw new CmisInvalidArgumentException("Can't creat document, folderId does not refer to a folder: "
+ folderId);
+ }
TypeValidator.validateAllowedChildObjectTypes(typeDef, folder.getAllowedChildObjectTypeIds());
}
// check if the given type is a document type
- if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
+ if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) {
throw new CmisInvalidArgumentException("Cannot create a document, with a non-document type: " + typeDef.getId());
+ }
// check name syntax
- if (!NameValidator.isValidId(name))
+ if (!NameValidator.isValidId(name)) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+ }
TypeValidator.validateVersionStateForCreate((DocumentTypeDefinition) typeDef, versioningState);
@@ -709,8 +750,9 @@ public class InMemoryObjectServiceImpl e
TypeValidator.validateProperties(typeDef, properties, true);
// set user, creation date, etc.
- if (user == null)
+ if (user == null) {
user = "unknown";
+ }
StoredObject so = null;
@@ -719,15 +761,17 @@ public class InMemoryObjectServiceImpl e
contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)) {
ContentStreamImpl cs = new ContentStreamImpl();
cs.setStream(contentStream.getStream());
- if (contentStream.getFileName() == null || contentStream.getFileName().length() == 0)
+ if (contentStream.getFileName() == null || contentStream.getFileName().length() == 0) {
cs.setFileName(name);
- else
+ } else {
cs.setFileName(contentStream.getFileName());
+ }
cs.setLength(contentStream.getBigLength());
- if (contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)
+ if (contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0) {
cs.setMimeType("application/octet-stream");
- else
+ } else {
cs.setMimeType(contentStream.getMimeType());
+ }
cs.setExtensions(contentStream.getExtensions());
contentStream = cs;
}
@@ -738,11 +782,12 @@ public class InMemoryObjectServiceImpl e
verDoc.createSystemBasePropertiesWhenCreated(properties.getProperties(), user);
verDoc.setCustomProperties(properties.getProperties());
DocumentVersion version = verDoc.addVersion(contentStream, versioningState, user);
- if (null != folder)
+ if (null != folder) {
folder.addChildDocument(verDoc); // add document to folder and
// set parent in doc
- else
+ } else {
verDoc.persist();
+ }
version.createSystemBasePropertiesWhenCreated(propMap, user);
version.setCustomProperties(propMap);
version.persist();
@@ -754,11 +799,12 @@ public class InMemoryObjectServiceImpl e
// add document to folder
doc.createSystemBasePropertiesWhenCreated(propMap, user);
doc.setCustomProperties(propMap);
- if (null != folder)
+ if (null != folder) {
folder.addChildDocument(doc); // add document to folder and set
// parent in doc
- else
+ } else {
doc.persist();
+ }
so = doc;
}
@@ -782,20 +828,23 @@ public class InMemoryObjectServiceImpl e
// get required properties
PropertyData<?> pd = properties.getProperties().get(PropertyIds.NAME);
String folderName = (String) pd.getFirstValue();
- if (null == folderName || folderName.length() == 0)
+ if (null == folderName || folderName.length() == 0) {
throw new CmisInvalidArgumentException("Cannot create a folder without a name.");
+ }
// check name syntax
- if (!NameValidator.isValidId(folderName))
+ if (!NameValidator.isValidId(folderName)) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+ }
TypeValidator.validateRequiredSystemProperties(properties);
TypeDefinition typeDef = getTypeDefinition(repositoryId, properties);
// check if the given type is a folder type
- if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_FOLDER))
+ if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_FOLDER)) {
throw new CmisInvalidArgumentException("Cannot create a folder, with a non-folder type: " + typeDef.getId());
+ }
Map<String, PropertyData<?>> propMap = properties.getProperties();
Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
@@ -813,17 +862,19 @@ public class InMemoryObjectServiceImpl e
throw new CmisObjectNotFoundException("Failed to retrieve folder.", e);
}
- if (so instanceof Folder)
+ if (so instanceof Folder) {
parent = (Folder) so;
- else
+ } else {
throw new CmisInvalidArgumentException("Can't create folder, folderId does not refer to a folder: "
+ folderId);
+ }
ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
Folder newFolder = objStore.createFolder(folderName);
// set default system attributes
- if (user == null)
+ if (user == null) {
user = "unknown";
+ }
newFolder.createSystemBasePropertiesWhenCreated(properties.getProperties(), user);
newFolder.setCustomProperties(properties.getProperties());
parent.addChildFolder(newFolder);
@@ -833,7 +884,7 @@ public class InMemoryObjectServiceImpl e
private StoredObject createPolicyIntern(CallContext context, String repositoryId, Properties properties, String folderId,
List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
-
+
validator.createPolicy(context, repositoryId, folderId, extension);
throw new CmisNotSupportedException("createPolicy is not supported.");
}
@@ -844,20 +895,22 @@ public class InMemoryObjectServiceImpl e
throw new CmisNotSupportedException("createRelationship is not supported.");
}
- private boolean hasDescendant(Folder sourceFolder, Folder targetFolder) {
+ private static boolean hasDescendant(Folder sourceFolder, Folder targetFolder) {
String sourceId = sourceFolder.getId();
String targetId = targetFolder.getId();
while (targetId != null) {
// log.debug("comparing source id " + sourceId + " with predecessor "
// +
// targetId);
- if (targetId.equals(sourceId))
+ if (targetId.equals(sourceId)) {
return true;
+ }
targetFolder = targetFolder.getParent();
- if (null != targetFolder)
+ if (null != targetFolder) {
targetId = targetFolder.getId();
- else
+ } else {
targetId = null;
+ }
}
return false;
}
@@ -878,15 +931,18 @@ public class InMemoryObjectServiceImpl e
boolean allVersions, List<String> failedToDeleteIds) {
List<StoredObject> children = parentFolder.getChildren(-1, -1);
- if (null == children)
+ if (null == children) {
return true;
+ }
for (StoredObject child : children) {
if (child instanceof Folder) {
boolean mustContinue = deleteRecursive(folderStore, (Folder) child, continueOnFailure, allVersions,
failedToDeleteIds);
if (!mustContinue && !continueOnFailure)
+ {
return false; // stop further deletions
+ }
} else {
try {
folderStore.deleteObject(child.getId());
@@ -899,7 +955,7 @@ public class InMemoryObjectServiceImpl e
return true;
}
- private ContentStream getContentStream(StoredObject so, String streamId, BigInteger offset, BigInteger length) {
+ private static ContentStream getContentStream(StoredObject so, String streamId, BigInteger offset, BigInteger length) {
if (streamId != null) {
return null;
}
@@ -923,46 +979,55 @@ public class InMemoryObjectServiceImpl e
properties = new HashMap<String, PropertyData<?>>(properties); // copy because it is an unmodified collection
hasCopied = true;
}
- if (propDef.getPropertyType() == PropertyType.BOOLEAN)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ if (propDef.getPropertyType() == PropertyType.BOOLEAN) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyBooleanData(propId, (List<Boolean>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyBooleanData(propId, (Boolean)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.DATETIME)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.DATETIME) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyDateTimeData(propId, (List<GregorianCalendar>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyDateTimeData(propId, (GregorianCalendar)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.DECIMAL)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.DECIMAL) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyDecimalData(propId, (List<BigDecimal>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyDecimalData(propId, (BigDecimal)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.HTML)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.HTML) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyHtmlData(propId, (List<String>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyHtmlData(propId, (String)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.ID)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.ID) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyIdData(propId, (List<String>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyIdData(propId, (String)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.INTEGER)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.INTEGER) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyIntegerData(propId, (List<BigInteger>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyIntegerData(propId, (BigInteger)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.STRING)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.STRING) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyStringData(propId, (List<String>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyStringData(propId, (String)defaultVal.get(0));
- else if (propDef.getPropertyType() == PropertyType.URI)
- if (propDef.getCardinality() == Cardinality.MULTI)
+ }
+ } else if (propDef.getPropertyType() == PropertyType.URI) {
+ if (propDef.getCardinality() == Cardinality.MULTI) {
pd = fStoreManager.getObjectFactory().createPropertyUriData(propId, (List<String>)defaultVal);
- else
+ } else {
pd = fStoreManager.getObjectFactory().createPropertyUriData(propId, (String)defaultVal.get(0));
+ }
+ }
// set property:
properties.put(propId, pd);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -44,7 +44,7 @@ public class InMemoryRepositoryServiceIm
public RepositoryInfo getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
validator.getRepositoryInfo(context, repositoryId, extension);
-
+
RepositoryInfo repoInfo = getRepositoryInfoFromStoreManager(repositoryId);
return repoInfo;
@@ -65,7 +65,7 @@ public class InMemoryRepositoryServiceIm
Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
validator.getTypeChildren(context, repositoryId, typeId, extension);
-
+
boolean inclPropDefs = includePropertyDefinitions == null ? false : includePropertyDefinitions;
getRepositoryInfoFromStoreManager(repositoryId); // just to check if
// repository
@@ -87,10 +87,12 @@ public class InMemoryRepositoryServiceIm
result.setHasMoreItems(children.size() > max - skip);
List<TypeDefinition> childrenTypes = new ArrayList<TypeDefinition>();
ListIterator<TypeDefinitionContainer> it = children.listIterator(skip);
- if (max < 0)
+ if (max < 0) {
max = children.size();
- for (int i = skip; i < max + skip && it.hasNext(); i++)
+ }
+ for (int i = skip; i < max + skip && it.hasNext(); i++) {
childrenTypes.add(it.next().getTypeDefinition());
+ }
result.setList(childrenTypes);
return result;
@@ -104,8 +106,9 @@ public class InMemoryRepositoryServiceIm
TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId);
if (tc != null) {
return tc.getTypeDefinition();
- } else
+ } else {
throw new CmisObjectNotFoundException("unknown type id: " + typeId);
+ }
}
public List<TypeDefinitionContainer> getTypeDescendants(CallContext context, String repositoryId, String typeId,
@@ -114,9 +117,10 @@ public class InMemoryRepositoryServiceIm
validator.getTypeDescendants(context, repositoryId, typeId, extension);
boolean inclPropDefs = includePropertyDefinitions == null ? false : includePropertyDefinitions;
-
- if (depth != null && depth.intValue() == 0)
+
+ if (depth != null && depth.intValue() == 0) {
throw new CmisInvalidArgumentException("depth == 0 is illegal in getTypeDescendants");
+ }
List<TypeDefinitionContainer> result = null;
if (typeId == null) {
@@ -127,10 +131,11 @@ public class InMemoryRepositoryServiceIm
} else {
TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId, inclPropDefs,
depth == null ? -1 : depth.intValue());
- if (tc == null)
+ if (tc == null) {
throw new CmisInvalidArgumentException("unknown type id: " + typeId);
- else
+ } else {
result = tc.getChildren();
+ }
}
return result;
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java Sun Apr 24 16:12:27 2011
@@ -93,20 +93,24 @@ public class InMemoryService extends Abs
return fRepSvc.getRepositoryInfos(getCallContext(), extension);
}
+ @Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
return fRepSvc.getRepositoryInfo(getCallContext(), repositoryId, extension);
}
+ @Override
public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
return fRepSvc.getTypeChildren(getCallContext(), repositoryId, typeId, includePropertyDefinitions, maxItems,
skipCount, extension);
}
+ @Override
public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
return fRepSvc.getTypeDefinition(getCallContext(), repositoryId, typeId, extension);
}
+ @Override
public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
Boolean includePropertyDefinitions, ExtensionsData extension) {
return fRepSvc.getTypeDescendants(getCallContext(), repositoryId, typeId, depth, includePropertyDefinitions,
@@ -115,6 +119,7 @@ public class InMemoryService extends Abs
// --- navigation service ---
+ @Override
public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
@@ -122,6 +127,7 @@ public class InMemoryService extends Abs
includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension, this);
}
+ @Override
public ObjectInFolderList getChildren(String repositoryId, String folderId, String filter, String orderBy,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
@@ -129,6 +135,7 @@ public class InMemoryService extends Abs
includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, extension, this);
}
+ @Override
public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
@@ -136,10 +143,12 @@ public class InMemoryService extends Abs
includeRelationships, renditionFilter, includePathSegment, extension, this);
}
+ @Override
public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
return fNavSvc.getFolderParent(getCallContext(), repositoryId, folderId, filter, extension, this);
}
+ @Override
public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
@@ -147,6 +156,7 @@ public class InMemoryService extends Abs
includeRelationships, renditionFilter, includePathSegment, extension, this);
}
+ @Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
Boolean includeRelativePathSegment, ExtensionsData extension) {
@@ -156,6 +166,7 @@ public class InMemoryService extends Abs
// --- object service ---
+ @Override
public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
VersioningState versioningState, List<String> policies, ExtensionsData extension) {
String id = fObjSvc.create(getCallContext(), repositoryId, properties, folderId, contentStream,
@@ -164,6 +175,7 @@ public class InMemoryService extends Abs
}
+ @Override
public String createDocument(String repositoryId, Properties properties, String folderId,
ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
Acl removeAces, ExtensionsData extension) {
@@ -171,6 +183,7 @@ public class InMemoryService extends Abs
versioningState, policies, addAces, removeAces, extension);
}
+ @Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
ExtensionsData extension) {
@@ -178,53 +191,63 @@ public class InMemoryService extends Abs
versioningState, policies, addAces, removeAces, extension);
}
+ @Override
public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
Acl addAces, Acl removeAces, ExtensionsData extension) {
return fObjSvc.createFolder(getCallContext(), repositoryId, properties, folderId, policies, addAces,
removeAces, extension);
}
+ @Override
public String createPolicy(String repositoryId, Properties properties, String folderId, List<String> policies,
Acl addAces, Acl removeAces, ExtensionsData extension) {
return fObjSvc.createPolicy(getCallContext(), repositoryId, properties, folderId, policies, addAces,
removeAces, extension);
}
+ @Override
public String createRelationship(String repositoryId, Properties properties, List<String> policies, Acl addAces,
Acl removeAces, ExtensionsData extension) {
return fObjSvc.createRelationship(getCallContext(), repositoryId, properties, policies, addAces, removeAces,
extension);
}
+ @Override
public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
ExtensionsData extension) {
fObjSvc.deleteContentStream(getCallContext(), repositoryId, objectId, changeToken, extension);
}
+ @Override
public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension) {
fObjSvc.deleteObjectOrCancelCheckOut(getCallContext(), repositoryId, objectId, allVersions, extension);
}
+ @Override
public void deleteObjectOrCancelCheckOut(String repositoryId, String objectId, Boolean allVersions,
ExtensionsData extension) {
fObjSvc.deleteObjectOrCancelCheckOut(getCallContext(), repositoryId, objectId, allVersions, extension);
}
+ @Override
public FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
return fObjSvc.deleteTree(getCallContext(), repositoryId, folderId, allVersions, unfileObjects,
continueOnFailure, extension);
}
+ @Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
return fObjSvc.getAllowableActions(getCallContext(), repositoryId, objectId, extension);
}
+ @Override
public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
BigInteger length, ExtensionsData extension) {
return fObjSvc.getContentStream(getCallContext(), repositoryId, objectId, streamId, offset, length, extension);
}
+ @Override
public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
Boolean includeAcl, ExtensionsData extension) {
@@ -232,6 +255,7 @@ public class InMemoryService extends Abs
includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension, this);
}
+ @Override
public ObjectData getObjectByPath(String repositoryId, String path, String filter, Boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
Boolean includeAcl, ExtensionsData extension) {
@@ -239,27 +263,32 @@ public class InMemoryService extends Abs
includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension, this);
}
+ @Override
public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
return fObjSvc.getProperties(getCallContext(), repositoryId, objectId, filter, extension);
}
+ @Override
public List<RenditionData> getRenditions(String repositoryId, String objectId, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
return fObjSvc.getRenditions(getCallContext(), repositoryId, objectId, renditionFilter, maxItems, skipCount,
extension);
}
+ @Override
public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
ExtensionsData extension) {
fObjSvc.moveObject(getCallContext(), repositoryId, objectId, targetFolderId, sourceFolderId, extension, this);
}
+ @Override
public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
fObjSvc.setContentStream(getCallContext(), repositoryId, objectId, overwriteFlag, changeToken, contentStream,
extension);
}
+ @Override
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
Properties properties, ExtensionsData extension) {
fObjSvc.updateProperties(getCallContext(), repositoryId, objectId, changeToken, properties, null, extension,
@@ -268,10 +297,12 @@ public class InMemoryService extends Abs
// --- versioning service ---
+ @Override
public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
fVerSvc.cancelCheckOut(getCallContext(), repositoryId, objectId, extension);
}
+ @Override
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
ExtensionsData extension) {
@@ -279,11 +310,13 @@ public class InMemoryService extends Abs
policies, addAces, removeAces, extension, this);
}
+ @Override
public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
Holder<Boolean> contentCopied) {
fVerSvc.checkOut(getCallContext(), repositoryId, objectId, extension, contentCopied, this);
}
+ @Override
public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
@@ -292,26 +325,30 @@ public class InMemoryService extends Abs
extension, this);
}
+ @Override
public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
Boolean major, String filter, ExtensionsData extension) {
return fVerSvc.getPropertiesOfLatestVersion(getCallContext(), repositoryId, objectId, versionSeriesId, major, filter,
extension);
}
+ @Override
public List<ObjectData> getAllVersions(String repositoryId, String objectId, String versionSeriesId, String filter,
Boolean includeAllowableActions, ExtensionsData extension) {
- return fVerSvc.getAllVersions(getCallContext(), repositoryId, objectId, versionSeriesId,
+ return fVerSvc.getAllVersions(getCallContext(), repositoryId, objectId, versionSeriesId,
filter, includeAllowableActions, extension, this);
}
// --- discovery service ---
+ @Override
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
return fDisSvc.getContentChanges(getCallContext(), repositoryId, changeLogToken, includeProperties, filter, includePolicyIds,
includeAcl, maxItems, extension, this);
}
+ @Override
public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
@@ -321,17 +358,20 @@ public class InMemoryService extends Abs
// --- multi filing service ---
+ @Override
public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
ExtensionsData extension) {
fMultiSvc.addObjectToFolder(getCallContext(), repositoryId, objectId, folderId, allVersions, extension, this);
}
+ @Override
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
fMultiSvc.removeObjectFromFolder(getCallContext(), repositoryId, objectId, folderId, extension, this);
}
// --- relationship service ---
+ @Override
public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
@@ -341,35 +381,40 @@ public class InMemoryService extends Abs
// --- ACL service ---
+ @Override
public Acl applyAcl(String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
return super.applyAcl(repositoryId, objectId, aces, aclPropagation);
}
+ @Override
public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
AclPropagation aclPropagation, ExtensionsData extension) {
return super.applyAcl(repositoryId, objectId, addAces, removeAces, aclPropagation, extension);
}
+ @Override
public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
return super.getAcl(repositoryId, objectId, onlyBasicPermissions, extension);
}
// --- policy service ---
+ @Override
public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
super.applyPolicy(repositoryId, policyId, objectId, extension);
}
+ @Override
public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
ExtensionsData extension) {
return super.getAppliedPolicies(repositoryId, objectId, filter, extension);
}
+ @Override
public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
super.removePolicy(repositoryId, policyId, objectId, extension);
}
- // //////////////
- //
+ // /////////////
}