Merged V4.1-BUG-FIX to HEAD

42933: ALF-15328 could we add a sample log4j file in 'extension'? 
   42935: ALF-16455: Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.2)
      42934: ALF-16454 TransformerDebug id values have gaps 
   42955: ALF-15328 could we add a sample log4j file in 'extension'?
      - missing j in file name
   42982: Merged DEV to V4.1-BUG-FIX
      42873: ALF-16194: Checkout/Checkin leaves Lockable aspect on which disables autoVersionOnUpdateProps
             DoNothingCopyBehaviourCallback policy has been set for lockable aspect (implemented in LockServiceImpl);
             Unit test has been added. 
   43000: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_10_19 to BRANCHES/DEV/V4.1-BUG-FIX:
      42936: ALF-11573: It's impossible to Modify settings for document versions
   43010: ALF-16006 MT: Document Library is absent after upgrade from 3.4.x to 4.1.x (eg. 3.4.10 -> 4.1.1)
      - applied patch suggested in JIRA
   43017: ALF-16457: "CmisObjectNotFoundException: No corresponding type found! Not a CMIS object?" thrown by AlfrescoCmisServiceImpl.getChildren
        - Check CMISNodeInfo for invalid type before processing.
   43019: ALF-14353: Upgrade Activiti dependencies in Maven build
   43022: ALF-14353: Upgrade Activiti dependencies in Maven build
   43027: Merged DEV to V4.1-BUG-FIX
       42426: ALF-15577: " does not support the method HEAD " when opening a MS Access file with "View In Browser"
   43029: Merged DEV to 4.1-BUG-FIX (4.1.2)
      42988: ALF-15791: Custom Types,Aspects defined with prefix using underscore cannot be loaded by API calls like api/classes/<type or aspect>
         Identical logic for old and new ClassDef API was moved to abstract super classes
      42924: ALF-15791: Custom Types,Aspects defined with prefix using underscore cannot be loaded by API calls like api/classes/<type or aspect>
         New set of URL templates for class defenitions were provided to support requests with separated namespace prefixes and names
   43031: ALF-16489: Typo in column-name of newly created index
   43041: Merged DEV to 4.1-BUG-FIX (4.1.2)
      43040: ALF-16425: API call to return all classes, returns wrong properties in classes
         Propertydefs and assocdefs are reordered to corelate with classdefs. Unit test was added for issue.
   43052: ALF-16194: Checkout/Checkin leaves Lockable aspect on which disables autoVersionOnUpdateProps
      - Fix failing test
   43055: Probable fix for ALF-15813. Replaced the 'skipCount' with the one in the query request, rather than query result.
   The Lucene query result does not support the reporting of the skipCount.
   43065: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      42958: ALF-14421: Inconsistencies when applying Versionable Aspect 
      - We think the most preferable fix that will result in the best consistency between Share and old Explorer behaviour is to make the adding of the versionable aspect always result in an initial MAJOR version, if a version type has not been specified. Major/minor versions can still be controlled explicitly by checkout/checkin the versionable aspect properties and the version service API.
      42998: ALF-14421: Fixed version label unit test fallout - back to what it used to be.
      42999: Fix for ALF-16261 - IE script error occurs when email space users providing there are no users in this space
      43006: Removed dependency on Apache Commons StringUtils. See ALF-12541, ALF-14254, AMZNSSS-17
      43028: ALF-14722: Merged V4.1-BUG-FIX to V3.4-BUG-FIX
         42902: Merged DEV to V4.1-BUG-FIX
            42519: ALF-13588: Google Doc failed to authenticate after incorrect password being entered for google account 
               Add ability to unregister class behaviours.
               Unregister googledocs behaviours when subsystem stops.
   43066: ALF-16502: Merged PATCHES/V4.0.2 to V4.1-BUG-FIX
      42969: Merged DEV to PATCHES/V4.0.2
         42967: MNT-158: SharePoint Protocol Opening Documents in Read-Only for Site Consumer with Collaborator Privileges
            Remove manual throwing of AccessDeniedException is user has "consumer" or "contributor" role.
            Create "links" container from system user.
   43067: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX
      42470: ALF-16503 / ALF-16256: Upgrade 3.4.6 HF to 4.1.1 - DuplicateChildNodeNameException: Duplicate child name not allowed: surf-config 
      42591: ALF-16504 / ALF-16332: Fixed synchronization around org.alfresco.repo.dictionary.NamespaceDAOImpl.namespaceRegistryCache
      - There was no 'double checking' after releasing the write lock, meaning that under high concurrency lots of threads would queue up to continuously re-initialize the registry. 
      42705: ALF-16504/ ALF-16332, ALF-16377: Revisited synchronization and initialization of mutually-dependent DictionaryDAO and NamespaceDAO to prevent deadlock and simultaneous re-initialization in more than one thread
   43068: Merged DEV to V4.1-BUG-FIX
      - TODO: Update DB2 DDL in activiti
      42388: ALF-15828: DB2: unexpected index found in database.
      Modify activity create script for db2 to create normal name for ACT_HI_PROCINST.PROC_INST_ID_ index.
      Introduce patch that will rename autogenerated name to normal name for ACT_HI_PROCINST.PROC_INST_ID_ index.
      Update schema reference file for DB2.
      42429: ALF-15828: DB2: unexpected index found in database.
      Fix scripts from ALF-14983 and ALF-16038 to drop/recreate tables in DB2.
   43069: ALF-11214: IMAP subsystem is not successfully restarted after incorrect modification of IMAP properties via Admin Console
      Stopped ChildApplicationContextFactory from caching a stale application context that didn't successfully refresh.
   43071: ALF-13660: When using kerberos SSO, non domain explorer users requesting a download URL get a login page but after login do not get the requested document
   - Now the Web Client authentication filters use the same mechanism for preserving the request URL through a redirect to the login page
   43076: ALF-15828: Fixed merge issue
   43079: ALF-13602: Incorrect number of documents displayed in Share DocLib when a file is checked out
   - added ability for FileFolderService.list (-> FileFolder GetChildren CQ) to filter by one or more aspects, eg. cm:checkedOut
   43080: ALF-14421: More version label unit test fallout
   43092: Fix ALF-16460: Users may receive activity feed entries (from people they follow) for moderated sites to which they do not belong
   - also add unit test
   43093: Fix for ALF-16091 - Unable to inline edit javascript file.
   43096: Fix for ALF-16283 - When document is checked out, 'Edit Online' and 'Upload New Version' options should not be visible on the original document.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43103 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2012-10-25 16:38:22 +00:00
