org.alfresco.service.cmr.workflow.WorkflowService Java Examples

The following examples show how to use org.alfresco.service.cmr.workflow.WorkflowService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskFormPersister.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public TaskFormPersister(ContentModelItemData<WorkflowTask> itemData,
            NamespaceService namespaceService,
            DictionaryService dictionaryService,
            WorkflowService workflowService,
            NodeService nodeService,
            AuthenticationService authenticationService,
            BehaviourFilter behaviourFilter, Log logger)
{
    super(itemData, namespaceService, dictionaryService, logger);
    WorkflowTask item = itemData.getItem();

    // make sure that the task is not already completed
    if (item.getState().equals(WorkflowTaskState.COMPLETED))
    {
        throw new AlfrescoRuntimeException("workflowtask.already.done.error");
    }

    // make sure the current user is able to edit the task
    if (!workflowService.isTaskEditable(item, authenticationService.getCurrentUserName()))
    {
        throw new AccessDeniedException("Failed to update task with id '" + item.getId() + "'.");
    }
    
    this.updater = new TaskUpdater(item.getId(), workflowService, nodeService, behaviourFilter);
}
 
Example #2
Source File: ScriptNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get active workflow instances this node belongs to
 * 
 * @return the active workflow instances this node belongs to
 */
public Scriptable getActiveWorkflows()
{
    if (this.activeWorkflows == null)
    {
        WorkflowService workflowService = this.services.getWorkflowService();
        
        List<WorkflowInstance> workflowInstances = workflowService.getWorkflowsForContent(this.nodeRef, true);
        Object[] jsWorkflowInstances = new Object[workflowInstances.size()];
        int index = 0;
        for (WorkflowInstance workflowInstance : workflowInstances)
        {
            jsWorkflowInstances[index++] = new JscriptWorkflowInstance(workflowInstance, this.services, this.scope);
        }
        this.activeWorkflows = Context.getCurrentContext().newArray(this.scope, jsWorkflowInstances);		
    }

    return this.activeWorkflows;
}
 
Example #3
Source File: JscriptWorkflowDefinition.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get active workflow instances of this workflow definition
 * 
 * @return the active workflow instances spawned from this workflow definition
 */
public synchronized Scriptable getActiveInstances()
{
	WorkflowService workflowService = this.serviceRegistry.getWorkflowService();
	
	List<WorkflowInstance> cmrWorkflowInstances = workflowService.getActiveWorkflows(this.id);
	ArrayList<Serializable> activeInstances = new ArrayList<Serializable>();
	for (WorkflowInstance cmrWorkflowInstance : cmrWorkflowInstances)
	{
		activeInstances.add(new JscriptWorkflowInstance(cmrWorkflowInstance, this.serviceRegistry, this.scope));
	}
	
	Scriptable activeInstancesScriptable =
		(Scriptable)getValueConverter().convertValueForScript(this.serviceRegistry, this.scope, null, activeInstances);
	
	return activeInstancesScriptable;
}
 
Example #4
Source File: JscriptWorkflowInstance.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get all paths for the specified workflow instance
 */
public Scriptable getPaths()
{
	WorkflowService workflowService = serviceRegistry.getWorkflowService();
	
	List<WorkflowPath> cmrPaths = workflowService.getWorkflowPaths(this.id);
	ArrayList<Serializable> paths = new ArrayList<Serializable>();
	for (WorkflowPath cmrPath : cmrPaths)
	{
		paths.add(new JscriptWorkflowPath(cmrPath, this.serviceRegistry, this.scope));
	}
	
	Scriptable pathsScriptable =
		(Scriptable)new ValueConverter().convertValueForScript(this.serviceRegistry, this.scope, null, paths);
	
	return pathsScriptable;
}
 
Example #5
Source File: JscriptWorkflowPath.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get all tasks associated with this workflow path
 * 
 * @return all the tasks associated with this workflow path instance
 */
public Scriptable getTasks()
{
	WorkflowService workflowService = serviceRegistry.getWorkflowService();
	
	List<WorkflowTask> cmrTasks = workflowService.getTasksForWorkflowPath(id);
	ArrayList<Serializable> tasks = new ArrayList<Serializable>();
	for (WorkflowTask cmrTask : cmrTasks)
	{
		tasks.add(new JscriptWorkflowTask(cmrTask, this.serviceRegistry, this.scope));
	}
	
	Scriptable tasksScriptable =
		(Scriptable)new ValueConverter().convertValueForScript(this.serviceRegistry, scope, null, tasks);
	
	return tasksScriptable;
}
 
