forked from community/device-mgt-core
commit
33bb9b5a14
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceGroupList extends BasePaginatedResult {
|
||||
|
||||
@ApiModelProperty(value = "List of device groups returned")
|
||||
@JsonProperty("groups")
|
||||
private List<?> deviceGroups = new ArrayList<>();
|
||||
|
||||
public List<?> getList() {
|
||||
return deviceGroups;
|
||||
}
|
||||
|
||||
public void setList(List<?> deviceGroups) {
|
||||
this.deviceGroups = deviceGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{\n");
|
||||
sb.append(" count: ").append(getCount()).append(",\n");
|
||||
sb.append(" groups: [").append(deviceGroups).append("\n");
|
||||
sb.append("]}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* This class holds Device Group user name and assigned roles of user for particular group. Exposed to external access.
|
||||
*/
|
||||
@ApiModel(value = "DeviceGroupShare", description = "This class carries roles assigned to a user of a managed device group.")
|
||||
public class DeviceGroupShare implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1998141711L;
|
||||
|
||||
@ApiModelProperty(name = "username", value = "Username of the user.", required = true)
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(name = "roles", value = "List of roles assigned to user from the group.")
|
||||
private List<String> groupRoles;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public List<String> getGroupRoles() {
|
||||
return groupRoles;
|
||||
}
|
||||
|
||||
public void setGroupRoles(List<String> groupRoles) {
|
||||
this.groupRoles = groupRoles;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceGroupUsersList extends BasePaginatedResult {
|
||||
|
||||
@ApiModelProperty(value = "List of device group users returned")
|
||||
@JsonProperty("users")
|
||||
private List<GroupUser> users = new ArrayList<>();
|
||||
|
||||
public List<GroupUser> getList() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setList(List<GroupUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{\n");
|
||||
|
||||
sb.append(" count: ").append(getCount()).append(",\n");
|
||||
sb.append(" users: [").append(users).append("\n");
|
||||
sb.append("]}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,726 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ResponseHeader;
|
||||
import org.apache.axis2.transport.http.HTTPConstants;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupShare;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupUsersList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
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.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Device group related REST-API. This can be used to manipulated device group related details.
|
||||
*/
|
||||
@API(name = "GroupManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"})
|
||||
|
||||
@Path("/groups")
|
||||
@Api(value = "Device Group Management", description = "This API carries all device group management related operations " +
|
||||
"such as get all the available groups, etc.")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface GroupManagementService {
|
||||
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "Get the list of groups belongs to current user.",
|
||||
notes = "Returns all permitted groups enrolled with the system.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of device groups.",
|
||||
response = DeviceGroupList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the groups list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Groups", permission = "/device-mgt/groups/view")
|
||||
Response getGroups(@ApiParam(
|
||||
name = "name",
|
||||
value = "Name of the group.")
|
||||
@QueryParam("name") String name,
|
||||
@ApiParam(
|
||||
name = "owner",
|
||||
value = "Owner of the group.")
|
||||
@QueryParam("owner") String owner,
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "Starting point within the complete list of items qualified.")
|
||||
@QueryParam("offset") int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "Maximum size of resource array to return.")
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@Path("/count")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "Get the count of groups belongs to current user.",
|
||||
notes = "Returns count of all permitted groups enrolled with the system.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device group count.",
|
||||
response = DeviceGroupList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the group count.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Groups", permission = "/device-mgt/groups/view")
|
||||
Response getGroupCount();
|
||||
|
||||
@POST
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_POST,
|
||||
value = "Add new device group to the system.",
|
||||
notes = "Add device group with current user as the owner.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 201,
|
||||
message = "Created. \n Device group has successfully been created",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Location",
|
||||
description = "The URL of the added group."),
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests.")
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 303,
|
||||
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Location",
|
||||
description = "The Source URL of the document.")}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Current logged in user is not authorized to add device groups.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while adding a new device group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Add Group", permission = "/device-mgt/groups/add")
|
||||
Response createGroup(@ApiParam(
|
||||
name = "group",
|
||||
value = "Group object with data.",
|
||||
required = true)
|
||||
@Valid DeviceGroup group);
|
||||
|
||||
@Path("/id/{groupId}")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "View group specified.",
|
||||
notes = "Returns details of group enrolled with the system.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device group.",
|
||||
response = DeviceGroup.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the group details.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Groups", permission = "/device-mgt/groups/view")
|
||||
Response getGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group to view.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId);
|
||||
|
||||
@Path("/id/{groupId}")
|
||||
@PUT
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_PUT,
|
||||
value = "Update a group.",
|
||||
notes = "If you wish to make changes to an existing group, that can be done by updating the group using " +
|
||||
"this resource.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Group has been updated successfully.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body."),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while updating the group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Update Group", permission = "/device-mgt/groups/update")
|
||||
Response updateGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group to be updated.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "group",
|
||||
value = "Group object with data.",
|
||||
required = true)
|
||||
@Valid DeviceGroup deviceGroup);
|
||||
|
||||
@Path("/id/{groupId}")
|
||||
@DELETE
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_DELETE,
|
||||
value = "Delete a group.",
|
||||
notes = "If you wish to remove an existing group, that can be done by updating the group using " +
|
||||
"this resource.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Group has been deleted successfully.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body."),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while removing the group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Remove Group", permission = "/device-mgt/groups/remove")
|
||||
Response deleteGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group to be deleted.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId);
|
||||
|
||||
@Path("/id/{groupId}/share")
|
||||
@POST
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_POST,
|
||||
value = "Manage group sharing with a user.",
|
||||
notes = "If you wish to share /un share an existing group with a user under defined sharing roles, " +
|
||||
"that can be done using this resource.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Sharing has been updated successfully.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body."),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while sharing the group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Share Group", permission = "/device-mgt/groups/share")
|
||||
Response manageGroupSharing(@ApiParam(
|
||||
name = "groupName",
|
||||
value = "Name of the group to be shared or unshared.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "deviceGroupShare",
|
||||
value = "User name and the assigned roles for the share.",
|
||||
required = true)
|
||||
@Valid DeviceGroupShare deviceGroupShare);
|
||||
|
||||
@Path("/id/{groupId}/users")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "View list of users of a device group.",
|
||||
notes = "Returns details of users which particular group has been shared with.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the users.",
|
||||
response = DeviceGroupUsersList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the users.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View users", permission = "/device-mgt/groups/users/view")
|
||||
Response getUsersOfGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId);
|
||||
|
||||
@Path("/id/{groupId}/roles")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "View list of roles of a device group.",
|
||||
notes = "Returns details of roles which particular group has been shared with.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the users.",
|
||||
response = DeviceGroupUsersList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the roles.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View roles", permission = "/device-mgt/groups/roles/view")
|
||||
Response getRolesOfGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "userName",
|
||||
value = "User name of the current user.",
|
||||
required = false)
|
||||
@QueryParam("userName") String userName);
|
||||
|
||||
@Path("/id/{groupId}/devices")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "View list of devices in the device group.",
|
||||
notes = "Returns list of devices in the device group.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the devices.",
|
||||
response = DeviceList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the devices.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View devices", permission = "/device-mgt/groups/devices/view")
|
||||
Response getDevicesOfGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "Starting point within the complete list of items qualified.")
|
||||
@QueryParam("offset") int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "Maximum size of resource array to return.")
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@Path("/id/{groupId}/devices/count")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "View list of device count in the device group.",
|
||||
notes = "Returns device count in the device group.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device count.",
|
||||
response = DeviceList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching device count.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View devices", permission = "/device-mgt/groups/devices/view")
|
||||
Response getDeviceCountOfGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId);
|
||||
|
||||
@Path("/id/{groupId}/devices")
|
||||
@POST
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_POST,
|
||||
value = "Add devices to group.",
|
||||
notes = "Add existing devices to the device group.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully add devices to the group.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while adding devices to the group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Add devices", permission = "/device-mgt/groups/devices/add")
|
||||
Response addDevicesToGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "deviceIdentifiers",
|
||||
value = "Device identifiers of the devices which needed be added.",
|
||||
required = true)
|
||||
@Valid List<DeviceIdentifier> deviceIdentifiers);
|
||||
|
||||
@Path("/id/{groupId}/devices")
|
||||
@DELETE
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_DELETE,
|
||||
value = "Remove devices from group.",
|
||||
notes = "Remove existing devices from the device group.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully removed devices from the group.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while removing devices from the group.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "Remove devices", permission = "/device-mgt/groups/devices/remove")
|
||||
Response removeDevicesFromGroup(@ApiParam(
|
||||
name = "groupId",
|
||||
value = "ID of the group.",
|
||||
required = true)
|
||||
@PathParam("groupId") int groupId,
|
||||
@ApiParam(
|
||||
name = "deviceIdentifiers",
|
||||
value = "Device identifiers of the devices which needed to be removed.",
|
||||
required = true)
|
||||
@Valid List<DeviceIdentifier> deviceIdentifiers);
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ResponseHeader;
|
||||
import org.apache.axis2.transport.http.HTTPConstants;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@API(name = "GroupManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/groups", tags = {"device_management"})
|
||||
|
||||
@Path("/admin/groups")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " +
|
||||
"'internal' components to log in as an admin user and do a selected number of operations. " +
|
||||
"Further, this is strictly restricted to admin users only ")
|
||||
public interface GroupManagementAdminService {
|
||||
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "Get the list of groups.",
|
||||
notes = "Returns all groups enrolled with the system.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of device groups.",
|
||||
response = DeviceGroupList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the groups list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Groups", permission = "/device-mgt/admin/groups/view")
|
||||
Response getGroups(@ApiParam(
|
||||
name = "name",
|
||||
value = "Name of the group.")
|
||||
@QueryParam("name") String name,
|
||||
@ApiParam(
|
||||
name = "owner",
|
||||
value = "Owner of the group.")
|
||||
@QueryParam("owner") String owner,
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "Starting point within the complete list of items qualified.")
|
||||
@QueryParam("offset") int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "Maximum size of resource array to return.")
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@Path("/count")
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = HTTPConstants.HEADER_GET,
|
||||
value = "Get the count of groups belongs to current user.",
|
||||
notes = "Returns count of all permitted groups enrolled with the system.",
|
||||
tags = "Device Group Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device group count.",
|
||||
response = DeviceGroupList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||
"the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "No groups found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the group count.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Groups", permission = "/device-mgt/admin/groups/view")
|
||||
Response getGroupCount();
|
||||
|
||||
}
|
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceNotFoundException;
|
||||
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupAlreadyExistException;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.RoleDoesNotExistException;
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.*;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.GroupManagementService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
import org.wso2.carbon.user.core.UserStoreException;
|
||||
import org.wso2.carbon.user.core.multiplecredentials.UserDoesNotExistException;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupManagementServiceImpl implements GroupManagementService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(GroupManagementServiceImpl.class);
|
||||
|
||||
private static final String DEFAULT_ADMIN_ROLE = "admin";
|
||||
private static final String[] DEFAULT_ADMIN_PERMISSIONS = {"/permission/device-mgt/admin/groups",
|
||||
"/permission/device-mgt/user/groups"};
|
||||
private static final String EMPTY_RESULT = "EMPTY";
|
||||
|
||||
@Override
|
||||
public Response getGroups(String name, String owner, int offset, int limit) {
|
||||
try {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
String currentUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
GroupPaginationRequest request = new GroupPaginationRequest(offset, limit);
|
||||
request.setGroupName(name);
|
||||
request.setOwner(owner);
|
||||
PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
|
||||
.getGroups(currentUser, request);
|
||||
if (deviceGroupsResult.getData() != null && deviceGroupsResult.getRecordsTotal() > 0) {
|
||||
DeviceGroupList deviceGroupList = new DeviceGroupList();
|
||||
deviceGroupList.setList(deviceGroupsResult.getData());
|
||||
deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal());
|
||||
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String error = "Error occurred while getting the groups.";
|
||||
log.error(error, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getGroupCount() {
|
||||
try {
|
||||
String currentUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
int count = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroupCount(currentUser);
|
||||
return Response.status(Response.Status.OK).entity(count).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while retrieving group count.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response createGroup(DeviceGroup group) {
|
||||
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
if (group == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
group.setOwner(owner);
|
||||
group.setDateOfCreation(new Date().getTime());
|
||||
group.setDateOfLastUpdate(new Date().getTime());
|
||||
try {
|
||||
DeviceMgtAPIUtils.getGroupManagementProviderService().createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while adding new group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (GroupAlreadyExistException e) {
|
||||
String msg = "Group already exists with name '" + group.getName() + "'.";
|
||||
log.warn(msg);
|
||||
return Response.status(Response.Status.CONFLICT).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getGroup(int groupId) {
|
||||
try {
|
||||
GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService();
|
||||
DeviceGroup deviceGroup = service.getGroup(groupId);
|
||||
if (deviceGroup != null) {
|
||||
return Response.status(Response.Status.OK).entity(deviceGroup).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String error = "Error occurred while getting the group.";
|
||||
log.error(error, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response updateGroup(int groupId, DeviceGroup deviceGroup) {
|
||||
if (deviceGroup == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
try {
|
||||
DeviceMgtAPIUtils.getGroupManagementProviderService().updateGroup(deviceGroup, groupId);
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while adding new group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (GroupAlreadyExistException e) {
|
||||
String msg = "There is another group already exists with name '" + deviceGroup.getName() + "'.";
|
||||
log.warn(msg);
|
||||
return Response.status(Response.Status.CONFLICT).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteGroup(int groupId) {
|
||||
try {
|
||||
if (DeviceMgtAPIUtils.getGroupManagementProviderService().deleteGroup(groupId)) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).entity("Group not found.").build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while deleting the group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response manageGroupSharing(int groupId, DeviceGroupShare deviceGroupShare) {
|
||||
try {
|
||||
DeviceMgtAPIUtils.getGroupManagementProviderService()
|
||||
.manageGroupSharing(groupId, deviceGroupShare.getUsername(), deviceGroupShare.getGroupRoles());
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while managing group share.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (RoleDoesNotExistException | UserDoesNotExistException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getUsersOfGroup(int groupId) {
|
||||
try {
|
||||
List<GroupUser> groupUsers = DeviceMgtAPIUtils.getGroupManagementProviderService().getUsers(groupId);
|
||||
if (groupUsers != null && groupUsers.size() > 0) {
|
||||
DeviceGroupUsersList deviceGroupUsersList = new DeviceGroupUsersList();
|
||||
deviceGroupUsersList.setList(groupUsers);
|
||||
deviceGroupUsersList.setCount(groupUsers.size());
|
||||
return Response.status(Response.Status.OK).entity(deviceGroupUsersList).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while getting users of the group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getRolesOfGroup(int groupId, String userName) {
|
||||
try {
|
||||
List<String> groupRoles;
|
||||
if(userName != null) {
|
||||
groupRoles = DeviceMgtAPIUtils.getGroupManagementProviderService().getRoles(userName, groupId);
|
||||
} else {
|
||||
groupRoles = DeviceMgtAPIUtils.getGroupManagementProviderService().getRoles(groupId);
|
||||
}
|
||||
|
||||
if(groupRoles != null && groupRoles.size() > 0) {
|
||||
RoleList deviceGroupRolesList = new RoleList();
|
||||
deviceGroupRolesList.setList(groupRoles);
|
||||
deviceGroupRolesList.setCount(groupRoles.size());
|
||||
return Response.status(Response.Status.OK).entity(deviceGroupRolesList).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.OK).entity(EMPTY_RESULT).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while getting roles of the group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error while retrieving the user.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getDevicesOfGroup(int groupId, int offset, int limit) {
|
||||
try {
|
||||
GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService();
|
||||
List<Device> deviceList = service.getDevices(groupId, offset, limit);
|
||||
if (deviceList != null && deviceList.size() > 0) {
|
||||
DeviceList deviceListWrapper = new DeviceList();
|
||||
deviceListWrapper.setList(deviceList);
|
||||
deviceListWrapper.setCount(service.getDeviceCount(groupId));
|
||||
return Response.status(Response.Status.OK).entity(deviceListWrapper).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while getting devices the group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getDeviceCountOfGroup(int groupId) {
|
||||
try {
|
||||
int count = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
||||
return Response.status(Response.Status.OK).entity(count).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while getting device count of the group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response addDevicesToGroup(int groupId, List<DeviceIdentifier> deviceIdentifiers) {
|
||||
try {
|
||||
DeviceMgtAPIUtils.getGroupManagementProviderService().addDevices(groupId, deviceIdentifiers);
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while adding devices to group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceNotFoundException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response removeDevicesFromGroup(int groupId, List<DeviceIdentifier> deviceIdentifiers) {
|
||||
try {
|
||||
DeviceMgtAPIUtils.getGroupManagementProviderService().removeDevice(groupId, deviceIdentifiers);
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error occurred while removing devices from group.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceNotFoundException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.GroupManagementAdminService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupManagementAdminServiceImpl implements GroupManagementAdminService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public Response getGroups(String name, String owner, int offset, int limit) {
|
||||
try {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
GroupPaginationRequest request = new GroupPaginationRequest(offset, limit);
|
||||
request.setGroupName(name);
|
||||
request.setOwner(owner);
|
||||
PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
|
||||
.getGroups(request);
|
||||
if (deviceGroupsResult.getData() != null && deviceGroupsResult.getRecordsTotal() > 0) {
|
||||
DeviceGroupList deviceGroupList = new DeviceGroupList();
|
||||
deviceGroupList.setList(deviceGroupsResult.getData());
|
||||
deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal());
|
||||
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "ErrorResponse occurred while retrieving all groups.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getGroupCount() {
|
||||
try {
|
||||
int count = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroupCount();
|
||||
return Response.status(Response.Status.OK).entity(count).build();
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "ErrorResponse occurred while retrieving group count.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.common;
|
||||
|
||||
public class DeviceNotFoundException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3151279311996070297L;
|
||||
|
||||
public DeviceNotFoundException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
}
|
||||
|
||||
public DeviceNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DeviceNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public DeviceNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeviceNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.common;
|
||||
|
||||
/**
|
||||
* This class holds required parameters for a querying a paginated device group response.
|
||||
*/
|
||||
public class GroupPaginationRequest {
|
||||
|
||||
private int startIndex;
|
||||
private int rowCount;
|
||||
private String owner;
|
||||
private String groupName;
|
||||
|
||||
public GroupPaginationRequest(int start, int rowCount) {
|
||||
this.startIndex = start;
|
||||
this.rowCount = rowCount;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public void setStartIndex(int startIndex) {
|
||||
this.startIndex = startIndex;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
public void setRowCount(int rowCount) {
|
||||
this.rowCount = rowCount;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.common.group.mgt;
|
||||
|
||||
/**
|
||||
* This class represents a custom exception specified for group management
|
||||
*/
|
||||
public class RoleDoesNotExistException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -312678379574556874L;
|
||||
private String errorMessage;
|
||||
|
||||
public RoleDoesNotExistException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public RoleDoesNotExistException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
setErrorMessage(message);
|
||||
}
|
||||
|
||||
public RoleDoesNotExistException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public RoleDoesNotExistException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RoleDoesNotExistException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.core.group.mgt;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to expose protected methods to the core. Use with internal access only.
|
||||
*/
|
||||
public class DeviceGroupBuilder extends DeviceGroup {
|
||||
|
||||
private int groupId;
|
||||
|
||||
/**
|
||||
* Set device group to be decorated with the builder
|
||||
*
|
||||
* @param deviceGroup to decorate
|
||||
*/
|
||||
public DeviceGroupBuilder(DeviceGroup deviceGroup) {
|
||||
this.setId(deviceGroup.getId());
|
||||
this.setDescription(deviceGroup.getDescription());
|
||||
this.setName(deviceGroup.getName());
|
||||
this.setDateOfCreation(deviceGroup.getDateOfCreation());
|
||||
this.setDateOfLastUpdate(deviceGroup.getDateOfLastUpdate());
|
||||
this.setOwner(deviceGroup.getOwner());
|
||||
this.setUsers(deviceGroup.getUsers());
|
||||
this.setRoles(deviceGroup.getRoles());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsers(List<GroupUser> users) {
|
||||
super.setUsers(users);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoles(List<String> roles) {
|
||||
super.setRoles(roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceGroup getGroup() {
|
||||
return super.getGroup();
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"uri": "/group/{owner}/{name}/analytics",
|
||||
"uri": "/group/{name}/{id}/analytics",
|
||||
"layout": "cdmf.layout.default"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue