Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into transport

revert-70aa11f8
ayyoob 9 years ago
commit 51d46213c2

@ -207,6 +207,24 @@
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

@ -0,0 +1,44 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.mgt.jaxrs;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiOriginFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
public void destroy() {
//do nothing
}
public void init(FilterConfig filterConfig) throws ServletException {
//do nothing
}
}

@ -1,34 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
/**
* Authentication related REST-API interface.
*/
@Api(value = "Authentication")
@Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" })
public interface Authentication {
}

@ -18,15 +18,10 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentCertificate; import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentCertificate;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -39,6 +34,7 @@ import javax.ws.rs.core.Response;
@Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " + @Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " +
"can be done through this API") "can be done through this API")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/certificates")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })
public interface Certificate { public interface Certificate {
@ -83,7 +79,7 @@ public interface Certificate {
notes = "Get the client side SSL certificate details", notes = "Get the client side SSL certificate details",
response = CertificateResponse.class) response = CertificateResponse.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = CertificateResponse.class),
@ApiResponse(code = 400, message = "Notification status updated successfully"), @ApiResponse(code = 400, message = "Notification status updated successfully"),
@ApiResponse(code = 500, message = "Error occurred while converting PEM file to X509Certificate") @ApiResponse(code = 500, message = "Error occurred while converting PEM file to X509Certificate")
}) })
@ -112,7 +108,7 @@ public interface Certificate {
+ "page therefore the details are paginated", + "page therefore the details are paginated",
response = PaginationResult.class) response = PaginationResult.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = PaginationResult.class),
@ApiResponse(code = 400, message = "Invalid start index"), @ApiResponse(code = 400, message = "Invalid start index"),
@ApiResponse(code = 400, message = "Invalid length value"), @ApiResponse(code = 400, message = "Invalid length value"),
@ApiResponse(code = 500, message = "Error occurred while fetching all certificates") @ApiResponse(code = 500, message = "Error occurred while fetching all certificates")

@ -18,13 +18,8 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -34,9 +29,9 @@ 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.
*/ */
@Path("/configuration")
@Api(value = "Configuration", description = "General Tenant Configuration management capabilities are exposed " + @Api(value = "Configuration", description = "General Tenant Configuration management capabilities are exposed " +
"through " + "through this API")
"this API")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })

@ -29,7 +29,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.
*/ */
@Path("/devices")
@Api(value = "Device", description = "Device related operations such as get all the available devices, etc.") @Api(value = "Device", description = "Device related operations such as get all the available devices, etc.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface Device { public interface Device {
@ -41,6 +41,7 @@ public interface Device {
* @return Device List * @return Device List
*/ */
@GET @GET
@Path("devices")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
@ -95,7 +96,7 @@ public interface Device {
*/ */
@GET @GET
@Path("user/{user}") @Path("user/{user}")
Response getDevice(@PathParam("user") String user); Response getDeviceOfUser(@PathParam("user") String user);
/** /**
* Fetch device count of a given user. * Fetch device count of a given user.
@ -105,7 +106,7 @@ public interface Device {
*/ */
@GET @GET
@Path("user/{user}/count") @Path("user/{user}/count")
Response getDeviceCount(@PathParam("user") String user); Response getDeviceCountOfUser(@PathParam("user") String user);
/** /**
* Get current device count * Get current device count
@ -118,7 +119,7 @@ public interface Device {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Device Count", value = "Getting the Device Count",
notes = "Get the number of devices that are registered with WSO2 EMM.", notes = "Get the number of devices that are registered with WSO2 EMM.",
response = Integer.class) response = int.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Device count"), @ApiResponse(code = 200, message = "Device count"),
@ApiResponse(code = 500, message = "Error occurred while fetching the device count") @ApiResponse(code = 500, message = "Error occurred while fetching the device count")

@ -18,14 +18,9 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@ -36,7 +31,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device information related operations. * Device information related operations.
*/ */
@Path("/information")
@Api(value = "DeviceInformation", description = "Device information related operations can be found here.") @Api(value = "DeviceInformation", description = "Device information related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface DeviceInformation { public interface DeviceInformation {

@ -42,6 +42,7 @@ import javax.ws.rs.core.Response;
*/ */
@Api(value = "DeviceNotification", description = "Device notification related operations can be found here.") @Api(value = "DeviceNotification", description = "Device notification related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/notifications")
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface DeviceNotification { public interface DeviceNotification {
@ -57,7 +58,8 @@ public interface DeviceNotification {
response = Notification.class, response = Notification.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "List of Notifications"), @ApiResponse(code = 200, message = "List of Notifications", response = Notification.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list") @ApiResponse(code = 500, message = "Error occurred while retrieving the notification list")
}) })
Response getNotifications(); Response getNotifications();
@ -74,7 +76,8 @@ public interface DeviceNotification {
response = Notification.class, response = Notification.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "List of Notifications"), @ApiResponse(code = 200, message = "List of Notifications", response = Notification.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list") @ApiResponse(code = 500, message = "Error occurred while retrieving the notification list")
}) })
Response getNotificationsByStatus(@ApiParam(name = "status", value = "Provide the notification status as" Response getNotificationsByStatus(@ApiParam(name = "status", value = "Provide the notification status as"

@ -18,23 +18,19 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper; import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper;
import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.search.SearchContext;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* Device search related operations such as getting device information. * Device search related operations such as getting device information.
*/ */
@Path("/search")
@Api(value = "DeviceSearch", description = "Device searching related operations can be found here.") @Api(value = "DeviceSearch", description = "Device searching related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface DeviceSearch { public interface DeviceSearch {
@ -48,9 +44,9 @@ public interface DeviceSearch {
response = DeviceWrapper.class, response = DeviceWrapper.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = DeviceWrapper.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while searching the device information") @ApiResponse(code = 500, message = "Error occurred while searching the device information")
}) })
Response getDeviceInfo(@ApiParam(name = "enrollmentCertificates", value = "List of search conditions", Response getFilteredDeviceInfo(@ApiParam(name = "enrollmentCertificates", value = "List of search conditions",
required = true) SearchContext searchContext); required = true) SearchContext searchContext);
} }

