Search in sources :

Example 81 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class GroupDetailPanel method getCurrentMembers.

// Hacky - must be put in custom service
protected List<String> getCurrentMembers() {
    List<User> users = identityService.createUserQuery().memberOfGroup(group.getId()).list();
    List<String> userIds = new ArrayList<String>();
    for (User user : users) {
        userIds.add(user.getId());
    }
    return userIds;
}
Also used : User(org.activiti.engine.identity.User) ArrayList(java.util.ArrayList)

Example 82 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class UserResource method deleteUser.

@RequestMapping(value = "/identity/users/{userId}", method = RequestMethod.DELETE)
public void deleteUser(@PathVariable String userId, HttpServletResponse response) {
    User user = getUserFromRequest(userId);
    identityService.deleteUser(user.getId());
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
Also used : User(org.activiti.engine.identity.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 83 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class SetUserPictureCmd method execute.

public Object execute(CommandContext commandContext) {
    if (userId == null) {
        throw new ActivitiIllegalArgumentException("userId is null");
    }
    User user = commandContext.getUserIdentityManager().findUserById(userId);
    if (user == null) {
        throw new ActivitiObjectNotFoundException("user " + userId + " doesn't exist", User.class);
    }
    commandContext.getUserIdentityManager().setUserPicture(userId, picture);
    return null;
}
Also used : User(org.activiti.engine.identity.User) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 84 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class GroupEventsTest method testGroupMembershipEvents.

/**
	 * Test create, update and delete events of Groups.
	 */
public void testGroupMembershipEvents() throws Exception {
    TestActivitiEventListener membershipListener = new TestActivitiEventListener();
    processEngineConfiguration.getEventDispatcher().addEventListener(membershipListener);
    User user = null;
    Group group = null;
    try {
        user = identityService.newUser("kermit");
        identityService.saveUser(user);
        group = identityService.newGroup("sales");
        identityService.saveGroup(group);
        // Add membership
        membershipListener.clearEventsReceived();
        identityService.createMembership("kermit", "sales");
        assertEquals(1, membershipListener.getEventsReceived().size());
        assertTrue(membershipListener.getEventsReceived().get(0) instanceof ActivitiMembershipEvent);
        ActivitiMembershipEvent event = (ActivitiMembershipEvent) membershipListener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.MEMBERSHIP_CREATED, event.getType());
        assertEquals("sales", event.getGroupId());
        assertEquals("kermit", event.getUserId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getProcessInstanceId());
        membershipListener.clearEventsReceived();
        // Delete membership
        identityService.deleteMembership("kermit", "sales");
        assertEquals(1, membershipListener.getEventsReceived().size());
        assertTrue(membershipListener.getEventsReceived().get(0) instanceof ActivitiMembershipEvent);
        event = (ActivitiMembershipEvent) membershipListener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.MEMBERSHIP_DELETED, event.getType());
        assertEquals("sales", event.getGroupId());
        assertEquals("kermit", event.getUserId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getProcessInstanceId());
        membershipListener.clearEventsReceived();
        // Deleting group will dispatch an event, informing ALL memberships are deleted
        identityService.createMembership("kermit", "sales");
        membershipListener.clearEventsReceived();
        identityService.deleteGroup(group.getId());
        assertEquals(2, membershipListener.getEventsReceived().size());
        assertTrue(membershipListener.getEventsReceived().get(0) instanceof ActivitiMembershipEvent);
        event = (ActivitiMembershipEvent) membershipListener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.MEMBERSHIPS_DELETED, event.getType());
        assertEquals("sales", event.getGroupId());
        assertNull(event.getUserId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getProcessInstanceId());
        membershipListener.clearEventsReceived();
    } finally {
        processEngineConfiguration.getEventDispatcher().removeEventListener(membershipListener);
        if (user != null) {
            identityService.deleteUser(user.getId());
        }
        if (group != null) {
            identityService.deleteGroup(group.getId());
        }
    }
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) ActivitiMembershipEvent(org.activiti.engine.delegate.event.ActivitiMembershipEvent)

Example 85 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class RemoveInvolvedPersonListener method buttonClick.

public void buttonClick(ClickEvent event) {
    User user = identityService.createUserQuery().userId(identityLink.getUserId()).singleResult();
    String name = user.getFirstName() + " " + user.getLastName();
    ConfirmationDialogPopupWindow confirmationPopup = new ConfirmationDialogPopupWindow(i18nManager.getMessage(Messages.TASK_INVOLVED_REMOVE_CONFIRMATION_TITLE, name), i18nManager.getMessage(Messages.TASK_INVOLVED_REMOVE_CONFIRMATION_DESCRIPTION, name, task.getName()));
    confirmationPopup.addListener(new ConfirmationEventListener() {

        private static final long serialVersionUID = 1L;

        protected void rejected(ConfirmationEvent event) {
        }

        protected void confirmed(ConfirmationEvent event) {
            taskService.deleteUserIdentityLink(identityLink.getTaskId(), identityLink.getUserId(), identityLink.getType());
            taskDetailPanel.notifyPeopleInvolvedChanged();
        }
    });
    viewManager.showPopupWindow(confirmationPopup);
}
Also used : ConfirmationEventListener(org.activiti.explorer.ui.event.ConfirmationEventListener) User(org.activiti.engine.identity.User) ConfirmationEvent(org.activiti.explorer.ui.event.ConfirmationEvent) ConfirmationDialogPopupWindow(org.activiti.explorer.ui.custom.ConfirmationDialogPopupWindow)

Aggregations

User (org.activiti.engine.identity.User)94 Group (org.activiti.engine.identity.Group)22 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 Task (org.activiti.engine.task.Task)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)9 Picture (org.activiti.engine.identity.Picture)9 StringEntity (org.apache.http.entity.StringEntity)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ArrayList (java.util.ArrayList)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)7 HttpPut (org.apache.http.client.methods.HttpPut)7 HttpGet (org.apache.http.client.methods.HttpGet)6 UserQuery (org.activiti.engine.identity.UserQuery)5 HttpDelete (org.apache.http.client.methods.HttpDelete)5 HttpPost (org.apache.http.client.methods.HttpPost)4 Item (com.vaadin.data.Item)3 ActivitiException (org.activiti.engine.ActivitiException)3 IdentityService (org.activiti.engine.IdentityService)3