Search in sources :

Example 1 with GetProcessDefinitionsPayload

use of org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload in project Activiti by Activiti.

the class ProcessRuntimeImpl method processDefinitions.

@Override
public Page<ProcessDefinition> processDefinitions(Pageable pageable, GetProcessDefinitionsPayload getProcessDefinitionsPayload) {
    if (getProcessDefinitionsPayload == null) {
        throw new IllegalStateException("payload cannot be null");
    }
    GetProcessDefinitionsPayload securityKeysInPayload = securityPoliciesManager.restrictProcessDefQuery(SecurityPolicyAccess.READ);
    // else ignore and use the user provided ones.
    if (!securityKeysInPayload.getProcessDefinitionKeys().isEmpty()) {
        getProcessDefinitionsPayload.setProcessDefinitionKeys(securityKeysInPayload.getProcessDefinitionKeys());
    }
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
    if (getProcessDefinitionsPayload.hasDefinitionKeys()) {
        processDefinitionQuery.processDefinitionKeys(getProcessDefinitionsPayload.getProcessDefinitionKeys());
    }
    List<org.activiti.engine.repository.ProcessDefinition> currentVersionDefinitions = filterCurrentVersionDefinitions(processDefinitionQuery.list());
    return new PageImpl<>(processDefinitionConverter.from(currentVersionDefinitions), Math.toIntExact(processDefinitionQuery.count()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) GetProcessDefinitionsPayload(org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload)

Example 2 with GetProcessDefinitionsPayload

use of org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload in project Activiti by Activiti.

the class SecurityPoliciesProcessDefinitionRestrictionApplierTest method restrictToKeysAddFilterOnGivenKeys.

@Test
public void restrictToKeysAddFilterOnGivenKeys() {
    // given
    Set<String> keys = singleton("procDef");
    // when
    GetProcessDefinitionsPayload filter = restrictionApplier.restrictToKeys(keys);
    // then
    assertThat(filter.getProcessDefinitionKeys()).isEqualTo(keys);
}
Also used : GetProcessDefinitionsPayload(org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload) Test(org.junit.jupiter.api.Test)

Example 3 with GetProcessDefinitionsPayload

use of org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload in project Activiti by Activiti.

the class SecurityPoliciesProcessDefinitionRestrictionApplierTest method denyAllShouldAddUnmatchableFilter.

@Test
public void denyAllShouldAddUnmatchableFilter() {
    // when
    GetProcessDefinitionsPayload filter = restrictionApplier.denyAll();
    // then
    assertThat(filter.getProcessDefinitionKeys()).hasSize(1);
    assertThat(filter.getProcessDefinitionKeys().iterator().next()).startsWith("missing-");
}
Also used : GetProcessDefinitionsPayload(org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload) Test(org.junit.jupiter.api.Test)

Aggregations

GetProcessDefinitionsPayload (org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload)3 Test (org.junit.jupiter.api.Test)2 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)1 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)1 PageImpl (org.activiti.runtime.api.query.impl.PageImpl)1