mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-18340: test to prove prop updates work when removing aspects
This commit is contained in:
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
* #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 <http://www.gnu.org/licenses/>.
|
||||
* #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<RepositoryInfo> repositories = withCmisService(new CmisServiceCallback<List<RepositoryInfo>>()
|
||||
@@ -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, "<html><head><title> Hello </title></head><body><p> Test html</p></body></html></body></html>");
|
||||
withCmisService(new CmisServiceCallback<Void>()
|
||||
@@ -917,68 +918,68 @@ public class CMISTest
|
||||
return contentType;
|
||||
}
|
||||
});
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_TEXT_PLAIN, contentType);
|
||||
|
||||
// check that the encoding is detected correctly
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_TEXT_PLAIN, contentType);
|
||||
|
||||
// check that the encoding is detected correctly
|
||||
checkEncoding(ffs, authenticationComponent, objectData, utfEncoding);
|
||||
}
|
||||
|
||||
// create content stream with mimetype and encoding as ISO-8859-1
|
||||
{
|
||||
String mimeType = MimetypeMap.MIMETYPE_TEXT_PLAIN + "; charset=" + utfEncoding;
|
||||
// NOTE that we intentionally specify the wrong charset here.
|
||||
// Alfresco will detect the encoding (as ISO-8859-1 - given by the ContentStreamImpl with streams)
|
||||
String content = "<html><head><title>aegif Mind Share Leader Generating New Paradigms by aegif corporation</title></head><body><p> Test html</p></body></html></body></html>";
|
||||
byte[] buf = null;
|
||||
try
|
||||
{
|
||||
buf = content.getBytes(isoEncoding); // set the encoding here for the content stream
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(buf);
|
||||
|
||||
final ContentStream contentStreamHTML = new ContentStreamImpl(null, BigInteger.valueOf(buf.length), mimeType, input);
|
||||
withCmisService(new CmisServiceCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute(CmisService cmisService)
|
||||
{
|
||||
Holder<String> latestObjectIdHolder = getHolderOfObjectOfLatestVersion(cmisService, repositoryId,
|
||||
objectIdHolder);
|
||||
cmisService.setContentStream(repositoryId, latestObjectIdHolder, true, null, contentStreamHTML, null);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// check mimetype
|
||||
final ObjectData objectData = withCmisService(new CmisServiceCallback<ObjectData>()
|
||||
{
|
||||
@Override
|
||||
public ObjectData execute(CmisService cmisService)
|
||||
{
|
||||
ObjectData objectData = cmisService.getObjectByPath(repositoryId, path, null, false,
|
||||
IncludeRelationships.NONE, null, false, false, null);
|
||||
return objectData;
|
||||
}
|
||||
});
|
||||
String contentType = withCmisService(new CmisServiceCallback<String>()
|
||||
{
|
||||
@Override
|
||||
public String execute(CmisService cmisService)
|
||||
{
|
||||
String contentType = cmisService.getObjectInfo(repositoryId, objectData.getId()).getContentType();
|
||||
return contentType;
|
||||
}
|
||||
});
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_TEXT_PLAIN, contentType);
|
||||
|
||||
// check that the encoding is detected correctly
|
||||
checkEncoding(ffs, authenticationComponent, objectData, isoEncoding);
|
||||
}
|
||||
|
||||
// create content stream with mimetype and encoding as ISO-8859-1
|
||||
{
|
||||
String mimeType = MimetypeMap.MIMETYPE_TEXT_PLAIN + "; charset=" + utfEncoding;
|
||||
// NOTE that we intentionally specify the wrong charset here.
|
||||
// Alfresco will detect the encoding (as ISO-8859-1 - given by the ContentStreamImpl with streams)
|
||||
String content = "<html><head><title>aegif Mind Share Leader Generating New Paradigms by aegif corporation</title></head><body><p> Test html</p></body></html></body></html>";
|
||||
byte[] buf = null;
|
||||
try
|
||||
{
|
||||
buf = content.getBytes(isoEncoding); // set the encoding here for the content stream
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(buf);
|
||||
|
||||
final ContentStream contentStreamHTML = new ContentStreamImpl(null, BigInteger.valueOf(buf.length), mimeType, input);
|
||||
withCmisService(new CmisServiceCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute(CmisService cmisService)
|
||||
{
|
||||
Holder<String> latestObjectIdHolder = getHolderOfObjectOfLatestVersion(cmisService, repositoryId,
|
||||
objectIdHolder);
|
||||
cmisService.setContentStream(repositoryId, latestObjectIdHolder, true, null, contentStreamHTML, null);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// check mimetype
|
||||
final ObjectData objectData = withCmisService(new CmisServiceCallback<ObjectData>()
|
||||
{
|
||||
@Override
|
||||
public ObjectData execute(CmisService cmisService)
|
||||
{
|
||||
ObjectData objectData = cmisService.getObjectByPath(repositoryId, path, null, false,
|
||||
IncludeRelationships.NONE, null, false, false, null);
|
||||
return objectData;
|
||||
}
|
||||
});
|
||||
String contentType = withCmisService(new CmisServiceCallback<String>()
|
||||
{
|
||||
@Override
|
||||
public String execute(CmisService cmisService)
|
||||
{
|
||||
String contentType = cmisService.getObjectInfo(repositoryId, objectData.getId()).getContentType();
|
||||
return contentType;
|
||||
}
|
||||
});
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_TEXT_PLAIN, contentType);
|
||||
|
||||
// check that the encoding is detected correctly
|
||||
checkEncoding(ffs, authenticationComponent, objectData, isoEncoding);
|
||||
}
|
||||
|
||||
// checkout/checkin object with mimetype and encoding
|
||||
{
|
||||
@@ -1033,50 +1034,50 @@ public class CMISTest
|
||||
return contentType;
|
||||
}
|
||||
});
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_HTML, contentType);
|
||||
|
||||
checkEncoding(ffs, authenticationComponent, objectData, utfEncoding);
|
||||
assertEquals("Mimetype is not defined correctly.", MimetypeMap.MIMETYPE_HTML, contentType);
|
||||
|
||||
checkEncoding(ffs, authenticationComponent, objectData, utfEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkEncoding(FileFolderService ffs, AuthenticationComponent authenticationComponent,
|
||||
final ObjectData objectData, String expectedEncoding)
|
||||
{
|
||||
// Authenticate as system to check the properties in alfresco
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
NodeRef doc1NodeRef = cmisIdToNodeRef(objectData.getId());
|
||||
doc1NodeRef.getId();
|
||||
|
||||
FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
|
||||
Map<QName, Serializable> properties2 = fileInfo.getProperties();
|
||||
|
||||
ContentDataWithId contentData = (ContentDataWithId) properties2
|
||||
.get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
|
||||
String encoding = contentData.getEncoding();
|
||||
|
||||
assertEquals(expectedEncoding, encoding);
|
||||
}
|
||||
finally
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Turns a CMIS id into a node ref
|
||||
* @param nodeId
|
||||
* @return
|
||||
*/
|
||||
private NodeRef cmisIdToNodeRef(String nodeId)
|
||||
{
|
||||
int idx = nodeId.indexOf(";");
|
||||
if(idx != -1)
|
||||
{
|
||||
nodeId = nodeId.substring(0, idx);
|
||||
}
|
||||
NodeRef nodeRef = new NodeRef(nodeId);
|
||||
return nodeRef;
|
||||
|
||||
protected void checkEncoding(FileFolderService ffs, AuthenticationComponent authenticationComponent,
|
||||
final ObjectData objectData, String expectedEncoding)
|
||||
{
|
||||
// Authenticate as system to check the properties in alfresco
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
NodeRef doc1NodeRef = cmisIdToNodeRef(objectData.getId());
|
||||
doc1NodeRef.getId();
|
||||
|
||||
FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
|
||||
Map<QName, Serializable> properties2 = fileInfo.getProperties();
|
||||
|
||||
ContentDataWithId contentData = (ContentDataWithId) properties2
|
||||
.get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
|
||||
String encoding = contentData.getEncoding();
|
||||
|
||||
assertEquals(expectedEncoding, encoding);
|
||||
}
|
||||
finally
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Turns a CMIS id into a node ref
|
||||
* @param nodeId
|
||||
* @return
|
||||
*/
|
||||
private NodeRef cmisIdToNodeRef(String nodeId)
|
||||
{
|
||||
int idx = nodeId.indexOf(";");
|
||||
if(idx != -1)
|
||||
{
|
||||
nodeId = nodeId.substring(0, idx);
|
||||
}
|
||||
NodeRef nodeRef = new NodeRef(nodeId);
|
||||
return nodeRef;
|
||||
}
|
||||
private Holder<String> getHolderOfObjectOfLatestVersion(CmisService cmisService, String repositoryId, Holder<String> currentHolder)
|
||||
{
|
||||
@@ -1755,9 +1756,13 @@ public class CMISTest
|
||||
|
||||
List secondaryTypeIds = currentProperties.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
|
||||
|
||||
assertTrue(secondaryTypeIds.contains(aspectName));
|
||||
|
||||
secondaryTypeIds.remove(aspectName);
|
||||
final PropertiesImpl newProperties = new PropertiesImpl();
|
||||
newProperties.addProperty(new PropertyStringImpl(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypeIds));
|
||||
final String updatedName = "My_new_name_"+UUID.randomUUID().toString();
|
||||
newProperties.replaceProperty(new PropertyStringImpl(PropertyIds.NAME, updatedName));
|
||||
|
||||
withCmisService(new CmisServiceCallback<Void>()
|
||||
{
|
||||
@@ -1765,6 +1770,8 @@ public class CMISTest
|
||||
public Void execute(CmisService cmisService)
|
||||
{
|
||||
Holder<String> latestObjectIdHolder = getHolderOfObjectOfLatestVersion(cmisService, repositoryId, objectIdHolder);
|
||||
// This will result in aspectName being removed
|
||||
// but that shouldn't mean that, for example, a cmis:name prop update gets ignored (MNT-18340)
|
||||
cmisService.updateProperties(repositoryId, latestObjectIdHolder, null, newProperties, null);
|
||||
return null;
|
||||
}
|
||||
@@ -1775,12 +1782,15 @@ public class CMISTest
|
||||
@Override
|
||||
public Properties execute(CmisService cmisService)
|
||||
{
|
||||
Properties properties = cmisService.getProperties(repositoryId, objectIdHolder.getValue(), null, null);
|
||||
Holder<String> latestObjectIdHolder = getHolderOfObjectOfLatestVersion(cmisService, repositoryId, objectIdHolder);
|
||||
Properties properties = cmisService.getProperties(repositoryId, latestObjectIdHolder.getValue(), null, null);
|
||||
return properties;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
secondaryTypeIds = currentProperties1.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
|
||||
|
||||
assertFalse(secondaryTypeIds.contains(aspectName));
|
||||
assertEquals(updatedName, currentProperties1.getProperties().get(PropertyIds.NAME).getFirstValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2553,32 +2563,32 @@ public class CMISTest
|
||||
{
|
||||
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
M2Model customModel = M2Model.createModel(
|
||||
Thread.currentThread().getContextClassLoader().
|
||||
getResourceAsStream("dictionary/dictionarydaotest_model1.xml"));
|
||||
dictionaryDAO.putModel(customModel);
|
||||
|
||||
assertNotNull(cmisDictionaryService.findType("P:cm:dublincore"));
|
||||
TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1");
|
||||
assertNotNull(td);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
M2Model customModel = M2Model.createModel(
|
||||
Thread.currentThread().getContextClassLoader().
|
||||
getResourceAsStream("dictionary/dictionarydaotest_model1.xml"));
|
||||
dictionaryDAO.putModel(customModel);
|
||||
|
||||
assertNotNull(cmisDictionaryService.findType("P:cm:dublincore"));
|
||||
TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1");
|
||||
assertNotNull(td);
|
||||
return null;
|
||||
}
|
||||
}, "user1", "tenant1");
|
||||
|
||||
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
assertNotNull(cmisDictionaryService.findType("P:cm:dublincore"));
|
||||
TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1");
|
||||
assertNull(td);
|
||||
return null;
|
||||
}
|
||||
}, "user2", "tenant2");
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
assertNotNull(cmisDictionaryService.findType("P:cm:dublincore"));
|
||||
TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1");
|
||||
assertNull(td);
|
||||
return null;
|
||||
}
|
||||
}, "user2", "tenant2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2706,32 +2716,32 @@ public class CMISTest
|
||||
|
||||
assertFalse("CMISChangeEvent " + changeType + " should store short form of objectId " + objectId,
|
||||
objectId.toString().contains(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString()));
|
||||
}
|
||||
}
|
||||
int expectAtLeast = changes.getObjects().size();
|
||||
|
||||
// We should also be able to query without passing in any limit
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, null, null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// and zero
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(0), null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// and one
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(1), null);
|
||||
assertEquals("Expected to still get changes", changes.getObjects().size(), 1);
|
||||
// Integery.MAX_VALUE must be handled
|
||||
// This will limit the number to a sane value
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(Integer.MAX_VALUE), null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// but not negative
|
||||
try
|
||||
{
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(-1), null);
|
||||
fail("Negative maxItems is expected to fail");
|
||||
}
|
||||
catch (CmisInvalidArgumentException e)
|
||||
{
|
||||
// Expected
|
||||
}
|
||||
|
||||
// We should also be able to query without passing in any limit
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, null, null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// and zero
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(0), null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// and one
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(1), null);
|
||||
assertEquals("Expected to still get changes", changes.getObjects().size(), 1);
|
||||
// Integery.MAX_VALUE must be handled
|
||||
// This will limit the number to a sane value
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(Integer.MAX_VALUE), null);
|
||||
assertTrue("Expected to still get changes", changes.getObjects().size() >= expectAtLeast);
|
||||
// but not negative
|
||||
try
|
||||
{
|
||||
changes = cmisService.getContentChanges(repositoryId, new Holder<String>(changeToken), Boolean.TRUE, null, Boolean.FALSE, Boolean.FALSE, BigInteger.valueOf(-1), null);
|
||||
fail("Negative maxItems is expected to fail");
|
||||
}
|
||||
catch (CmisInvalidArgumentException e)
|
||||
{
|
||||
// Expected
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -3668,64 +3678,64 @@ public class CMISTest
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDocWithVersioningStateNone() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
try
|
||||
{
|
||||
// get repository id
|
||||
final String repositoryId = withCmisService(new CmisServiceCallback<String>()
|
||||
{
|
||||
@Override
|
||||
public String execute(CmisService cmisService)
|
||||
{
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
final String repositoryId = repo.getId();
|
||||
return repositoryId;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef execute(CmisService cmisService)
|
||||
{
|
||||
final PropertiesImpl properties = new PropertiesImpl();
|
||||
String objectTypeId = "cmis:document";
|
||||
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, objectTypeId));
|
||||
String fileName = "textFile" + GUID.generate();
|
||||
properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, fileName));
|
||||
final ContentStreamImpl contentStream = new ContentStreamImpl(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Simple text plain document");
|
||||
|
||||
String nodeId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.NONE, null, null);
|
||||
return new NodeRef(nodeId.substring(0, nodeId.indexOf(';')));
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
// check versioning properties
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
|
||||
{
|
||||
@Override
|
||||
public List<Void> execute() throws Throwable
|
||||
{
|
||||
assertTrue(nodeService.exists(documentNodeRef));
|
||||
assertFalse(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDocWithVersioningStateNone() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
try
|
||||
{
|
||||
// get repository id
|
||||
final String repositoryId = withCmisService(new CmisServiceCallback<String>()
|
||||
{
|
||||
@Override
|
||||
public String execute(CmisService cmisService)
|
||||
{
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
final String repositoryId = repo.getId();
|
||||
return repositoryId;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef execute(CmisService cmisService)
|
||||
{
|
||||
final PropertiesImpl properties = new PropertiesImpl();
|
||||
String objectTypeId = "cmis:document";
|
||||
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, objectTypeId));
|
||||
String fileName = "textFile" + GUID.generate();
|
||||
properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, fileName));
|
||||
final ContentStreamImpl contentStream = new ContentStreamImpl(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Simple text plain document");
|
||||
|
||||
String nodeId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.NONE, null, null);
|
||||
return new NodeRef(nodeId.substring(0, nodeId.indexOf(';')));
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
// check versioning properties
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
|
||||
{
|
||||
@Override
|
||||
public List<Void> execute() throws Throwable
|
||||
{
|
||||
assertTrue(nodeService.exists(documentNodeRef));
|
||||
assertFalse(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-14951: Test that the list of parents can be retrieved for a folder.
|
||||
@@ -3792,5 +3802,5 @@ public class CMISTest
|
||||
auditSubsystem.destroy();
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user