diff --git a/src/main/java/org/alfresco/opencmis/CMISConnector.java b/src/main/java/org/alfresco/opencmis/CMISConnector.java
index a188b3e38c..e2a0e12263 100644
--- a/src/main/java/org/alfresco/opencmis/CMISConnector.java
+++ b/src/main/java/org/alfresco/opencmis/CMISConnector.java
@@ -1,28 +1,28 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
package org.alfresco.opencmis;
import java.io.BufferedOutputStream;
@@ -50,17 +50,17 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
-
+
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
-
+
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.events.types.ContentEvent;
import org.alfresco.events.types.ContentEventImpl;
import org.alfresco.events.types.ContentReadRangeEvent;
import org.alfresco.events.types.Event;
import org.alfresco.model.ContentModel;
-import org.alfresco.service.cmr.activities.ActivityInfo;
+import org.alfresco.service.cmr.activities.ActivityInfo;
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
import org.alfresco.opencmis.dictionary.CMISAllowedActionEnum;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
@@ -81,8 +81,8 @@ import org.alfresco.opencmis.search.CMISResultSetRow;
import org.alfresco.repo.Client;
import org.alfresco.repo.Client.ClientType;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
-import org.alfresco.repo.cache.SimpleCache;
-import org.alfresco.repo.coci.CheckOutCheckInServiceImpl;
+import org.alfresco.repo.cache.SimpleCache;
+import org.alfresco.repo.coci.CheckOutCheckInServiceImpl;
import org.alfresco.repo.events.EventPreparator;
import org.alfresco.repo.events.EventPublisher;
import org.alfresco.repo.model.filefolder.GetChildrenCannedQuery;
@@ -462,22 +462,22 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.objectsDefaultDepth = objectsDefaultDepth;
}
- /**
- * Set the default number of content changes to return if nothing is specified
- */
- public void setContentChangesDefaultMaxItems(int contentChangesDefaultMaxItems)
- {
- if (contentChangesDefaultMaxItems < 1)
- {
- throw new IllegalArgumentException("The default maximum number of content changes to retrieve must be greater than zero.");
- }
- else if (contentChangesDefaultMaxItems == Integer.MAX_VALUE)
- {
- throw new IllegalArgumentException("The server cannot return " + Integer.MAX_VALUE + " content changes in a request!");
- }
- this.contentChangesDefaultMaxItems = contentChangesDefaultMaxItems;
- }
-
+ /**
+ * Set the default number of content changes to return if nothing is specified
+ */
+ public void setContentChangesDefaultMaxItems(int contentChangesDefaultMaxItems)
+ {
+ if (contentChangesDefaultMaxItems < 1)
+ {
+ throw new IllegalArgumentException("The default maximum number of content changes to retrieve must be greater than zero.");
+ }
+ else if (contentChangesDefaultMaxItems == Integer.MAX_VALUE)
+ {
+ throw new IllegalArgumentException("The server cannot return " + Integer.MAX_VALUE + " content changes in a request!");
+ }
+ this.contentChangesDefaultMaxItems = contentChangesDefaultMaxItems;
+ }
+
/**
* Set rendition kind mapping.
*/
@@ -504,14 +504,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
- }
-
- /**
- * Return the service registry
- */
- public final ServiceRegistry getServiceRegistry()
- {
- return this.serviceRegistry;
+ }
+
+ /**
+ * Return the service registry
+ */
+ public final ServiceRegistry getServiceRegistry()
+ {
+ return this.serviceRegistry;
}
/**
@@ -3097,13 +3097,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
throw new CmisInvalidArgumentException("Property " + property.getId() + " is unknown!");
}
}
-
- Boolean isOnWorkingCopy = checkOutCheckInService.isWorkingCopy(nodeRef);
- Updatability updatability = propDef.getPropertyDefinition().getUpdatability();
- if (!isUpdatable(updatability, isOnWorkingCopy))
- {
- throw new CmisInvalidArgumentException("Property " + propertyId + " is read-only!");
- }
+
+ Boolean isOnWorkingCopy = checkOutCheckInService.isWorkingCopy(nodeRef);
+ Updatability updatability = propDef.getPropertyDefinition().getUpdatability();
+ if (!isUpdatable(updatability, isOnWorkingCopy))
+ {
+ throw new CmisInvalidArgumentException("Property " + propertyId + " is read-only!");
+ }
TypeDefinitionWrapper propType = propDef.getOwningType();
Serializable value = getValue(property, propDef.getPropertyDefinition().getCardinality() == Cardinality.MULTI);
@@ -3128,21 +3128,21 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
- for (String propertyId : propsMap.keySet())
- {
- if (propertyId.equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS))
- {
- // already handled above
- continue;
- }
-
- pair = propsMap.get(propertyId);
- TypeDefinitionWrapper propType = pair.getFirst();
- Serializable value = pair.getSecond();
- if (Arrays.binarySearch(exclude, propertyId) < 0)
- {
- setProperty(nodeRef, propType, propertyId, value);
- }
+ for (String propertyId : propsMap.keySet())
+ {
+ if (propertyId.equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS))
+ {
+ // already handled above
+ continue;
+ }
+
+ pair = propsMap.get(propertyId);
+ TypeDefinitionWrapper propType = pair.getFirst();
+ Serializable value = pair.getSecond();
+ if (Arrays.binarySearch(exclude, propertyId) < 0)
+ {
+ setProperty(nodeRef, propType, propertyId, value);
+ }
}
List extensions = properties.getExtensions();
@@ -3186,8 +3186,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Set ignore = new HashSet();
ignore.add(ContentModel.ASPECT_REFERENCEABLE);
- ignore.add(ContentModel.ASPECT_LOCALIZED);
- ignore.add(ContentModel.ASPECT_WORKING_COPY);
+ ignore.add(ContentModel.ASPECT_LOCALIZED);
+ ignore.add(ContentModel.ASPECT_WORKING_COPY);
// aspects to add == the list of secondary types - existing aspects - ignored aspects
Set toAdd = new HashSet(secondaryTypeAspects);
@@ -3214,13 +3214,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
for(QName aspectQName : aspectsToRemove)
{
nodeService.removeAspect(nodeRef, aspectQName);
- // aspect is being removed so remove all of its properties from the propsToAdd map
- TypeDefinitionWrapper w = getOpenCMISDictionaryService().findNodeType(aspectQName);
- for(PropertyDefinitionWrapper wr : w.getProperties())
- {
- String propertyId = wr.getPropertyId();
- propsToAdd.remove(propertyId);
- }
}
// add aspects and properties
@@ -3560,13 +3553,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
throw new CmisInvalidArgumentException("Property " + propertyId + " is unknown!");
}
-
- Boolean isOnWorkingCopy = checkOutCheckInService.isWorkingCopy(nodeRef);
+
+ Boolean isOnWorkingCopy = checkOutCheckInService.isWorkingCopy(nodeRef);
Updatability updatability = propDef.getPropertyDefinition().getUpdatability();
if (!isUpdatable(updatability, isOnWorkingCopy))
- {
- throw new CmisInvalidArgumentException("Property " + propertyId + " is read-only!");
- }
+ {
+ throw new CmisInvalidArgumentException("Property " + propertyId + " is read-only!");
+ }
if(propDef.getPropertyId().equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS))
{
@@ -3588,21 +3581,21 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
try
- {
- String newName = value.toString();
- // If the node is checked out and the name property is set on the working copy, make sure the new name has the working copy format
- if (isOnWorkingCopy)
- {
- String wcLabel = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_LABEL);
- if (wcLabel == null)
- {
- wcLabel = CheckOutCheckInServiceImpl.getWorkingCopyLabel();
- }
- if (!newName.contains(wcLabel))
- {
- newName = CheckOutCheckInServiceImpl.createWorkingCopyName(newName, wcLabel);
- }
- }
+ {
+ String newName = value.toString();
+ // If the node is checked out and the name property is set on the working copy, make sure the new name has the working copy format
+ if (isOnWorkingCopy)
+ {
+ String wcLabel = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_LABEL);
+ if (wcLabel == null)
+ {
+ wcLabel = CheckOutCheckInServiceImpl.getWorkingCopyLabel();
+ }
+ if (!newName.contains(wcLabel))
+ {
+ newName = CheckOutCheckInServiceImpl.createWorkingCopyName(newName, wcLabel);
+ }
+ }
fileFolderService.rename(nodeRef, newName);
}
@@ -3690,30 +3683,30 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
params.setApplicationName(CMIS_CHANGELOG_AUDIT_APPLICATION);
params.setForward(true);
params.setFromId(from);
-
- // So we have a BigInteger. We need to ensure that we cut it down to an integer smaller than Integer.MAX_VALUE
+
+ // So we have a BigInteger. We need to ensure that we cut it down to an integer smaller than Integer.MAX_VALUE
- int maxResults = (maxItems == null ? contentChangesDefaultMaxItems : maxItems.intValue());
- maxResults = maxResults < 1 ? contentChangesDefaultMaxItems : maxResults; // Just a double check of the unbundled contents
- maxResults = maxResults > contentChangesDefaultMaxItems ? contentChangesDefaultMaxItems : maxResults; // cut it down
+ int maxResults = (maxItems == null ? contentChangesDefaultMaxItems : maxItems.intValue());
+ maxResults = maxResults < 1 ? contentChangesDefaultMaxItems : maxResults; // Just a double check of the unbundled contents
+ maxResults = maxResults > contentChangesDefaultMaxItems ? contentChangesDefaultMaxItems : maxResults; // cut it down
int queryFor = maxResults + 1; // Query for 1 more so that we know if there are more results
auditService.auditQuery(changeLogCollectingCallback, params, queryFor);
- String newChangeLogToken = null;
+ String newChangeLogToken = null;
// Check if we got more than the client requested
if (result.getObjects().size() >= maxResults)
{
// Build the change log token from the last item
StringBuilder clt = new StringBuilder();
- newChangeLogToken = (from == null ? clt.append(maxItems.intValue() + 1).toString() : clt.append(from.longValue() + maxItems.intValue()).toString()); // TODO: Make this readable
+ newChangeLogToken = (from == null ? clt.append(maxItems.intValue() + 1).toString() : clt.append(from.longValue() + maxItems.intValue()).toString()); // TODO: Make this readable
// Remove extra item that was not actually requested
- result.getObjects().remove(result.getObjects().size() - 1).getId();
+ result.getObjects().remove(result.getObjects().size() - 1).getId();
// Note to client that there are more items
result.setHasMoreItems(true);
}
else
- {
+ {
// We got the same or fewer than the number requested, so there are no more items
result.setHasMoreItems(false);
}
@@ -4090,24 +4083,24 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
singletonCache.put(KEY_CMIS_RENDITION_MAPPING_NODEREF, renditionMapping);
}
return renditionMapping;
- }
-
- /**
- * Verify if a property is updatable.
- * @param updatability
- * @param isOnWorkingCopy
- * @return
- */
- private boolean isUpdatable(Updatability updatability, Boolean isOnWorkingCopy)
- {
- if ((updatability == Updatability.READONLY)
- || (updatability == Updatability.WHENCHECKEDOUT && !isOnWorkingCopy))
- {
- return false;
- }
- else
- {
- return true;
- }
+ }
+
+ /**
+ * Verify if a property is updatable.
+ * @param updatability
+ * @param isOnWorkingCopy
+ * @return
+ */
+ private boolean isUpdatable(Updatability updatability, Boolean isOnWorkingCopy)
+ {
+ if ((updatability == Updatability.READONLY)
+ || (updatability == Updatability.WHENCHECKEDOUT && !isOnWorkingCopy))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
}
diff --git a/src/test/java/org/alfresco/opencmis/CMISTest.java b/src/test/java/org/alfresco/opencmis/CMISTest.java
index 19071d6309..76fc8451f0 100644
--- a/src/test/java/org/alfresco/opencmis/CMISTest.java
+++ b/src/test/java/org/alfresco/opencmis/CMISTest.java
@@ -1,172 +1,173 @@
-
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
+
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
package org.alfresco.opencmis;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.opencmis.dictionary.CMISDictionaryService;
-import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
-import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
-import org.alfresco.opencmis.search.CMISQueryOptions;
-import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
-import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
-import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
-import org.alfresco.repo.audit.AuditComponent;
-import org.alfresco.repo.audit.AuditComponentImpl;
-import org.alfresco.repo.audit.AuditServiceImpl;
-import org.alfresco.repo.audit.UserAuditFilter;
-import org.alfresco.repo.audit.model.AuditModelRegistryImpl;
-import org.alfresco.repo.content.MimetypeMap;
-import org.alfresco.repo.dictionary.DictionaryDAO;
-import org.alfresco.repo.dictionary.M2Model;
-import org.alfresco.repo.domain.audit.AuditDAO;
-import org.alfresco.repo.domain.node.ContentDataWithId;
-import org.alfresco.repo.domain.node.NodeDAO;
-import org.alfresco.repo.model.Repository;
-import org.alfresco.repo.node.archive.NodeArchiveService;
-import org.alfresco.repo.security.authentication.AuthenticationComponent;
-import org.alfresco.repo.security.authentication.AuthenticationContext;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
-import org.alfresco.repo.tenant.TenantAdminService;
-import org.alfresco.repo.tenant.TenantService;
-import org.alfresco.repo.tenant.TenantUtil;
-import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
-import org.alfresco.repo.transaction.RetryingTransactionHelper;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.repo.version.VersionableAspectTest;
-import org.alfresco.repo.workflow.WorkflowDeployer;
-import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.action.ActionCondition;
-import org.alfresco.service.cmr.action.ActionService;
-import org.alfresco.service.cmr.dictionary.AspectDefinition;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.cmr.lock.LockService;
-import org.alfresco.service.cmr.lock.LockType;
-import org.alfresco.service.cmr.model.FileFolderService;
-import org.alfresco.service.cmr.model.FileInfo;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.ContentService;
-import org.alfresco.service.cmr.repository.ContentWriter;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.cmr.rule.Rule;
-import org.alfresco.service.cmr.rule.RuleService;
-import org.alfresco.service.cmr.rule.RuleType;
-import org.alfresco.service.cmr.search.SearchService;
-import org.alfresco.service.cmr.security.AccessPermission;
-import org.alfresco.service.cmr.security.AuthorityService;
-import org.alfresco.service.cmr.security.AuthorityType;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.cmr.tagging.TaggingService;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionService;
-import org.alfresco.service.cmr.version.VersionType;
-import org.alfresco.service.cmr.workflow.WorkflowAdminService;
-import org.alfresco.service.cmr.workflow.WorkflowService;
-import org.alfresco.service.namespace.NamespaceService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.ApplicationContextHelper;
-import org.alfresco.util.Pair;
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Ace;
-import org.apache.chemistry.opencmis.commons.data.AllowableActions;
-import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
-import org.apache.chemistry.opencmis.commons.data.ObjectList;
-import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
-import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
-import org.apache.chemistry.opencmis.commons.enums.Action;
-import org.apache.chemistry.opencmis.commons.enums.ChangeType;
-import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
-import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
-import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
-import org.apache.chemistry.opencmis.commons.server.CallContext;
-import org.apache.chemistry.opencmis.commons.server.CmisService;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-import org.springframework.extensions.webscripts.GUID;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.dictionary.CMISDictionaryService;
+import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
+import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
+import org.alfresco.opencmis.search.CMISQueryOptions;
+import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
+import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
+import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
+import org.alfresco.repo.audit.AuditComponent;
+import org.alfresco.repo.audit.AuditComponentImpl;
+import org.alfresco.repo.audit.AuditServiceImpl;
+import org.alfresco.repo.audit.UserAuditFilter;
+import org.alfresco.repo.audit.model.AuditModelRegistryImpl;
+import org.alfresco.repo.content.MimetypeMap;
+import org.alfresco.repo.dictionary.DictionaryDAO;
+import org.alfresco.repo.dictionary.M2Model;
+import org.alfresco.repo.domain.audit.AuditDAO;
+import org.alfresco.repo.domain.node.ContentDataWithId;
+import org.alfresco.repo.domain.node.NodeDAO;
+import org.alfresco.repo.model.Repository;
+import org.alfresco.repo.node.archive.NodeArchiveService;
+import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationContext;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.tenant.TenantAdminService;
+import org.alfresco.repo.tenant.TenantService;
+import org.alfresco.repo.tenant.TenantUtil;
+import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.repo.version.VersionableAspectTest;
+import org.alfresco.repo.workflow.WorkflowDeployer;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.action.ActionCondition;
+import org.alfresco.service.cmr.action.ActionService;
+import org.alfresco.service.cmr.dictionary.AspectDefinition;
+import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.service.cmr.lock.LockService;
+import org.alfresco.service.cmr.lock.LockType;
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.model.FileInfo;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.ContentService;
+import org.alfresco.service.cmr.repository.ContentWriter;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.repository.StoreRef;
+import org.alfresco.service.cmr.rule.Rule;
+import org.alfresco.service.cmr.rule.RuleService;
+import org.alfresco.service.cmr.rule.RuleType;
+import org.alfresco.service.cmr.search.SearchService;
+import org.alfresco.service.cmr.security.AccessPermission;
+import org.alfresco.service.cmr.security.AuthorityService;
+import org.alfresco.service.cmr.security.AuthorityType;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.cmr.tagging.TaggingService;
+import org.alfresco.service.cmr.version.Version;
+import org.alfresco.service.cmr.version.VersionService;
+import org.alfresco.service.cmr.version.VersionType;
+import org.alfresco.service.cmr.workflow.WorkflowAdminService;
+import org.alfresco.service.cmr.workflow.WorkflowService;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.ApplicationContextHelper;
+import org.alfresco.util.Pair;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.Ace;
+import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.data.ObjectList;
+import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.enums.ChangeType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
+import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.extensions.webscripts.GUID;
/**
* OpenCMIS tests.
@@ -175,11 +176,11 @@ import org.springframework.extensions.webscripts.GUID;
*
*/
public class CMISTest
-{
- private static Log logger = LogFactory.getLog(CMISTest.class);
+{
+ private static Log logger = LogFactory.getLog(CMISTest.class);
- private static final QName TEST_START_TASK = QName.createQName("http://www.alfresco.org/model/workflow/test/1.0", "startTaskVarScriptAssign");
- private static final QName TEST_WORKFLOW_TASK = QName.createQName("http://www.alfresco.org/model/workflow/test/1.0", "assignVarTask");
+ private static final QName TEST_START_TASK = QName.createQName("http://www.alfresco.org/model/workflow/test/1.0", "startTaskVarScriptAssign");
+ private static final QName TEST_WORKFLOW_TASK = QName.createQName("http://www.alfresco.org/model/workflow/test/1.0", "assignVarTask");
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(new String[]{ApplicationContextHelper.CONFIG_LOCATIONS[0],"classpath:test-cmisinteger_modell-context.xml"});
@@ -209,7 +210,7 @@ public class CMISTest
private TenantService tenantService;
private SearchService searchService;
private java.util.Properties globalProperties;
- private AuditComponentImpl auditComponent;
+ private AuditComponentImpl auditComponent;
private AlfrescoCmisServiceFactory factory;
@@ -388,7 +389,7 @@ public class CMISTest
this.tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService");
this.tenantService = (TenantService) ctx.getBean("tenantService");
this.searchService = (SearchService) ctx.getBean("SearchService");
- this.auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");
+ this.auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");
this.globalProperties = (java.util.Properties) ctx.getBean("global-properties");
this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
@@ -658,9 +659,9 @@ public class CMISTest
assertNotNull(startTaskTypeDefinition);
assertNotNull(workflowTaskTypeDefinition);
- // caches are refreshed asynchronously
- Thread.sleep(5000);
-
+ // caches are refreshed asynchronously
+ Thread.sleep(5000);
+
// check that loaded model is available via CMIS API
CallContext context = new SimpleCallContext("admin", "admin", CmisVersion.CMIS_1_1);
CmisService service = factory.getService(context);
@@ -799,12 +800,12 @@ public class CMISTest
*/
@Test
public void testContentMimeTypeDetection()
- {
- ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
- FileFolderService ffs = serviceRegistry.getFileFolderService();
- AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
- final String isoEncoding = "ISO-8859-1";
- final String utfEncoding = "UTF-8";
+ {
+ ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
+ FileFolderService ffs = serviceRegistry.getFileFolderService();
+ AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
+ final String isoEncoding = "ISO-8859-1";
+ final String utfEncoding = "UTF-8";
// get repository id
List repositories = withCmisService(new CmisServiceCallback>()
@@ -875,16 +876,16 @@ public class CMISTest
return contentType;
}
});
- assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_HTML, contentType);
-
- // check that the encoding is detected correctly
+ assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_HTML, contentType);
+
+ // check that the encoding is detected correctly
checkEncoding(ffs, authenticationComponent, objectData, utfEncoding);
}
// create content stream with mimetype and encoding as UTF-8
{
- String mimeType = MimetypeMap.MIMETYPE_TEXT_PLAIN + "; charset="+isoEncoding;
- // NOTE that we intentionally specify the wrong charset here.
+ String mimeType = MimetypeMap.MIMETYPE_TEXT_PLAIN + "; charset="+isoEncoding;
+ // NOTE that we intentionally specify the wrong charset here.
// Alfresco will detect the encoding (as UTF-8 - given by the ContentStreamImpl constructor)
final ContentStreamImpl contentStreamHTML = new ContentStreamImpl(null, mimeType, " Hello Test html