Search in sources :

Example 1 with WorkflowAdminService

use of org.alfresco.service.cmr.workflow.WorkflowAdminService in project alfresco-repository by Alfresco.

the class ConfigurationDataCollectorTest method setUp.

@Before
public void setUp() {
    smartFoldersBundle = mock(SpringExtensionBundle.class);
    mockDescriptorDAO = mock(DescriptorDAO.class);
    mockServerDescriptorDAO = mock(DescriptorDAO.class);
    mockCollectorService = mock(HBDataCollectorService.class);
    mockScheduler = mock(HeartBeatJobScheduler.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getId()).thenReturn("mock_id");
    when(mockServerDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    BasicDataSource mockBasicDataSource = mock(BasicDataSource.class);
    RepoUsageComponent mockRepoUsageComponent = mock(RepoUsageComponent.class);
    ServerModeProvider mockServerModeProvider = mock(ServerModeProvider.class);
    when(mockServerModeProvider.getServerMode()).thenReturn(SERVER_MODE);
    ChildApplicationContextFactory mockFileServerSubsystem = mock(ChildApplicationContextFactory.class);
    WebDavService mockWebDavService = mock(WebDavService.class);
    ThumbnailService mockThumbnailService = mock(ThumbnailService.class);
    ChildApplicationContextFactory mockActivitiesFeedSubsystem = mock(ChildApplicationContextFactory.class);
    WorkflowAdminService mockWorkflowAdminService = mock(WorkflowAdminService.class);
    ChildApplicationContextFactory mockInboundSMTPSubsystem = mock(ChildApplicationContextFactory.class);
    ChildApplicationContextFactory mockImapSubsystem = mock(ChildApplicationContextFactory.class);
    ChildApplicationContextFactory mockReplication = mock(ChildApplicationContextFactory.class);
    // mock modules and module service
    ModuleService mockModuleService = mock(ModuleService.class);
    ModuleDetails mockInstalledModule1 = mock(ModuleDetails.class);
    when(mockInstalledModule1.getId()).thenReturn(INSTALLED_MODULE_ID_1);
    when(mockInstalledModule1.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_1);
    ModuleDetails mockInstalledModule2 = mock(ModuleDetails.class);
    when(mockInstalledModule2.getId()).thenReturn(INSTALLED_MODULE_ID_2);
    when(mockInstalledModule2.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_2);
    ModuleDetails mockMissingModule = mock(ModuleDetails.class);
    when(mockMissingModule.getId()).thenReturn(MISSING_MODULE_ID_1);
    when(mockMissingModule.getModuleVersionNumber()).thenReturn(MISSING_MODULE_VERSION_1);
    when(mockModuleService.getAllModules()).thenReturn(Arrays.asList(mockInstalledModule1, mockInstalledModule2));
    when(mockModuleService.getMissingModules()).thenReturn(Arrays.asList(mockMissingModule));
    // mock audit applications and audit service
    AuditService mockAuditService = mock(AuditService.class);
    AuditService.AuditApplication mockAuditApp = mock(AuditService.AuditApplication.class);
    when(mockAuditApp.isEnabled()).thenReturn(AUDIT_APP_ENABLED);
    Map<String, AuditService.AuditApplication> auditApps = new HashMap<>();
    auditApps.put(AUDIT_APP_NAME, mockAuditApp);
    TransactionService mockTransactionService = mock(TransactionService.class);
    RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
    // Mock transaction service calls
    when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(// First call made by the collector to get the server readOnly value via transformation service
    true).thenReturn(// Second call to get the audit applications
    auditApps);
    when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
    // mock authentication chain
    DefaultChildApplicationContextManager mockAuthenticationSubsystem = mock(DefaultChildApplicationContextManager.class);
    configurationCollector = new ConfigurationDataCollector("acs.repository.configuration", "1.0", "0 0 0 ? * SUN", mockScheduler);
    configurationCollector.setHbDataCollectorService(mockCollectorService);
    configurationCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
    configurationCollector.setSmartFoldersBundle(smartFoldersBundle);
    configurationCollector.setDataSource(mockBasicDataSource);
    configurationCollector.setTransactionService(mockTransactionService);
    configurationCollector.setRepoUsageComponent(mockRepoUsageComponent);
    configurationCollector.setServerModeProvider(mockServerModeProvider);
    configurationCollector.setFileServersSubsystem(mockFileServerSubsystem);
    configurationCollector.setWebdavService(mockWebDavService);
    configurationCollector.setThumbnailService(mockThumbnailService);
    configurationCollector.setActivitiesFeedSubsystem(mockActivitiesFeedSubsystem);
    configurationCollector.setWorkflowAdminService(mockWorkflowAdminService);
    configurationCollector.setInboundSMTPSubsystem(mockInboundSMTPSubsystem);
    configurationCollector.setImapSubsystem(mockImapSubsystem);
    configurationCollector.setReplicationSubsystem(mockReplication);
    configurationCollector.setModuleService(mockModuleService);
    configurationCollector.setAuditService(mockAuditService);
    configurationCollector.setAuthenticationSubsystem(mockAuthenticationSubsystem);
    collectedData = configurationCollector.collectData();
}
Also used : ModuleService(org.alfresco.service.cmr.module.ModuleService) ThumbnailService(org.alfresco.service.cmr.thumbnail.ThumbnailService) TransactionService(org.alfresco.service.transaction.TransactionService) HashMap(java.util.HashMap) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) DefaultChildApplicationContextManager(org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager) SpringExtensionBundle(org.alfresco.traitextender.SpringExtensionBundle) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) ChildApplicationContextFactory(org.alfresco.repo.management.subsystems.ChildApplicationContextFactory) RepoUsageComponent(org.alfresco.repo.usage.RepoUsageComponent) WebDavService(org.alfresco.service.cmr.webdav.WebDavService) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) WorkflowAdminService(org.alfresco.service.cmr.workflow.WorkflowAdminService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) AuditService(org.alfresco.service.cmr.audit.AuditService) ServerModeProvider(org.alfresco.repo.mode.ServerModeProvider) Before(org.junit.Before)

