Search in sources :

Example 1 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class HalTenantResolver method resolveNotCachedLinks.

@Override
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
    IdentityService identityService = processEngine.getIdentityService();
    List<Tenant> tenants = identityService.createTenantQuery().tenantIdIn(linkedIds).list();
    List<HalResource<?>> resolvedTenants = new ArrayList<HalResource<?>>();
    for (Tenant tenant : tenants) {
        resolvedTenants.add(HalTenant.fromTenant(tenant));
    }
    return resolvedTenants;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Tenant(org.camunda.bpm.engine.identity.Tenant) ArrayList(java.util.ArrayList) HalResource(org.camunda.bpm.engine.rest.hal.HalResource)

Example 2 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class HalUserResolver method resolveNotCachedLinks.

protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
    IdentityService identityService = processEngine.getIdentityService();
    List<User> users = identityService.createUserQuery().userIdIn(linkedIds).listPage(0, linkedIds.length);
    List<HalResource<?>> resolvedUsers = new ArrayList<HalResource<?>>();
    for (User user : users) {
        resolvedUsers.add(HalUser.fromUser(user));
    }
    return resolvedUsers;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) User(org.camunda.bpm.engine.identity.User) ArrayList(java.util.ArrayList) HalResource(org.camunda.bpm.engine.rest.hal.HalResource)

Example 3 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class GroupRestServiceImpl method createGroup.

public void createGroup(GroupDto groupDto) {
    final IdentityService identityService = getIdentityService();
    if (identityService.isReadOnly()) {
        throw new InvalidRequestException(Status.FORBIDDEN, "Identity service implementation is read-only.");
    }
    Group newGroup = identityService.newGroup(groupDto.getId());
    groupDto.update(newGroup);
    identityService.saveGroup(newGroup);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Group(org.camunda.bpm.engine.identity.Group) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 4 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class FetchAndLockHandlerImpl method addPendingRequest.

@Override
public void addPendingRequest(FetchExternalTasksExtendedDto dto, AsyncResponse asyncResponse, ProcessEngine processEngine) {
    Long asyncResponseTimeout = dto.getAsyncResponseTimeout();
    if (asyncResponseTimeout != null && asyncResponseTimeout > MAX_TIMEOUT) {
        invalidRequest(asyncResponse, "The asynchronous response timeout cannot be set to a value greater than " + MAX_TIMEOUT + " milliseconds");
        return;
    }
    IdentityService identityService = processEngine.getIdentityService();
    Authentication authentication = identityService.getCurrentAuthentication();
    FetchAndLockRequest incomingRequest = new FetchAndLockRequest().setProcessEngine(processEngine).setAsyncResponse(asyncResponse).setAuthentication(authentication).setDto(dto);
    FetchAndLockResult result = tryFetchAndLock(incomingRequest);
    if (result.wasSuccessful()) {
        List<LockedExternalTaskDto> lockedTasks = result.getTasks();
        if (!lockedTasks.isEmpty() || dto.getAsyncResponseTimeout() == null) {
            // response immediately if tasks available
            asyncResponse.resume(lockedTasks);
        } else {
            addRequest(incomingRequest);
        }
    } else {
        ProcessEngineException processEngineException = result.getProcessEngineException();
        asyncResponse.resume(processEngineException);
    }
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) LockedExternalTaskDto(org.camunda.bpm.engine.rest.dto.externaltask.LockedExternalTaskDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 5 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class TaskCommentResourceImpl method isHistoryEnabled.

private boolean isHistoryEnabled() {
    IdentityService identityService = engine.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    try {
        identityService.clearAuthentication();
        int historyLevel = engine.getManagementService().getHistoryLevel();
        return historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE;
    } finally {
        identityService.setAuthentication(currentAuthentication);
    }
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Aggregations

IdentityService (org.camunda.bpm.engine.IdentityService)32 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)9 User (org.camunda.bpm.engine.identity.User)8 Group (org.camunda.bpm.engine.identity.Group)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 RuntimeService (org.camunda.bpm.engine.RuntimeService)6 ArrayList (java.util.ArrayList)4 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)4 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 Authorization (org.camunda.bpm.engine.authorization.Authorization)3 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)3 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)3 URI (java.net.URI)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 FilterService (org.camunda.bpm.engine.FilterService)2 FormService (org.camunda.bpm.engine.FormService)2 TaskService (org.camunda.bpm.engine.TaskService)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2