revert-70aa11f8
Pasindu 8 years ago
commit be0c98cf54

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name> <name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description> <description>WSO2 Carbon - API Management Custom Annotation Module</description>

@ -21,12 +21,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name> <name>WSO2 Carbon - API Application Management API</name>

@ -22,12 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name> <name>WSO2 Carbon - API Application Management</name>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId> <artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name> <name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description> <description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name> <name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name> <name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name> <name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description> <description>WSO2 Carbon - API Management Webapp Publisher</description>

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name> <name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name> <name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description> <description>WSO2 Carbon - Certificate Management Core</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name> <name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -114,6 +114,7 @@
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging.*, org.apache.commons.logging.*,
org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.context;version="${carbon.kernel.version.range}", org.wso2.carbon.context;version="${carbon.kernel.version.range}",
org.wso2.carbon.utils;version="${carbon.kernel.version.range}", org.wso2.carbon.utils;version="${carbon.kernel.version.range}",
org.wso2.carbon.databridge.*;version="${carbon.analytics.common.version.range}", org.wso2.carbon.databridge.*;version="${carbon.analytics.common.version.range}",
@ -122,7 +123,7 @@
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",
org.json;version="${commons-json.version}", org.json;version="${commons-json.version}",
javax.xml.*, javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.w3c.dom, org.w3c.dom,
org.wso2.carbon.base org.wso2.carbon.base
</Import-Package> </Import-Package>
@ -131,5 +132,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -140,6 +140,93 @@ public interface ActivityInfoProviderService {
@HeaderParam("If-Modified-Since") String ifModifiedSince); @HeaderParam("If-Modified-Since") String ifModifiedSince);
@GET
@Path("/{id}/{devicetype}/{deviceid}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of an Activity for a specific device",
notes = "Retrieve the details of a specific activity/operation, such as the meta information of " +
"an operation, including the responses from a given device",
tags = "Activity Info Provider",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the activity details.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client already has the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found. \n No activity found with the given ID.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the activity data.",
response = ErrorResponse.class)
})
Response getActivityByDevice(
@ApiParam(
name = "id",
value = "Activity id of the operation/activity.",
required = true,
defaultValue = "ACTIVITY_1")
@PathParam("id")
@Size(max = 45)
String id,
@ApiParam(
name = "devicetype",
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("devicetype")
@Size(max = 45)
String type,
@ApiParam(
name = "deviceid",
value = "The device identifier of the device you want ot get details.",
required = true)
@PathParam("deviceid")
@Size(max = 45)
String deviceid,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time\n." +
"Provide the value in the Java Date Format: EEE, d MMM yyyy HH:mm:ss Z\n." +
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@GET @GET
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,

@ -221,6 +221,12 @@ public interface DeviceManagementService {
required = false) required = false)
@QueryParam("user") @QueryParam("user")
String user, String user,
@ApiParam(
name = "userPattern",
value = "The pattern of username of the owner of the device.",
required = false)
@QueryParam("userPattern")
String userPattern,
@ApiParam( @ApiParam(
name = "role", name = "role",
value = "A role of device owners. Ex : store-admin", value = "A role of device owners. Ex : store-admin",

@ -39,7 +39,7 @@ import javax.ws.rs.core.Response;
extensions = { extensions = {
@Extension(properties = { @Extension(properties = {
@ExtensionProperty(name = "name", value = "DeviceAnalyticsArtifactUploaderAdminService"), @ExtensionProperty(name = "name", value = "DeviceAnalyticsArtifactUploaderAdminService"),
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/devicetype"), @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/publish-artifact"),
}) })
} }
), ),
@ -47,7 +47,7 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Path("/admin/devicetype") @Path("/admin/publish-artifact")
@Api(value = "Devicetype deployment Administrative Service", description = "This an API intended to be used to " + @Api(value = "Devicetype deployment Administrative Service", description = "This an API intended to be used to " +
"deploy device type components" + "deploy device type components" +
"Further, this is strictly restricted to admin users only ") "Further, this is strictly restricted to admin users only ")

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@ -72,6 +73,43 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
} }
} }
@GET
@Override
@Path("/{id}/{devicetype}/{deviceid}")
public Response getActivityByDevice(@PathParam("id")
@Size(max = 45) String id,
@PathParam("devicetype")
@Size(max = 45) String devicetype,
@PathParam("deviceid")
@Size(max = 45) String deviceid,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
Activity activity;
DeviceManagementProviderService dmService;
try {
RequestValidationUtil.validateActivityId(id);
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(deviceid);
deviceIdentifier.setType(devicetype);
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
activity = dmService.getOperationByActivityIdAndDevice(id, deviceIdentifier);
if (activity == null) {
return Response.status(404).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("No activity can be " +
"found upon the provided activity id '" + id + "'").build()).build();
}
return Response.status(Response.Status.OK).entity(activity).build();
} catch (OperationManagementException e) {
String msg = "ErrorResponse occurred while fetching the activity for the supplied id.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
@GET @GET
@Override @Override
public Response getActivities(@QueryParam("since") String since, @QueryParam("offset") int offset, public Response getActivities(@QueryParam("since") String since, @QueryParam("offset") int offset,

@ -90,6 +90,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("name") String name, @QueryParam("name") String name,
@QueryParam("type") String type, @QueryParam("type") String type,
@QueryParam("user") String user, @QueryParam("user") String user,
@QueryParam("userPattern") String userPattern,
@QueryParam("role") String role, @QueryParam("role") String role,
@QueryParam("ownership") String ownership, @QueryParam("ownership") String ownership,
@QueryParam("status") String status, @QueryParam("status") String status,
@ -126,9 +127,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (type != null && !type.isEmpty()) { if (type != null && !type.isEmpty()) {
request.setDeviceType(type); request.setDeviceType(type);
} }
if (user != null && !user.isEmpty()) {
request.setOwner(user);
}
if (ownership != null && !ownership.isEmpty()) { if (ownership != null && !ownership.isEmpty()) {
RequestValidationUtil.validateOwnershipType(ownership); RequestValidationUtil.validateOwnershipType(ownership);
request.setOwnership(ownership); request.setOwnership(ownership);
@ -151,6 +149,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (deviceAccessAuthorizationService.isDeviceAdminUser()) { if (deviceAccessAuthorizationService.isDeviceAdminUser()) {
if (user != null && !user.isEmpty()) { if (user != null && !user.isEmpty()) {
request.setOwner(MultitenantUtils.getTenantAwareUsername(user)); request.setOwner(MultitenantUtils.getTenantAwareUsername(user));
} else if (userPattern != null && !userPattern.isEmpty()) {
request.setOwnerPattern(userPattern);
} }
} else { } else {
if (user != null && !user.isEmpty()) { if (user != null && !user.isEmpty()) {

@ -68,7 +68,7 @@ import java.security.cert.CertificateException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Path("/admin/devicetype") @Path("/admin/publish-artifact")
public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAnalyticsArtifactUploaderAdminService { public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAnalyticsArtifactUploaderAdminService {
/** /**

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -29,6 +29,7 @@ public class PaginationRequest {
private int rowCount; private int rowCount;
private int groupId; private int groupId;
private String owner; private String owner;
private String ownerPattern;
private String status; private String status;
private String deviceType; private String deviceType;
private String deviceName; private String deviceName;
@ -120,4 +121,12 @@ public class PaginationRequest {
public void setOwnerRole(String ownerRole) { public void setOwnerRole(String ownerRole) {
this.ownerRole = ownerRole; this.ownerRole = ownerRole;
} }
public String getOwnerPattern() {
return ownerPattern;
}
public void setOwnerPattern(String ownerPattern) {
this.ownerPattern = ownerPattern;
}
} }

@ -93,6 +93,8 @@ public interface OperationManager {
Activity getOperationByActivityId(String activity) throws OperationManagementException; Activity getOperationByActivityId(String activity) throws OperationManagementException;
Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException;
List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException; List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException;
List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException; List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException;

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -55,29 +55,35 @@ public class DeviceCacheManagerImpl implements DeviceCacheManager {
@Override @Override
public void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) { public void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache(); Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId); if (lCache != null) {
if (lCache.containsKey(cacheKey)) { DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
this.updateDeviceInCache(deviceIdentifier, device, tenantId); if (lCache.containsKey(cacheKey)) {
} else { this.updateDeviceInCache(deviceIdentifier, device, tenantId);
lCache.put(cacheKey, device); } else {
lCache.put(cacheKey, device);
}
} }
} }
@Override @Override
public void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) { public void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache(); Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId); if (lCache != null) {
if (lCache.containsKey(cacheKey)) { DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
lCache.remove(cacheKey); if (lCache.containsKey(cacheKey)) {
lCache.remove(cacheKey);
}
} }
} }
@Override @Override
public void removeDevicesFromCache(List<DeviceCacheKey> deviceList) { public void removeDevicesFromCache(List<DeviceCacheKey> deviceList) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache(); Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
for (DeviceCacheKey cacheKey : deviceList) { if (lCache != null) {
if (lCache.containsKey(cacheKey)) { for (DeviceCacheKey cacheKey : deviceList) {
lCache.remove(cacheKey); if (lCache.containsKey(cacheKey)) {
lCache.remove(cacheKey);
}
} }
} }
} }
@ -85,16 +91,21 @@ public class DeviceCacheManagerImpl implements DeviceCacheManager {
@Override @Override
public void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) { public void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache(); Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId); if (lCache != null) {
if (lCache.containsKey(cacheKey)) { DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
lCache.replace(cacheKey, device); if (lCache.containsKey(cacheKey)) {
lCache.replace(cacheKey, device);
}
} }
} }
@Override @Override
public Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) { public Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache(); Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
return lCache.get(getCacheKey(deviceIdentifier, tenantId)); if (lCache != null) {
return lCache.get(getCacheKey(deviceIdentifier, tenantId));
}
return null;
} }

@ -485,6 +485,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
String owner = request.getOwner(); String owner = request.getOwner();
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
String ownerPattern = request.getOwnerPattern();
boolean isOwnerPatternProvided = false;
String ownership = request.getOwnership(); String ownership = request.getOwnership();
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
String status = request.getStatus(); String status = request.getStatus();
@ -523,9 +525,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
isOwnershipProvided = true; isOwnershipProvided = true;
} }
//Add the query for owner
if (owner != null && !owner.isEmpty()) { if (owner != null && !owner.isEmpty()) {
sql = sql + " AND LOWER(e.OWNER) LIKE LOWER(?)"; sql = sql + " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
} else if (ownerPattern != null && !ownerPattern.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?";
isOwnerPatternProvided = true;
} }
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
@ -551,7 +557,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
stmt.setString(paramIdx++, request.getOwnership()); stmt.setString(paramIdx++, request.getOwnership());
} }
if (isOwnerProvided) { if (isOwnerProvided) {
stmt.setString(paramIdx++, request.getOwner() + "%"); stmt.setString(paramIdx++, owner);
} else if (isOwnerPatternProvided) {
stmt.setString(paramIdx++, ownerPattern + "%");
} }
if (isStatusProvided) { if (isStatusProvided) {
stmt.setString(paramIdx++, request.getStatus()); stmt.setString(paramIdx++, request.getStatus());

@ -58,7 +58,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
return groupId; return groupId;
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" +
deviceGroup.getName() + "'", e); deviceGroup.getName() + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, null); GroupManagementDAOUtil.cleanupResources(stmt, null);
} }
@ -81,7 +81,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while updating deviceGroup '" + throw new GroupManagementDAOException("Error occurred while updating deviceGroup '" +
deviceGroup.getName() + "'", e); deviceGroup.getName() + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, null); GroupManagementDAOUtil.cleanupResources(stmt, null);
} }
@ -146,7 +146,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while obtaining information of Device Group '" + throw new GroupManagementDAOException("Error occurred while obtaining information of Device Group '" +
groupId + "'", e); groupId + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, resultSet); GroupManagementDAOUtil.cleanupResources(stmt, resultSet);
} }
@ -563,7 +563,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while getting own groups of user '" throw new GroupManagementDAOException("Error occurred while getting own groups of user '"
+ username + "'", e); + username + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, resultSet); GroupManagementDAOUtil.cleanupResources(stmt, resultSet);
} }
@ -588,7 +588,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while getting own groups of user '" throw new GroupManagementDAOException("Error occurred while getting own groups of user '"
+ username + "'", e); + username + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, resultSet); GroupManagementDAOUtil.cleanupResources(stmt, resultSet);
} }
@ -613,7 +613,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while getting own groups count of user '" throw new GroupManagementDAOException("Error occurred while getting own groups count of user '"
+ username + "'", e); + username + "'", e);
} finally { } finally {
GroupManagementDAOUtil.cleanupResources(stmt, resultSet); GroupManagementDAOUtil.cleanupResources(stmt, resultSet);
} }

@ -48,6 +48,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
String owner = request.getOwner(); String owner = request.getOwner();
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
String ownerPattern = request.getOwnerPattern();
boolean isOwnerPatternProvided = false;
String ownership = request.getOwnership(); String ownership = request.getOwnership();
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
String status = request.getStatus(); String status = request.getStatus();
@ -95,8 +97,11 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
//Add the query for owner //Add the query for owner
if (owner != null && !owner.isEmpty()) { if (owner != null && !owner.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?"; sql = sql + " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
} else if (ownerPattern != null && !ownerPattern.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?";
isOwnerPatternProvided = true;
} }
//Add the query for status //Add the query for status
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
@ -113,21 +118,23 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
stmt.setLong(paramIdx++, since.getTime()); stmt.setLong(paramIdx++, since.getTime());
} }
if (isDeviceTypeProvided) { if (isDeviceTypeProvided) {
stmt.setString(paramIdx++, request.getDeviceType()); stmt.setString(paramIdx++, deviceType);
} }
if (isDeviceNameProvided) { if (isDeviceNameProvided) {
stmt.setString(paramIdx++, request.getDeviceName() + "%"); stmt.setString(paramIdx++, deviceName + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isOwnershipProvided) { if (isOwnershipProvided) {
stmt.setString(paramIdx++, request.getOwnership()); stmt.setString(paramIdx++, ownership);
} }
if (isOwnerProvided) { if (isOwnerProvided) {
stmt.setString(paramIdx++, request.getOwner() + "%"); stmt.setString(paramIdx++, owner);
} else if (isOwnerPatternProvided) {
stmt.setString(paramIdx++, ownerPattern + "%");
} }
if (isStatusProvided) { if (isStatusProvided) {
stmt.setString(paramIdx++, request.getStatus()); stmt.setString(paramIdx++, status);
} }
stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getStartIndex());
stmt.setInt(paramIdx, request.getRowCount()); stmt.setInt(paramIdx, request.getRowCount());

@ -54,6 +54,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
String owner = request.getOwner(); String owner = request.getOwner();
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
String ownerPattern = request.getOwnerPattern();
boolean isOwnerPatternProvided = false;
String ownership = request.getOwnership(); String ownership = request.getOwnership();
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
String status = request.getStatus(); String status = request.getStatus();
@ -101,8 +103,11 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
//Add the query for owner //Add the query for owner
if (owner != null && !owner.isEmpty()) { if (owner != null && !owner.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?"; sql = sql + " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
} else if (ownerPattern != null && !ownerPattern.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?";
isOwnerPatternProvided = true;
} }
//Add the query for status //Add the query for status
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
@ -119,20 +124,23 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
stmt.setLong(paramIdx++, since.getTime()); stmt.setLong(paramIdx++, since.getTime());
} }
if (isDeviceTypeProvided) { if (isDeviceTypeProvided) {
stmt.setString(paramIdx++, request.getDeviceType()); stmt.setString(paramIdx++, deviceType);
} }
if (isDeviceNameProvided) { if (isDeviceNameProvided) {
stmt.setString(paramIdx++, request.getDeviceName() + "%"); stmt.setString(paramIdx++, deviceName + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isOwnershipProvided) { if (isOwnershipProvided) {
stmt.setString(paramIdx++, request.getOwnership()); stmt.setString(paramIdx++, ownership);
} }
if (isOwnerProvided) { if (isOwnerProvided) {
stmt.setString(paramIdx++, request.getOwner() + "%"); stmt.setString(paramIdx++, owner);
} else if (isOwnerPatternProvided) {
stmt.setString(paramIdx++, ownerPattern + "%");
} }
if (isStatusProvided) { if (isStatusProvided) {
stmt.setString(paramIdx++, request.getStatus()); stmt.setString(paramIdx++, status);
} }
stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getStartIndex());
stmt.setInt(paramIdx, request.getRowCount()); stmt.setInt(paramIdx, request.getRowCount());

@ -51,6 +51,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
String owner = request.getOwner(); String owner = request.getOwner();
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
String ownerPattern = request.getOwnerPattern();
boolean isOwnerPatternProvided = false;
String ownership = request.getOwnership(); String ownership = request.getOwnership();
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
String status = request.getStatus(); String status = request.getStatus();
@ -85,8 +87,11 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
//Add the query for owner //Add the query for owner
if (owner != null && !owner.isEmpty()) { if (owner != null && !owner.isEmpty()) {
sql = sql + " AND LOWER(e.OWNER) LIKE LOWER(?)"; sql = sql + " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
} else if (ownerPattern != null && !ownerPattern.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?";
isOwnerPatternProvided = true;
} }
//Add the query for status //Add the query for status
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
@ -100,20 +105,23 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
stmt.setInt(1, tenantId); stmt.setInt(1, tenantId);
int paramIdx = 2; int paramIdx = 2;
if (isDeviceTypeProvided) { if (isDeviceTypeProvided) {
stmt.setString(paramIdx++, request.getDeviceType()); stmt.setString(paramIdx++, deviceType);
} }
if (isDeviceNameProvided) { if (isDeviceNameProvided) {
stmt.setString(paramIdx++, request.getDeviceName() + "%"); stmt.setString(paramIdx++, deviceName + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isOwnershipProvided) { if (isOwnershipProvided) {
stmt.setString(paramIdx++, request.getOwnership()); stmt.setString(paramIdx++, ownership);
} }
if (isOwnerProvided) { if (isOwnerProvided) {
stmt.setString(paramIdx++, request.getOwner() + "%"); stmt.setString(paramIdx++, owner);
} else if (isOwnerPatternProvided) {
stmt.setString(paramIdx++, ownerPattern + "%");
} }
if (isStatusProvided) { if (isStatusProvided) {
stmt.setString(paramIdx++, request.getStatus()); stmt.setString(paramIdx++, status);
} }
stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx++, request.getRowCount());
stmt.setInt(paramIdx, request.getStartIndex()); stmt.setInt(paramIdx, request.getStartIndex());

@ -51,6 +51,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
String owner = request.getOwner(); String owner = request.getOwner();
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
String ownerPattern = request.getOwnerPattern();
boolean isOwnerPatternProvided = false;
String ownership = request.getOwnership(); String ownership = request.getOwnership();
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
String status = request.getStatus(); String status = request.getStatus();
@ -98,8 +100,11 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
//Add the query for owner //Add the query for owner
if (owner != null && !owner.isEmpty()) { if (owner != null && !owner.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?"; sql = sql + " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
} else if (ownerPattern != null && !ownerPattern.isEmpty()) {
sql = sql + " AND e.OWNER LIKE ?";
isOwnerPatternProvided = true;
} }
//Add the query for status //Add the query for status
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
@ -116,20 +121,23 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
stmt.setLong(paramIdx++, since.getTime()); stmt.setLong(paramIdx++, since.getTime());
} }
if (isDeviceTypeProvided) { if (isDeviceTypeProvided) {
stmt.setString(paramIdx++, request.getDeviceType()); stmt.setString(paramIdx++, deviceType);
} }
if (isDeviceNameProvided) { if (isDeviceNameProvided) {
stmt.setString(paramIdx++, request.getDeviceName() + "%"); stmt.setString(paramIdx++, deviceName + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isOwnershipProvided) { if (isOwnershipProvided) {
stmt.setString(paramIdx++, request.getOwnership()); stmt.setString(paramIdx++, ownership);
} }
if (isOwnerProvided) { if (isOwnerProvided) {
stmt.setString(paramIdx++, request.getOwner() + "%"); stmt.setString(paramIdx++, owner);
} else if (isOwnerPatternProvided) {
stmt.setString(paramIdx++, ownerPattern + "%");
} }
if (isStatusProvided) { if (isStatusProvided) {
stmt.setString(paramIdx++, request.getStatus()); stmt.setString(paramIdx++, status);
} }
stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getStartIndex());
stmt.setInt(paramIdx, request.getRowCount()); stmt.setInt(paramIdx, request.getRowCount());

@ -64,7 +64,7 @@ public class SQLServerGroupDAOImpl extends AbstractGroupDAOImpl {
hasOwner = true; hasOwner = true;
} }
if (hasLimit) { if (hasLimit) {
sql += " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; sql += " ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
} }
int paramIndex = 1; int paramIndex = 1;
@ -127,7 +127,7 @@ public class SQLServerGroupDAOImpl extends AbstractGroupDAOImpl {
} }
sql += ")"; sql += ")";
if (hasLimit) { if (hasLimit) {
sql += " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; sql += " ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
} }
int paramIndex = 1; int paramIndex = 1;
@ -177,7 +177,7 @@ public class SQLServerGroupDAOImpl extends AbstractGroupDAOImpl {
" DM_DEVICE d, (" + " DM_DEVICE d, (" +
"SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " + "SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " +
"WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " +
"WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY d1.DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, groupId); stmt.setInt(1, groupId);
@ -195,7 +195,7 @@ public class SQLServerGroupDAOImpl extends AbstractGroupDAOImpl {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while retrieving information of all " + throw new GroupManagementDAOException("Error occurred while retrieving information of all " +
"registered devices", e); "registered devices", e);
} finally { } finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs); DeviceManagementDAOUtil.cleanupResources(stmt, rs);
} }

@ -812,6 +812,28 @@ public class OperationManagerImpl implements OperationManager {
} }
} }
public Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException {
// This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
int operationId = Integer.parseInt(
activity.replace(DeviceManagementConstants.OperationAttributes.ACTIVITY, ""));
if (operationId == 0) {
throw new IllegalArgumentException("Operation ID cannot be null or zero (0).");
}
Device device = this.getDevice(deviceId);
try {
OperationManagementDAOFactory.openConnection();
return operationDAO.getActivityByDevice(operationId, device.getId());
} catch (SQLException e) {
throw new OperationManagementException("Error occurred while opening a connection to the data source.", e);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the operation with activity Id '" +
activity + " and device Id: " + deviceId.getId(), e);
} finally {
OperationManagementDAOFactory.closeConnection();
}
}
@Override @Override
public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException { public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException {
return null; return null;

@ -70,6 +70,8 @@ public interface OperationDAO {
Activity getActivity(int operationId) throws OperationManagementDAOException; Activity getActivity(int operationId) throws OperationManagementDAOException;
Activity getActivityByDevice(int operationId, int deviceId) throws OperationManagementDAOException;
int getEnrolmentIdFromMappingId(int enrollmentOpMappingId) throws OperationManagementDAOException; int getEnrolmentIdFromMappingId(int enrollmentOpMappingId) throws OperationManagementDAOException;
List<Operation> getOperationsUpdatedAfter(long timestamp) throws OperationManagementDAOException; List<Operation> getOperationsUpdatedAfter(long timestamp) throws OperationManagementDAOException;

@ -135,9 +135,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
ResultSet rs = null; ResultSet rs = null;
try { try {
Connection connection = OperationManagementDAOFactory.getConnection(); Connection connection = OperationManagementDAOFactory.getConnection();
String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING AS EOM INNER JOIN DM_OPERATION DM " + String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM "
"ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? " + + "ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? "
"AND EOM.STATUS = ?;"; + "AND EOM.STATUS = ?";
stmt = connection.prepareStatement(query); stmt = connection.prepareStatement(query);
stmt.setInt(1, enrolmentId); stmt.setInt(1, enrolmentId);
stmt.setString(2, operationCode); stmt.setString(2, operationCode);
@ -149,8 +149,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
id = rs.getInt("ID"); id = rs.getInt("ID");
} }
if (id != 0) { if (id != 0) {
stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS = ?, " + stmt = connection.prepareStatement(
"UPDATED_TIMESTAMP = ? WHERE ID = ?"); "UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS = ?, " + "UPDATED_TIMESTAMP = ? WHERE ID = ?");
stmt.setString(1, newStatus.toString()); stmt.setString(1, newStatus.toString());
stmt.setLong(2, System.currentTimeMillis() / 1000); stmt.setLong(2, System.currentTimeMillis() / 1000);
stmt.setInt(3, id); stmt.setInt(3, id);
@ -158,8 +158,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while update device mapping operation status " + throw new OperationManagementDAOException(
"metadata", e); "Error occurred while update device mapping operation status " + "metadata", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt); OperationManagementDAOUtil.cleanupResources(stmt);
} }
@ -173,9 +173,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
boolean result = false; boolean result = false;
try { try {
Connection connection = OperationManagementDAOFactory.getConnection(); Connection connection = OperationManagementDAOFactory.getConnection();
String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING AS EOM INNER JOIN DM_OPERATION DM " + String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM "
"ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? AND " + + "ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? AND "
"EOM.STATUS = ?;"; + "EOM.STATUS = ?";
stmt = connection.prepareStatement(query); stmt = connection.prepareStatement(query);
stmt.setInt(1, enrolmentId); stmt.setInt(1, enrolmentId);
stmt.setString(2, operationCode); stmt.setString(2, operationCode);
@ -187,16 +187,16 @@ public class GenericOperationDAOImpl implements OperationDAO {
id = rs.getInt("ID"); id = rs.getInt("ID");
} }
if (id != 0) { if (id != 0) {
stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + stmt = connection.prepareStatement(
"WHERE ID = ?"); "UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + "WHERE ID = ?");
stmt.setLong(1, System.currentTimeMillis() / 1000); stmt.setLong(1, System.currentTimeMillis() / 1000);
stmt.setInt(2, id); stmt.setInt(2, id);
stmt.executeUpdate(); stmt.executeUpdate();
result = true; result = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while update device mapping operation status " + throw new OperationManagementDAOException(
"metadata", e); "Error occurred while update device mapping operation status " + "metadata", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt); OperationManagementDAOUtil.cleanupResources(stmt);
} }
@ -310,6 +310,82 @@ public class GenericOperationDAOImpl implements OperationDAO {
@Override @Override
public Activity getActivity(int operationId) throws OperationManagementDAOException { public Activity getActivity(int operationId) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
Activity activity = null;
List<ActivityStatus> activityStatusList = new ArrayList<>();
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.ID AS EOM_MAPPING_ID, dor.ID AS OP_RES_ID,\n" +
"de.DEVICE_ID, d.DEVICE_IDENTIFICATION, \n" +
"d.DEVICE_TYPE_ID, dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, \n" +
"eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, dor.OPERATION_RESPONSE, \n" +
"dor.RECEIVED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING eom \n" +
"INNER JOIN DM_OPERATION op ON op.ID=eom.OPERATION_ID\n" +
"INNER JOIN DM_ENROLMENT de ON de.ID=eom.ENROLMENT_ID\n" +
"INNER JOIN DM_DEVICE d ON d.ID=de.DEVICE_ID \n" +
"INNER JOIN DM_DEVICE_TYPE dt ON dt.ID=d.DEVICE_TYPE_ID\n" +
"LEFT JOIN DM_DEVICE_OPERATION_RESPONSE dor ON dor.ENROLMENT_ID=de.id \n" +
"AND dor.OPERATION_ID = eom.OPERATION_ID\n" +
"WHERE eom.OPERATION_ID = ? AND de.TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, operationId);
stmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
rs = stmt.executeQuery();
int enrolmentId = 0;
ActivityStatus activityStatus = null;
while (rs.next()) {
if (enrolmentId == 0) {
activity = new Activity();
activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE")));
activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString());
activity.setCode(rs.getString("OPERATION_CODE"));
}
if (enrolmentId != rs.getInt("ENROLMENT_ID")) {
activityStatus = new ActivityStatus();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE_NAME"));
activityStatus.setDeviceIdentifier(deviceIdentifier);
activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS")));
List<OperationResponse> operationResponses = new ArrayList<>();
if (rs.getInt("UPDATED_TIMESTAMP") != 0) {
activityStatus.setUpdatedTimestamp(new java.util.Date(rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString());
operationResponses.add(OperationDAOUtil.getOperationResponse(rs));
}
activityStatus.setResponses(operationResponses);
activityStatusList.add(activityStatus);
enrolmentId = rs.getInt("ENROLMENT_ID");
activity.setActivityStatus(activityStatusList);
} else {
if (rs.getInt("UPDATED_TIMESTAMP") != 0) {
activityStatus.getResponses().add(OperationDAOUtil.getOperationResponse(rs));
}
}
}
} catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while getting the operation details from " +
"the database.", e);
} catch (ClassNotFoundException e) {
throw new OperationManagementDAOException("Error occurred while converting the operation response to string.", e);
} catch (IOException e) {
throw new OperationManagementDAOException("IO exception occurred while converting the operations responses.", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
}
return activity;
}
public Activity getActivityByDevice(int operationId, int deviceId) throws OperationManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Activity activity = null; Activity activity = null;
@ -327,11 +403,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
"INNER JOIN DM_DEVICE_TYPE AS dt ON dt.ID=d.DEVICE_TYPE_ID\n" + "INNER JOIN DM_DEVICE_TYPE AS dt ON dt.ID=d.DEVICE_TYPE_ID\n" +
"LEFT JOIN DM_DEVICE_OPERATION_RESPONSE AS dor ON dor.ENROLMENT_ID=de.id \n" + "LEFT JOIN DM_DEVICE_OPERATION_RESPONSE AS dor ON dor.ENROLMENT_ID=de.id \n" +
"AND dor.OPERATION_ID = eom.OPERATION_ID\n" + "AND dor.OPERATION_ID = eom.OPERATION_ID\n" +
"WHERE eom.OPERATION_ID = ? AND de.TENANT_ID = ?"; "WHERE eom.OPERATION_ID = ? AND de.device_id = ? AND de.TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, operationId); stmt.setInt(1, operationId);
stmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); stmt.setInt(2, deviceId);
stmt.setInt(3, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
rs = stmt.executeQuery(); rs = stmt.executeQuery();
int enrolmentId = 0; int enrolmentId = 0;
@ -548,9 +625,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
ResultSet rs = null; ResultSet rs = null;
try { try {
Connection conn = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT COUNT(*) AS COUNT FROM DM_ENROLMENT_OP_MAPPING AS m \n" + String sql = "SELECT COUNT(*) AS COUNT FROM DM_ENROLMENT_OP_MAPPING m \n"
"INNER JOIN DM_ENROLMENT AS d ON m.ENROLMENT_ID = d.ID \n" + + "INNER JOIN DM_ENROLMENT d ON m.ENROLMENT_ID = d.ID \n"
"WHERE m.UPDATED_TIMESTAMP > ? AND d.TENANT_ID = ?;"; + "WHERE m.UPDATED_TIMESTAMP > ? AND d.TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setLong(1, timestamp); stmt.setLong(1, timestamp);
stmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); stmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
@ -559,8 +636,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
return rs.getInt("COUNT"); return rs.getInt("COUNT");
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while getting the activity count from " + throw new OperationManagementDAOException(
"the database.", e); "Error occurred while getting the activity count from " + "the database.", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs); OperationManagementDAOUtil.cleanupResources(stmt, rs);
} }

@ -148,7 +148,7 @@ public class OperationMappingDAOImpl implements OperationMappingDAO {
//devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states. //devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states.
String sql = "SELECT ENROLMENT_ID, D.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFIER, MIN(CREATED_TIMESTAMP) " + String sql = "SELECT ENROLMENT_ID, D.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFIER, MIN(CREATED_TIMESTAMP) " +
"AS CREATED_TIMESTAMP, E.STATUS AS ENROLMENT_STATUS, E.TENANT_ID FROM " + "AS CREATED_TIMESTAMP, E.STATUS AS ENROLMENT_STATUS, E.TENANT_ID FROM " +
"DM_ENROLMENT_OP_MAPPING AS OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " + "DM_ENROLMENT_OP_MAPPING OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " +
"DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " + "DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " +
"OP.STATUS IN ('"+ Operation.Status.PENDING.name() + "','" + Operation.Status.REPEATED.name() + "') " + "OP.STATUS IN ('"+ Operation.Status.PENDING.name() + "','" + Operation.Status.REPEATED.name() + "') " +
"AND OP.CREATED_TIMESTAMP BETWEEN ? AND ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() + "AND OP.CREATED_TIMESTAMP BETWEEN ? AND ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() +
@ -183,7 +183,7 @@ public class OperationMappingDAOImpl implements OperationMappingDAO {
//We are specifically looking for operation mappings in 'Pending' & 'Repeated' states. Further we want //We are specifically looking for operation mappings in 'Pending' & 'Repeated' states. Further we want
//devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states. //devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states.
String sql = "SELECT OP.ENROLMENT_ID AS EID, MAX(OP.UPDATED_TIMESTAMP) AS LAST_CONNECTED_TIME FROM " + String sql = "SELECT OP.ENROLMENT_ID AS EID, MAX(OP.UPDATED_TIMESTAMP) AS LAST_CONNECTED_TIME FROM " +
"DM_ENROLMENT_OP_MAPPING AS OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " + "DM_ENROLMENT_OP_MAPPING OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " +
"DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " + "DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " +
"OP.STATUS = '" + Operation.Status.COMPLETED.name() + "'" + "OP.STATUS = '" + Operation.Status.COMPLETED.name() + "'" +
"AND OP.UPDATED_TIMESTAMP >= ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() + "AND OP.UPDATED_TIMESTAMP >= ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() +

@ -138,77 +138,47 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
} }
@Override @Override
public void updateEnrollmentOperationsStatus(int enrolmentId, String operationCode, public Map<Integer, List<OperationMapping>> getOperationMappingsByStatus(Operation.Status opStatus, Operation.PushNotificationStatus pushNotificationStatus,
Operation.Status existingStatus, Operation.Status newStatus) throws OperationManagementDAOException { int limit) throws OperationManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
OperationMapping operationMapping;
Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>();
try { try {
Connection connection = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM " String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, d.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE, d" +
+ "ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? " ".TENANT_ID FROM DM_DEVICE d, DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? " +
+ "AND EOM.STATUS = ?"; "AND op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID AND " +
stmt = connection.prepareStatement(query); "ROWNUM <= ? ORDER BY op.OPERATION_ID";
stmt.setInt(1, enrolmentId);
stmt.setString(2, operationCode);
stmt.setString(3, existingStatus.toString());
// This will return only one result always.
rs = stmt.executeQuery();
int id = 0;
while (rs.next()) {
id = rs.getInt("ID");
}
if (id != 0) {
stmt = connection.prepareStatement(
"UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS = ?, " + "UPDATED_TIMESTAMP = ? WHERE ID = ?");
stmt.setString(1, newStatus.toString());
stmt.setLong(2, System.currentTimeMillis() / 1000);
stmt.setInt(3, id);
stmt.executeUpdate();
}
} catch (SQLException e) {
throw new OperationManagementDAOException(
"Error occurred while update device mapping operation status " + "metadata", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
}
}
@Override stmt = conn.prepareStatement(sql);
public boolean updateTaskOperation(int enrolmentId, String operationCode) throws OperationManagementDAOException { stmt.setString(1, opStatus.toString());
PreparedStatement stmt = null; stmt.setString(2, pushNotificationStatus.toString());
ResultSet rs = null; stmt.setInt(3, limit);
boolean result = false;
try {
Connection connection = OperationManagementDAOFactory.getConnection();
String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM "
+ "ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? AND "
+ "EOM.STATUS = ?";
stmt = connection.prepareStatement(query);
stmt.setInt(1, enrolmentId);
stmt.setString(2, operationCode);
stmt.setString(3, Operation.Status.PENDING.toString());
// This will return only one result always.
rs = stmt.executeQuery(); rs = stmt.executeQuery();
int id = 0; while (rs.next()) {
if (rs.next()) { int tenantID = rs.getInt("TENANT_ID");
id = rs.getInt("ID"); List<OperationMapping> operationMappings = operationMappingsTenantMap.get(tenantID);
} if (operationMappings == null) {
if (id != 0) { operationMappings = new LinkedList<>();
stmt = connection.prepareStatement( operationMappingsTenantMap.put(tenantID, operationMappings);
"UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + "WHERE ID = ?"); }
stmt.setLong(1, System.currentTimeMillis() / 1000); operationMapping = new OperationMapping();
stmt.setInt(2, id); operationMapping.setOperationId(rs.getInt("OPERATION_ID"));
stmt.executeUpdate(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
result = true; deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
operationMapping.setDeviceIdentifier(deviceIdentifier);
operationMapping.setEnrollmentId(rs.getInt("ENROLMENT_ID"));
operationMapping.setTenantId(tenantID);
operationMappings.add(operationMapping);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException( throw new OperationManagementDAOException("SQL error while getting operation mappings from database. ", e);
"Error occurred while update device mapping operation status " + "metadata", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt); OperationManagementDAOUtil.cleanupResources(stmt, rs);
} }
return result; return operationMappingsTenantMap;
} }
@Override @Override
@ -340,74 +310,4 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
} }
return activities; return activities;
} }
@Override
public int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT COUNT(*) COUNT FROM DM_ENROLMENT_OP_MAPPING m \n"
+ "INNER JOIN DM_ENROLMENT d ON m.ENROLMENT_ID = d.ID \n"
+ "WHERE m.UPDATED_TIMESTAMP > ? AND d.TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setLong(1, timestamp);
stmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
rs = stmt.executeQuery();
if (rs.next()) {
return rs.getInt("COUNT");
}
} catch (SQLException e) {
throw new OperationManagementDAOException(
"Error occurred while getting the activity count from " + "the database.", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
}
return 0;
}
@Override
public Map<Integer, List<OperationMapping>> getOperationMappingsByStatus(Operation.Status opStatus, Operation.PushNotificationStatus pushNotificationStatus,
int limit) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
OperationMapping operationMapping;
Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>();
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, d.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE, d" +
".TENANT_ID FROM DM_DEVICE d, DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? " +
"AND op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID AND " +
"ROWNUM <= ? ORDER BY op.OPERATION_ID";
stmt = conn.prepareStatement(sql);
stmt.setString(1, opStatus.toString());
stmt.setString(2, pushNotificationStatus.toString());
stmt.setInt(3, limit);
rs = stmt.executeQuery();
while (rs.next()) {
int tenantID = rs.getInt("TENANT_ID");
List<OperationMapping> operationMappings = operationMappingsTenantMap.get(tenantID);
if (operationMappings == null) {
operationMappings = new LinkedList<>();
operationMappingsTenantMap.put(tenantID, operationMappings);
}
operationMapping = new OperationMapping();
operationMapping.setOperationId(rs.getInt("OPERATION_ID"));
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
operationMapping.setDeviceIdentifier(deviceIdentifier);
operationMapping.setEnrollmentId(rs.getInt("ENROLMENT_ID"));
operationMapping.setTenantId(tenantID);
operationMappings.add(operationMapping);
}
} catch (SQLException e) {
throw new OperationManagementDAOException("SQL error while getting operation mappings from database. ", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
}
return operationMappingsTenantMap;
}
} }

@ -116,6 +116,11 @@ public class PushNotificationBasedOperationManager implements OperationManager {
return this.operationManager.getOperationByActivityId(activity); return this.operationManager.getOperationByActivityId(activity);
} }
@Override
public Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException {
return this.operationManager.getOperationByActivityIdAndDevice(activity, deviceId);
}
@Override @Override
public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException { public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException {
return this.operationManager.getOperationUpdatedAfter(timestamp); return this.operationManager.getOperationUpdatedAfter(timestamp);

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
@ -62,7 +63,7 @@ public class ProcessorImpl implements Processor {
@Override @Override
public List<Device> execute(SearchContext searchContext) throws SearchMgtException { public List<Device> execute(SearchContext searchContext) throws SearchMgtException {
if(!Utils.validateOperators(searchContext.getConditions())){ if (!Utils.validateOperators(searchContext.getConditions())) {
throw new SearchMgtException("Invalid validator is provided."); throw new SearchMgtException("Invalid validator is provided.");
} }
@ -268,10 +269,10 @@ public class ProcessorImpl implements Processor {
} else if (type.getColumnType().equals(ValueType.columnType.INTEGER)) { } else if (type.getColumnType().equals(ValueType.columnType.INTEGER)) {
stmt.setInt(x, type.getIntValue()); stmt.setInt(x, type.getIntValue());
x++; x++;
} else if (type.getColumnType().equals(ValueType.columnType.LONG)){ } else if (type.getColumnType().equals(ValueType.columnType.LONG)) {
stmt.setLong(x, type.getLongValue()); stmt.setLong(x, type.getLongValue());
x++; x++;
} else if(type.getColumnType().equals(ValueType.columnType.DOUBLE)){ } else if (type.getColumnType().equals(ValueType.columnType.DOUBLE)) {
stmt.setDouble(x, type.getDoubleValue()); stmt.setDouble(x, type.getDoubleValue());
x++; x++;
} }
@ -360,8 +361,10 @@ public class ProcessorImpl implements Processor {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN ("; String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (";
if (conn.getMetaData().getDatabaseProductName().contains("H2") || conn.getMetaData() if (conn.getMetaData().getDatabaseProductName().contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2) || conn.getMetaData()
.getDatabaseProductName().contains("MySQL")) { .getDatabaseProductName().contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL) ||
conn.getMetaData().getDatabaseProductName().contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE) ||
conn.getMetaData().getDatabaseProductName().contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL)) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = 0; i < devices.size(); i++) { for (int i = 0; i < devices.size(); i++) {
builder.append("?,"); builder.append("?,");

@ -119,7 +119,6 @@ public class QueryBuilderImpl implements QueryBuilder {
log.debug("Property with OR Query : " + queries.get(Constants.PROP_OR)); log.debug("Property with OR Query : " + queries.get(Constants.PROP_OR));
log.debug("Location related Query : " + queries.get(Constants.LOCATION)); log.debug("Location related Query : " + queries.get(Constants.LOCATION));
} }
return queries; return queries;
} }
@ -342,10 +341,10 @@ public class QueryBuilderImpl implements QueryBuilder {
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" + "DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" + "DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DE.OWNER, DE.OWNERSHIP, DE.STATUS " + "DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DE.OWNER, DE.OWNERSHIP, DE.STATUS " +
"AS DE_STATUS FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" + "AS DE_STATUS FROM DM_DEVICE_DETAIL DD INNER JOIN DM_DEVICE D ON D.ID=DD.DEVICE_ID\n" +
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" + "LEFT JOIN DM_DEVICE_LOCATION DL ON DL.DEVICE_ID=D.ID \n" +
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" + "INNER JOIN DM_DEVICE_TYPE DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
"INNER JOIN DM_ENROLMENT AS DE ON D.ID=DE.DEVICE_ID\n" + "INNER JOIN DM_ENROLMENT DE ON D.ID=DE.DEVICE_ID\n" +
"WHERE D.TENANT_ID = ? "; "WHERE D.TENANT_ID = ? ";
ValueType type = new ValueType(); ValueType type = new ValueType();
@ -370,11 +369,11 @@ public class QueryBuilderImpl implements QueryBuilder {
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" + "DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DI.KEY_FIELD, DI.VALUE_FIELD, \n" + "DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DI.KEY_FIELD, DI.VALUE_FIELD, \n" +
"DE.OWNER, DE.OWNERSHIP, DE.STATUS AS DE_STATUS " + "DE.OWNER, DE.OWNERSHIP, DE.STATUS AS DE_STATUS " +
"FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" + "FROM DM_DEVICE_DETAIL DD INNER JOIN DM_DEVICE D ON D.ID=DD.DEVICE_ID\n" +
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" + "LEFT JOIN DM_DEVICE_LOCATION DL ON DL.DEVICE_ID=D.ID \n" +
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" + "INNER JOIN DM_DEVICE_TYPE DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
"INNER JOIN DM_ENROLMENT AS DE ON D.ID=DE.DEVICE_ID\n" + "INNER JOIN DM_ENROLMENT DE ON D.ID=DE.DEVICE_ID\n" +
"LEFT JOIN DM_DEVICE_INFO AS DI ON DI.DEVICE_ID=D.ID\n" + "LEFT JOIN DM_DEVICE_INFO DI ON DI.DEVICE_ID=D.ID\n" +
"WHERE D.TENANT_ID = ? "; "WHERE D.TENANT_ID = ? ";
ValueType type = new ValueType(); ValueType type = new ValueType();

@ -532,6 +532,8 @@ public interface DeviceManagementProviderService {
Activity getOperationByActivityId(String activity) throws OperationManagementException; Activity getOperationByActivityId(String activity) throws OperationManagementException;
Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException;
List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException; List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException;
List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementException; List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementException;

@ -1008,6 +1008,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByActivityId(activity); return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByActivityId(activity);
} }
public Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException {
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByActivityIdAndDevice(activity, deviceId);
}
@Override @Override
public List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException { public List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException {
return DeviceManagementDataHolder.getInstance().getOperationManager().getActivitiesUpdatedAfter(timestamp); return DeviceManagementDataHolder.getInstance().getOperationManager().getActivitiesUpdatedAfter(timestamp);

@ -432,12 +432,15 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<Device> devices; List<Device> devices;
try { try {
rowCount = DeviceManagerUtil.validateDeviceListPageSize(rowCount);
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
devices = this.groupDAO.getDevices(groupId, startIndex, rowCount, tenantId); devices = this.groupDAO.getDevices(groupId, startIndex, rowCount, tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while getting devices in group.", e); throw new GroupManagementException("Error occurred while getting devices in group.", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); throw new GroupManagementException("Error occurred while opening a connection to the data source.", e);
} catch (DeviceManagementException e) {
throw new GroupManagementException("Error occurred while validating the limit of the devices to be returned", e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -1,5 +1,5 @@
{ {
"appName": "WSO2 Device Cloud", "appName": "WSO2 IoT Server",
"cachingEnabled": false, "cachingEnabled": false,
"debuggingEnabled": false, "debuggingEnabled": false,
"permissionRoot": "/", "permissionRoot": "/",

@ -38,17 +38,17 @@ deviceModule = function () {
privateMethods.callBackend = function (url, method) { privateMethods.callBackend = function (url, method) {
if (constants["HTTP_GET"] == method) { if (constants["HTTP_GET"] == method) {
return serviceInvokers.XMLHttp.get(url, return serviceInvokers.XMLHttp.get(url,
function (backendResponse) { function (backendResponse) {
var response = {}; var response = {};
response.content = backendResponse.responseText; response.content = backendResponse.responseText;
if (backendResponse.status == 200) { if (backendResponse.status == 200) {
response.status = "success"; response.status = "success";
} else if (backendResponse.status == 400 || backendResponse.status == 401 || } else if (backendResponse.status == 400 || backendResponse.status == 401 ||
backendResponse.status == 404 || backendResponse.status == 500) { backendResponse.status == 404 || backendResponse.status == 500) {
response.status = "error"; response.status = "error";
} }
return response; return response;
} }
); );
} else { } else {
log.error("Runtime error : This method only support HTTP GET requests."); log.error("Runtime error : This method only support HTTP GET requests.");
@ -282,7 +282,10 @@ deviceModule = function () {
publicMethods.getDevices = function (userName) { publicMethods.getDevices = function (userName) {
var url = devicemgtProps["httpsURL"] + var url = devicemgtProps["httpsURL"] +
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices"; devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices";
if (userName && userName !== "") {
url = url + "?user=" + userName;
}
return serviceInvokers.XMLHttp.get( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url, function (responsePayload) {
var devices = JSON.parse(responsePayload.responseText).devices; var devices = JSON.parse(responsePayload.responseText).devices;

@ -115,7 +115,6 @@ var userModule = function () {
var url = carbon.server.address('https') + "/admin/services"; var url = carbon.server.address('https') + "/admin/services";
var server = new carbon.server.Server(url); var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId); var userManager = new carbon.user.UserManager(server, tenantId);
try { try {
if (userManager.userExists(username)) { if (userManager.userExists(username)) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -632,11 +631,17 @@ var userModule = function () {
var url = carbon.server.address('https') + "/admin/services"; var url = carbon.server.address('https') + "/admin/services";
var server = new carbon.server.Server(url); var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId); var userManager = new carbon.user.UserManager(server, tenantId);
try { try {
if (!userManager.roleExists(roleName)) { if (!userManager.roleExists(roleName)) {
userManager.addRole(roleName, users, permissions); userManager.addRole(roleName, users, permissions);
} else { } else {
log.info("Role exist with name: " + roleName); var array = Object.keys(permissions);
var i, permission;
for (i = 0; i < array.length; i++) {
permission = array[i];
userManager.authorizeRole(roleName, permission, "ui.execute");
}
} }
} catch (e) { } catch (e) {
throw e; throw e;

@ -397,8 +397,8 @@ var utils = function () {
publicMethods["getUniqueBrowserScope"] = function () { publicMethods["getUniqueBrowserScope"] = function () {
var deviceScope = "device_" + utility.md5(request.getHeader("User-Agent") + "::" + request.getRemoteAddr()); var deviceScope = "device_" + utility.md5(request.getHeader("User-Agent") + "::" + request.getRemoteAddr());
deviceScope = deviceScope + " "; deviceScope = deviceScope + " ";
log.error("device scope"); log.debug("device scope");
log.error(deviceScope); log.debug(deviceScope);
return deviceScope; return deviceScope;
}; };

@ -313,7 +313,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="row"> <div class="row">
<div class="col-md-3 col-centered"> <div class="col-md-3 col-centered">
<h3>Device associations updated.</h3> <h3>Successfully added the device/s to the group!</h3>
</div> </div>
</div> </div>
</div> </div>
@ -374,7 +374,7 @@
<div id="edit-device-modal-content" class="hide"> <div id="edit-device-modal-content" class="hide">
<div class="modal-header"> <div class="modal-header">
<h3 class="pull-left modal-title"> <h3 class="pull-left modal-title">
Please enter new name for the device? Please enter a new name for the device.
</h3> </h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i> class="fw fw-cancel"></i>

@ -155,7 +155,7 @@ function loadDevices(searchType, searchParam) {
serviceURL = "/api/device-mgt/v1.0/devices"; serviceURL = "/api/device-mgt/v1.0/devices";
} else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) { } else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) {
//Get authenticated users devices //Get authenticated users devices
serviceURL = "/api/device-mgt/v1.0/devices?username=" + currentUser; serviceURL = "/api/device-mgt/v1.0/devices?user=" + currentUser;
} else { } else {
$("#loading-content").remove(); $("#loading-content").remove();
$('#device-table').addClass('hidden'); $('#device-table').addClass('hidden');
@ -282,7 +282,7 @@ function loadDevices(searchType, searchParam) {
}, },
{ {
targets: 2, targets: 2,
data: 'user', data: 'userPattern',
class: 'remove-padding-top viewEnabledIcon' class: 'remove-padding-top viewEnabledIcon'
}, },
{ {
@ -410,7 +410,7 @@ function loadDevices(searchType, searchParam) {
$(row).attr('data-url', context + '/device/' + htmlspecialchars(data.deviceType) + '?id=' + htmlspecialchars(data.deviceIdentifier)); $(row).attr('data-url', context + '/device/' + htmlspecialchars(data.deviceType) + '?id=' + htmlspecialchars(data.deviceIdentifier));
var model = htmlspecialchars(getPropertyValue(data.properties, 'DEVICE_MODEL')); var model = htmlspecialchars(getPropertyValue(data.properties, 'DEVICE_MODEL'));
var vendor = htmlspecialchars(getPropertyValue(data.properties, 'VENDOR')); var vendor = htmlspecialchars(getPropertyValue(data.properties, 'VENDOR'));
var owner = htmlspecialchars(data.user); var owner = htmlspecialchars(data.userPattern);
var status = htmlspecialchars(data.status); var status = htmlspecialchars(data.status);
var ownership = htmlspecialchars(data.ownership); var ownership = htmlspecialchars(data.ownership);
var deviceType = htmlspecialchars(data.deviceType); var deviceType = htmlspecialchars(data.deviceType);
@ -460,7 +460,7 @@ function loadDevices(searchType, searchParam) {
{ {
model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"),
vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), vendor: getPropertyValue(data.devices[index].properties, "VENDOR"),
user: data.devices[index].enrolmentInfo.owner, userPattern: data.devices[index].enrolmentInfo.owner,
status: data.devices[index].enrolmentInfo.status, status: data.devices[index].enrolmentInfo.status,
ownership: data.devices[index].enrolmentInfo.ownership, ownership: data.devices[index].enrolmentInfo.ownership,
deviceType: data.devices[index].type, deviceType: data.devices[index].type,

@ -134,8 +134,8 @@ function resetPassword(username) {
$("a#reset-password-yes-link").click(function () { $("a#reset-password-yes-link").click(function () {
var newPassword = $("#basic-modal-view .new-password").val(); var newPassword = $("#basic-modal-view .new-password").val();
var confirmedPassword = $("#basic-modal-view .confirmed-password").val(); var confirmedPassword = $("#basic-modal-view .confirmed-password").val();
var errorMsgWrapper = "#notification-error-msg"; var errorMsgWrapper = ".modal #notification-error-msg";
var errorMsg = "#notification-error-msg span"; var errorMsg = ".modal #notification-error-msg span";
if (!newPassword) { if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty."); $(errorMsg).text("New password is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");

@ -186,7 +186,7 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter
$(filterColumn.eq(column.index()).empty()).html('<input type="text" class="form-control" placeholder="Search ' + title + '" />'); $(filterColumn.eq(column.index()).empty()).html('<input type="text" class="form-control" placeholder="Search ' + title + '" />');
//noinspection SpellCheckingInspection //noinspection SpellCheckingInspection
filterColumn.eq(column.index()).find('input').on('keyup change', function () { filterColumn.eq(column.index()).find('input').on('keyup', function () {
column.search($(this).val()).draw(); column.search($(this).val()).draw();
}); });
} }

@ -0,0 +1,345 @@
.operation-icon{
width: 88px;
height: 100px;
background-color: #ebebeb;
float: left;
margin: 0px 10px 10px 0px;
cursor: pointer;
position: relative;
}
.operation-icon i{
padding: 15px 0px 0px 0px;
display: block;
min-height: 65px;
font-size: 3em !important;
margin: 0px !important;
}
.operation-icon span{
height: 35px;
line-height: 15px;
vertical-align: middle;
display: table-cell;
width: inherit;
}
.application{
width: 250px;
height: 100px;
background-color: #ebebeb;
float: left;
margin: 0px 10px 10px 0px;
}
.application img{
height: inherit;
padding: 10px;
float: left;
}
.app-info h4{
margin-bottom: 0px;
}
.application i{
float: right;
margin: 0px 10px;
position: relative;
bottom: -20px;
cursor: pointer;
}
.nav-tabs>li>a{
color: #333;
}
.nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover{
border-bottom: 2px solid #37474f;
border-right: none;
border-top: none;
border-left: none;
font-weight: 400;
}
.nav-tabs-selector{
margin: 0px;
border: 1px solid #37474f;
}
.tab-pane{
padding: 20px 0px;
}
#location{
height: calc(100vh - 400px);
}
.page-loader{
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: calc(100vh - 160px);
z-index: 9999;
background: url(images/page-loader.gif) 50% 50% no-repeat rgb(249,249,249);
}
.page-loader .loader{
left: 43%;
position: absolute;
bottom: 50%;
width: 13%;
}
.page-loader .loader span{
padding: 9px;
position: absolute;
font-size: 18px;
}
.device-info-container{
margin-bottom: 40px;
}
.device-type{
font-size: 9em;
}
.device-info h1, .device-info h4:not(:last-child){
margin: 0px 0px 9px 0px;
position: relative;
}
.device-id a{
font-size: 0.4em;
position: absolute;
margin: 0px 5px;
}
.device-info h4:last-child{
margin: 0px;
}
.tab-actions{
position: relative;
}
.tab-actions .action-btn{
padding: 10px 15px;
background-color: #ebebeb;
float: right;
cursor: pointer;
position: relative;
margin-left: 10px;
ma
}
.tab-actions .action{
float: right;
margin-left: 10px;
}
.tab-actions .action-btn.show a{
margin: 0 0 10px;
}
.tab-actions .action-btn a{
margin: 0px;
}
.tab-actions {
margin: 0px;
}
.tab-actions .action-prop{
padding: 10px;
background: #ebebeb;
width: 100%;
margin-bottom: 10px;
}
.tab-action-active{
padding-bottom: 15px !important;
}
.action-btn-container:after{
content: '';
display: block;
clear:both;
}
.input-group .fw{
position: absolute;
top: 10px;
right: 10px;
z-index: 100;
}
.vital-strip{
display: flex;
flex-direction: row;
background-color: #ebebeb;
padding: 10px;
margin-bottom: 40px;
}
.vital-strip p{
flex-grow: 1;
margin: 0px;
display: inline-flex;
}
.vital-strip p i{
margin: 0px 10px;
}
.vital-strip p span{
padding: 5px 0px;
}
.memory-amt{
font-size: 0.8em;
position: relative;
bottom: -3px;
padding-left: 2px !important;
}
.policy-item{
display: flex;
flex-direction: row;
padding: 10px;
background-color: #ebebeb;
}
.policy-item .policy-status, .policy-item p{
flex-grow: 1;
}
.policy-item .policy-status{
flex-grow: 1;
flex-basis: 0;
margin-right: 10px;
align-self: center;
color: #5cb85c;
}
.policy-name{
font-size: 1.5em;
display: flex;
}
.policy-platform{
display: flex;
}
.policy-item p:nth-child(2){
margin: 0px;
}
.policy-item p:nth-child(3){
flex-grow: 7;
align-self: center;
margin: 0px;
}
.policy-item p:nth-child(3) span{
display: flex;
}
.policy-item .actions{
flex-grow: 1;
display: flex;
}
.policy-item .action-btn{
flex-grow: 1;
margin: 3px 5px;
background-color: #ccc;
display: flex;
cursor: pointer;
position: relative;
}
.policy-item .action-btn p{
align-self: center;
margin: 0px;
display: flex;
justify-content: center;
}
.policy-item .action-btn p i{
padding: 0px 5px;
}
.policy-item .action-btn span{
align-self: center;
}
#operation-log tr td{
border-bottom: 15px solid #fff !important;
}
#operation-log tr.shown td{
border-bottom: none !important;
}
.log-data-row td{
padding: 0px !important;
border-bottom: 15px solid #fff !important;
}
.log-data{
background-color: #f6f6f6;
padding: 0px 20px;
}
.log-data:after{
content: '';
width: 0;
height: 100%;
position: absolute;
border: 1px solid #ced8db;
top: 0;
left: 50px;
}
.log-record-status{
background-color: #4c4c4c !important;
color: #fff;
cursor: pointer;
user-select: none;
}
.log-record-status i:first-child{
float: left;
line-height: 19px;
padding: 0px 10px 0px 0px;
}
.log-record-status span{
float: left;
line-height: 17px;
}
.log-status{
padding-left: 14px;
z-index: 10;
position: relative;
}
.log-status i{
margin: 0px 10px;
background-color: #f6f6f6;
border-radius: 20px;
}
.log-entry{
padding: 15px 0px;
}
.log-entry:not(:first-child){
padding-top: 0px;
}
/*
* custom css fixes
*/
.page-content-wrapper, .page-content-wrapper[data-container-behaviour=static]{
min-height: calc(100vh - 123px);
}
.content{
/*opacity: 0;*/
}
.content-wrapper{
position: relative;
}
.dataTablesTop{
display: none;
}
.table.list-table:not(.grid-view)>tbody>tr>td, .table.list-table:not(.grid-view)>tbody>tr>th{
background-color: #eaeaea;
}
.table.table-hover>tbody>tr:hover td:not(.dataTables_empty){
background-color: inherit !important;
}
.table-hover>tbody>tr:hover,{
background-color:
}
.table.list-table>tbody>tr:nth-of-type(even), .table.list-table>tbody>tr:nth-of-type(odd){
background-color: #eaeaea;
}
.table.table-hover>tbody>tr:hover td:not(.dataTables_empty){
background-color: inherit !important;
}
.table.table-hover>tbody>tr:hover td.log-record-status{
background-color: #4c4c4c !important;
}
.tab-content{
border:none;
}

@ -16,195 +16,322 @@
* under the License. * under the License.
*/ */
var deviceId = $(".device-id"); var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid"); var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
var deviceOwner = deviceId.data("owner"); var deviceOwner = deviceId.data("owner");
$(document).ready(function () { $(document).ready(function() {
$(".panel-body").removeClass("hidden"); $(".panel-body").removeClass("hidden");
$("#loading-content").remove(); $("#loading-content").remove();
if ($('#event_log').length) { if ($('#event_log').length) {
loadOperationsLog(); loadOperationsLog();
} }
if ($('#policy_compliance').length) {
loadPolicyCompliance();
}
if ($('#policy_compliance').length) {
loadPolicyCompliance();
}
$("#refresh-policy").click(function () {
$('#policy-spinner').removeClass('hidden');
loadPolicyCompliance();
});
$("#refresh-operations").click(function () { $("#refresh-policy").click(function() {
$('#operations-spinner').removeClass('hidden'); $('#policy-spinner').removeClass('hidden');
loadOperationsLog(true); loadPolicyCompliance();
}); });
$("#refresh-operations").click(function() {
$('#operations-spinner').removeClass('hidden');
loadOperationsLog(true);
}); });
function loadOperationsLog(update) { });
var operationsLogTable = "#operations-log-table";
if (update) { function loadOperationsLog() {
operationTable = $(operationsLogTable).DataTable(); var table = $('#operation-log').DataTable({
$("#operations-spinner").removeClass("hidden"); serverSide: true,
operationTable.ajax.reload(function ( json ) { processing: false,
searching: false,
ordering: false,
pageLength: 10,
order: [],
autoWidth: false,
ajax: {
url: "/devicemgt/api/operation/paginate",
data: {
deviceId: deviceIdentifier,
deviceType: deviceType,
owner: deviceOwner
},
dataSrc: function(json) {
$("#operations-spinner").addClass("hidden"); $("#operations-spinner").addClass("hidden");
}, false); $("#operations-log-container").empty();
return; return json.data;
} }
operationTable = $(operationsLogTable).datatables_extended({ },
serverSide: true, columnDefs: [{
processing: false, targets: 0,
searching: false, data: "code",
ordering: false, class: "icon-only content-fill"
pageLength : 10, },
order: [], {
ajax: { targets: 1,
data: "createdTimeStamp",
url: "/devicemgt/api/operation/paginate", class: "text-right",
data: {deviceId : deviceIdentifier, deviceType: deviceType, owner: deviceOwner}, render: function(date) {
dataSrc: function (json) { var value = String(date);
$("#operations-spinner").addClass("hidden"); return value.slice(0, 16);
$("#operations-log-container").empty();
return json.data;
} }
}, },
columnDefs: [ {
{targets: 0, data: "code" }, targets: 2,
{targets: 1, data: "status", render: data: "status",
function (status) { class: "text-right extended-log-data log-record-status",
var html; render: function(data, type, full, meta) {
switch (status) { return '<i class="icon fw fw-success"></i><span> ' + data + ' </span><i class="icon fw fw-down"></i>';
case "COMPLETED" :
html = "<span><i class='fw fw-success icon-success'></i> Completed</span>";
break;
case "PENDING" :
html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break;
case "ERROR" :
html = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
break;
case "IN_PROGRESS" :
html = "<span><i class='fw fw-success icon-warning'></i> In Progress</span>";
break;
case "REPEATED" :
html = "<span><i class='fw fw-success icon-warning'></i> Repeated</span>";
break;
}
return html;
}
}, },
{targets: 2, data: "createdTimeStamp", render: width: "100%"
function (date) { }
var value = String(date); ],
return value.slice(0, 16); fnCreatedRow: function(nRow, aData, iDataIndex) {
$('td:eq(0)', nRow)
.attr('data-search', aData.Device_Type)
.attr('data-display', aData.Device_Type)
.addClass(' icon-only content-fill');
$('td:eq(1), td:eq(2)', nRow).addClass('text-right');
$('td:eq(2)', nRow).addClass('log-record-status')
}
});
$('#operation-log tbody').on('click', 'td.extended-log-data', function() {
var tr = $(this).closest('tr');
var row = table.row(tr);
var rowData = row.data()
var deviceid = $('.device-id').data('deviceid');
var deviceType = $('.device-id').data('type');
var uri = "/api/device-mgt/v1.0/activities/" + rowData.activityId + "/" + deviceType + "/" + deviceid;
var contentType = "application/json";
if (row.child.isShown()) {
row.child.hide();
$(row.child()).removeClass('log-data-row');
tr.removeClass('shown');
} else {
invokerUtil.get(uri,(payload) => {
row.child(renderLogDetails(row.data(),payload)).show();
$(row.child()).addClass('log-data-row');
tr.addClass('shown');
},(error) => {
},contentType);
}
});
function renderLogDetails(obj,data) {
var payload = JSON.parse(data);
var logStream = '<div class="log-data">';
Object.entries(payload.activityStatus).forEach(
([key, entry]) => {
logStream += '<div class="row log-entry">' +
'<div class="col-lg-8">' +
'<div class="log-status"><i class="icon fw ' + getLogStatusIcon(entry.status) + ' "></i>' +
'<span>' + entry.status + '</span></div>' +
'</div>' +
'<div class="col-lg-4">' +
'<div class="log-time text-right"><span>' + entry.updatedTimestamp + '</span></div>' +
'</div>' +
'</div>';
}
);
logStream += '</div></div>';
return logStream;
function getLogStatusIcon(entry) {
switch (entry) {
case 'COMPLETED':
return 'fw-success'
break;
case 'PENDING':
return 'fw-pending'
break;
default:
return 'fw-info'
}
}
}
}
function loadOperationsLog2(update) {
var operationsLogTable = "#operations-log-table";
if (update) {
operationTable = $(operationsLogTable).DataTable();
$("#operations-spinner").removeClass("hidden");
operationTable.ajax.reload(function(json) {
$("#operations-spinner").addClass("hidden");
}, false);
return;
}
operationTable = $(operationsLogTable).datatables_extended({
serverSide: true,
processing: false,
searching: false,
ordering: false,
pageLength: 10,
order: [],
ajax: {
url: "/devicemgt/api/operation/paginate",
data: {
deviceId: deviceIdentifier,
deviceType: deviceType,
owner: deviceOwner
},
dataSrc: function(json) {
$("#operations-spinner").addClass("hidden");
$("#operations-log-container").empty();
return json.data;
}
},
columnDefs: [{
targets: 0,
data: "code"
},
{
targets: 1,
data: "status",
render: function(status) {
var html;
switch (status) {
case "COMPLETED":
html = "<span><i class='fw fw-success icon-success'></i> Completed</span>";
break;
case "PENDING":
html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break;
case "ERROR":
html = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
break;
case "IN_PROGRESS":
html = "<span><i class='fw fw-success icon-warning'></i> In Progress</span>";
break;
case "REPEATED":
html = "<span><i class='fw fw-success icon-warning'></i> Repeated</span>";
break;
} }
return html;
}
},
{
targets: 2,
data: "createdTimeStamp",
render: function(date) {
var value = String(date);
return value.slice(0, 16);
} }
],
"createdRow": function(row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),
function(colIndex) {
switch(colIndex) {
case 1:
$(this).attr("data-grid-label", "Code");
$(this).attr("data-display", data["code"]);
break;
case 2:
$(this).attr("data-grid-label", "Status");
$(this).attr("data-display", data["status"]);
break;
case 3:
$(this).attr("data-grid-label", "Created Timestamp");
$(this).attr("data-display", data["createdTimeStamp"]);
break;
}
}
);
} }
}); ],
} "createdRow": function(row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),
function(colIndex) {
switch (colIndex) {
case 1:
$(this).attr("data-grid-label", "Code");
$(this).attr("data-display", data["code"]);
break;
case 2:
$(this).attr("data-grid-label", "Status");
$(this).attr("data-display", data["status"]);
break;
case 3:
$(this).attr("data-grid-label", "Created Timestamp");
$(this).attr("data-display", data["createdTimeStamp"]);
break;
}
}
);
}
});
}
function loadPolicyCompliance() {
var policyCompliance = $("#policy-view");
var policyComplianceTemplate = policyCompliance.attr("src");
var deviceId = policyCompliance.data("device-id");
var deviceType = policyCompliance.data("device-type");
var activePolicy = null;
function loadPolicyCompliance() { $.template(
var policyCompliance = $("#policy-view"); "policy-view",
var policyComplianceTemplate = policyCompliance.attr("src"); policyComplianceTemplate,
var deviceId = policyCompliance.data("device-id"); function(template) {
var deviceType = policyCompliance.data("device-type"); var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
var activePolicy = null; var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
invokerUtil.get(
$.template( getEffectivePolicyURL,
"policy-view", // success-callback
policyComplianceTemplate, function(data, textStatus, jqXHR) {
function (template) { if (jqXHR.status == 200) {
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; $("#policy-spinner").addClass("hidden");
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; if (data) {
invokerUtil.get( data = JSON.parse(data);
getEffectivePolicyURL, if (data["active"] == true) {
// success-callback activePolicy = data;
function (data, textStatus, jqXHR) { invokerUtil.get(
if (jqXHR.status == 200) { getDeviceComplianceURL,
$("#policy-spinner").addClass("hidden"); // success-callback
if(data){ function(data, textStatus, jqXHR) {
data = JSON.parse(data); if (jqXHR.status == 200 && data) {
if (data["active"] == true) { var viewModel = {};
activePolicy = data; viewModel["policy"] = activePolicy;
invokerUtil.get( viewModel["deviceType"] = deviceType;
getDeviceComplianceURL, viewModel["deviceId"] = deviceId;
// success-callback viewModel["appContext"] = context;
function (data, textStatus, jqXHR) { data = JSON.parse(data);
if (jqXHR.status == 200 && data) { var content;
var viewModel = {}; if (data["complianceData"]) {
viewModel["policy"] = activePolicy; if (data["complianceData"]["complianceFeatures"] &&
viewModel["deviceType"] = deviceType; data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["deviceId"] = deviceId; viewModel["compliance"] = "NON-COMPLIANT";
viewModel["appContext"] = context; viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
data = JSON.parse(data); content = template(viewModel);
var content; $("#policy-list-container").html(content);
if (data["complianceData"]) {
if (data["complianceData"]["complianceFeatures"] &&
data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["compliance"] = "NON-COMPLIANT";
viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
content = template(viewModel);
$("#policy-list-container").html(content);
} else {
viewModel["compliance"] = "COMPLIANT";
content = template(viewModel);
$("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden");
}
} else { } else {
$("#policy-list-container"). viewModel["compliance"] = "COMPLIANT";
html("<div class='panel-body'><br><p class='fw-warning'> This device " + content = template(viewModel);
"has no policy applied.<p></div>"); $("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden");
} }
} else {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> This device " +
"has no policy applied.<p></div>");
} }
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
} }
); },
} // error-callback
function() {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
} }
} }
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
} }
); },
} // error-callback
); function() {
} $("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
}
);
}

@ -15,156 +15,114 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#zone "topCss"}}
{{css "css/main.css"}}
{{/zone}}
{{unit "cdmf.unit.lib.editable"}} {{unit "cdmf.unit.lib.editable"}}
{{#zone "content"}} {{#zone "content"}}
{{#if deviceFound}} {{#if deviceFound}}
{{#if isAuthorized}} {{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}" <div class="row">
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"></span> <div class="col-lg-4">
{{#defineZone "device-details-header"}} <div class="device-info-container">
<h1 class="page-sub-title device-id device-select" data-deviceid="{{device.deviceIdentifier}}" <div class="row">
data-type="{{device.type}}"> <div class="col-lg-3">
Device {{device.name}} {{#defineZone "device-thumbnail"}}
{{#if device.viewModel.model}} <i class="fw fw-mobile device-type fw-2x"></i>
<span class="lbl-device">
( {{device.viewModel.vendor}} {{device.viewModel.model}} )
</span>
{{/if}}
</h1>
{{/defineZone}}
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div id="device_overview">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
<div class="thumbnail icon">
{{#defineZone "device-thumbnail"}}
<i class="square-element text fw fw-mobile"></i>
{{/defineZone}}
</div>
</div>
<div class="media-body asset-desc add-padding-left-5x">
{{#defineZone "overview-section"}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Device Overview - {{label}}</div>
{{unit "cdmf.unit.device.overview-section" device=device}}
{{/defineZone}}
{{#defineZone "operation-status"}}{{/defineZone}}
{{#defineZone "device-opetations"}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Operations
</div>
<div class="add-margin-top-4x" style="height: 90px;">
{{unit "cdmf.unit.device.operation-bar" device=device}}
</div>
{{/defineZone}}
</div>
</div>
</div>
<div class="media tab-responsive">
<div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs">
<ul class="list-group nav nav-pills nav-stacked" role="tablist">
{{#defineZone "device-view-tabs"}}
{{#defineZone "device-details-tab"}}
<li role="presentation" class="list-group-item active">
<a href="#device_details_tab" role="tab" data-toggle="tab"
aria-controls="device_details_tab">
<i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span>
</a>
</li>
{{/defineZone}}
{{#defineZone "device-details-tab-injected"}}
{{/defineZone}}
{{#defineZone "device-details-tab-operations"}}
<li role="presentation" class="list-group-item">
<a href="#event_log_tab" role="tab" data-toggle="tab" aria-controls="event_log_tab">
<i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
</a>
</li>
{{/defineZone}}
{{/defineZone}} {{/defineZone}}
</ul> </div>
</div> <div class="col-lg-9">
<div class="media-body add-padding-left-5x remove-padding-xs"> <div class="device-info">
<div class="panel-group tab-content remove-padding" id="tabs" role="tablist" {{#defineZone "device-details-header"}}
data-status="{{device.isNotRemoved}}" aria-multiselectable="true"> <h1 data-deviceid="{{device.deviceIdentifier}}"
<div class="arrow-left hidden-xs"></div> data-type="{{device.type}}"
data-ownership="{{device.ownership}}"
{{#defineZone "device-view-tab-contents"}} data-owner="{{device.owner}}">
{{#defineZone "device-details-tab-contents"}} {{#if device.viewModel.model}}
<div class="message message-info"> <h4>{{device.viewModel.vendor}} {{device.viewModel.model}}</h4>
<h4 class="remove-margin"> {{/if}}
<i class="icon fw fw-info"></i> <h4>Ownership - <strong>{{device.viewModel.ownership}}</strong></h4>
No Device details avaialbe yet. <h4>Device is
<strong>
{{#equal device.status "ACTIVE"}}Active{{/equal}}
{{#equal device.status "INACTIVE"}}Inactive{{/equal}}
{{#equal device.status "BLOCKED"}}Blocked{{/equal}}
{{#equal device.status "REMOVED"}}Removed{{/equal}}
{{#equal device.status "UNREACHABLE"}}Unreachable{{/equal}}
</strong>
</h4> </h4>
</div>
{{/defineZone}}
{{#defineZone "device-view-tab-injected-conents"}}
{{/defineZone}}
{{#defineZone "device-view-tab-operations-log-conents"}}
<div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab">
<div class="panel-heading visible-xs collapsed" id="event_log">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#tabs"
href="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
<i class="fw fw-text fw-2x"></i>
Operations Log
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Operations Log
<span>
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-body">
<span class="visible-xs add-padding-2x text-right">
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Operations Log...
</div>
<div id="operations-log-container">
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
There are no operations, performed yet on this device.
</h4>
</div>
</div>
<table class="table table-striped table-hover table-bordered display data-table"
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
{{/defineZone}} {{/defineZone}}
{{/defineZone}} </div>
</div>
</div>
</div>
<div class="vital-strip">
{{#defineZone "device-details"}}
{{/defineZone}}
</div>
{{#defineZone "device-opetations"}}
<div class="operation-container">
<div class="operation-title">
<h4>Device Operations</h4>
</div>
{{unit "cdmf.unit.device.operation-bar" device=device}}
</div>
{{/defineZone}}
<div class="clearfix"></div>
</div>
<!-- /col-lg-4 -->
<div class="col-lg-8">
<ul class="nav nav-tabs">
{{#defineZone "device-view-tabs"}}
<li class="active"><a data-toggle="tab" href="#event_log">Operations Log</a></li>
{{#defineZone "device-details-tab-injected"}}
{{/defineZone}}
{{/defineZone}}
</ul>
<div class="tab-content">
{{#defineZone "device-view-tab-contents"}}
<div id="event_log" class="tab-pane fade in active">
<div class="clearfix"></div>
<div class="operation-log-container">
<table class="table table-striped table-hover table-responsive list-table display responsive nowrap data-table"
id="operation-log">
<thead class="block">
<tr class="sort-row">
<!-- <th class="content-fill no-sort"></th> -->
<th>Name</th>
<th>Position</th>
<th>Office</th>
<!-- <th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th class="no-sort"></th> -->
</tr>
</thead>
<tbody>
</tbody>
</table>
<!-- <table class="table table-striped table-hover table-bordered display data-table"
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table> -->
</div>
</div> </div>
</div> {{#defineZone "device-view-tab-injected-conents"}}
</div> {{/defineZone}}
{{/defineZone}}
</div>
</div>
<!-- /col-lg-08 -->
</div> </div>
<!-- /row -->
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Permission Denied Permission Denied
@ -192,4 +150,4 @@
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{/zone}} {{/zone}}

@ -131,7 +131,7 @@ var showAdvanceOperation = function (operation, button) {
var artifactGeoUpload = function () { var artifactGeoUpload = function () {
var contentType = "application/json"; var contentType = "application/json";
var backendEndBasePath = "/api/device-mgt/v1.0"; var backendEndBasePath = "/api/device-mgt/v1.0";
var urix = backendEndBasePath + "/admin/devicetype/deploy/analytics"; var urix = backendEndBasePath + "/admin/publish-artifact/deploy/analytics";
var defaultStatusClasses = "fw fw-stack-1x"; var defaultStatusClasses = "fw fw-stack-1x";
var content = $("#geo-analytics-response-template").find(".content"); var content = $("#geo-analytics-response-template").find(".content");
var title = content.find("#title"); var title = content.find("#title");

@ -196,11 +196,11 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<br> <!--<br>-->
<label class="wr-input-label" title=""> <label class="wr-input-label" title="" style="display: none;">
Set an action upon non-compliance Set an action upon non-compliance
</label> </label>
<div class="wr-input-control"> <div class="wr-input-control" style="display: none;">
<div class="cus-col-50"> <div class="cus-col-50">
<!--suppress HtmlFormInputWithoutLabel --> <!--suppress HtmlFormInputWithoutLabel -->
<select id="action-input" class="form-control"> <select id="action-input" class="form-control">
@ -209,7 +209,7 @@
<option data-action="monitor">Monitor</option> <option data-action="monitor">Monitor</option>
</select> </select>
</div> </div>
<br class="c-both"/> <!--<br class="c-both"/>-->
</div> </div>
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div class="wr-input-control wr-btn-grp">

@ -192,10 +192,10 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<label class="wr-input-label" title=""> <label class="wr-input-label" title="" style="display: none;">
Set an action upon non-compliance Set an action upon non-compliance
</label> </label>
<div class="wr-input-control"> <div class="wr-input-control" style="display: none;">
<div class="cus-col-50"> <div class="cus-col-50">
<select id="action-input" class="form-control"> <select id="action-input" class="form-control">
<option value="enforce" data-action="enforce" selected>Enforce</option> <option value="enforce" data-action="enforce" selected>Enforce</option>
@ -203,7 +203,7 @@
<option value="monitor" data-action="monitor">Monitor</option> <option value="monitor" data-action="monitor">Monitor</option>
</select> </select>
</div> </div>
<br class="c-both"/> <!--<br class="c-both"/>-->
</div> </div>
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div class="wr-input-control wr-btn-grp">

@ -469,7 +469,7 @@ function statisticLoad(redirectUrl) {
window.location.href = redirectUrl; window.location.href = redirectUrl;
}, },
error: function() { error: function() {
var urix = backendEndBasePath + "/admin/devicetype/deploy/device_management"; var urix = backendEndBasePath + "/admin/publish-artifact/deploy/device_management";
var device = {}; var device = {};
invokerUtil.post(urix, device, function (data) { invokerUtil.post(urix, device, function (data) {
title.html("Deploying statistic artifacts. Please wait..."); title.html("Deploying statistic artifacts. Please wait...");

@ -1173,6 +1173,10 @@ header .dropdown[aria-expanded=true], header .dropdown:hover {
right: 0; right: 0;
} }
.sidebar-wrapper.toggled a.btn{
margin-bottom: 70px;
}
.sidebar-wrapper-animation-fix { .sidebar-wrapper-animation-fix {
-webkit-transition: left 0.5s ease, right 0.5s ease !important; -webkit-transition: left 0.5s ease, right 0.5s ease !important;
-moz-transition: left 0.5s ease, right 0.5s ease !important; -moz-transition: left 0.5s ease, right 0.5s ease !important;
@ -2859,7 +2863,8 @@ a.ast-type-item:hover {
font-size: 12px; font-size: 12px;
text-decoration: none; text-decoration: none;
margin-right: 10px; margin-right: 10px;
color: #526A84; /*color: #526A84;*/
color: #333;
min-width: 70px; min-width: 70px;
background: #fafafa; background: #fafafa;
padding: 2px 10px 10px 10px; padding: 2px 10px 10px 10px;

@ -23,7 +23,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId> <artifactId>email-sender</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name> <name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description> <description>WSO2 Carbon - Dynamic Client Registration Service</description>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name> <name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description> <description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name> <name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId> <artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name> <name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,14 +3,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.policy.decision.point</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId> <artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name> <name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description> <description>WSO2 Carbon - Policy Information Point</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId> <artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name> <name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description> <description>WSO2 Carbon - Policy Management Common</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId> <artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name> <name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description> <description>WSO2 Carbon - Policy Management Core</description>

@ -29,6 +29,7 @@ import org.wso2.carbon.policy.mgt.core.dao.impl.MonitoringDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.impl.PolicyDAOImpl; import org.wso2.carbon.policy.mgt.core.dao.impl.PolicyDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.impl.ProfileDAOImpl; import org.wso2.carbon.policy.mgt.core.dao.impl.ProfileDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.impl.feature.GenericFeatureDAOImpl; import org.wso2.carbon.policy.mgt.core.dao.impl.feature.GenericFeatureDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.impl.feature.OracleServerFeatureDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.impl.feature.SQLServerFeatureDAOImpl; import org.wso2.carbon.policy.mgt.core.dao.impl.feature.SQLServerFeatureDAOImpl;
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
@ -77,6 +78,7 @@ public class PolicyManagementDAOFactory {
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL: case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL:
return new SQLServerFeatureDAOImpl(); return new SQLServerFeatureDAOImpl();
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE: case DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleServerFeatureDAOImpl();
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL: case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2: case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2:
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL: case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL:

@ -60,10 +60,10 @@ public final class GenericFeatureDAOImpl extends AbstractFeatureDAO {
stmt.setInt(1, profileId); stmt.setInt(1, profileId);
stmt.setString(2, feature.getFeatureCode()); stmt.setString(2, feature.getFeatureCode());
stmt.setString(3, feature.getDeviceType()); stmt.setString(3, feature.getDeviceType());
// if (conn.getMetaData().getDriverName().contains("H2")) { // if (conn.getMetaData().getDriverName().contains("H2")) {
// stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent())); // stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent()));
// } else { // } else {
stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent())); stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent()));
//} //}
stmt.setInt(5, tenantId); stmt.setInt(5, tenantId);
stmt.addBatch(); stmt.addBatch();

@ -0,0 +1,94 @@
/*
* Copyright (c) 2017, 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.policy.mgt.core.dao.impl.feature;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException;
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class OracleServerFeatureDAOImpl extends AbstractFeatureDAO {
/**
* Batch sizes greater than 10 throws array out of bound exception.
*/
private static int BATCH_SIZE = 10;
@Override
public List<ProfileFeature> addProfileFeatures(List<ProfileFeature> features, int profileId) throws
FeatureManagerDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet generatedKeys = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
conn = this.getConnection();
String query = "INSERT INTO DM_PROFILE_FEATURES (PROFILE_ID, FEATURE_CODE, DEVICE_TYPE, CONTENT, " +
"TENANT_ID) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(query, new String[]{"id"});
int noRecords = 0;
for (ProfileFeature feature : features) {
stmt.setInt(1, profileId);
stmt.setString(2, feature.getFeatureCode());
stmt.setString(3, feature.getDeviceType());
stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent()));
stmt.setInt(5, tenantId);
stmt.addBatch();
noRecords++;
if (noRecords >= BATCH_SIZE && noRecords % BATCH_SIZE == 0) {
stmt.executeBatch();
generatedKeys = stmt.getGeneratedKeys();
int i = noRecords - this.BATCH_SIZE;
while (generatedKeys.next()) {
features.get(i).setId(generatedKeys.getInt(1));
i++;
}
}
}
stmt.executeBatch();
generatedKeys = stmt.getGeneratedKeys();
int i = 0;
if (noRecords > BATCH_SIZE) {
i = noRecords - BATCH_SIZE;
}
while (generatedKeys.next()) {
features.get(i).setId(generatedKeys.getInt(1));
i++;
}
} catch (SQLException | IOException e) {
throw new FeatureManagerDAOException("Error occurred while adding the feature list to the database.", e);
} finally {
PolicyManagementDAOUtil.cleanupResources(stmt, generatedKeys);
}
return features;
}
private Connection getConnection() throws FeatureManagerDAOException {
return PolicyManagementDAOFactory.getConnection();
}
}

@ -23,13 +23,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name> <name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId> <artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name> <name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description> <description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name> <name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name> <name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription <description>This feature contains an implementation of a api application registration, which takes care of subscription

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management - APIM handler Server Feature</name> <name>WSO2 Carbon - Device Management - APIM handler Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the handler for the api authentications <description>This feature contains the handler for the api authentications

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - APIM Integration Client Feature</name> <name>WSO2 Carbon - APIM Integration Client Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Webapp Publisher Feature</name> <name>WSO2 Carbon - API Management Webapp Publisher Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing <description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Feature</name> <name>WSO2 Carbon - API Management Extensions Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<name>WSO2 Carbon - Certificate Management Server Feature</name> <name>WSO2 Carbon - Certificate Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for back-end Certificate Management functionality <description>This feature contains the core bundles required for back-end Certificate Management functionality

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>3.0.4-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Feature</name> <name>WSO2 Carbon - Certificate Management Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save