@ -34,6 +34,7 @@ import javax.ws.rs.core.Response;
@Api(value = "Feature", description = "Feature management related operations can be found here.") @Api(value = "Feature", description = "Feature management related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/features")
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface Feature { public interface Feature {

@ -35,10 +35,8 @@ 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;
/** @Path("/groups")
* @Api(value = "Group", description = "Group related operations such as get all the available groups, etc.")
*/
@Api(value = "Group")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface Group { public interface Group {
@ -59,7 +57,7 @@ public interface Group {
@GET @GET
@Produces("application/json") @Produces("application/json")
Response getGroups(@QueryParam("start") int startIndex, @PathParam("length") int length); Response getGroups(@QueryParam("start") int startIndex, @QueryParam("length") int length);
@Path("/all") @Path("/all")
@GET @GET
@ -119,8 +117,7 @@ public interface Group {
@PUT @PUT
@Produces("application/json") @Produces("application/json")
Response addSharing(@QueryParam("shareUser") String shareUser, @PathParam("groupName") String groupName, Response addSharing(@QueryParam("shareUser") String shareUser, @PathParam("groupName") String groupName,
@PathParam("owner") String owner, @PathParam("roleName") String roleName, @PathParam("owner") String owner, @PathParam("roleName") String roleName, String[] permissions);
@FormParam("permissions") String[] permissions);
@DELETE @DELETE
@Path("/owner/{owner}/name/{groupName}/share/roles/{roleName}/permissions") @Path("/owner/{owner}/name/{groupName}/share/roles/{roleName}/permissions")

@ -28,6 +28,7 @@ import javax.ws.rs.core.Response;
* This class represents license related operations. * This class represents license related operations.
*/ */
@Api(value = "License") @Api(value = "License")
@Path("/license")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface License { public interface License {

@ -19,25 +19,19 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.context.DeviceOperationContext; import org.wso2.carbon.device.mgt.jaxrs.api.context.DeviceOperationContext;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper;
import javax.ws.rs.GET; import javax.ws.rs.*;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* *
*/ */
@Path("/operations")
@Api(value = "Operation", description = "Operation management related operations can be found here.") @Api(value = "Operation", description = "Operation management related operations can be found here.")
public interface Operation { public interface Operation {
@ -51,7 +45,7 @@ public interface Operation {
consumes = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, consumes = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML,
produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML,
httpMethod = "GET", httpMethod = "GET",
value = "Getting Pagination Details for Operations on a Device.", value = "Getting Paginated Details for Operations on a Device.",
notes = "You will carry out many operations on a device. In a situation where you wish to view the all" + notes = "You will carry out many operations on a device. In a situation where you wish to view the all" +
" the operations carried out on a device it is not feasible to show all the details on one page" + " the operations carried out on a device it is not feasible to show all the details on one page" +
" therefore the details are paginated." + " therefore the details are paginated." +
@ -91,7 +85,7 @@ public interface Operation {
@ApiResponses(value = {@ApiResponse(code = 200, message = "List of Operations on a device."), @ApiResponses(value = {@ApiResponse(code = 200, message = "List of Operations on a device."),
@ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " + @ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " +
"device.")}) "device.")})
Response getDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " + Response getAllDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " +
"Example: ios, android or windows.", "Example: ios, android or windows.",
required = true) @PathParam("type") String type, required = true) @PathParam("type") String type,
@ApiParam(name = "id", value = "Define the device ID", @ApiParam(name = "id", value = "Define the device ID",
@ -111,7 +105,7 @@ public interface Operation {
responseContainer = "List", responseContainer = "List",
notes = "Get the list of applications that a device has subscribed.", notes = "Get the list of applications that a device has subscribed.",
response = Application.class) response = Application.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of installed application details of a device."), @ApiResponses(value = {@ApiResponse(code = 200, message = "List of installed application details of a device.", response = Application.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while fetching the apps of the device" + @ApiResponse(code = 500, message = "Error occurred while fetching the apps of the device" +
".")}) ".")})
Response getInstalledApps(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " + Response getInstalledApps(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " +

@ -20,25 +20,15 @@ package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
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.core.MediaType; 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;
/** @Path("/policies")
*
*/
@Api(value = "Policy", description = "Policy management related operations can be found here.") @Api(value = "Policy", description = "Policy management related operations can be found here.")
public interface Policy { public interface Policy {
@ -85,7 +75,8 @@ public interface Policy {
responseContainer = "List", responseContainer = "List",
notes = "Retrieve the details of all the policies that you have created in WSO2 EMM.", notes = "Retrieve the details of all the policies that you have created in WSO2 EMM.",
response = org.wso2.carbon.policy.mgt.common.Policy.class) response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetched all policies."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched all policies.",
response = org.wso2.carbon.policy.mgt.common.Policy.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Policy Management related error occurred when " + @ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"fetching the policies.")}) "fetching the policies.")})
Response getAllPolicies(); Response getAllPolicies();
@ -114,7 +105,7 @@ public interface Policy {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Policy Count.", value = "Getting the Policy Count.",
notes = "Get the number of policies that are created in WSO2 EMM.", notes = "Get the number of policies that are created in WSO2 EMM.",
response = Integer.class) response = int.class)
@ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched the policy count."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched the policy count."),
@ApiResponse(code = 500, message = "Error while Fetching the policy count.")}) @ApiResponse(code = 500, message = "Error while Fetching the policy count.")})
Response getPolicyCount(); Response getPolicyCount();

@ -30,6 +30,7 @@ import javax.ws.rs.core.Response;
* These end points provide profile related operations. * These end points provide profile related operations.
*/ */
@Api(value = "Profile") @Api(value = "Profile")
@Path("/profiles")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface Profile { public interface Profile {

@ -19,26 +19,15 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UIPermissionNode;
import javax.ws.rs.DELETE; import javax.ws.rs.*;
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.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
/** @Path("/roles")
*
*/
@Api(value = "Role", description = "Role management related operations can be found here.") @Api(value = "Role", description = "Role management related operations can be found here.")
public interface Role { public interface Role {
@ -54,7 +43,7 @@ public interface Role {
response = String.class) response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"), @ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.") }) @ApiResponse(code = 500, message = "Error occurred while fetching the role list.") })
Response getRoles(); Response getAllRoles();
@GET @GET
@Path("{userStore}") @Path("{userStore}")
@ -69,7 +58,7 @@ public interface Role {
response = String.class) response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"), @ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.") }) @ApiResponse(code = 500, message = "Error occurred while fetching the role list.") })
Response getRoles(@ApiParam(name = "userStore", value = "Provide the name of the UserStore you wish to get the" + Response getRolesOfUserStore(@ApiParam(name = "userStore", value = "Provide the name of the UserStore you wish to get the" +
" details from ", " details from ",
required = true) @PathParam("userStore") String userStore); required = true) @PathParam("userStore") String userStore);
@ -203,9 +192,10 @@ public interface Role {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Role Count.", value = "Getting the Role Count.",
response = Integer.class, response = int.class,
notes = "Get the number of roles in WSO2 EMM.") notes = "Get the number of roles in WSO2 EMM.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved the role count."), @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved the role count."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the role count.") }) @ApiResponse(code = 500, message = "Error occurred while retrieving the role count.") })
Response getRoleCount(); Response getRoleCount();
} }