parent 4b4b1f72a7
commit b794365eaa
26 changed files with 728 additions and 203 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -40,7 +40,6 @@ import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.PermissionCheckedCollection.PermissionCheckedCollectionMixin;
@@ -425,59 +424,63 @@ public class FileFolderServiceImpl implements FileFolderService
/* (non-Javadoc)
* @see org.alfresco.service.cmr.model.FileFolderService#list(org.alfresco.service.cmr.repository.NodeRef, boolean, boolean, java.util.Set, org.alfresco.service.cmr.model.PagingSortRequest)
*/
@Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreTypeQNames", "sortProps", "pagingRequest"})
@Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreQNames", "sortProps", "pagingRequest"})
public PagingResults<FileInfo> list(NodeRef contextNodeRef,
boolean files,
boolean folders,
Set<QName> ignoreTypeQNames,
Set<QName> ignoreQNames,
List<Pair<QName, Boolean>> sortProps,
PagingRequest pagingRequest)
{
ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
ParameterCheck.mandatory("pagingRequest", pagingRequest);
Set<QName> searchTypeQNames = buildTypes(files, folders, ignoreTypeQNames);
Pair<Set<QName>,Set<QName>> pair = buildSearchTypesAndIgnoreAspects(files, folders, ignoreQNames);
Set<QName> searchTypeQNames = pair.getFirst();
Set<QName> ignoreAspectQNames = pair.getSecond();
// execute query
final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, null, searchTypeQNames, sortProps, pagingRequest);
final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, null, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
return getPagingResults(pagingRequest, results);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.model.FileFolderService#list(org.alfresco.service.cmr.repository.NodeRef, boolean, boolean, String, java.util.Set, org.alfresco.service.cmr.model.PagingSortRequest)
*/
public PagingResults<FileInfo> list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set<QName> ignoreQNameTypes, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
public PagingResults<FileInfo> list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
ParameterCheck.mandatory("pagingRequest", pagingRequest);
Set<QName> searchTypeQNames = buildTypes(files, folders, ignoreQNameTypes);
Pair<Set<QName>,Set<QName>> pair = buildSearchTypesAndIgnoreAspects(files, folders, ignoreQNames);
Set<QName> searchTypeQNames = pair.getFirst();
Set<QName> ignoreAspectQNames = pair.getSecond();
// execute query
final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, pattern, searchTypeQNames, sortProps, pagingRequest);
final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, pattern, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
return getPagingResults(pagingRequest, results);
}
private CannedQueryResults<NodeRef> listImpl(NodeRef contextNodeRef, boolean files, boolean folders)
{
Set<QName> searchTypeQNames = buildTypes(files, folders, null);
Set<QName> searchTypeQNames = buildSearchTypesAndIgnoreAspects(files, folders, null).getFirst();
return listImpl(contextNodeRef, searchTypeQNames);
}
private CannedQueryResults<NodeRef> listImpl(NodeRef contextNodeRef, Set<QName> searchTypeQNames)
{
return listImpl(contextNodeRef, null, searchTypeQNames, null, new PagingRequest(defaultListMaxResults, null));
return listImpl(contextNodeRef, null, searchTypeQNames, null, null, new PagingRequest(defaultListMaxResults, null));
}
// note: similar to getChildAssocs(contextNodeRef, searchTypeQNames) but enables paging features, including max items, sorting etc (with permissions per-applied)
private CannedQueryResults<NodeRef> listImpl(NodeRef contextNodeRef, String pattern, Set<QName> searchTypeQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
private CannedQueryResults<NodeRef> listImpl(NodeRef contextNodeRef, String pattern, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
// get canned query
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_FILEFOLDER_LIST);
GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, pattern, Collections.singleton(ContentModel.ASSOC_CONTAINS), searchTypeQNames, null, sortProps, pagingRequest);
GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, pattern, Collections.singleton(ContentModel.ASSOC_CONTAINS), searchTypeQNames, ignoreAspectQNames, null, sortProps, pagingRequest);
// execute canned query
CannedQueryResults<NodeRef> results = cq.execute();
@@ -747,9 +750,10 @@ public class FileFolderServiceImpl implements FileFolderService
return PermissionCheckedValueMixin.create(results);
}
private Set<QName> buildTypes(boolean files, boolean folders, Set<QName> ignoreQNameTypes)
private Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(boolean files, boolean folders, Set<QName> ignoreQNameTypes)
{
Set<QName> searchTypeQNames = new HashSet<QName>(100);
Set<QName> ignoreAspectQNames = null;
// Build a list of file and folder types
if (folders)
@@ -763,10 +767,32 @@ public class FileFolderServiceImpl implements FileFolderService
if (ignoreQNameTypes != null)
{
Set<QName> ignoreQNamesNotSearchTypes = new HashSet<QName>(ignoreQNameTypes);
ignoreQNamesNotSearchTypes.removeAll(searchTypeQNames);
ignoreQNamesNotSearchTypes.remove(ContentModel.TYPE_SYSTEM_FOLDER); // note: not included in buildFolderTypes()
if (ignoreQNamesNotSearchTypes.size() > 0)
{
ignoreAspectQNames = getAspectsToIgnore(ignoreQNamesNotSearchTypes);
}
searchTypeQNames.removeAll(ignoreQNameTypes);
}
return searchTypeQNames;
return new Pair<Set<QName>, Set<QName>>(searchTypeQNames, ignoreAspectQNames);
}
private Set<QName> getAspectsToIgnore(Set<QName> ignoreQNames)
{
Set<QName> ignoreQNameAspects = new HashSet<QName>(ignoreQNames.size());
for (QName qname : ignoreQNames)
{
if (dictionaryService.getAspect(qname) != null)
{
ignoreQNameAspects.add(qname);
}
}
return ignoreQNameAspects;
}
private Set<QName> buildFolderTypes()

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -24,8 +24,10 @@ import java.io.OutputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
@@ -49,6 +51,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileFolderServiceType;
@@ -107,6 +110,8 @@ public class FileFolderServiceImplTest extends TestCase
private PermissionService permissionService;
private TenantService tenantService;
private MutableAuthenticationService authenticationService;
private CheckOutCheckInService cociService;
private DictionaryDAO dictionaryDAO;
private UserTransaction txn;
private NodeRef rootNodeRef;
@@ -124,6 +129,7 @@ public class FileFolderServiceImplTest extends TestCase
authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
tenantService = (TenantService) ctx.getBean("tenantService");
cociService = serviceRegistry.getCheckOutCheckInService();
// start the transaction
txn = transactionService.getUserTransaction();
@@ -266,37 +272,6 @@ public class FileFolderServiceImplTest extends TestCase
}
}
public void testListPage() throws Exception
{
// sanity checks only (see also GetChildrenCannedQueryTest)
PagingRequest pagingRequest = new PagingRequest(100, null);
PagingResults<FileInfo> pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
assertTrue((pagingResults.getQueryExecutionId() != null) && (pagingResults.getQueryExecutionId().length() > 0));
assertNull(pagingResults.getTotalResultCount());
List<FileInfo> files = pagingResults.getPage();
// check
String[] expectedNames = new String[]
{ NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
checkFileList(files, 2, 3, expectedNames);
// empty list if skip count greater than number of results (ALF-7884)
pagingRequest = new PagingRequest(1000, 3, null);
pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
assertEquals(0, pagingResults.getPage().size());
// TODO add more here
}
public void testShallowFilesOnlyList() throws Exception
{
List<FileInfo> files = fileFolderService.listFiles(workingRootNodeRef);
@@ -1373,7 +1348,38 @@ public class FileFolderServiceImplTest extends TestCase
assertEquals(1, pagingResults.getPage().size());
}
public void testListHiddenFiles()
public void testListPage() throws Exception
{
// sanity checks only (see also GetChildrenCannedQueryTest)
PagingRequest pagingRequest = new PagingRequest(100, null);
PagingResults<FileInfo> pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
assertTrue((pagingResults.getQueryExecutionId() != null) && (pagingResults.getQueryExecutionId().length() > 0));
assertNull(pagingResults.getTotalResultCount());
List<FileInfo> files = pagingResults.getPage();
// check
String[] expectedNames = new String[]
{ NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
checkFileList(files, 2, 3, expectedNames);
// empty list if skip count greater than number of results (ALF-7884)
pagingRequest = new PagingRequest(1000, 3, null);
pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
assertEquals(0, pagingResults.getPage().size());
// TODO add more here
}
public void testList_HiddenFiles()
{
// Test that hidden files are not returned for clients that should not be able to see them,
// and that the total result count is correct.
@@ -1417,4 +1423,104 @@ public class FileFolderServiceImplTest extends TestCase
FileFilterMode.setClient(saveClient);
}
}
public void testList_notCheckedOut_ALF_13602()
{
// Test that, eg. in the case of Share doclib, when listing files that have been checked-out we only list the working copy (ie. not the original checkedOut copy)
int totalItems = 165;
int pageSize = 50;
// create some files
NodeRef nodeRef = fileFolderService.create(workingRootNodeRef, "" + System.currentTimeMillis(), ContentModel.TYPE_CONTENT).getNodeRef();
NodeRef nodeRef1 = fileFolderService.create(nodeRef, "parent", ContentModel.TYPE_CONTENT).getNodeRef();
NodeRef[] children = new NodeRef[totalItems];
for (int i = 0; i < totalItems; i++)
{
String suffix = String.format("%05d", i);
children[i] = fileFolderService.create(nodeRef1, "child-" + suffix, ContentModel.TYPE_CONTENT).getNodeRef();
}
checkPages(nodeRef1, pageSize, totalItems, false, -1);
// checkout 5th child
cociService.checkout(children[4]);
checkPages(nodeRef1, pageSize, totalItems, false, 4);
checkPages(nodeRef1, pageSize, totalItems, true, 4);
}
private void checkPages(NodeRef parentRef, int pageSize, int totalItems, boolean hideCheckedOut, int checkedOutChildIdx)
{
Set<QName> ignoreQNameTypes = null;
if (hideCheckedOut)
{
ignoreQNameTypes = new HashSet<QName>(1);
ignoreQNameTypes.add(ContentModel.ASPECT_CHECKED_OUT);
}
else
{
if (checkedOutChildIdx > -1)
{
totalItems++;
}
}
List<Pair<QName, Boolean>> sortProps = new ArrayList<Pair<QName, Boolean>>(1);
sortProps.add(new Pair<QName, Boolean>(ContentModel.PROP_NAME, true));
int pageCount = (totalItems / pageSize) + 1;
for (int i = 1; i <= pageCount; i++)
{
int offset = (i-1)*pageSize;
PagingRequest pagingRequest = new PagingRequest(offset, pageSize);
pagingRequest.setRequestTotalCountMax(10000); // need this so that total count is set
PagingResults<FileInfo> results = fileFolderService.list(parentRef, true, true, ignoreQNameTypes, sortProps, pagingRequest);
Pair<Integer, Integer> totalResultCount = results.getTotalResultCount();
assertNotNull(totalResultCount.getFirst());
assertEquals(totalItems, totalResultCount.getFirst().intValue());
assertNotNull(totalResultCount.getSecond());
assertEquals(totalItems, totalResultCount.getSecond().intValue());
assertEquals((i != pageCount ? pageSize : (totalItems - ((pageCount-1)*pageSize))), results.getPage().size());
int j = offset;
for (FileInfo fileInfo : results.getPage())
{
String suffix = String.format("%05d", j);
if (checkedOutChildIdx > -1)
{
if (! hideCheckedOut)
{
if (j == checkedOutChildIdx+1)
{
suffix = String.format("%05d", j-1) + " (Working Copy)";
}
else if (j > checkedOutChildIdx+1)
{
suffix = String.format("%05d", j-1);
}
}
else
{
if (j == checkedOutChildIdx)
{
suffix = String.format("%05d", j) + " (Working Copy)";
}
}
}
String actual = fileInfo.getName();
String expected = "child-"+suffix;
assertTrue("Expected: "+expected+", Actual: "+actual+" (j="+j+")", expected.equals(actual));
j++;
}
}
}
}

View File

@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.query.CannedQueryParameters;
@@ -36,6 +37,7 @@ import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.FileFilterMode;
import org.alfresco.util.FileFilterMode.Client;
@@ -46,7 +48,8 @@ import org.alfresco.util.FileFilterMode.Client;
* To get paged list of files and folders of a parent folder filtered by child type.
* Also optionally filtered and/or sorted by one or more properties (up to three).
*
* This is the same as the nodes getchildren canned query, except it takes into account hidden files and folders.
* This is the same as the nodes getchildren canned query, except it takes into account hidden files and folders (with respect to client visibility)
* and other aspect(s) to ignore - eg. optionally "cm:checkedOut" in case of Share DocLib.
*
* @since 4.1.1
* @author steveglover, janv
@@ -56,6 +59,8 @@ public class GetChildrenCannedQuery extends org.alfresco.repo.node.getchildren.G
{
private HiddenAspect hiddenAspect;
private DictionaryService dictionaryService;
private NodeService nodeService;
private Set<QName> ignoreAspectQNames;
public GetChildrenCannedQuery(
NodeDAO nodeDAO,
@@ -66,12 +71,17 @@ public class GetChildrenCannedQuery extends org.alfresco.repo.node.getchildren.G
MethodSecurityBean<NodeRef> methodSecurity,
CannedQueryParameters params,
HiddenAspect hiddenAspect,
DictionaryService dictionaryService)
DictionaryService dictionaryService,
NodeService nodeService,
Set<QName> ignoreAspectQNames)
{
super(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurity, params);
this.hiddenAspect = hiddenAspect;
this.dictionaryService = dictionaryService;
this.nodeService = nodeService;
this.ignoreAspectQNames = ignoreAspectQNames;
}
@Override
@@ -101,18 +111,7 @@ public class GetChildrenCannedQuery extends org.alfresco.repo.node.getchildren.G
protected boolean include(FilterSortNode node)
{
boolean ret = super.include(node);
// only visible files are returned, relative to the client type.
try
{
final Client client = FileFilterMode.getClient();
return ret && hiddenAspect.getVisibility(client, node.getNodeRef()) != Visibility.NotVisible;
}
catch(AccessDeniedException e)
{
// user may not have permission to determine the visibility of the node
return ret;
}
return ret && includeImpl(ret, node.getNodeRef());
}
@Override
@@ -151,20 +150,42 @@ public class GetChildrenCannedQuery extends org.alfresco.repo.node.getchildren.G
protected boolean include(NodeRef nodeRef)
{
boolean ret = super.include(nodeRef);
// only visible files are returned, relative to the client type.
try
{
final Client client = FileFilterMode.getClient();
return ret && hiddenAspect.getVisibility(client, nodeRef) != Visibility.NotVisible;
}
catch(AccessDeniedException e)
{
// user may not have permission to determine the visibility of the node
return ret;
}
return ret && includeImpl(ret, nodeRef);
}
}
protected boolean includeImpl(boolean ret, NodeRef nodeRef)
{
// only visible files are returned, relative to the client type.
try
{
final Client client = FileFilterMode.getClient();
boolean notHidden = hiddenAspect.getVisibility(client, nodeRef) != Visibility.NotVisible;
boolean notIgnore = true;
if (ignoreAspectQNames != null)
{
if (ignoreAspectQNames.size() > 1)
{
Set<QName> nodeAspects = nodeService.getAspects(nodeRef);
notIgnore = (! nodeAspects.removeAll(ignoreAspectQNames));
}
else if (ignoreAspectQNames.size() == 1)
{
if (nodeService.hasAspect(nodeRef, ignoreAspectQNames.iterator().next()))
{
notIgnore = false;
}
}
}
return ret && notHidden && notIgnore;
}
catch (AccessDeniedException e)
{
// user may not have permission to determine the visibility of the node
return ret;
}
}
}