Example 2 with WorkflowAdminService

use of org.alfresco.service.cmr.workflow.WorkflowAdminService in project alfresco-repository by Alfresco.

the class GenericWorkflowPatch method applyInternal.

@Override
protected String applyInternal() throws Exception {
    WorkflowDeployer deployer = (WorkflowDeployer) applicationContext.getBean("workflowPatchDeployer");
    WorkflowAdminService workflowAdminService = (WorkflowAdminService) applicationContext.getBean("workflowAdminService");
    if (workflowDefinitions != null) {
        for (Properties props : workflowDefinitions) {
            props.put(WorkflowDeployer.REDEPLOY, "true");
        }
        deployer.setWorkflowDefinitions(workflowDefinitions);
        deployer.init();
    }
    int undeployed = 0;
    StringBuilder errorMessages = new StringBuilder();
    if (undeployWorkflowNames != null) {
        List<String> undeployableWorkflows = new ArrayList<String>(undeployWorkflowNames);
        for (String workflowName : undeployWorkflowNames) {
            String engineId = BPMEngineRegistry.getEngineId(workflowName);
            if (workflowAdminService.isEngineEnabled(engineId)) {
                undeployableWorkflows.add(workflowName);
            } else {
                errorMessages.append(I18NUtil.getMessage(MSG_ERROR_ENGINE_DEACTIVATED, workflowName, engineId));
            }
        }
        undeployed = deployer.undeploy(undeployableWorkflows);
    }
    // done
    StringBuilder msg = new StringBuilder();
    if (workflowDefinitions != null) {
        msg.append(I18NUtil.getMessage(MSG_DEPLOYED, workflowDefinitions.size()));
    }
    if (undeployWorkflowNames != null) {
        if (msg.length() > 0) {
            msg.append(' ');
        }
        msg.append(I18NUtil.getMessage(MSG_UNDEPLOYED, undeployed));
    }
    if (errorMessages.length() > 0) {
        msg.append(errorMessages);
    }
    return msg.toString();
}
Also used : WorkflowDeployer(org.alfresco.repo.workflow.WorkflowDeployer) WorkflowAdminService(org.alfresco.service.cmr.workflow.WorkflowAdminService) ArrayList(java.util.ArrayList) Properties(java.util.Properties)

Aggregations

WorkflowAdminService (org.alfresco.service.cmr.workflow.WorkflowAdminService)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 HeartBeatJobScheduler (org.alfresco.heartbeat.jobs.HeartBeatJobScheduler)1 DescriptorDAO (org.alfresco.repo.descriptor.DescriptorDAO)1 ChildApplicationContextFactory (org.alfresco.repo.management.subsystems.ChildApplicationContextFactory)1 DefaultChildApplicationContextManager (org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager)1 ServerModeProvider (org.alfresco.repo.mode.ServerModeProvider)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 RepoUsageComponent (org.alfresco.repo.usage.RepoUsageComponent)1 WorkflowDeployer (org.alfresco.repo.workflow.WorkflowDeployer)1 AuditService (org.alfresco.service.cmr.audit.AuditService)1 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)1 ModuleService (org.alfresco.service.cmr.module.ModuleService)1 HBDataCollectorService (org.alfresco.service.cmr.repository.HBDataCollectorService)1 ThumbnailService (org.alfresco.service.cmr.thumbnail.ThumbnailService)1 WebDavService (org.alfresco.service.cmr.webdav.WebDavService)1 Descriptor (org.alfresco.service.descriptor.Descriptor)1 TransactionService (org.alfresco.service.transaction.TransactionService)1