@ -18,25 +18,12 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.axis2.databinding.types.soapencoding.Integer; import org.apache.axis2.databinding.types.soapencoding.Integer;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
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.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -44,6 +31,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.
*/ */
@Path("/users")
@Api(value = "User", description = "User management related operations can be found here.") @Api(value = "User", description = "User management related operations can be found here.")
public interface User { public interface User {
@ -138,7 +126,7 @@ public interface User {
@ApiResponse(code = 400, message = "User by username: 'username' does not exist for role retrieval"), @ApiResponse(code = 400, message = "User by username: 'username' does not exist for role retrieval"),
@ApiResponse(code = 500, message = "Exception in trying to retrieve roles for user by username: 'username'") @ApiResponse(code = 500, message = "Exception in trying to retrieve roles for user by username: 'username'")
}) })
Response getRoles(@ApiParam(name = "username", value = "Provide the user name of the user you wish to get" Response getRolesOfUser(@ApiParam(name = "username", value = "Provide the user name of the user you wish to get"
+ " the role details", required = true) @QueryParam("username") String username); + " the role details", required = true) @QueryParam("username") String username);
@GET @GET
@ -253,7 +241,7 @@ public interface User {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the User Count", value = "Getting the User Count",
notes = "Get the number of users in WSO2 EMM", notes = "Get the number of users in WSO2 EMM",
response = Integer.class) response = int.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the list of users that exist" @ApiResponse(code = 500, message = "Error occurred while retrieving the list of users that exist"
@ -264,7 +252,7 @@ public interface User {
@PUT @PUT
@Path("{roleName}/users") @Path("{roleName}/users")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
Response updateRoles(@PathParam("username") String username, List<String> userList); Response updateRoles(@PathParam("roleName") String roleName, List<String> userList);
@POST @POST
@Path("change-password") @Path("change-password")

@ -1,36 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.jaxrs.api.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
/**
* Authentication related REST-API implementation.
*/
@Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" })
public class AuthenticationImpl {
private static Log log = LogFactory.getLog(AuthenticationImpl.class);
}

@ -142,7 +142,7 @@ public class DeviceImpl implements Device{
*/ */
@GET @GET
@Path("user/{user}") @Path("user/{user}")
public Response getDevice(@PathParam("user") String user) { public Response getDeviceOfUser(@PathParam("user") String user) {
List<org.wso2.carbon.device.mgt.common.Device> devices; List<org.wso2.carbon.device.mgt.common.Device> devices;
try { try {
devices = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(user); devices = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(user);
@ -165,7 +165,7 @@ public class DeviceImpl implements Device{
*/ */
@GET @GET
@Path("user/{user}/count") @Path("user/{user}/count")
public Response getDeviceCount(@PathParam("user") String user) { public Response getDeviceCountOfUser(@PathParam("user") String user) {
try { try {
Integer count = DeviceMgtAPIUtils.getDeviceManagementService().getDeviceCount(user); Integer count = DeviceMgtAPIUtils.getDeviceManagementService().getDeviceCount(user);
return Response.status(Response.Status.OK).entity(count).build(); return Response.status(Response.Status.OK).entity(count).build();

@ -38,7 +38,7 @@ public class DeviceSearchImpl implements DeviceSearch {
private static Log log = LogFactory.getLog(DeviceSearchImpl.class); private static Log log = LogFactory.getLog(DeviceSearchImpl.class);
@GET @GET
public Response getDeviceInfo(SearchContext searchContext) { public Response getFilteredDeviceInfo(SearchContext searchContext) {
SearchManagerService searchManagerService; SearchManagerService searchManagerService;
List<DeviceWrapper> devices; List<DeviceWrapper> devices;
try { try {

@ -103,7 +103,7 @@ public class OperationImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Opera
@Override @Override
@GET @GET
@Path("{type}/{id}") @Path("{type}/{id}")
public Response getDeviceOperations(@PathParam("type") String type, @PathParam("id") String id) { public Response getAllDeviceOperations(@PathParam("type") String type, @PathParam("id") String id) {
List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations; List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations;
DeviceManagementProviderService dmService; DeviceManagementProviderService dmService;
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier();

@ -65,7 +65,7 @@ public class RoleImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Role {
@Override @Override
@GET @GET
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles() { public Response getAllRoles() {
List<String> filteredRoles; List<String> filteredRoles;
try { try {
filteredRoles = getRolesFromUserStore(); filteredRoles = getRolesFromUserStore();
@ -89,7 +89,7 @@ public class RoleImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Role {
@GET @GET
@Path("{userStore}") @Path("{userStore}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles(@PathParam("userStore") String userStore) { public Response getRolesOfUserStore(@PathParam("userStore") String userStore) {
String[] roles; String[] roles;
try { try {
AbstractUserStoreManager abstractUserStoreManager = AbstractUserStoreManager abstractUserStoreManager =

@ -371,7 +371,7 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User {
@GET @GET
@Path("roles") @Path("roles")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles(@QueryParam("username") String username) { public Response getRolesOfUser(@QueryParam("username") String username) {
ResponsePayload responsePayload = new ResponsePayload(); ResponsePayload responsePayload = new ResponsePayload();
try { try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@ -716,7 +716,7 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User {
@PUT @PUT
@Path("{roleName}/users") @Path("{roleName}/users")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response updateRoles(@PathParam("username") String username, List<String> userList) { public Response updateRoles(@PathParam("roleName") String username, List<String> userList) {
try { try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import java.util.List; import java.util.List;
@ -32,7 +33,8 @@ public class ApplicationWrapper {
private List<String> userNameList; private List<String> userNameList;
@ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true) @ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true)
private List<String> roleNameList; private List<String> roleNameList;
@ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true ) @ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true,
dataType = "List[org.wso2.carbon.device.mgt.common.DeviceIdentifier]")
private List<DeviceIdentifier> deviceIdentifiers; private List<DeviceIdentifier> deviceIdentifiers;
@ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true) @ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true)
private MobileApp application; private MobileApp application;
@ -44,6 +46,7 @@ public class ApplicationWrapper {
public void setApplication(MobileApp application) { public void setApplication(MobileApp application) {
this.application = application; this.application = application;
} }
public List<String> getUserNameList() { public List<String> getUserNameList() {
return userNameList; return userNameList;
} }

@ -27,7 +27,7 @@ import java.util.Properties;
* This class represents the generic mobile AuthenticationImpl information * This class represents the generic mobile AuthenticationImpl information
* which is used by AppM. * which is used by AppM.
*/ */
@ApiModel(value = "ApplicationWrapper", description = "Details of a mobile application.") @ApiModel(value = "MobileApp", description = "Details of a mobile application.")
public class MobileApp { public class MobileApp {
@ApiModelProperty(name = "id", value = "Id of the app used internally.", required = true) @ApiModelProperty(name = "id", value = "Id of the app used internally.", required = true)

@ -18,23 +18,36 @@
package org.wso2.carbon.device.mgt.jaxrs.beans; package org.wso2.carbon.device.mgt.jaxrs.beans;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
@XmlRootElement @XmlRootElement
@ApiModel(value = "Profile", description = "This class carries all information related to policy profiles")
public class Profile { public class Profile {
@ApiModelProperty(name = "profileId", value = "The ID of each profile that is in the selected policy",
required = true)
private int profileId; private int profileId;
@ApiModelProperty(name = "profileName", value = "The name of the profile", required = true)
private String profileName; private String profileName;
@ApiModelProperty(name = "tenantId", value = "The ID of the tenant that added the policy", required = true)
private int tenantId; private int tenantId;
@ApiModelProperty(name = "deviceType", value = "Contains the device type details the policy was created "
+ "for", required = true)
private DeviceType deviceType; private DeviceType deviceType;
@ApiModelProperty(name = "createdDate", value = "The date the policy was created", required = true)
private Timestamp createdDate; private Timestamp createdDate;
@ApiModelProperty(name = "updatedDate", value = "The date the changes made to the policy was published to"
+ " the devices registered with the EMM", required = true)
private Timestamp updatedDate; private Timestamp updatedDate;
@ApiModelProperty(name = "profileFeaturesList", value = "Contains the features specific to each profile "
+ "in the policy", required = true)
private List<ProfileFeature> profileFeaturesList; // Features included in the policies. private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
public DeviceType getDeviceType() { public DeviceType getDeviceType() {
@ -104,4 +117,5 @@ public class Profile {
public void setProfileFeaturesList(List<ProfileFeature> profileFeaturesList) { public void setProfileFeaturesList(List<ProfileFeature> profileFeaturesList) {
this.profileFeaturesList = profileFeaturesList; this.profileFeaturesList = profileFeaturesList;
} }
} }

@ -19,15 +19,30 @@
package org.wso2.carbon.device.mgt.jaxrs.beans; package org.wso2.carbon.device.mgt.jaxrs.beans;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
@ApiModel(value = "ProfileFeature", description = "This class carries all information related to profile "
+ "features")
public class ProfileFeature implements Serializable { public class ProfileFeature implements Serializable {
@ApiModelProperty(name = "id", value = "Define the ID", required = true)
private int id; private int id;
@ApiModelProperty(name = "featureCode", value = "Provide the code that defines the policy you wish to add",
required = true)
private String featureCode; private String featureCode;
@ApiModelProperty(name = "profileId", value = "Define the ID of the profile", required = true)
private int profileId; private int profileId;
@ApiModelProperty(name = "deviceTypeId", value = "The ID used to define the type of the device platform",
required = true)
private int deviceTypeId; private int deviceTypeId;
@ApiModelProperty(name = "content", value = "The list of parameters that define the policy",
required = true)
private Object content; private Object content;
@ApiModelProperty(name = "payLoad", value = "The payload which is submitted to each feature",
required = true)
private String payLoad; private String payLoad;
public int getId() { public int getId() {

@ -29,10 +29,10 @@ public class RoleWrapper {
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true) @ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
private String roleName; private String roleName;
@ApiModelProperty(name = "permissions", value = "Lists out all the permissions associated with roles.", @ApiModelProperty(name = "permissions", value = "Lists out all the permissions associated with roles.",
required = true) required = true, dataType = "List[java.lang.String]")
private String[] permissions; private String[] permissions;
@ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.", @ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.",
required = true) required = true, dataType = "List[java.lang.String]")
private String[] users; private String[] users;
@ApiModelProperty(name = "permissionList", value = "This contain the following, " + @ApiModelProperty(name = "permissionList", value = "This contain the following, " +
"\n resourcePath\tThe path related to the API.\n " + "\n resourcePath\tThe path related to the API.\n " +

@ -24,145 +24,46 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 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/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<jaxrs:server id="operationService" address="/operations"> <jaxrs:server id="services" address="/">
<jaxrs:serviceBeans> <jaxrs:serviceBeans>
<ref bean="operationServiceBean"/> <ref bean="operationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="featureService" address="/features">
<jaxrs:serviceBeans>
<ref bean="featureServiceBean"/> <ref bean="featureServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="deviceService" address="/devices">
<jaxrs:serviceBeans>
<ref bean="deviceServiceBean"/> <ref bean="deviceServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="deviceGroupService" address="/groups">
<jaxrs:serviceBeans>
<ref bean="groupServiceBean"/> <ref bean="groupServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="userService" address="/users">
<jaxrs:serviceBeans>
<ref bean="userServiceBean"/> <ref bean="userServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="roleService" address="/roles">
<jaxrs:serviceBeans>
<ref bean="roleServiceBean"/> <ref bean="roleServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="policyService" address="/policies">
<jaxrs:serviceBeans>
<ref bean="policyServiceBean"/> <ref bean="policyServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="profileService" address="/profiles">
<jaxrs:serviceBeans>
<ref bean="profileServiceBean"/> <ref bean="profileServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="configurationService" address="/configuration">
<jaxrs:serviceBeans>
<ref bean="configurationServiceBean"/> <ref bean="configurationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="licenseService" address="/license">
<jaxrs:serviceBeans>
<ref bean="licenseServiceBean"/> <ref bean="licenseServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="certificateService" address="/certificates">
<jaxrs:serviceBeans>
<ref bean="certificateServiceBean"/> <ref bean="certificateServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="notificationService" address="/notifications">
<jaxrs:serviceBeans>
<ref bean="notificationServiceBean"/> <ref bean="notificationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="informationService" address="/information">
<jaxrs:serviceBeans>
<ref bean="informationServiceBean"/> <ref bean="informationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="searchService" address="/search">
<jaxrs:serviceBeans>
<ref bean="searchingServiceBean"/> <ref bean="searchingServiceBean"/>
<ref bean="swaggerResource"/>
</jaxrs:serviceBeans> </jaxrs:serviceBeans>
<jaxrs:providers> <jaxrs:providers>
<ref bean="jsonProvider"/> <ref bean="jsonProvider"/>
<ref bean="errorHandler"/> <ref bean="errorHandler"/>
<ref bean="swaggerWriter"/>
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<!--
<jaxrs:server id="authenticationService" address="/authentication"> <bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
<jaxrs:serviceBeans> <bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
<ref bean="authenticationServiceBean"/>
</jaxrs:serviceBeans> <bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
<jaxrs:providers> <property name="resourcePackage" value="org.wso2.carbon.device.mgt.jaxrs"/>
<ref bean="jsonProvider"/> <property name="version" value="1.0.0"/>
<ref bean="errorHandler"/> <property name="host" value="localhost:9443"/>
</jaxrs:providers> <property name="basePath" value="/"/>
</jaxrs:server> <property name="title" value="Device Management Admin Service API Definitions"/>
--> <property name="contact" value="dev@wso2.org"/>
<property name="license" value="Apache 2.0"/>
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
<property name="scan" value="true"/>
</bean>
<bean id="operationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.OperationImpl"/> <bean id="operationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.OperationImpl"/>
<bean id="deviceServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceImpl"/> <bean id="deviceServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceImpl"/>
<bean id="groupServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.GroupImpl"/> <bean id="groupServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.GroupImpl"/>
@ -175,9 +76,6 @@
<bean id="certificateServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.CertificateImpl"/> <bean id="certificateServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.CertificateImpl"/>
<bean id="informationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceInformationImpl"/> <bean id="informationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceInformationImpl"/>
<bean id="searchingServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceSearchImpl"/> <bean id="searchingServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceSearchImpl"/>
<!--
<bean id="authenticationServiceBean" class="AuthenticationImpl"/>
-->
<bean id="policyServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.PolicyImpl"/> <bean id="policyServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.PolicyImpl"/>
<bean id="profileServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.ProfileImpl"/> <bean id="profileServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.ProfileImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/> <bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/>

@ -25,6 +25,16 @@
<servlet-class> <servlet-class>
org.apache.cxf.transport.servlet.CXFServlet org.apache.cxf.transport.servlet.CXFServlet
</servlet-class> </servlet-class>
<!--<init-param>-->
<!--<param-name>swagger.api.basepath</param-name>-->
<!--<param-value>http://localhost:9763/test</param-value>-->
<!--</init-param>-->
<!-- 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> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
@ -41,7 +51,7 @@
</context-param> </context-param>
<context-param> <context-param>
<param-name>doAuthentication</param-name> <param-name>doAuthentication</param-name>
<param-value>true</param-value> <param-value>false</param-value>
</context-param> </context-param>
<!--context-param> <!--context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
@ -71,4 +81,13 @@
</user-data-constraint> </user-data-constraint>
</security-constraint> </security-constraint>
<filter>
<filter-name>ApiOriginFilter</filter-name>
<filter-class>org.wso2.carbon.device.mgt.jaxrs.ApiOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApiOriginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app> </web-app>

@ -52,7 +52,8 @@ public class Device implements Serializable{
private List<Feature> features; private List<Feature> features;
private List<Device.Property> properties; private List<Device.Property> properties;
public Device() {} public Device() {
}
public Device(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo, public Device(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo,
List<Feature> features, List<Property> properties) { List<Feature> features, List<Property> properties) {

@ -19,9 +19,17 @@
package org.wso2.carbon.device.mgt.common.operation.mgt; package org.wso2.carbon.device.mgt.common.operation.mgt;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(value = "OperationResponse", description = "This class carries all information related to operation"
+ " responses")
public class OperationResponse { public class OperationResponse {
@ApiModelProperty(name = "response", value = "Operation response return from the device", required = true)
private String response; private String response;
@ApiModelProperty(name = "recievedTimeStamp", value = "Time that the operation response received",
required = true)
private String recievedTimeStamp; private String recievedTimeStamp;
public String getResponse() { public String getResponse() {

@ -29,12 +29,17 @@
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory> <directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory> <directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/jaggery-modules</directory>
<outputDirectory>/jaggery-modules/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
</fileSets> </fileSets>

@ -0,0 +1,38 @@
<module name="utils" xmlns="http://wso2.org/projects/jaggery/module.xml">
<script>
<name>reflection</name>
<path>scripts/reflection/reflection.js</path>
</script>
<script>
<name>file</name>
<path>scripts/file/file.js</path>
</script>
<script>
<name>patterns</name>
<path>scripts/patterns/patterns.js</path>
</script>
<script>
<name>xml</name>
<path>scripts/xml/xml.js</path>
</script>
<script>
<name>request</name>
<path>scripts/request/request.js</path>
</script>
<script>
<name>response</name>
<path>scripts/response/response.js</path>
</script>
<script>
<name>time</name>
<path>scripts/time/time.js</path>
</script>
<script>
<name>url</name>
<path>scripts/url/url.js</path>
</script>
<script>
<name>exception</name>
<path>scripts/exception/exception.js</path>
</script>
</module>

@ -0,0 +1,62 @@
/*
* Copyright (c) WSO2 Inc. (http://wso2.com) All Rights Reserved.
*
* Licensed 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.
*/
/**
* Description: The response of the currently invoked api enpoint is organized
*/
var exception = {};
var log = new Log('exception_module');
(function(exception) {
/**
*
* @param message The exception description
* @param code HTTP STATUS CODE related to the exception
* @return The error object
*/
exception.buildExceptionObject = function(message, code) {
var error = {};
error.message = message;
error.code = code;
return error;
};
exception.handleError = function (exception, type, code){
var constants = require('rxt').constants;
if (type == constants.THROW_EXCEPTION_TO_CLIENT) {
log.debug(exception);
var e = exceptionModule.buildExceptionObject(exception, code);
throw e;
} else if (type == constants.LOG_AND_THROW_EXCEPTION) {
log.error(exception);
throw exception;
} else if (type == constants.LOG_EXCEPTION_AND_TERMINATE) {
log.error(exception);
var msg = 'An error occurred while serving the request!';
var e = exceptionModule.buildExceptionObject(msg, constants.STATUS_CODES.INTERNAL_SERVER_ERROR);
throw e;
} else if (type == constants.LOG_EXCEPTION_AND_CONTINUE) {
log.debug(exception);
}
else {
log.error(exception);
throw e;
}
};
}(exception))

@ -0,0 +1,167 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var file = {};
(function() {
var log = new Log('utils-file');
var CONTENT_MAP = {
'js': 'application/javascript',
'css': 'text/css',
'csv': 'text/csv',
'html': 'text/html',
'json': 'application/json',
'png': 'image/png',
'jpeg': 'image/jpeg',
'gif': 'image/gif',
'svg': 'image/svg+xml',
'ttf': 'application/x-font-ttf',
'eot': 'application/vnd.ms-fontobject',
'woff': 'application/font-woff',
'otf': 'application/x-font-otf',
'zip': 'application/zip',
'xml': 'text/xml',
'xhtml': 'application/xhtml+xml',
'pdf': 'application/pdf'
};
/**
* The function checks whether a directory contains a particular file
* @param dir The directory in which the file must be checked
* @param file A File object if the file exists,else null
*/
file.getFileInDir = function(dir, fileName) {
var isFilePresent = false;
var files = dir.listFiles();
for (var index in files) {
if (files[index].getName() == fileName) {
return files[index];
}
}
return null;
};
/**
* The function returns the file extension of a filename
* @param file
* @return: The extension of the file
*/
file.getExtension = function(file) {
var baseFileName = file.getName();
//Break up the name by .
var baseNameComponents = baseFileName.split('.');
var extension = baseNameComponents[baseNameComponents.length - 1];
return extension;
};
/**
* The function obtains the MIME type based on the extension
* @param The extension
* @return The mime type
*/
file.getMimeType = function(extension) {
return CONTENT_MAP[extension];
};
/**
* The function returns the name of the file without the file extension
* @param file A file object
* @return: The name of the file without the extension
*/
file.getFileName = function(file) {
//Get the name of the file
var baseFileName = file.getName();
//Break up the name by .
var baseNameComponents = baseFileName.split('.');
//Get all of the components except the last one
baseNameComponents.splice(baseNameComponents.length - 1, 1);
return baseNameComponents.join('.');
};
/**
* The function returns the contents of a directory as a JSON object.The name of the
* file is used as the property names without the extensions.
* NOTE: The method will not traverse sub folders.
* @param The directory to be inspected
* @return A JSON object which contains the files in the directory
*/
file.getDirectoryContents = function(dir) {
var dirContents = {};
//Check if it is a directory
if (!dir.isDirectory()) {
log.info('Not a directory');
return dirContents;
}
//Obtain a list of all files
var files = this.getAllFiles(dir);
var name;
log.info('Files: ' + files);
//Create the directory object with each file been a property
for (var index in files) {
dirContents[this.getFileName(files[index])] = files[index];
}
return dirContents;
};
/**
* The function obtains a list of files that are not directories
* @param dir The directory to be inspected
* @return An array with all of the files in the directory
*/
file.getAllFiles = function(dir) {
var filesInDir = [];
if (!dir.isDirectory()) {
return filesInDir;
}
//Obtain a list of all files
var files = dir.listFiles();
for (var index in files) {
log.info('Checking file: ' + files[index].getName());
//Check if the file is a directory
if (!files[index].isDirectory()) {
filesInDir.push(files[index]);
}
}
return filesInDir;
};
/**
* The function returns a list of all file names in a directory
* @param dir The directory to be inspected
* @return {An array containing the name of all files in a directory
*/
file.getAllFileNames = function(dir) {
var files = dir.listFiles();
var list = [];
var fileName;
for (var index in files) {
if (files[index].isDirectory()) {
fileName=this.getFileName(files[index].getName());
list.push(fileName);
}
}
return list;
};
/**
* The function returns a list of all sub directories in a given directory
* @param dir The root directory
* @return: An array containing all sub directories
*/
file.getAllSubDirs = function(dir) {
var files = dir.listFiles();
var subDirs = [];
for (var index in files) {
if (files[index].isDirectory()) {
subDirs.push(files[index]);
}
}
return subDirs;
};
}());

@ -0,0 +1,128 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var patterns = {};
(function () {
var DEF_ERR_ARITY = 3;
var DEF_HANDLE_ARITY = 2;
var log = new Log('utils.patterns.GenericPipe');
function GenericPipe(options) {
this.errHandlerArity = DEF_ERR_ARITY || options.errArity;
this.handlerArity = DEF_HANDLE_ARITY || options.handlerArity;
this.plugins = [];
this.finalHandler = function () {
};
}
/**
*The function registers the provided plugin
*/
GenericPipe.prototype.plug = function (plugin, options) {
var options = options || {};
//Only a function
if (plugin instanceof Function) {
this.plugins.push({
handle: plugin,
options: options
});
}
//Is it a plugin object
else if (plugin instanceof Object) {
plugin.options = options;
this.plugins.push(plugin);
}
return this;
};
GenericPipe.prototype.finally = function (plugin) {
this.finalHandler = plugin;
return this;
};
GenericPipe.prototype.resolve = function (data, req, res, session) {
var context = {};
context.req = req;
context.res = res;
context.session = session;
context.data = data;
handle(context, this.plugins, this.errHandlerArity, this.handlerArity, this.finalHandler);
};
var handle = function (context, plugins, errArity, handlerArity, finallyHandler) {
var index = 0;
var currentPlugin;
var recursiveHandle = function (err) {
currentPlugin = plugins[index];
index++;
//Check if there is a plugin
if (!currentPlugin) {
//log.warn('No plugin found at index: ' + index);
return;
}
//Populate the options object for the plugin
context.options=currentPlugin.options;;
//Check if an error has been provided
if (err) {
//Can the current plugin handle the err
if (currentPlugin.handle.length == errArity) {
try {
currentPlugin.handle(err, context,recursiveHandle);
}
catch (e) {
recursiveHandle(e);
}
}
else {
recursiveHandle(err);
}
}
//There is no error so try to invoke the current plugin
else {
if (currentPlugin.handle.length == handlerArity) {
try {
currentPlugin.handle(context,recursiveHandle);
} catch (e) {
recursiveHandle(e);
}
}
else {
recursiveHandle();
}
}
};
recursiveHandle();
finallyHandler(context);
};
patterns.GenericPipe = GenericPipe;
}());

@ -0,0 +1,230 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var reflection = {};
/**
* Description: The script encapsulates any reflection related utility functions
*/
(function() {
var log = new Log('utils-reflection');
reflection.copyPropKeys = function(from, to) {
for (var key in from) {
if (from.hasOwnProperty(key)) {
to[key] = '';
}
}
return to;
};
/**
* The function recursively copies all property keys in an object
* @param from
* @param to
*/
reflection.copyAllPropKeys = function(from, to) {
recurse(from, to, function(from, to, key) {
if (from[key] instanceof Object) {
to[key] = from[key];
} else {
to[key] = null;
}
});
};
reflection.copyAllPropValues = function(from, to) {
recurse(from, to, function(from, to, key) {
//Create an instance if the property does not exist
if (!to[key]) {
to[key] = {};
}
//Copy the values over
if (!(from[key] instanceof Object)) {
to[key] = from[key];
} else {
log.debug('Not copying values of key: ' + key);
}
});
};
/**
* The function will only copy public properties
* @param from
* @param to
*/
reflection.copyPublicPropValues = function(from, to) {
recurse(from, to, function(from, to, key) {
//Ignore any hidden properties
if (key.charAt(0) == '_') {
log.warn('Drop key: ' + key);
return;
}
//Create an instance if the property does not exist
if (!to[key]) {
to[key] = {};
}
//Copy the values over
if (!(from[key] instanceof Object)) {
to[key] = from[key];
} else {
log.warn('Not copying values of key: ' + key);
}
});
};
reflection.inspect = function(from, to, cb) {
recurse(from, to, cb);
};
/**
* The function recursively traverses an object and then invokes the provided
* callback
* @param root
* @param clone
* @param cb
*/
var recurse = function(root, clone, cb) {
var key;
//Check if the root is an object
if (!(root instanceof Object)) {
return;
} else {
var keys = Object.keys(root);
//Go through all the other keys in the current root
for (var index in keys) {
key = keys[index];
cb(root, clone, key);
recurse(root[key], clone[key], cb);
}
}
};
reflection.copyProps = function(from, to) {
for (var key in from) {
if (from.hasOwnProperty(key)) {
to[key] = from[key];
}
}
return to;
};
reflection.getProps = function(obj) {
var props = {};
for (var key in obj) {
if (!(obj[key] instanceof Function)) {
props[key] = obj[key];
}
}
return props;
};
reflection.printProps = function(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
log.info('key: ' + key);
}
}
};
/**
* The function determines if a property is hidden based on _
* @param key
* @returns {boolean}
*/
reflection.isHiddenProp = function(key) {
if (key == '') {
return false;
}
return (key.charAt(0) == '_') ? true : false;
};
var getDiff = function(a, b, diff) {};
/**
* The function calculates the differences between two simple JSON objects
* @param a The object with which b is compared
* @param b The target of the comparison
* @return An object which records the differences between the two objects
*/
reflection.diff = function(a, b) {};
/**
* The function merges the two provided objects to create a new
* object.In the case where b has the same property as a; the property of b
* will have precedence
* @param {[type]} a [description]
* @param {[type]} b [description]
* @return A new object having the properties of both object a and b
*/
reflection.merge = function(a, b) {
var newObj = {};
//Copy the properties of a first
for (var key in a) {
newObj[key] = b[key];
}
//Override with the properties of b
for (var key in b) {
newObj[key] = b[key];
}
return newObj;
};
/**
* The function allows a child class to override a select set of methods of
* a parent class.The original methods of the parent can be accessed
* using the this._super keyword
* @param {[type]} parent The parent class instance to be overriden
* @param {[type]} child The child class instance containing methods which will override the parent
*/
reflection.override = function(parent, child) {
//Make a clone of the parent
var super = parse(stringify(parent));
for (var childKey in child) {
for (var parentKey in parent) {
//Only override those methods that are common
if (childKey === parentKey) {
var parentPtr = parent[parentKey];
var childPtr = child[childKey];
//Update the clone with the old parent method
super[parentKey] = parentPtr;
parent[parentKey] = childPtr;
/*parent[parentKey] = function() {
var result=childPtr.apply(this, arguments)||null;
return result;
};*/
}
}
}
//Allow the child object to call methods of the parent
parent._super = super;
};
reflection.overrideAll=function(parent,child){
//Make a clone of the parent
var super = parse(stringify(parent));
for (var childKey in child) {
for (var parentKey in parent) {
//Only override those methods that are common
if ( (child.hasOwnProperty(childKey))&&(parent.hasOwnProperty(parentKey)) ) {
var parentPtr = parent[parentKey];
var childPtr = child[childKey];
//Update the clone with the old parent method
super[parentKey] = parentPtr;
parent[parentKey] = childPtr;
/*parent[parentKey] = function() {
var result=childPtr.apply(this, arguments)||null;
return result;
};*/
}
}
}
//Allow the child object to call methods of the parent
parent._super = super;
};
reflection.isArray = function(object) {
if (Object.prototype.toString.call(object) === '[object Array]') {
return true;
}
return false;
};
}());

@ -0,0 +1,57 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var request = {};
(function(request) {
var hasOwnProperty = function(obj, element) {
return Object.prototype.hasOwnProperty.call(obj, element);
};
var isObject = function(object) {;
return typeof object === 'object';
};
/*
* ECMA Standard (ECMA-262 : 5.1 Edition)*/
var decodes = function(encodedURI) {
return decodeURIComponent(encodedURI);
};
request.getQueryOptions = function(queryString) {
var opt={};
var sep = opt.sep || '&',
assign = opt.assign || '=',
compoArray = [];
var obj = {};
var decodedURI = decodes(queryString);
decodedURI.split(sep).forEach(function(comp) {
comp.split(assign).some(function(element, index, array) {
if (hasOwnProperty(obj, element.toString())) {
compoArray.push(obj[element]);
compoArray.push(array[1]);
obj[element] = compoArray;
} else {
Object.defineProperty(obj, element, {
enumerable: true,
writable: true,
value: array[1]
});
}
return true;
});
});
return obj;
};
}(request))

@ -0,0 +1,96 @@
/*
* Copyright (c) WSO2 Inc. (http://wso2.com) All Rights Reserved.
*
* Licensed 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.
*/
/**
* Description: The response of the currently invoked api endpoint is organized
*/
var response = {};
var log = new Log("response");
(function(response) {
/**
* Build Error response
* @param resp jaggery-response object to retrieve to client
* @param code status code
* @param message message to the client side
* @return return response
*/
response.buildErrorResponse = function(resp,code,message) {
var content={};
content.error = message;
resp = processResponse(resp,code,content);
return resp;
};
/**
* Build success response
* @param resp jaggery response object
* @param code status code
* @param data the result to client
* @return return response
*/
response.buildSuccessResponse= function(resp, code, data){
var content={};
content.data = data;
resp = processResponse(resp,code,content);
return resp;
};
/**
* process General response
* @param resp jaggery response
* @param code status code
* @param data success result
* @return resp jaggery response
*/
response.buildSuccessResponseForRxt= function(resp, code, data){
resp.status = code;
resp.content = data;
return resp;
};
/**
* General response builder
* @param resp jaggery response
* @param code status code
* @param content what ever the content to be sent as response
* @return resp jaggery response
*/
function processResponse(resp, code, content){
resp.status = code;
resp.contentType = 'application/json';
resp.content = content;
return resp;
};
/**
*
* @param resp
* @param code
* @param data
* @return The http response
*/
response.buildSuccessResponseForRxt= function(resp, code, data){
resp.contentType = 'application/json';
resp.status = code;
resp.content = data;
return resp;
};
}(response))

@ -0,0 +1,35 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var time = {};
(function(time) {
time.getCurrentTime = function(dateLength) {
var dateLength=dateLength||20;
var now = new String(new Date().valueOf());
var length = now.length;
var prefix = dateLength;
var onsetVal = '';
if (length != prefix) {
var onset = prefix - length;
for (var i = 0; i < onset; i++) {
onsetVal += '0';
}
}
return onsetVal + now;
};
}(time));

@ -0,0 +1,47 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var url = {};
(function() {
var log=new Log('utils-url');
url.popServerDetails = function(obj) {
var process = require('process');
var localIP = process.getProperty('server.host');
var httpPort = process.getProperty('http.port');
var httpsPort = process.getProperty('https.port');
var value = '';
var carbonLocalIP = process.getProperty('carbon.local.ip');
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
value = obj[key];
if ((typeof value === 'string') && value.indexOf('%https.host%') > -1) {
value=value.replace('%https.host%', 'https://' + localIP + ':' + httpsPort);
} else if ((typeof value === 'string') && value.indexOf('%http.host%') > -1) {
value=value.replace('%http.host%', 'http://' + localIP + ':' + httpPort);
} else if ((typeof value === 'string') && value.indexOf('%https.carbon.local.ip%') > -1) {
value=value.replace('%https.carbon.local.ip%', 'https://' + carbonLocalIP + ':' + httpsPort);
} else if ((typeof value === 'string') && value.indexOf('%http.carbon.local.ip%') > -1) {
value=value.replace('%http.carbon.local.ip%', 'http://' + carbonLocalIP + ':' + httpPort);
}
obj[key] = value;
}
}
return obj;
};
}(url));

@ -0,0 +1,138 @@
/*
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var xml = {};
(function () {
var log=new Log('util.xml')
/*
The method is used to create a JSON object using
an xml object.
@xmlElement: An xml element object to be processed
@return: A pseudo object containing the properties of the
xml element.
*/
var createJSONObject = function (xmlElement) {
var pseudo = {};
//Extract all attributes
var attributes = xmlElement.@*;
//Fill the pseudo object with the attributes of the element
for (var attributeKey in attributes) {
var attribute = attributes[attributeKey];
pseudo[attribute.localName()] = attribute.toString();
}
return pseudo;
};
/*
The function converts an E4X Xml object to a JSON object
This function has been adapted from the work of Oleg Podsechin available at
https://gist.github.com/olegp/642667
It uses a slightly modified version of his algorithm , therefore
all credit should be attributed to Oleg Podsechin.
IMPORTANT:
1. It does not create a 1..1 mapping due to the differences
between Xml and JSON.It is IMPORTANT that you verify the structure
of the object generated before using it.
2. The input xml object must not contain the xml header information
This is a known bug 336551 (Mozilla Developer Network)
Source: https://developer.mozilla.org/en/docs/E4X
Please remove the header prior to sending the xml object for processing.
@root: A starting element in an E4X Xml object
@return: A JSON object mirroring the provided Xml object
*/
var recursiveConvertE4XtoJSON = function (root) {
log.debug('Root: ' + root.localName());
//Obtain child nodes
var children = root.*;
//The number of children
var numChildren = children.length();
//No children
if (numChildren == 0) {
//Extract contents
return createJSONObject(root);
}
else {
//Create an empty object
var rootObject = createJSONObject(root);
//Could be multiple children
for (var childElementKey in children) {
var child = children[childElementKey];
log.debug('Examining child: ' + child.localName());
//If the child just contains a single value then stop
if (child.localName() == undefined) {
log.debug('Child is undefined: ' + child.toString());
//Change the object to just a key value pair
rootObject[root.localName()] = child.toString();
return rootObject;
}
//Make a recursive call to construct the child element
var createdObject = recursiveConvertE4XtoJSON(child);
log.debug('Converted object: ' + stringify(createdObject));
//Check if the root object has the property
if (rootObject.hasOwnProperty(child.localName())) {
log.debug('key: ' + child.localName() + ' already present.');
rootObject[child.localName()].push(createdObject);
}
else {
log.debug('key: ' + child.localName() + ' not present.');
rootObject[child.localName()] = [];
rootObject[child.localName()].push(createdObject);
}
}
log.debug('root: ' + root.localName());
return rootObject;
}
};
/**
* The function is used to convert an E4X xml to JSON
* @param root
*/
xml.convertE4XtoJSON = function (root) {
return recursiveConvertE4XtoJSON(root);
};
}());

@ -57,7 +57,7 @@
<type>zip</type> <type>zip</type>
<overWrite>true</overWrite> <overWrite>true</overWrite>
<outputDirectory> <outputDirectory>
${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt-cdmf ${project.build.directory}/maven-shared-archive-resources
</outputDirectory> </outputDirectory>
<includes>**/*</includes> <includes>**/*</includes>
</artifactItem> </artifactItem>

@ -1,3 +1,4 @@
instructions.configure = \ instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggeryapps/devicemgt-cdmf,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggeryapps/devicemgt-cdmf,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggery-modules/utils/,target:${installFolder}/../../modules/utils,overwrite:true);\

@ -1456,10 +1456,23 @@
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
</dependency>
</dependencies>
</dependencyManagement> </dependencyManagement>
<scm> <scm>
@ -1823,6 +1836,7 @@
<nimbus.orbit.version.range>[2.26.1, 3.0.0)</nimbus.orbit.version.range> <nimbus.orbit.version.range>[2.26.1, 3.0.0)</nimbus.orbit.version.range>
<swagger.version>1.5.8</swagger.version> <swagger.version>1.5.8</swagger.version>
<servlet-api.version>2.5</servlet-api.version>
</properties> </properties>
</project> </project>

Loading…
Cancel
Save