Updated with grouping changes

charithag 9 years ago
parent c3835a1992
commit e7069e2d83

@ -31,7 +31,16 @@ import org.wso2.carbon.device.mgt.group.core.providers.GroupManagementServicePro
import javax.jws.WebService; import javax.jws.WebService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Date; import java.util.Date;
@ -40,11 +49,6 @@ import java.util.List;
@WebService @WebService
public class GroupManagerService { public class GroupManagerService {
private static Log log = LogFactory.getLog(GroupManagerService.class);
@Context //injected response proxy supporting multiple threads
private HttpServletResponse response;
private static final String DEFAULT_ADMIN_ROLE = "admin"; private static final String DEFAULT_ADMIN_ROLE = "admin";
private static final String DEFAULT_OPERATOR_ROLE = "invoke-device-operations"; private static final String DEFAULT_OPERATOR_ROLE = "invoke-device-operations";
private static final String DEFAULT_STATS_MONITOR_ROLE = "view-statistics"; private static final String DEFAULT_STATS_MONITOR_ROLE = "view-statistics";
@ -58,7 +62,9 @@ public class GroupManagerService {
private static final String[] DEFAULT_MANAGE_POLICIES_PERMISSIONS = {"/permission/device-mgt/user/groups/device_policies/add"}; private static final String[] DEFAULT_MANAGE_POLICIES_PERMISSIONS = {"/permission/device-mgt/user/groups/device_policies/add"};
private static final String[] DEFAULT_VIEW_POLICIES_PERMISSIONS = {"/permission/device-mgt/user/groups/device_policies/view"}; private static final String[] DEFAULT_VIEW_POLICIES_PERMISSIONS = {"/permission/device-mgt/user/groups/device_policies/view"};
private static final String[] DEFAULT_VIEW_EVENTS_PERMISSIONS = {"/permission/device-mgt/user/groups/device_events"}; private static final String[] DEFAULT_VIEW_EVENTS_PERMISSIONS = {"/permission/device-mgt/user/groups/device_events"};
private static Log log = LogFactory.getLog(GroupManagerService.class);
@Context //injected response proxy supporting multiple threads
private HttpServletResponse response;
private PrivilegedCarbonContext ctx; private PrivilegedCarbonContext ctx;
private GroupManagementServiceProvider getServiceProvider() { private GroupManagementServiceProvider getServiceProvider() {
@ -126,7 +132,6 @@ public class GroupManagerService {
response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); response.setStatus(Response.Status.FORBIDDEN.getStatusCode());
return false; return false;
} }
boolean isUpdated = false;
try { try {
GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); GroupManagementServiceProvider groupManagementService = this.getServiceProvider();
DeviceGroup group = groupManagementService.getGroup(groupId); DeviceGroup group = groupManagementService.getGroup(groupId);
@ -135,14 +140,15 @@ public class GroupManagerService {
group.setOwner(username); group.setOwner(username);
group.setDateOfLastUpdate(new Date().getTime()); group.setDateOfLastUpdate(new Date().getTime());
response.setStatus(Response.Status.OK.getStatusCode()); response.setStatus(Response.Status.OK.getStatusCode());
isUpdated = groupManagementService.updateGroup(group); groupManagementService.updateGroup(group);
return true;
} catch (GroupManagementException e) { } catch (GroupManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.error(e.getErrorMessage(), e); log.error(e.getErrorMessage(), e);
return false;
} finally { } finally {
this.endTenantFlow(); this.endTenantFlow();
} }
return isUpdated;
} }
@Path("/group/id/{groupId}") @Path("/group/id/{groupId}")

Loading…
Cancel
Save