public void exportRepository(String[] repositories, int assetMaxSize, boolean onlyPublishedVersions, String exportFileName, ProcessBean processBean, boolean copy, String onlyLatestVersions, String standardReplacement, String replacements) throws Exception
{
Timer t = new Timer();
VisualFormatter visualFormatter = new VisualFormatter();
String exportId = "Export_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd_HHmm");
processBean.setStatus(ProcessBean.RUNNING);
String folderName = CmsPropertyHandler.getDigitalAssetPath() + File.separator + exportId + "Archive";
File folder = new File(folderName);
folder.mkdirs();
Database db = null;
try
{
db = CastorDatabaseService.getDatabase();
Mapping map = new Mapping();
logger.info("MappingFile:" + CastorDatabaseService.class.getResource("/xml_mapping_site_3.0.xml").toString());
map.loadMapping(CastorDatabaseService.class.getResource("/xml_mapping_site_3.0.xml").toString());
processBean.updateProcess("Export configuration initialized");
// All ODMG database access requires a transaction
db.begin();
Hashtable<String,String> allRepositoryProperties = new Hashtable<String,String>();
Hashtable<String,String> allSiteNodeProperties = new Hashtable<String,String>();
Hashtable<String,String> allContentProperties = new Hashtable<String,String>();
List<AccessRight> allAccessRights = new ArrayList<AccessRight>();
Map args = new HashMap();
args.put("globalKey", "infoglue");
PropertySet ps = PropertySetManager.getInstance("jdbc", args);
//END TEST
Collection keys = ps.getKeys();
logger.info("keys:" + keys.size());
processBean.updateProcess("Propertyset fetched in " + (t.getElapsedTime() / 1000) + " seconds");
String names = "";
List<Content> allExportedContents = new ArrayList<Content>();
List<SiteNode> allExportedSiteNodes = new ArrayList<SiteNode>();
int exportedEntities = exportHeavyEntities(repositories, "Contents", folderName, assetMaxSize, onlyPublishedVersions, exportFileName, allExportedSiteNodes, allExportedContents);
processBean.updateProcess("Contents exported: " + exportedEntities + " in " + (t.getElapsedTime() / 1000) + " seconds");
exportedEntities = exportHeavyEntities(repositories, "ContentVersions", folderName, assetMaxSize, onlyPublishedVersions, exportFileName, allExportedSiteNodes, allExportedContents);
processBean.updateProcess("Content versions exported: " + exportedEntities + " in " + (t.getElapsedTime() / 1000) + " seconds");
exportedEntities = exportHeavyEntities(repositories, "SiteNodes", folderName, assetMaxSize, onlyPublishedVersions, exportFileName, allExportedSiteNodes, allExportedContents);
processBean.updateProcess("Sitenodes exported: " + exportedEntities + " in " + (t.getElapsedTime() / 1000) + " seconds");
exportedEntities = exportHeavyEntities(repositories, "SiteNodeVersions", folderName, assetMaxSize, onlyPublishedVersions, exportFileName, allExportedSiteNodes, allExportedContents);
processBean.updateProcess("Sitenode versions exported: " + exportedEntities + " in " + (t.getElapsedTime() / 1000) + " seconds");
exportedEntities = exportHeavyEntities(repositories, "DigitalAssets", folderName, assetMaxSize, onlyPublishedVersions, exportFileName, allExportedSiteNodes, allExportedContents);
processBean.updateProcess("Assets exported: " + exportedEntities + " in " + (t.getElapsedTime() / 1000) + " seconds");
List<Repository> repositoryList = new ArrayList<Repository>();
for(int i=0; i<repositories.length; i++)
{
Integer repositoryId = new Integer(repositories[i]);
Repository repository = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
logger.info("Read repo");
/*
SiteNode siteNode = SiteNodeController.getController().getRootSiteNode(repositoryId, db);
logger.info("Read siteNode");
Content content = ContentController.getContentController().getRootContent(repositoryId, db);
logger.info("Read content");
*/
InterceptionPointVO interceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("Repository.Read", db);
if(interceptionPointVO != null)
allAccessRights.addAll(AccessRightController.getController().getAccessRightListOnlyReadOnly(interceptionPointVO.getId(), repository.getId().toString(), db));
logger.info("Read allAccessRights 1");
interceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("Repository.Write", db);
if(interceptionPointVO != null)
allAccessRights.addAll(AccessRightController.getController().getAccessRightListOnlyReadOnly(interceptionPointVO.getId(), repository.getId().toString(), db));
logger.info("Read allAccessRights 2");
interceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("Repository.ReadForBinding", db);
if(interceptionPointVO != null)
allAccessRights.addAll(AccessRightController.getController().getAccessRightListOnlyReadOnly(interceptionPointVO.getId(), repository.getId().toString(), db));
logger.info("Read allAccessRights 3:" + allAccessRights.size());
allAccessRights.addAll(AccessRightController.getController().getContentAccessRightListOnlyReadOnly(repository.getId(), db));
logger.info("Read allAccessRights 4:" + allAccessRights.size());
allAccessRights.addAll(AccessRightController.getController().getSiteNodeAccessRightListOnlyReadOnly(repository.getId(), db));
logger.info("Read allAccessRights 5:" + allAccessRights.size());
getContentProperties(ps, allContentProperties, allExportedContents, db);
logger.info("getContentPropertiesAndAccessRights");
getSiteNodeProperties(ps, allSiteNodeProperties, allExportedSiteNodes, db);
logger.info("getSiteNodePropertiesAndAccessRights");
//siteNodes.add(siteNode);
//contents.add(content);
names = names + "_" + repository.getName();
allRepositoryProperties.putAll(getRepositoryProperties(ps, repositoryId));
repositoryList.add(repository);
}
processBean.updateProcess("Access rights: " + allAccessRights.size() + " exported in " + (t.getElapsedTime() / 1000) + " seconds");
List<Language> languages = LanguageController.getController().getLanguageList(db);
List<ContentTypeDefinition> contentTypeDefinitions = ContentTypeDefinitionController.getController().getContentTypeDefinitionList(db);
List<CategoryVO> categories = CategoryController.getController().getAllActiveCategories();
List<SiteNodeTypeDefinition> siteNodeTypeDefinitions = SiteNodeTypeDefinitionController.getController().getSiteNodeTypeDefinitionList(db);
processBean.updateProcess("Content type and categories exported in " + (t.getElapsedTime() / 1000) + " seconds");
InfoGlueExportImpl infoGlueExportImpl = new InfoGlueExportImpl();
names = new VisualFormatter().replaceNonAscii(names, '_');
if(repositories.length > 2 || names.length() > 40)
names = "" + repositories.length + "_repositories";
String fileName = exportId;