use of org.alfresco.repo.tenant.TenantAdminService in project alfresco-repository by Alfresco.
the class FeedNotifierJob method execute.
/**
* Calls the feed notifier to do its work
*/
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap jobData = context.getJobDetail().getJobDataMap();
final FeedNotifier feedNotifier = (FeedNotifier) jobData.get(KEY_FEED_NOTIFIER);
final TenantAdminService tenantAdminService = (TenantAdminService) jobData.get(KEY_TENANT_ADMIN_SERVICE);
Long repeatInterval = null;
Trigger trigger = context.getTrigger();
if (trigger instanceof SimpleTrigger) {
repeatInterval = ((SimpleTrigger) trigger).getRepeatInterval();
}
final int repeatIntervalMins = new Long(repeatInterval == null ? 0L : repeatInterval / 1000 / 60).intValue();
AuthenticationUtil.runAs(new RunAsWork<Object>() {
public Object doWork() throws Exception {
feedNotifier.execute(repeatIntervalMins);
return null;
}
}, AuthenticationUtil.getSystemUserName());
if ((tenantAdminService != null) && tenantAdminService.isEnabled()) {
List<Tenant> tenants = tenantAdminService.getAllTenants();
for (Tenant tenant : tenants) {
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>() {
public Object doWork() throws Exception {
feedNotifier.execute(repeatIntervalMins);
return null;
}
}, tenant.getTenantDomain());
}
}
}
use of org.alfresco.repo.tenant.TenantAdminService in project alfresco-repository by Alfresco.
the class DownloadsCleanupJob method execute.
/*
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap jobData = context.getJobDetail().getJobDataMap();
// extract the services and max age to use
final DownloadService downloadService = (DownloadService) jobData.get(KEY_DOWNLOAD_SERVICE);
final TenantAdminService tenantAdminService = (TenantAdminService) jobData.get(KEY_TENANT_ADMIN_SERVICE);
final int maxAgeInMinutes = Integer.parseInt((String) jobData.get(KEY_MAX_AGE));
final int batchSize = Integer.parseInt((String) jobData.get(BATCH_SIZE));
final boolean cleanAllSysDownloadFolders = Boolean.parseBoolean((String) jobData.get(CLEAN_All_SYS_DOWNLOAD_FOLDERS));
final DateTime before = new DateTime().minusMinutes(maxAgeInMinutes);
AuthenticationUtil.runAs(new RunAsWork<Object>() {
public Object doWork() throws Exception {
downloadService.deleteDownloads(before.toDate(), batchSize, cleanAllSysDownloadFolders);
return null;
}
}, AuthenticationUtil.getSystemUserName());
if ((tenantAdminService != null) && tenantAdminService.isEnabled()) {
List<Tenant> tenants = tenantAdminService.getAllTenants();
for (Tenant tenant : tenants) {
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>() {
public Object doWork() throws Exception {
downloadService.deleteDownloads(before.toDate(), batchSize, cleanAllSysDownloadFolders);
return null;
}
}, tenant.getTenantDomain());
}
}
}
use of org.alfresco.repo.tenant.TenantAdminService in project alfresco-repository by Alfresco.
the class DictionaryModelTypeTest method before.
@Before
public void before() throws Exception {
TestTransaction.flagForCommit();
this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
this.contentService = (ContentService) this.applicationContext.getBean("contentService");
this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
this.actionService = (ActionService) this.applicationContext.getBean("actionService");
this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent");
// Authenticate as the admin user for dictionaryModelType
// "System" user should also be allowed to create models
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Create the store and get the root node
this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
this.rootNodeRef = this.nodeService.getRootNode(this.storeRef);
// Get the required services
this.dictionaryService = (DictionaryService) this.applicationContext.getBean("dictionaryService");
this.namespaceService = (NamespaceService) this.applicationContext.getBean("namespaceService");
this.cociService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");
this.dictionaryDAO = (DictionaryDAO) this.applicationContext.getBean("dictionaryDAO");
this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent");
TenantAdminService tenantAdminService = (TenantAdminService) this.applicationContext.getBean("tenantAdminService");
MessageService messageService = (MessageService) this.applicationContext.getBean("messageService");
TestTransaction.end();
TestTransaction.start();
TestTransaction.flagForCommit();
DictionaryRepositoryBootstrap bootstrap = new DictionaryRepositoryBootstrap();
bootstrap.setContentService(this.contentService);
bootstrap.setDictionaryDAO(this.dictionaryDAO);
bootstrap.setTransactionService(this.transactionService);
bootstrap.setTenantAdminService(tenantAdminService);
bootstrap.setNodeService(this.nodeService);
bootstrap.setNamespaceService(this.namespaceService);
bootstrap.setMessageService(messageService);
bootstrap.setPolicyComponent(policyComponent);
RepositoryLocation location = new RepositoryLocation();
location.setStoreProtocol(this.storeRef.getProtocol());
location.setStoreId(this.storeRef.getIdentifier());
location.setQueryLanguage(RepositoryLocation.LANGUAGE_PATH);
// NOTE: we are not setting the path for now .. in doing so we are searching the root node only
List<RepositoryLocation> locations = new ArrayList<RepositoryLocation>();
locations.add(location);
bootstrap.setRepositoryModelsLocations(locations);
// register with dictionary service
bootstrap.register();
TestTransaction.end();
TestTransaction.start();
}
use of org.alfresco.repo.tenant.TenantAdminService in project alfresco-repository by Alfresco.
the class AlfrescoTenant method before.
/**
* Create the tenant.
*/
@Override
protected void before() throws Throwable {
final ApplicationContext appCtx = getApplicationContext();
RetryingTransactionHelper transactionHelper = appCtx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
final TenantAdminService tenantAdminService = appCtx.getBean("tenantAdminService", TenantAdminService.class);
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
tenantAdminService.createTenant(tenantName, ADMIN_PASSWORD.toCharArray());
return null;
}
});
}
use of org.alfresco.repo.tenant.TenantAdminService in project alfresco-repository by Alfresco.
the class AlfrescoTenant method after.
/**
* Remove the tenant
*/
@Override
protected void after() {
final ApplicationContext appCtx = getApplicationContext();
RetryingTransactionHelper transactionHelper = appCtx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
final TenantAdminService tenantAdminService = appCtx.getBean("tenantAdminService", TenantAdminService.class);
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
tenantAdminService.deleteTenant(tenantName);
return null;
}
});
}
Aggregations