diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 9b6eec3ff60..1b4758a475b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -138,7 +138,7 @@ public class APIPublisherUtil { // api scope and uri template scope for (Scope scope : scopes) { for (URITemplate template : uriTemplates) { - if (scope.getKey().equals(template.getScope().getKey())) { + if (template.getScope() != null && scope.getKey().equals(template.getScope().getKey())) { template.setScope(scope); } } @@ -252,7 +252,7 @@ public class APIPublisherUtil { if (log.isDebugEnabled()) { log.debug("'managed-api-endpoint' attribute is not configured"); } - String endpointContext = servletContext.getContextPath(); + String endpointContext = apiDef.getContext(); endpoint = APIPublisherUtil.getApiEndpointUrl(endpointContext); } apiConfig.setEndpoint(endpoint); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index 951d7b12a50..af773d6df33 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -159,7 +159,7 @@ public class AnnotationProcessor { } Method[] annotatedMethods = clazz.getDeclaredMethods(); - resourceList = getApiResources(rootContext, subContext, annotatedMethods); + resourceList = getApiResources(rootContext, annotatedMethods); apiResourceConfig.setResources(resourceList); } catch (Throwable throwable) { log.error("Error encountered while scanning for annotations", throwable); @@ -211,13 +211,11 @@ public class AnnotationProcessor { * Get Resources for each API * * @param resourceRootContext - * @param apiRootContext * @param annotatedMethods * @return * @throws Throwable */ - private List getApiResources(String resourceRootContext, String apiRootContext, - Method[] annotatedMethods) throws Throwable { + private List getApiResources(String resourceRootContext, Method[] annotatedMethods) throws Throwable { List resourceList = new ArrayList<>(); String subCtx = null; for (Method method : annotatedMethods) { @@ -228,8 +226,10 @@ public class AnnotationProcessor { Annotation methodContextAnno = method.getAnnotation(pathClazz); if (methodContextAnno != null) { subCtx = invokeMethod(pathClazzMethods[0], methodContextAnno, STRING); + } else { + subCtx = "/*"; } - resource.setUriTemplate(makeContextURLReady(apiRootContext) + makeContextURLReady(subCtx)); + resource.setUriTemplate(makeContextURLReady(subCtx)); resource.setUri(APIPublisherUtil.getServerBaseUrl() + makeContextURLReady(resourceRootContext) + makeContextURLReady(subCtx)); @@ -266,7 +266,6 @@ public class AnnotationProcessor { } resourceList.add(resource); } - subCtx = null; } return resourceList; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java index 3ab6537276d..56ec881e924 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Response; /** * All the certificate related tasks such as saving certificates, can be done through this endpoint. */ -@API(name = "Certificate", version = "1.0.0", context = "/certificates", tags = {"devicemgt_admin"}) +@API(name = "Certificate", version = "1.0.0", context = "/devicemgt_admin/certificates", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java index 798d4766f8e..b15c4427866 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; * General Tenant Configuration REST-API implementation. * All end points support JSON, XMl with content negotiation. */ -@API(name = "Configuration", version = "1.0.0", context = "/configuration", tags = {"devicemgt_admin"}) +@API(name = "Configuration", version = "1.0.0", context = "/devicemgt_admin/configuration", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/configuration") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java index 1e1355d6a89..6756e863deb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; /** * Device related operations such as get all the available devices, etc. */ -@API(name = "Configuration", version = "1.0.0", context = "/devices", tags = {"devicemgt_admin"}) +@API(name = "Device", version = "1.0.0", context = "/devicemgt_admin/devices", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/devices") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceInformation.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceInformation.java index 5c439e48429..b10412b516a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceInformation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceInformation.java @@ -35,7 +35,7 @@ import java.util.List; /** * Device information related operations. */ -@API(name = "Device Information", version = "1.0.0", context = "/information", tags = {"devicemgt_admin"}) +@API(name = "Device Information", version = "1.0.0", context = "/devicemgt_admin/information", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/information") @@ -65,7 +65,7 @@ public interface DeviceInformation { @POST - @Path("{list}") + @Path("list") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "POST", @@ -80,6 +80,7 @@ public interface DeviceInformation { @ApiResponse(code = 400, message = ""), @ApiResponse(code = 500, message = "Internal Server Error") }) + @Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"}) Response getDevicesInfo(@ApiParam(name = "deviceIdentifiers", value = "List of device identifiers", required = true) List deviceIdentifiers); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceNotification.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceNotification.java index e627547df41..c2c5c99f81b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceNotification.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceNotification.java @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; * DeviceNotification management REST-API implementation. * All end points support JSON, XMl with content negotiation. */ -@API(name = "Device Notification", version = "1.0.0", context = "/notifications", tags = {"devicemgt_admin"}) +@API(name = "Device Notification", version = "1.0.0", context = "/devicemgt_admin/notifications", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Api(value = "DeviceNotification", description = "Device notification related operations can be found here.") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceSearch.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceSearch.java index 28ba46d9ff9..24a58f739cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceSearch.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/DeviceSearch.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.Response; /** * Device search related operations such as getting device information. */ -@API(name = "Device Search", version = "1.0.0", context = "/search", tags = {"devicemgt_admin"}) +@API(name = "Device Search", version = "1.0.0", context = "/devicemgt_admin/search", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/search") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Feature.java index 77869cc2d99..64a2b243c57 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Feature.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.Response; /** * Features */ -@API(name = "Device Search", version = "1.0.0", context = "/features", tags = {"devicemgt_admin"}) +@API(name = "Device Search", version = "1.0.0", context = "/devicemgt_admin/features", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Api(value = "Feature", description = "Feature management related operations can be found here.") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Group.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Group.java index 899d1800f88..20c5b2c9c89 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Group.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Group.java @@ -37,7 +37,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.List; -@API(name = "Group", version = "1.0.0", context = "/groups", tags = {"devicemgt_admin"}) +@API(name = "Group", version = "1.0.0", context = "/devicemgt_admin/groups", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/groups") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/License.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/License.java index 9b897078210..738a3d4588d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/License.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/License.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.Response; /** * This class represents license related operations. */ -@API(name = "License", version = "1.0.0", context = "/license", tags = {"devicemgt_admin"}) +@API(name = "License", version = "1.0.0", context = "/devicemgt_admin/license", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Api(value = "License") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java index 4fe9b6e24bf..3004378df43 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java @@ -32,7 +32,7 @@ import javax.ws.rs.core.Response; /** * */ -@API(name = "Operation", version = "1.0.0", context = "/operations", tags = {"devicemgt_admin"}) +@API(name = "Operation", version = "1.0.0", context = "/devicemgt_admin/operations", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/operations") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java index b01fb2f0cf9..7067eb19f67 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; -@API(name = "Policy", version = "1.0.0", context = "/policies", tags = {"devicemgt_admin"}) +@API(name = "Policy", version = "1.0.0", context = "/devicemgt_admin/policies", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/policies") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Profile.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Profile.java index 788980ba578..dcb2bf573d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Profile.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Profile.java @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; /** * These end points provide profile related operations. */ -@API(name = "Profile", version = "1.0.0", context = "/profiles", tags = {"devicemgt_admin"}) +@API(name = "Profile", version = "1.0.0", context = "/devicemgt_admin/profiles", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Api(value = "Profile") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Role.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Role.java index f88d004b417..735e4cfaf8c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Role.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Role.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; -@API(name = "Role", version = "1.0.0", context = "/roles", tags = {"devicemgt_admin"}) +@API(name = "Role", version = "1.0.0", context = "/devicemgt_admin/roles", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/roles") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/User.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/User.java index 12ec1840fee..eef95c6b6b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/User.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/User.java @@ -32,7 +32,7 @@ import java.util.List; /** * This represents the JAX-RS services of User related functionality. */ -@API(name = "User", version = "1.0.0", context = "/users", tags = {"devicemgt_admin"}) +@API(name = "User", version = "1.0.0", context = "/devicemgt_admin/users", tags = {"devicemgt_admin"}) // Below Api is for swagger annotations @Path("/users")