Merged 5.1.N (5.1.1) to HEAD (5.1)

118307 nsmintanca: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)
      118231 aleahu: MNT-14853 : Unable to download zip with non primary child
         - Added the flag exportSecondaryNodes for the ExporterComponent, and if this is set on true we export the secondary nodes as actual nodes.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123591 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 17:29:50 +00:00
parent c2e645b2ae
commit 967c55b264
3 changed files with 24 additions and 4 deletions

View File

@@ -92,7 +92,7 @@
<property name="checkOutCheckInSerivce" ref="checkOutCheckInService"/>
<property name="contentServiceHelper" ref="downloadContentServiceHelper" />
<property name="downloadStorage" ref="downloadStorage" />
<property name="exporterService" ref="exporterComponent" />
<property name="exporterService" ref="downloadExporterComponent" />
<property name="maximumContentSize" value="${download.maxContentSize}" />
<property name="nodeService" ref="nodeService" />
<property name="publicAction" value="false"/>
@@ -100,6 +100,10 @@
<property name="updateService" ref="downloadStatusUpdateService"/>
</bean>
<bean id="downloadExporterComponent" parent="exporterComponent">
<property name="exportSecondaryNodes" value="true"/>
</bean>
<bean id="downloadActionServiceHelper" class="org.alfresco.repo.download.LocalActionServiceHelper">
<property name="localActionService" ref="actionService"/>
</bean>

View File

@@ -96,6 +96,7 @@ public class ExporterComponent
/** Indent Size */
private int indentSize = 2;
private boolean exportSecondaryNodes = false;
/**
@@ -162,6 +163,14 @@ public class ExporterComponent
this.permissionService = permissionService;
}
/**
* @param exportSecondaryNodes whether children that do dot have a primary association with their parent are exported as nodes
* If false, these nodes will be exported as secondary links.
*/
public void setExportSecondaryNodes(boolean exportSecondaryNodes)
{
this.exportSecondaryNodes = exportSecondaryNodes;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.view.ExporterService#exportView(java.io.OutputStream, org.alfresco.service.cmr.view.ExporterCrawlerParameters, org.alfresco.service.cmr.view.Exporter)
@@ -524,7 +533,7 @@ public class ExporterComponent
{
continue;
}
if (childAssoc.isPrimary() == false)
if (childAssoc.isPrimary() == false && !exportSecondaryNodes)
{
context.recordSecondaryLink(nodeRef);
continue;

View File

@@ -41,6 +41,7 @@ import org.alfresco.service.cmr.download.DownloadService;
import org.alfresco.service.cmr.download.DownloadStatus;
import org.alfresco.service.cmr.download.DownloadStatus.Status;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -107,6 +108,7 @@ public class DownloadServiceIntegrationTest
// Test Content
private NodeRef rootFolder;
private NodeRef rootFile;
private NodeRef secondaryNode;
private NodeRef level1Folder1;
@@ -168,6 +170,11 @@ public class DownloadServiceIntegrationTest
testNodes.createNodeWithTextContent(level1Folder2, "level2File.txt", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 2 file content");
allEntries.add("rootFolder/level1Folder2/level2File.txt");
secondaryNode = testNodes.createNodeWithTextContent(COMPANY_HOME, "secondaryNodeFile.txt", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Secondary node");
ChildAssociationRef assoc = NODE_SERVICE.addChild(rootFolder, secondaryNode, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);
Assert.assertFalse(assoc.isPrimary());
allEntries.add("rootFolder/secondaryNodeFile.txt");
fileToCheckout = testNodes.createNodeWithTextContent(level1Folder2, "fileToCheckout.txt", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 2 file content");
// Add the lock and version aspects to the created node
NODE_SERVICE.addAspect(fileToCheckout, ContentModel.ASPECT_VERSIONABLE, null);
@@ -217,7 +224,7 @@ public class DownloadServiceIntegrationTest
status = getDownloadStatus(downloadNode);
}
Assert.assertEquals(5l, status.getTotalFiles());
Assert.assertEquals(6l, status.getTotalFiles());
long elapsedTime = waitForDownload(downloadNode);