Example #6
Source File: WorkflowManager.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get tasks assigned to the current user, filtered by workflow task state.
 * Only tasks having the specified state will be returned.
 * 
 * @param state  workflow task state to filter assigned tasks by
 * @return  the list of assigned tasks, filtered by state
 */
private Scriptable getAssignedTasksByState(WorkflowTaskState state)
{
    WorkflowService workflowService = services.getWorkflowService();
    String currentUser = services.getAuthenticationService().getCurrentUserName();
    List<WorkflowTask> cmrAssignedTasks = workflowService.getAssignedTasks(currentUser, state);
    ArrayList<Serializable> assignedTasks = new ArrayList<Serializable>();
    for (WorkflowTask cmrTask : cmrAssignedTasks)
    {
        assignedTasks.add(new JscriptWorkflowTask(cmrTask, services, getScope()));
    }
    return (Scriptable)new ValueConverter().convertValueForScript(services, getScope(), null, assignedTasks);
}
 
Example #7
Source File: ResetPasswordServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass
public static void initStaticData() throws Exception
{
    resetPasswordService = APP_CONTEXT_INIT.getApplicationContext().getBean("resetPasswordService", ResetPasswordServiceImpl.class);
    resetPasswordService.setSendEmailAsynchronously(false);
    resetPasswordService.setDefaultEmailSender(DEFAULT_SENDER);
    authenticationService = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationService", MutableAuthenticationService.class);
    transactionHelper = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    personService = APP_CONTEXT_INIT.getApplicationContext().getBean("personService", PersonService.class);
    globalProperties = APP_CONTEXT_INIT.getApplicationContext().getBean("global-properties", Properties.class);
    workflowService = APP_CONTEXT_INIT.getApplicationContext().getBean("WorkflowService", WorkflowService.class);
    emailUtil = new EmailUtil(APP_CONTEXT_INIT.getApplicationContext());
    emailUtil.reset();

    String userName = "jane.doe" + System.currentTimeMillis();
    testPerson = new TestPerson()
                .setUserName(userName)
                .setFirstName("Jane")
                .setLastName("doe")
                .setPassword("password")
                .setEmail(userName + "@example.com");

    transactionHelper.doInTransaction((RetryingTransactionCallback<Void>) () ->
    {
        createUser(testPerson);
        return null;
    });

}
 
Example #8
Source File: WorkflowFormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private WorkflowService makeWorkflowService()
{
    WorkflowService service = mock(WorkflowService.class);
    when(service.getDefinitionByName(WF_DEF_NAME)).thenReturn(definition);
    
    String instanceId = "foo$instanceId";
    newInstance = new WorkflowInstance(instanceId,
                definition, null, null, null,
                null, true, null, null);
    WorkflowTask startTask = new WorkflowTask("foo$taskId", null, null, null, null, null, null, null);
    String pathId = "foo$pathId";
    final WorkflowPath path = new WorkflowPath(pathId, newInstance, null, true);
    
    when(service.startWorkflow(eq(definition.getId()), anyMap()))
        .thenAnswer(new Answer<WorkflowPath>()
        {
            public WorkflowPath answer(InvocationOnMock invocation) throws Throwable
            {
                Object[] arguments = invocation.getArguments();
                actualProperties = (Map<QName, Serializable>) arguments[1];
                return path;
            }
        });
    when(service.getTasksForWorkflowPath(path.getId()))
        .thenReturn(Collections.singletonList(startTask));
    when(service.createPackage(null)).thenReturn(PCKG_NODE);
    return service;
}
 
Example #9
Source File: ActivitiInvitationServiceImplTests.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before() throws Exception
{
    super.before();
    this.workflowService = (WorkflowService) applicationContext.getBean("WorkflowService");
    
    // Enable Activiti
    workflowAdminService.setEnabledEngines(Arrays.asList(ActivitiConstants.ENGINE_ID));
}
 
Example #10
Source File: InvitationCleanupTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass public static void initStaticData() throws Exception
{
    INVITATION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("InvitationService", InvitationService.class);
    SITE_SERVICE       = APP_CONTEXT_INIT.getApplicationContext().getBean("SiteService", SiteService.class);
    TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    WORKFLOW_SERVICE   = APP_CONTEXT_INIT.getApplicationContext().getBean("WorkflowService", WorkflowService.class);
    NODE_ARCHIVE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeArchiveService", NodeArchiveService.class);
}
 
Example #11
Source File: WorkflowBuilder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowBuilder(WorkflowDefinition definition,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter)
{
    this.workflowService = workflowService;
    this.packageMgr = new PackageManager(workflowService, nodeService, behaviourFilter, null);
    this.definition = definition;
}
 
Example #12
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before()
{
    this.actionService = (ActionService)ctx.getBean("actionService");
    this.ruleService = (RuleService)ctx.getBean("ruleService");
	this.fileFolderService = (FileFolderService)ctx.getBean("FileFolderService");
	this.transactionService = (TransactionService)ctx.getBean("transactionService");
	this.nodeService = (NodeService)ctx.getBean("NodeService");
	this.contentService = (ContentService)ctx.getBean("ContentService");
    this.versionService = (VersionService) ctx.getBean("versionService");
    this.lockService = (LockService) ctx.getBean("lockService");
    this.taggingService = (TaggingService) ctx.getBean("TaggingService");
    this.namespaceService = (NamespaceService) ctx.getBean("namespaceService");
    this.repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
	this.factory = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory");
    this.versionService = (VersionService) ctx.getBean("versionService");
	this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
    this.nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");
    this.authorityService = (AuthorityService)ctx.getBean("AuthorityService");
    this.auditSubsystem = (AuditModelRegistryImpl) ctx.getBean("Audit");
    this.permissionService = (PermissionService) ctx.getBean("permissionService");
	this.dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO");
	this.cmisDictionaryService = (CMISDictionaryService)ctx.getBean("OpenCMISDictionaryService1.1");
    this.auditDAO = (AuditDAO) ctx.getBean("auditDAO");
    this.nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
    this.dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    this.workflowService = (WorkflowService) ctx.getBean("WorkflowService");
    this.workflowAdminService = (WorkflowAdminService) ctx.getBean("workflowAdminService");
    this.authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext");
    this.tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService");
    this.tenantService = (TenantService) ctx.getBean("tenantService");
    this.searchService = (SearchService) ctx.getBean("SearchService");
    this.auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");

    this.globalProperties = (java.util.Properties) ctx.getBean("global-properties");
    this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
}
 
Example #13
Source File: PackageManager.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PackageManager(WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter,
            Log logger)
{
    this.workflowService = workflowService;
    this.nodeService = nodeService;
    this.behaviourFilter =behaviourFilter;
    this.logger = logger ==null ? LOGGER : logger;
}
 
Example #14
Source File: JscriptWorkflowDefinition.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Start workflow instance from workflow definition
 * 
 * @param workflowPackage workflow package node to 'attach' to the new workflow
 * 		instance
 * @param properties Associative array of properties used to populate the 
 * 		start task properties
 * @return the initial workflow path
 */
@SuppressWarnings("unchecked")
public JscriptWorkflowPath startWorkflow(ScriptNode workflowPackage,
	Object properties)
{
	WorkflowService workflowService = this.serviceRegistry.getWorkflowService();
	
	// if properties object is a scriptable object, then extract property name/value pairs
	// into property Map<QName, Serializable>, otherwise leave property map as null
	Map<QName, Serializable> workflowParameters = null;
       if (properties instanceof ScriptableObject)
       {
           ScriptableObject scriptableProps = (ScriptableObject)properties;
           workflowParameters = new HashMap<QName, Serializable>(scriptableProps.getIds().length);
           extractScriptablePropertiesToMap(scriptableProps, workflowParameters);
       }
	
	// attach given workflow package node if it is not null
       if (workflowPackage != null)
       {
           if (workflowParameters == null)
           {
               workflowParameters = new HashMap<QName, Serializable>(1);
           }
           workflowParameters.put(WorkflowModel.ASSOC_PACKAGE, getValueConverter().convertValueForRepo(workflowPackage));
       }        

       // provide a default context, if one is not specified
       Serializable context = workflowParameters.get(WorkflowModel.PROP_CONTEXT);
       if (context == null)
       {
           workflowParameters.put(WorkflowModel.PROP_CONTEXT, workflowPackage.getNodeRef());
       }

	WorkflowPath cmrWorkflowPath = workflowService.startWorkflow(this.id, workflowParameters);
	
	return new JscriptWorkflowPath(cmrWorkflowPath, this.serviceRegistry, this.scope);
}
 
