Fixed issues in api publishing

revert-70aa11f8
mharindu 9 years ago
parent bca1b4b059
commit 83c2a1f0ee

@ -138,7 +138,7 @@ public class APIPublisherUtil {
// api scope and uri template scope // api scope and uri template scope
for (Scope scope : scopes) { for (Scope scope : scopes) {
for (URITemplate template : uriTemplates) { for (URITemplate template : uriTemplates) {
if (scope.getKey().equals(template.getScope().getKey())) { if (template.getScope() != null && scope.getKey().equals(template.getScope().getKey())) {
template.setScope(scope); template.setScope(scope);
} }
} }
@ -252,7 +252,7 @@ public class APIPublisherUtil {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("'managed-api-endpoint' attribute is not configured"); log.debug("'managed-api-endpoint' attribute is not configured");
} }
String endpointContext = servletContext.getContextPath(); String endpointContext = apiDef.getContext();
endpoint = APIPublisherUtil.getApiEndpointUrl(endpointContext); endpoint = APIPublisherUtil.getApiEndpointUrl(endpointContext);
} }
apiConfig.setEndpoint(endpoint); apiConfig.setEndpoint(endpoint);

@ -159,7 +159,7 @@ public class AnnotationProcessor {
} }
Method[] annotatedMethods = clazz.getDeclaredMethods(); Method[] annotatedMethods = clazz.getDeclaredMethods();
resourceList = getApiResources(rootContext, subContext, annotatedMethods); resourceList = getApiResources(rootContext, annotatedMethods);
apiResourceConfig.setResources(resourceList); apiResourceConfig.setResources(resourceList);
} catch (Throwable throwable) { } catch (Throwable throwable) {
log.error("Error encountered while scanning for annotations", throwable); log.error("Error encountered while scanning for annotations", throwable);
@ -211,13 +211,11 @@ public class AnnotationProcessor {
* Get Resources for each API * Get Resources for each API
* *
* @param resourceRootContext * @param resourceRootContext
* @param apiRootContext
* @param annotatedMethods * @param annotatedMethods
* @return * @return
* @throws Throwable * @throws Throwable
*/ */
private List<APIResource> getApiResources(String resourceRootContext, String apiRootContext, private List<APIResource> getApiResources(String resourceRootContext, Method[] annotatedMethods) throws Throwable {
Method[] annotatedMethods) throws Throwable {
List<APIResource> resourceList = new ArrayList<>(); List<APIResource> resourceList = new ArrayList<>();
String subCtx = null; String subCtx = null;
for (Method method : annotatedMethods) { for (Method method : annotatedMethods) {
@ -228,8 +226,10 @@ public class AnnotationProcessor {
Annotation methodContextAnno = method.getAnnotation(pathClazz); Annotation methodContextAnno = method.getAnnotation(pathClazz);
if (methodContextAnno != null) { if (methodContextAnno != null) {
subCtx = invokeMethod(pathClazzMethods[0], methodContextAnno, STRING); subCtx = invokeMethod(pathClazzMethods[0], methodContextAnno, STRING);
} else {
subCtx = "/*";
} }
resource.setUriTemplate(makeContextURLReady(apiRootContext) + makeContextURLReady(subCtx)); resource.setUriTemplate(makeContextURLReady(subCtx));
resource.setUri(APIPublisherUtil.getServerBaseUrl() + makeContextURLReady(resourceRootContext) + resource.setUri(APIPublisherUtil.getServerBaseUrl() + makeContextURLReady(resourceRootContext) +
makeContextURLReady(subCtx)); makeContextURLReady(subCtx));
@ -266,7 +266,6 @@ public class AnnotationProcessor {
} }
resourceList.add(resource); resourceList.add(resource);
} }
subCtx = null;
} }
return resourceList; return resourceList;
} }

@ -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. * 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 // Below Api is for swagger annotations
@Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " + @Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " +

@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
* General Tenant Configuration REST-API implementation. * General Tenant Configuration REST-API implementation.
* All end points support JSON, XMl with content negotiation. * 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 // Below Api is for swagger annotations
@Path("/configuration") @Path("/configuration")

@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device related operations such as get all the available devices, etc. * 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 // Below Api is for swagger annotations
@Path("/devices") @Path("/devices")

@ -35,7 +35,7 @@ import java.util.List;
/** /**
* Device information related operations. * 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 // Below Api is for swagger annotations
@Path("/information") @Path("/information")
@ -65,7 +65,7 @@ public interface DeviceInformation {
@POST @POST
@Path("{list}") @Path("list")
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
@ -80,6 +80,7 @@ public interface DeviceInformation {
@ApiResponse(code = 400, message = ""), @ApiResponse(code = 400, message = ""),
@ApiResponse(code = 500, message = "Internal Server Error") @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", Response getDevicesInfo(@ApiParam(name = "deviceIdentifiers", value = "List of device identifiers",
required = true) List<DeviceIdentifier> deviceIdentifiers); required = true) List<DeviceIdentifier> deviceIdentifiers);

@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
* DeviceNotification management REST-API implementation. * DeviceNotification management REST-API implementation.
* All end points support JSON, XMl with content negotiation. * 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 // Below Api is for swagger annotations
@Api(value = "DeviceNotification", description = "Device notification related operations can be found here.") @Api(value = "DeviceNotification", description = "Device notification related operations can be found here.")

@ -31,7 +31,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device search related operations such as getting device information. * 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 // Below Api is for swagger annotations
@Path("/search") @Path("/search")

@ -28,7 +28,7 @@ import javax.ws.rs.core.Response;
/** /**
* Features * 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 // Below Api is for swagger annotations
@Api(value = "Feature", description = "Feature management related operations can be found here.") @Api(value = "Feature", description = "Feature management related operations can be found here.")

@ -37,7 +37,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; 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 // Below Api is for swagger annotations
@Path("/groups") @Path("/groups")

@ -28,7 +28,7 @@ import javax.ws.rs.core.Response;
/** /**
* This class represents license related operations. * 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 // Below Api is for swagger annotations
@Api(value = "License") @Api(value = "License")

@ -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 // Below Api is for swagger annotations
@Path("/operations") @Path("/operations")

@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; 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 // Below Api is for swagger annotations
@Path("/policies") @Path("/policies")

@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
/** /**
* These end points provide profile related operations. * 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 // Below Api is for swagger annotations
@Api(value = "Profile") @Api(value = "Profile")

@ -28,7 +28,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; 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 // Below Api is for swagger annotations
@Path("/roles") @Path("/roles")

@ -32,7 +32,7 @@ import java.util.List;
/** /**
* This represents the JAX-RS services of User related functionality. * 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 // Below Api is for swagger annotations
@Path("/users") @Path("/users")

Loading…
Cancel
Save