try
{
db.begin();
Integer repositoryId = new Integer(repositories[i]);
Repository repository = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
logger.info("Read repo");
List<SiteNode> allSiteNodes = new ArrayList<SiteNode>();
List<SiteNodeVersion> allSiteNodeVersions = new ArrayList<SiteNodeVersion>();
List<Content> allContents = new ArrayList<Content>();
List<ExportContentVersionImpl> allContentVersions = new ArrayList<ExportContentVersionImpl>();
List<DigitalAsset> allDigitalAssets = new ArrayList<DigitalAsset>();
if(type.equals("Contents"))
{
List<Content> contents = ContentController.getContentController().getContentList(repositoryId, 0, 5000, db);
while(contents.size() > 0)
{
allContents.addAll(contents);
contents = ContentController.getContentController().getContentList(repositoryId, contents.get(contents.size()-1).getContentId(), 5000, db);
logger.info(".");
}
exportedEntities = allContents.size();
logger.info("Read all contents");
}
if(type.equals("ContentVersions"))
{
List<ExportContentVersionImpl> contentVersions = ContentVersionController.getContentVersionController().getContentVersionList(repositoryId, 0, 5000, onlyPublishedVersions, db);
while(contentVersions.size() > 0)
{
allContentVersions.addAll(contentVersions);
contentVersions = ContentVersionController.getContentVersionController().getContentVersionList(repositoryId, contentVersions.get(contentVersions.size()-1).getContentVersionId(), 5000, onlyPublishedVersions, db);
logger.info(".");
}
exportedEntities = allContentVersions.size();
logger.info("Read all content versions");
}
if(type.equals("SiteNodes"))
{
List<SiteNode> siteNodes = SiteNodeController.getController().getSiteNodeList(repositoryId, 0, 5000, db);
while(siteNodes.size() > 0)
{
allSiteNodes.addAll(siteNodes);
siteNodes = SiteNodeController.getController().getSiteNodeList(repositoryId, siteNodes.get(siteNodes.size()-1).getSiteNodeId(), 5000, db);
logger.info(".");
}
exportedEntities = allSiteNodes.size();
logger.info("Read all siteNodes");
}
if(type.equals("SiteNodeVersions"))
{
List<SiteNodeVersion> siteNodeVersions = SiteNodeVersionController.getController().getSiteNodeVersionList(repositoryId, 0, 5000, onlyPublishedVersions, db);
while(siteNodeVersions.size() > 0)
{
allSiteNodeVersions.addAll(siteNodeVersions);
siteNodeVersions = SiteNodeVersionController.getController().getSiteNodeVersionList(repositoryId, siteNodeVersions.get(siteNodeVersions.size()-1).getSiteNodeVersionId(), 5000, onlyPublishedVersions, db);
logger.info(".");
}
exportedEntities = allSiteNodeVersions.size();
}
if(type.equals("DigitalAssets"))
{
int assetCount = 0;
List<DigitalAssetVO> assets = DigitalAssetController.getController().dumpDigitalAssetList(repositoryId, 0, 50, assetMaxSize, onlyPublishedVersions, folderName);
while(assets.size() > 0)
{
assetCount += assets.size();
//allDigitalAssets.addAll(assets);
assets = DigitalAssetController.getController().dumpDigitalAssetList(repositoryId, assets.get(assets.size()-1).getDigitalAssetId(), 50, assetMaxSize, onlyPublishedVersions, folderName);
logger.info(".");
}
exportedEntities = assetCount;
}
if(!type.equals("DigitalAssets"))
{
InfoGlueExportImpl infoGlueExportImpl = new InfoGlueExportImpl();
String name = new VisualFormatter().replaceNonAscii(repository.getName(), '_');
String fileName = type + "_" + repository.getId() + ".xml";
/*
if(exportFileName != null && !exportFileName.equals(""))
fileName = exportFileName;
*/