提交 8567fc36 编写于 作者: F Frederik Heremans

Added user get, create and update + user-collection get

上级 eb271b45
......@@ -26,6 +26,7 @@ import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.history.HistoricVariableInstance;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.bpmn.deployer.BpmnDeployer;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.repository.Deployment;
......@@ -57,7 +58,8 @@ import org.activiti.rest.api.history.HistoricDetailResponse;
import org.activiti.rest.api.history.HistoricProcessInstanceResponse;
import org.activiti.rest.api.history.HistoricTaskInstanceResponse;
import org.activiti.rest.api.history.HistoricVariableInstanceResponse;
import org.activiti.rest.api.identity.RestIdentityLink;
import org.activiti.rest.api.identity.UserResponse;
import org.activiti.rest.api.legacy.identity.LegacyRestIdentityLink;
import org.activiti.rest.api.management.JobResponse;
import org.activiti.rest.api.management.TableResponse;
import org.activiti.rest.api.repository.DeploymentResourceResponse;
......@@ -294,12 +296,12 @@ public class RestResponseFactory {
return value;
}
public RestIdentityLink createRestIdentityLink(SecuredResource securedResource, IdentityLink link) {
public LegacyRestIdentityLink createRestIdentityLink(SecuredResource securedResource, IdentityLink link) {
return createRestIdentityLink(securedResource, link.getType(), link.getUserId(), link.getGroupId(), link.getTaskId());
}
public RestIdentityLink createRestIdentityLink(SecuredResource securedResource, String type, String userId, String groupId, String taskId) {
RestIdentityLink result = new RestIdentityLink();
public LegacyRestIdentityLink createRestIdentityLink(SecuredResource securedResource, String type, String userId, String groupId, String taskId) {
LegacyRestIdentityLink result = new LegacyRestIdentityLink();
result.setUser(userId);
result.setGroup(groupId);
result.setType(type);
......@@ -545,6 +547,21 @@ public class RestResponseFactory {
return response;
}
public UserResponse createUserResponse(SecuredResource securedResource, User user, boolean incudePassword) {
UserResponse response = new UserResponse();
response.setFirstName(user.getFirstName());
response.setLastName(user.getLastName());
response.setId(user.getId());
response.setEmail(user.getEmail());
response.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_USER, user.getId()));
if(incudePassword) {
response.setPassword(user.getPassword());
}
return response;
}
/**
* Called once when the converters need to be initialized. Override of custom conversion
* needs to be done between java and rest.
......@@ -558,4 +575,5 @@ public class RestResponseFactory {
variableConverters.add(new BooleanRestVariableConverter());
variableConverters.add(new DateRestVariableConverter());
}
}
......@@ -29,6 +29,7 @@ public final class RestUrls {
public static final String SEGMENT_RUNTIME_RESOURCES = "runtime";
public static final String SEGMENT_MANAGEMENT_RESOURCES = "management";
public static final String SEGMENT_HISTORY_RESOURCES = "history";
public static final String SEGMENT_IDENTITY_RESOURCES = "identity";
public static final String SEGMENT_QUERY_RESOURCES = "query";
public static final String SEGMENT_DEPLOYMENT_RESOURCE = "deployments";
......@@ -58,6 +59,8 @@ public final class RestUrls {
public static final String SEGMENT_DATA = "data";
public static final String SEGMENT_JOBS = "jobs";
public static final String SEGMENT_JOB_EXCEPTION_STACKTRACE = "exception-stacktrace";
public static final String SEGMENT_USERS = "users";
public static final String SEGMENT_GROUPS = "groups";
/**
* URL template for the deployment collection: <i>repository/deployments</i>
......@@ -338,6 +341,16 @@ public final class RestUrls {
*/
public static final String[] URL_JOB_COLLECTION = {SEGMENT_MANAGEMENT_RESOURCES, SEGMENT_JOBS};
/**
* URL template for the collection of users: <i>identity/users</i>
*/
public static final String[] URL_USER_COLLECTION = {SEGMENT_IDENTITY_RESOURCES, SEGMENT_USERS};
/**
* URL template for a single user: <i>identity/users/{0:userId}</i>
*/
public static final String[] URL_USER = {SEGMENT_IDENTITY_RESOURCES, SEGMENT_USERS, "{0}"};
/**
* Creates an url based on the passed fragments and replaces any placeholders with the given arguments. The
* placeholders are folowing the {@link MessageFormat} convention
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
import java.util.HashMap;
import java.util.Set;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.identity.User;
import org.activiti.engine.identity.UserQuery;
import org.activiti.engine.impl.UserQueryProperty;
import org.activiti.engine.query.QueryProperty;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.DataResponse;
import org.activiti.rest.api.SecuredResource;
import org.activiti.rest.application.ActivitiRestServicesApplication;
import org.restlet.data.Form;
import org.restlet.data.Status;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.ResourceException;
/**
* @author Frederik Heremans
*/
public class UserCollectionResource extends SecuredResource {
protected static HashMap<String, QueryProperty> properties = new HashMap<String, QueryProperty>();
static {
properties.put("id", UserQueryProperty.USER_ID);
properties.put("firstName", UserQueryProperty.FIRST_NAME);
properties.put("lastName", UserQueryProperty.LAST_NAME);
properties.put("email", UserQueryProperty.EMAIL);
}
@Get
public DataResponse getUsers() {
if(!authenticate())
return null;
UserQuery query = ActivitiUtil.getIdentityService().createUserQuery();
Form form = getQuery();
Set<String> names = form.getNames();
if(names.contains("id")) {
query.userId(getQueryParameter("id", form));
}
if(names.contains("firstName")) {
query.userFirstName(getQueryParameter("firstName", form));
}
if(names.contains("lastName")) {
query.userLastName(getQueryParameter("lastName", form));
}
if(names.contains("email")) {
query.userEmail(getQueryParameter("email", form));
}
if(names.contains("firstNameLike")) {
query.userFirstNameLike(getQueryParameter("firstNameLike", form));
}
if(names.contains("lastNameLike")) {
query.userLastNameLike(getQueryParameter("lastNameLike", form));
}
if(names.contains("emailLike")) {
query.userEmailLike(getQueryParameter("emailLike", form));
}
if(names.contains("memberOfGroup")) {
query.memberOfGroup(getQueryParameter("memberOfGroup", form));
}
if(names.contains("potentialStarter")) {
query.potentialStarter(getQueryParameter("potentialStarter", form));
}
return new UserPaginateList(this).paginateList(form, query, "id", properties);
}
@Post
public UserResponse createUser(UserRequest request) {
if(request.getId() == null) {
throw new ActivitiIllegalArgumentException("The id for the new user cannot be null");
}
// Check if a user with the given ID already exists so we return a CONFLICT
if(ActivitiUtil.getIdentityService().createUserQuery().userId(request.getId()).count() > 0) {
throw new ResourceException(Status.CLIENT_ERROR_CONFLICT.getCode(), "A user with id '" + request.getId() + "' already exists.", null, null);
}
User created = ActivitiUtil.getIdentityService().newUser(request.getId());
created.setEmail(request.getEmail());
created.setFirstName(request.getFirstName());
created.setLastName(request.getLastName());
created.setPassword(request.getPassword());
ActivitiUtil.getIdentityService().saveUser(created);
return getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory()
.createUserResponse(this, created, true);
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.identity.User;
import org.activiti.rest.api.AbstractPaginateList;
import org.activiti.rest.api.RestResponseFactory;
import org.activiti.rest.api.SecuredResource;
import org.activiti.rest.application.ActivitiRestServicesApplication;
/**
* @author Frederik Heremans
*/
public class UserPaginateList extends AbstractPaginateList {
private SecuredResource resource;
public UserPaginateList(SecuredResource resource) {
this.resource = resource;
}
@SuppressWarnings("rawtypes")
@Override
protected List processList(List list) {
List<UserResponse> responseList = new ArrayList<UserResponse>();
RestResponseFactory restResponseFactory = resource.getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory();
for (Object user : list) {
responseList.add(restResponseFactory.createUserResponse(resource, (User) user, false));
}
return responseList;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
/**
* @author Frederik Heremans
*/
public class UserRequest extends UserResponse {
protected boolean firstNameChanged = false;
protected boolean lastNameChanged = false;
protected boolean passwordChanged = false;
protected boolean emailChanged = false;
@Override
public void setEmail(String email) {
super.setEmail(email);
emailChanged = true;
}
@Override
public void setFirstName(String firstName) {
super.setFirstName(firstName);
firstNameChanged = true;
}
@Override
public void setLastName(String lastName) {
super.setLastName(lastName);
lastNameChanged = true;
}
@Override
public void setPassword(String passWord) {
super.setPassword(passWord);
passwordChanged = true;
}
public boolean isEmailChanged() {
return emailChanged;
}
public boolean isFirstNameChanged() {
return firstNameChanged;
}
public boolean isLastNameChanged() {
return lastNameChanged;
}
public boolean isPasswordChanged() {
return passwordChanged;
}
}
......@@ -14,27 +14,72 @@
package org.activiti.rest.api.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.identity.User;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.SecuredResource;
import org.activiti.rest.application.ActivitiRestServicesApplication;
import org.restlet.data.Status;
import org.restlet.resource.Delete;
import org.restlet.resource.Get;
import org.restlet.resource.Put;
/**
* @author Tijs Rademakers
* @author Frederik Heremans
*/
public class UserResource extends SecuredResource {
@Get
public UserInfo getUser() {
if(authenticate() == false) return null;
public UserResponse getUser() {
if(!authenticate())
return null;
String userId = (String) getRequest().getAttributes().get("userId");
if(userId == null) {
throw new ActivitiIllegalArgumentException("No userId provided");
return getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory()
.createUserResponse(this, getUserFromRequest(), false);
}
@Put
public UserResponse updateUser(UserRequest request) {
User user = getUserFromRequest();
if(request.isEmailChanged()) {
user.setEmail(request.getEmail());
}
User user = ActivitiUtil.getIdentityService().createUserQuery().userId(userId).singleResult();
UserInfo response = new UserInfo(user);
return response;
if(request.isFirstNameChanged()) {
user.setFirstName(request.getFirstName());
}
if(request.isLastNameChanged()) {
user.setLastName(request.getLastName());
}
if(request.isPasswordChanged()) {
user.setPassword(request.getPassword());
}
ActivitiUtil.getIdentityService().saveUser(user);
return getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory()
.createUserResponse(this, user, false);
}
@Delete
public void deleteUser() {
User user = getUserFromRequest();
ActivitiUtil.getIdentityService().deleteUser(user.getId());
setStatus(Status.SUCCESS_NO_CONTENT);
}
protected User getUserFromRequest() {
String userId = getAttribute("userId");
if (userId == null) {
throw new ActivitiIllegalArgumentException("The userId cannot be null");
}
User user = ActivitiUtil.getIdentityService().createUserQuery().userId(userId).singleResult();
if (user == null) {
throw new ActivitiObjectNotFoundException("Could not find a user with id '" + userId + "'.", User.class);
}
return user;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
/**
* @author Frederik Hermans
*/
public class UserResponse {
protected String id;
protected String firstName;
protected String lastName;
protected String passWord;
protected String url;
protected String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonSerialize(include=Inclusion.NON_NULL)
public String getPassword() {
return passWord;
}
public void setPassword(String passWord) {
this.passWord = passWord;
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.IdentityService;
......@@ -25,10 +25,10 @@ import org.restlet.resource.ResourceException;
/**
* @author Ernesto Revilla
*/
public class GroupCreateResource extends SecuredResource {
public class LegacyGroupCreateResource extends SecuredResource {
@Put()
public StateResponse createGroup(GroupInfo groupInfo) {
public LegacyStateResponse createGroup(LegacyGroupInfo groupInfo) {
if (authenticate() == false)
return null;
......@@ -51,6 +51,6 @@ public class GroupCreateResource extends SecuredResource {
} else {
throw new ResourceException(Status.CLIENT_ERROR_CONFLICT, "group id must be unique");
}
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
}
......@@ -11,22 +11,22 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.identity.Group;
/**
* @author Ernesto Revilla
*/
public class GroupInfo {
public class LegacyGroupInfo {
String id;
String name;
String type;
public GroupInfo(){}
public LegacyGroupInfo(){}
public GroupInfo(Group group) {
public LegacyGroupInfo(Group group) {
setId(group.getId());
setName(group.getName());
setType(group.getType());
......@@ -35,21 +35,21 @@ public class GroupInfo {
public String getId() {
return id;
}
public GroupInfo setId(String id) {
public LegacyGroupInfo setId(String id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public GroupInfo setName(String name) {
public LegacyGroupInfo setName(String name) {
this.name = name;
return this;
}
public String getType() {
return type;
}
public GroupInfo setType(String type) {
public LegacyGroupInfo setType(String type) {
this.type = type;
return this;
}
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.identity.Group;
......@@ -24,7 +24,7 @@ import org.restlet.resource.Get;
/**
* @author Tijs Rademakers
*/
public class GroupResource extends SecuredResource {
public class LegacyGroupResource extends SecuredResource {
@Get
public Group getGroup() {
......@@ -41,7 +41,7 @@ public class GroupResource extends SecuredResource {
}
@Delete
public StateResponse deleteGroup() {
public LegacyStateResponse deleteGroup() {
if (authenticate() == false)
return null;
......@@ -49,14 +49,14 @@ public class GroupResource extends SecuredResource {
if (groupId == null) {
setStatus(Status.CLIENT_ERROR_NOT_FOUND, "The group '" + groupId
+ "' does not exist.");
return new StateResponse().setSuccess(false);
return new LegacyStateResponse().setSuccess(false);
}
Group group = ActivitiUtil.getIdentityService().createGroupQuery()
.groupId(groupId).singleResult();
if (group != null) {
ActivitiUtil.getIdentityService().deleteGroup(groupId);
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
return new StateResponse().setSuccess(false);
return new LegacyStateResponse().setSuccess(false);
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.Collections;
......@@ -28,7 +28,7 @@ import org.restlet.resource.Get;
/**
* @author Tijs Rademakers
*/
public class GroupSearchResource extends SecuredResource {
public class LegacyGroupSearchResource extends SecuredResource {
@Get
public DataResponse searchGroups() {
......@@ -41,16 +41,16 @@ public class GroupSearchResource extends SecuredResource {
}
List<Group> groups = ActivitiUtil.getIdentityService().createGroupQuery().list();
List<GroupInfo> groupList = new ArrayList<GroupInfo>();
List<LegacyGroupInfo> groupList = new ArrayList<LegacyGroupInfo>();
for (Group group : groups) {
if (StringUtils.isNotEmpty(searchText)) {
if (group.getName().toLowerCase().contains(searchText)
|| group.getId().toLowerCase().contains(searchText)) {
groupList.add(new GroupInfo(group));
groupList.add(new LegacyGroupInfo(group));
}
} else {
groupList.add(new GroupInfo(group));
groupList.add(new LegacyGroupInfo(group));
}
}
......@@ -67,9 +67,9 @@ public class GroupSearchResource extends SecuredResource {
return response;
}
protected class GroupResponseComparable implements Comparator<GroupInfo> {
protected class GroupResponseComparable implements Comparator<LegacyGroupInfo> {
public int compare(GroupInfo group1, GroupInfo group2) {
public int compare(LegacyGroupInfo group1, LegacyGroupInfo group2) {
return group1.getName().compareTo(group2.getName());
}
}
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.List;
......@@ -22,14 +22,14 @@ import org.activiti.rest.api.AbstractPaginateList;
/**
* @author Tijs Rademakers
*/
public class GroupUsersPaginateList extends AbstractPaginateList {
public class LegacyGroupUsersPaginateList extends AbstractPaginateList {
@SuppressWarnings("rawtypes")
@Override
protected List processList(List list) {
List<UserInfo> responseList = new ArrayList<UserInfo>();
List<LegacyUserInfo> responseList = new ArrayList<LegacyUserInfo>();
for (Object definition : list) {
UserInfo response = new UserInfo((User) definition);
LegacyUserInfo response = new LegacyUserInfo((User) definition);
responseList.add(response);
}
return responseList;
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -32,11 +32,11 @@ import org.restlet.resource.Post;
/**
* @author Ernesto Revilla
*/
public class GroupUsersResource extends SecuredResource {
public class LegacyGroupUsersResource extends SecuredResource {
Map<String, QueryProperty> properties = new HashMap<String, QueryProperty>();
public GroupUsersResource() {
public LegacyGroupUsersResource() {
properties.put("id", UserQueryProperty.USER_ID);
properties.put("firstName", UserQueryProperty.FIRST_NAME);
properties.put("lastName", UserQueryProperty.LAST_NAME);
......@@ -53,14 +53,14 @@ public class GroupUsersResource extends SecuredResource {
throw new ActivitiIllegalArgumentException("No groupId provided");
}
DataResponse dataResponse = new GroupUsersPaginateList().paginateList(
DataResponse dataResponse = new LegacyGroupUsersPaginateList().paginateList(
getQuery(), ActivitiUtil.getIdentityService().createUserQuery()
.memberOfGroup(groupId), "id", properties);
return dataResponse;
}
@Post
public StateResponse setUsers(ArrayList<String> userIds) {
public LegacyStateResponse setUsers(ArrayList<String> userIds) {
if (authenticate() == false)
return null;
String groupId = (String) getRequest().getAttributes().get("groupId");
......@@ -87,7 +87,7 @@ public class GroupUsersResource extends SecuredResource {
.memberOfGroup(groupId).singleResult() == null)
identityService.createMembership(userId, groupId);
}
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
}
......@@ -11,12 +11,12 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
/**
* @author Tijs Rademakers
*/
public class LoginInfo {
public class LegacyLoginInfo {
private String userId;
private String password;
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.List;
......@@ -27,10 +27,10 @@ import org.restlet.resource.ServerResource;
/**
* @author Tijs Rademakers
*/
public class LoginResource extends ServerResource {
public class LegacyLoginResource extends ServerResource {
@Post
public LoginResponse login(LoginInfo loginInfo) {
public LegacyLoginResponse login(LegacyLoginInfo loginInfo) {
if(loginInfo == null) {
throw new ActivitiIllegalArgumentException("No login info supplied");
}
......@@ -48,7 +48,7 @@ public class LoginResource extends ServerResource {
if (pe.getIdentityService().checkPassword(loginInfo.getUserId(), loginInfo.getPassword()) == false) {
throw new ActivitiException("Username and password does not match.");
}
return new LoginResponse().setSuccess(true);
return new LegacyLoginResponse().setSuccess(true);
} else {
String message;
......
......@@ -11,12 +11,12 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
/**
* @author Tijs Rademakers
*/
public class LoginResponse {
public class LegacyLoginResponse {
private boolean success;
......@@ -24,7 +24,7 @@ public class LoginResponse {
return success;
}
public LoginResponse setSuccess(boolean success) {
public LegacyLoginResponse setSuccess(boolean success) {
this.success = success;
return this;
}
......
......@@ -11,13 +11,13 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
/**
* @author Frederik Heremans
*/
public class RestIdentityLink {
public class LegacyRestIdentityLink {
private String url;
private String user;
......
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
public class StateResponse {
public class LegacyStateResponse {
boolean success;
......@@ -8,7 +8,7 @@ public class StateResponse {
return success;
}
public StateResponse setSuccess(boolean success) {
public LegacyStateResponse setSuccess(boolean success) {
this.success = success;
return this;
}
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.IdentityService;
......@@ -25,10 +25,10 @@ import org.restlet.resource.ResourceException;
/**
* @author Tijs Rademakers
*/
public class UserCreateResource extends SecuredResource {
public class LegacyUserCreateResource extends SecuredResource {
@Put()
public StateResponse createUser(UserInfoWithPassword userInfo){
public LegacyStateResponse createUser(LegacyUserInfoWithPassword userInfo){
if(authenticate() == false) return null;
IdentityService identityService = ActivitiUtil.getIdentityService();
......@@ -46,6 +46,6 @@ public class UserCreateResource extends SecuredResource {
} else {
throw new ResourceException(Status.CLIENT_ERROR_CONFLICT, "user id must be unique");
}
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.Group;
......@@ -23,22 +23,22 @@ import org.restlet.data.Status;
/**
* @author Ernesto Revilla
*/
public class UserGroupsDeleteResource extends SecuredResource {
public class LegacyUserGroupsDeleteResource extends SecuredResource {
@Delete
public StateResponse deleteGroup() {
public LegacyStateResponse deleteGroup() {
if (authenticate() == false)
return null;
String userId = (String) getRequest().getAttributes().get("userId");
String groupId = (String) getRequest().getAttributes().get("groupId");
if (userId == null) {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "No userId provided.");
return new StateResponse().setSuccess(false);
return new LegacyStateResponse().setSuccess(false);
}
if (groupId == null) {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "No groupId provided.");
return new StateResponse().setSuccess(false);
return new LegacyStateResponse().setSuccess(false);
}
IdentityService identityService = ActivitiUtil.getIdentityService();
......@@ -46,7 +46,7 @@ public class UserGroupsDeleteResource extends SecuredResource {
if (identityService.createUserQuery().userId(userId).singleResult() == null) {
setStatus(Status.CLIENT_ERROR_NOT_FOUND, "The user '" + userId
+ "' does not exist.");
return new StateResponse().setSuccess(false);
return new LegacyStateResponse().setSuccess(false);
}
// Add only if not already member
......@@ -54,6 +54,6 @@ public class UserGroupsDeleteResource extends SecuredResource {
.groupId(groupId).singleResult();
if (group != null)
identityService.deleteMembership(userId, groupId);
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.List;
......@@ -22,14 +22,14 @@ import org.activiti.rest.api.AbstractPaginateList;
/**
* @author Tijs Rademakers
*/
public class UserGroupsPaginateList extends AbstractPaginateList {
public class LegacyUserGroupsPaginateList extends AbstractPaginateList {
@SuppressWarnings("rawtypes")
@Override
protected List processList(List list) {
List<GroupInfo> groupList = new ArrayList<GroupInfo>();
List<LegacyGroupInfo> groupList = new ArrayList<LegacyGroupInfo>();
for (Object instance : list) {
groupList.add(new GroupInfo((Group) instance));
groupList.add(new LegacyGroupInfo((Group) instance));
}
return groupList;
}
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -33,11 +33,11 @@ import org.restlet.resource.Post;
/**
* @author Tijs Rademakers
*/
public class UserGroupsResource extends SecuredResource {
public class LegacyUserGroupsResource extends SecuredResource {
Map<String, QueryProperty> properties = new HashMap<String, QueryProperty>();
public UserGroupsResource() {
public LegacyUserGroupsResource() {
properties.put("id", GroupQueryProperty.GROUP_ID);
properties.put("name", GroupQueryProperty.NAME);
properties.put("type", GroupQueryProperty.TYPE);
......@@ -53,14 +53,14 @@ public class UserGroupsResource extends SecuredResource {
throw new ActivitiIllegalArgumentException("No userId provided");
}
DataResponse dataResponse = new UserGroupsPaginateList().paginateList(
DataResponse dataResponse = new LegacyUserGroupsPaginateList().paginateList(
getQuery(), ActivitiUtil.getIdentityService().createGroupQuery()
.groupMember(userId), "id", properties);
return dataResponse;
}
@Post
public StateResponse setGroups(ArrayList<String> groupIds) {
public LegacyStateResponse setGroups(ArrayList<String> groupIds) {
if (authenticate() == false)
return null;
String userId = (String) getRequest().getAttributes().get("userId");
......@@ -87,7 +87,7 @@ public class UserGroupsResource extends SecuredResource {
.memberOfGroup(groupId).singleResult() == null)
identityService.createMembership(userId, groupId);
}
return new StateResponse().setSuccess(true);
return new LegacyStateResponse().setSuccess(true);
}
}
......@@ -11,23 +11,23 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.identity.User;
/**
* @author Tijs Rademakers
*/
public class UserInfo {
public class LegacyUserInfo {
String id;
String firstName;
String lastName;
String email;
public UserInfo(){}
public LegacyUserInfo(){}
public UserInfo(User user) {
public LegacyUserInfo(User user) {
setId(user.getId());
setEmail(user.getEmail());
setFirstName(user.getFirstName());
......@@ -37,28 +37,28 @@ public class UserInfo {
public String getId() {
return id;
}
public UserInfo setId(String id) {
public LegacyUserInfo setId(String id) {
this.id = id;
return this;
}
public String getFirstName() {
return firstName;
}
public UserInfo setFirstName(String firstName) {
public LegacyUserInfo setFirstName(String firstName) {
this.firstName = firstName;
return this;
}
public String getLastName() {
return lastName;
}
public UserInfo setLastName(String lastName) {
public LegacyUserInfo setLastName(String lastName) {
this.lastName = lastName;
return this;
}
public String getEmail() {
return email;
}
public UserInfo setEmail(String email) {
public LegacyUserInfo setEmail(String email) {
this.email = email;
return this;
}
......
......@@ -11,13 +11,14 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
/**
* @author Tijs Rademakers
*/
public class UserInfoWithPassword extends UserInfo {
public class LegacyUserInfoWithPassword extends LegacyUserInfo {
String password;
......
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.identity.Picture;
......@@ -25,7 +25,7 @@ import org.restlet.resource.Get;
/**
* @author Tijs Rademakers
*/
public class UserPictureResource extends SecuredResource {
public class LegacyUserPictureResource extends SecuredResource {
@Get
public InputRepresentation getPicture() {
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.legacy.identity;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.identity.User;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.SecuredResource;
import org.restlet.resource.Get;
/**
* @author Tijs Rademakers
*/
public class LegacyUserResource extends SecuredResource {
@Get
public LegacyUserInfo getUser() {
if(authenticate() == false) return null;
String userId = (String) getRequest().getAttributes().get("userId");
if(userId == null) {
throw new ActivitiIllegalArgumentException("No userId provided");
}
User user = ActivitiUtil.getIdentityService().createUserQuery().userId(userId).singleResult();
LegacyUserInfo response = new LegacyUserInfo(user);
return response;
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy.identity;
import java.util.ArrayList;
import java.util.Collections;
......@@ -30,7 +30,7 @@ import org.restlet.resource.Get;
/**
* @author Tijs Rademakers
*/
public class UserSearchResource extends SecuredResource {
public class LegacyUserSearchResource extends SecuredResource {
@Get
public DataResponse searchUsers() {
......@@ -45,22 +45,22 @@ public class UserSearchResource extends SecuredResource {
List<User> firstNameMatchList = ActivitiUtil.getIdentityService().createUserQuery().userFirstNameLike(searchText).list();
List<User> lastNameMatchList = ActivitiUtil.getIdentityService().createUserQuery().userLastNameLike(searchText).list();
Map<String, UserInfo> userMap = new HashMap<String, UserInfo>();
Map<String, LegacyUserInfo> userMap = new HashMap<String, LegacyUserInfo>();
if(firstNameMatchList != null) {
for (User user : firstNameMatchList) {
userMap.put(user.getId(), new UserInfo(user));
userMap.put(user.getId(), new LegacyUserInfo(user));
}
}
if(lastNameMatchList != null) {
for (User user : lastNameMatchList) {
if(userMap.containsKey(user.getId()) == false) {
userMap.put(user.getId(), new UserInfo(user));
userMap.put(user.getId(), new LegacyUserInfo(user));
}
}
}
List<UserInfo> userList = new ArrayList<UserInfo>();
List<LegacyUserInfo> userList = new ArrayList<LegacyUserInfo>();
userList.addAll(userMap.values());
Collections.sort(userList, new UserResponseComparable());
......@@ -75,9 +75,9 @@ public class UserSearchResource extends SecuredResource {
return response;
}
protected class UserResponseComparable implements Comparator<UserInfo>{
protected class UserResponseComparable implements Comparator<LegacyUserInfo>{
public int compare(UserInfo user1, UserInfo user2) {
public int compare(LegacyUserInfo user1, LegacyUserInfo user2) {
return user1.getLastName().compareTo(user2.getLastName());
}
}
......
......@@ -15,6 +15,7 @@ package org.activiti.rest.api.management;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.JobQueryProperty;
......@@ -49,54 +50,55 @@ public class JobCollectionResource extends SecuredResource {
JobQuery query = ActivitiUtil.getManagementService().createJobQuery();
Form form = getQuery();
Set<String> names = form.getNames();
if(form.getNames().contains("id")) {
if(names.contains("id")) {
query.jobId(getQueryParameter("id", form));
}
if(form.getNames().contains("processInstanceId")) {
if(names.contains("processInstanceId")) {
query.processInstanceId(getQueryParameter("processInstanceId", form));
}
if(form.getNames().contains("executionId")) {
if(names.contains("executionId")) {
query.executionId(getQueryParameter("executionId", form));
}
if(form.getNames().contains("processDefinitionId")) {
if(names.contains("processDefinitionId")) {
query.processDefinitionId(getQueryParameter("processDefinitionId", form));
}
if(form.getNames().contains("withRetriesLeft")) {
if(names.contains("withRetriesLeft")) {
if(Boolean.TRUE.equals(getQueryParameterAsBoolean("withRetriesLeft", form))) {
query.withRetriesLeft();
}
}
if(form.getNames().contains("executable")) {
if(names.contains("executable")) {
if(Boolean.TRUE.equals(getQueryParameterAsBoolean("executable", form))) {
query.executable();
}
}
if(form.getNames().contains("timersOnly")) {
if(form.getNames().contains("messagesOnly")) {
if(names.contains("timersOnly")) {
if(names.contains("messagesOnly")) {
throw new ActivitiIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
}
if(Boolean.TRUE.equals(getQueryParameterAsBoolean("timersOnly", form))) {
query.timers();
}
}
if(form.getNames().contains("messagesOnly")) {
if(names.contains("messagesOnly")) {
if(Boolean.TRUE.equals(getQueryParameterAsBoolean("messagesOnly", form))) {
query.messages();
}
}
if(form.getNames().contains("dueBefore")) {
if(names.contains("dueBefore")) {
query.duedateLowerThan(getQueryParameterAsDate("dueBefore", form));
}
if(form.getNames().contains("dueAfter")) {
if(names.contains("dueAfter")) {
query.duedateHigherThan(getQueryParameterAsDate("dueAfter", form));
}
if(form.getNames().contains("withException")) {
if(names.contains("withException")) {
if(Boolean.TRUE.equals(getQueryParameterAsBoolean("withException", form))) {
query.withException();
}
}
if(form.getNames().contains("exceptionMessage")) {
if(names.contains("exceptionMessage")) {
query.exceptionMessage(getQueryParameter("exceptionMessage", form));
}
......
......@@ -16,6 +16,7 @@ package org.activiti.rest.api.repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipInputStream;
import org.activiti.engine.ActivitiException;
......@@ -62,17 +63,19 @@ public class DeploymentCollectionResource extends SecuredResource {
DeploymentQuery deploymentQuery = ActivitiUtil.getRepositoryService().createDeploymentQuery();
Form query = getQuery();
Set<String> names = query.getNames();
// Apply filters
if(getQuery().getNames().contains("name")) {
if(names.contains("name")) {
deploymentQuery.deploymentName(getQueryParameter("name", query));
}
if(getQuery().getNames().contains("nameLike")) {
if(names.contains("nameLike")) {
deploymentQuery.deploymentNameLike(getQueryParameter("nameLike", query));
}
if(getQuery().getNames().contains("category")) {
if(names.contains("category")) {
deploymentQuery.deploymentCategory(getQueryParameter("category", query));
}
if(getQuery().getNames().contains("categoryNotEquals")) {
if(names.contains("categoryNotEquals")) {
deploymentQuery.deploymentCategoryNotEquals(getQueryParameter("categoryNotEquals", query));
}
......
......@@ -15,6 +15,7 @@ package org.activiti.rest.api.repository;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.activiti.engine.impl.ProcessDefinitionQueryProperty;
import org.activiti.engine.query.QueryProperty;
......@@ -47,39 +48,40 @@ public class ProcessDefinitionCollectionResource extends SecuredResource {
ProcessDefinitionQuery processDefinitionQuery = ActivitiUtil.getRepositoryService().createProcessDefinitionQuery();
Form query = getQuery();
Set<String> names = query.getNames();
// Populate filter-parameters
if(query.getNames().contains("category")) {
if(names.contains("category")) {
processDefinitionQuery.processDefinitionCategory(getQueryParameter("category", query));
}
if(query.getNames().contains("categoryLike")) {
if(names.contains("categoryLike")) {
processDefinitionQuery.processDefinitionCategoryLike(getQueryParameter("categoryLike", query));
}
if(query.getNames().contains("categoryNotEquals")) {
if(names.contains("categoryNotEquals")) {
processDefinitionQuery.processDefinitionCategoryNotEquals(getQueryParameter("categoryNotEquals", query));
}
if(query.getNames().contains("key")) {
if(names.contains("key")) {
processDefinitionQuery.processDefinitionKey(getQueryParameter("key", query));
}
if(query.getNames().contains("keyLike")) {
if(names.contains("keyLike")) {
processDefinitionQuery.processDefinitionKeyLike(getQueryParameter("keyLike", query));
}
if(query.getNames().contains("name")) {
if(names.contains("name")) {
processDefinitionQuery.processDefinitionName(getQueryParameter("name", query));
}
if(query.getNames().contains("nameLike")) {
if(names.contains("nameLike")) {
processDefinitionQuery.processDefinitionNameLike(getQueryParameter("nameLike", query));
}
if(query.getNames().contains("resourceName")) {
if(names.contains("resourceName")) {
processDefinitionQuery.processDefinitionResourceName(getQueryParameter("resourceName", query));
}
if(query.getNames().contains("resourceNameLike")) {
if(names.contains("resourceNameLike")) {
processDefinitionQuery.processDefinitionResourceNameLike(getQueryParameter("resourceNameLike", query));
}
if(query.getNames().contains("version")) {
if(names.contains("version")) {
processDefinitionQuery.processDefinitionVersion(getQueryParameterAsInt("version", query));
}
if(query.getNames().contains("suspended")) {
if(names.contains("suspended")) {
Boolean suspended = getQueryParameterAsBoolean("suspended", query);
if(suspended != null) {
if(suspended) {
......@@ -89,16 +91,16 @@ public class ProcessDefinitionCollectionResource extends SecuredResource {
}
}
}
if(query.getNames().contains("latest")) {
if(names.contains("latest")) {
Boolean latest = getQueryParameterAsBoolean("latest", query);
if(latest != null && latest) {
processDefinitionQuery.latestVersion();
}
}
if(query.getNames().contains("deploymentId")) {
if(names.contains("deploymentId")) {
processDefinitionQuery.deploymentId(getQueryParameter("deploymentId", query));
}
if(query.getNames().contains("startableByUser")) {
if(names.contains("startableByUser")) {
processDefinitionQuery.startableByUser(getQueryParameter("startableByUser", query));
}
......
......@@ -13,6 +13,8 @@
package org.activiti.rest.api.runtime.task;
import java.util.Set;
import org.activiti.engine.task.Task;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.DataResponse;
......@@ -55,113 +57,114 @@ public class TaskCollectionResource extends TaskBaseResource {
// Create a Task query request
TaskQueryRequest request = new TaskQueryRequest();
Form query = getQuery();
Set<String> names = query.getNames();
// Populate filter-parameters
if(query.getNames().contains("name")) {
if(names.contains("name")) {
request.setName(getQueryParameter("name", query));
}
if(query.getNames().contains("nameLike")) {
if(names.contains("nameLike")) {
request.setNameLike(getQueryParameter("nameLike", query));
}
if(query.getNames().contains("description")) {
if(names.contains("description")) {
request.setDescription(getQueryParameter("description", query));
}
if(query.getNames().contains("descriptionLike")) {
if(names.contains("descriptionLike")) {
request.setDescriptionLike(getQueryParameter("descriptionLike", query));
}
if(query.getNames().contains("priority")) {
if(names.contains("priority")) {
request.setPriority(getQueryParameterAsInt("priority", query));
}
if(query.getNames().contains("minimumPriority")) {
if(names.contains("minimumPriority")) {
request.setMinimumPriority(getQueryParameterAsInt("minimumPriority", query));
}
if(query.getNames().contains("maximumPriority")) {
if(names.contains("maximumPriority")) {
request.setMaximumPriority(getQueryParameterAsInt("maximumPriority", query));
}
if(query.getNames().contains("assignee")) {
if(names.contains("assignee")) {
request.setAssignee(getQueryParameter("assignee", query));
}
if(query.getNames().contains("owner")) {
if(names.contains("owner")) {
request.setOwner(getQueryParameter("owner", query));
}
if(query.getNames().contains("unassigned")) {
if(names.contains("unassigned")) {
request.setUnassigned(getQueryParameterAsBoolean("unassigned", query));
}
if(query.getNames().contains("delegationState")) {
if(names.contains("delegationState")) {
request.setDelegationState(getQueryParameter("delegationState", query));
}
if(query.getNames().contains("candidateUser")) {
if(names.contains("candidateUser")) {
request.setCandidateUser(getQueryParameter("candidateUser", query));
}
if(query.getNames().contains("involvedUser")) {
if(names.contains("involvedUser")) {
request.setInvolvedUser(getQueryParameter("involvedUser", query));
}
if(query.getNames().contains("candidateGroup")) {
if(names.contains("candidateGroup")) {
request.setCandidateGroup(getQueryParameter("candidateGroup", query));
}
if(query.getNames().contains("processInstanceId")) {
if(names.contains("processInstanceId")) {
request.setProcessInstanceId(getQueryParameter("processInstanceId", query));
}
if(query.getNames().contains("processInstanceBusinessKey")) {
if(names.contains("processInstanceBusinessKey")) {
request.setProcessInstanceBusinessKey(getQueryParameter("processInstanceBusinessKey", query));
}
if(query.getNames().contains("executionId")) {
if(names.contains("executionId")) {
request.setExecutionId(getQueryParameter("executionId", query));
}
if(query.getNames().contains("createdOn")) {
if(names.contains("createdOn")) {
request.setCreatedOn(getQueryParameterAsDate("createdOn", query));
}
if(query.getNames().contains("createdBefore")) {
if(names.contains("createdBefore")) {
request.setCreatedBefore(getQueryParameterAsDate("createdBefore", query));
}
if(query.getNames().contains("createdAfter")) {
if(names.contains("createdAfter")) {
request.setCreatedAfter(getQueryParameterAsDate("createdAfter", query));
}
if(query.getNames().contains("excludeSubTasks")) {
if(names.contains("excludeSubTasks")) {
request.setExcludeSubTasks(getQueryParameterAsBoolean("excludeSubTasks", query));
}
if(query.getNames().contains("taskDefinitionKey")) {
if(names.contains("taskDefinitionKey")) {
request.setTaskDefinitionKey(getQueryParameter("taskDefinitionKey", query));
}
if(query.getNames().contains("taskDefinitionKeyLike")) {
if(names.contains("taskDefinitionKeyLike")) {
request.setTaskDefinitionKeyLike(getQueryParameter("taskDefinitionKeyLike", query));
}
if(query.getNames().contains("dueDate")) {
if(names.contains("dueDate")) {
request.setDueDate(getQueryParameterAsDate("dueDate", query));
}
if(query.getNames().contains("dueBefore")) {
if(names.contains("dueBefore")) {
request.setDueBefore(getQueryParameterAsDate("dueBefore", query));
}
if(query.getNames().contains("dueAfter")) {
if(names.contains("dueAfter")) {
request.setDueAfter(getQueryParameterAsDate("dueAfter", query));
}
if(query.getNames().contains("active")) {
if(names.contains("active")) {
request.setActive(getQueryParameterAsBoolean("active", query));
}
......
......@@ -21,7 +21,7 @@ import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.RestResponseFactory;
import org.activiti.rest.api.identity.RestIdentityLink;
import org.activiti.rest.api.legacy.identity.LegacyRestIdentityLink;
import org.activiti.rest.application.ActivitiRestServicesApplication;
import org.restlet.data.Status;
import org.restlet.resource.Get;
......@@ -34,11 +34,11 @@ import org.restlet.resource.Post;
public class TaskIdentityLinkCollectionResource extends TaskBaseResource {
@Get
public List<RestIdentityLink> getIdentityLinks() {
public List<LegacyRestIdentityLink> getIdentityLinks() {
if(!authenticate())
return null;
List<RestIdentityLink> result = new ArrayList<RestIdentityLink>();
List<LegacyRestIdentityLink> result = new ArrayList<LegacyRestIdentityLink>();
Task task = getTaskFromRequest();
List<IdentityLink> identityLinks = ActivitiUtil.getTaskService().getIdentityLinksForTask(task.getId());
......@@ -50,7 +50,7 @@ public class TaskIdentityLinkCollectionResource extends TaskBaseResource {
}
@Post
public RestIdentityLink createIdentityLink(RestIdentityLink identityLink) {
public LegacyRestIdentityLink createIdentityLink(LegacyRestIdentityLink identityLink) {
if(!authenticate())
return null;
......
......@@ -23,7 +23,7 @@ import org.activiti.engine.task.Task;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.RestResponseFactory;
import org.activiti.rest.api.RestUrls;
import org.activiti.rest.api.identity.RestIdentityLink;
import org.activiti.rest.api.legacy.identity.LegacyRestIdentityLink;
import org.activiti.rest.application.ActivitiRestServicesApplication;
import org.restlet.data.Status;
import org.restlet.resource.Delete;
......@@ -36,7 +36,7 @@ import org.restlet.resource.Get;
public class TaskIdentityLinkFamilyResource extends TaskBaseResource {
@Get
public List<RestIdentityLink> getIdentityLinksForFamily() {
public List<LegacyRestIdentityLink> getIdentityLinksForFamily() {
if(!authenticate())
return null;
......@@ -51,7 +51,7 @@ public class TaskIdentityLinkFamilyResource extends TaskBaseResource {
}
boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
List<RestIdentityLink> results = new ArrayList<RestIdentityLink>();
List<LegacyRestIdentityLink> results = new ArrayList<LegacyRestIdentityLink>();
RestResponseFactory responseFactory = getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory();
List<IdentityLink> allLinks = ActivitiUtil.getTaskService().getIdentityLinksForTask(task.getId());
......
......@@ -21,7 +21,7 @@ import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.activiti.rest.api.ActivitiUtil;
import org.activiti.rest.api.RestUrls;
import org.activiti.rest.api.identity.RestIdentityLink;
import org.activiti.rest.api.legacy.identity.LegacyRestIdentityLink;
import org.activiti.rest.application.ActivitiRestServicesApplication;
import org.restlet.data.Status;
import org.restlet.resource.Delete;
......@@ -34,7 +34,7 @@ import org.restlet.resource.Get;
public class TaskIdentityLinkResource extends TaskBaseResource {
@Get
public RestIdentityLink getIdentityLink() {
public LegacyRestIdentityLink getIdentityLink() {
if(!authenticate())
return null;
......
......@@ -15,17 +15,8 @@ import org.activiti.rest.api.history.HistoricTaskInstanceQueryResource;
import org.activiti.rest.api.history.HistoricTaskInstanceResource;
import org.activiti.rest.api.history.HistoricVariableInstanceCollectionResource;
import org.activiti.rest.api.history.HistoricVariableInstanceQueryResource;
import org.activiti.rest.api.identity.GroupCreateResource;
import org.activiti.rest.api.identity.GroupResource;
import org.activiti.rest.api.identity.GroupSearchResource;
import org.activiti.rest.api.identity.GroupUsersResource;
import org.activiti.rest.api.identity.LoginResource;
import org.activiti.rest.api.identity.UserCreateResource;
import org.activiti.rest.api.identity.UserGroupsDeleteResource;
import org.activiti.rest.api.identity.UserGroupsResource;
import org.activiti.rest.api.identity.UserPictureResource;
import org.activiti.rest.api.identity.UserCollectionResource;
import org.activiti.rest.api.identity.UserResource;
import org.activiti.rest.api.identity.UserSearchResource;
import org.activiti.rest.api.legacy.LegacyTaskAttachmentResource;
import org.activiti.rest.api.legacy.TaskAddResource;
import org.activiti.rest.api.legacy.TaskAttachmentAddResource;
......@@ -41,6 +32,17 @@ import org.activiti.rest.api.legacy.deployment.DeploymentDeleteResource;
import org.activiti.rest.api.legacy.deployment.DeploymentUploadResource;
import org.activiti.rest.api.legacy.deployment.DeploymentsDeleteResource;
import org.activiti.rest.api.legacy.deployment.DeploymentsResource;
import org.activiti.rest.api.legacy.identity.LegacyGroupCreateResource;
import org.activiti.rest.api.legacy.identity.LegacyGroupResource;
import org.activiti.rest.api.legacy.identity.LegacyGroupSearchResource;
import org.activiti.rest.api.legacy.identity.LegacyGroupUsersResource;
import org.activiti.rest.api.legacy.identity.LegacyLoginResource;
import org.activiti.rest.api.legacy.identity.LegacyUserCreateResource;
import org.activiti.rest.api.legacy.identity.LegacyUserGroupsDeleteResource;
import org.activiti.rest.api.legacy.identity.LegacyUserGroupsResource;
import org.activiti.rest.api.legacy.identity.LegacyUserPictureResource;
import org.activiti.rest.api.legacy.identity.LegacyUserResource;
import org.activiti.rest.api.legacy.identity.LegacyUserSearchResource;
import org.activiti.rest.api.legacy.management.JobExecuteResource;
import org.activiti.rest.api.legacy.management.JobsExecuteResource;
import org.activiti.rest.api.legacy.management.JobsResource;
......@@ -165,6 +167,10 @@ public class RestServicesInit {
router.attach("/management/jobs/{jobId}", JobResource.class);
router.attach("/management/jobs/{jobId}/exception-stacktrace", JobExceptionStacktraceResource.class);
router.attach("/identity/users", UserCollectionResource.class);
router.attach("/identity/users/{userId}", UserResource.class);
router.attach("/query/tasks", TaskQueryResource.class);
router.attach("/query/process-instances", ProcessInstanceQueryResource.class);
router.attach("/query/executions", ExecutionQueryResource.class);
......@@ -177,20 +183,20 @@ public class RestServicesInit {
// Old rest-urls
router.attach("/process-engine", ProcessEngineResource.class);
router.attach("/login", LoginResource.class);
router.attach("/login", LegacyLoginResource.class);
router.attach("/user", UserCreateResource.class);
router.attach("/user/{userId}", UserResource.class);
router.attach("/user/{userId}/groups", UserGroupsResource.class);
router.attach("/user/{userId}/groups/{groupId}", UserGroupsDeleteResource.class);
router.attach("/user/{userId}/picture", UserPictureResource.class);
router.attach("/users", UserSearchResource.class);
router.attach("/user", LegacyUserCreateResource.class);
router.attach("/user/{userId}", LegacyUserResource.class);
router.attach("/user/{userId}/groups", LegacyUserGroupsResource.class);
router.attach("/user/{userId}/groups/{groupId}", LegacyUserGroupsDeleteResource.class);
router.attach("/user/{userId}/picture", LegacyUserPictureResource.class);
router.attach("/users", LegacyUserSearchResource.class);
router.attach("/group", GroupCreateResource.class);
router.attach("/group/{groupId}", GroupResource.class);
router.attach("/group/{groupId}/users/{userId}", UserGroupsDeleteResource.class);
router.attach("/group/{groupId}/users", GroupUsersResource.class);
router.attach("/groups", GroupSearchResource.class);
router.attach("/group", LegacyGroupCreateResource.class);
router.attach("/group/{groupId}", LegacyGroupResource.class);
router.attach("/group/{groupId}/users/{userId}", LegacyUserGroupsDeleteResource.class);
router.attach("/group/{groupId}/users", LegacyGroupUsersResource.class);
router.attach("/groups", LegacyGroupSearchResource.class);
router.attach("/process-definitions", ProcessDefinitionsResource.class);
router.attach("/process-instances", LegacyProcessInstancesResource.class);
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.identity.User;
import org.activiti.engine.test.Deployment;
import org.activiti.rest.BaseRestTestCase;
import org.activiti.rest.api.RestUrls;
/**
* @author Frederik Heremans
*/
public class UserCollectionResourceTest extends BaseRestTestCase {
/**
* Test getting all users.
*/
@Deployment
public void testGetUsers() throws Exception {
List<User> savedUsers = new ArrayList<User>();
try {
User user1 = identityService.newUser("testuser");
user1.setFirstName("Fred");
user1.setLastName("McDonald");
user1.setEmail("no-reply@activiti.org");
identityService.saveUser(user1);
savedUsers.add(user1);
User user2 = identityService.newUser("anotherUser");
user2.setFirstName("Tijs");
user2.setLastName("Barrez");
user2.setEmail("no-reply@alfresco.org");
identityService.saveUser(user2);
savedUsers.add(user2);
User user3 = identityService.createUserQuery().userId("kermit").singleResult();
assertNotNull(user3);
// Test filter-less
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION);
assertResultsPresentInDataResponse(url, user1.getId(), user2.getId(), user3.getId());
// Test based on userId
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?id=testuser";
assertResultsPresentInDataResponse(url, user1.getId());
// Test based on firstName
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?firstName=Tijs";
assertResultsPresentInDataResponse(url, user2.getId());
// Test based on lastName
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?lastName=Barrez";
assertResultsPresentInDataResponse(url, user2.getId());
// Test based on email
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?email=no-reply@activiti.org";
assertResultsPresentInDataResponse(url, user1.getId());
// Test based on firstNameLike
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?firstNameLike=" + encode("%ij%");
assertResultsPresentInDataResponse(url, user2.getId());
// Test based on lastNameLike
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?lastNameLike=" + encode("%rez");
assertResultsPresentInDataResponse(url, user2.getId());
// Test based on emailLike
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?emailLike=" + encode("no-reply@activiti.org%");
assertResultsPresentInDataResponse(url, user1.getId());
// Test based on memberOfGroup
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?memberOfGroup=admin";
assertResultsPresentInDataResponse(url, user3.getId());
// Test based on potentialStarter
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("simpleProcess")
.singleResult().getId();
repositoryService.addCandidateStarterUser(processDefinitionId, "kermit");
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?potentialStarter=" + processDefinitionId;
assertResultsPresentInDataResponse(url, user3.getId());
} finally {
// Delete user after test passes or fails
if(savedUsers.size() > 0) {
for(User user : savedUsers) {
identityService.deleteUser(user.getId());
}
}
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.identity;
import org.activiti.engine.identity.User;
import org.activiti.rest.BaseRestTestCase;
import org.activiti.rest.api.RestUrls;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ObjectNode;
import org.restlet.data.Status;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;
/**
* @author Frederik Heremans
*/
public class UserResourceTest extends BaseRestTestCase {
/**
* Test getting a single user.
*/
public void testGetUser() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER,
newUser.getId()));
Representation response = client.get();
assertEquals(Status.SUCCESS_OK, client.getResponse().getStatus());
JsonNode responseNode = objectMapper.readTree(response.getStream());
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").getTextValue());
assertEquals("Fred", responseNode.get("firstName").getTextValue());
assertEquals("McDonald", responseNode.get("lastName").getTextValue());
assertEquals("no-reply@activiti.org", responseNode.get("email").getTextValue());
assertTrue(responseNode.get("url").getTextValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
} finally {
// Delete user after test passes or fails
if(savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
/**
* Test getting an unexisting user.
*/
public void testGetUnexistingUser() throws Exception {
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, "unexisting"));
try {
client.get();
fail("Exception expected");
} catch(ResourceException expected) {
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, expected.getStatus());
assertEquals("Could not find a user with id 'unexisting'.", expected.getStatus().getDescription());
}
}
/**
* Test deleting a single user.
*/
public void testDeleteUser() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER,
newUser.getId()));
Representation response = client.delete();
assertEquals(Status.SUCCESS_NO_CONTENT, client.getResponse().getStatus());
assertEquals(0L, response.getSize());
// Check if user is deleted
assertEquals(0, identityService.createUserQuery().userId(newUser.getId()).count());
savedUser = null;
} finally {
// Delete user after test fails
if(savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
/**
* Test deleting an unexisting user.
*/
public void testDeleteUnexistingUser() throws Exception {
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, "unexisting"));
try {
client.delete();
fail("Exception expected");
} catch(ResourceException expected) {
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, expected.getStatus());
assertEquals("Could not find a user with id 'unexisting'.", expected.getStatus().getDescription());
}
}
/**
* Test updating a single user.
*/
public void testUpdateUser() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
taskUpdateRequest.put("firstName", "Tijs");
taskUpdateRequest.put("lastName", "Barrez");
taskUpdateRequest.put("email", "no-reply@alfresco.org");
taskUpdateRequest.put("password", "updatedpassword");
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER,
newUser.getId()));
Representation response = client.put(taskUpdateRequest);
assertEquals(Status.SUCCESS_OK, client.getResponse().getStatus());
JsonNode responseNode = objectMapper.readTree(response.getStream());
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").getTextValue());
assertEquals("Tijs", responseNode.get("firstName").getTextValue());
assertEquals("Barrez", responseNode.get("lastName").getTextValue());
assertEquals("no-reply@alfresco.org", responseNode.get("email").getTextValue());
assertTrue(responseNode.get("url").getTextValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertEquals("Barrez", newUser.getLastName());
assertEquals("Tijs", newUser.getFirstName());
assertEquals("no-reply@alfresco.org", newUser.getEmail());
assertEquals("updatedpassword", newUser.getPassword());
} finally {
// Delete user after test fails
if(savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
/**
* Test updating a single user passing in no fields in the json, user should remain unchanged.
*/
public void testUpdateUserNoFields() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER,
newUser.getId()));
Representation response = client.put(taskUpdateRequest);
assertEquals(Status.SUCCESS_OK, client.getResponse().getStatus());
JsonNode responseNode = objectMapper.readTree(response.getStream());
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").getTextValue());
assertEquals("Fred", responseNode.get("firstName").getTextValue());
assertEquals("McDonald", responseNode.get("lastName").getTextValue());
assertEquals("no-reply@activiti.org", responseNode.get("email").getTextValue());
assertTrue(responseNode.get("url").getTextValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertEquals("McDonald", newUser.getLastName());
assertEquals("Fred", newUser.getFirstName());
assertEquals("no-reply@activiti.org", newUser.getEmail());
assertNull(newUser.getPassword());
} finally {
// Delete user after test fails
if(savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
/**
* Test updating a single user passing in no fields in the json, user should remain unchanged.
*/
public void testUpdateUserNullFields() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
taskUpdateRequest.putNull("firstName");
taskUpdateRequest.putNull("lastName");
taskUpdateRequest.putNull("email");
taskUpdateRequest.putNull("password");
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER,
newUser.getId()));
Representation response = client.put(taskUpdateRequest);
assertEquals(Status.SUCCESS_OK, client.getResponse().getStatus());
JsonNode responseNode = objectMapper.readTree(response.getStream());
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").getTextValue());
assertTrue(responseNode.get("firstName").isNull());
assertTrue(responseNode.get("lastName").isNull());
assertTrue(responseNode.get("email").isNull());
assertTrue(responseNode.get("url").getTextValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertNull(newUser.getLastName());
assertNull(newUser.getFirstName());
assertNull(newUser.getEmail());
} finally {
// Delete user after test fails
if(savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
/**
* Test updating an unexisting user.
*/
public void testUpdateUnexistingUser() throws Exception {
ClientResource client = getAuthenticatedClient(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, "unexisting"));
try {
client.put(objectMapper.createObjectNode());
fail("Exception expected");
} catch(ResourceException expected) {
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, expected.getStatus());
assertEquals("Could not find a user with id 'unexisting'.", expected.getStatus().getDescription());
}
}
}
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
......
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
......
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.restlet.data.Status;
......
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
......
package org.activiti.rest.api.identity;
package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
......
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="simpleProcess" name="Simple process" isExecutable="true">
<startEvent id="start" name="Start JUnit"></startEvent>
<sequenceFlow id="flow1" name="" sourceRef="start" targetRef="waitTask"></sequenceFlow>
<userTask id="waitTask" name="WaitTask" activiti:assignee="me" />
<sequenceFlow id="flow2" sourceRef="waitTask" targetRef="anotherTask"></sequenceFlow>
<userTask id="anotherTask" name="AnotherTask" activiti:assignee="me" />
<sequenceFlow id="flow3" sourceRef="anotherTask" targetRef="end"></sequenceFlow>
<endEvent id="end" name="End JUnit"></endEvent>
</process>
</definitions>
\ No newline at end of file
......@@ -4258,7 +4258,7 @@ Only the attachment name is required to create a new attachment.
</thead>
<tbody>
<row>
<entry>jobId</entry>
<entry>id</entry>
<entry>Only return job with the given id</entry>
<entry>String</entry>
</row>
......@@ -4379,10 +4379,305 @@ Only the attachment name is required to create a new attachment.
</table>
</para>
</section>
</section>
<section>
<title>Users</title>
<section>
<title>Get a single user</title>
<para>
<programlisting>GET identity/users/{userId}</programlisting>
</para>
<para>
<table>
<title>URL parameters</title>
<tgroup cols='3'>
<thead>
<row>
<entry>Parameter</entry>
<entry>Required</entry>
<entry>Value</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>userId</entry>
<entry>Yes</entry>
<entry>String</entry>
<entry>The id of the user to get.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<emphasis role="bold">Success response body:</emphasis>
<programlisting>
{
"id":"testuser",
"firstName":"Fred",
"lastName":"McDonald",
"url":"http://localhost:8182/identity/users/testuser",
"email":"no-reply@activiti.org"
}</programlisting>
<table>
<title>Response codes</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Response code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>200</entry>
<entry>Indicates the user exists and is returned.</entry>
</row>
<row>
<entry>404</entry>
<entry>Indicates the requested user does not exist.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
<section>
<title>Get a list of users</title>
<para>
<programlisting>GET identity/users</programlisting>
</para>
<para>
<table>
<title>URL query parameters</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Parameter</entry>
<entry>Description</entry>
<entry>Type</entry>
</row>
</thead>
<tbody>
<row>
<entry>id</entry>
<entry>Only return user with the given id</entry>
<entry>String</entry>
</row>
<row>
<entry>firstName</entry>
<entry>Only return users with the given firstname</entry>
<entry>String</entry>
</row>
<row>
<entry>lastName</entry>
<entry>Only return users with the given lastname</entry>
<entry>String</entry>
</row>
<row>
<entry>email</entry>
<entry>Only return users with the given email</entry>
<entry>String</entry>
</row>
<row>
<entry>firstNameLike</entry>
<entry>Only return userswith a firstname like the given value. Use <literal>%</literal> as wildcard-character.</entry>
<entry>String</entry>
</row>
<row>
<entry>lastNameLike</entry>
<entry>Only return users with a lastname like the given value. Use <literal>%</literal> as wildcard-character.</entry>
<entry>String</entry>
</row>
<row>
<entry>emailLike</entry>
<entry>Only return users with an email like the given value. Use <literal>%</literal> as wildcard-character.</entry>
<entry>String</entry>
</row>
<row>
<entry>memberOfGroup</entry>
<entry>Only return users which are a member of the given group.</entry>
<entry>String</entry>
</row>
<row>
<entry>potentialStarter</entry>
<entry>Only return users which are potential starters for a process-definition with the given id.</entry>
<entry>String</entry>
</row>
<row>
<entry>sort</entry>
<entry>Field to sort results on, should be one of <literal>id</literal>, <literal>firstName</literal>, <literal>lastname</literal> or <literal>email</literal>.</entry>
<entry>String</entry>
</row>
<row>
<entry namest="c1" nameend="c3"><para>The general <link linkend="restPagingAndSort">paging and sorting query-parameters</link> can be used for this URL.</para></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<emphasis role="bold">Success response body:</emphasis>
<programlisting>
{
"data":[
{
"id":"anotherUser",
"firstName":"Tijs",
"lastName":"Barrez",
"url":"http://localhost:8182/identity/users/anotherUser",
"email":"no-reply@alfresco.org"
},
{
"id":"kermit",
"firstName":"Kermit",
"lastName":"the Frog",
"url":"http://localhost:8182/identity/users/kermit",
"email":null
},
{
"id":"testuser",
"firstName":"Fred",
"lastName":"McDonald",
"url":"http://localhost:8182/identity/users/testuser",
"email":"no-reply@activiti.org"
}
],
"total":3,
"start":0,
"sort":"id",
"order":"asc",
"size":3
}</programlisting>
<table>
<title>Response codes</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Response code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>200</entry>
<entry>Indicates the requested users were returned.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
<section>
<title>Update a user</title>
<para>
<programlisting>PUT identity/users/{userId}</programlisting>
</para>
<para>
<emphasis role="bold">Body JSON:</emphasis>
<programlisting>
{
"firstName":"Tijs",
"lastName":"Barrez",
"url":"http://localhost:8182/identity/users/anotherUser",
"email":"no-reply@alfresco.org"
}</programlisting>
All request values are optional. For example, you can only include the 'firstName' attribute in the request body JSON-object, only updating the firstName of the user, leaving all other fields unaffected. When an attribute is explicitly included and is set to null, the user-value will be updated to null. Example: <literal>{"firstName" : null}</literal> will clear the firstName of the user).
</para>
<para>
<table>
<title>Response codes</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Response code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>200</entry>
<entry>Indicates the user was updated.</entry>
</row>
<row>
<entry>404</entry>
<entry>Indicates the requested user was not found.</entry>
</row>
<row>
<entry>409</entry>
<entry>Indicates the requested user was updated simultaneously.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<emphasis role="bold">Success response body:</emphasis> see response for <literal>runtime/tasks/{taskId}</literal>.
</para>
</section>
<section>
<title>Delete a user</title>
<para>
<programlisting>DELETE identity/users/{userId}</programlisting>
</para>
<para>
<table>
<title>URL parameters</title>
<tgroup cols='3'>
<thead>
<row>
<entry>Parameter</entry>
<entry>Required</entry>
<entry>Value</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>userId</entry>
<entry>Yes</entry>
<entry>String</entry>
<entry>The id of the user to delete.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Response codes</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Response code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>204</entry>
<entry>Indicates the user was found and has been deleted. Response-body is intentionally empty.</entry>
</row>
<row>
<entry>404</entry>
<entry>Indicates the requested user was not found.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
</section>
<!-- Legacy -->
<section>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册