Skip to content

Commit

Permalink
Some utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Nov 12, 2013
1 parent 189218b commit 297beab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/net/tirasa/syncoperestclient/App.java
Expand Up @@ -11,6 +11,7 @@
import org.apache.syncope.client.SyncopeClient;
import org.apache.syncope.client.SyncopeClientFactoryBean;
import org.apache.syncope.common.mod.AttributeMod;
import org.apache.syncope.common.mod.UserMod;
import org.apache.syncope.common.services.ConfigurationService;
import org.apache.syncope.common.services.ConnectorService;
import org.apache.syncope.common.services.EntitlementService;
Expand All @@ -33,6 +34,7 @@
import org.apache.syncope.common.to.AbstractTaskTO;
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.RESTHeaders;
import org.apache.syncope.common.types.SchemaType;

public class App {
Expand Down Expand Up @@ -211,6 +213,19 @@ private static UserTO createUser(final UserTO userTO) {
return response.readEntity(UserTO.class);
}

private static UserTO readUser(final String username) {
return userService.read(Long.valueOf(
userService.getUserId(username).getHeaderString(RESTHeaders.USER_ID.toString())));
}

private static UserTO updateUser(final UserMod userMod) {
return userService.update(userMod.getId(), userMod).readEntity(UserTO.class);
}

private static UserTO deleteUser(final Long id) {
return userService.delete(id).readEntity(UserTO.class);
}

private static RoleTO createRole(final RoleTO roleTO) {
final Response response = client.getService(RoleService.class).create(roleTO);
if (response.getStatus() != Response.Status.CREATED.getStatusCode()) {
Expand Down

0 comments on commit 297beab

Please sign in to comment.