Example #15
Source File: TaskUpdater.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TaskUpdater(String taskId,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter)
{
    this.taskId = taskId;
    this.workflowService = workflowService;
    this.packageMgr = new PackageManager(workflowService, nodeService, behaviourFilter, LOGGER);
}
 
Example #16
Source File: WorkflowModelBuilder.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowModelBuilder(NamespaceService namespaceService, NodeService nodeService, 
            AuthenticationService authenticationService, PersonService personService, 
            WorkflowService workflowService, DictionaryService dictionaryService)
{
    this.nodeService = nodeService;
    this.personService = personService;
    this.workflowService = workflowService;
    this.authenticationService = authenticationService;
    this.qNameConverter = new WorkflowQNameConverter(namespaceService);
    this.dictionaryService = dictionaryService;
}
 
Example #17
Source File: WorkflowModelBuilderTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    namespaceService = new NamespaceServiceMemoryImpl();
    namespaceService.registerNamespace("test", URI);
    namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
    namespaceService.registerNamespace(NamespaceService.BPM_MODEL_PREFIX, NamespaceService.BPM_MODEL_1_0_URI);
    
    personService = mock(PersonService.class);
    when(personService.getPerson(userName)).thenReturn(person);
    when(personService.personExists(userName)).thenReturn(true);
    
    nodeService = mock(NodeService.class);
    Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
    personProps.put(ContentModel.PROP_USERNAME, userName);
    personProps.put(ContentModel.PROP_FIRSTNAME, firstName);
    personProps.put(ContentModel.PROP_LASTNAME, lastName);
    when(nodeService.getProperties(person)).thenReturn(personProps);
    when(nodeService.getProperty(person, ContentModel.PROP_USERNAME)).thenReturn(userName);
    when(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)).thenReturn(firstName);
    when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName);
    
    workflowService = mock(WorkflowService.class);
    dictionaryService = mock(DictionaryService.class);
    authenticationService = mock(AuthenticationService.class);
    
    builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService);
}
 
Example #18
Source File: TaskFormProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TaskFormProcessor(WorkflowService workflowService, NamespaceService namespaceService,
        DictionaryService dictionaryService, AuthenticationService authenticationService,
        PersonService personService, FieldProcessorRegistry fieldProcessorRegistry)
{
    this.workflowService = workflowService;
    this.namespaceService = namespaceService;
    this.dictionaryService = dictionaryService;
    this.authenticationService = authenticationService;
    this.personService = personService;
    this.fieldProcessorRegistry = fieldProcessorRegistry;
}
 
Example #19
Source File: WorkflowFormPersister.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowFormPersister(ContentModelItemData<?> itemData,
            NamespaceService namespaceService,
            DictionaryService dictionaryService,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter, Log logger)
{
    super(itemData, namespaceService, dictionaryService, logger);
    WorkflowDefinition definition = (WorkflowDefinition) itemData.getItem();
    this.builder = new WorkflowBuilder(definition, workflowService, nodeService, behaviourFilter);
}
 
Example #20
Source File: ScriptCounterSignService.java    From CounterSign with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Gets all of the recorded signature workflow events for this node, both for
 * active and completed workflows
 * 
 * @param nodeRef
 */
