diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java
index baab23a0b5e426448a4c4448337c26e6469f3006..0a2e747828c87deffe5d4c741a1764f566ebdf3b 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java
@@ -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());
}
+
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
index 3e07d47948f661af106faefd9ac6a98fea6ad68b..c0cc3eec3f0134f278dbf36d7f823e1790e02648 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
@@ -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: repository/deployments
@@ -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: identity/users
+ */
+ public static final String[] URL_USER_COLLECTION = {SEGMENT_IDENTITY_RESOURCES, SEGMENT_USERS};
+
+ /**
+ * URL template for a single user: identity/users/{0:userId}
+ */
+ 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
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/StateResponse.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/StateResponse.java
deleted file mode 100644
index 65b1f84257e9bb4f066eb0682db4a5791f62c8ae..0000000000000000000000000000000000000000
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/StateResponse.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.activiti.rest.api.identity;
-
-public class StateResponse {
-
- boolean success;
-
- public boolean isSuccess() {
- return success;
- }
-
- public StateResponse setSuccess(boolean success) {
- this.success = success;
- return this;
- }
-}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCollectionResource.java
new file mode 100644
index 0000000000000000000000000000000000000000..961b5f29817e335134aedae6951ed183036d8451
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCollectionResource.java
@@ -0,0 +1,110 @@
+/* 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 properties = new HashMap();
+
+ 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 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);
+ }
+
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPaginateList.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPaginateList.java
new file mode 100644
index 0000000000000000000000000000000000000000..5f096ceaae6b6a12fe05e8a59da5153dc537471e
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPaginateList.java
@@ -0,0 +1,46 @@
+/* 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 responseList = new ArrayList();
+ RestResponseFactory restResponseFactory = resource.getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory();
+ for (Object user : list) {
+ responseList.add(restResponseFactory.createUserResponse(resource, (User) user, false));
+ }
+ return responseList;
+ }
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserRequest.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserRequest.java
new file mode 100644
index 0000000000000000000000000000000000000000..60636972b2039ad5e671684ad7a03eb009cd8a60
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserRequest.java
@@ -0,0 +1,66 @@
+/* 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;
+ }
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResource.java
index f9e2b872882e265f6030772e37acd4cef3100fc7..d778663d1020d246613cc56709a2932fca576fa1 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResource.java
@@ -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;
+ }
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResponse.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResponse.java
new file mode 100644
index 0000000000000000000000000000000000000000..394f522c2d6a2b547696ca4a0c6ae0e3d843b457
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserResponse.java
@@ -0,0 +1,81 @@
+/* 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;
+ }
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupCreateResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupCreateResource.java
similarity index 88%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupCreateResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupCreateResource.java
index 69529ec930ef3b39cfef8129b1da308bdd6bebd2..dce959126630dc0588541163abaa918d36a43eec 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupCreateResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupCreateResource.java
@@ -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);
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupInfo.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupInfo.java
similarity index 78%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupInfo.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupInfo.java
index e26be1eed0a97eeffb8fc51af7d1036b8201d834..7e373a732ece7376544f6a5378b551d910308c14 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupInfo.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupInfo.java
@@ -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;
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupResource.java
similarity index 84%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupResource.java
index 9d98c8348b2f05e65cf9e8391a72128df3765347..06c14c0d69e948cb1eb9845531b92a50a82d229b 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupResource.java
@@ -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);
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupSearchResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupSearchResource.java
similarity index 84%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupSearchResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupSearchResource.java
index 6d31705d15014614cb9f8e986d2041d40971c9be..7598b3cac32b6b3778303bdc0c5acd22a1f4afee 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupSearchResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupSearchResource.java
@@ -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 groups = ActivitiUtil.getIdentityService().createGroupQuery().list();
- List groupList = new ArrayList();
+ List groupList = new ArrayList();
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 {
+ protected class GroupResponseComparable implements Comparator {
- public int compare(GroupInfo group1, GroupInfo group2) {
+ public int compare(LegacyGroupInfo group1, LegacyGroupInfo group2) {
return group1.getName().compareTo(group2.getName());
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersPaginateList.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersPaginateList.java
similarity index 78%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersPaginateList.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersPaginateList.java
index 37c1a283186db17475f85e8760a522a5f2a460b1..4ce4d8b53d63a593f67d5f665b19b6e69f8972f9 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersPaginateList.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersPaginateList.java
@@ -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 responseList = new ArrayList();
+ List responseList = new ArrayList();
for (Object definition : list) {
- UserInfo response = new UserInfo((User) definition);
+ LegacyUserInfo response = new LegacyUserInfo((User) definition);
responseList.add(response);
}
return responseList;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersResource.java
similarity index 89%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersResource.java
index 882487d1e413f8eb684fa9472e52aa000118766b..3d9e5834f4d653751022efab5573cdb13b540be8 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/GroupUsersResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyGroupUsersResource.java
@@ -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 properties = new HashMap();
- 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 userIds) {
+ public LegacyStateResponse setUsers(ArrayList 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);
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginInfo.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginInfo.java
similarity index 92%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginInfo.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginInfo.java
index 71b326ac01d7f47c6b1cec0aac98696d062b18ef..fec758251f66af7806d43810156653536b9ef106 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginInfo.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginInfo.java
@@ -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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResource.java
similarity index 92%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResource.java
index 8d6d4638abdc55a17baf492db6eb321bfa688e49..3e8a6ef58749879cb18278a46580e03f1d40bc16 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResource.java
@@ -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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResponse.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResponse.java
similarity index 83%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResponse.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResponse.java
index 3cb00cbd5af34d99c8da6ae12fdb18e40c8a1c7f..c06d56af0d2ce93beb9eea198ef6223e52fc57cf 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/LoginResponse.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyLoginResponse.java
@@ -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;
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/RestIdentityLink.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyRestIdentityLink.java
similarity index 93%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/RestIdentityLink.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyRestIdentityLink.java
index d0ba1486cd319090519aaeefaf8ff90260db0d6b..1ac08fca16f3a5d2c8e4c2191ca486bfe15ac4aa 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/RestIdentityLink.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyRestIdentityLink.java
@@ -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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyStateResponse.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyStateResponse.java
new file mode 100644
index 0000000000000000000000000000000000000000..8143cf79553caab0ed5abfaedb43cd1c5f152802
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyStateResponse.java
@@ -0,0 +1,15 @@
+package org.activiti.rest.api.legacy.identity;
+
+public class LegacyStateResponse {
+
+ boolean success;
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public LegacyStateResponse setSuccess(boolean success) {
+ this.success = success;
+ return this;
+ }
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCreateResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserCreateResource.java
similarity index 87%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCreateResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserCreateResource.java
index 48b69afe817412e230c17bcd86f929caea224137..0a2ccb13370dee15177467eca929fa7fc90d6686 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserCreateResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserCreateResource.java
@@ -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);
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsDeleteResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsDeleteResource.java
similarity index 82%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsDeleteResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsDeleteResource.java
index 7c3107888e0a528cfc69e6ed0cbfd429af67a353..97d08b09d553989b67126776d83832da47872c96 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsDeleteResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsDeleteResource.java
@@ -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
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsPaginateList.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsPaginateList.java
similarity index 78%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsPaginateList.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsPaginateList.java
index e3fb13fe1c9f0ff9f9095d03784140abc856a4da..0f95479b625450064d404bf04f10975621a6b062 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsPaginateList.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsPaginateList.java
@@ -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 groupList = new ArrayList();
+ List groupList = new ArrayList();
for (Object instance : list) {
- groupList.add(new GroupInfo((Group) instance));
+ groupList.add(new LegacyGroupInfo((Group) instance));
}
return groupList;
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsResource.java
similarity index 89%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsResource.java
index 7e2aa00e8146a513ad78992dbdf75c1ef8af2a8b..319d64e9c6a1d290ea7424209836e6591f9a4650 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserGroupsResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserGroupsResource.java
@@ -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 properties = new HashMap();
- 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 groupIds) {
+ public LegacyStateResponse setGroups(ArrayList 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);
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfo.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfo.java
similarity index 78%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfo.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfo.java
index 0c75ff6efce10a871e695599faa0fd841b85aa99..491347dbd4b5a25dbab39159f57fc6f710e3a955 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfo.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfo.java
@@ -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;
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfoWithPassword.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfoWithPassword.java
similarity index 87%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfoWithPassword.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfoWithPassword.java
index 11569f65eae604103d0ad508b3c235a303237bfb..1eae89cdca336725351ae897f167c581b446998e 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserInfoWithPassword.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserInfoWithPassword.java
@@ -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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPictureResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserPictureResource.java
similarity index 94%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPictureResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserPictureResource.java
index d644eb0951cef56a02f9ca512a4295e4707dfc8e..35facad949fb5ac75aef2a95e24b946f319d214e 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserPictureResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserPictureResource.java
@@ -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() {
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserResource.java
new file mode 100644
index 0000000000000000000000000000000000000000..382935a497d12aa36c74205d25043ad4d0917453
--- /dev/null
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserResource.java
@@ -0,0 +1,40 @@
+/* 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;
+ }
+
+}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserSearchResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserSearchResource.java
similarity index 81%
rename from modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserSearchResource.java
rename to modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserSearchResource.java
index 7436a510e8acbfd90c4320e92290de3c94d1f86a..c0c05e385fb3bc3e65731be0bacffb30cacb9e32 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/identity/UserSearchResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/identity/LegacyUserSearchResource.java
@@ -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 firstNameMatchList = ActivitiUtil.getIdentityService().createUserQuery().userFirstNameLike(searchText).list();
List lastNameMatchList = ActivitiUtil.getIdentityService().createUserQuery().userLastNameLike(searchText).list();
- Map userMap = new HashMap();
+ Map userMap = new HashMap();
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 userList = new ArrayList();
+ List userList = new ArrayList();
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{
+ protected class UserResponseComparable implements Comparator{
- public int compare(UserInfo user1, UserInfo user2) {
+ public int compare(LegacyUserInfo user1, LegacyUserInfo user2) {
return user1.getLastName().compareTo(user2.getLastName());
}
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobCollectionResource.java
index bf51f7708c5688c2e0fd96adfb120844ad5e05af..e7474d9443c27cfb8ae90945f54438e98cc16cea 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobCollectionResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobCollectionResource.java
@@ -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 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));
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/DeploymentCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/DeploymentCollectionResource.java
index 4571d2fcd476e61b8d5494007bf33e52423ed486..e830a4777f1a9c44525698b6e74e018b56b36e86 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/DeploymentCollectionResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/DeploymentCollectionResource.java
@@ -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 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));
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/ProcessDefinitionCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/ProcessDefinitionCollectionResource.java
index 8d7a73fb40e4cb107d7131bcb9aa462baef3fb49..9772b19d4ac6eee9def802275dfedb0867f1320f 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/ProcessDefinitionCollectionResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/repository/ProcessDefinitionCollectionResource.java
@@ -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 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));
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskCollectionResource.java
index 5a564293532ee5eb9b05b90e8106cf6357b0b5c8..d1d640ead310022743aef264c37c409b14b2555c 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskCollectionResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskCollectionResource.java
@@ -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 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));
}
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkCollectionResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkCollectionResource.java
index a5d5e8d94a75182d40fbb0869a208328564bcfbd..90271dd3c55ad1faccebbb8366da41b34944a71c 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkCollectionResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkCollectionResource.java
@@ -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 getIdentityLinks() {
+ public List getIdentityLinks() {
if(!authenticate())
return null;
- List result = new ArrayList();
+ List result = new ArrayList();
Task task = getTaskFromRequest();
List 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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkFamilyResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkFamilyResource.java
index 59118a2e7ada86d520e7a87502c7e5c7fd022f27..fc7ecba5bab0bb563bfde3354f0778f850f905bc 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkFamilyResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkFamilyResource.java
@@ -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 getIdentityLinksForFamily() {
+ public List getIdentityLinksForFamily() {
if(!authenticate())
return null;
@@ -51,7 +51,7 @@ public class TaskIdentityLinkFamilyResource extends TaskBaseResource {
}
boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
- List results = new ArrayList();
+ List results = new ArrayList();
RestResponseFactory responseFactory = getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory();
List allLinks = ActivitiUtil.getTaskService().getIdentityLinksForTask(task.getId());
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkResource.java b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkResource.java
index 276f847d43f6cbb94ba1298875a2527a35af40de..bb9b2e7892d35b4925dff2527a9e660a4b46d440 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkResource.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/api/runtime/task/TaskIdentityLinkResource.java
@@ -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;
diff --git a/modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java b/modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java
index ae64f64545ff05abdba4d71f44646a277499be06..51d2329ee43bee3e4841419e0b61e07a6e7a9407 100644
--- a/modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java
+++ b/modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java
@@ -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);
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserCollectionResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserCollectionResourceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d10a07a7e91c926ce71fc856c74f51b612d01d49
--- /dev/null
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserCollectionResourceTest.java
@@ -0,0 +1,109 @@
+/* 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 savedUsers = new ArrayList();
+ 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());
+ }
+ }
+ }
+ }
+}
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserResourceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..00b32f20e54df02371103ab47aa9f93eb97e83a2
--- /dev/null
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserResourceTest.java
@@ -0,0 +1,285 @@
+/* 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());
+ }
+ }
+}
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupSearchResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupSearchResourceTest.java
similarity index 96%
rename from modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupSearchResourceTest.java
rename to modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupSearchResourceTest.java
index 99216f4022822a683294d724cd582850fbcca086..e6deda5eaf43b685c4b4a6b547af86d4f4e78df3 100644
--- a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupSearchResourceTest.java
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupSearchResourceTest.java
@@ -1,4 +1,4 @@
-package org.activiti.rest.api.identity;
+package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupUsersResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupUsersResourceTest.java
similarity index 94%
rename from modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupUsersResourceTest.java
rename to modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupUsersResourceTest.java
index a2ac6ef3a4bf33acf1597742f7cc9c5d79e08e16..ba270af6e2355ac0513e55fb9c154c5f376e28d3 100644
--- a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/GroupUsersResourceTest.java
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/GroupUsersResourceTest.java
@@ -1,4 +1,4 @@
-package org.activiti.rest.api.identity;
+package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/LoginResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/LoginResourceTest.java
similarity index 93%
rename from modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/LoginResourceTest.java
rename to modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/LoginResourceTest.java
index 6aca7e18dcc79e5281b5759292dfd7dae6d09424..b0a2d5833ec599bf6df0673071b1f2300ef2d0f9 100644
--- a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/LoginResourceTest.java
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/LoginResourceTest.java
@@ -1,4 +1,4 @@
-package org.activiti.rest.api.identity;
+package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.restlet.data.Status;
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserGroupsResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserGroupsResourceTest.java
similarity index 94%
rename from modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserGroupsResourceTest.java
rename to modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserGroupsResourceTest.java
index 0c5c2f5b64ddab61909d29d5f83d27a60b346e18..f9c01834d8e1456aabf9b84ad5b50bcba2930552 100644
--- a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserGroupsResourceTest.java
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserGroupsResourceTest.java
@@ -1,4 +1,4 @@
-package org.activiti.rest.api.identity;
+package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
diff --git a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserSearchResourceTest.java b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserSearchResourceTest.java
similarity index 95%
rename from modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserSearchResourceTest.java
rename to modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserSearchResourceTest.java
index 90f80cf776575b5bfa8036004b101face691866f..bedfc4af097b77a4f5b34680af4f269f3366a0ba 100644
--- a/modules/activiti-rest/src/test/java/org/activiti/rest/api/identity/UserSearchResourceTest.java
+++ b/modules/activiti-rest/src/test/java/org/activiti/rest/api/legacy/UserSearchResourceTest.java
@@ -1,4 +1,4 @@
-package org.activiti.rest.api.identity;
+package org.activiti.rest.api.legacy;
import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
diff --git a/modules/activiti-rest/src/test/resources/org/activiti/rest/api/identity/UserCollectionResourceTest.testGetUsers.bpmn20.xml b/modules/activiti-rest/src/test/resources/org/activiti/rest/api/identity/UserCollectionResourceTest.testGetUsers.bpmn20.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9b59f54a28b39f65ea921f2becc1c0c80e62ef29
--- /dev/null
+++ b/modules/activiti-rest/src/test/resources/org/activiti/rest/api/identity/UserCollectionResourceTest.testGetUsers.bpmn20.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/userguide/src/en/chapters/ch14-REST.xml b/userguide/src/en/chapters/ch14-REST.xml
index d987f495f0e35deb7cdf1b9514a86e20cfc39be8..1c6ec9adbd7df6ac3587f9be73c001a92e1eece7 100644
--- a/userguide/src/en/chapters/ch14-REST.xml
+++ b/userguide/src/en/chapters/ch14-REST.xml
@@ -4258,7 +4258,7 @@ Only the attachment name is required to create a new attachment.
- jobId
+ id
Only return job with the given id
String
@@ -4379,10 +4379,305 @@ Only the attachment name is required to create a new attachment.
-
+
+ Users
+
+
+ Get a single user
+
+ GET identity/users/{userId}
+
+
+
+ URL parameters
+
+
+
+ Parameter
+ Required
+ Value
+ Description
+
+
+
+
+ userId
+ Yes
+ String
+ The id of the user to get.
+
+
+
+
+
+
+ Success response body:
+
+{
+ "id":"testuser",
+ "firstName":"Fred",
+ "lastName":"McDonald",
+ "url":"http://localhost:8182/identity/users/testuser",
+ "email":"no-reply@activiti.org"
+}
+
+ Response codes
+
+
+
+ Response code
+ Description
+
+
+
+
+ 200
+ Indicates the user exists and is returned.
+
+
+ 404
+ Indicates the requested user does not exist.
+
+
+
+
+
+
+
+
+ Get a list of users
+
+ GET identity/users
+
+
+
+ URL query parameters
+
+
+
+ Parameter
+ Description
+ Type
+
+
+
+
+ id
+ Only return user with the given id
+ String
+
+
+ firstName
+ Only return users with the given firstname
+ String
+
+
+ lastName
+ Only return users with the given lastname
+ String
+
+
+ email
+ Only return users with the given email
+ String
+
+
+ firstNameLike
+ Only return userswith a firstname like the given value. Use % as wildcard-character.
+ String
+
+
+ lastNameLike
+ Only return users with a lastname like the given value. Use % as wildcard-character.
+ String
+
+
+ emailLike
+ Only return users with an email like the given value. Use % as wildcard-character.
+ String
+
+
+ memberOfGroup
+ Only return users which are a member of the given group.
+ String
+
+
+ potentialStarter
+ Only return users which are potential starters for a process-definition with the given id.
+ String
+
+
+ sort
+ Field to sort results on, should be one of id , firstName , lastname or email .
+ String
+
+
+ The general paging and sorting query-parameters can be used for this URL.
+
+
+
+
+
+
+ Success response body:
+
+{
+ "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
+}
+
+ Response codes
+
+
+
+ Response code
+ Description
+
+
+
+
+ 200
+ Indicates the requested users were returned.
+
+
+
+
+
+
+
+
+ Update a user
+
+ PUT identity/users/{userId}
+
+
+ Body JSON:
+
+{
+ "firstName":"Tijs",
+ "lastName":"Barrez",
+ "url":"http://localhost:8182/identity/users/anotherUser",
+ "email":"no-reply@alfresco.org"
+}
+ 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: {"firstName" : null} will clear the firstName of the user).
+
+
+
+ Response codes
+
+
+
+ Response code
+ Description
+
+
+
+
+ 200
+ Indicates the user was updated.
+
+
+ 404
+ Indicates the requested user was not found.
+
+
+ 409
+ Indicates the requested user was updated simultaneously.
+
+
+
+
+
+
+ Success response body: see response for runtime/tasks/{taskId} .
+
+
+
+
+ Delete a user
+
+ DELETE identity/users/{userId}
+
+
+
+ URL parameters
+
+
+
+ Parameter
+ Required
+ Value
+ Description
+
+
+
+
+ userId
+ Yes
+ String
+ The id of the user to delete.
+
+
+
+
+
+
+
+ Response codes
+
+
+
+ Response code
+ Description
+
+
+
+
+ 204
+ Indicates the user was found and has been deleted. Response-body is intentionally empty.
+
+
+ 404
+ Indicates the requested user was not found.
+
+
+
+
+
+
+
+
+
+