View File

@@ -18,32 +18,55 @@
*/
package org.alfresco.repo.model.filefolder;
import java.util.List;
import java.util.Set;
import org.alfresco.query.CannedQuery;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.PagingRequest;
import org.alfresco.repo.domain.node.NodePropertyHelper;
import org.alfresco.repo.node.getchildren.FilterProp;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/**
* GetChidren canned query factory for files and folders.
*
* @since 4.1.1
* @author steveglover
* @author steveglover, janv
*
*/
public class GetChildrenCannedQueryFactory extends org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory
{
private HiddenAspect hiddenAspect;
private Set<QName> ignoreAspectQNames;
protected NodeService nodeService;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setHiddenAspect(HiddenAspect hiddenAspect)
{
this.hiddenAspect = hiddenAspect;
}
this.hiddenAspect = hiddenAspect;
}
public CannedQuery<NodeRef> getCannedQuery(NodeRef parentRef, String pattern, Set<QName> assocTypeQNames, Set<QName> childTypeQNames, Set<QName> ignoreAspectQNames, List<FilterProp> filterProps, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
this.ignoreAspectQNames = ignoreAspectQNames;
return super.getCannedQuery(parentRef, pattern, assocTypeQNames, childTypeQNames, filterProps, sortProps, pagingRequest);
}
@Override
public CannedQuery<NodeRef> getCannedQuery(CannedQueryParameters parameters)
{
NodePropertyHelper nodePropertyHelper = new NodePropertyHelper(dictionaryService, qnameDAO, localeDAO, contentDataDAO);
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurity, parameters, hiddenAspect, dictionaryService);
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurity, parameters, hiddenAspect, dictionaryService, nodeService, ignoreAspectQNames);
}
}

