Search in sources :

Example 6 with ImporterBootstrap

use of org.alfresco.repo.importer.ImporterBootstrap in project alfresco-repository by Alfresco.

the class MultiTAdminServiceImpl method createTenant.

@Override
public void createTenant(final String tenantDomainIn, final char[] tenantAdminRawPassword, String contentRootPath, final String dbUrl) {
    ParameterCheck.mandatory("tenantAdminRawPassword", tenantAdminRawPassword);
    final String tenantDomain = getTenantDomain(tenantDomainIn);
    // in case this is the 1st tenant
    AuthenticationUtil.setMtEnabled(true);
    long start = System.currentTimeMillis();
    if ((contentRootContainerPath != null) && (!contentRootContainerPath.isEmpty())) {
        String defaultContentRoot = null;
        if (!contentRootContainerPath.endsWith("/")) {
            defaultContentRoot = contentRootContainerPath + "/" + tenantDomain;
        } else {
            defaultContentRoot = contentRootContainerPath + tenantDomain;
        }
        if ((contentRootPath != null) && (!contentRootPath.isEmpty())) {
            logger.warn("Use default content root path: " + defaultContentRoot + " (ignoring: " + contentRootPath + ")");
        }
        contentRootPath = defaultContentRoot;
    }
    initTenant(tenantDomain, contentRootPath, dbUrl);
    if ((dbUrl != null) && (trds != null)) {
        try {
            // note: experimental - currently assumes a bootstrapped DB schema exists for this dbUrl !
            trds.addTenantDataSource(tenantDomain, dbUrl);
        } catch (SQLException se) {
            throw new AlfrescoRuntimeException("Failed to create tenant '" + tenantDomain + "' for dbUrl '" + dbUrl + "'", se);
        }
    }
    try {
        // note: runAs would cause auditable property "creator" to be "admin" instead of "System@xxx"
        AuthenticationUtil.pushAuthentication();
        AuthenticationUtil.setFullyAuthenticatedUser(getSystemUser(tenantDomain));
        TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>() {

            public Object doWork() {
                dictionaryComponent.init();
                if (isTenantDeployer(tenantFileContentStore)) {
                    TenantDeployer deployer = tenantDeployer(tenantFileContentStore);
                    deployer.init();
                }
                // callback
                RetryingTransactionCallback<Object> doImportCallback = new RetryingTransactionCallback<Object>() {

                    public Object execute() throws Throwable {
                        // create tenant-specific stores
                        ImporterBootstrap userImporterBootstrap = (ImporterBootstrap) ctx.getBean("userBootstrap-mt");
                        bootstrapUserTenantStore(userImporterBootstrap, tenantDomain, tenantAdminRawPassword);
                        ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap) ctx.getBean("systemBootstrap-mt");
                        bootstrapSystemTenantStore(systemImporterBootstrap, tenantDomain);
                        // deprecated
                        ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap) ctx.getBean("versionBootstrap-mt");
                        bootstrapVersionTenantStore(versionImporterBootstrap, tenantDomain);
                        ImporterBootstrap version2ImporterBootstrap = (ImporterBootstrap) ctx.getBean("version2Bootstrap-mt");
                        bootstrapVersionTenantStore(version2ImporterBootstrap, tenantDomain);
                        ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap) ctx.getBean("spacesArchiveBootstrap-mt");
                        bootstrapSpacesArchiveTenantStore(spacesArchiveImporterBootstrap, tenantDomain);
                        ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap) ctx.getBean("spacesBootstrap-mt");
                        bootstrapSpacesTenantStore(spacesImporterBootstrap, tenantDomain);
                        thumbnailRegistry.initThumbnailDefinitions();
                        // bootstrap workflows
                        for (WorkflowDeployer workflowDeployer : workflowDeployers) {
                            workflowDeployer.init();
                        }
                        // bootstrap modules (if any)
                        moduleService.startModules();
                        return null;
                    }
                };
                // if not default DB (ie. dbUrl != null) then run in new Spring managed txn (to ensure datasource is switched)
                transactionService.getRetryingTransactionHelper().doInTransaction(doImportCallback, transactionService.isReadOnly(), (dbUrl != null));
                return null;
            }
        }, tenantDomain);
    } finally {
        AuthenticationUtil.popAuthentication();
    }
    if (logger.isInfoEnabled()) {
        logger.info("Tenant created: " + tenantDomain + " in " + (System.currentTimeMillis() - start) + " ms");
    }
}
Also used : WorkflowDeployer(org.alfresco.repo.workflow.WorkflowDeployer) SQLException(java.sql.SQLException) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Example 7 with ImporterBootstrap

use of org.alfresco.repo.importer.ImporterBootstrap in project acs-community-packaging by Alfresco.

the class Application method getEmailTemplatesFolderName.

/**
 * Returns the Email Templates folder name
 *
 * @param context The spring context
 * @return The email folder name
 */
private static String getEmailTemplatesFolderName(WebApplicationContext context) {
    if (emailTemplatesFolderName == null) {
        ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP);
        Properties configuration = bootstrap.getConfiguration();
        emailTemplatesFolderName = configuration.getProperty("spaces.templates.email.childname");
    }
    return emailTemplatesFolderName;
}
Also used : Properties(java.util.Properties) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Example 8 with ImporterBootstrap

use of org.alfresco.repo.importer.ImporterBootstrap in project acs-community-packaging by Alfresco.

the class Application method getContentTemplatesFolderName.

/**
 * Returns the Content Templates folder name
 *
 * @param context The spring context
 * @return The templates folder name
 */
private static String getContentTemplatesFolderName(WebApplicationContext context) {
    if (contentTemplatesFolderName == null) {
        ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP);
        Properties configuration = bootstrap.getConfiguration();
        contentTemplatesFolderName = configuration.getProperty("spaces.templates.content.childname");
    }
    return contentTemplatesFolderName;
}
Also used : Properties(java.util.Properties) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Example 9 with ImporterBootstrap

use of org.alfresco.repo.importer.ImporterBootstrap in project acs-community-packaging by Alfresco.

the class Application method getNotifyEmailTemplatesFolderName.

/**
 * Returns the Notify Email Templates folder name
 *
 * @param context The spring context
 * @return The notify email folder name
 */
private static String getNotifyEmailTemplatesFolderName(WebApplicationContext context) {
    if (notifyEmailTemplatesFolderName == null) {
        ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP);
        Properties configuration = bootstrap.getConfiguration();
        notifyEmailTemplatesFolderName = configuration.getProperty("spaces.templates.email.notify.childname");
    }
    return notifyEmailTemplatesFolderName;
}
Also used : Properties(java.util.Properties) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Example 10 with ImporterBootstrap

use of org.alfresco.repo.importer.ImporterBootstrap in project acs-community-packaging by Alfresco.

the class Application method getScriptsFolderName.

/**
 * Returns the JavaScript scripts folder name
 *
 * @param context The spring context
 * @return The scripts folder name
 */
private static String getScriptsFolderName(WebApplicationContext context) {
    if (scriptsFolderName == null) {
        ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP);
        Properties configuration = bootstrap.getConfiguration();
        scriptsFolderName = configuration.getProperty("spaces.scripts.childname");
    }
    return scriptsFolderName;
}
Also used : Properties(java.util.Properties) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Aggregations

ImporterBootstrap (org.alfresco.repo.importer.ImporterBootstrap)20 Properties (java.util.Properties)18 ArrayList (java.util.ArrayList)7 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 SQLException (java.sql.SQLException)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 WorkflowDeployer (org.alfresco.repo.workflow.WorkflowDeployer)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1 Descriptor (org.alfresco.service.descriptor.Descriptor)1