mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V4.1-BUG-FIX to HEAD
47745: ALF-18302: Merged V4.0.2 (4.0.2.29) to V4.1-BUG-FIX (4.1.5) 47498: MNT-317: CIFS: Image document version history lost intermittently after saving content in Preview on Mac Mountain Lion - Candidate fix by Dmitry Vaserin 47753: ALF-12264: Domain-filtering also done with new approach of fetching WorklfowTasks 47778: Merged DEV to V4.1-BUG-FIX ALF-18151: CMIS cannot delete folders that have rules applied - Will throw 'CMISConstraintException' exception only if 'ContentModel.ASSOC_CONTAINS' child association exist for the folder what is deleted. - Added and succesfully executed two unit test for openCMIS and CMIS. 47794: ALF-18302: Merged DEV to V4.1-BUG-FIX 47631: MNT-317: CIFS: Image document version history lost intermittently after saving content in Preview on Mac Mountain Lion Add class description describing the shuffle on ScenarioRenameDeleteMove. Add proper unit test. 47795: Merged back build fix from HEAD (thanks Neil) 47803: Merged PATCHES/V4.1.4 to V4.1-BUG-FIX 47680: Merged DEV to PATCHES/V4.1.4 47677: ALF-18270 Cannot open properties of model In FormUIGet.processFieldConstraints() was added check: (fieldConfig != null && fieldConfig.getConstraintDefinitionMap() != null). 47738: ALF-18301: Alfresco fails to start up because of NPE error, when debug logging for 'org.alfresco.repo.cache.AbstractAsynchronouslyRefreshedCache' is enabled - Fix by Dmitry Velichkevich 47754: Merged DEV to PATCHES/V4.1.4 47751: ALF-17644 : Document version was increased after canceling editing. Unnecessary calls for property deletion was removed. 47767: ALF-18088: Add Implementation-Edition + limit Specification-Version to 3 digits in war MANIFEST files 47786: Fixed ALF-18137 "It's impossible to create a new item in the data list." 47804: Merged PATCHES/V4.1.4 to V4.1-BUG-FIX (RECORD ONLY) 47755: Merged V4.1-BUG-FIX to PATCHES/V4.1.4 47753: ALF-12264: Domain-filtering also done with new approach of fetching WorklfowTasks git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47807 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,17 +32,20 @@ import org.alfresco.cmis.CMISRenditionService;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.NamespaceDAOImpl;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.repo.security.permissions.impl.ModelDAO;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
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.RuleService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -58,61 +61,39 @@ import org.springframework.context.ApplicationContext;
|
||||
* Basic TX control and authentication
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public abstract class BaseCMISTest extends TestCase
|
||||
{
|
||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
||||
protected CMISMapping cmisMapping;
|
||||
|
||||
protected CMISServices cmisService;
|
||||
|
||||
protected CMISDictionaryService cmisDictionaryService;
|
||||
|
||||
protected CMISRenditionService cmisRenditionService;
|
||||
|
||||
protected CMISAccessControlService cmisAccessControlService;
|
||||
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
protected TransactionService transactionService;
|
||||
|
||||
protected AuthenticationComponent authenticationComponent;
|
||||
|
||||
protected UserTransaction testTX;
|
||||
|
||||
protected NodeService nodeService;
|
||||
|
||||
protected NodeRef rootNodeRef;
|
||||
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
protected ServiceRegistry serviceRegistry;
|
||||
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
protected CMISQueryService cmisQueryService;
|
||||
|
||||
private MutableAuthenticationService authenticationService;
|
||||
|
||||
private MutableAuthenticationDao authenticationDAO;
|
||||
|
||||
protected SearchService searchService;
|
||||
|
||||
protected ContentService contentService;
|
||||
|
||||
protected PermissionService permissionService;
|
||||
|
||||
protected ThumbnailService thumbnailService;
|
||||
|
||||
protected ModelDAO permissionModelDao;
|
||||
|
||||
protected DictionaryDAO dictionaryDAO;
|
||||
|
||||
protected NamespaceDAOImpl namespaceDao;
|
||||
|
||||
protected VersionService versionService;
|
||||
protected ActionService actionService;
|
||||
protected RuleService ruleService;
|
||||
protected Repository repositoryHelper;
|
||||
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
@@ -140,6 +121,11 @@ public abstract class BaseCMISTest extends TestCase
|
||||
|
||||
versionService = (VersionService) ctx.getBean("versionService");
|
||||
|
||||
actionService = (ActionService)ctx.getBean("actionService");
|
||||
ruleService = (RuleService)ctx.getBean("ruleService");
|
||||
|
||||
repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
|
||||
|
||||
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
|
||||
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
|
||||
|
||||
|
@@ -19,19 +19,29 @@
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISConstraintException;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
|
||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionType;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
|
||||
@@ -774,4 +784,136 @@ public class CMISPropertyServiceTest extends BaseCMISTest
|
||||
String mimetype = (String) cmisService.getProperty(content, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE);
|
||||
assertTrue("Mimetype is not defined correctly.", mimetype.equals(MimetypeMap.MIMETYPE_HTML));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for ALF-18151.
|
||||
*/
|
||||
public void testDeleteFolder() throws Exception
|
||||
{
|
||||
Map<FileInfo, Boolean> testFolderMap = new HashMap<FileInfo, Boolean>(4);
|
||||
|
||||
try
|
||||
{
|
||||
// create folder with file
|
||||
String folderName = "cmistestfolder" + GUID.generate();
|
||||
String docName = "cmistestdoc.txt" + GUID.generate();
|
||||
FileInfo folder = createContent(folderName, docName, false);
|
||||
testFolderMap.put(folder, Boolean.FALSE);
|
||||
|
||||
// create empty folder
|
||||
String folderNameEmpty = "cmistestfolder_empty1" + GUID.generate();
|
||||
FileInfo folderEmpty = createContent(folderNameEmpty, null, false);
|
||||
testFolderMap.put(folderEmpty, Boolean.TRUE);
|
||||
|
||||
// create folder with file
|
||||
String folderNameRule = "cmistestfolde_rule" + GUID.generate();
|
||||
String docNameRule = "cmistestdoc_rule.txt" + GUID.generate();
|
||||
FileInfo folderWithRule = createContent(folderNameRule, docNameRule, true);
|
||||
testFolderMap.put(folderWithRule, Boolean.FALSE);
|
||||
|
||||
// create empty folder
|
||||
String folderNameEmptyRule = "cmistestfolde_empty_rule1" + GUID.generate();
|
||||
FileInfo folderEmptyWithRule = createContent(folderNameEmptyRule, null, true);
|
||||
testFolderMap.put(folderEmptyWithRule, Boolean.TRUE);
|
||||
|
||||
for (Map.Entry<FileInfo, Boolean> entry : testFolderMap.entrySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
// delete folder
|
||||
cmisService.deleteObject((String) cmisService.getProperty(entry.getKey().getNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID), Boolean.TRUE);
|
||||
}
|
||||
catch (CMISConstraintException ex)
|
||||
{
|
||||
assertTrue(!entry.getValue());
|
||||
continue;
|
||||
}
|
||||
|
||||
assertTrue(entry.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
for (Map.Entry<FileInfo, Boolean> entry : testFolderMap.entrySet())
|
||||
{
|
||||
if (fileFolderService.exists(entry.getKey().getNodeRef()))
|
||||
{
|
||||
fileFolderService.delete(entry.getKey().getNodeRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FileInfo createContent(final String folderName, final String docName, final boolean isRule)
|
||||
{
|
||||
final FileInfo folderInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
@Override
|
||||
public FileInfo execute() throws Throwable
|
||||
{
|
||||
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
|
||||
|
||||
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
|
||||
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
|
||||
assertNotNull(folderInfo);
|
||||
|
||||
FileInfo fileInfo;
|
||||
if (docName != null)
|
||||
{
|
||||
fileInfo = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT);
|
||||
nodeService.setProperty(fileInfo.getNodeRef(), ContentModel.PROP_NAME, docName);
|
||||
assertNotNull(fileInfo);
|
||||
}
|
||||
|
||||
if (isRule)
|
||||
{
|
||||
Rule rule = addRule(true, folderName);
|
||||
|
||||
assertNotNull(rule);
|
||||
|
||||
// Attach the rule to the node
|
||||
ruleService.saveRule(folderInfo.getNodeRef(), rule);
|
||||
|
||||
assertTrue(ruleService.getRules(folderInfo.getNodeRef()).size() > 0);
|
||||
}
|
||||
|
||||
return folderInfo;
|
||||
}
|
||||
});
|
||||
|
||||
return folderInfo;
|
||||
}
|
||||
|
||||
private Rule addRule(boolean isAppliedToChildren, String title)
|
||||
{
|
||||
|
||||
// Rule properties
|
||||
Map<String, Serializable> conditionProps = new HashMap<String, Serializable>();
|
||||
conditionProps.put(ComparePropertyValueEvaluator.PARAM_VALUE, ".txt");
|
||||
|
||||
Map<String, Serializable> actionProps = new HashMap<String, Serializable>();
|
||||
actionProps.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||
|
||||
List<String> ruleTypes = new ArrayList<String>(1);
|
||||
ruleTypes.add(RuleType.INBOUND);
|
||||
|
||||
// Create the action
|
||||
org.alfresco.service.cmr.action.Action action = actionService.createAction(title);
|
||||
action.setParameterValues(conditionProps);
|
||||
|
||||
ActionCondition actionCondition = actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
|
||||
actionCondition.setParameterValues(conditionProps);
|
||||
action.addActionCondition(actionCondition);
|
||||
|
||||
// Create the rule
|
||||
Rule rule = new Rule();
|
||||
rule.setRuleTypes(ruleTypes);
|
||||
rule.setTitle(title);
|
||||
rule.setDescription("description");
|
||||
rule.applyToChildren(isAppliedToChildren);
|
||||
rule.setAction(action);
|
||||
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,6 @@ import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
@@ -92,7 +91,6 @@ 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.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -160,7 +158,6 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
private CMISRenditionService cmisRenditionService;
|
||||
private CheckOutCheckInService checkOutCheckInService;
|
||||
private VersionService versionService;
|
||||
private MimetypeService mimetypeService;
|
||||
private ProcessorLifecycle lifecycle = new ProcessorLifecycle();
|
||||
|
||||
// CMIS supported version
|
||||
@@ -336,33 +333,13 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
this.versionService = versionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mimetype service.
|
||||
*
|
||||
* @param mimetypeService
|
||||
* the mimetype service
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
lifecycle.setApplicationContext(applicationContext);
|
||||
}
|
||||
|
||||
public void setHiddenAspect(HiddenAspect hiddenAspect)
|
||||
{
|
||||
this.hiddenAspect = hiddenAspect;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationContextEvent event)
|
||||
{
|
||||
lifecycle.onApplicationEvent(event);
|
||||
@@ -374,43 +351,31 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
private class ProcessorLifecycle extends AbstractLifecycleBean
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.tenant.TenantDeployer#onEnableTenant()
|
||||
*/
|
||||
@Override
|
||||
public void onEnableTenant()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.tenant.TenantDeployer#onDisableTenant()
|
||||
*/
|
||||
@Override
|
||||
public void onDisableTenant()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.tenant.TenantDeployer#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
// initialise data types
|
||||
@@ -595,18 +560,12 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
}
|
||||
}
|
||||
|
||||
private HiddenAspect hiddenAspect;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getChildren(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.cmis.CMISTypesFilterEnum, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef[] getChildren(NodeRef folderNodeRef, CMISTypesFilterEnum typesFilter, String orderBy)
|
||||
throws CMISInvalidArgumentException
|
||||
{
|
||||
PagingResults<FileInfo> pageOfNodeInfos = getChildren(folderNodeRef, typesFilter, BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.valueOf(0), orderBy);
|
||||
|
||||
// List<FileInfo> filteredChildren = hiddenAspect.removeHiddenFiles(Client.cmis, pageOfNodeInfos.getPage());
|
||||
List<FileInfo> filteredChildren = pageOfNodeInfos.getPage();
|
||||
int pageCnt = filteredChildren.size();
|
||||
NodeRef[] result = new NodeRef[pageCnt];
|
||||
@@ -1663,7 +1622,10 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
CMISTypeDefinition typeDef = getTypeDefinition(nodeRef);
|
||||
if (typeDef.getTypeId().getBaseTypeId() == CMISDictionaryModel.FOLDER_TYPE_ID)
|
||||
{
|
||||
if (nodeService.getChildAssocs(nodeRef).size() > 0)
|
||||
if (nodeService.getChildAssocs(
|
||||
nodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
RegexQNamePattern.MATCH_ALL).size() > 0)
|
||||
{
|
||||
throw new CMISConstraintException("Could not delete folder with at least one Child");
|
||||
}
|
||||
|
Reference in New Issue
Block a user