public List<Map<String, Object>> getSignatureWorkflowHistory(String nodeRef)
{
	NodeService ns = serviceRegistry.getNodeService();
	WorkflowService wfs = serviceRegistry.getWorkflowService();
	List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
	NodeRef node = new NodeRef(nodeRef);
	WorkflowModelBuilder modelBuilder = 
			new WorkflowModelBuilder(serviceRegistry.getNamespaceService(), 
									 serviceRegistry.getNodeService(), 
									 serviceRegistry.getAuthenticationService(), 
									 serviceRegistry.getPersonService(),
									 serviceRegistry.getWorkflowService(), 
									 serviceRegistry.getDictionaryService());
	if(ns.exists(node))
	{
		List<WorkflowInstance> active = wfs.getWorkflowsForContent(node, true);
		List<WorkflowInstance> inactive = wfs.getWorkflowsForContent(node, false);
		
		// merge the lists
		ArrayList<WorkflowInstance> all = new ArrayList<WorkflowInstance>(active.size() + inactive.size());
		all.addAll(active);
		all.addAll(inactive);
		
		// we only need instances of the known CounterSign workflow types
		for(WorkflowInstance instance : all)
		{
			// if the instance definition name is in the list, get its tasks
			// and add them to the task list
			if(counterSignWorkflowIds.contains(instance.getDefinition().getName()))
			{
				results.add(modelBuilder.buildDetailed(instance, true));
			}
		}
	}
	else
	{
		throw new AlfrescoRuntimeException("Node " + nodeRef + " does not exist");
	}

	return results;
}
 
Example #21
Source File: AbstractWorkflowWebscript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setWorkflowService(WorkflowService workflowService)
{
    this.workflowService = workflowService;
}
 
Example #22
Source File: WorkflowInstanceDiagramGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setWorkflowService(WorkflowService workflowService)
{
    this.workflowService = workflowService;
}
 
Example #23
Source File: AbstractWorkflowRestApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();

    namespaceService = (NamespaceService) appContext.getBean("NamespaceService");
    workflowService = (WorkflowService) appContext.getBean("WorkflowService");
    MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService) appContext.getBean("PersonService");
    SearchService searchService = (SearchService) appContext.getBean("SearchService");
    FileFolderService fileFolderService = (FileFolderService) appContext.getBean("FileFolderService");
    nodeService = (NodeService) appContext.getBean("NodeService");
    
    // for the purposes of the tests make sure workflow engine is enabled/visible.
    WorkflowAdminServiceImpl workflowAdminService = (WorkflowAdminServiceImpl) appContext.getBean("workflowAdminService");
    this.wfTestHelper = new WorkflowTestHelper(workflowAdminService, getEngine(), true);
    
    AuthorityService authorityService = (AuthorityService) appContext.getBean("AuthorityService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);
    groupManager = new TestGroupManager(authorityService);

    authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
    dictionaryService = (DictionaryService) appContext.getBean("dictionaryService");

    personManager.createPerson(USER1);
    personManager.createPerson(USER2);
    personManager.createPerson(USER3);

    authenticationComponent.setSystemUserAsCurrentUser();

    groupManager.addUserToGroup(GROUP, USER2);

    packageRef = workflowService.createPackage(null);

    NodeRef companyHome = searchService.selectNodes(nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), COMPANY_HOME, null, namespaceService, false).get(0);

    contentNodeRef = fileFolderService.create(companyHome, TEST_CONTENT + System.currentTimeMillis(), ContentModel.TYPE_CONTENT).getNodeRef();

    authenticationComponent.clearCurrentSecurityContext();
}
 
Example #24
Source File: MockedTestServiceRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public WorkflowService getWorkflowService()
{
    // A mock response
    return null;
}
 
