Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.0/Cloud)

87733: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      87683: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.4)
         87387: MNT-12504: Unable to Download as Zip if there is an association between nodes
            - try\catch block was added in ExporterComponent.isWithinExport() method. Appropriate unit test was added.
         87633: MNT-12504: Unable to Download as Zip if there is an association between nodes
            - Corrections for unit test that creates test user if one does not exist.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94550 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 09:49:03 +00:00
parent 2222eee2e9
commit 285eaa0399
2 changed files with 106 additions and 17 deletions

View File

@@ -35,6 +35,7 @@ import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.MLPropertyInterceptor;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -45,6 +46,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -921,30 +923,42 @@ public class ExporterComponent
private boolean isWithinExport(NodeRef nodeRef, ExporterCrawlerParameters parameters)
{
boolean isWithin = false;
// Current strategy is to determine if node is a child of the root exported node
for (NodeRef exportRoot : context.getExportList())
try
{
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
// Current strategy is to determine if node is a child of the root exported node
for (NodeRef exportRoot : context.getExportList())
{
// node to export is the root export node (and root is to be exported)
isWithin = true;
}
else
{
// locate export root in primary parent path of node
Path nodePath = nodeService.getPath(nodeRef);
for (int i = nodePath.size() -1; i >= 0; i--)
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
{
Path.ChildAssocElement pathElement = (Path.ChildAssocElement)nodePath.get(i);
if (pathElement.getRef().getChildRef().equals(exportRoot))
// node to export is the root export node (and root is to be exported)
isWithin = true;
}
else
{
// locate export root in primary parent path of node
Path nodePath = nodeService.getPath(nodeRef);
for (int i = nodePath.size() - 1; i >= 0; i--)
{
isWithin = true;
break;
Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i);
if (pathElement.getRef().getChildRef().equals(exportRoot))
{
isWithin = true;
break;
}
}
}
}
}
catch (AccessDeniedException accessErr)
{
// use default if this occurs
}
catch (InvalidNodeRefException nodeErr)
{
// use default if this occurs
}
return isWithin;
}
}