device organization web servelet related modifications

backup
Isuri Mendis 1 year ago
parent e76a31b1b6
commit 17c94aab2f

@ -51,7 +51,7 @@ public class APIUtil {
private static final String DEFAULT_ENTERPRISE_TAG= "androidforwork";
private static final String DEFAULT_ANALYTICS_MGT_TAG= "analytics_management";
private static final String DEFAULT_DEVICE_ORGANIZATION_MGT_TAG= "deviceOrganization_management";
private static final String DEFAULT_DEVICE_ORGANIZATION_MGT_TAG= "device_organization_management";
public static final String PERMISSION_PROPERTY_NAME = "name";

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>io.entgra.device.mgt.core</groupId>
<version>5.0.31-SNAPSHOT</version>
<version>5.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -46,7 +46,7 @@
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
<warName>api#deviceOrganization-mgt-v1.0</warName>
<warName>api#device-org#v1.0</warName>
</configuration>
</plugin>
<plugin>
@ -98,7 +98,7 @@
<tasks>
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
<fileset dir="${basedir}/target">
<include name="api#deviceOrganization-mgt-v1.0.war" />
<include name="api#device-org#v1.0.war" />
</fileset>
</copy>
</tasks>

@ -17,7 +17,12 @@
*/
package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api;
import javax.servlet.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ -29,6 +29,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
@ -54,30 +55,51 @@ import javax.ws.rs.core.Response;
title = "",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "name", value = "DeviceOrganization Management"),
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/deviceOrganization"),
@ExtensionProperty(name = "name", value = "DeviceOrganizationManagement"),
@ExtensionProperty(name = "context", value = "/api/device-org/v1.0"),
})
}
),
tags = {
@Tag(name = "deviceOrganization_management, device_management", description = "DeviceOrganization management related REST-API. " +
"This can be used to manipulate device organization related details.")
@Tag(name = "device_organization_management, device_management", description = "Device organization " +
"management related REST-API. This can be used to manipulate device organization related details.")
}
)
@Api(value = "DeviceOrganization Management", description = "This API carries all device Organization management " +
@Api(value = "Device Organization Management", description = "This API carries all device organization management " +
"related operations.")
@Path("/deviceOrganization")
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Scopes(scopes = {
@Scope(
name = "Device Organization",
description = "Device Organization",
key = "dm:device-organization",
name = "View Device Organization",
description = "View Device Organization",
key = "dm:device-org:view",
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/devices/owning-device/organization"}
)
permissions = {"/device-mgt/organization/view"}
),
@Scope(
name = "Add Device Organization",
description = "Add Device Organization",
key = "dm:device-org:add",
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/organization/add"}
),
@Scope(
name = "Modify Device Organization",
description = "Modify Device Organization",
key = "dm:device-org:modify",
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/organization/modify"}
),
@Scope(
name = "Delete Device Organization",
description = "Delete Device Organization",
key = "dm:device-org:delete",
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/organization/delete"}
),
}
)
public interface DeviceOrganizationMgtService {
@ -91,7 +113,6 @@ public interface DeviceOrganizationMgtService {
* @return A response indicating the success or failure of the operation.
*/
@POST
@Path("/add-device-organization")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
@ -101,28 +122,41 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:add")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully created the device organization.",
response = String.class),
@ApiResponse(
code = 201,
message = "Created. Successfully created a new resource.",
response = Response.class),
message = "OK. \n Successfully created the device organization.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 400,
message = "Bad Request. Invalid input data.",
response = Response.class),
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = Response.class)
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response addDeviceOrganization(DeviceOrganization request);
@ -135,7 +169,7 @@ public interface DeviceOrganizationMgtService {
* @return A response containing a list of child device nodes.
*/
@GET
@Path("/children")
@Path("children")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -144,26 +178,43 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully retrieved the list of child nodes."
),
@ApiResponse(
code = 400,
message = "Bad Request. Invalid input data.",
response = ErrorResponse.class
),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class
)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the child devices.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response getChildrenOfDeviceNode(
@ApiParam(value = "The ID of the parent device node.", required = true)
@QueryParam("deviceId") int deviceId,
@ -183,7 +234,7 @@ public interface DeviceOrganizationMgtService {
* @return A response containing a list of parent device nodes.
*/
@GET
@Path("/parents")
@Path("parents")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -192,23 +243,43 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully retrieved the list of parent nodes."),
@ApiResponse(
code = 400,
message = "Bad Request. Invalid input data.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the parent devices.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response getParentsOfDeviceNode(
@ApiParam(value = "The ID of the child device node.", required = true)
@QueryParam("deviceId") int deviceId,
@ -224,7 +295,6 @@ public interface DeviceOrganizationMgtService {
* @return A response containing a list of all device organizations.
*/
@GET
@Path("/all")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -233,23 +303,43 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully retrieved the list of all device organizations."),
@ApiResponse(
code = 404,
message = "Not Found. \n No organizations found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the all devices.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response getAllDeviceOrganizations();
@ -257,11 +347,10 @@ public interface DeviceOrganizationMgtService {
* Retrieves a specific device organization by its organization ID.
*
* @param organizationId The organization ID of the device organization to retrieve.
* @return A response containing the device organization with the specifi
* ed ID.
* @return A response containing the device organization with the specified ID.
*/
@GET
@Path("/{organizationId}")
@Path("{organizationId}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -270,23 +359,43 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully retrieved the device organization by ID."),
@ApiResponse(
code = 404,
message = "Not Found. The specified organization does not exist.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the device organization by ID.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response getDeviceOrganizationById(@PathParam("organizationId") int organizationId);
@ -298,7 +407,7 @@ public interface DeviceOrganizationMgtService {
* @return A response indicating whether the organization exists or not.
*/
@GET
@Path("/exists")
@Path("exists")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -307,24 +416,43 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. The organization exists.",
response = Response.class),
@ApiResponse(
code = 404,
message = "Not Found. The organization does not exist.",
response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfull. The device organization exists.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response isDeviceOrganizationExist(
@QueryParam("deviceId") int deviceId,
@QueryParam("parentDeviceId") int parentDeviceId);
@ -338,7 +466,7 @@ public interface DeviceOrganizationMgtService {
* @return A response containing the retrieved DeviceOrganization object, or null if not found.
*/
@GET
@Path("/unique")
@Path("organization")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -347,101 +475,47 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. The organization exists.",
response = DeviceOrganization.class),
@ApiResponse(
code = 404,
message = "Not Found. The specified organization does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully retrieved organization details.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
})
Response getDeviceOrganizationByUniqueKey(
@QueryParam("deviceId") int deviceId,
@QueryParam("parentDeviceId") int parentDeviceId);
/**
* Checks whether a record with the specified device ID exists either in the deviceID column or
* parentDeviceID column in the device organization table.
*
* @param deviceId The ID of the device to check.
* @return A response indicating whether the device exists or not.
*/
@GET
@Path("/device-exists")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Check if Device ID Exists in Device Organization",
notes = "Checks whether a record with the specified device ID exists in the device organization table.",
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. The device exists in the device organization."),
@ApiResponse(
code = 404,
message = "Not Found. The device does not exist in the device organization."),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
Response doesDeviceIdExist(
@ApiParam(value = "The ID of the device to check.", required = true)
@QueryParam("deviceId") int deviceId);
/**
* Checks if a child device with the specified device ID already exists.
*
* @param deviceID The ID of the child device to check.
* @return A response indicating whether the child device exists or not.
*/
@GET
@Path("/child-exists")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Check if Child Device ID Exists in Device Organization",
notes = "Checks whether a child device with the specified device ID exists in the device organization.",
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. The child device exists in the device organization."),
@ApiResponse(
code = 404,
message = "Not Found. The child device does not exist in the device organization."),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = ErrorResponse.class)
})
Response isChildDeviceIdExist(
@ApiParam(value = "The ID of the child device to check.", required = true)
@QueryParam("deviceID") int deviceID);
/**
* Updates a device organization.
*
@ -449,7 +523,6 @@ public interface DeviceOrganizationMgtService {
* @return A response indicating the success or failure of the operation.
*/
@PUT
@Path("/update")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
@ -459,28 +532,46 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:modify")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully updated the device organization.",
response = Response.class),
@ApiResponse(
code = 400,
message = "Bad Request. Invalid input data.",
response = Response.class),
@ApiResponse(
code = 404,
message = "Not Found. The specified device organization does not exist.",
response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = Response.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully updated device organization.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
" of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n A deviceType with the specified device type was not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response updateDeviceOrganization(
@ApiParam(value = "The updated device organization.", required = true)
DeviceOrganization deviceOrganization);
@ -493,7 +584,7 @@ public interface DeviceOrganizationMgtService {
* @return A response indicating the success or failure of the operation.
*/
@DELETE
@Path("/delete/{organizationId}")
@Path("{organizationId}")
@ApiOperation(
httpMethod = "DELETE",
value = "Delete a Device Organization",
@ -501,24 +592,46 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:delete")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully deleted the device organization.",
response = Response.class),
@ApiResponse(
code = 404,
message = "Not Found. The specified device organization does not exist.",
response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = Response.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully deleted the device organization.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
" of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n A deviceType with the specified device type was not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response deleteDeviceOrganizationById(
@ApiParam(value = "The organization ID of the device organization to delete.", required = true)
@PathParam("organizationId") int organizationId);
@ -532,7 +645,7 @@ public interface DeviceOrganizationMgtService {
* @return A response indicating the success or failure of the operation.
*/
@DELETE
@Path("/delete-associations/{deviceId}")
@Path("associations/{deviceId}")
@ApiOperation(
httpMethod = "DELETE",
value = "Delete Device Associations",
@ -540,24 +653,46 @@ public interface DeviceOrganizationMgtService {
tags = "Device Organization Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "dm:device-organization")
@ExtensionProperty(name = SCOPE, value = "dm:device-org:delete")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. Successfully deleted the device associations.",
response = Response.class),
@ApiResponse(
code = 404,
message = "Not Found. No associations found for the specified device ID.",
response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. An error occurred while processing the request.",
response = Response.class)
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully deleted device organizations.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
" of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n A deviceType with the specified device type was not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response deleteDeviceAssociations(
@ApiParam(value = "The ID of the device for which associations should be deleted.", required = true)
@PathParam("deviceId") int deviceId);

@ -39,7 +39,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
@Path("/deviceOrganization")
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtService {
@ -49,7 +49,6 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@POST
@Override
@Path("/add-device-organization")
public Response addDeviceOrganization(DeviceOrganization deviceOrganizationRequest) {
if (deviceOrganizationRequest == null) {
String errorMessage = "The payload of the device organization is incorrect.";
@ -62,7 +61,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
}
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean resp = deviceOrganizationService.addDeviceOrganization(deviceOrganizationRequest);
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
return Response.status(Response.Status.OK).entity(resp).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -70,7 +69,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@GET
@Override
@Path("/children")
@Path("children")
public Response getChildrenOfDeviceNode(
@QueryParam("deviceId") int deviceId,
@QueryParam("maxDepth") int maxDepth,
@ -80,7 +79,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
DeviceNode deviceNode = new DeviceNode();
deviceNode.setDeviceId(deviceId);
List<DeviceNode> children = deviceOrganizationService.getChildrenOfDeviceNode(deviceNode, maxDepth, includeDevice);
return Response.status(Response.Status.OK).entity(gson.toJson(children)).build();
return Response.status(Response.Status.OK).entity(children).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -88,7 +87,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@GET
@Override
@Path("/parents")
@Path("parents")
public Response getParentsOfDeviceNode(
@QueryParam("deviceId") int deviceId,
@QueryParam("maxDepth") int maxDepth,
@ -98,7 +97,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
DeviceNode deviceNode = new DeviceNode();
deviceNode.setDeviceId(deviceId);
List<DeviceNode> parents = deviceOrganizationService.getParentsOfDeviceNode(deviceNode, maxDepth, includeDevice);
return Response.status(Response.Status.OK).entity(gson.toJson(parents)).build();
return Response.status(Response.Status.OK).entity(parents).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -106,12 +105,11 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@GET
@Override
@Path("/all")
public Response getAllDeviceOrganizations() {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
List<DeviceOrganization> organizations = deviceOrganizationService.getAllDeviceOrganizations();
return Response.status(Response.Status.OK).entity(gson.toJson(organizations)).build();
return Response.status(Response.Status.OK).entity(organizations).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -119,12 +117,12 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@GET
@Override
@Path("/{organizationId}")
@Path("{organizationId}")
public Response getDeviceOrganizationById(@PathParam("organizationId") int organizationId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
DeviceOrganization organization = deviceOrganizationService.getDeviceOrganizationByID(organizationId);
return Response.status(Response.Status.OK).entity(gson.toJson(organization)).build();
return Response.status(Response.Status.OK).entity(organization).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -132,56 +130,32 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@GET
@Override
@Path("/exists")
@Path("exists")
public Response isDeviceOrganizationExist(
@QueryParam("deviceId") int deviceId,
@QueryParam("parentDeviceId") int parentDeviceId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean exists = deviceOrganizationService.isDeviceOrganizationExist(deviceId, parentDeviceId);
return Response.status(Response.Status.OK).entity(gson.toJson(exists)).build();
return Response.status(Response.Status.OK).entity(exists).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
@GET
@Override
@Path("/child-exists")
public Response isChildDeviceIdExist(@QueryParam("deviceId") int deviceID) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean exists = deviceOrganizationService.isChildDeviceIdExist(deviceID);
return Response.status(Response.Status.OK).entity(gson.toJson(exists)).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
@GET
@Override
@Path("/unique")
@Path("organization")
public Response getDeviceOrganizationByUniqueKey(
@QueryParam("deviceId") int deviceId,
@QueryParam("parentDeviceId") int parentDeviceId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
DeviceOrganization organization = deviceOrganizationService.getDeviceOrganizationByUniqueKey(deviceId, parentDeviceId);
return Response.status(Response.Status.OK).entity(gson.toJson(organization)).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
@GET
@Override
@Path("/device-exists")
public Response doesDeviceIdExist(@QueryParam("deviceId") int deviceId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean exists = deviceOrganizationService.isDeviceIdExist(deviceId);
return Response.status(Response.Status.OK).entity(gson.toJson(exists)).build();
return Response.status(Response.Status.OK).entity(organization).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -189,12 +163,11 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@PUT
@Override
@Path("/update")
public Response updateDeviceOrganization(DeviceOrganization deviceOrganization) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean resp = deviceOrganizationService.updateDeviceOrganization(deviceOrganization);
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
return Response.status(Response.Status.OK).entity(resp).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -202,12 +175,12 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@DELETE
@Override
@Path("/delete/{organizationId}")
@Path("{organizationId}")
public Response deleteDeviceOrganizationById(@PathParam("organizationId") int organizationId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean resp = deviceOrganizationService.deleteDeviceOrganizationByID(organizationId);
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
return Response.status(Response.Status.OK).entity(resp).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
@ -215,12 +188,12 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
@DELETE
@Override
@Path("/delete-associations/{deviceId}")
@Path("associations/{deviceId}")
public Response deleteDeviceAssociations(@PathParam("deviceId") int deviceId) {
try {
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
boolean resp = deviceOrganizationService.deleteDeviceAssociations(deviceId);
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
return Response.status(Response.Status.OK).entity(resp).build();
} catch (DeviceOrganizationMgtPluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}

@ -29,7 +29,7 @@
<ref bean="swaggerResource"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<!-- <ref bean="jsonProvider"/>-->
<ref bean="jsonProvider"/>
<ref bean="swaggerWriter"/>
</jaxrs:providers>
</jaxrs:server>
@ -44,8 +44,8 @@
<property name="version" value="1.0"/>
<property name="host" value="localhost:9443"/>
<property name="schemes" value="https" />
<property name="basePath" value="/api/device-mgt/v1.0"/>
<property name="title" value="Device Management Admin Service API Definitions"/>
<property name="basePath" value="/api/device-org/v1.0"/>
<property name="title" value="Device Organization Management Service API Definitions"/>
<property name="contact" value="dev@entgra.io"/>
<property name="license" value="Apache 2.0"/>
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
@ -54,6 +54,7 @@
<bean id="deviceOrganizationMgtService" class="io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.DeviceOrganizationMgtServiceImpl"/>
<bean id="jsonProvider" class="io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.beans.GsonMessageBodyHandler"/>
<cxf:bus>
<cxf:inInterceptors>

@ -17,7 +17,7 @@
~ under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Admin-Webapp</display-name>
<display-name>Device-Organization-Webapp</display-name>
<servlet>
<description>JAX-WS/JAX-RS Device Organization Endpoint</description>
<display-name>JAX-WS/JAX-RS Servlet</display-name>
@ -50,66 +50,66 @@
<param-name>managed-api-enabled</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
<!-- <context-param>-->
<!-- <param-name>managed-api-owner</param-name>-->
<!-- <param-value>admin</param-value>-->
<!-- </context-param>-->
<context-param>
<param-name>isSharedWithAllTenants</param-name>
<param-value>true</param-value>
</context-param>
<!-- Below configuration is used to redirect http requests to https -->
<security-constraint>
<web-resource-collection>
<web-resource-name>DeviceMgt-Admin</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- <security-constraint>-->
<!-- <web-resource-collection>-->
<!-- <web-resource-name>DeviceMgt-Admin</web-resource-name>-->
<!-- <url-pattern>/*</url-pattern>-->
<!-- </web-resource-collection>-->
<!-- <user-data-constraint>-->
<!-- <transport-guarantee>CONFIDENTIAL</transport-guarantee>-->
<!-- </user-data-constraint>-->
<!-- </security-constraint>-->
<filter>
<filter-name>ApiOriginFilter</filter-name>
<filter-class>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.ApiOriginFilter</filter-class>
</filter>
<filter>
<filter-name>HttpHeaderSecurityFilter</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>hstsEnabled</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<!-- <filter>-->
<!-- <filter-name>HttpHeaderSecurityFilter</filter-name>-->
<!-- <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>-->
<!-- <init-param>-->
<!-- <param-name>hstsEnabled</param-name>-->
<!-- <param-value>false</param-value>-->
<!-- </init-param>-->
<!-- </filter>-->
<filter>
<filter-name>ContentTypeBasedCachePreventionFilter</filter-name>
<filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>
<init-param>
<param-name>patterns</param-name>
<param-value>text/html" ,application/json" ,text/plain</param-value>
</init-param>
<init-param>
<param-name>filterAction</param-name>
<param-value>enforce</param-value>
</init-param>
<init-param>
<param-name>httpHeaders</param-name>
<param-value>Cache-Control: no-store, no-cache, must-revalidate, private</param-value>
</init-param>
</filter>
<!-- <filter>-->
<!-- <filter-name>ContentTypeBasedCachePreventionFilter</filter-name>-->
<!-- <filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>-->
<!-- <init-param>-->
<!-- <param-name>patterns</param-name>-->
<!-- <param-value>text/html" ,application/json" ,text/plain</param-value>-->
<!-- </init-param>-->
<!-- <init-param>-->
<!-- <param-name>filterAction</param-name>-->
<!-- <param-value>enforce</param-value>-->
<!-- </init-param>-->
<!-- <init-param>-->
<!-- <param-name>httpHeaders</param-name>-->
<!-- <param-value>Cache-Control: no-store, no-cache, must-revalidate, private</param-value>-->
<!-- </init-param>-->
<!-- </filter>-->
<filter-mapping>
<filter-name>HttpHeaderSecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- <filter-mapping>-->
<!-- <filter-name>HttpHeaderSecurityFilter</filter-name>-->
<!-- <url-pattern>/*</url-pattern>-->
<!-- </filter-mapping>-->
<filter-mapping>
<filter-name>ContentTypeBasedCachePreventionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- <filter-mapping>-->
<!-- <filter-name>ContentTypeBasedCachePreventionFilter</filter-name>-->
<!-- <url-pattern>/*</url-pattern>-->
<!-- </filter-mapping>-->
<filter-mapping>
<filter-name>ApiOriginFilter</filter-name>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>io.entgra.device.mgt.core</groupId>
<version>5.0.31-SNAPSHOT</version>
<version>5.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>io.entgra.device.mgt.core</groupId>
<artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.31-SNAPSHOT</version>
<version>5.0.32-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -56,7 +56,7 @@
<outputDirectory>
${project.build.directory}/maven-shared-archive-resources/webapps
</outputDirectory>
<destFileName>api#deviceOrganization-mgt-v1.0.war</destFileName>
<destFileName>api#device-org#v1.0.war</destFileName>
</artifactItem>
</artifactItems>
</configuration>

@ -1,3 +1,3 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api_${feature.version}/webapps/api#deviceOrganization-mgt-v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#deviceOrganization-mgt-v1.0.war,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api_${feature.version}/webapps/api#device-org#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-org#v1.0.war,overwrite:true);\

@ -22,7 +22,7 @@
<parent>
<groupId>io.entgra.device.mgt.core</groupId>
<artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.31-SNAPSHOT</version>
<version>5.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -354,7 +354,10 @@
<Scope>am:store:vpp:assets:view</Scope>
<Scope>and:devices:enroll</Scope>
<Scope>ios:devices:enroll</Scope>
<Scope>dm:device-organization</Scope>
<Scope>dm:device-org:view</Scope>
<Scope>dm:device-org:add</Scope>
<Scope>dm:device-org:modify</Scope>
<Scope>dm:device-org:delete</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>device-mgt</Issuer>

Loading…
Cancel
Save