mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixed conflict and merged
This commit is contained in:
commit
ac75ff1d71
@ -83,10 +83,6 @@
|
|||||||
<groupId>com.googlecode.json-simple.wso2</groupId>
|
<groupId>com.googlecode.json-simple.wso2</groupId>
|
||||||
<artifactId>json-simple</artifactId>
|
<artifactId>json-simple</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
|||||||
@ -22,9 +22,9 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||||
|
|
||||||
@ApiModel(value = "RoleWrapper", description = "Role details including permission and the users in the roles are " +
|
@ApiModel(value = "RoleInfo", description = "Role details including permission and the users in the roles are " +
|
||||||
"wrapped here.")
|
"wrapped here.")
|
||||||
public class RoleWrapper {
|
public class RoleInfo {
|
||||||
|
|
||||||
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
|
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
|
||||||
private String roleName;
|
private String roleName;
|
||||||
@ -78,7 +78,7 @@ public interface ActivityInfoProviderService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 401,
|
code = 401,
|
||||||
message = ". \n Invalid request or validation error."),
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n No activity is found under the provided id.",
|
message = "Not Found. \n No activity is found under the provided id.",
|
||||||
@ -88,7 +88,7 @@ public interface ActivityInfoProviderService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.",
|
message = "Internal Server Error. \n Server error occurred while fetching activity data.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "activity-view", roles = {"emm-user", "emm-admin"})
|
@Permission(scope = "activity-view", roles = {"emm-user", "emm-admin"})
|
||||||
@ -135,6 +135,9 @@ public interface ActivityInfoProviderService {
|
|||||||
code = 304,
|
code = 304,
|
||||||
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||||
"the requested resource."),
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n No activities found.",
|
message = "Not Found. \n No activities found.",
|
||||||
@ -144,7 +147,7 @@ public interface ActivityInfoProviderService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.",
|
message = "Internal Server Error. \n Server error occurred while fetching activity data.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "activity-view", roles = {"emm-admin"})
|
@Permission(scope = "activity-view", roles = {"emm-admin"})
|
||||||
|
|||||||
@ -47,7 +47,8 @@ public interface ConfigurationManagementService {
|
|||||||
value = "Get the general platform configurations.",
|
value = "Get the general platform configurations.",
|
||||||
notes = "Get the general platform level configuration details.",
|
notes = "Get the general platform level configuration details.",
|
||||||
tags = "Configuration Management")
|
tags = "Configuration Management")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Successfully fetched general platform configuration.",
|
message = "OK. \n Successfully fetched general platform configuration.",
|
||||||
@ -65,16 +66,18 @@ public interface ConfigurationManagementService {
|
|||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests."),
|
"Used by caches, or in conditional requests."),
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 304,
|
code = 304,
|
||||||
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the general " +
|
message = "Internal Server Error. \n Server error occurred while fetching the general " +
|
||||||
"platform configuration.",
|
"platform configuration.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -84,7 +87,8 @@ public interface ConfigurationManagementService {
|
|||||||
name = "If-Modified-Since",
|
name = "If-Modified-Since",
|
||||||
value = "Validates if the requested variant has not been modified since the time specified",
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
required = false)
|
required = false)
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
@HeaderParam("If-Modified-Since")
|
||||||
|
String ifModifiedSince);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
@ -94,14 +98,12 @@ public interface ConfigurationManagementService {
|
|||||||
value = "Update General Platform Configurations.",
|
value = "Update General Platform Configurations.",
|
||||||
notes = "This resource is used to update the general platform configuration.",
|
notes = "This resource is used to update the general platform configuration.",
|
||||||
tags = "Configuration Management")
|
tags = "Configuration Management")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n General platform configuration has been updated successfully",
|
message = "OK. \n General platform configuration has been updated successfully",
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
|
||||||
name = "Content-Location",
|
|
||||||
description = "URL of the updated general platform configuration."),
|
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
description = "The content type of the body"),
|
description = "The content type of the body"),
|
||||||
@ -121,7 +123,7 @@ public interface ConfigurationManagementService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while modifying general platform configuration.",
|
"Server error occurred while modifying general platform configuration.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -130,6 +132,7 @@ public interface ConfigurationManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "configuration",
|
name = "configuration",
|
||||||
value = "The required properties to be updated in the platform configuration.",
|
value = "The required properties to be updated in the platform configuration.",
|
||||||
required = true) PlatformConfiguration configuration);
|
required = true)
|
||||||
|
PlatformConfiguration configuration);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public interface DeviceManagementService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the device list.",
|
message = "Internal Server Error. \n Server error occurred while fetching the device list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "device-list", roles = {"emm-admin"})
|
@Permission(scope = "device-list", roles = {"emm-admin"})
|
||||||
@ -190,7 +190,7 @@ public interface DeviceManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while retrieving information requested device.",
|
"Server error occurred while retrieving information requested device.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -270,7 +270,7 @@ public interface DeviceManagementService {
|
|||||||
message = "Not Acceptable. \n The requested media type is not supported."),
|
message = "Not Acceptable. \n The requested media type is not supported."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while retrieving feature list of the device.",
|
"Server error occurred while retrieving feature list of the device.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -344,7 +344,7 @@ public interface DeviceManagementService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while enrolling the device.",
|
"Server error occurred while enrolling the device.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -423,9 +423,8 @@ public interface DeviceManagementService {
|
|||||||
message = "Not Acceptable. \n The requested media type is not supported."),
|
message = "Not Acceptable. \n The requested media type is not supported."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while retrieving installed application list of "
|
"Server error occurred while retrieving installed application list of the device.",
|
||||||
+ "the device.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "operation-view", roles = {"emm-admin"})
|
@Permission(scope = "operation-view", roles = {"emm-admin"})
|
||||||
@ -518,9 +517,8 @@ public interface DeviceManagementService {
|
|||||||
message = "Not Acceptable. \n The requested media type is not supported."),
|
message = "Not Acceptable. \n The requested media type is not supported."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while retrieving operation list scheduled for the "
|
"Server error occurred while retrieving operation list scheduled for the device.",
|
||||||
+ "device.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "operation-view", roles = {"emm-admin"})
|
@Permission(scope = "operation-view", roles = {"emm-admin"})
|
||||||
@ -614,9 +612,8 @@ public interface DeviceManagementService {
|
|||||||
message = "Not Acceptable. \n The requested media type is not supported."),
|
message = "Not Acceptable. \n The requested media type is not supported."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while retrieving the effective policy calculated "
|
"Server error occurred while retrieving the effective policy calculated for the device.",
|
||||||
+ "for the device.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -86,7 +86,8 @@ public interface NotificationManagementService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the notification list.",
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while fetching the notification list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "device-notification-view", roles = {"emm-admin"})
|
@Permission(scope = "device-notification-view", roles = {"emm-admin"})
|
||||||
@ -116,4 +117,15 @@ public interface NotificationManagementService {
|
|||||||
required = false)
|
required = false)
|
||||||
@QueryParam("limit")
|
@QueryParam("limit")
|
||||||
int limit);
|
int limit);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{id}/{status}")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "",
|
||||||
|
notes = "",
|
||||||
|
tags = "Device Notification Management")
|
||||||
|
Response updateNotificationStatus(
|
||||||
|
@PathParam("id") int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,8 @@ public interface PolicyManagementService {
|
|||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests.")
|
"Used by caches, or in conditional requests.")
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 303,
|
code = 303,
|
||||||
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
|
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
|
||||||
@ -94,7 +95,7 @@ public interface PolicyManagementService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while adding a new policy.",
|
"Server error occurred while adding a new policy.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -134,7 +135,8 @@ public interface PolicyManagementService {
|
|||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests."),
|
"Used by caches, or in conditional requests."),
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 304,
|
code = 304,
|
||||||
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
@ -147,7 +149,7 @@ public interface PolicyManagementService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = ("Internal Server ErrorResponse. \n Server error occurred while fetching " +
|
message = ("Internal Server Error. \n Server error occurred while fetching " +
|
||||||
"policies."),
|
"policies."),
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -199,21 +201,21 @@ public interface PolicyManagementService {
|
|||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests."),
|
"Used by caches, or in conditional requests."),
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 304,
|
code = 304,
|
||||||
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n No policy is found with the given id.",
|
message = "Not Found. \n No policy is found with the given id.",
|
||||||
response = ErrorResponse.class
|
response = ErrorResponse.class),
|
||||||
),
|
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the " +
|
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||||
"policy.",
|
"policy.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -261,7 +263,9 @@ public interface PolicyManagementService {
|
|||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests.")}),
|
"Used by caches, or in conditional requests.")
|
||||||
|
}
|
||||||
|
),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 400,
|
code = 400,
|
||||||
message = "Bad Request. \n Invalid request or validation error.",
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
@ -275,7 +279,7 @@ public interface PolicyManagementService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while updating the policy.",
|
"Server error occurred while updating the policy.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -317,10 +321,11 @@ public interface PolicyManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not "
|
||||||
|
+ "supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while bulk removing policies.",
|
"Server error occurred while bulk removing policies.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -375,8 +380,8 @@ public interface PolicyManagementService {
|
|||||||
produces = MediaType.APPLICATION_JSON,
|
produces = MediaType.APPLICATION_JSON,
|
||||||
httpMethod = "PUT",
|
httpMethod = "PUT",
|
||||||
value = "Deactivating policies.",
|
value = "Deactivating policies.",
|
||||||
notes = "Using the REST API command you are able to unpublish a policy in order to bring a policy that " +
|
notes = "Using the REST API command you are able to unpublish a policy in order to bring a "
|
||||||
"is in the active state to the inactive state.",
|
+ "policy that is in the active state to the inactive state.",
|
||||||
tags = "Device Policy Management")
|
tags = "Device Policy Management")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
|
|||||||
@ -21,10 +21,9 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
|||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
|
|
||||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -70,16 +69,12 @@ public interface RoleManagementService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 304,
|
code = 304,
|
||||||
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
@ApiResponse(
|
|
||||||
code = 404,
|
|
||||||
message = "Not Found. \n Resource does not exist.",
|
|
||||||
response = ErrorResponse.class),
|
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching requested list of roles.",
|
message = "Internal Server Error. \n Server error occurred while fetching requested list of roles.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "roles-view", roles = {"emm-admin"})
|
@Permission(scope = "roles-view", roles = {"emm-admin"})
|
||||||
@ -153,11 +148,12 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource does not exist.",
|
message = "Not Found. \n Role does not exist.",
|
||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.",
|
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.",
|
||||||
@ -183,14 +179,14 @@ public interface RoleManagementService {
|
|||||||
httpMethod = "GET",
|
httpMethod = "GET",
|
||||||
value = "Get details of a role.",
|
value = "Get details of a role.",
|
||||||
notes = "If you wish to get the details of a role in EMM, you can do so using this REST API.",
|
notes = "If you wish to get the details of a role in EMM, you can do so using this REST API.",
|
||||||
response = RoleWrapper.class,
|
response = RoleInfo.class,
|
||||||
tags = "Role Management")
|
tags = "Role Management")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Successfully fetched the requested role.",
|
message = "OK. \n Successfully fetched the requested role.",
|
||||||
response = RoleWrapper.class,
|
response = RoleInfo.class,
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
@ -214,14 +210,15 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource does not exist.",
|
message = "Not Found. \n Role does not exist.",
|
||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the " +
|
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||||
"requested role.",
|
"requested role.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -278,11 +275,11 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n Server error occurred while adding a new role.",
|
||||||
"Server error occurred while adding a new role.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
||||||
@ -290,7 +287,7 @@ public interface RoleManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "role",
|
name = "role",
|
||||||
value = "Details about the role to be added.",
|
value = "Details about the role to be added.",
|
||||||
required = true) RoleWrapper role);
|
required = true) RoleInfo role);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{roleName}")
|
@Path("/{roleName}")
|
||||||
@ -307,9 +304,6 @@ public interface RoleManagementService {
|
|||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Role has been updated successfully",
|
message = "OK. \n Role has been updated successfully",
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
|
||||||
name = "Content-Location",
|
|
||||||
description = "URL of the updated role."),
|
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
description = "Content type of the body"),
|
description = "Content type of the body"),
|
||||||
@ -327,14 +321,15 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource to be deleted does not exist."),
|
message = "Not Found. \n Role to be deleted does not exist.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n Server error occurred while updating the role.",
|
||||||
"Server error occurred while updating the role.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
||||||
@ -347,7 +342,7 @@ public interface RoleManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "role",
|
name = "role",
|
||||||
value = "Details about the role to be added.",
|
value = "Details about the role to be added.",
|
||||||
required = true) RoleWrapper role);
|
required = true) RoleInfo role);
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{roleName}")
|
@Path("/{roleName}")
|
||||||
@ -367,11 +362,11 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource to be deleted does not exist."),
|
message = "Not Found. \n Role to be deleted does not exist.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n Server error occurred while removing the role.",
|
||||||
"Server error occurred while removing the role.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
@Permission(scope = "roles-modify", roles = {"emm-admin"})
|
||||||
@ -402,9 +397,6 @@ public interface RoleManagementService {
|
|||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n User list of the role has been updated successfully",
|
message = "OK. \n User list of the role has been updated successfully",
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
|
||||||
name = "Content-Location",
|
|
||||||
description = "URL of the updated user list."),
|
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
description = "Content type of the body"),
|
description = "Content type of the body"),
|
||||||
@ -422,13 +414,16 @@ public interface RoleManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource to be deleted does not exist."),
|
message = "Not Found. \n Resource to be deleted does not exist.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not " +
|
||||||
|
"supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while updating the user list of the role.",
|
"Server error occurred while updating the user list of the role.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -64,34 +64,29 @@ public interface UserManagementService {
|
|||||||
name = "Last-Modified",
|
name = "Last-Modified",
|
||||||
description = "Date and time the resource has been modified the last time.\n" +
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
"Used by caches, or in conditional requests.")}),
|
"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(
|
@ApiResponse(
|
||||||
code = 400,
|
code = 400,
|
||||||
message = "Bad Request. \n Invalid request or validation error."),
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 409,
|
code = 409,
|
||||||
message = "Conflict. \n User already exist.",
|
message = "Conflict. \n User already exists.",
|
||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not " +
|
||||||
|
"supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n Server error occurred while adding a new user.",
|
||||||
"Server error occurred while adding a new user.",
|
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "user-modify", roles = {"emm-admin"})
|
@Permission(scope = "user-modify", roles = {"emm-admin"})
|
||||||
Response addUser(
|
Response addUser(
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "user",
|
name = "user",
|
||||||
value = "User related details.",
|
value = "Information of the user to be added",
|
||||||
required = true) UserInfo user);
|
required = true) UserInfo user);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -131,7 +126,8 @@ public interface UserManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while" +
|
message = "Internal Server ErrorResponse. \n Server error occurred while" +
|
||||||
@ -166,9 +162,6 @@ public interface UserManagementService {
|
|||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n User has been updated successfully",
|
message = "OK. \n User has been updated successfully",
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
|
||||||
name = "Content-Location",
|
|
||||||
description = "URL of the updated user."),
|
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
description = "Content type of the body"),
|
description = "Content type of the body"),
|
||||||
@ -182,17 +175,19 @@ public interface UserManagementService {
|
|||||||
"Used by caches, or in conditional requests.")}),
|
"Used by caches, or in conditional requests.")}),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 400,
|
code = 400,
|
||||||
message = "Bad Request. \n Invalid request or validation error."),
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource does not exist.",
|
message = "Not Found. \n Resource does not exist.",
|
||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while updating the user.",
|
"Server error occurred while updating the user.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -226,7 +221,7 @@ public interface UserManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while removing the user.",
|
"Server error occurred while removing the user.",
|
||||||
response = ErrorResponse.class
|
response = ErrorResponse.class
|
||||||
)
|
)
|
||||||
@ -272,10 +267,11 @@ public interface UserManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the role list" +
|
message = "Internal Server Error. \n Server error occurred while fetching the role list" +
|
||||||
" assigned to the user.",
|
" assigned to the user.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -296,7 +292,7 @@ public interface UserManagementService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Successfully fetched the requested role.",
|
message = "OK. \n Successfully fetched the requested role.",
|
||||||
response = UserInfoList.class,
|
response = BasicUserInfoList.class,
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
@ -315,10 +311,11 @@ public interface UserManagementService {
|
|||||||
message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the user list.",
|
message = "Internal Server Error. \n Server error occurred while fetching the user list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "user-view", roles = {"emm-admin"})
|
@Permission(scope = "user-view", roles = {"emm-admin"})
|
||||||
@ -380,10 +377,11 @@ public interface UserManagementService {
|
|||||||
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 406,
|
code = 406,
|
||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the username " +
|
message = "Internal Server Error. \n Server error occurred while fetching the username " +
|
||||||
"list that matches the given filter.",
|
"list that matches the given filter.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@ -429,13 +427,15 @@ public interface UserManagementService {
|
|||||||
response = ErrorResponse.class),
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 404,
|
||||||
message = "Not Found. \n Resource to be deleted does not exist."),
|
message = "Not Found. \n Resource to be deleted does not exist.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 415,
|
code = 415,
|
||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while updating credentials of the user.",
|
"Server error occurred while updating credentials of the user.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public interface ApplicationManagementAdminService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while bulk issuing application installation operations upon " +
|
"Server error occurred while bulk issuing application installation operations upon " +
|
||||||
"a given set of devices.",
|
"a given set of devices.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
@ -108,7 +108,7 @@ public interface ApplicationManagementAdminService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while bulk issuing application un-installation operations upon " +
|
"Server error occurred while bulk issuing application un-installation operations upon " +
|
||||||
"a given set of devices.",
|
"a given set of devices.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
|
|||||||
@ -81,7 +81,7 @@ public interface DeviceManagementAdminService {
|
|||||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the device list.",
|
message = "Internal Server Error. \n Server error occurred while fetching the device list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
@Permission(scope = "device-view", roles = {"emm-admin"})
|
@Permission(scope = "device-view", roles = {"emm-admin"})
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public interface UserManagementAdminService {
|
|||||||
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 500,
|
code = 500,
|
||||||
message = "Internal Server ErrorResponse. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while updating credentials of the user.",
|
"Server error occurred while updating credentials of the user.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -26,8 +26,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.ActivityInfoProviderService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.ActivityInfoProviderService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -58,17 +57,17 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
|||||||
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
|
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
activity = dmService.getOperationByActivityId(id);
|
activity = dmService.getOperationByActivityId(id);
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
throw new NotFoundException(new ErrorResponse.ErrorResponseBuilder().setCode(404l)
|
return Response.status(404).entity(
|
||||||
.setMessage("No activity can be " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No activity can be " +
|
||||||
"found upon the provided activity id '" + id + "'").build());
|
"found upon the provided activity id '" + id + "'").build()).build();
|
||||||
}
|
}
|
||||||
|
return Response.status(Response.Status.OK).entity(activity).build();
|
||||||
} catch (OperationManagementException e) {
|
} catch (OperationManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while fetching the activity for the supplied id.";
|
String msg = "ErrorResponse occurred while fetching the activity for the supplied id.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(new ErrorResponse.ErrorResponseBuilder().setCode(500l)
|
return Response.serverError().entity(
|
||||||
.setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(activity).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -77,19 +76,21 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
|||||||
@QueryParam("limit") int limit,
|
@QueryParam("limit") int limit,
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
|
||||||
long ifModifiedSinceTimestamp = 0;
|
long ifModifiedSinceTimestamp;
|
||||||
long sinceTimestamp = 0;
|
long sinceTimestamp;
|
||||||
long timestamp = 0;
|
long timestamp = 0;
|
||||||
boolean isIfModifiedSinceSet = false;
|
boolean isIfModifiedSinceSet = false;
|
||||||
boolean isSinceSet = false;
|
boolean isSinceSet = false;
|
||||||
|
|
||||||
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
|
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
|
||||||
Date ifSinceDate;
|
Date ifSinceDate;
|
||||||
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
|
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
|
||||||
try {
|
try {
|
||||||
ifSinceDate = format.parse(ifModifiedSince);
|
ifSinceDate = format.parse(ifModifiedSince);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l)
|
return Response.status(400).entity(
|
||||||
.setMessage("Invalid date string is provided in 'If-Modified-Since' header").build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
|
"Invalid date string is provided in 'If-Modified-Since' header").build()).build();
|
||||||
}
|
}
|
||||||
ifModifiedSinceTimestamp = ifSinceDate.getTime();
|
ifModifiedSinceTimestamp = ifSinceDate.getTime();
|
||||||
isIfModifiedSinceSet = true;
|
isIfModifiedSinceSet = true;
|
||||||
@ -100,13 +101,15 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
|||||||
try {
|
try {
|
||||||
sinceDate = format.parse(since);
|
sinceDate = format.parse(since);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l)
|
return Response.status(400).entity(
|
||||||
.setMessage("Invalid date string is provided in 'since' filter").build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
|
"Invalid date string is provided in 'since' filter").build()).build();
|
||||||
}
|
}
|
||||||
sinceTimestamp = sinceDate.getTime();
|
sinceTimestamp = sinceDate.getTime();
|
||||||
isSinceSet = true;
|
isSinceSet = true;
|
||||||
timestamp = sinceTimestamp / 1000;
|
timestamp = sinceTimestamp / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Activity> activities;
|
List<Activity> activities;
|
||||||
ActivityList activityList = new ActivityList();
|
ActivityList activityList = new ActivityList();
|
||||||
DeviceManagementProviderService dmService;
|
DeviceManagementProviderService dmService;
|
||||||
@ -117,24 +120,18 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
|||||||
int count = dmService.getActivityCountUpdatedAfter(timestamp);
|
int count = dmService.getActivityCountUpdatedAfter(timestamp);
|
||||||
activityList.setCount(count);
|
activityList.setCount(count);
|
||||||
if (activities == null || activities.size() == 0) {
|
if (activities == null || activities.size() == 0) {
|
||||||
if (isIfModifiedSinceSet) {
|
if (isIfModifiedSinceSet || isSinceSet) {
|
||||||
return Response.status(Response.Status.NOT_MODIFIED).entity(
|
return Response.notModified().build();
|
||||||
"No activities " + "after the time provided in 'If-Modified-Since' header")
|
|
||||||
.build();
|
|
||||||
} else if (isSinceSet) {
|
|
||||||
return Response.status(Response.Status.NOT_MODIFIED).entity(
|
|
||||||
"No activities " + "after the time provided in 'since' filter").build();
|
|
||||||
}
|
}
|
||||||
throw new NotFoundException(new ErrorResponse.ErrorResponseBuilder().setCode(404l)
|
|
||||||
.setMessage("No activities " + "found.").build());
|
|
||||||
}
|
}
|
||||||
|
return Response.ok().entity(activityList).build();
|
||||||
} catch (OperationManagementException e) {
|
} catch (OperationManagementException e) {
|
||||||
String msg
|
String msg
|
||||||
= "ErrorResponse occurred while fetching the activities updated after given time stamp.";
|
= "ErrorResponse occurred while fetching the activities updated after given time stamp.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(new ErrorResponse.ErrorResponseBuilder().setCode(500l)
|
return Response.serverError().entity(
|
||||||
.setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(activityList).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,19 +55,19 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
|
|||||||
ConfigurationEntry configurationEntry = new ConfigurationEntry();
|
ConfigurationEntry configurationEntry = new ConfigurationEntry();
|
||||||
configurationEntry.setContentType("text");
|
configurationEntry.setContentType("text");
|
||||||
configurationEntry.setName("notifierFrequency");
|
configurationEntry.setName("notifierFrequency");
|
||||||
configurationEntry.setValue(PolicyManagerUtil.getMonitoringFequency());
|
configurationEntry.setValue(PolicyManagerUtil.getMonitoringFrequency());
|
||||||
List<ConfigurationEntry> configList = config.getConfiguration();
|
List<ConfigurationEntry> configList = config.getConfiguration();
|
||||||
if (configList == null) {
|
if (configList == null) {
|
||||||
configList = new ArrayList<>();
|
configList = new ArrayList<>();
|
||||||
configList.add(configurationEntry);
|
configList.add(configurationEntry);
|
||||||
}
|
}
|
||||||
config.setConfiguration(configList);
|
config.setConfiguration(configList);
|
||||||
return Response.status(Response.Status.OK).entity(config).build();
|
return Response.ok().entity(config).build();
|
||||||
} catch (ConfigurationManagementException | PolicyManagementException e) {
|
} catch (ConfigurationManagementException | PolicyManagementException e) {
|
||||||
msg = "ErrorResponse occurred while retrieving the configurations.";
|
msg = "Error occurred while retrieving the general platform configuration";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,13 +80,15 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
|
|||||||
MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
|
MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
|
||||||
//Schedule the task service
|
//Schedule the task service
|
||||||
DeviceMgtAPIUtils.scheduleTaskService(DeviceMgtAPIUtils.getNotifierFrequency(config));
|
DeviceMgtAPIUtils.scheduleTaskService(DeviceMgtAPIUtils.getNotifierFrequency(config));
|
||||||
return Response.status(Response.Status.CREATED)
|
|
||||||
.entity("Configuration has successfully been updated").build();
|
PlatformConfiguration updatedConfig = DeviceMgtAPIUtils.getPlatformConfigurationManagementService().
|
||||||
|
getConfiguration(MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
|
||||||
|
return Response.ok().entity(updatedConfig).build();
|
||||||
} catch (ConfigurationManagementException e) {
|
} catch (ConfigurationManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while updating the configuration.";
|
String msg = "Error occurred while updating the general platform configuration";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.search.SearchContext;
|
import org.wso2.carbon.device.mgt.common.search.SearchContext;
|
||||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
|
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
|
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
@ -35,10 +34,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
@ -100,9 +96,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
try {
|
try {
|
||||||
sinceDate = format.parse(ifModifiedSince);
|
sinceDate = format.parse(ifModifiedSince);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Invalid date " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " +
|
||||||
"string is provided in 'If-Modified-Since' header").build());
|
"string is provided in 'If-Modified-Since' header").build()).build();
|
||||||
}
|
}
|
||||||
request.setSince(sinceDate);
|
request.setSince(sinceDate);
|
||||||
result = dms.getAllDevices(request);
|
result = dms.getAllDevices(request);
|
||||||
@ -116,9 +112,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
try {
|
try {
|
||||||
sinceDate = format.parse(since);
|
sinceDate = format.parse(since);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Invalid date " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " +
|
||||||
"string is provided in 'since' filter").build());
|
"string is provided in 'since' filter").build()).build();
|
||||||
}
|
}
|
||||||
request.setSince(sinceDate);
|
request.setSince(sinceDate);
|
||||||
result = dms.getAllDevices(request);
|
result = dms.getAllDevices(request);
|
||||||
@ -140,8 +136,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while fetching all enrolled devices";
|
String msg = "Error occurred while fetching all enrolled devices";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,13 +157,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while fetching the device information.";
|
String msg = "Error occurred while fetching the device information.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Requested device of type '" +
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Requested device of type '" +
|
||||||
type + "', which carries id '" + id + "' does not exist").build());
|
type + "', which carries id '" + id + "' does not exist").build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(device).build();
|
return Response.status(Response.Status.OK).entity(device).build();
|
||||||
}
|
}
|
||||||
@ -187,17 +183,17 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
FeatureManager fm = dms.getFeatureManager(type);
|
FeatureManager fm = dms.getFeatureManager(type);
|
||||||
if (fm == null) {
|
if (fm == null) {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No feature manager is " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No feature manager is " +
|
||||||
"registered with the given type '" + type + "'").build());
|
"registered with the given type '" + type + "'").build()).build();
|
||||||
}
|
}
|
||||||
features = fm.getFeatures();
|
features = fm.getFeatures();
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while retrieving the list of features of '" + type + "' device, which " +
|
String msg = "Error occurred while retrieving the list of features of '" + type + "' device, which " +
|
||||||
"carries the id '" + id + "'";
|
"carries the id '" + id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(features).build();
|
return Response.status(Response.Status.OK).entity(features).build();
|
||||||
}
|
}
|
||||||
@ -216,13 +212,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
} catch (SearchMgtException e) {
|
} catch (SearchMgtException e) {
|
||||||
String msg = "Error occurred while searching for devices that matches the provided selection criteria";
|
String msg = "Error occurred while searching for devices that matches the provided selection criteria";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
if (devices == null || devices.size() == 0) {
|
|
||||||
Response.status(Response.Status.OK).entity(deviceList);
|
|
||||||
}
|
|
||||||
|
|
||||||
deviceList.setList(devices);
|
deviceList.setList(devices);
|
||||||
return Response.status(Response.Status.OK).entity(deviceList).build();
|
return Response.status(Response.Status.OK).entity(deviceList).build();
|
||||||
}
|
}
|
||||||
@ -237,23 +229,21 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@QueryParam("offset") int offset,
|
@QueryParam("offset") int offset,
|
||||||
@QueryParam("limit") int limit) {
|
@QueryParam("limit") int limit) {
|
||||||
List<Application> applications;
|
List<Application> applications;
|
||||||
|
//ApplicationList appList;
|
||||||
ApplicationManagementProviderService amc;
|
ApplicationManagementProviderService amc;
|
||||||
try {
|
try {
|
||||||
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
||||||
|
|
||||||
amc = DeviceMgtAPIUtils.getAppManagementService();
|
amc = DeviceMgtAPIUtils.getAppManagementService();
|
||||||
applications = amc.getApplicationListForDevice(new DeviceIdentifier(id, type));
|
applications = amc.getApplicationListForDevice(new DeviceIdentifier(id, type));
|
||||||
if (applications == null) {
|
|
||||||
throw new NotFoundException(
|
//TODO: return app list
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("It is likely that " +
|
|
||||||
"no applications is found upon the provided type and id").build());
|
|
||||||
}
|
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while fetching the apps of the '" + type + "' device, which carries " +
|
String msg = "Error occurred while fetching the apps of the '" + type + "' device, which carries " +
|
||||||
"the id '" + id + "'";
|
"the id '" + id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(applications).build();
|
return Response.status(Response.Status.OK).entity(applications).build();
|
||||||
}
|
}
|
||||||
@ -275,24 +265,18 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
||||||
|
|
||||||
dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
result = dms.getOperations(new DeviceIdentifier(id, type),request);
|
result = dms.getOperations(new DeviceIdentifier(id, type), request);
|
||||||
int resultCount = result.getRecordsTotal();
|
|
||||||
|
|
||||||
if (resultCount == 0) {
|
operationsList.setList((List<? extends Operation>) result.getData());
|
||||||
throw new NotFoundException(
|
operationsList.setCount(result.getRecordsTotal());
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("It is likely that" +
|
return Response.status(Response.Status.OK).entity(operationsList).build();
|
||||||
" no operation is found upon the provided type and id").build());
|
|
||||||
}
|
|
||||||
} catch (OperationManagementException e) {
|
} catch (OperationManagementException e) {
|
||||||
String msg = "Error occurred while fetching the operations for the '" + type + "' device, which " +
|
String msg = "Error occurred while fetching the operations for the '" + type + "' device, which " +
|
||||||
"carries the id '" + id + "'";
|
"carries the id '" + id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
operationsList.setList((List<? extends Operation>) result.getData());
|
|
||||||
operationsList.setCount(result.getRecordsTotal());
|
|
||||||
return Response.status(Response.Status.OK).entity(operationsList).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -306,35 +290,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
|
|
||||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||||
Policy policy = policyManagementService.getAppliedPolicyToDevice(new DeviceIdentifier(id, type));
|
Policy policy = policyManagementService.getAppliedPolicyToDevice(new DeviceIdentifier(id, type));
|
||||||
if (policy == null) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No policy has " +
|
|
||||||
"been found for the '" + type + "' device, which carries the id '" + id + "'").build());
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(policy).build();
|
return Response.status(Response.Status.OK).entity(policy).build();
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "Error occurred while retrieving the current policy associated with the '" + type +
|
String msg = "Error occurred while retrieving the current policy associated with the '" + type +
|
||||||
"' device, which carries the id '" + id + "'";
|
"' device, which carries the id '" + id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/types")
|
|
||||||
@Override
|
|
||||||
public Response getDeviceTypes() {
|
|
||||||
List<DeviceType> deviceTypes;
|
|
||||||
try {
|
|
||||||
deviceTypes = DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes();
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Error occurred while fetching the list of device types.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(new ErrorResponse.ErrorResponseBuilder().
|
|
||||||
setCode(500l).setMessage(msg).build());
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(deviceTypes).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,19 +20,15 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.NotificationContext;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.NotificationList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.NotificationList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.NotificationManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.NotificationManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -55,37 +51,53 @@ public class NotificationManagementServiceImpl implements NotificationManagement
|
|||||||
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
|
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
|
||||||
|
|
||||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||||
PaginationResult result = null;
|
PaginationResult result;
|
||||||
|
|
||||||
NotificationList notificationList = new NotificationList();
|
NotificationList notificationList = new NotificationList();
|
||||||
int resultCount = 0;
|
|
||||||
|
|
||||||
String msg;
|
String msg;
|
||||||
try {
|
try {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
RequestValidationUtil.validateNotificationStatus(status);
|
RequestValidationUtil.validateNotificationStatus(status);
|
||||||
result = DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus(
|
result = DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus(
|
||||||
Notification.Status.valueOf(status),request);
|
Notification.Status.valueOf(status), request);
|
||||||
resultCount = result.getRecordsTotal();
|
|
||||||
} else {
|
} else {
|
||||||
result = DeviceMgtAPIUtils.getNotificationManagementService().getAllNotifications(request);
|
result = DeviceMgtAPIUtils.getNotificationManagementService().getAllNotifications(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultCount == 0) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No notification is " +
|
|
||||||
"available to be retrieved.").build());
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationList.setNotifications((List<Notification>) result.getData());
|
|
||||||
notificationList.setCount(result.getRecordsTotal());
|
notificationList.setCount(result.getRecordsTotal());
|
||||||
|
notificationList.setNotifications((List<Notification>) result.getData());
|
||||||
return Response.status(Response.Status.OK).entity(notificationList).build();
|
return Response.status(Response.Status.OK).entity(notificationList).build();
|
||||||
} catch (NotificationManagementException e) {
|
} catch (NotificationManagementException e) {
|
||||||
msg = "Error occurred while retrieving notification info";
|
msg = "Error occurred while retrieving notification list";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.serverError().entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{id}/mark-checked")
|
||||||
|
public Response updateNotificationStatus(
|
||||||
|
@PathParam("id") int id) {
|
||||||
|
String msg;
|
||||||
|
Notification.Status status = Notification.Status.CHECKED;
|
||||||
|
Notification notification;
|
||||||
|
try {
|
||||||
|
DeviceMgtAPIUtils.getNotificationManagementService().updateNotificationStatus(id, status);
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
msg = "Error occurred while updating notification status.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
notification = DeviceMgtAPIUtils.getNotificationManagementService().getNotification(id);
|
||||||
|
return Response.status(Response.Status.OK).entity(notification).build();
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
msg = "Notification updated successfully. But the retrial of the updated notification failed";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.OK).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,6 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.PolicyManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.PolicyManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
@ -45,6 +44,8 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
|
|||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ import java.util.List;
|
|||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public class PolicyManagementServiceImpl implements PolicyManagementService {
|
public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||||
|
|
||||||
|
private static final String API_BASE_PATH = "/policies";
|
||||||
private static final Log log = LogFactory.getLog(PolicyManagementServiceImpl.class);
|
private static final Log log = LogFactory.getLog(PolicyManagementServiceImpl.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -74,31 +76,38 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
String username = threadLocalCarbonContext.getUsername();
|
String username = threadLocalCarbonContext.getUsername();
|
||||||
try {
|
try {
|
||||||
if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, username)) {
|
if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, username)) {
|
||||||
throw new UnauthorizedAccessException(
|
return Response.status(Response.Status.UNAUTHORIZED).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage
|
new ErrorResponse.ErrorResponseBuilder().setMessage
|
||||||
("Current logged in user is not authorized to add policies").build());
|
("Current logged in user is not authorized to add policies").build()).build();
|
||||||
}
|
}
|
||||||
} catch (DeviceAccessAuthorizationException e) {
|
} catch (DeviceAccessAuthorizationException e) {
|
||||||
String msg = "ErrorResponse occurred while checking if the current user is authorized to add a policy";
|
String msg = "Error occurred while checking if the current user is authorized to add a policy";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
||||||
pap.addPolicy(policy);
|
Policy createdPolicy = pap.addPolicy(policy);
|
||||||
return Response.status(Response.Status.CREATED).entity("Policy has been added successfully").build();
|
|
||||||
|
return Response.created(new URI(API_BASE_PATH + "/" + createdPolicy.getId())).entity(createdPolicy).build();
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while adding policy";
|
String msg = "Error occurred while adding policy";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving device list.";
|
String msg = "Error occurred while retrieving device list.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
String msg = "Error occurred while composing the location URI, which represents information of the " +
|
||||||
|
"newly created policy";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.serverError().entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,21 +147,14 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
try {
|
try {
|
||||||
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
||||||
policies = policyAdministratorPoint.getPolicies();
|
policies = policyAdministratorPoint.getPolicies();
|
||||||
if (policies == null || policies.size() == 0) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No policies found.").build());
|
|
||||||
}
|
|
||||||
targetPolicies.setCount(policies.size());
|
targetPolicies.setCount(policies.size());
|
||||||
filteredPolicies = FilteringUtil.getFilteredList(policies, offset, limit);
|
filteredPolicies = FilteringUtil.getFilteredList(policies, offset, limit);
|
||||||
if (filteredPolicies.size() == 0) {
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity("No policies found.").build();
|
|
||||||
}
|
|
||||||
targetPolicies.setList(filteredPolicies);
|
targetPolicies.setList(filteredPolicies);
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving all available policies";
|
String msg = "Error occurred while retrieving all available policies";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.status(Response.Status.OK).entity(targetPolicies).build();
|
return Response.status(Response.Status.OK).entity(targetPolicies).build();
|
||||||
@ -168,14 +170,15 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
||||||
policy = policyAdministratorPoint.getPolicy(id);
|
policy = policyAdministratorPoint.getPolicy(id);
|
||||||
if (policy == null) {
|
if (policy == null) {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No policy found.").build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
|
"No policy found with the id '" + id + "'").build()).build();
|
||||||
}
|
}
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving policy corresponding to the id '" + id + "'";
|
String msg = "Error occurred while retrieving policy corresponding to the id '" + id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(policy).build();
|
return Response.status(Response.Status.OK).entity(policy).build();
|
||||||
}
|
}
|
||||||
@ -190,22 +193,22 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
Policy policy = this.getPolicyFromWrapper(policyWrapper);
|
Policy policy = this.getPolicyFromWrapper(policyWrapper);
|
||||||
policy.setId(id);
|
policy.setId(id);
|
||||||
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
||||||
Policy exisitingPolicy = pap.getPolicy(id);
|
Policy existingPolicy = pap.getPolicy(id);
|
||||||
if (exisitingPolicy == null) {
|
if (existingPolicy == null) {
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity("Policy not found.").build();
|
return Response.status(Response.Status.NOT_FOUND).entity("Policy not found.").build();
|
||||||
}
|
}
|
||||||
pap.updatePolicy(policy);
|
pap.updatePolicy(policy);
|
||||||
return Response.status(Response.Status.OK).entity("Policy has successfully been updated.").build();
|
return Response.status(Response.Status.OK).entity("Policy has successfully been updated.").build();
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while updating the policy";
|
String msg = "Error occurred while updating the policy";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving the device list.";
|
String msg = "Error occurred while retrieving the device list.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,15 +230,15 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while removing policies";
|
String msg = "ErrorResponse occurred while removing policies";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
if (policyDeleted) {
|
if (policyDeleted) {
|
||||||
return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build();
|
return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build();
|
||||||
} else {
|
} else {
|
||||||
//TODO:Check of this logic is correct
|
//TODO:Check of this logic is correct
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Policy doesn't exist").build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Policy doesn't exist").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,18 +259,18 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while activating policies";
|
String msg = "Error occurred while activating policies";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
if (isPolicyActivated) {
|
if (isPolicyActivated) {
|
||||||
return Response.status(Response.Status.OK).entity("Selected policies have been successfully activated")
|
return Response.status(Response.Status.OK).entity("Selected policies have been successfully activated")
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Selected policies have " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Selected policies have " +
|
||||||
"not been activated").build());
|
"not been activated").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,16 +293,16 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "Exception in inactivating policies.";
|
String msg = "Exception in inactivating policies.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
if (isPolicyDeActivated) {
|
if (isPolicyDeActivated) {
|
||||||
return Response.status(Response.Status.OK).entity("Selected policies have been successfully " +
|
return Response.status(Response.Status.OK).entity("Selected policies have been successfully " +
|
||||||
"deactivated").build();
|
"deactivated").build();
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Selected policies have " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Selected policies have " +
|
||||||
"not been deactivated").build());
|
"not been deactivated").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,8 +318,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "Exception in applying changes.";
|
String msg = "Exception in applying changes.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Changes have been successfully updated.").build();
|
return Response.status(Response.Status.OK).entity("Changes have been successfully updated.").build();
|
||||||
}
|
}
|
||||||
@ -340,17 +343,17 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String error = "Exception in updating policy priorities.";
|
String error = "Exception in updating policy priorities.";
|
||||||
log.error(error, e);
|
log.error(error, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(error).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(error).build()).build();
|
||||||
}
|
}
|
||||||
if (policiesUpdated) {
|
if (policiesUpdated) {
|
||||||
return Response.status(Response.Status.OK).entity("Policy Priorities successfully "
|
return Response.status(Response.Status.OK).entity("Policy Priorities successfully "
|
||||||
+ "updated.").build();
|
+ "updated.").build();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Policy priorities did "
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Policy priorities did "
|
||||||
+ "not update. Bad Request.").build());
|
+ "not update. Bad Request.").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,14 +23,12 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.wso2.carbon.CarbonConstants;
|
import org.wso2.carbon.CarbonConstants;
|
||||||
import org.wso2.carbon.base.MultitenantConstants;
|
import org.wso2.carbon.base.MultitenantConstants;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
|
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
|
||||||
import org.wso2.carbon.user.api.*;
|
import org.wso2.carbon.user.api.*;
|
||||||
import org.wso2.carbon.user.mgt.UserRealmProxy;
|
import org.wso2.carbon.user.mgt.UserRealmProxy;
|
||||||
@ -40,6 +38,8 @@ import org.wso2.carbon.user.mgt.common.UserAdminException;
|
|||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -49,6 +49,7 @@ import java.util.List;
|
|||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public class RoleManagementServiceImpl implements RoleManagementService {
|
public class RoleManagementServiceImpl implements RoleManagementService {
|
||||||
|
|
||||||
|
private static final String API_BASE_PATH = "/roles";
|
||||||
private static final Log log = LogFactory.getLog(RoleManagementServiceImpl.class);
|
private static final Log log = LogFactory.getLog(RoleManagementServiceImpl.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -61,25 +62,20 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
List<String> filteredRoles;
|
List<String> filteredRoles;
|
||||||
RoleList targetRoles = new RoleList();
|
RoleList targetRoles = new RoleList();
|
||||||
try {
|
try {
|
||||||
|
//Get the total role count that matches the given filter
|
||||||
filteredRoles = getRolesFromUserStore(filter);
|
filteredRoles = getRolesFromUserStore(filter);
|
||||||
if (filteredRoles == null || filteredRoles.size() == 0) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No roles found.").build());
|
|
||||||
}
|
|
||||||
targetRoles.setCount(filteredRoles.size());
|
targetRoles.setCount(filteredRoles.size());
|
||||||
|
|
||||||
filteredRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter), offset, limit);
|
filteredRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter), offset, limit);
|
||||||
if (filteredRoles.size() == 0) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No roles found").build());
|
|
||||||
}
|
|
||||||
targetRoles.setList(filteredRoles);
|
targetRoles.setList(filteredRoles);
|
||||||
|
|
||||||
|
return Response.ok().entity(targetRoles).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while retrieving roles from the underlying user stores";
|
String msg = "Error occurred while retrieving roles from the underlying user stores";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(targetRoles).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -91,35 +87,39 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
RequestValidationUtil.validateRoleName(roleName);
|
RequestValidationUtil.validateRoleName(roleName);
|
||||||
try {
|
try {
|
||||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||||
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
|
if (!userRealm.getUserStoreManager().isExistingRole(roleName)) {
|
||||||
final UIPermissionNode rolePermissions;
|
return Response.status(Response.Status.NOT_FOUND).entity(new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
if (userRealm instanceof org.wso2.carbon.user.core.UserRealm) {
|
"No role exists with the name '" + roleName + "'").build()).build();
|
||||||
userRealmCore = (org.wso2.carbon.user.core.UserRealm) userRealm;
|
|
||||||
}
|
}
|
||||||
final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore);
|
|
||||||
rolePermissions = this.getUIPermissionNode(roleName, userRealmProxy);
|
final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm);
|
||||||
if (rolePermissions == null) {
|
if (rolePermissions == null) {
|
||||||
throw new NotFoundException(
|
if (log.isDebugEnabled()) {
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No permissions found" +
|
log.debug("No permissions found for the role '" + roleName + "'");
|
||||||
" for the role '" + roleName + "'").build());
|
}
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(rolePermissions).build();
|
return Response.status(Response.Status.OK).entity(rolePermissions).build();
|
||||||
} catch (UserAdminException e) {
|
} catch (UserAdminException e) {
|
||||||
String msg = "Error occurred while retrieving the permissions of role '" + roleName + "'";
|
String msg = "Error occurred while retrieving the permissions of role '" + roleName + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while retrieving the underlying user realm attached to the " +
|
String msg = "Error occurred while retrieving the underlying user realm attached to the " +
|
||||||
"current logged in user";
|
"current logged in user";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UIPermissionNode getUIPermissionNode(String roleName, UserRealmProxy userRealmProxy)
|
private UIPermissionNode getUIPermissionNode(String roleName, UserRealm userRealm)
|
||||||
throws UserAdminException {
|
throws UserAdminException {
|
||||||
|
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
|
||||||
|
if (userRealm instanceof org.wso2.carbon.user.core.UserRealm) {
|
||||||
|
userRealmCore = (org.wso2.carbon.user.core.UserRealm) userRealm;
|
||||||
|
}
|
||||||
|
final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore);
|
||||||
final UIPermissionNode rolePermissions =
|
final UIPermissionNode rolePermissions =
|
||||||
userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID);
|
userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID);
|
||||||
UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2];
|
UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2];
|
||||||
@ -144,42 +144,36 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
@Override
|
@Override
|
||||||
public Response getRole(@PathParam("roleName") String roleName,
|
public Response getRole(@PathParam("roleName") String roleName,
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
RequestValidationUtil.validateRoleName(roleName);
|
|
||||||
RoleWrapper roleWrapper = new RoleWrapper();
|
|
||||||
try {
|
|
||||||
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
|
||||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
|
||||||
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
|
|
||||||
if (userRealm instanceof org.wso2.carbon.user.core.UserRealm) {
|
|
||||||
userRealmCore = (org.wso2.carbon.user.core.UserRealm) userRealm;
|
|
||||||
}
|
|
||||||
|
|
||||||
final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore);
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting the list of user roles");
|
log.debug("Getting the list of user roles");
|
||||||
}
|
}
|
||||||
if (userStoreManager.isExistingRole(roleName)) {
|
RequestValidationUtil.validateRoleName(roleName);
|
||||||
roleWrapper.setRoleName(roleName);
|
RoleInfo roleInfo = new RoleInfo();
|
||||||
roleWrapper.setUsers(userStoreManager.getUserListOfRole(roleName));
|
try {
|
||||||
|
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
|
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||||
|
if (!userStoreManager.isExistingRole(roleName)) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||||
|
roleName + "'").build()).build();
|
||||||
|
}
|
||||||
|
roleInfo.setRoleName(roleName);
|
||||||
|
roleInfo.setUsers(userStoreManager.getUserListOfRole(roleName));
|
||||||
// Get the permission nodes and hand picking only device management and login perms
|
// Get the permission nodes and hand picking only device management and login perms
|
||||||
final UIPermissionNode rolePermissions = getUIPermissionNode(roleName, userRealmProxy);
|
final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm);
|
||||||
List<String> permList = new ArrayList<>();
|
List<String> permList = new ArrayList<>();
|
||||||
this.iteratePermissions(rolePermissions, permList);
|
this.iteratePermissions(rolePermissions, permList);
|
||||||
roleWrapper.setPermissionList(rolePermissions);
|
roleInfo.setPermissionList(rolePermissions);
|
||||||
String[] permListAr = new String[permList.size()];
|
String[] permListAr = new String[permList.size()];
|
||||||
roleWrapper.setPermissions(permList.toArray(permListAr));
|
roleInfo.setPermissions(permList.toArray(permListAr));
|
||||||
} else {
|
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.OK).entity(roleInfo).build();
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("Role name doesn't exist.")
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
} catch (UserStoreException | UserAdminException e) {
|
} catch (UserStoreException | UserAdminException e) {
|
||||||
String msg = "Error occurred while retrieving the user role '" + roleName + "'";
|
String msg = "Error occurred while retrieving the user role '" + roleName + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(roleWrapper).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> iteratePermissions(UIPermissionNode uiPermissionNode, List<String> list) {
|
private List<String> iteratePermissions(UIPermissionNode uiPermissionNode, List<String> list) {
|
||||||
@ -194,78 +188,97 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Override
|
@Override
|
||||||
public Response addRole(RoleWrapper roleWrapper) {
|
public Response addRole(RoleInfo roleInfo) {
|
||||||
RequestValidationUtil.validateRoleDetails(roleWrapper);
|
RequestValidationUtil.validateRoleDetails(roleInfo);
|
||||||
RequestValidationUtil.validateRoleName(roleWrapper.getRoleName());
|
RequestValidationUtil.validateRoleName(roleInfo.getRoleName());
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Persisting the role to user store");
|
log.debug("Persisting the role in the underlying user store");
|
||||||
}
|
}
|
||||||
Permission[] permissions = null;
|
Permission[] permissions = null;
|
||||||
if (roleWrapper.getPermissions() != null && roleWrapper.getPermissions().length > 0) {
|
if (roleInfo.getPermissions() != null && roleInfo.getPermissions().length > 0) {
|
||||||
permissions = new Permission[roleWrapper.getPermissions().length];
|
permissions = new Permission[roleInfo.getPermissions().length];
|
||||||
|
|
||||||
for (int i = 0; i < permissions.length; i++) {
|
for (int i = 0; i < permissions.length; i++) {
|
||||||
String permission = roleWrapper.getPermissions()[i];
|
String permission = roleInfo.getPermissions()[i];
|
||||||
permissions[i] = new Permission(permission, CarbonConstants.UI_PERMISSION_ACTION);
|
permissions[i] = new Permission(permission, CarbonConstants.UI_PERMISSION_ACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
userStoreManager.addRole(roleWrapper.getRoleName(), roleWrapper.getUsers(), permissions);
|
userStoreManager.addRole(roleInfo.getRoleName(), roleInfo.getUsers(), permissions);
|
||||||
} catch (UserStoreException e) {
|
|
||||||
String msg = "Error occurred while adding role '" + roleWrapper.getRoleName() + "'";
|
//TODO fix what's returned in the entity
|
||||||
log.error(msg, e);
|
return Response.created(new URI(API_BASE_PATH + "/" + roleInfo.getRoleName())).entity(
|
||||||
throw new UnexpectedServerErrorException(
|
"Role '" + roleInfo.getRoleName() + "' has " +
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity("Role '" + roleWrapper.getRoleName() + "' has " +
|
|
||||||
"successfully been added").build();
|
"successfully been added").build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
String msg = "Error occurred while adding role '" + roleInfo.getRoleName() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.serverError().entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
String msg = "Error occurred while composing the URI at which the information of the newly created role " +
|
||||||
|
"can be retrieved";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.serverError().entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{roleName}")
|
@Path("/{roleName}")
|
||||||
@Override
|
@Override
|
||||||
public Response updateRole(@PathParam("roleName") String roleName, RoleWrapper roleWrapper) {
|
public Response updateRole(@PathParam("roleName") String roleName, RoleInfo roleInfo) {
|
||||||
RequestValidationUtil.validateRoleName(roleName);
|
RequestValidationUtil.validateRoleName(roleName);
|
||||||
RequestValidationUtil.validateRoleDetails(roleWrapper);
|
RequestValidationUtil.validateRoleDetails(roleInfo);
|
||||||
String newRoleName = roleWrapper.getRoleName();
|
|
||||||
try {
|
try {
|
||||||
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||||
final AuthorizationManager authorizationManager = DeviceMgtAPIUtils.getAuthorizationManager();
|
final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
|
||||||
|
if (!userStoreManager.isExistingRole(roleName)) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||||
|
roleName + "'").build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Updating the role to user store");
|
log.debug("Updating the role to user store");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String newRoleName = roleInfo.getRoleName();
|
||||||
if (newRoleName != null && !roleName.equals(newRoleName)) {
|
if (newRoleName != null && !roleName.equals(newRoleName)) {
|
||||||
userStoreManager.updateRoleName(roleName, newRoleName);
|
userStoreManager.updateRoleName(roleName, newRoleName);
|
||||||
}
|
}
|
||||||
if (roleWrapper.getUsers() != null) {
|
|
||||||
|
if (roleInfo.getUsers() != null) {
|
||||||
SetReferenceTransformer<String> transformer = new SetReferenceTransformer<>();
|
SetReferenceTransformer<String> transformer = new SetReferenceTransformer<>();
|
||||||
transformer.transform(Arrays.asList(userStoreManager.getUserListOfRole(newRoleName)),
|
transformer.transform(Arrays.asList(userStoreManager.getUserListOfRole(newRoleName)),
|
||||||
Arrays.asList(roleWrapper.getUsers()));
|
Arrays.asList(roleInfo.getUsers()));
|
||||||
final String[] usersToAdd = transformer.getObjectsToAdd().toArray(new String[transformer
|
final String[] usersToAdd = transformer.getObjectsToAdd().toArray(new String[transformer
|
||||||
.getObjectsToAdd().size()]);
|
.getObjectsToAdd().size()]);
|
||||||
final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer
|
final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer
|
||||||
.getObjectsToRemove().size()]);
|
.getObjectsToRemove().size()]);
|
||||||
userStoreManager.updateUserListOfRole(newRoleName, usersToDelete, usersToAdd);
|
userStoreManager.updateUserListOfRole(newRoleName, usersToDelete, usersToAdd);
|
||||||
}
|
}
|
||||||
if (roleWrapper.getPermissions() != null) {
|
|
||||||
|
if (roleInfo.getPermissions() != null) {
|
||||||
// Delete all authorizations for the current role before authorizing the permission tree
|
// Delete all authorizations for the current role before authorizing the permission tree
|
||||||
authorizationManager.clearRoleAuthorization(roleName);
|
authorizationManager.clearRoleAuthorization(roleName);
|
||||||
if (roleWrapper.getPermissions().length > 0) {
|
if (roleInfo.getPermissions().length > 0) {
|
||||||
for (int i = 0; i < roleWrapper.getPermissions().length; i++) {
|
for (int i = 0; i < roleInfo.getPermissions().length; i++) {
|
||||||
String permission = roleWrapper.getPermissions()[i];
|
String permission = roleInfo.getPermissions()[i];
|
||||||
authorizationManager.authorizeRole(roleName, permission, CarbonConstants.UI_PERMISSION_ACTION);
|
authorizationManager.authorizeRole(roleName, permission, CarbonConstants.UI_PERMISSION_ACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: Need to send the updated role information in the entity back to the client
|
||||||
|
return Response.status(Response.Status.OK).entity("Role '" + roleInfo.getRoleName() + "' has " +
|
||||||
|
"successfully been updated").build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while updating role '" + roleName + "'";
|
String msg = "Error occurred while updating role '" + roleName + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Role '" + roleWrapper.getRoleName() + "' has " +
|
|
||||||
"successfully been updated").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@ -274,22 +287,29 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
public Response deleteRole(@PathParam("roleName") String roleName) {
|
public Response deleteRole(@PathParam("roleName") String roleName) {
|
||||||
RequestValidationUtil.validateRoleName(roleName);
|
RequestValidationUtil.validateRoleName(roleName);
|
||||||
try {
|
try {
|
||||||
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||||
final AuthorizationManager authorizationManager = DeviceMgtAPIUtils.getAuthorizationManager();
|
final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
|
||||||
|
if (!userStoreManager.isExistingRole(roleName)) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||||
|
roleName + "'").build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Deleting the role in user store");
|
log.debug("Deleting the role in user store");
|
||||||
}
|
}
|
||||||
userStoreManager.deleteRole(roleName);
|
userStoreManager.deleteRole(roleName);
|
||||||
// Delete all authorizations for the current role before deleting
|
// Delete all authorizations for the current role before deleting
|
||||||
authorizationManager.clearRoleAuthorization(roleName);
|
authorizationManager.clearRoleAuthorization(roleName);
|
||||||
|
|
||||||
|
return Response.status(Response.Status.OK).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while deleting the role '" + roleName + "'";
|
String msg = "Error occurred while deleting the role '" + roleName + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " +
|
|
||||||
"successfully been deleted").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@ -312,20 +332,21 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
.getObjectsToRemove().size()]);
|
.getObjectsToRemove().size()]);
|
||||||
|
|
||||||
userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd);
|
userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd);
|
||||||
|
|
||||||
|
return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " +
|
||||||
|
"successfully been updated with the user list").build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while updating the users of the role '" + roleName + "'";
|
String msg = "Error occurred while updating the users of the role '" + roleName + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " +
|
|
||||||
"successfully been updated with the user list").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getRolesFromUserStore(String filter) throws UserStoreException {
|
private List<String> getRolesFromUserStore(String filter) throws UserStoreException {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
String[] roles;
|
String[] roles;
|
||||||
boolean filterRolesByName = ((filter == null) || filter.isEmpty() ? false : true);
|
boolean filterRolesByName = (!((filter == null) || filter.isEmpty()));
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting the list of user roles");
|
log.debug("Getting the list of user roles");
|
||||||
}
|
}
|
||||||
@ -334,10 +355,10 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
List<String> filteredRoles = new ArrayList<>();
|
List<String> filteredRoles = new ArrayList<>();
|
||||||
for (String role : roles) {
|
for (String role : roles) {
|
||||||
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/") || role.startsWith("Application/"))) {
|
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/") || role.startsWith("Application/"))) {
|
||||||
if(!filterRolesByName) {
|
if (!filterRolesByName) {
|
||||||
filteredRoles.add(role);
|
filteredRoles.add(role);
|
||||||
} else{
|
} else {
|
||||||
if(role.contains(filter)){
|
if (role.contains(filter)) {
|
||||||
filteredRoles.add(role);
|
filteredRoles.add(role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,24 +21,19 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
||||||
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.*;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.*;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.user.api.UserStoreException;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
import org.wso2.carbon.user.api.UserStoreManager;
|
import org.wso2.carbon.user.api.UserStoreManager;
|
||||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Path("/users")
|
@Path("/users")
|
||||||
@ -47,119 +42,61 @@ import java.util.*;
|
|||||||
public class UserManagementServiceImpl implements UserManagementService {
|
public class UserManagementServiceImpl implements UserManagementService {
|
||||||
|
|
||||||
private static final String ROLE_EVERYONE = "Internal/everyone";
|
private static final String ROLE_EVERYONE = "Internal/everyone";
|
||||||
|
private static final String API_BASE_PATH = "/users";
|
||||||
private static final Log log = LogFactory.getLog(UserManagementServiceImpl.class);
|
private static final Log log = LogFactory.getLog(UserManagementServiceImpl.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Override
|
@Override
|
||||||
public Response addUser(UserInfo userWrapper) {
|
public Response addUser(UserInfo userInfo) {
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (userStoreManager.isExistingUser(userWrapper.getUsername())) {
|
if (userStoreManager.isExistingUser(userInfo.getUsername())) {
|
||||||
// if user already exists
|
// if user already exists
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + userWrapper.getUsername() +
|
log.debug("User by username: " + userInfo.getUsername() +
|
||||||
" already exists. Therefore, request made to add user was refused.");
|
" already exists. Therefore, request made to add user was refused.");
|
||||||
}
|
}
|
||||||
// returning response with bad request state
|
// returning response with bad request state
|
||||||
throw new ConflictException(
|
return Response.status(Response.Status.CONFLICT).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(409l).setMessage("User by username: " +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " +
|
||||||
userWrapper.getUsername() + " already exists. Therefore, request made to add user " +
|
userInfo.getUsername() + " already exists. Therefore, request made to add user " +
|
||||||
"was refused.").build());
|
"was refused.").build()).build();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
String initialUserPassword = this.generateInitialUserPassword();
|
String initialUserPassword = this.generateInitialUserPassword();
|
||||||
Map<String, String> defaultUserClaims =
|
Map<String, String> defaultUserClaims =
|
||||||
this.buildDefaultUserClaims(userWrapper.getFirstname(), userWrapper.getLastname(),
|
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
||||||
userWrapper.getEmailAddress());
|
userInfo.getEmailAddress());
|
||||||
// calling addUser method of carbon user api
|
// calling addUser method of carbon user api
|
||||||
userStoreManager.addUser(userWrapper.getUsername(), initialUserPassword,
|
userStoreManager.addUser(userInfo.getUsername(), initialUserPassword,
|
||||||
userWrapper.getRoles(), defaultUserClaims, null);
|
userInfo.getRoles(), defaultUserClaims, null);
|
||||||
// invite newly added user to enroll device
|
|
||||||
this.inviteNewlyAddedUserToEnrollDevice(userWrapper.getUsername(), initialUserPassword);
|
|
||||||
// Outputting debug message upon successful addition of user
|
// Outputting debug message upon successful addition of user
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User '" + userWrapper.getUsername() + "' has successfully been added.");
|
log.debug("User '" + userInfo.getUsername() + "' has successfully been added.");
|
||||||
}
|
}
|
||||||
// returning response with success state
|
|
||||||
return Response.status(Response.Status.CREATED).entity("User by username: " + userWrapper.getUsername() +
|
BasicUserInfo createdUserInfo = this.getBasicUserInfo(userInfo.getUsername());
|
||||||
" was successfully added.").build();
|
// Outputting debug message upon successful retrieval of user
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("User by username: " + userInfo.getUsername() + " was found.");
|
||||||
}
|
}
|
||||||
|
return Response.created(new URI(API_BASE_PATH + "/" + userInfo.getUsername())).entity(
|
||||||
|
createdUserInfo).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Exception in trying to add user '" + userWrapper.getUsername() + "' to the user store";
|
String msg = "Error occurred while trying to add user '" + userInfo.getUsername() + "' to the " +
|
||||||
|
"underlying user management system";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (DeviceManagementException e) {
|
} catch (URISyntaxException e) {
|
||||||
String msg = "ErrorResponse occurred while inviting user to enroll the device";
|
String msg = "Error occurred while composing the location URI, which represents information of the " +
|
||||||
|
"newly created user '" + userInfo.getUsername() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> buildDefaultUserClaims(String firstname, String lastname, String emailAddress) {
|
|
||||||
Map<String, String> defaultUserClaims = new HashMap<>();
|
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_FIRST_NAME, firstname);
|
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_LAST_NAME, lastname);
|
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress);
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Default claim map is created for new user: " + defaultUserClaims.toString());
|
|
||||||
}
|
|
||||||
return defaultUserClaims;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateInitialUserPassword() {
|
|
||||||
int passwordLength = 6;
|
|
||||||
//defining the pool of characters to be used for initial password generation
|
|
||||||
String lowerCaseCharset = "abcdefghijklmnopqrstuvwxyz";
|
|
||||||
String upperCaseCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
||||||
String numericCharset = "0123456789";
|
|
||||||
Random randomGenerator = new Random();
|
|
||||||
String totalCharset = lowerCaseCharset + upperCaseCharset + numericCharset;
|
|
||||||
int totalCharsetLength = totalCharset.length();
|
|
||||||
StringBuilder initialUserPassword = new StringBuilder();
|
|
||||||
for (int i = 0; i < passwordLength; i++) {
|
|
||||||
initialUserPassword
|
|
||||||
.append(totalCharset.charAt(randomGenerator.nextInt(totalCharsetLength)));
|
|
||||||
}
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Initial user password is created for new user: " + initialUserPassword);
|
|
||||||
}
|
|
||||||
return initialUserPassword.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void inviteNewlyAddedUserToEnrollDevice(String username,
|
|
||||||
String password) throws DeviceManagementException, UserStoreException {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Sending invitation mail to user by username: " + username);
|
|
||||||
}
|
|
||||||
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
|
||||||
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(tenantDomain)) {
|
|
||||||
tenantDomain = "";
|
|
||||||
}
|
|
||||||
if (!username.contains("/")) {
|
|
||||||
username = "/" + username;
|
|
||||||
}
|
|
||||||
String[] usernameBits = username.split("/");
|
|
||||||
DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService();
|
|
||||||
|
|
||||||
Properties props = new Properties();
|
|
||||||
props.setProperty("username", usernameBits[1]);
|
|
||||||
props.setProperty("domain-name", tenantDomain);
|
|
||||||
props.setProperty("first-name", getClaimValue(usernameBits[1], Constants.USER_CLAIM_FIRST_NAME));
|
|
||||||
props.setProperty("password", password);
|
|
||||||
|
|
||||||
String recipient = getClaimValue(usernameBits[1], Constants.USER_CLAIM_EMAIL_ADDRESS);
|
|
||||||
|
|
||||||
EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props);
|
|
||||||
|
|
||||||
deviceManagementProviderService.sendRegistrationEmail(metaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getClaimValue(String username, String claimUri) throws UserStoreException {
|
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
|
||||||
return userStoreManager.getUserClaimValue(username, claimUri, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{username}")
|
@Path("/{username}")
|
||||||
@Override
|
@Override
|
||||||
@ -167,53 +104,52 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
BasicUserInfo user = new BasicUserInfo();
|
|
||||||
user.setUsername(username);
|
|
||||||
user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
|
|
||||||
user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
|
|
||||||
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
|
||||||
// Outputting debug message upon successful retrieval of user
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("User by username: " + username + " was found.");
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(user).build();
|
|
||||||
} else {
|
|
||||||
// Outputting debug message upon trying to remove non-existing user
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + username + " does not exist.");
|
log.debug("User by username: " + username + " does not exist.");
|
||||||
}
|
}
|
||||||
// returning response with bad request state
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
throw new NotFoundException(
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("User doesn't exist.")
|
"User doesn't exist.").build()).build();
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicUserInfo user = this.getBasicUserInfo(username);
|
||||||
|
return Response.status(Response.Status.OK).entity(user).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving information of the user '" + username + "'";
|
String msg = "Error occurred while retrieving information of the user '" + username + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{username}")
|
@Path("/{username}")
|
||||||
@Override
|
@Override
|
||||||
public Response updateUser(@PathParam("username") String username, UserInfo userWrapper) {
|
public Response updateUser(@PathParam("username") String username, UserInfo userInfo) {
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (userStoreManager.isExistingUser(userWrapper.getUsername())) {
|
if (!userStoreManager.isExistingUser(userInfo.getUsername())) {
|
||||||
Map<String, String> defaultUserClaims =
|
if (log.isDebugEnabled()) {
|
||||||
this.buildDefaultUserClaims(userWrapper.getFirstname(), userWrapper.getLastname(),
|
log.debug("User by username: " + userInfo.getUsername() +
|
||||||
userWrapper.getEmailAddress());
|
" doesn't exists. Therefore, request made to update user was refused.");
|
||||||
if (StringUtils.isNotEmpty(userWrapper.getPassword())) {
|
|
||||||
// Decoding Base64 encoded password
|
|
||||||
userStoreManager.updateCredentialByAdmin(userWrapper.getUsername(),
|
|
||||||
userWrapper.getPassword());
|
|
||||||
log.debug("User credential of username: " + userWrapper.getUsername() + " has been changed");
|
|
||||||
}
|
}
|
||||||
List<String> currentRoles = this.getFilteredRoles(userStoreManager, userWrapper.getUsername());
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
List<String> newRoles = Arrays.asList(userWrapper.getRoles());
|
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " +
|
||||||
|
userInfo.getUsername() + " doesn't exist.").build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> defaultUserClaims =
|
||||||
|
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
||||||
|
userInfo.getEmailAddress());
|
||||||
|
if (StringUtils.isNotEmpty(userInfo.getPassword())) {
|
||||||
|
// Decoding Base64 encoded password
|
||||||
|
userStoreManager.updateCredentialByAdmin(userInfo.getUsername(),
|
||||||
|
userInfo.getPassword());
|
||||||
|
log.debug("User credential of username: " + userInfo.getUsername() + " has been changed");
|
||||||
|
}
|
||||||
|
List<String> currentRoles = this.getFilteredRoles(userStoreManager, userInfo.getUsername());
|
||||||
|
List<String> newRoles = Arrays.asList(userInfo.getRoles());
|
||||||
|
|
||||||
List<String> rolesToAdd = new ArrayList<>(newRoles);
|
List<String> rolesToAdd = new ArrayList<>(newRoles);
|
||||||
List<String> rolesToDelete = new ArrayList<>();
|
List<String> rolesToDelete = new ArrayList<>();
|
||||||
@ -226,32 +162,22 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rolesToDelete.remove(ROLE_EVERYONE);
|
rolesToDelete.remove(ROLE_EVERYONE);
|
||||||
userStoreManager.updateRoleListOfUser(userWrapper.getUsername(),
|
userStoreManager.updateRoleListOfUser(userInfo.getUsername(),
|
||||||
rolesToDelete.toArray(new String[rolesToDelete.size()]),
|
rolesToDelete.toArray(new String[rolesToDelete.size()]),
|
||||||
rolesToAdd.toArray(new String[rolesToAdd.size()]));
|
rolesToAdd.toArray(new String[rolesToAdd.size()]));
|
||||||
userStoreManager.setUserClaimValues(userWrapper.getUsername(), defaultUserClaims, null);
|
userStoreManager.setUserClaimValues(userInfo.getUsername(), defaultUserClaims, null);
|
||||||
// Outputting debug message upon successful addition of user
|
// Outputting debug message upon successful addition of user
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + userWrapper.getUsername() + " was successfully updated.");
|
log.debug("User by username: " + userInfo.getUsername() + " was successfully updated.");
|
||||||
}
|
|
||||||
// returning response with success state
|
|
||||||
return Response.status(Response.Status.CREATED).entity("User by username '" + userWrapper.getUsername() +
|
|
||||||
"' was successfully updated.").build();
|
|
||||||
} else {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("User by username: " + userWrapper.getUsername() +
|
|
||||||
" doesn't exists. Therefore, request made to update user was refused.");
|
|
||||||
}
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("User by username: " +
|
|
||||||
userWrapper.getUsername() + " doesn't exists. Therefore, request made to update user" +
|
|
||||||
" was refused.").build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicUserInfo updatedUserInfo = this.getBasicUserInfo(username);
|
||||||
|
return Response.ok().entity(updatedUserInfo).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Exception in trying to update user by username: " + userWrapper.getUsername();
|
String msg = "Error occurred while trying to update user '" + userInfo.getUsername() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,31 +203,25 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
public Response removeUser(@PathParam("username") String username) {
|
public Response removeUser(@PathParam("username") String username) {
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
// if user already exists, trying to remove user
|
|
||||||
userStoreManager.deleteUser(username);
|
|
||||||
// Outputting debug message upon successful removal of user
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("User by username: " + username + " was successfully removed.");
|
|
||||||
}
|
|
||||||
// returning response with success state
|
|
||||||
return Response.status(Response.Status.OK).entity("User by username: " + username +
|
|
||||||
" was successfully removed.").build();
|
|
||||||
} else {
|
|
||||||
// Outputting debug message upon trying to remove non-existing user
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + username + " does not exist for removal.");
|
log.debug("User by username: " + username + " does not exist for removal.");
|
||||||
}
|
}
|
||||||
// returning response with bad request state
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
throw new NotFoundException(
|
new ErrorResponse.ErrorResponseBuilder().setMessage("User '" +
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("User by username: " +
|
username + "' does not exist for removal.").build()).build();
|
||||||
username + " does not exist for removal.").build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userStoreManager.deleteUser(username);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("User '" + username + "' was successfully removed.");
|
||||||
|
}
|
||||||
|
return Response.status(Response.Status.OK).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Exception in trying to remove user by username: " + username;
|
String msg = "Exception in trying to remove user by username: " + username;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,24 +231,23 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
public Response getRolesOfUser(@PathParam("username") String username) {
|
public Response getRolesOfUser(@PathParam("username") String username) {
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
RoleList result = new RoleList();
|
|
||||||
result.setList(getFilteredRoles(userStoreManager, username));
|
|
||||||
return Response.status(Response.Status.OK).entity(result).build();
|
|
||||||
} else {
|
|
||||||
// Outputting debug message upon trying to remove non-existing user
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + username + " does not exist for role retrieval.");
|
log.debug("User by username: " + username + " does not exist for role retrieval.");
|
||||||
}
|
}
|
||||||
throw new NotFoundException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("User by username: " + username +
|
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + username +
|
||||||
" does not exist for role retrieval.").build());
|
" does not exist for role retrieval.").build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RoleList result = new RoleList();
|
||||||
|
result.setList(getFilteredRoles(userStoreManager, username));
|
||||||
|
return Response.status(Response.Status.OK).entity(result).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Exception in trying to retrieve roles for user by username: " + username;
|
String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,10 +290,10 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
|
|
||||||
return Response.status(Response.Status.OK).entity(result).build();
|
return Response.status(Response.Status.OK).entity(result).build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "ErrorResponse occurred while retrieving the list of users.";
|
String msg = "Error occurred while retrieving the list of users.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +326,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while retrieving the list of users using the filter : " + filter;
|
String msg = "Error occurred while retrieving the list of users using the filter : " + filter;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,4 +338,49 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
return CredentialManagementResponseBuilder.buildChangePasswordResponse(username, credentials);
|
return CredentialManagementResponseBuilder.buildChangePasswordResponse(username, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String> buildDefaultUserClaims(String firstName, String lastName, String emailAddress) {
|
||||||
|
Map<String, String> defaultUserClaims = new HashMap<>();
|
||||||
|
defaultUserClaims.put(Constants.USER_CLAIM_FIRST_NAME, firstName);
|
||||||
|
defaultUserClaims.put(Constants.USER_CLAIM_LAST_NAME, lastName);
|
||||||
|
defaultUserClaims.put(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Default claim map is created for new user: " + defaultUserClaims.toString());
|
||||||
|
}
|
||||||
|
return defaultUserClaims;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateInitialUserPassword() {
|
||||||
|
int passwordLength = 6;
|
||||||
|
//defining the pool of characters to be used for initial password generation
|
||||||
|
String lowerCaseCharset = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
String upperCaseCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
String numericCharset = "0123456789";
|
||||||
|
Random randomGenerator = new Random();
|
||||||
|
String totalCharset = lowerCaseCharset + upperCaseCharset + numericCharset;
|
||||||
|
int totalCharsetLength = totalCharset.length();
|
||||||
|
StringBuilder initialUserPassword = new StringBuilder();
|
||||||
|
for (int i = 0; i < passwordLength; i++) {
|
||||||
|
initialUserPassword.append(
|
||||||
|
totalCharset.charAt(randomGenerator.nextInt(totalCharsetLength)));
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initial user password is created for new user: " + initialUserPassword);
|
||||||
|
}
|
||||||
|
return initialUserPassword.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BasicUserInfo getBasicUserInfo(String username) throws UserStoreException {
|
||||||
|
BasicUserInfo userInfo = new BasicUserInfo();
|
||||||
|
userInfo.setUsername(username);
|
||||||
|
userInfo.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
|
||||||
|
userInfo.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
|
||||||
|
userInfo.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getClaimValue(String username, String claimUri) throws UserStoreException {
|
||||||
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
|
return userStoreManager.getUserClaimValue(username, claimUri, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException;
|
import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.ApplicationManagementAdminService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.ApplicationManagementAdminService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.MDMAndroidOperationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.util.MDMAndroidOperationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.MDMIOSOperationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.util.MDMIOSOperationUtil;
|
||||||
@ -82,21 +80,22 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
|
|||||||
applicationWrapper.getDeviceIdentifiers().size() > 0) {
|
applicationWrapper.getDeviceIdentifiers().size() > 0) {
|
||||||
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
|
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
|
||||||
} else {
|
} else {
|
||||||
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
"No application installation criteria i.e. user/role/device is given").build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
|
"No application installation criteria i.e. user/role/device is given").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(activity).build();
|
return Response.status(Response.Status.ACCEPTED).entity(activity).build();
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while processing application installation request";
|
String msg = "Error occurred while processing application installation request";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (UnknownApplicationTypeException e) {
|
} catch (UnknownApplicationTypeException e) {
|
||||||
String msg = "The type of application requested to be installed is not supported";
|
String msg = "The type of application requested to be installed is not supported";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,22 +129,22 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
|
|||||||
applicationWrapper.getDeviceIdentifiers().size() > 0) {
|
applicationWrapper.getDeviceIdentifiers().size() > 0) {
|
||||||
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
|
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
|
||||||
} else {
|
} else {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
"No application un-installation criteria i.e. user/role/device is given").build());
|
"No application un-installation criteria i.e. user/role/device is given").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(activity).build();
|
return Response.status(Response.Status.ACCEPTED).entity(activity).build();
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while processing application un-installation request";
|
String msg = "Error occurred while processing application un-installation request";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (UnknownApplicationTypeException e) {
|
} catch (UnknownApplicationTypeException e) {
|
||||||
String msg = "The type of application requested to be un-installed is not supported";
|
String msg = "The type of application requested to be un-installed is not supported";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,8 +28,6 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceManagementAdminService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceManagementAdminService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -55,9 +53,9 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
try {
|
try {
|
||||||
int currentTenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int currentTenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
if (MultitenantConstants.SUPER_TENANT_ID != currentTenantId) {
|
if (MultitenantConstants.SUPER_TENANT_ID != currentTenantId) {
|
||||||
throw new UnauthorizedAccessException(
|
return Response.status(Response.Status.UNAUTHORIZED).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(
|
new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||||
"Current logged in user is not authorized to perform this operation").build());
|
"Current logged in user is not authorized to perform this operation").build()).build();
|
||||||
}
|
}
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
|
||||||
@ -65,11 +63,6 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
|
|
||||||
List<Device> devices = DeviceMgtAPIUtils.getDeviceManagementService().
|
List<Device> devices = DeviceMgtAPIUtils.getDeviceManagementService().
|
||||||
getDevicesByNameAndType(name, type, offset, limit);
|
getDevicesByNameAndType(name, type, offset, limit);
|
||||||
if (devices == null || devices.size() == 0) {
|
|
||||||
throw new NotFoundException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No device, which carries" +
|
|
||||||
" the name '" + name + "', is currently enrolled in the system").build());
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting up paginated result
|
// setting up paginated result
|
||||||
DeviceList deviceList = new DeviceList();
|
DeviceList deviceList = new DeviceList();
|
||||||
@ -80,8 +73,8 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred at server side while fetching device list.";
|
String msg = "Error occurred at server side while fetching device list.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,8 +304,8 @@ public class RequestValidationUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateRoleDetails(RoleWrapper roleWrapper) {
|
public static void validateRoleDetails(RoleInfo roleInfo) {
|
||||||
if (roleWrapper == null) {
|
if (roleInfo == null) {
|
||||||
throw new InputValidationException(
|
throw new InputValidationException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is incorrect or" +
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is incorrect or" +
|
||||||
" empty").build());
|
" empty").build());
|
||||||
|
|||||||
@ -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.swagger.extension;
|
||||||
|
|
||||||
|
import io.swagger.annotations.SwaggerDefinition;
|
||||||
|
import io.swagger.jaxrs.Reader;
|
||||||
|
import io.swagger.jaxrs.config.ReaderListener;
|
||||||
|
import io.swagger.models.Swagger;
|
||||||
|
import io.swagger.models.auth.OAuth2Definition;
|
||||||
|
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SwaggerDefinition(
|
||||||
|
basePath = "/api/device-mgt/v1.0",
|
||||||
|
host = "localhost:9443"
|
||||||
|
)
|
||||||
|
public class SecurityDefinitionConfigurator implements ReaderListener {
|
||||||
|
|
||||||
|
public static final String TOKEN_AUTH_SCHEME = "tokenAuthScheme";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeScan(Reader reader, Swagger swagger) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterScan(Reader reader, Swagger swagger) {
|
||||||
|
OAuth2Definition tokenScheme = new OAuth2Definition();
|
||||||
|
tokenScheme.setType("oauth2");
|
||||||
|
tokenScheme.setFlow("password");
|
||||||
|
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth/token");
|
||||||
|
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth/authorize");
|
||||||
|
|
||||||
|
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
|
||||||
|
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
|
||||||
|
|
||||||
|
swagger.setSecurityDefinitions(schemes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -21,11 +21,9 @@ package org.wso2.carbon.device.mgt.jaxrs.util;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
|
||||||
import org.wso2.carbon.user.api.UserStoreException;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
import org.wso2.carbon.user.api.UserStoreManager;
|
import org.wso2.carbon.user.api.UserStoreManager;
|
||||||
|
|
||||||
@ -44,6 +42,7 @@ public class CredentialManagementResponseBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the response to change the password of a user
|
* Builds the response to change the password of a user
|
||||||
|
*
|
||||||
* @param username - Username of the user.
|
* @param username - Username of the user.
|
||||||
* @param credentials - User credentials
|
* @param credentials - User credentials
|
||||||
* @return Response Object
|
* @return Response Object
|
||||||
@ -52,17 +51,17 @@ public class CredentialManagementResponseBuilder {
|
|||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("No user found with the username "
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No user found with the username '"
|
||||||
+ username).build());
|
+ username + "'").build()).build();
|
||||||
}
|
}
|
||||||
RequestValidationUtil.validateCredentials(credentials);
|
RequestValidationUtil.validateCredentials(credentials);
|
||||||
|
|
||||||
if (!validateCredential(credentials.getNewPassword())) {
|
if (!validateCredential(credentials.getNewPassword())) {
|
||||||
String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
|
String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
|
||||||
.getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
|
.getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMsg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build();
|
||||||
}
|
}
|
||||||
userStoreManager.updateCredential(username, credentials.getNewPassword(),
|
userStoreManager.updateCredential(username, credentials.getNewPassword(),
|
||||||
credentials.getOldPassword());
|
credentials.getOldPassword());
|
||||||
@ -70,19 +69,20 @@ public class CredentialManagementResponseBuilder {
|
|||||||
username + " was successfully changed.").build();
|
username + " was successfully changed.").build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(e.getMessage()).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()).build();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
String msg = "Could not change the password of the user: " + username +
|
String msg = "Could not change the password of the user: " + username +
|
||||||
". The Character Encoding is not supported.";
|
". The Character Encoding is not supported.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the response to reset the password of a user
|
* Builds the response to reset the password of a user
|
||||||
|
*
|
||||||
* @param username - Username of the user.
|
* @param username - Username of the user.
|
||||||
* @param credentials - User credentials
|
* @param credentials - User credentials
|
||||||
* @return Response Object
|
* @return Response Object
|
||||||
@ -91,35 +91,35 @@ public class CredentialManagementResponseBuilder {
|
|||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("No user found with the username "
|
new ErrorResponse.ErrorResponseBuilder().setMessage("No user found with the username "
|
||||||
+ username).build());
|
+ username).build()).build();
|
||||||
}
|
}
|
||||||
if (credentials == null || credentials.getNewPassword() == null) {
|
if (credentials == null || credentials.getNewPassword() == null) {
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Password cannot be empty."
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Password cannot be empty."
|
||||||
+ username).build());
|
+ username).build()).build();
|
||||||
}
|
}
|
||||||
if (!validateCredential(credentials.getNewPassword())) {
|
if (!validateCredential(credentials.getNewPassword())) {
|
||||||
String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
|
String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
|
||||||
.getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
|
.getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
|
||||||
throw new InputValidationException(
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMsg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build();
|
||||||
}
|
}
|
||||||
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
|
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
|
||||||
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
|
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
|
||||||
username + " was successfully changed.").build();
|
username + " was successfully changed.").build();
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "ErrorResponse occurred while updating the credentials of user '" + username + "'";
|
String msg = "Error occurred while updating the credentials of user '" + username + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
String msg = "Could not change the password of the user: " + username +
|
String msg = "Could not change the password of the user: " + username +
|
||||||
". The Character Encoding is not supported.";
|
". The Character Encoding is not supported.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,10 @@ public class Application implements Serializable {
|
|||||||
private Properties appProperties;
|
private Properties appProperties;
|
||||||
@ApiModelProperty(name = "applicationIdentifier", value = "The application identifier", required = true)
|
@ApiModelProperty(name = "applicationIdentifier", value = "The application identifier", required = true)
|
||||||
private String applicationIdentifier;
|
private String applicationIdentifier;
|
||||||
@ApiModelProperty(name = "memoryUsage", value = "AMount of memory used by the application", required = true)
|
@ApiModelProperty(name = "memoryUsage", value = "Amount of memory used by the application", required = true)
|
||||||
private int memoryUsage;
|
private int memoryUsage;
|
||||||
|
@ApiModelProperty(name = "isActive", value = "Is the application actively running", required = true)
|
||||||
|
private boolean isActive;
|
||||||
|
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
@ -166,4 +168,12 @@ public class Application implements Serializable {
|
|||||||
this.appProperties = appProperties;
|
this.appProperties = appProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean active) {
|
||||||
|
isActive = active;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,9 @@ public class DeviceInfo implements Serializable {
|
|||||||
@ApiModelProperty(name = "osVersion", value = "Operating system version.", required = true)
|
@ApiModelProperty(name = "osVersion", value = "Operating system version.", required = true)
|
||||||
private String osVersion;
|
private String osVersion;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "osBuildDate", value = "Operating system build date.", required = true)
|
||||||
|
private String osBuildDate;
|
||||||
|
|
||||||
@ApiModelProperty(name = "batteryLevel", value = "Battery level of the device.", required = true)
|
@ApiModelProperty(name = "batteryLevel", value = "Battery level of the device.", required = true)
|
||||||
private Double batteryLevel;
|
private Double batteryLevel;
|
||||||
|
|
||||||
@ -201,6 +204,19 @@ public class DeviceInfo implements Serializable {
|
|||||||
this.osVersion = osVersion;
|
this.osVersion = osVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getOsBuildDate() {
|
||||||
|
if (osBuildDate != null) {
|
||||||
|
return osBuildDate;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOsBuildDate(String osBuildDate) {
|
||||||
|
this.osBuildDate = osBuildDate;
|
||||||
|
}
|
||||||
|
|
||||||
public Double getBatteryLevel() {
|
public Double getBatteryLevel() {
|
||||||
if (batteryLevel != null) {
|
if (batteryLevel != null) {
|
||||||
return batteryLevel;
|
return batteryLevel;
|
||||||
|
|||||||
@ -71,6 +71,8 @@ public interface NotificationManagementService {
|
|||||||
*/
|
*/
|
||||||
List<Notification> getAllNotifications() throws NotificationManagementException;
|
List<Notification> getAllNotifications() throws NotificationManagementException;
|
||||||
|
|
||||||
|
Notification getNotification(int notificationId) throws NotificationManagementException;
|
||||||
|
|
||||||
PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException;
|
PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -47,8 +47,8 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
|
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
|
||||||
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID, APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE) " +
|
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID, APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE, IS_ACTIVE) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
stmt.setString(1, application.getName());
|
stmt.setString(1, application.getName());
|
||||||
stmt.setString(2, application.getPlatform());
|
stmt.setString(2, application.getPlatform());
|
||||||
@ -66,6 +66,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
|
|
||||||
stmt.setString(10, application.getApplicationIdentifier());
|
stmt.setString(10, application.getApplicationIdentifier());
|
||||||
stmt.setInt(11, application.getMemoryUsage());
|
stmt.setInt(11, application.getMemoryUsage());
|
||||||
|
stmt.setBoolean(12, application.isActive());
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
|
||||||
rs = stmt.getGeneratedKeys();
|
rs = stmt.getGeneratedKeys();
|
||||||
@ -109,8 +110,8 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
|
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
|
||||||
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID,APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE) " +
|
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID,APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE, IS_ACTIVE) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new String[]{"id"});
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new String[]{"id"});
|
||||||
|
|
||||||
|
|
||||||
for (Application application : applications) {
|
for (Application application : applications) {
|
||||||
@ -131,6 +132,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
|
|
||||||
stmt.setString(10, application.getApplicationIdentifier());
|
stmt.setString(10, application.getApplicationIdentifier());
|
||||||
stmt.setInt(11, application.getMemoryUsage());
|
stmt.setInt(11, application.getMemoryUsage());
|
||||||
|
stmt.setBoolean(12, application.isActive());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
rs = stmt.getGeneratedKeys();
|
rs = stmt.getGeneratedKeys();
|
||||||
@ -208,7 +210,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
||||||
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
|
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
|
||||||
"AND TENANT_ID = ?");
|
"AND TENANT_ID = ?");
|
||||||
stmt.setString(1, identifier);
|
stmt.setString(1, identifier);
|
||||||
stmt.setInt(2, tenantId);
|
stmt.setInt(2, tenantId);
|
||||||
@ -240,7 +242,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
||||||
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, TENANT_ID From DM_APPLICATION app " +
|
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID From DM_APPLICATION app " +
|
||||||
"INNER JOIN " +
|
"INNER JOIN " +
|
||||||
"(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
|
"(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
|
||||||
"ON " +
|
"ON " +
|
||||||
@ -287,6 +289,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|||||||
application.setPlatform(rs.getString("PLATFORM"));
|
application.setPlatform(rs.getString("PLATFORM"));
|
||||||
application.setVersion(rs.getString("VERSION"));
|
application.setVersion(rs.getString("VERSION"));
|
||||||
application.setMemoryUsage(rs.getInt("MEMORY_USAGE"));
|
application.setMemoryUsage(rs.getInt("MEMORY_USAGE"));
|
||||||
|
application.setActive(rs.getBoolean("IS_ACTIVE"));
|
||||||
application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER"));
|
application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER"));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@ -209,6 +209,7 @@ public final class DeviceManagementDAOUtil {
|
|||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("INTERNAL_TOTAL_MEMORY"));
|
deviceInfo.setInternalTotalMemory(rs.getDouble("INTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
|||||||
@ -48,27 +48,28 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
|
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
|
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
|
||||||
"VENDOR, OS_VERSION, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
|
"VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
|
||||||
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
|
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
|
||||||
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP) " +
|
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setString(2, deviceInfo.getDeviceModel());
|
stmt.setString(2, deviceInfo.getDeviceModel());
|
||||||
stmt.setString(3, deviceInfo.getVendor());
|
stmt.setString(3, deviceInfo.getVendor());
|
||||||
stmt.setString(4, deviceInfo.getOsVersion());
|
stmt.setString(4, deviceInfo.getOsVersion());
|
||||||
stmt.setDouble(5, deviceInfo.getBatteryLevel());
|
stmt.setString(5, deviceInfo.getOsBuildDate());
|
||||||
stmt.setDouble(6, deviceInfo.getInternalTotalMemory());
|
stmt.setDouble(6, deviceInfo.getBatteryLevel());
|
||||||
stmt.setDouble(7, deviceInfo.getInternalAvailableMemory());
|
stmt.setDouble(7, deviceInfo.getInternalTotalMemory());
|
||||||
stmt.setDouble(8, deviceInfo.getExternalTotalMemory());
|
stmt.setDouble(8, deviceInfo.getInternalAvailableMemory());
|
||||||
stmt.setDouble(9, deviceInfo.getExternalAvailableMemory());
|
stmt.setDouble(9, deviceInfo.getExternalTotalMemory());
|
||||||
stmt.setString(10, deviceInfo.getConnectionType());
|
stmt.setDouble(10, deviceInfo.getExternalAvailableMemory());
|
||||||
stmt.setString(11, deviceInfo.getSsid());
|
stmt.setString(11, deviceInfo.getConnectionType());
|
||||||
stmt.setDouble(12, deviceInfo.getCpuUsage());
|
stmt.setString(12, deviceInfo.getSsid());
|
||||||
stmt.setDouble(13, deviceInfo.getTotalRAMMemory());
|
stmt.setDouble(13, deviceInfo.getCpuUsage());
|
||||||
stmt.setDouble(14, deviceInfo.getAvailableRAMMemory());
|
stmt.setDouble(14, deviceInfo.getTotalRAMMemory());
|
||||||
stmt.setBoolean(15, deviceInfo.isPluggedIn());
|
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
|
||||||
stmt.setLong(16, System.currentTimeMillis());
|
stmt.setBoolean(16, deviceInfo.isPluggedIn());
|
||||||
|
stmt.setLong(17, System.currentTimeMillis());
|
||||||
|
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("INTERNAL_TOTAL_MEMORY"));
|
deviceInfo.setInternalTotalMemory(rs.getDouble("INTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
|||||||
@ -160,6 +160,19 @@ public class NotificationManagementServiceImpl implements NotificationManagement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Notification getNotification(int notificationId) throws NotificationManagementException {
|
||||||
|
try {
|
||||||
|
NotificationManagementDAOFactory.openConnection();
|
||||||
|
return notificationDAO.getNotification(NotificationDAOUtil.getTenantId(), notificationId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new NotificationManagementException("Error occurred while opening a connection to" +
|
||||||
|
" the data source", e);
|
||||||
|
} finally {
|
||||||
|
NotificationManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException {
|
public PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException {
|
||||||
PaginationResult paginationResult = new PaginationResult();
|
PaginationResult paginationResult = new PaginationResult();
|
||||||
|
|||||||
@ -71,6 +71,8 @@ public interface NotificationDAO {
|
|||||||
*/
|
*/
|
||||||
List<Notification> getAllNotifications(int tenantId) throws NotificationManagementException;
|
List<Notification> getAllNotifications(int tenantId) throws NotificationManagementException;
|
||||||
|
|
||||||
|
Notification getNotification(int tenantId, int notificationId) throws NotificationManagementException;
|
||||||
|
|
||||||
List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException;
|
List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException;
|
||||||
|
|
||||||
int getNotificationCount(int tenantId) throws NotificationManagementException;
|
int getNotificationCount(int tenantId) throws NotificationManagementException;
|
||||||
|
|||||||
@ -70,6 +70,35 @@ public class NotificationDAOImpl implements NotificationDAO {
|
|||||||
return notificationId;
|
return notificationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Notification getNotification(int tenantId, int notificationId) throws NotificationManagementException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
Notification notification = null;
|
||||||
|
try {
|
||||||
|
conn = NotificationManagementDAOFactory.getConnection();
|
||||||
|
String sql =
|
||||||
|
"SELECT NOTIFICATION_ID, OPERATION_ID, DESCRIPTION, STATUS FROM DM_NOTIFICATION WHERE " +
|
||||||
|
"TENANT_ID = ? AND NOTIFICATION_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, tenantId);
|
||||||
|
stmt.setInt(2, notificationId);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
notification = this.getNotification(rs);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new NotificationManagementException(
|
||||||
|
"Error occurred while retrieving information of all notifications", e);
|
||||||
|
} finally {
|
||||||
|
NotificationDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
return notification;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateNotification(Notification notification)
|
public int updateNotification(Notification notification)
|
||||||
throws NotificationManagementException {
|
throws NotificationManagementException {
|
||||||
|
|||||||
@ -79,6 +79,7 @@ public class SearchDAOImpl implements SearchDAO {
|
|||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
@ -156,6 +157,7 @@ public class SearchDAOImpl implements SearchDAO {
|
|||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
|
|||||||
@ -192,7 +192,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
||||||
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
||||||
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
||||||
"DD.OS_VERSION, DD.BATTERY_LEVEL, DD.INTERNAL_TOTAL_MEMORY, DD.INTERNAL_AVAILABLE_MEMORY,\n" +
|
"DD.OS_VERSION, DD.OS_BUILD_DATE, DD.BATTERY_LEVEL, DD.INTERNAL_TOTAL_MEMORY, DD.INTERNAL_AVAILABLE_MEMORY,\n" +
|
||||||
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
||||||
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
||||||
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
||||||
@ -211,7 +211,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
||||||
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
||||||
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
||||||
"DD.OS_VERSION, DD.BATTERY_LEVEL, DD.INTERNAL_TOTAL_MEMORY, DD.INTERNAL_AVAILABLE_MEMORY,\n" +
|
"DD.OS_VERSION, DD.OS_BUILD_DATE, DD.BATTERY_LEVEL, DD.INTERNAL_TOTAL_MEMORY, DD.INTERNAL_AVAILABLE_MEMORY,\n" +
|
||||||
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
||||||
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
||||||
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public class Utils {
|
|||||||
genericColumnsMap.put("deviceModel", "DEVICE_MODEL");
|
genericColumnsMap.put("deviceModel", "DEVICE_MODEL");
|
||||||
genericColumnsMap.put("vendor", "VENDOR");
|
genericColumnsMap.put("vendor", "VENDOR");
|
||||||
genericColumnsMap.put("osVersion", "OS_VERSION");
|
genericColumnsMap.put("osVersion", "OS_VERSION");
|
||||||
|
genericColumnsMap.put("osBuildDate", "OS_BUILD_DATE");
|
||||||
genericColumnsMap.put("batteryLevel", "BATTERY_LEVEL");
|
genericColumnsMap.put("batteryLevel", "BATTERY_LEVEL");
|
||||||
genericColumnsMap.put("internalTotalMemory", "INTERNAL_TOTAL_MEMORY");
|
genericColumnsMap.put("internalTotalMemory", "INTERNAL_TOTAL_MEMORY");
|
||||||
genericColumnsMap.put("internalAvailableMemory", "INTERNAL_AVAILABLE_MEMORY");
|
genericColumnsMap.put("internalAvailableMemory", "INTERNAL_AVAILABLE_MEMORY");
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public class Utils {
|
|||||||
deviceInfo.setMobileSignalStrength(0.67);
|
deviceInfo.setMobileSignalStrength(0.67);
|
||||||
deviceInfo.setOperator("Dialog");
|
deviceInfo.setOperator("Dialog");
|
||||||
deviceInfo.setOsVersion("Lolipop");
|
deviceInfo.setOsVersion("Lolipop");
|
||||||
|
deviceInfo.setOsBuildDate("1467366458");
|
||||||
deviceInfo.setPluggedIn(true);
|
deviceInfo.setPluggedIn(true);
|
||||||
deviceInfo.setSsid("SSSSSS");
|
deviceInfo.setSsid("SSSSSS");
|
||||||
deviceInfo.setTotalRAMMemory(4.00);
|
deviceInfo.setTotalRAMMemory(4.00);
|
||||||
|
|||||||
@ -388,6 +388,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -468,6 +469,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -33,6 +33,7 @@ var DEVICE_VENDOR = "vendor";
|
|||||||
var DEVICE_MODEL = "model";
|
var DEVICE_MODEL = "model";
|
||||||
var DEVICE_PRODUCT = "PRODUCT";
|
var DEVICE_PRODUCT = "PRODUCT";
|
||||||
var DEVICE_OS_VERSION = "osVersion";
|
var DEVICE_OS_VERSION = "osVersion";
|
||||||
|
var DEVICE_OS_BUILD_DATE = "osBuildDate";
|
||||||
var DEVICE_PROPERTIES = "properties";
|
var DEVICE_PROPERTIES = "properties";
|
||||||
var DEVICE_ENROLLMENT_INFO = "enrolmentInfo";
|
var DEVICE_ENROLLMENT_INFO = "enrolmentInfo";
|
||||||
var DEVICE_STATUS = "status";
|
var DEVICE_STATUS = "status";
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public class PolicyManagementServiceComponent {
|
|||||||
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
|
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
|
||||||
if(policyConfiguration.getMonitoringEnable()) {
|
if(policyConfiguration.getMonitoringEnable()) {
|
||||||
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
|
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
|
||||||
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFequency());
|
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFrequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
@ -196,7 +196,7 @@ public class PolicyManagerUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getMonitoringFequency() throws PolicyManagementException {
|
public static int getMonitoringFrequency() throws PolicyManagementException {
|
||||||
|
|
||||||
PlatformConfigurationManagementService configMgtService = new PlatformConfigurationManagementServiceImpl();
|
PlatformConfigurationManagementService configMgtService = new PlatformConfigurationManagementServiceImpl();
|
||||||
PlatformConfiguration tenantConfiguration;
|
PlatformConfiguration tenantConfiguration;
|
||||||
|
|||||||
@ -392,6 +392,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -472,6 +473,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -392,6 +392,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -472,6 +473,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -399,6 +399,7 @@ CREATE TABLE DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES VARBINARY(max) NULL,
|
APP_PROPERTIES VARBINARY(max) NULL,
|
||||||
MEMORY_USAGE INTEGER NULL,
|
MEMORY_USAGE INTEGER NULL,
|
||||||
|
IS_ACTIVE BIT NOT NULL DEFAULT 'FALSE',
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -485,6 +486,7 @@ CREATE TABLE DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -365,6 +365,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
)ENGINE = InnoDB;
|
)ENGINE = InnoDB;
|
||||||
@ -506,6 +507,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -661,6 +661,7 @@ CREATE TABLE DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR2(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR2(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE NUMBER(10) NULL,
|
MEMORY_USAGE NUMBER(10) NULL,
|
||||||
|
IS_ACTIVE NUMBER(10) DEFAULT 0 NOT NULL,
|
||||||
TENANT_ID NUMBER(10) NOT NULL,
|
TENANT_ID NUMBER(10) NOT NULL,
|
||||||
CONSTRAINT PK_DM_APPLICATION PRIMARY KEY (ID)
|
CONSTRAINT PK_DM_APPLICATION PRIMARY KEY (ID)
|
||||||
)
|
)
|
||||||
@ -824,6 +825,7 @@ CREATE TABLE DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR2(45) NULL,
|
DEVICE_MODEL VARCHAR2(45) NULL,
|
||||||
VENDOR VARCHAR2(45) NULL,
|
VENDOR VARCHAR2(45) NULL,
|
||||||
OS_VERSION VARCHAR2(45) NULL,
|
OS_VERSION VARCHAR2(45) NULL,
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL NUMBER(4) NULL,
|
BATTERY_LEVEL NUMBER(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY NUMBER(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY NUMBER(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY NUMBER(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY NUMBER(30,3) NULL,
|
||||||
|
|||||||
@ -341,6 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||||
APP_PROPERTIES BYTEA NULL,
|
APP_PROPERTIES BYTEA NULL,
|
||||||
MEMORY_USAGE INTEGER NULL,
|
MEMORY_USAGE INTEGER NULL,
|
||||||
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL
|
TENANT_ID INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -415,6 +416,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
|
|
||||||
|
OS_BUILD_DATE VARCHAR(100) NULL,
|
||||||
BATTERY_LEVEL DECIMAL(4) NULL,
|
BATTERY_LEVEL DECIMAL(4) NULL,
|
||||||
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<artifactId>oauth-extensions-feature</artifactId>
|
<artifactId>oauth-extensions-feature</artifactId>
|
||||||
<version>1.1.1-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>WSO2 Carbon Device Management - OAuth Extensions Feature</name>
|
<name>WSO2 Carbon - Device Management OAuth Extensions Feature</name>
|
||||||
<url>http://wso2.org</url>
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user