Example #25
Source File: FormServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Before
public void before() throws Exception
{
    super.before();
    
    // Get the required services
    this.formService = (FormService)this.applicationContext.getBean("FormService");
    this.namespaceService = (NamespaceService)this.applicationContext.getBean("NamespaceService");
    this.scriptService = (ScriptService)this.applicationContext.getBean("ScriptService");
    PersonService personService = (PersonService)this.applicationContext.getBean("PersonService");
    this.contentService = (ContentService)this.applicationContext.getBean("ContentService");
    this.workflowService = (WorkflowService)this.applicationContext.getBean("WorkflowService");
    
    MutableAuthenticationService mutableAuthenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
    this.personManager = new TestPersonManager(mutableAuthenticationService, personService, nodeService);

    // create users
    personManager.createPerson(USER_ONE);
    personManager.createPerson(USER_TWO);
    
    // Do the tests as userOne
    personManager.setUser(USER_ONE);
    
    String guid = GUID.generate();
    
    NodeRef rootNode = this.nodeService.getRootNode(
                new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
    
    Map<QName, Serializable> folderProps = new HashMap<QName, Serializable>(1);
    this.folderName = "testFolder" + guid;
    folderProps.put(ContentModel.PROP_NAME, this.folderName);
    this.folder = this.nodeService.createNode(
            rootNode, 
            ContentModel.ASSOC_CHILDREN, 
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testFolder" + guid),
            ContentModel.TYPE_FOLDER,
            folderProps).getChildRef();
    
    // Create a node
    Map<QName, Serializable> docProps = new HashMap<QName, Serializable>(1);
    this.documentName = "testDocument" + guid + ".txt";
    docProps.put(ContentModel.PROP_NAME, this.documentName);
    this.document = this.nodeService.createNode(
            this.folder, 
            ContentModel.ASSOC_CONTAINS, 
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testDocument" + guid + ".txt"), 
            ContentModel.TYPE_CONTENT,
            docProps).getChildRef();    
   
    // create a node to use as target of association
    docProps.put(ContentModel.PROP_NAME, "associatedDocument" + guid + ".txt");
    this.associatedDoc = this.nodeService.createNode(
                this.folder, 
                ContentModel.ASSOC_CONTAINS, 
                QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "associatedDocument" + guid + ".txt"), 
                ContentModel.TYPE_CONTENT,
                docProps).getChildRef();
    
    // create a node to use as a 2nd child node of the folder
    docProps.put(ContentModel.PROP_NAME, "childDocument" + guid + ".txt");
    this.childDoc = this.nodeService.createNode(
                this.folder, 
                ContentModel.ASSOC_CONTAINS, 
                QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "childDocument" + guid + ".txt"), 
                ContentModel.TYPE_CONTENT,
                docProps).getChildRef();
    
    // add some content to the nodes
    ContentWriter writer = this.contentService.getWriter(this.document, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(VALUE_MIMETYPE);
    writer.setEncoding(VALUE_ENCODING);
    writer.putContent(VALUE_CONTENT);
    
    ContentWriter writer2 = this.contentService.getWriter(this.associatedDoc, ContentModel.PROP_CONTENT, true);
    writer2.setMimetype(VALUE_MIMETYPE);
    writer2.setEncoding(VALUE_ENCODING);
    writer2.putContent(VALUE_ASSOC_CONTENT);
    
    // add standard titled aspect
    Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>(2);
    aspectProps.put(ContentModel.PROP_TITLE, VALUE_TITLE);
    aspectProps.put(ContentModel.PROP_DESCRIPTION, VALUE_DESCRIPTION);
    this.nodeService.addAspect(this.document, ContentModel.ASPECT_TITLED, aspectProps);
    
    // add emailed aspect (has multiple value field)
    aspectProps = new HashMap<QName, Serializable>(5);
    aspectProps.put(ContentModel.PROP_ORIGINATOR, VALUE_ORIGINATOR);
    aspectProps.put(ContentModel.PROP_ADDRESSEE, VALUE_ADDRESSEE);
    List<String> addressees = new ArrayList<String>(2);
    addressees.add(VALUE_ADDRESSEES1);
    addressees.add(VALUE_ADDRESSEES2);
    aspectProps.put(ContentModel.PROP_ADDRESSEES, (Serializable)addressees);
    aspectProps.put(ContentModel.PROP_SUBJECT, VALUE_SUBJECT);
    aspectProps.put(ContentModel.PROP_SENTDATE, VALUE_SENT_DATE);
    this.nodeService.addAspect(this.document, ContentModel.ASPECT_EMAILED, aspectProps);
    
    // add referencing aspect (has association)
    aspectProps.clear();
    this.nodeService.addAspect(document, ContentModel.ASPECT_REFERENCING, aspectProps);
    this.nodeService.createAssociation(this.document, this.associatedDoc, ContentModel.ASSOC_REFERENCES);
}
 
Example #26
Source File: ModelValidatorImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setWorkflowService(WorkflowService workflowService)
{
    this.workflowService = workflowService;
}
 
Example #27
Source File: Workflow.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private WorkflowService getWorkflowService()
{
    return this.services.getWorkflowService();
}
 
Example #28
Source File: MultiTAdminServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setWorkflowService(WorkflowService workflowService)
{
    this.workflowService = workflowService;
}
 
Example #29
Source File: InvitationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return the workflow service
 */
public WorkflowService getWorkflowService()
{
    return workflowService;
}
 
Example #30
Source File: StartWorkflowActionExecuter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param workflowService WorkflowService
 */
public void setWorkflowService(WorkflowService workflowService) 
{
    this.workflowService = workflowService;
}