parent
c8c7922e97
commit
7d0d7e4910
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.31-SNAPSHOT</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - API Device Organization Management API</name>
|
||||
<description>This module extends the API manager's device organization management apis.</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-bundle-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization</artifactId>
|
||||
<version>${io.entgra.device.mgt.core.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.annotations.Scope;
|
||||
import io.entgra.device.mgt.core.apimgt.annotations.Scopes;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Extension;
|
||||
import io.swagger.annotations.ExtensionProperty;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.SwaggerDefinition;
|
||||
import io.swagger.annotations.Tag;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* This interface defines the RESTful web service endpoints for managing device organizations.
|
||||
*/
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "DeviceOrganization Management"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/deviceOrganization"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "deviceOrganization_management", description = "DeviceOrganization management related REST-API. " +
|
||||
"This can be used to manipulate device organization related details.")
|
||||
}
|
||||
)
|
||||
@Path("/deviceOrganization")
|
||||
@Api(value = "DeviceOrganization Management", description = "This API carries all device Organization management " +
|
||||
"related operations.")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(scopes = {
|
||||
@Scope(
|
||||
name = "Device Organization",
|
||||
description = "Device Organization",
|
||||
key = "perm:devices:view",
|
||||
roles = {"Internal/devicemgt-user"},
|
||||
permissions = {"/device-mgt/devices/owning-device/view"}
|
||||
)
|
||||
}
|
||||
)
|
||||
public interface DeviceOrganizationMgtService {
|
||||
|
||||
String SCOPE = "scope";
|
||||
|
||||
/**
|
||||
* Adds a new device organization.
|
||||
*
|
||||
* @param request The request containing the device organization information.
|
||||
* @return A response indicating the success or failure of the operation.
|
||||
*/
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("/add-device-organization")
|
||||
@ApiOperation(
|
||||
consumes = MediaType.TEXT_PLAIN,
|
||||
produces = MediaType.TEXT_PLAIN,
|
||||
httpMethod = "POST",
|
||||
value = "Add a new device Organization.",
|
||||
notes = "This will return a response to indicate when a new device organization is created.",
|
||||
tags = "Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = SCOPE, value = "perm:devices:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the device location.",
|
||||
response = String.class),
|
||||
})
|
||||
Response addDeviceOrganization(DeviceOrganizationRequest request);
|
||||
|
||||
/**
|
||||
* Retrieves a list of child nodes of a given device node, up to a specified depth.
|
||||
*
|
||||
* @param deviceId The ID of the parent device node.
|
||||
* @param maxDepth The maximum depth of child nodes to retrieve.
|
||||
* @param includeDevice Indicates whether to include device information in the retrieved nodes.
|
||||
* @return A response containing a list of child device nodes.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/children")
|
||||
Response getChildrenOfDeviceNode(
|
||||
@QueryParam("deviceId") int deviceId,
|
||||
@QueryParam("maxDepth") int maxDepth,
|
||||
@QueryParam("includeDevice") boolean includeDevice);
|
||||
|
||||
/**
|
||||
* Retrieves a list of parent nodes of a given device node, up to a specified depth.
|
||||
*
|
||||
* @param deviceId The ID of the child device node.
|
||||
* @param maxDepth The maximum depth of parent nodes to retrieve.
|
||||
* @param includeDevice Indicates whether to include device information in the retrieved nodes.
|
||||
* @return A response containing a list of parent device nodes.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/parents")
|
||||
Response getParentsOfDeviceNode(
|
||||
@QueryParam("deviceId") int deviceId,
|
||||
@QueryParam("maxDepth") int maxDepth,
|
||||
@QueryParam("includeDevice") boolean includeDevice);
|
||||
|
||||
/**
|
||||
* Retrieves a list of all device organizations.
|
||||
*
|
||||
* @return A response containing a list of all device organizations.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/all")
|
||||
Response getAllDeviceOrganizations();
|
||||
|
||||
/**
|
||||
* 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 specified ID.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/{organizationId}")
|
||||
Response getDeviceOrganizationById(@PathParam("organizationId") int organizationId);
|
||||
|
||||
/**
|
||||
* Checks if a device organization with the specified device and parent device IDs already exists.
|
||||
*
|
||||
* @param deviceId The ID of the device.
|
||||
* @param parentDeviceId The ID of the parent device.
|
||||
* @return A response indicating whether the organization exists or not.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/exists")
|
||||
Response organizationExists(
|
||||
@QueryParam("deviceId") int deviceId,
|
||||
@QueryParam("parentDeviceId") int parentDeviceId);
|
||||
|
||||
/**
|
||||
* Retrieve a device organization by its unique key (deviceId and parentDeviceId).
|
||||
*
|
||||
* @param deviceId The ID of the device.
|
||||
* @param parentDeviceId The ID of the parent device.
|
||||
* @return A response containing the retrieved DeviceOrganization object, or null if not found.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/unique")
|
||||
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
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/device-exists")
|
||||
Response doesDeviceIdExist(@QueryParam("deviceId") int deviceId);
|
||||
|
||||
/**
|
||||
* Updates a device organization.
|
||||
*
|
||||
* @param deviceOrganization The updated device organization.
|
||||
* @return A response indicating the success or failure of the operation.
|
||||
*/
|
||||
@PUT
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("/update")
|
||||
Response updateDeviceOrganization(DeviceOrganization deviceOrganization);
|
||||
|
||||
/**
|
||||
* Deletes a device organization by its organization ID.
|
||||
*
|
||||
* @param organizationId The organization ID of the device organization to delete.
|
||||
* @return A response indicating the success or failure of the operation.
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/delete/{organizationId}")
|
||||
Response deleteDeviceOrganizationById(@PathParam("organizationId") int organizationId);
|
||||
|
||||
/**
|
||||
* Deletes records associated with a particular device ID from the device organization table.
|
||||
* This method deletes records where the provided device ID matches either the deviceID column or
|
||||
* parentDeviceID column in the device organization table.
|
||||
*
|
||||
* @param deviceId The ID of the device for which associations should be deleted.
|
||||
* @return A response indicating the success or failure of the operation.
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/delete-associations/{deviceId}")
|
||||
Response deleteDeviceAssociations(@PathParam("deviceId") int deviceId);
|
||||
|
||||
}
|
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNode;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DeviceOrganizationMgtPluginException;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.impl.DeviceOrganizationServiceImpl;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.spi.DeviceOrganizationService;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtService{
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
@Override
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("/add-device-organization")
|
||||
public Response addDeviceOrganization(DeviceOrganizationRequest deviceOrganizationRequest) {
|
||||
try {
|
||||
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
|
||||
DeviceOrganization deviceOrganization = new DeviceOrganization();
|
||||
deviceOrganization.setDeviceId(deviceOrganizationRequest.getDeviceId());
|
||||
deviceOrganization.setParentDeviceId(deviceOrganizationRequest.getParentDeviceId());
|
||||
boolean resp = deviceOrganizationService.addDeviceOrganization(deviceOrganization);
|
||||
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/children")
|
||||
public Response getChildrenOfDeviceNode(
|
||||
@QueryParam("deviceId") int deviceId,
|
||||
@QueryParam("maxDepth") int maxDepth,
|
||||
@QueryParam("includeDevice") boolean includeDevice) {
|
||||
try {
|
||||
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
|
||||
DeviceNode deviceNode = new DeviceNode();
|
||||
deviceNode.setDeviceId(deviceId);
|
||||
List<DeviceNode> children = deviceOrganizationService.getChildrenOf(deviceNode, maxDepth, includeDevice);
|
||||
return Response.status(Response.Status.OK).entity(gson.toJson(children)).build();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/parents")
|
||||
public Response getParentsOfDeviceNode(
|
||||
@QueryParam("deviceId") int deviceId,
|
||||
@QueryParam("maxDepth") int maxDepth,
|
||||
@QueryParam("includeDevice") boolean includeDevice) {
|
||||
try {
|
||||
DeviceOrganizationService deviceOrganizationService = new DeviceOrganizationServiceImpl();
|
||||
DeviceNode deviceNode = new DeviceNode();
|
||||
deviceNode.setDeviceId(deviceId);
|
||||
List<DeviceNode> parents = deviceOrganizationService.getParentsOf(deviceNode, maxDepth, includeDevice);
|
||||
return Response.status(Response.Status.OK).entity(gson.toJson(parents)).build();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/exists")
|
||||
public Response organizationExists(
|
||||
@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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/unique")
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PUT
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DELETE
|
||||
@Path("/delete/{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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DELETE
|
||||
@Path("/delete-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();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Date;
|
||||
|
||||
@XmlRootElement
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeviceOrganizationRequest {
|
||||
|
||||
@XmlElement
|
||||
private int organizationId;
|
||||
|
||||
@XmlElement
|
||||
private int deviceId;
|
||||
|
||||
@XmlElement
|
||||
private Integer parentDeviceId;
|
||||
|
||||
@XmlElement
|
||||
private Date updateTime;
|
||||
|
||||
public int getOrganizationId() {
|
||||
return organizationId;
|
||||
}
|
||||
|
||||
public void setOrganizationId(int organizationId) {
|
||||
this.organizationId = organizationId;
|
||||
}
|
||||
|
||||
public int getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(int deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public Integer getParentDeviceId() {
|
||||
return parentDeviceId;
|
||||
}
|
||||
|
||||
public void setParentDeviceId(Integer parentDeviceId) {
|
||||
this.parentDeviceId = parentDeviceId;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. 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.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
For ex:
|
||||
Actual API endpoint: devicemgt_admin/1.0.0/devices/{device-id}
|
||||
URL to be represented here: /devices/*
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
</PermissionConfiguration>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. 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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||
-->
|
||||
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||
|
||||
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||
<ParentFirst>false</ParentFirst>
|
||||
|
||||
<!--
|
||||
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||
-->
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. 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.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
|
||||
|
||||
<jaxrs:server id="services" address="/">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="deviceOrganizationService"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
|
||||
<bean id="deviceOrganizationService" class="io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.DeviceOrganizationMgtServiceImpl"/>
|
||||
|
||||
</beans>
|
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. 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.
|
||||
-->
|
||||
<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>Grafana-API-Proxy-Webapp</display-name>
|
||||
<servlet>
|
||||
<description>JAX-WS/JAX-RS Grafana API Management Endpoint</description>
|
||||
<display-name>JAX-WS/JAX-RS Servlet</display-name>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>
|
||||
org.apache.cxf.transport.servlet.CXFServlet
|
||||
</servlet-class>
|
||||
<!-- configure a security filter -->
|
||||
<init-param>
|
||||
<param-name>swagger.security.filter</param-name>
|
||||
<param-value>ApiAuthorizationFilterImpl</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<session-config>
|
||||
<session-timeout>60</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<context-param>
|
||||
<param-name>doAuthentication</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>basicAuth</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>nonSecuredEndPoints</param-name>
|
||||
<param-value>
|
||||
/keymgt-test-api/.*,
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--publish to apim-->
|
||||
<context-param>
|
||||
<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>isSharedWithAllTenants</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<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-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>
|
||||
|
||||
</web-app>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||
<version>5.0.31-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
#
|
||||
# Entgra (Pvt) Ltd. 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.
|
||||
#
|
||||
|
||||
custom = true
|
@ -0,0 +1 @@
|
||||
instructions.configure = \
|
Loading…
Reference in new issue