diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/permissions.xml
index 8718c827e07..b38133cc1fb 100644
--- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/permissions.xml
@@ -33,7 +33,7 @@
get certificate in the database
/device-mgt/emm-admin/certificate/GetSignCSR
- /certificates/signcsr
+ /certificates/scep/signcsr
POST
emm_admin
diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/permissions.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/permissions.xml
index 480483adb46..dcd6b92155f 100644
--- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/permissions.xml
@@ -29,38 +29,30 @@
-->
-
-
- get certificate in the database
- /device-mgt/emm-admin/certificate/GetSignCSR
- /certificates/sign-csr
- POST
- emm_admin
-
Save certificate
/device-mgt/admin/certificate/Save
- /certificates
+ /admin/certificates
POST
Get certificate
/device-mgt/admin/certificate/Get
- /certificates/*
+ /admin/certificates/*
GET
Get all certificates
/device-mgt/admin/certificate/GetAll
- /certificates
+ /admin/certificates
GET
Remove certificate
/device-mgt/admin/certificate/Remove
- /certificates/*
+ /admin/certificates/*
DELETE
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java
new file mode 100644
index 00000000000..21b4f12cbc7
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java
@@ -0,0 +1,55 @@
+/*
+ * 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.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.wso2.carbon.policy.mgt.common.Policy;
+
+import java.util.List;
+
+@ApiModel(value = "Policy List")
+public class PolicyList extends BasePaginatedResult {
+
+ private List policies;
+
+ @ApiModelProperty(value = "List of policies returned")
+ @JsonProperty("policies")
+ public List getList() {
+ return policies;
+ }
+
+ public void setList(List policies) {
+ this.policies = policies;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{\n");
+ sb.append(" count: ").append(getCount()).append(",\n");
+ sb.append(" next: ").append(getNext()).append(",\n");
+ sb.append(" previous: ").append(getPrevious()).append(",\n");
+ sb.append(" roles: [").append(policies).append("\n");
+ sb.append("]}\n");
+ return sb.toString();
+ }
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java
index 4cb08fa36cb..11cfaa3ddcd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java
@@ -43,7 +43,6 @@ public class RoleList extends BasePaginatedResult {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{\n");
-
sb.append(" count: ").append(getCount()).append(",\n");
sb.append(" next: ").append(getNext()).append(",\n");
sb.append(" previous: ").append(getPrevious()).append(",\n");
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index f1c13574f5d..8a0e1d81358 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -254,15 +254,15 @@ public interface DeviceManagementService {
})
@Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesInfo(
- @ApiParam(
- name = "deviceIds",
- value = "List of device identifiers",
- required = true) List deviceIds,
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
- @HeaderParam("If-Modified-Since") String timestamp);
+ @HeaderParam("If-Modified-Since") String timestamp,
+ @ApiParam(
+ name = "deviceIds",
+ value = "List of device identifiers",
+ required = true) List deviceIds);
@GET
@@ -610,7 +610,7 @@ public interface DeviceManagementService {
code = 500,
message = "Internal Server ErrorResponse. \n " +
"Server error occurred while retrieving installed application list of the device.",
- response = ErrorResponse.class)
+ response = ErrorResponse.class)
})
@Permission(scope = "operation-view", permissions = {
"/permission/admin/device-mgt/admin/devices/view",
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index 6122071b40f..9fc2a63b1cd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -137,10 +137,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
@POST
+ @Path("/get-info")
@Override
public Response getDevicesInfo(
- List deviceIds,
- @HeaderParam("If-Modified-Since") String timestamp) {
+ @HeaderParam("If-Modified-Since") String timestamp,
+ List deviceIds) {
DeviceInformationManager informationManager;
List deviceInfo;
try {
@@ -276,10 +277,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
}
- if (devices == null) {
+ if (devices == null || devices.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("It is likely that no device is found upon " +
- "the provided type and id").build();
+ "the provided search filters").build();
}
+
return Response.status(Response.Status.OK).entity(devices).build();
}
@@ -330,8 +332,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
dms = DeviceMgtAPIUtils.getDeviceManagementService();
operations = dms.getOperations(new DeviceIdentifier(id, type));
if (operations == null) {
- Response.status(Response.Status.NOT_FOUND).entity("It is likely that no device is found upon " +
- "the provided type and id");
+ return Response.status(Response.Status.NOT_FOUND).entity("It is likely that no device is found upon " +
+ "the provided type and id").build();
}
} catch (OperationManagementException e) {
String msg = "Error occurred while fetching the operations for the '" + type + "' device, which " +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
index 32760e1189b..aeacd9046e8 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
@@ -27,9 +27,10 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
+import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyList;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.PolicyManagementService;
-import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.PolicyFilteringUtil;
+import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil;
import org.wso2.carbon.policy.mgt.common.Policy;
@@ -120,19 +121,27 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
@QueryParam("limit") int limit) {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
List policies;
+ List filteredPolicies;
+ PolicyList targetPolicies = new PolicyList();
try {
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
policies = policyAdministratorPoint.getPolicies();
if (policies == null || policies.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No policies found.").build();
}
+ targetPolicies.setCount(policies.size());
+ filteredPolicies = FilteringUtil.getFilteredList(policies, offset, limit);
+ if (filteredPolicies.size() == 0) {
+ return Response.status(Response.Status.NOT_FOUND).entity("No policies found.").build();
+ }
+ targetPolicies.setList(filteredPolicies);
} catch (PolicyManagementException e) {
String msg = "ErrorResponse occurred while retrieving all available policies";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
- return Response.status(Response.Status.OK).entity(PolicyFilteringUtil.getPolicies(policies, offset, limit))
- .build();
+
+ return Response.status(Response.Status.OK).entity(targetPolicies).build();
}
@GET
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
index 8979f596414..46d4888ef2c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
@@ -25,6 +25,7 @@ import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService;
+import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
@@ -57,14 +58,17 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
List filteredRoles;
- RoleList targetRoles;
+ RoleList targetRoles = new RoleList();
try {
filteredRoles = getRolesFromUserStore();
- if (filteredRoles == null) {
+ if (filteredRoles == null || filteredRoles.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No roles found.").build();
}
- targetRoles = new RoleList();
targetRoles.setCount(filteredRoles.size());
+ filteredRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(), offset, limit);
+ if (filteredRoles.size() == 0) {
+ return Response.status(Response.Status.NOT_FOUND).entity("No roles found.").build();
+ }
targetRoles.setList(filteredRoles);
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving roles from the underlying user stores";
@@ -181,6 +185,10 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@POST
@Override
public Response addRole(RoleWrapper roleWrapper) {
+ if (roleWrapper == null) {
+ log.error("Request body is incorrect or empty");
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) {
@@ -210,6 +218,9 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@Path("/{roleName}")
@Override
public Response updateRole(@PathParam("roleName") String roleName, RoleWrapper roleWrapper) {
+ if (roleWrapper == null) {
+ return Response.status(Response.Status.BAD_REQUEST).entity("Request body is incorrect or empty").build();
+ }
String newRoleName = roleWrapper.getRoleName();
try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@@ -273,10 +284,13 @@ public class RoleManagementServiceImpl implements RoleManagementService {
"successfully been deleted").build();
}
- @POST
+ @PUT
@Path("/{roleName}/users")
@Override
public Response updateUsersOfRole(@PathParam("roleName") String roleName, List users) {
+ if (users == null || users.size() == 0) {
+ return Response.status(Response.Status.BAD_REQUEST).entity("No users are found in the request").build();
+ }
try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java
index 54140ccada8..46f80d18bfc 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java
@@ -25,9 +25,11 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnauthorizedAccessException;
+import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.*;
@@ -54,24 +56,31 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
int currentTenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
if (MultitenantConstants.SUPER_TENANT_ID != currentTenantId) {
throw new UnauthorizedAccessException(
- new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(
- "Current logged in user is not authorized to perform this operation").build());
+ new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(
+ "Current logged in user is not authorized to perform this operation").build());
}
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(DeviceMgtAPIUtils.getTenantId(tenantDomain));
List devices = DeviceMgtAPIUtils.getDeviceManagementService().
- getDevicesByNameAndType(name, type, offset, limit);
- if (devices == null) {
+ getDevicesByNameAndType(name, type, offset, limit);
+ if (devices == null || devices.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device, which carries the name '" +
- name + "', is currently enrolled in the system").build();
+ name + "', is currently enrolled in the system").build();
}
- return Response.status(Response.Status.OK).entity(devices).build();
+
+ // setting up paginated result
+ DeviceList deviceList = new DeviceList();
+ deviceList.setList(devices);
+ deviceList.setCount(devices.size());
+
+ return Response.status(Response.Status.OK).entity(deviceList).build();
} catch (DeviceManagementException e) {
- String msg = "Error occurred while fetching the devices that carry the name '" + name + "'";
+ String msg = "Error occurred at server side while fetching device list.";
log.error(msg, e);
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ throw new UnexpectedServerErrorException(
+ new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/PolicyFilteringUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/FilteringUtil.java
similarity index 81%
rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/PolicyFilteringUtil.java
rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/FilteringUtil.java
index d57266145b7..3cc650029c0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/PolicyFilteringUtil.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/FilteringUtil.java
@@ -18,21 +18,20 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.util;
-import org.wso2.carbon.policy.mgt.common.Policy;
+
import java.util.Collections;
import java.util.List;
/**
* This is used instead of filtering from cache.
- * Todo : need to implement proper pagination support on retrieving policies.
*/
-public class PolicyFilteringUtil {
+public class FilteringUtil {
/**
* This is used to filter from the cached policies.
*/
- public static List getPolicies(List sourceList, int offset, int limit) {
+ public static List getFilteredList(List sourceList, int offset, int limit) {
if(sourceList == null || sourceList.size() < offset){
return Collections.emptyList();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
index 9f273b63b12..d9c998c622d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
@@ -252,12 +252,13 @@ public class DeviceMgtAPIUtils {
RealmService realmService =
(RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(RealmService.class, null);
if (realmService == null) {
- throw new IllegalStateException("");
+ throw new IllegalStateException("Realm service has not been initialized.");
}
try {
return realmService.getTenantManager().getTenantId(tenantDomain);
} catch (UserStoreException e) {
- throw new DeviceManagementException("");
+ throw new DeviceManagementException("Error occured while trying to " +
+ "obtain tenant id of currently logged in user");
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
index f3a81be3e1b..ec1cc96cb02 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
@@ -30,104 +30,7 @@
-
-
- Fetch Activity related details
- /device-mgt/admin/activities/view
- /activities/*
- GET
-
-
- Fetch Activity related details
- /device-mgt/admin/activities/view
- /activities
- GET
-
-
-
-
- List devices
- /device-mgt/admin/devices/list
- /devices
- GET
-
-
-
- List device types
- /device-mgt/admin/devices/list
- /devices/types
- GET
-
-
-
- List device types
- /device-mgt/user/devices/list
- /devices/types
- GET
-
-
-
- Add policy
- /device-mgt/admin/policies/add
- /devices/types
- GET
-
-
-
- Add User policy
- /device-mgt/user/policies/add
- /devices/types
- GET
-
-
-
- Edit policy
- /device-mgt/admin/policies/update
- /devices/types
- GET
-
-
-
- Edit User policy
- /device-mgt/user/policies/update
- /devices/types
- GET
-
-
-
- View device
- /device-mgt/admin/devices/view
- /devices/view
- GET
-
-
-
- View user device
- /device-mgt/user/devices/view
- /devices/view
- GET
-
-
-
- Modify user device
- /device-mgt/user/devices/update
- /devices/type/*/id/*
- PUT
-
-
-
- Remove user device
- /device-mgt/user/devices/remove
- /devices/type/*/id/*
- DELETE
-
-
-
-
-
-
-
-
+
Device Management
/device-mgt
@@ -239,51 +142,90 @@
/
GET
+
-
-
-
-
-
-
-
-
-
-
+
- View device
- /device-mgt/admin/devices/view
- /devices/user/*/*
+ Fetch Activity related details
+ /device-mgt/admin/activities/view
+ /activities/*
GET
-
- Devices Count All
+ Fetch Activity related details
+ /device-mgt/admin/activities/view
+ /activities
+ GET
+
+
+
+
+ List devices
/device-mgt/admin/devices/list
- /devices/count
+ /devices
GET
-
- Device Count
- /device-mgt/user/devices/list
- /devices/user/*/count
+ Retrieve device information
+ /device-mgt/admin/devices/list
+ /devices/*/*/info
GET
-
- List devices
+ Get device
/device-mgt/admin/devices/list
- /devices/name/*/*
+ /devices/*/*
+ GET
+
+
+ Get device location
+ /device-mgt/admin/devices/list
+ /devices/*/*/location
+ GET
+
+
+ devices location
+ /device-mgt/admin/devices/list
+ /devices/locations
+ POST
+
+
+ Get devices feature
+ /device-mgt/admin/devices/list
+ /devices/*/*/features
+ GET
+
+
+ Search devices
+ /device-mgt/admin/devices/list
+ /devices/search-devices
+ POST
+
+
+ list device application
+ /device-mgt/admin/devices/list
+ /devices/*/*/applications
+ GET
+
+
+ list device operation
+ /device-mgt/admin/devices/list
+ /devices/*/*/operations
+ GET
+
+
+ list device effective-policy
+ /device-mgt/admin/devices/list
+ /devices/*/*/effective-policy
GET
-
- List All Own Devices
- /device-mgt/user/devices/list
- /devices/user/*
+ list devices
+ /device-mgt/admin/devices/list
+ /admin/devices
GET
+
@@ -394,6 +336,20 @@
GET
+
+ View device
+ /device-mgt/admin/devices/view
+ /devices/*/*/operations
+ GET
+
+
+
+ View device
+ /device-mgt/user/devices/view
+ /devices/*/*/operations
+ GET
+
+
@@ -404,34 +360,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
List policies
/device-mgt/admin/policies/list
- /features/*
+ /devices/*/*/features
GET
View device
/device-mgt/admin/devices/view
- /features/*
+ /devices/*/*/features
GET
View device
/device-mgt/user/devices/view
- /features/*
+ /devices/*/*/features
GET
View device
/device-mgt/user/devices/view
- /features
+ /devices/*/*/features
GET
-
+
@@ -466,7 +449,7 @@
List roles
/device-mgt/admin/roles/list
- /roles/permissions
+ /roles/*/permissions
GET
@@ -487,22 +470,14 @@
Update role
/device-mgt/admin/roles/update
- /roles
+ /roles/*
PUT
-
-
-
-
-
-
-
-
Update role
/device-mgt/admin/roles/update
- /roles/users
+ /roles/*/users
PUT
@@ -516,7 +491,7 @@
Remove role
/device-mgt/admin/roles/remove
- /roles
+ /roles/*
DELETE
@@ -665,9 +640,9 @@
- Device Information
+ Get additional information of devices
/device-mgt/admin/information/list
- /information/list
+ /devices/get-info
POST
@@ -1000,5 +975,4 @@
GET
-
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
index a65f40db65c..ae7fd00de2a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
@@ -259,7 +259,8 @@ public interface DeviceDAO {
* @return returns list of devices.
* @throws DeviceManagementDAOException
*/
- List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit) throws DeviceManagementDAOException;
+ List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
+ throws DeviceManagementDAOException;
/**
* This method is used to retrieve devices of a given device name as a paginated result.
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
index 0bc4d83f64e..96dce585c26 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
@@ -619,71 +619,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
return deviceCount;
}
- /**
- * Get the list of devices that matches with the given device name.
- *
- * @param deviceName Name of the device.
- * @param tenantId Id of the current tenant
- * @return device list
- * @throws DeviceManagementDAOException
- */
- @Override
- public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
- throws DeviceManagementDAOException {
-
- String filteringString = "";
- if (deviceName != null && !deviceName.isEmpty()) {
- filteringString = filteringString + " AND d.NAME LIKE ?";
- }
-
- if (type != null && !type.isEmpty()) {
- filteringString = filteringString + " AND t.NAME = ?";
- }
-
- Connection conn;
- PreparedStatement stmt = null;
- List devices = new ArrayList<>();
- ResultSet rs = null;
- try {
- conn = this.getConnection();
- String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
- "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
- "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
- "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
- "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
- ") d1 WHERE d1.ID = e.DEVICE_ID LIMIT ?, ?";
-
- stmt = conn.prepareStatement(sql);
- stmt.setInt(1, tenantId);
-
- int i = 1;
-
- if (deviceName != null && !deviceName.isEmpty()) {
- stmt.setString(++i, deviceName + "%");
- }
-
- if (type != null && !type.isEmpty()) {
- stmt.setString(++i, type);
- }
-
- stmt.setInt(++i, offset);
- stmt.setInt(++i, limit);
-
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- Device device = DeviceManagementDAOUtil.loadDevice(rs);
- devices.add(device);
- }
- } catch (SQLException e) {
- throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches " +
- "'" + deviceName + "'", e);
- } finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
- }
- return devices;
- }
-
@Override
public int addEnrollment(Device device, int tenantId) throws DeviceManagementDAOException {
Connection conn;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java
index e009fd63430..d10b7e9d994 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java
@@ -303,6 +303,71 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
return devices;
}
+ /**
+ * Get the list of devices that matches with the given device name and (or) device type.
+ *
+ * @param deviceName Name of the device.
+ * @param tenantId Id of the current tenant
+ * @return device list
+ * @throws DeviceManagementDAOException
+ */
+ @Override
+ public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
+ throws DeviceManagementDAOException {
+
+ String filteringString = "";
+ if (deviceName != null && !deviceName.isEmpty()) {
+ filteringString = filteringString + " AND d.NAME LIKE ?";
+ }
+
+ if (type != null && !type.isEmpty()) {
+ filteringString = filteringString + " AND t.NAME = ?";
+ }
+
+ Connection conn;
+ PreparedStatement stmt = null;
+ List devices = new ArrayList<>();
+ ResultSet rs = null;
+ try {
+ conn = this.getConnection();
+ String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
+ "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
+ "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
+ "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
+ "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
+ ") d1 WHERE d1.ID = e.DEVICE_ID LIMIT ?, ?";
+
+ stmt = conn.prepareStatement(sql);
+ stmt.setInt(1, tenantId);
+
+ int i = 1;
+
+ if (deviceName != null && !deviceName.isEmpty()) {
+ stmt.setString(++i, deviceName + "%");
+ }
+
+ if (type != null && !type.isEmpty()) {
+ stmt.setString(++i, type);
+ }
+
+ stmt.setInt(++i, offset);
+ stmt.setInt(++i, limit);
+
+ rs = stmt.executeQuery();
+
+ while (rs.next()) {
+ Device device = DeviceManagementDAOUtil.loadDevice(rs);
+ devices.add(device);
+ }
+ } catch (SQLException e) {
+ throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
+ "to the mentioned filtering criteria", e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ }
+ return devices;
+ }
+
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java
index bc8756710c0..7d2f874dd52 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java
@@ -310,6 +310,71 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
return devices;
}
+ /**
+ * Get the list of devices that matches with the given device name and (or) device type.
+ *
+ * @param deviceName Name of the device.
+ * @param tenantId Id of the current tenant
+ * @return device list
+ * @throws DeviceManagementDAOException
+ */
+ @Override
+ public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
+ throws DeviceManagementDAOException {
+
+ String filteringString = "";
+ if (deviceName != null && !deviceName.isEmpty()) {
+ filteringString = filteringString + " AND d.NAME LIKE ?";
+ }
+
+ if (type != null && !type.isEmpty()) {
+ filteringString = filteringString + " AND t.NAME = ?";
+ }
+
+ Connection conn;
+ PreparedStatement stmt = null;
+ List devices = new ArrayList<>();
+ ResultSet rs = null;
+ try {
+ conn = this.getConnection();
+ String sql = "SELECT * FROM (SELECT ROWNUM offset, rs.* FROM (SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, " +
+ "d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, " +
+ "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " +
+ "(SELECT d.ID, d.NAME, d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " +
+ "DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
+ ") d1 WHERE d1.ID = e.DEVICE_ID) rs) WHERE offset >= ? AND ROWNUM <= ?";
+
+ stmt = conn.prepareStatement(sql);
+ stmt.setInt(1, tenantId);
+
+ int i = 1;
+
+ if (deviceName != null && !deviceName.isEmpty()) {
+ stmt.setString(++i, deviceName + "%");
+ }
+
+ if (type != null && !type.isEmpty()) {
+ stmt.setString(++i, type);
+ }
+
+ stmt.setInt(++i, offset);
+ stmt.setInt(++i, limit);
+
+ rs = stmt.executeQuery();
+
+ while (rs.next()) {
+ Device device = DeviceManagementDAOUtil.loadDevice(rs);
+ devices.add(device);
+ }
+ } catch (SQLException e) {
+ throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
+ "to the mentioned filtering criteria", e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ }
+ return devices;
+ }
+
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java
index 00ed10661bc..878e3107422 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java
@@ -303,6 +303,71 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
return devices;
}
+ /**
+ * Get the list of devices that matches with the given device name and (or) device type.
+ *
+ * @param deviceName Name of the device.
+ * @param tenantId Id of the current tenant
+ * @return device list
+ * @throws DeviceManagementDAOException
+ */
+ @Override
+ public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
+ throws DeviceManagementDAOException {
+
+ String filteringString = "";
+ if (deviceName != null && !deviceName.isEmpty()) {
+ filteringString = filteringString + " AND d.NAME LIKE ?";
+ }
+
+ if (type != null && !type.isEmpty()) {
+ filteringString = filteringString + " AND t.NAME = ?";
+ }
+
+ Connection conn;
+ PreparedStatement stmt = null;
+ List devices = new ArrayList<>();
+ ResultSet rs = null;
+ try {
+ conn = this.getConnection();
+ String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
+ "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
+ "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
+ "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
+ "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
+ ") d1 WHERE d1.ID = e.DEVICE_ID OFFSET ? LIMIT ?";
+
+ stmt = conn.prepareStatement(sql);
+ stmt.setInt(1, tenantId);
+
+ int i = 1;
+
+ if (deviceName != null && !deviceName.isEmpty()) {
+ stmt.setString(++i, deviceName + "%");
+ }
+
+ if (type != null && !type.isEmpty()) {
+ stmt.setString(++i, type);
+ }
+
+ stmt.setInt(++i, offset);
+ stmt.setInt(++i, limit);
+
+ rs = stmt.executeQuery();
+
+ while (rs.next()) {
+ Device device = DeviceManagementDAOUtil.loadDevice(rs);
+ devices.add(device);
+ }
+ } catch (SQLException e) {
+ throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
+ "to the mentioned filtering criteria", e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ }
+ return devices;
+ }
+
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java
index d39bc7f52d2..476b703ad8c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java
@@ -305,6 +305,71 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
return devices;
}
+ /**
+ * Get the list of devices that matches with the given device name and (or) device type.
+ *
+ * @param deviceName Name of the device.
+ * @param tenantId Id of the current tenant
+ * @return device list
+ * @throws DeviceManagementDAOException
+ */
+ @Override
+ public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit)
+ throws DeviceManagementDAOException {
+
+ String filteringString = "";
+ if (deviceName != null && !deviceName.isEmpty()) {
+ filteringString = filteringString + " AND d.NAME LIKE ?";
+ }
+
+ if (type != null && !type.isEmpty()) {
+ filteringString = filteringString + " AND t.NAME = ?";
+ }
+
+ Connection conn;
+ PreparedStatement stmt = null;
+ List devices = new ArrayList<>();
+ ResultSet rs = null;
+ try {
+ conn = this.getConnection();
+ String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
+ "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
+ "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
+ "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
+ "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
+ ") d1 WHERE d1.ID = e.DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+
+ stmt = conn.prepareStatement(sql);
+ stmt.setInt(1, tenantId);
+
+ int i = 1;
+
+ if (deviceName != null && !deviceName.isEmpty()) {
+ stmt.setString(++i, deviceName + "%");
+ }
+
+ if (type != null && !type.isEmpty()) {
+ stmt.setString(++i, type);
+ }
+
+ stmt.setInt(++i, offset);
+ stmt.setInt(++i, limit);
+
+ rs = stmt.executeQuery();
+
+ while (rs.next()) {
+ Device device = DeviceManagementDAOUtil.loadDevice(rs);
+ devices.add(device);
+ }
+ } catch (SQLException e) {
+ throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
+ "to the mentioned filtering criteria", e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ }
+ return devices;
+ }
+
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}