View File

@@ -80,7 +80,7 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
Version rootEdition = editionService.getEditions(mlContainerNodeRef).getAllVersions().iterator().next();
// Ensure that the version label is 1.0
assertTrue("The edition label would be 0.1 and not " + rootEdition.getVersionLabel(), rootEdition.getVersionLabel().equals("0.1"));
assertTrue("The edition label would be 1.0 and not " + rootEdition.getVersionLabel(), rootEdition.getVersionLabel().equals("1.0"));
/*
* default (1.1)
@@ -90,7 +90,7 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
editions = new ArrayList<Version>(editionService.getEditions(mlContainerNodeRef).getAllVersions());
Version firstEdition = editions.get(0);
// Ensure that the version label is 1.1
assertTrue("The edition label would be 0.2 and not " + firstEdition.getVersionLabel(), firstEdition.getVersionLabel().equals("0.2"));
assertTrue("The edition label would be 1.1 and not " + firstEdition.getVersionLabel(), firstEdition.getVersionLabel().equals("1.1"));
/*
* major (2.0)
@@ -101,8 +101,8 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
pivot = editionService.createEdition(pivot, versionProperties);
editions = new ArrayList<Version>(editionService.getEditions(mlContainerNodeRef).getAllVersions());
Version secondEdition = editions.get(0);
// Ensure that the version label is 1.0
assertTrue("The edition label would be 1.0 and not " + secondEdition.getVersionLabel(), secondEdition.getVersionLabel().equals("1.0"));
// Ensure that the version label is 2.0
assertTrue("The edition label would be 2.0 and not " + secondEdition.getVersionLabel(), secondEdition.getVersionLabel().equals("2.0"));
/*
* minor (2.1)
@@ -114,7 +114,7 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
editions = new ArrayList<Version>(editionService.getEditions(mlContainerNodeRef).getAllVersions());
Version thirdEdition = editions.get(0);
// Ensure that the version label is 2.1
assertTrue("The edition label would be 1.1 and not " + thirdEdition.getVersionLabel(), thirdEdition.getVersionLabel().equals("1.1"));
assertTrue("The edition label would be 2.1 and not " + thirdEdition.getVersionLabel(), thirdEdition.getVersionLabel().equals("2.1"));
}
public void testCreateEdition() throws Exception
@@ -138,8 +138,8 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
assertTrue("The locale of the conatiner should be changed", nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE).equals(Locale.FRENCH));
// get the two editions
Version rootEdition = editionHistory.getVersion("0.1");
Version actualEdition = editionHistory.getVersion("0.2");
Version rootEdition = editionHistory.getVersion("1.0");
Version actualEdition = editionHistory.getVersion("1.1");
// get the translations of the root versions
List<VersionHistory> rootVersionTranslations = editionService.getVersionedTranslations(rootEdition);
@@ -181,7 +181,7 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
public void testEditionServiceWithContent()
{
// create a mlContainer with some content
NodeRef mlContainerNodeRef = createMLContainerWithContent("0.1");
NodeRef mlContainerNodeRef = createMLContainerWithContent("1.0");
// get the french translation
NodeRef frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef,
Locale.FRENCH);
@@ -189,24 +189,24 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
// create a new edition starting from the french translation
NodeRef newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.2");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.1" + "-" + "0.2");
checkContentVersionValuesForEditions(mlContainerNodeRef);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.3");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.1" + "-" + "0.3");
checkContentVersionValuesForEditions(mlContainerNodeRef);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.4");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.1" + "-" + "0.4");
// checkContentVersionValuesForEditions(mlContainerNodeRef);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.3" + "-" + "0.2");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.2" + "-" + "0.2");
checkContentVersionValuesForEditions(mlContainerNodeRef);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.3" + "-" + "0.3");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.2" + "-" + "0.3");
checkContentVersionValuesForEditions(mlContainerNodeRef);
NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "0.3" + "-0.1");
NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "1.2" + "-1.0");
multilingualContentService.addTranslation(chineseContentNodeRef, mlContainerNodeRef, Locale.CHINESE);
checkContentVersionValuesForEditions(mlContainerNodeRef);
NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "0.3" + "-0.1");
NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "1.2" + "-1.0");
multilingualContentService.addTranslation(japaneseContentNodeRef, mlContainerNodeRef, Locale.JAPANESE);
checkContentVersionValuesForEditions(mlContainerNodeRef);
@@ -216,19 +216,19 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
checkContentVersionValuesForEditions(mlContainerNodeRef);
japaneseContentNodeRef = multilingualContentService
.getTranslationForLocale(mlContainerNodeRef, Locale.JAPANESE);
modifyContent(japaneseContentNodeRef, JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "0.4" + "-0.2");
chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "0.4" + "-0.1");
modifyContent(japaneseContentNodeRef, JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "1.3" + "-0.2");
chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "1.3" + "-1.0");
multilingualContentService.addTranslation(chineseContentNodeRef, mlContainerNodeRef, Locale.CHINESE);
checkContentVersionValuesForEditions(mlContainerNodeRef);
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.4" + "-0.1");
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.3" + "-1.0");
multilingualContentService.addTranslation(frenchContentNodeRef, mlContainerNodeRef, Locale.FRENCH);
checkContentVersionValuesForEditions(mlContainerNodeRef);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.5" + "-" + "0.2");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.4" + "-" + "0.2");
checkContentVersionValuesForEditions(mlContainerNodeRef);
@@ -241,9 +241,9 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
Version secondEdition = editions.iterator().next();
// Ensure that the version label is 2.0
assertTrue("The edition label would be 2.0 and not " + secondEdition.getVersionLabel(), secondEdition
.getVersionLabel().equals("1.0"));
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-0.1");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-" + "0.2");
.getVersionLabel().equals("2.0"));
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-1.0");
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-" + "1.1");
checkContentVersionValuesForEditions(mlContainerNodeRef);
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
@@ -254,10 +254,10 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
editions = editionService.getEditions(mlContainerNodeRef).getAllVersions();
secondEdition = editions.iterator().next();
// Ensure that the version label is 2.0
// Ensure that the version label is 3.0
assertTrue("The edition label would be 3.0 and not " + secondEdition.getVersionLabel(), secondEdition
.getVersionLabel().equals("2.0"));
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "2.0" + "-" + "0.2");
.getVersionLabel().equals("3.0"));
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "3.0" + "-" + "0.2");
checkContentVersionValuesForEditions(mlContainerNodeRef);
@@ -404,9 +404,9 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
{
// it is not a root version therefore it should respect the conventions
Triplet testTriplet = new Triplet(versionnedContent);
assertTrue(testTriplet.locale.equals(versionLocale.toString()));
assertTrue(testTriplet.edition.equals(editionLabel));
assertTrue(testTriplet.version.equals(versionLabel));
assertEquals(testTriplet.locale, versionLocale.toString());
assertEquals(testTriplet.edition, editionLabel);
assertEquals(testTriplet.version, versionLabel);
}
}
@@ -504,11 +504,11 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
NodeRef createMLContainerWithContent(String editionSuffix)
{
NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + editionSuffix
+ "-0.1");
+ "-1.0");
NodeRef frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + editionSuffix
+ "-0.1");
+ "-1.0");
NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + editionSuffix
+ "-0.1");
+ "-1.0");
multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);