Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)

51903 to 54309 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Samuel Langlois
2013-08-20 17:17:31 +00:00
parent a91f6e2535
commit 788d3c9c89
777 changed files with 77820 additions and 23746 deletions

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.web.scripts.site;
import org.alfresco.repo.activities.SiteActivityTest;
import org.alfresco.repo.site.SiteServiceImplMoreTest;
import org.alfresco.repo.site.SiteServiceImplTest;
import org.alfresco.service.cmr.site.SiteService;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* This class is a holder for the various test classes associated with the {@link SiteService}.
* It is not (at the time of writing) intended to be incorporated into the automatic build
* which will find the various test classes and run them individually.
*
* @author Neil Mc Erlean
* @since 4.0
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
SiteServiceImplTest.class,
SiteServiceImplMoreTest.class,
SiteServiceTest.class,
SiteActivityTest.class
})
public class AllSiteTests
{
// Intentionally empty
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -30,6 +30,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.exporter.ACPExportPackageHandler;
@@ -44,8 +46,6 @@ import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
import org.alfresco.service.cmr.view.ExporterService;
import org.alfresco.service.cmr.view.Location;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.extensions.webscripts.AbstractWebScript;
@@ -108,8 +108,22 @@ public class SiteExportGet extends AbstractWebScript
// Export the users who are members of the site's groups
// Also includes the list of their site related groups
mainZip.putNextEntry(new ZipEntry("People.acp"));
doPeopleACPExport(site, outputForNesting);
//
// If there are no users in this site (other than the built-ins like admin, guest)
// then include a special marker entry to that effect.
final List<NodeRef> peopleNodes = getPersonNodesInSiteGroup(site);
if (peopleNodes.isEmpty())
{
mainZip.putNextEntry(new ZipEntry("No_Persons_In_Site.txt"));
String text = "Person nodes were not exported because the site does not contain\n"+
"any members other than the built-ins e.g. admin, guest.";
outputForNesting.write(text.getBytes("ASCII"));
}
else
{
mainZip.putNextEntry(new ZipEntry("People.acp"));
doPeopleACPExport(peopleNodes, site, outputForNesting);
}
// Export the Site's groups listings
mainZip.putNextEntry(new ZipEntry("Groups.txt"));
@@ -134,6 +148,13 @@ public class SiteExportGet extends AbstractWebScript
"Subsystem you are using is not repository based";
outputForNesting.write(text.getBytes("ASCII"));
}
else if (peopleNodes.isEmpty())
{
mainZip.putNextEntry(new ZipEntry("No_Users_In_Site.txt"));
String text = "User nodes were not exported because the site does not contain\n"+
"any members other than the built-ins e.g. admin, guest.";
outputForNesting.write(text.getBytes("ASCII"));
}
else
{
mainZip.putNextEntry(new ZipEntry("Users.acp"));
@@ -164,7 +185,34 @@ public class SiteExportGet extends AbstractWebScript
exporterService.exportView(handler, parameters, null);
}
protected void doPeopleACPExport(SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException
protected void doPeopleACPExport(final List<NodeRef> peopleNodes, SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException
{
if (!peopleNodes.isEmpty())
{
// Build the parameters
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
parameters.setExportFrom(new Location(peopleNodes.toArray(new NodeRef[peopleNodes.size()])));
parameters.setCrawlChildNodes(true);
parameters.setCrawlSelf(true);
parameters.setCrawlContent(true);
// And the export handler
ACPExportPackageHandler handler = new ACPExportPackageHandler(
writeTo,
new File(site.getShortName() + "-people.xml"),
new File(site.getShortName() + "-people"),
mimetypeService);
// Do the export
exporterService.exportView(handler, parameters, null);
}
}
/**
* Gets the NodeRefs for cm:person nodes in the specified site - excluding admin, guest.
* @since 4.1.5
*/
private List<NodeRef> getPersonNodesInSiteGroup(SiteInfo site)
{
// Find the root group
String siteGroup = AbstractSiteWebScript.buildSiteGroup(site);
@@ -182,24 +230,7 @@ public class SiteExportGet extends AbstractWebScript
peopleNodes.add(authorityService.getAuthorityNodeRef(authority));
}
}
// Build the parameters
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
parameters.setExportFrom(new Location(peopleNodes.toArray(new NodeRef[peopleNodes.size()])));
parameters.setCrawlChildNodes(true);
parameters.setCrawlSelf(true);
parameters.setCrawlContent(true);
// And the export handler
ACPExportPackageHandler handler = new ACPExportPackageHandler(
writeTo,
new File(site.getShortName() + "-people.xml"),
new File(site.getShortName() + "-people"),
mimetypeService);
// Do the export
exporterService.exportView(handler, parameters, null);
return peopleNodes;
}
protected void doGroupExport(SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException