Search in sources :

Example 1 with IdentityService

use of org.activiti.engine.IdentityService in project Activiti by Activiti.

the class CreateUserAndMembershipTestDelegate method execute.

@Override
public void execute(DelegateExecution execution) throws Exception {
    IdentityService identityService = execution.getEngineServices().getIdentityService();
    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);
    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);
    identityService.createMembership(username, "admin");
}
Also used : IdentityService(org.activiti.engine.IdentityService) Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 2 with IdentityService

use of org.activiti.engine.IdentityService in project Activiti by Activiti.

the class TaskEventTextResolver method resolveText.

public Label resolveText(Event event) {
    IdentityService identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
    User user = identityService.createUserQuery().userId(event.getUserId()).singleResult();
    String eventAuthor = "<span class='" + ExplorerLayout.STYLE_TASK_EVENT_AUTHOR + "'>" + user.getFirstName() + " " + user.getLastName() + "</span> ";
    String text = null;
    if (Event.ACTION_ADD_USER_LINK.equals(event.getAction())) {
        User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
        text = i18nManager.getMessage(Messages.EVENT_ADD_USER_LINK, eventAuthor, involvedUser.getFirstName() + " " + involvedUser.getLastName(), // second msg part = role
        event.getMessageParts().get(1));
    } else if (Event.ACTION_DELETE_USER_LINK.equals(event.getAction())) {
        User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
        text = i18nManager.getMessage(Messages.EVENT_DELETE_USER_LINK, eventAuthor, involvedUser.getFirstName() + " " + involvedUser.getLastName(), event.getMessageParts().get(1));
    } else if (Event.ACTION_ADD_GROUP_LINK.equals(event.getAction())) {
        text = i18nManager.getMessage(Messages.EVENT_ADD_GROUP_LINK, eventAuthor, event.getMessageParts().get(0), // second msg part = role
        event.getMessageParts().get(1));
    } else if (Event.ACTION_DELETE_GROUP_LINK.equals(event.getAction())) {
        text = i18nManager.getMessage(Messages.EVENT_DELETE_GROUP_LINK, eventAuthor, event.getMessageParts().get(0), // second msg part = role
        event.getMessageParts().get(1));
    } else if (Event.ACTION_ADD_ATTACHMENT.equals(event.getAction())) {
        text = i18nManager.getMessage(Messages.EVENT_ADD_ATTACHMENT, eventAuthor, event.getMessage());
    } else if (Event.ACTION_DELETE_ATTACHMENT.equals(event.getAction())) {
        text = i18nManager.getMessage(Messages.EVENT_DELETE_ATTACHMENT, eventAuthor, event.getMessage());
    } else if (Event.ACTION_ADD_COMMENT.equals(event.getAction())) {
        text = i18nManager.getMessage(Messages.EVENT_COMMENT, eventAuthor, event.getMessage());
    } else {
        // default: just show the message
        text += i18nManager.getMessage(Messages.EVENT_DEFAULT, eventAuthor, event.getMessage());
    }
    return new Label(text, Label.CONTENT_XHTML);
}
Also used : IdentityService(org.activiti.engine.IdentityService) User(org.activiti.engine.identity.User) Label(com.vaadin.ui.Label)

Example 3 with IdentityService

use of org.activiti.engine.IdentityService in project Activiti by Activiti.

the class BaseSpringRestTestCase method dropUsers.

protected void dropUsers() {
    IdentityService identityService = processEngine.getIdentityService();
    identityService.deleteUser("kermit");
    identityService.deleteGroup("admin");
    identityService.deleteMembership("kermit", "admin");
}
Also used : IdentityService(org.activiti.engine.IdentityService)

Example 4 with IdentityService

use of org.activiti.engine.IdentityService in project Activiti by Activiti.

the class BaseJPARestTestCase method dropUsers.

protected void dropUsers() {
    IdentityService identityService = processEngine.getIdentityService();
    identityService.deleteUser("kermit");
    identityService.deleteGroup("admin");
    identityService.deleteMembership("kermit", "admin");
}
Also used : IdentityService(org.activiti.engine.IdentityService)

Aggregations

IdentityService (org.activiti.engine.IdentityService)4 User (org.activiti.engine.identity.User)2 Label (com.vaadin.ui.Label)1 Group (org.activiti.engine.identity.Group)1