use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.
the class SiteLoadPatch method applyInternalImpl.
/**
* Load the site in.<br/>
* Site will be loaded as admin user.
*/
private String applyInternalImpl() throws Exception {
if (descriptorService != null) {
// if the descriptor service is wired up only load the site at install time (and not on upgrade)
Descriptor installed = descriptorService.getInstalledRepositoryDescriptor();
Descriptor live = descriptorService.getServerDescriptor();
if (!installed.getVersion().equals(live.getVersion())) {
return I18NUtil.getMessage(MSG_SITE_NOT_CREATED, siteName);
}
}
if (bootstrapViews == null || bootstrapViews.size() == 0) {
if (logger.isDebugEnabled()) {
logger.debug("No Bootstraps given to import from - bootstrap import ignored");
}
return I18NUtil.getMessage(MSG_NO_BOOTSTRAP_VIEWS_GIVEN, siteName);
}
// (Run now as we need DB + Security Context)
if (siteService.getSite(siteName) != null) {
if (logger.isDebugEnabled()) {
logger.debug("Site " + siteName + " already exists - bootstrap import ignored");
}
return I18NUtil.getMessage(MSG_SITE_ALREADY_EXISTS, siteName);
}
// If we get here, we're good to go!
if (logger.isDebugEnabled()) {
logger.debug("Performing bootstrap of site " + siteName);
}
// Create the site as the admin user
SiteInfo site = siteService.createSite(siteName, siteName, siteName, null, SiteVisibility.PUBLIC);
// At this point we can go back to being the system
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
// Setup the Importer Bootstrap Beans
for (ImporterBootstrap bootstrap : new ImporterBootstrap[] { spacesBootstrap, usersBootstrap }) {
bootstrap.setAllowWrite(true);
bootstrap.setUseExistingStore(true);
bootstrap.setUuidBinding(UUID_BINDING.REPLACE_EXISTING);
}
// the defaults where they weren't
for (String type : DEFAULT_PATHS.keySet()) {
Properties props = bootstrapViews.get(type);
if (props != null && DEFAULT_PATHS.get(type) != null) {
if (!props.containsKey("path")) {
props.setProperty("path", DEFAULT_PATHS.get(type));
}
}
}
// Load any users requested
if (bootstrapViews.containsKey(PROPERTIES_USERS)) {
List<Properties> views = new ArrayList<Properties>(1);
views.add(bootstrapViews.get(PROPERTIES_USERS));
usersBootstrap.setBootstrapViews(views);
usersBootstrap.bootstrap();
}
// Load any people requested
if (bootstrapViews.containsKey(PROPERTIES_PEOPLE)) {
List<Properties> views = new ArrayList<Properties>(1);
views.add(bootstrapViews.get(PROPERTIES_PEOPLE));
spacesBootstrap.setBootstrapViews(views);
spacesBootstrap.bootstrap();
}
// Put people into groups
if (bootstrapViews.containsKey(PROPERTIES_GROUPS)) {
try {
doGroupImport(bootstrapViews.get(PROPERTIES_GROUPS).getProperty("location"));
} catch (Throwable t) {
throw new AlfrescoRuntimeException("Bootstrap failed", t);
}
}
// Load the Main (ACP) Contents
if (bootstrapViews.containsKey(PROPERTIES_CONTENTS)) {
// Disable the behaviour which prevents site deletion.
behaviourFilter.disableBehaviour(site.getNodeRef(), ContentModel.ASPECT_UNDELETABLE);
try {
// Clear up the stub content that createSite gave us, first
// apply the temporary aspect though to prevent the node from
// being archived
nodeService.addAspect(site.getNodeRef(), ContentModel.ASPECT_TEMPORARY, null);
nodeService.deleteNode(site.getNodeRef());
} finally {
behaviourFilter.enableBehaviour(site.getNodeRef(), ContentModel.ASPECT_UNDELETABLE);
}
// Now load in the real content from the ACP
List<Properties> views = new ArrayList<Properties>(1);
views.add(bootstrapViews.get(PROPERTIES_CONTENTS));
spacesBootstrap.setBootstrapViews(views);
spacesBootstrap.bootstrap();
}
return I18NUtil.getMessage(MSG_SITE_CREATED, siteName);
}
use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.
the class MultiTAdminServiceImpl method importBootstrapSystemTenantStore.
private void importBootstrapSystemTenantStore(String tenantDomain, File directorySource) {
// Import Bootstrap (restore) Tenant-Specific Version Store
Properties bootstrapView = new Properties();
bootstrapView.put("path", "/");
bootstrapView.put("location", directorySource.getPath() + "/" + tenantDomain + "_system.acp");
List<Properties> bootstrapViews = new ArrayList<Properties>(1);
bootstrapViews.add(bootstrapView);
ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap) ctx.getBean("systemBootstrap");
systemImporterBootstrap.setBootstrapViews(bootstrapViews);
bootstrapSystemTenantStore(systemImporterBootstrap, tenantDomain);
}
use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.
the class MultiTAdminServiceImpl method importBootstrapVersionTenantStore.
private void importBootstrapVersionTenantStore(String tenantDomain, File directorySource) {
// Import Bootstrap (restore) Tenant-Specific Version Store
Properties bootstrapView = new Properties();
bootstrapView.put("path", "/");
bootstrapView.put("location", directorySource.getPath() + "/" + tenantDomain + "_versions2.acp");
List<Properties> bootstrapViews = new ArrayList<Properties>(1);
bootstrapViews.add(bootstrapView);
ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap) ctx.getBean("versionBootstrap");
versionImporterBootstrap.setBootstrapViews(bootstrapViews);
bootstrapVersionTenantStore(versionImporterBootstrap, tenantDomain);
}
use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.
the class MultiTAdminServiceImpl method importBootstrapSpacesModelsTenantStore.
private void importBootstrapSpacesModelsTenantStore(String tenantDomain, File directorySource) {
// Import Bootstrap (restore) Tenant-Specific Spaces Store
Properties bootstrapView = new Properties();
bootstrapView.put("path", "/");
bootstrapView.put("location", directorySource.getPath() + "/" + tenantDomain + "_models.acp");
List<Properties> bootstrapViews = new ArrayList<Properties>(1);
bootstrapViews.add(bootstrapView);
ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap) ctx.getBean("spacesBootstrap");
spacesImporterBootstrap.setBootstrapViews(bootstrapViews);
bootstrapSpacesTenantStore(spacesImporterBootstrap, tenantDomain);
}
use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.
the class MultiTAdminServiceImpl method importBootstrapSpacesArchiveTenantStore.
private void importBootstrapSpacesArchiveTenantStore(String tenantDomain, File directorySource) {
// Import Bootstrap (restore) Tenant-Specific Spaces Archive Store
Properties bootstrapView = new Properties();
bootstrapView.put("path", "/");
bootstrapView.put("location", directorySource.getPath() + "/" + tenantDomain + "_spaces_archive.acp");
List<Properties> bootstrapViews = new ArrayList<Properties>(1);
bootstrapViews.add(bootstrapView);
ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap) ctx.getBean("spacesArchiveBootstrap");
spacesArchiveImporterBootstrap.setBootstrapViews(bootstrapViews);
bootstrapSpacesArchiveTenantStore(spacesArchiveImporterBootstrap, tenantDomain);
}
Aggregations