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

revert-70aa11f8
warunalakshitha 7 years ago
commit a5e22c652b

@ -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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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>

@ -22,11 +22,16 @@ import feign.RequestInterceptor;
import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import java.util.HashMap;
import java.util.Map;
public class IntegrationClientServiceImpl implements IntegrationClientService { public class IntegrationClientServiceImpl implements IntegrationClientService {
private static StoreClient storeClient; private static StoreClient storeClient;
private static PublisherClient publisherClient; private static PublisherClient publisherClient;
private static Map<String, AccessTokenInfo> tenantUserTokenMap = new HashMap<>();
public IntegrationClientServiceImpl() { public IntegrationClientServiceImpl() {
RequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); RequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor();
@ -42,4 +47,8 @@ public class IntegrationClientServiceImpl implements IntegrationClientService {
public PublisherClient getPublisherClient() { public PublisherClient getPublisherClient() {
return publisherClient; return publisherClient;
} }
public static Map<String, AccessTokenInfo> getTenantUserTokenMap() {
return tenantUserTokenMap;
}
} }

@ -55,7 +55,6 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000; private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000;
private DCRClient dcrClient; private DCRClient dcrClient;
private static OAuthApplication oAuthApplication; private static OAuthApplication oAuthApplication;
private static Map<String, AccessTokenInfo> tenantUserTokenMap = new HashMap<>();
private static final Log log = LogFactory.getLog(OAuthRequestInterceptor.class); private static final Log log = LogFactory.getLog(OAuthRequestInterceptor.class);
/** /**
@ -89,7 +88,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
username = username + "@" + tenantDomain; username = username + "@" + tenantDomain;
} }
AccessTokenInfo tenantBasedAccessTokenInfo = tenantUserTokenMap.get(username); AccessTokenInfo tenantBasedAccessTokenInfo = IntegrationClientServiceImpl.getTenantUserTokenMap().get(username);
if ((tenantBasedAccessTokenInfo == null || if ((tenantBasedAccessTokenInfo == null ||
((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) >
tenantBasedAccessTokenInfo.getExpiresIn()))) { tenantBasedAccessTokenInfo.getExpiresIn()))) {
@ -106,7 +105,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
} }
if (tenantBasedAccessTokenInfo.getScopes().contains(APIM_SUBSCRIBE_SCOPE)) { if (tenantBasedAccessTokenInfo.getScopes().contains(APIM_SUBSCRIBE_SCOPE)) {
tenantUserTokenMap.put(username, tenantBasedAccessTokenInfo); IntegrationClientServiceImpl.getTenantUserTokenMap().put(username, tenantBasedAccessTokenInfo);
} }
} }

@ -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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -362,6 +362,11 @@
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId> <artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -24,7 +24,6 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
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.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
@ -66,7 +65,6 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.security.auth.login.Configuration;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -92,8 +90,8 @@ import java.util.List;
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public class DeviceManagementServiceImpl implements DeviceManagementService { public class DeviceManagementServiceImpl implements DeviceManagementService {
private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
@GET @GET
@Path("/{type}/{id}/status") @Path("/{type}/{id}/status")
@ -499,15 +497,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("offset") int offset, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) { @QueryParam("limit") int limit) {
List<Application> applications; List<Application> applications;
//ApplicationList appList;
ApplicationManagementProviderService amc; ApplicationManagementProviderService amc;
try { try {
RequestValidationUtil.validateDeviceIdentifier(type, id); RequestValidationUtil.validateDeviceIdentifier(type, id);
amc = DeviceMgtAPIUtils.getAppManagementService(); amc = DeviceMgtAPIUtils.getAppManagementService();
applications = amc.getApplicationListForDevice(new DeviceIdentifier(id, type)); applications = amc.getApplicationListForDevice(new DeviceIdentifier(id, type));
return Response.status(Response.Status.OK).entity(applications).build();
//TODO: return app list
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while fetching the apps of the '" + type + "' device, which carries " + String msg = "Error occurred while fetching the apps of the '" + type + "' device, which carries " +
"the id '" + id + "'"; "the id '" + id + "'";
@ -515,7 +511,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
return Response.status(Response.Status.OK).entity(applications).build();
} }
@GET @GET

@ -562,7 +562,12 @@ public class UserManagementServiceImpl implements UserManagementService {
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while inviting user to enrol their device"; String msg = "Error occurred while inviting user to enrol their device";
if (e.getMessage() != null && !e.getMessage().isEmpty()) {
msg = e.getMessage();
}
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while getting claim values to invite user"; String msg = "Error occurred while getting claim values to invite user";
log.error(msg, e); log.error(msg, e);

@ -20,7 +20,10 @@ package org.wso2.carbon.device.mgt.jaxrs.util;
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.apimgt.integration.client.IntegrationClientServiceImpl;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
@ -63,6 +66,9 @@ public class CredentialManagementResponseBuilder {
username = CarbonContext.getThreadLocalCarbonContext().getUsername(); username = CarbonContext.getThreadLocalCarbonContext().getUsername();
userStoreManager.updateCredential(username, credentials.getNewPassword(), userStoreManager.updateCredential(username, credentials.getNewPassword(),
credentials.getOldPassword()); credentials.getOldPassword());
IntegrationClientServiceImpl integrationClientService = (IntegrationClientServiceImpl) PrivilegedCarbonContext.
getThreadLocalCarbonContext().getOSGiService(IntegrationClientService.class, null);
integrationClientService.getTenantUserTokenMap().remove(username);
return Response.status(Response.Status.OK).entity("UserImpl password by username: " + return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
username + " was successfully changed.").build(); username + " was successfully changed.").build();
} catch (UserStoreException e) { } catch (UserStoreException e) {

@ -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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -65,4 +65,10 @@ public class GroupPaginationRequest {
this.groupName = groupName; this.groupName = groupName;
} }
@Override
public String toString() {
return "Group Name '" + this.groupName + "' num of rows: " + this.rowCount + " start index: " + this.startIndex
+ " owner' " + this.owner + "'";
}
} }

@ -129,4 +129,12 @@ public class PaginationRequest {
public void setOwnerPattern(String ownerPattern) { public void setOwnerPattern(String ownerPattern) {
this.ownerPattern = ownerPattern; this.ownerPattern = ownerPattern;
} }
@Override
public String toString() {
return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount
+ " Owner role '" + this.ownerRole + "' owner pattern '" + this.ownerPattern + "' ownership "
+ this.ownership + "' Status '" + this.status + "' owner '" + this.owner + "' groupId: " + this.groupId
+ " start index: " + this.startIndex;
}
} }

@ -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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -198,17 +198,17 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
public void updateApplicationListInstalledInDevice( public void updateApplicationListInstalledInDevice(
DeviceIdentifier deviceIdentifier, DeviceIdentifier deviceIdentifier,
List<Application> applications) throws ApplicationManagementException { List<Application> applications) throws ApplicationManagementException {
if (log.isDebugEnabled()) {
log.debug("Updating application list for device: " + deviceIdentifier.toString());
}
List<Application> installedAppList = getApplicationListForDevice(deviceIdentifier); List<Application> installedAppList = getApplicationListForDevice(deviceIdentifier);
try { try {
Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier, Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier,
false); false);
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
if (log.isDebugEnabled()) {
log.debug("Device:" + device.getId() + ":identifier:" + deviceIdentifier.getId());
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("num of apps installed:" + installedAppList.size()); log.debug("Number of apps installed:" + installedAppList.size());
} }
List<Application> appsToAdd = new ArrayList<>(); List<Application> appsToAdd = new ArrayList<>();
List<Integer> appIdsToRemove = new ArrayList<>(installedAppList.size()); List<Integer> appIdsToRemove = new ArrayList<>(installedAppList.size());
@ -227,11 +227,12 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
List<Integer> applicationIds = new ArrayList<>(); List<Integer> applicationIds = new ArrayList<>();
for (Application application : applications) { for (Application application : applications) {
/* // Adding N/A if application doesn't have a version. Also truncating the application version,
Truncating the application version if length of the version is greater than maximum allowed length. // if length of the version is greater than maximum allowed length.
*/ if (application.getVersion() == null) {
if (application.getVersion().length() > application.setVersion("N/A");
DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) { } else if (application.getVersion().length() >
DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) {
application.setVersion(StringUtils.abbreviate(application.getVersion(), application.setVersion(StringUtils.abbreviate(application.getVersion(),
DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH)); DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH));
} }
@ -258,24 +259,34 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("num of remove app Ids:" + appIdsToRemove.size()); log.debug("num of remove app Ids:" + appIdsToRemove.size());
} }
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new ApplicationManagementException("Error occurred saving application list to the device", e); String msg = "Error occurred saving application list of the device " + deviceIdentifier.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new ApplicationManagementException("Error occurred while initializing transaction", e); String msg = "Error occurred while initializing transaction for saving application list to the device "
+ deviceIdentifier.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error occurred obtaining the device object.", e); String msg = "Error occurred obtaining the device object for device " + deviceIdentifier.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (Exception e) {
String msg = "Exception occurred saving application list of the device " + deviceIdentifier.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
} }
@Override @Override
public List<Application> getApplicationListForDevice( public List<Application> getApplicationListForDevice(DeviceIdentifier deviceId)
DeviceIdentifier deviceId) throws ApplicationManagementException { throws ApplicationManagementException {
Device device = null; Device device;
try { try {
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId,
false); false);
@ -286,18 +297,26 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
if (device == null) { if (device == null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("No device is found upon the device identifier '" + deviceId.getId() + log.debug("No device is found upon the device identifier '" + deviceId.getId() +
"' and type '" + deviceId.getType() + "'. Therefore returning null"); "' and type '" + deviceId.getType() + "'. Therefore returning empty app list");
} }
return null; return new ArrayList<>();
} }
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
return applicationDAO.getInstalledApplications(device.getId()); return applicationDAO.getInstalledApplications(device.getId());
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new ApplicationManagementException("Error occurred while fetching the Application List of '" + String msg = "Error occurred while fetching the Application List of device " + deviceId.toString();
deviceId.getType() + "' device carrying the identifier'" + deviceId.getId(), e); log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementException("Error occurred while opening a connection to the data source", e); String msg = "Error occurred while opening a connection to the data source to get application " +
"list of the device " + deviceId.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (Exception e) {
String msg = "Exception occurred getting application list of the device " + deviceId.toString();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }

@ -182,16 +182,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt.setString(3, Operation.Status.PENDING.toString()); stmt.setString(3, Operation.Status.PENDING.toString());
// This will return only one result always. // This will return only one result always.
rs = stmt.executeQuery(); rs = stmt.executeQuery();
int id = 0;
if (rs.next()) { if (rs.next()) {
id = rs.getInt("ID");
}
if (id != 0) {
stmt = connection.prepareStatement(
"UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + "WHERE ID = ?");
stmt.setLong(1, System.currentTimeMillis() / 1000);
stmt.setInt(2, id);
stmt.executeUpdate();
result = true; result = true;
} }
} catch (SQLException e) { } catch (SQLException e) {

@ -65,6 +65,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) public void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions)
throws GroupManagementException, GroupAlreadyExistException { throws GroupManagementException, GroupAlreadyExistException {
if (deviceGroup == null) {
String msg = "Received incomplete data for createGroup";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Creating group '" + deviceGroup.getName() + "'");
}
if (deviceGroup == null) { if (deviceGroup == null) {
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException()); throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
} }
@ -80,10 +88,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
throw new GroupManagementException("Error occurred while adding deviceGroup " + String msg = "Error occurred while adding deviceGroup '" + deviceGroup.getName() + "' to database.";
"'" + deviceGroup.getName() + "' to database.", e); log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new GroupManagementException("Error occurred while initiating transaction.", e); String msg = "Error occurred while initiating transaction.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in creating group '" + deviceGroup.getName() + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -99,6 +114,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public void updateGroup(DeviceGroup deviceGroup, int groupId) public void updateGroup(DeviceGroup deviceGroup, int groupId)
throws GroupManagementException, GroupAlreadyExistException { throws GroupManagementException, GroupAlreadyExistException {
if (deviceGroup == null) {
String msg = "Received incomplete data for updateGroup";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("update group '" + deviceGroup.getName() + "'");
}
if (deviceGroup == null) { if (deviceGroup == null) {
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException()); throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
} }
@ -114,10 +137,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
throw new GroupManagementException("Error occurred while modifying deviceGroup " + String msg = "Error occurred while modifying deviceGroup '" + deviceGroup.getName() + "'.";
"'" + deviceGroup.getName() + "'.", e); log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new GroupManagementException("Error occurred while initiating transaction.", e); String msg = "Error occurred while initiating transaction.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in updating group '" + deviceGroup.getName() + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -128,6 +158,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public boolean deleteGroup(int groupId) throws GroupManagementException { public boolean deleteGroup(int groupId) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Delete group: " + groupId);
}
DeviceGroup deviceGroup = getGroup(groupId); DeviceGroup deviceGroup = getGroup(groupId);
if (deviceGroup == null) { if (deviceGroup == null) {
return false; return false;
@ -142,9 +175,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
return true; return true;
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
throw new GroupManagementException("Error occurred while removing group data.", e); String msg = "Error occurred while removing group data.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new GroupManagementException("Error occurred while initiating transaction.", e); String msg = "Error occurred while initiating transaction.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in deleting group: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -155,14 +196,25 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public DeviceGroup getGroup(int groupId) throws GroupManagementException { public DeviceGroup getGroup(int groupId) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Get group by id: " + groupId);
}
DeviceGroup deviceGroup; DeviceGroup deviceGroup;
try { try {
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while obtaining group '" + groupId + "'", e); String msg = "Error occurred while obtaining group '" + groupId + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroup for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -174,14 +226,30 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public DeviceGroup getGroup(String groupName) throws GroupManagementException { public DeviceGroup getGroup(String groupName) throws GroupManagementException {
if (groupName == null) {
String msg = "Received empty groupName for getGroup";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get group by name '" + groupName + "'");
}
DeviceGroup deviceGroup; DeviceGroup deviceGroup;
try { try {
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId());
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while obtaining group with name: '" + groupName + "'", e); String msg = "Error occurred while obtaining group with name: '" + groupName + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroup with name " + groupName;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -190,15 +258,26 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public List<DeviceGroup> getGroups() throws GroupManagementException { public List<DeviceGroup> getGroups() throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Get groups");
}
List<DeviceGroup> deviceGroups = new ArrayList<>(); List<DeviceGroup> deviceGroups = new ArrayList<>();
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroups = this.groupDAO.getGroups(tenantId); deviceGroups = this.groupDAO.getGroups(tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroups";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -207,6 +286,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public PaginationResult getGroups(GroupPaginationRequest request) throws GroupManagementException { public PaginationResult getGroups(GroupPaginationRequest request) throws GroupManagementException {
if (request == null) {
String msg = "Received incomplete data for getGroup";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups with pagination " + request.toString());
}
request = DeviceManagerUtil.validateGroupListPageSize(request); request = DeviceManagerUtil.validateGroupListPageSize(request);
List<DeviceGroup> deviceGroups = new ArrayList<>(); List<DeviceGroup> deviceGroups = new ArrayList<>();
try { try {
@ -214,9 +301,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroups = this.groupDAO.getGroups(request, tenantId); deviceGroups = this.groupDAO.getGroups(request, tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroups";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -228,6 +323,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public List<DeviceGroup> getGroups(String username) throws GroupManagementException { public List<DeviceGroup> getGroups(String username) throws GroupManagementException {
if (username == null || username.isEmpty()) {
String msg = "Received null user name for getGroups";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups of owner '" + username + "'");
}
Map<Integer, DeviceGroup> groups = new HashMap<>(); Map<Integer, DeviceGroup> groups = new HashMap<>();
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
try { try {
@ -245,11 +348,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
groups.put(deviceGroup.getGroupId(), deviceGroup); groups.put(deviceGroup.getGroupId(), deviceGroup);
} }
} catch (UserStoreException e) { } catch (UserStoreException e) {
throw new GroupManagementException("Error occurred while getting user store manager.", e); String msg = "Error occurred while getting user store manager.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while retrieving all groups accessible to user.", e); String msg = "Error occurred while retrieving all groups accessible to user.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
log.error(e);
throw new GroupManagementException(e); throw new GroupManagementException(e);
} catch (Exception e) {
String msg = "Error occurred in getGroups for " + username;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -257,6 +369,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
private List<Integer> getGroupIds(String username) throws GroupManagementException { private List<Integer> getGroupIds(String username) throws GroupManagementException {
if (username == null || username.isEmpty()) {
String msg = "Received empty user name for getGroupIds";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups Ids of owner '" + username + "'");
}
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
List<Integer> deviceGroupIds = new ArrayList<>(); List<Integer> deviceGroupIds = new ArrayList<>();
try { try {
@ -268,11 +388,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
deviceGroupIds = this.groupDAO.getOwnGroupIds(username, tenantId); deviceGroupIds = this.groupDAO.getOwnGroupIds(username, tenantId);
deviceGroupIds.addAll(this.groupDAO.getGroupIds(roleList, tenantId)); deviceGroupIds.addAll(this.groupDAO.getGroupIds(roleList, tenantId));
} catch (UserStoreException e) { } catch (UserStoreException e) {
throw new GroupManagementException("Error occurred while getting user store manager.", e); String msg = "Error occurred while getting user store manager.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while retrieving all groups accessible to user.", e); String msg = "Error occurred while retrieving all groups accessible to user.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
log.error(e);
throw new GroupManagementException(e); throw new GroupManagementException(e);
} catch (Exception e) {
String msg = "Error occurred in getGroups for username '" + username + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -282,6 +411,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public PaginationResult getGroups(String currentUser, GroupPaginationRequest request) public PaginationResult getGroups(String currentUser, GroupPaginationRequest request)
throws GroupManagementException { throws GroupManagementException {
if (currentUser == null || request == null) {
String msg = "Received incomplete date for getGroups";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get all groups of user '" + currentUser + "' pagination request " + request.toString());
}
request = DeviceManagerUtil.validateGroupListPageSize(request); request = DeviceManagerUtil.validateGroupListPageSize(request);
List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser); List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser);
List<DeviceGroup> allMatchingGroups = new ArrayList<>(); List<DeviceGroup> allMatchingGroups = new ArrayList<>();
@ -290,9 +427,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroups";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -304,28 +449,55 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public int getGroupCount() throws GroupManagementException { public int getGroupCount() throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Get groups count");
}
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
return groupDAO.getGroupCount(tenantId); return groupDAO.getGroupCount(tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
} }
private int getGroupCount(GroupPaginationRequest request) throws GroupManagementException { private int getGroupCount(GroupPaginationRequest request) throws GroupManagementException {
if (request == null) {
String msg = "Received empty request for getGroupCount";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups count, pagination request " + request.toString());
}
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
return groupDAO.getGroupCount(request, tenantId); return groupDAO.getGroupCount(request, tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroupCount";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -336,6 +508,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public int getGroupCount(String username) throws GroupManagementException { public int getGroupCount(String username) throws GroupManagementException {
if (username == null || username.isEmpty()) {
String msg = "Received empty user name for getGroupCount";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups count of '" + username + "'");
}
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
int count; int count;
try { try {
@ -348,11 +528,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
count += groupDAO.getGroupsCount(roleList, tenantId); count += groupDAO.getGroupsCount(roleList, tenantId);
return count; return count;
} catch (UserStoreException e) { } catch (UserStoreException e) {
throw new GroupManagementException("Error occurred while getting user store manager.", e); String msg = "Error occurred while getting user store manager.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving group count of user '" + username + "'", e); String msg = "Error occurred while retrieving group count of user '" + username + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroupCount for username '" + username + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -364,41 +554,52 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public void manageGroupSharing(int groupId, List<String> newRoles) public void manageGroupSharing(int groupId, List<String> newRoles)
throws GroupManagementException, RoleDoesNotExistException { throws GroupManagementException, RoleDoesNotExistException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (log.isDebugEnabled()) {
UserStoreManager userStoreManager; log.debug("Manage group sharing for group: " + groupId);
try { }
userStoreManager = int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( UserStoreManager userStoreManager;
tenantId).getUserStoreManager(); try {
List<String> currentUserRoles = getRoles(groupId); userStoreManager =
GroupManagementDAOFactory.beginTransaction(); DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(
if (newRoles != null) { tenantId).getUserStoreManager();
for (String role : newRoles) { List<String> currentUserRoles = getRoles(groupId);
if (!userStoreManager.isExistingRole(role)) { GroupManagementDAOFactory.beginTransaction();
throw new RoleDoesNotExistException("Role '" + role + "' does not exists in the user store."); if (newRoles != null) {
} for (String role : newRoles) {
// Removing role from current user roles of the group will return true if role exist. if (!userStoreManager.isExistingRole(role)) {
// So we don't need to add it to the db again. throw new RoleDoesNotExistException("Role '" + role + "' does not exists in the user store.");
if (!currentUserRoles.remove(role)) { }
// If group doesn't have the role, it is adding to the db. // Removing role from current user roles of the group will return true if role exist.
groupDAO.addRole(groupId, role, tenantId); // So we don't need to add it to the db again.
} if (!currentUserRoles.remove(role)) {
// If group doesn't have the role, it is adding to the db.
groupDAO.addRole(groupId, role, tenantId);
} }
} }
for (String role : currentUserRoles) { }
// Removing old roles from db which are not available in the new roles list. for (String role : currentUserRoles) {
groupDAO.removeRole(groupId, role, tenantId); // Removing old roles from db which are not available in the new roles list.
} groupDAO.removeRole(groupId, role, tenantId);
GroupManagementDAOFactory.commitTransaction(); }
} catch (GroupManagementDAOException e) { GroupManagementDAOFactory.commitTransaction();
GroupManagementDAOFactory.rollbackTransaction(); } catch (GroupManagementDAOException e) {
throw new GroupManagementException(e); GroupManagementDAOFactory.rollbackTransaction();
} catch (UserStoreException e) { log.error(e);
throw new GroupManagementException("User store error in updating sharing roles.", e); throw new GroupManagementException(e);
} catch (TransactionManagementException e) { } catch (UserStoreException e) {
throw new GroupManagementException(e); String msg = "User store error in updating sharing roles.";
} finally { log.error(msg, e);
GroupManagementDAOFactory.closeConnection(); throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) {
log.error(e);
throw new GroupManagementException(e);
} catch (Exception e) {
String msg = "Error occurred in manageGroupSharing for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally {
GroupManagementDAOFactory.closeConnection();
} }
} }
@ -407,14 +608,25 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public List<String> getRoles(int groupId) throws GroupManagementException { public List<String> getRoles(int groupId) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Group roles for group: " + groupId);
}
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
return groupDAO.getRoles(groupId, tenantId); return groupDAO.getRoles(groupId, tenantId);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getRoles for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -426,6 +638,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public List<Device> getDevices(int groupId, int startIndex, int rowCount) public List<Device> getDevices(int groupId, int startIndex, int rowCount)
throws GroupManagementException { throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Group devices of group: " + groupId + " start index " + startIndex + " row count " + rowCount);
}
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<Device> devices; List<Device> devices;
try { try {
@ -433,11 +648,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
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); String msg = "Error occurred while getting devices in group.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new GroupManagementException("Error occurred while validating the limit of the devices to be returned", e); String msg = "Error occurred while validating the limit of the devices to be returned";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getDevices for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -449,13 +674,24 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public int getDeviceCount(int groupId) throws GroupManagementException { public int getDeviceCount(int groupId) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Group devices count of group: " + groupId);
}
try { try {
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
return groupDAO.getDeviceCount(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId()); return groupDAO.getDeviceCount(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); String msg = "Error occurred while opening a connection to the data source.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getDeviceCount for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -467,6 +703,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public void addDevices(int groupId, List<DeviceIdentifier> deviceIdentifiers) public void addDevices(int groupId, List<DeviceIdentifier> deviceIdentifiers)
throws GroupManagementException, DeviceNotFoundException { throws GroupManagementException, DeviceNotFoundException {
if (log.isDebugEnabled()) {
log.debug("Group devices to the group: " + groupId);
}
Device device; Device device;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
@ -483,12 +722,22 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
GroupManagementDAOFactory.commitTransaction(); GroupManagementDAOFactory.commitTransaction();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new GroupManagementException("Error occurred while retrieving device.", e); String msg = "Error occurred while retrieving device.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
throw new GroupManagementException("Error occurred while adding device to group.", e); String msg = "Error occurred while adding device to group.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new GroupManagementException("Error occurred while initiating transaction.", e); String msg = "Error occurred while initiating transaction.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in addDevices for groupId " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -500,6 +749,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override @Override
public void removeDevice(int groupId, List<DeviceIdentifier> deviceIdentifiers) public void removeDevice(int groupId, List<DeviceIdentifier> deviceIdentifiers)
throws GroupManagementException, DeviceNotFoundException { throws GroupManagementException, DeviceNotFoundException {
if (log.isDebugEnabled()) {
log.debug("Remove devices from the group: " + groupId);
}
Device device; Device device;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
@ -514,12 +766,22 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
GroupManagementDAOFactory.commitTransaction(); GroupManagementDAOFactory.commitTransaction();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new GroupManagementException("Error occurred while retrieving device.", e); String msg = "Error occurred while retrieving device.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new GroupManagementException("Error occurred while initiating transaction.", e); String msg = "Error occurred while initiating transaction.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
throw new GroupManagementException("Error occurred while adding device to group.", e); String msg = "Error occurred while adding device to group.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in removeDevice for groupId: " + groupId;
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -530,6 +792,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public List<DeviceGroup> getGroups(String username, String permission) throws GroupManagementException { public List<DeviceGroup> getGroups(String username, String permission) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Get groups of user '" + username + "'");
}
List<DeviceGroup> deviceGroups = getGroups(username); List<DeviceGroup> deviceGroups = getGroups(username);
Map<Integer, DeviceGroup> permittedDeviceGroups = new HashMap<>(); Map<Integer, DeviceGroup> permittedDeviceGroups = new HashMap<>();
UserRealm userRealm; UserRealm userRealm;
@ -546,13 +811,27 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
} }
} catch (UserStoreException e) { } catch (UserStoreException e) {
throw new GroupManagementException("Error occurred while getting user realm.", e); String msg = "Error occurred while getting user realm.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroups for username '" + username + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} }
return new ArrayList<>(permittedDeviceGroups.values()); return new ArrayList<>(permittedDeviceGroups.values());
} }
@Override @Override
public List<DeviceGroup> getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException { public List<DeviceGroup> getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException {
if (deviceIdentifier == null) {
String msg = "Received empty device identifier for getGroups";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) {
log.debug("Get groups of device " + deviceIdentifier.getId());
}
DeviceManagementProviderService managementProviderService = new DeviceManagementProviderServiceImpl(); DeviceManagementProviderService managementProviderService = new DeviceManagementProviderServiceImpl();
try { try {
Device device = managementProviderService.getDevice(deviceIdentifier, false); Device device = managementProviderService.getDevice(deviceIdentifier, false);
@ -560,11 +839,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
return groupDAO.getGroups(device.getId(), return groupDAO.getGroups(device.getId(),
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new GroupManagementException("Error occurred while retrieving the device details.", e); String msg = "Error occurred while retrieving the device details.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
throw new GroupManagementException("Error occurred while retrieving device groups.", e); String msg = "Error occurred while retrieving device groups.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementException("Error occurred while opening database connection.", e); String msg = "Error occurred while opening database connection.";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getGroups";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} finally { } finally {
GroupManagementDAOFactory.closeConnection(); GroupManagementDAOFactory.closeConnection();
} }
@ -575,7 +864,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
*/ */
@Override @Override
public DeviceGroup createDefaultGroup(String groupName) throws GroupManagementException { public DeviceGroup createDefaultGroup(String groupName) throws GroupManagementException {
if (log.isDebugEnabled()) {
log.debug("Create default group " + groupName);
}
DeviceGroup defaultGroup = this.getGroup(groupName); DeviceGroup defaultGroup = this.getGroup(groupName);
if (defaultGroup == null) { if (defaultGroup == null) {
defaultGroup = new DeviceGroup(groupName); defaultGroup = new DeviceGroup(groupName);
@ -586,10 +877,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
this.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE, this.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE,
DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS); DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS);
} catch (GroupAlreadyExistException e) { } catch (GroupAlreadyExistException e) {
if (log.isDebugEnabled()) { String msg = "Default group: " + defaultGroup.getName() + " already exists. Skipping group creation.";
log.debug("Default group: " + defaultGroup.getName() + " already exists. Skipping group creation.", log.error(msg, e);
e); throw new GroupManagementException(msg, e);
} } catch (Exception e) {
String msg = "Error occurred in createDefaultGroup for groupName '" + groupName + "'";
log.error(msg, e);
throw new GroupManagementException(msg, e);
} }
return this.getGroup(groupName); return this.getGroup(groupName);
} else { } else {

@ -18,3 +18,6 @@ insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=false and id == "$deviceId"] from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=false and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut; insert into dataOut;
from dataIn[id != "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -18,3 +18,6 @@ insert into dataOut;
from dataIn[speed < $speedAlertValue and id == "$deviceId"] from dataIn[speed < $speedAlertValue and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information
insert into dataOut; insert into dataOut;
from dataIn[id != "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -18,3 +18,6 @@ insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"] from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut; insert into dataOut;
from dataIn[id != "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright WSO2, Inc. (http://wso2.com) ~ Copyright WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2005-2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com) ~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright WSO2, Inc. (http://wso2.com) ~ Copyright WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<!-- <!--
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -2,6 +2,7 @@
"appContext": "/devicemgt/", "appContext": "/devicemgt/",
"isCloud": false, "isCloud": false,
"isDeviceOwnerEnabled": false, "isDeviceOwnerEnabled": false,
"managerHTTPSURL": "https://%iot.manager.host%:%iot.manager.https.port%",
"httpsURL": "https://%iot.gateway.host%:%iot.gateway.https.port%", "httpsURL": "https://%iot.gateway.host%:%iot.gateway.https.port%",
"httpURL": "http://%iot.gateway.host%:%iot.gateway.http.port%", "httpURL": "http://%iot.gateway.host%:%iot.gateway.http.port%",
"wssURL": "https://%iot.analytics.host%:%iot.analytics.https.port%", "wssURL": "https://%iot.analytics.host%:%iot.analytics.https.port%",

@ -116,6 +116,11 @@ var invokers = function () {
log.debug("Request payload if any : " + stringify(requestPayload)); log.debug("Request payload if any : " + stringify(requestPayload));
log.debug("Response status : " + xmlHttpRequest.status); log.debug("Response status : " + xmlHttpRequest.status);
log.debug("Response payload if any : " + xmlHttpRequest.responseText); log.debug("Response payload if any : " + xmlHttpRequest.responseText);
if (devicemgtProps["isCloud"]) {
log.info("Request : " + httpMethod + " " + endpoint);
log.info("Request payload if any : " + stringify(requestPayload));
log.info("Response status : " + xmlHttpRequest.status);
}
if (xmlHttpRequest.status == 401) { if (xmlHttpRequest.status == 401) {
if ((xmlHttpRequest.responseText == TOKEN_EXPIRED || if ((xmlHttpRequest.responseText == TOKEN_EXPIRED ||

@ -12,6 +12,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
{{unit "cdmf.unit.ui.title" pageTitle="Advanced Search"}}
{{unit "cdmf.unit.ui.modal"}} {{unit "cdmf.unit.ui.modal"}}
{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
@ -81,7 +82,7 @@
required.</label> required.</label>
</div> </div>
<div class="col-md-2 form-group wr-input-control col-fixed-right"> <div class="col-md-2 form-group wr-input-control col-fixed-right">
<button id="device-search-btn" class="wr-btn-search ">Search</button> <button id="device-search-btn add-custom-param" class="wr-btn">Search</button>
</div> </div>
</div> </div>

@ -259,7 +259,7 @@ function loadDevices(searchType, searchParam) {
var columns = [ var columns = [
{ {
targets: 0, targets: 0,
data: 'name', data: 'namePattern',
class: 'remove-padding icon-only content-fill viewEnabledIcon', class: 'remove-padding icon-only content-fill viewEnabledIcon',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<div class="thumbnail icon"><img class="square-element text fw " src="' return '<div class="thumbnail icon"><img class="square-element text fw " src="'
@ -471,7 +471,8 @@ function loadDevices(searchType, searchParam) {
ownership: data.devices[index].enrolmentInfo.ownership, ownership: data.devices[index].enrolmentInfo.ownership,
deviceType: data.devices[index].type, deviceType: data.devices[index].type,
deviceIdentifier: data.devices[index].deviceIdentifier, deviceIdentifier: data.devices[index].deviceIdentifier,
name: data.devices[index].name name: data.devices[index].name,
namePattern: data.devices[index].name
} }
); );
}); });
@ -497,15 +498,15 @@ function loadDevices(searchType, searchParam) {
attachDeviceEvents(); attachDeviceEvents();
// if ($('.advance-search').length < 1) { if ($('.advance-search').length < 1) {
// $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
// .after('<a href="' + context + '/devices/search"' + .after('<a href="' + context + '/devices/search"' +
// ' class="advance-search add-padding-3x">Advance Search</a>'); ' class="advance-search add-padding-3x">Advanced Search</a>');
// } }
}, { }, {
"placeholder": "Search By Device Name", "placeholder": "Top-Device-Name-Search",
"searchKey": "name" "searchKey": "namePattern"
} }
); );
@ -567,6 +568,9 @@ $(document).ready(function () {
} }
}); });
//Hide the search by device-name input
$("input[placeholder='Top-Device-Name-Search']").hide();
}); });
var modalPopup = ".modal"; var modalPopup = ".modal";
@ -891,7 +895,7 @@ function removeDevices(deviceIdentifiers) {
var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id; var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id;
invokerUtil.delete(serviceURL, function (message) { invokerUtil.delete(serviceURL, function (message) {
if (deviceIdentifiers.length > 1) { if (deviceIdentifiers.length > 1) {
deviceIdentifiers.slice(1, deviceIdentifiers.length); deviceIdentifiers.shift();
removeDevices(deviceIdentifiers); removeDevices(deviceIdentifiers);
} else { } else {
$(modalPopupContent).html($('#remove-device-200-content').html()); $(modalPopupContent).html($('#remove-device-200-content').html());

@ -73,18 +73,7 @@
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Group was created successfully.</p> <p class="page-sub-title">Group was created successfully.</p>
<br>Please click <b>"Add Another Group"</b>, if you wish to add another group or click <br>You will be redirected to the Group Listing page in a moment.
<b>"View Group List"</b> to complete the process and go back to the group list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/groups'">View Group List
</button>
<a href="{{@app.context}}/group/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another Group
</a>
</div> </div>
</div> </div>

@ -47,6 +47,9 @@ $(function () {
if (resp.status == 201) { if (resp.status == 201) {
$("#group-create-form").addClass("hidden"); $("#group-create-form").addClass("hidden");
$("#group-created-msg").removeClass("hidden"); $("#group-created-msg").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/groups";
}, 1000);
} else { } else {
displayErrors(resp.status); displayErrors(resp.status);
} }

@ -22,6 +22,10 @@
{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.lib.ui-permissions-utility"}} {{unit "cdmf.unit.lib.ui-permissions-utility"}}
{{#zone "topCss"}}
{{css "css/groups.css"}}
{{/zone}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
<li> <li>
<a href="{{@app.context}}/"> <a href="{{@app.context}}/">
@ -83,7 +87,7 @@
<h3 class="text-muted"> <h3 class="text-muted">
<i class="fw fw-group fw-3x"></i> <i class="fw fw-group fw-3x"></i>
</h3> </h3>
<h3 class="text-muted">You don't have any device group. Let's add a new device group!</h3> <h3 class="text-muted">You don't have any device groups. Let's add a new device group!</h3>
{{#if permissions.ADD_GROUP}} {{#if permissions.ADD_GROUP}}
<h3> <h3>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
@ -232,7 +236,7 @@
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this group from your Group List?</h3> <h3>Do you really want to remove this group?</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-yes-link" class="btn-operations"> <a href="#" id="remove-group-yes-link" class="btn-operations">
@ -253,7 +257,7 @@
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully removed.</h3> <h3>Successfully removed the group.</h3>
</div> </div>
</div> </div>
</div> </div>
@ -280,11 +284,15 @@
<h4> <h4>
Enter new name and description for the group Enter new name and description for the group
<br><br> <br><br>
Name:
<br/>
<input type="text" id="edit-group-name" <input type="text" id="edit-group-name"
class="form-control modal-input operationDataKeys" placeholder="Group Name" class="form-control modal-input operationDataKeys" placeholder="Group Name"
value=""> value="">
</input> </input>
<br> <br>
Description:
<br/>
<input type="text" id="edit-group-description" <input type="text" id="edit-group-description"
class="form-control modal-input operationDataKeys" class="form-control modal-input operationDataKeys"
placeholder="Group Description" value=""> placeholder="Group Description" value="">

@ -0,0 +1,3 @@
.dataTablesTop .dataTables_toolbar ul li:nth-child(1), .dataTables_toolbar ul li:nth-child(2) {
display: none;
}

@ -140,7 +140,7 @@ function loadRoles() {
} }
}, },
{ {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix",
data: null, data: null,
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
var isCloud = false; var isCloud = false;
@ -153,7 +153,9 @@ function loadRoles() {
var editLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' + var editLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' + 'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' + 'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-role-link">' + 'data-toggle="tooltip" ' +
'data-original-title="Edit Role"' +
'class="btn padding-reduce-on-grid-view edit-role-link"> ' +
'<span class="fw-stack">' + '<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' + '<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-bookmark fw-stack-1x"></i>' + '<i class="fw fw-bookmark fw-stack-1x"></i>' +
@ -167,7 +169,9 @@ function loadRoles() {
var editPermissionLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' + var editPermissionLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' + 'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' + 'data-click-event="edit-form " ' +
'data-toggle="tooltip" ' +
'data-original-title="Edit Permission"' +
'class="btn padding-reduce-on-grid-view edit-permission-link">' + 'class="btn padding-reduce-on-grid-view edit-permission-link">' +
'<span class="fw-stack">' + '<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' + '<i class="fw fw-circle-outline fw-stack-2x"></i>' +
@ -182,6 +186,8 @@ function loadRoles() {
var removeLink = '<a data-role="' + data.name + '" ' + var removeLink = '<a data-role="' + data.name + '" ' +
'data-click-event="remove-form" ' + 'data-click-event="remove-form" ' +
'data-toggle="tooltip" ' +
'data-original-title="Remove"' +
'class="btn padding-reduce-on-grid-view remove-role-link">' + 'class="btn padding-reduce-on-grid-view remove-role-link">' +
'<span class="fw-stack">' + '<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' + '<i class="fw fw-circle-outline fw-stack-2x"></i>' +
@ -272,4 +278,7 @@ $("#role-grid").on("click", ".remove-role-link", function () {
$(document).ready(function () { $(document).ready(function () {
loadRoles(); loadRoles();
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
}); });

@ -16,7 +16,7 @@
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="User Management | Add User"}} {{unit "cdmf.unit.ui.title" pageTitle="User Management | Add User"}}
{{unit "cdmf.unit.ui.modal"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
<li> <li>
<a href="{{@app.context}}/"> <a href="{{@app.context}}/">
@ -122,26 +122,14 @@
<button id="add-user-btn" class="wr-btn">Add User</button> <button id="add-user-btn" class="wr-btn">Add User</button>
</div> </div>
</div> </div>
<div id="user-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<p class="page-sub-title">User was added successfully.</p>
<p>
An invitation mail will be sent to this user to initiate device enrollment.
</p>
<br>Please click <b>"Add Another User"</b>, if you wish to add another user or click <div id="modal-content-user-created" class="hide">
<b>"View User List"</b> to complete the process and go back to the user list. <div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<hr/> <i class="icon fw fw-error"></i><span></span>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button>
<a href="{{@app.context}}/user/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another User
</a>
</div> </div>
<h4>
An invitation mail will be sent to this user to initiate device enrollment.
</h4>
</div> </div>
<!-- /content --> <!-- /content -->
</div> </div>

@ -226,7 +226,7 @@ $(document).ready(function () {
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();
var lastname = lastnameInput.val(); var lastname = lastnameInput.val();
var emailAddress = $("input#emailAddress").val(); var emailAddress = $("input#emailAddress").val();
var roles ; var roles;
if ($("#roles").length > 0) { if ($("#roles").length > 0) {
roles = $("select#roles").val(); roles = $("select#roles").val();
} }
@ -282,7 +282,13 @@ $(document).ready(function () {
} }
// Refreshing with success message // Refreshing with success message
$("#user-create-form").addClass("hidden"); $("#user-create-form").addClass("hidden");
$("#user-created-msg").removeClass("hidden"); modalDialog.header('<span class="fw-stack">' +
'<i class="fw fw-info fw-stack-1x"></i> </span> User was added successfully');
modalDialog.content($("#modal-content-user-created").html());
modalDialog.footer('<div class="buttons"> ' +
'<a href="/devicemgt/users" id="reset-password-yes-link" class="btn-operations"> OK' +
'</a></div>');
modalDialog.show();
generateQRCode("#user-created-msg .qr-code"); generateQRCode("#user-created-msg .qr-code");
} }

@ -123,18 +123,7 @@
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">User was updated successfully.</p> <p class="page-sub-title">User was updated successfully.</p>
<br>Please click <b>"View Updated User"</b>, if you wish to view the updated user or click <br>You will be redirected to User Listing Page in a moment.
<b>"View User List"</b> to complete the process and go back to the user list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button>
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View Updated User
</a>
</div> </div>
</div> </div>
<!-- /content --> <!-- /content -->

@ -248,6 +248,10 @@ $(document).ready(function () {
// Refreshing with success message // Refreshing with success message
$("#user-create-form").addClass("hidden"); $("#user-create-form").addClass("hidden");
$("#user-created-msg").removeClass("hidden"); $("#user-created-msg").removeClass("hidden");
setTimeout(function () {
window.location.href = "/devicemgt/users"
}, 1000);
} }
}, function (jqXHR) { }, function (jqXHR) {
var payload = JSON.parse(jqXHR.responseText); var payload = JSON.parse(jqXHR.responseText);

@ -89,10 +89,11 @@ $("a#invite-user-link").click(function () {
modalDialog.hide(); modalDialog.hide();
}); });
}, },
function () { function (data) {
var msg = JSON.parse(data.responseText);
modalDialog.header('<span class="fw-stack"> <i class="fw fw-circle-outline fw-stack-2x"></i> <i class="fw ' + modalDialog.header('<span class="fw-stack"> <i class="fw fw-circle-outline fw-stack-2x"></i> <i class="fw ' +
'fw-error fw-stack-1x"></i> </span> Unexpected Error !'); 'fw-error fw-stack-1x"></i> </span> Unexpected Error !');
modalDialog.content('An unexpected error occurred. Try again later.'); modalDialog.content(msg.message);
modalDialog.footer('<div class="buttons"><a href="#" id="invite-user-error-link" ' + modalDialog.footer('<div class="buttons"><a href="#" id="invite-user-error-link" ' +
'class="btn-operations">Ok </a></div>'); 'class="btn-operations">Ok </a></div>');
$("a#invite-user-error-link").click(function () { $("a#invite-user-error-link").click(function () {
@ -157,7 +158,7 @@ function resetPassword(username) {
domain = username.substr(0, username.indexOf('/')); domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1); username = username.substr(username.indexOf('/') + 1);
} }
var resetPasswordServiceURL = apiBasePath + "/admin/users/" + username + "/credentials"; var resetPasswordServiceURL = apiBasePath + "/admin/users/" + encodeURIComponent(username) + "/credentials";
if (domain) { if (domain) {
resetPasswordServiceURL += '?domain=' + encodeURIComponent(domain); resetPasswordServiceURL += '?domain=' + encodeURIComponent(domain);
} }

@ -128,7 +128,7 @@
cursor: pointer; cursor: pointer;
position: relative; position: relative;
margin-left: 10px; margin-left: 10px;
ma margin-bottom: 10px;
} }
.tab-actions .action{ .tab-actions .action{
float: right; float: right;
@ -142,6 +142,7 @@
} }
.tab-actions { .tab-actions {
margin: 0px; margin: 0px;
margin-bottom: 10px;
} }
.tab-actions .action-prop{ .tab-actions .action-prop{
padding: 10px; padding: 10px;

@ -33,7 +33,6 @@ $(document).ready(function() {
loadPolicyCompliance(); loadPolicyCompliance();
} }
$("#refresh-policy").click(function() { $("#refresh-policy").click(function() {
$('#policy-spinner').removeClass('hidden'); $('#policy-spinner').removeClass('hidden');
loadPolicyCompliance(); loadPolicyCompliance();
@ -44,8 +43,26 @@ $(document).ready(function() {
loadOperationsLog(true); loadOperationsLog(true);
}); });
$("#refresh-apps").click(function() {
$('#apps-spinner').removeClass('hidden');
loadApplicationsList();
});
}); });
function getLogStatusIcon(entry) {
switch (entry) {
case 'COMPLETED':
return 'fw-success';
case 'PENDING':
return 'fw-pending';
case 'ERROR':
return 'fw-error';
default:
return 'fw-info'
}
}
function loadOperationsLog(update) { function loadOperationsLog(update) {
var operationsLogTable = "#operation-log"; var operationsLogTable = "#operation-log";
if (update) { if (update) {
@ -95,7 +112,7 @@ function loadOperationsLog(update) {
data: "status", data: "status",
class: "text-right extended-log-data log-record-status", class: "text-right extended-log-data log-record-status",
render: function(data, type, full, meta) { render: function(data, type, full, meta) {
return '<i class="icon fw fw-success"></i><span> ' + data + ' </span><i class="icon fw fw-down"></i>'; return '<i class="icon fw ' + getLogStatusIcon(data) + '"> </i><span> ' + data + ' </span><i class="icon fw fw-down"></i>';
}, },
width: "100%" width: "100%"
} }
@ -146,13 +163,19 @@ function loadOperationsLog(update) {
function renderLogDetails(obj,data) { function renderLogDetails(obj,data) {
var payload = JSON.parse(data); var payload = JSON.parse(data);
var logStream = '<div class="log-data">'; var logStream = '<div class="log-data">';
var activityStatus = payload.activityStatus;
var responseMsg = null;
if (activityStatus['0'].status == "ERROR") {
responseMsg = activityStatus['0'].responses['0'].response;
}
Object.entries(payload.activityStatus).forEach( Object.entries(activityStatus).forEach(
([key, entry]) => { ([key, entry]) => {
logStream += '<div class="row log-entry">' + logStream += '<div class="row log-entry">' +
'<div class="col-lg-8">' + '<div class="col-lg-8">' +
'<div class="log-status"><i class="icon fw ' + getLogStatusIcon(entry.status) + ' "></i>' + '<div class="log-status"><i class="icon fw ' + getLogStatusIcon(entry.status) + ' "></i>' +
'<span>' + entry.status + '</span></div>' + '<span>' + ((responseMsg == null) ? entry.status : responseMsg) + '</span></div>' +
'</div>' + '</div>' +
'<div class="col-lg-4">' + '<div class="col-lg-4">' +
'<div class="log-time text-right"><span>' + entry.updatedTimestamp + '</span></div>' + '<div class="log-time text-right"><span>' + entry.updatedTimestamp + '</span></div>' +
@ -166,11 +189,11 @@ function loadOperationsLog(update) {
function getLogStatusIcon(entry) { function getLogStatusIcon(entry) {
switch (entry) { switch (entry) {
case 'COMPLETED': case 'COMPLETED':
return 'fw-success' return 'fw-success';
break;
case 'PENDING': case 'PENDING':
return 'fw-pending' return 'fw-pending';
break; case 'ERROR':
return 'fw-error';
default: default:
return 'fw-info' return 'fw-info'
} }
@ -254,3 +277,47 @@ function loadPolicyCompliance() {
} }
); );
} }
function loadApplicationsList() {
var applicationsList = $("#applications-list");
var applicationListingTemplate = applicationsList.attr("src");
var deviceId = applicationsList.data("device-id");
var deviceType = applicationsList.data("device-type");
$.template("application-list", applicationListingTemplate, function (template) {
var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications";
invokerUtil.get(
serviceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data);
$("#apps-spinner").addClass("hidden");
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
data[i]["name"] = decodeURIComponent(data[i]["name"]);
data[i]["platform"] = deviceType;
}
var viewModel = {};
viewModel["applications"] = data;
viewModel["deviceType"] = deviceType;
viewModel["deviceId"] = deviceId;
viewModel["appContext"] = context;
var content = template(viewModel);
$("#applications-list-container").html(content);
var iconSource = $("#applications-list-container").data("public-uri") + "/img/android_app_icon.png";
$("#applications-list-container img").attr("src",iconSource);
} else {
$("#applications-list-container").html("<div class='message message-info'><h4><i class='icon fw fw-info'></i>No applications found.</h4>" +
"<p>Please try refreshing the list in a while.</p></div>");
}
}
},
// error-callback
function () {
$("#applications-list-container").html("<div class='panel-body'><br><p class='fw-warning'>&nbsp;Loading application list " +
"was not successful. please try refreshing the list in a while.<p></div>");
});
});
}

@ -431,3 +431,76 @@ function viewFence(geoFenceElement,id) {
} }
closeAll(); closeAll();
} }
function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
var matchResults = /(?:"geoFenceGeoJSON"):"{(.*)}"/g.exec(geoJson);
if (matchResults && matchResults.length > 1) {
geoJson = "{" + matchResults[1] + "}";
}
geoJson = JSON.parse(geoJson.replace(/'/g, '"'));
var geometryShape;
if(geoJson.type=="Point"){
var circleOptions = {
color: '#ff0043'
};
geometryShape= new L.circle([geoJson.coordinates[1],geoJson.coordinates[0]], geoJson.radius,circleOptions);
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
map.addLayer(geometryShape);
// map.addLayer(marker);
} else if(geoJson.type=="Polygon"){
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
var leafletLatLngs = [];
$.each(geoJson.coordinates[0], function (idx, pItem) {
leafletLatLngs.push({lat: pItem[1], lng: pItem[0]});
});
geometryShape = new L.Polygon(leafletLatLngs);
map.addLayer(geometryShape);
}
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
if(id=="Stationery"){
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
var popupTemplate = $('#templateLoader').find('#viewStationeryAlert');
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#viewAreaTime').html(stationeryTime);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
});
} else if(id=="WithIn"){
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#viewAreaName').html(areaName);
popupTemplate.find('#withinAlertForm').attr('area-name', areaName);
popupTemplate.find('#withinAlertForm').attr('query-name', queryName);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
});
} else if(id=="Exit"){
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
popupTemplate.find('#viewAreaName').html(areaName);
popupTemplate.find('#exitAlertForm').attr('area-name', areaName);
popupTemplate.find('#exitAlertForm').attr('query-name', queryName);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
});
} else if(id=="Traffic"){
}
closeAll();
}

@ -264,6 +264,7 @@ function setWithinAlert(leafletId) {
} else { } else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g; var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g;
var errorTxt; var errorTxt;
var result = (ptrn.exec(data));
if (result) { if (result) {
errorTxt = result.length > 1 ? result[1] : data; errorTxt = result.length > 1 ? result[1] : data;
} else { } else {
@ -277,6 +278,7 @@ function setWithinAlert(leafletId) {
responseHandler, function (xhr) { responseHandler, function (xhr) {
responseHandler(xhr.responseText, xhr.statusText, xhr); responseHandler(xhr.responseText, xhr.statusText, xhr);
}); });
viewFenceByData(selectedAreaGeoJson, queryName, areaName, null, 'Within');
} }
} }
@ -320,6 +322,7 @@ function setExitAlert(leafletId) {
} else { } else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g; var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g;
var errorTxt; var errorTxt;
var result = (ptrn.exec(data));
if (result) { if (result) {
errorTxt = result.length > 1 ? result[1] : data; errorTxt = result.length > 1 ? result[1] : data;
} else { } else {
@ -333,6 +336,7 @@ function setExitAlert(leafletId) {
responseHandler, function (xhr) { responseHandler, function (xhr) {
responseHandler(xhr.responseText, xhr.statusText, xhr); responseHandler(xhr.responseText, xhr.statusText, xhr);
}); });
viewFenceByData(selectedAreaGeoJson, queryName, areaName, null, 'Exit');
} }
} }
@ -391,6 +395,7 @@ function setStationeryAlert(leafletId) {
} else { } else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g; var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g;
var errorTxt; var errorTxt;
var result = (ptrn.exec(data));
if (result) { if (result) {
errorTxt = result.length > 1 ? result[1] : data; errorTxt = result.length > 1 ? result[1] : data;
} else { } else {
@ -404,6 +409,7 @@ function setStationeryAlert(leafletId) {
responseHandler, function (xhr) { responseHandler, function (xhr) {
responseHandler(xhr.responseText, xhr.statusText, xhr); responseHandler(xhr.responseText, xhr.statusText, xhr);
}); });
viewFenceByData(selectedProcessedAreaGeoJson, queryName, areaName, time, 'Stationery');
} }
@ -499,6 +505,7 @@ function setTrafficAlert(leafletId) {
} else { } else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g; var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g;
var errorTxt; var errorTxt;
var result = (ptrn.exec(data));
if (result) { if (result) {
errorTxt = result.length > 1 ? result[1] : data; errorTxt = result.length > 1 ? result[1] : data;
} else { } else {
@ -603,6 +610,7 @@ function setProximityAlert() {
} else { } else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g; var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g;
var errorTxt; var errorTxt;
var result = (ptrn.exec(data));
if (result) { if (result) {
errorTxt = result.length > 1 ? result[1] : data; errorTxt = result.length > 1 ? result[1] : data;
} else { } else {

@ -27,26 +27,37 @@
Platform Configurations Platform Configurations
</h1> </h1>
<br> <br>
General and Platform Specific Server Settings for the Tenant {{#if isCloud}}
iOS Mobile Management Specific Server Settings for the Tenant
{{else}}
General and Platform Specific Server Settings for the Tenant
{{/if}}
<br> <br>
<br> <br>
<div class="wr-advance-operations"> <div class="wr-advance-operations">
<div class="row no-gutter"> <div class="row no-gutter">
<div class="wr-hidden-operations-nav col-lg-4"> <div class="wr-hidden-operations-nav col-lg-4">
<a id="generalConfigLink" href="javascript:void(0)" onclick="showAdvanceOperation('general', this)" class="selected">
<span class="wr-hidden-operations-icon fw-stack"> {{#unless isCloud}}
<i class="fw fw-settings fw-stack-2x"></i> <a id="generalConfigLink" href="javascript:void(0)" onclick="showAdvanceOperation('general', this)" class="selected">
<span class="fw-stack fw-move-right fw-move-bottom"> <span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i> <i class="fw fw-settings fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x"></i> <span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-mobile fw-stack-1x fw-inverse"></i> <i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-mobile fw-stack-1x fw-inverse"></i>
</span>
</span> </span>
</span> General Configurations
General Configurations </a>
</a> {{/unless}}
{{#each deviceTypes}} {{#each deviceTypes}}
<a id="{{name}}ConfigLink" href="javascript:void(0)" onclick="showAdvanceOperation('{{name}}', this)"> <a id="{{name}}ConfigLink" href="javascript:void(0)" onclick="showAdvanceOperation('{{name}}', this)"
{{#if isCloud}}
class="selected"
{{/if}} >
<span class="wr-hidden-operations-icon fw-stack"> <span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-settings fw-stack-2x"></i> <i class="fw fw-settings fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom"> <span class="fw-stack fw-move-right fw-move-bottom">
@ -62,50 +73,52 @@
<div class="wr-hidden-operations-content col-lg-8"> <div class="wr-hidden-operations-content col-lg-8">
<!-- general --> <!-- general -->
<div class="wr-hidden-operation" data-operation="general" style="display: block"> {{#unless isCloud}}
<div class="panel panel-default"> <div class="wr-hidden-operation" data-operation="general" style="display: block">
<div id="general-config-heading" class="panel-heading" role="tab"> <div class="panel panel-default">
<h2 class="sub-title panel-title"> <div id="general-config-heading" class="panel-heading" role="tab">
Policy Monitoring <h2 class="sub-title panel-title">
</h2> Policy Monitoring
</div> </h2>
<div id="email-config-body" class="panel-collapse panel-body"
role="tabpanel">
<div id="email-config-error-msg"
class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div> </div>
<div class="wr-input-control"> <div id="email-config-body" class="panel-collapse panel-body"
<label class="wr-input-label" for="email-config-host"> role="tabpanel">
Monitoring Frequency <div id="email-config-error-msg"
<span class="helper" title="SMTP Server Host"> class="alert alert-danger hidden" role="alert">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> <i class="icon fw fw-error"></i><span></span>
</span> </div>
<br> <div class="wr-input-control">
( Should be in seconds ) <label class="wr-input-label" for="email-config-host">
</label> Monitoring Frequency
<input id="monitoring-config-frequency" type="text" <span class="helper" title="SMTP Server Host">
class="form-control" <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
placeholder="[ Required Field ]"> </span>
<br>
( Should be in seconds )
</label>
<input id="monitoring-config-frequency" type="text"
class="form-control"
placeholder="[ Required Field ]">
</div>
<div class="wr-input-control wr-btn-grp">
<button id="save-general-btn" class="wr-btn">Save</button>
</div>
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div id="general-config-heading" role="tab">
<button id="save-general-btn" class="wr-btn">Save</button> <h2 class="sub-title panel-title">
Geo Analytics
</h2>
</div> </div>
</div> <div class="panel-collapse panel-body" role="tabpanel">
<div id="general-config-heading" role="tab"> <div class="wr-input-control">
<h2 class="sub-title panel-title"> <button class="wr-btn" onclick="artifactGeoUpload();">
Geo Analytics Deploy Geo Analytics Artifacts
</h2> </button>
</div> </div>
<div class="panel-collapse panel-body" role="tabpanel">
<div class="wr-input-control">
<button class="wr-btn" onclick="artifactGeoUpload();">
Deploy Geo Analytics Artifacts
</button>
</div> </div>
</div> </div>
</div> </div>
</div> {{/unless}}
<!-- general--> <!-- general-->
{{#each deviceTypes}} {{#each deviceTypes}}
<div class="wr-hidden-operation" data-operation="{{name}}" style="display: none;"> <div class="wr-hidden-operation" data-operation="{{name}}" style="display: none;">

@ -18,6 +18,7 @@
function onRequest(context) { function onRequest(context) {
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
//get all device types //get all device types
var isAuthorized = false; var isAuthorized = false;
@ -49,6 +50,7 @@ function onRequest(context) {
} }
return { return {
"deviceTypes": deviceTypesArray, "deviceTypes": deviceTypesArray,
"isAuthorized": isAuthorized "isAuthorized": isAuthorized,
"isCloud": mdmProps["isCloud"]
}; };
} }

@ -38,23 +38,10 @@
<div class="col-centered policy-message hidden"> <div class="col-centered policy-message hidden">
<div class="wr-form"> <div class="wr-form">
<h1 id="policy-message-page-wizard-title" class="page-sub-title">Policy creation is <h1 id="policy-message-page-wizard-title" class="page-sub-title">
successful.</h1> Policy creation is successful.</h1>
<br>Please click <b>"Add Another Policy"</b>, if you wish to add another policy or click <br>You will be redirected to Policy Listing Page in a moment.
<b>"View policy list"</b> to complete the process and go back to the policy list.
<hr> <hr>
<button class="wr-btn wizard-stepper" data-current="policy-message"
data-direct="{{@app.context}}/policies/">
View policy list
</button>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add another policy
</a>
</div> </div>
</div> </div>
@ -82,9 +69,7 @@
<!--suppress HtmlFormInputWithoutLabel --> <!--suppress HtmlFormInputWithoutLabel -->
<input id="policy-name-input" class="form-control" type="text" value=""/> <input id="policy-name-input" class="form-control" type="text" value=""/>
<label class="error nameEmpty hidden" for="summary">Policy name is required <label class="error nameEmpty hidden" for="summary">Policy name is required
& and should be 1-to-30 characters long.</label>
Should be be 1-to-30
characters long.</label>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
@ -285,7 +270,7 @@
</div> </div>
{{#unless types}} {{#unless types}}
<h3><i class="icon fw fw-warning"></i> No compatible device types have been installed. <h3><i class="icon fw fw-warning"></i> No compatible device types have been installed.
Install device types to add policies.</h3> Install device types to add policies.</h3>
{{/unless}} {{/unless}}
<div class="row wr-tile-buttons-list"> <div class="row wr-tile-buttons-list">
<div class="wr-input-control"> <div class="wr-input-control">

@ -428,6 +428,10 @@ var savePolicy = function (policy, isActive, serviceURL) {
$(".add-policy").addClass("hidden"); $(".add-policy").addClass("hidden");
$(".policy-naming").addClass("hidden"); $(".policy-naming").addClass("hidden");
$(".policy-message").removeClass("hidden"); $(".policy-message").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/policies";
}, 1000);
}, },
function (data) { function (data) {
} }

@ -35,20 +35,8 @@
<div class="wr-form"> <div class="wr-form">
<h1 id="policy-message-page-wizard-title" class="page-sub-title">Policy is successfully <h1 id="policy-message-page-wizard-title" class="page-sub-title">Policy is successfully
re-configured.</h1> re-configured.</h1>
<br>Please click <b>"Add Another Policy"</b>, if you wish to add another policy or click <br>You will be redirected to Policy Listing page in a moment.
<b>"View policy list"</b> to complete the process and go back to the policy list. </div>
<hr>
<button class="wr-btn wizard-stepper" data-current="policy-message"
data-direct="{{@app.context}}/policies/">
View policy list
</button>
<a href="{{@app.context}}/policies/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add another policy
</a>
</div> </div>
</div> </div>

@ -495,6 +495,9 @@ var updatePolicy = function (policy, state) {
if (jqXHR.status == 200) { if (jqXHR.status == 200) {
$(".add-policy").addClass("hidden"); $(".add-policy").addClass("hidden");
$(".policy-message").removeClass("hidden"); $(".policy-message").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/policies";
}, 1000);
} }
}, },
// on error // on error
@ -513,6 +516,9 @@ var updatePolicy = function (policy, state) {
$(".add-policy").addClass("hidden"); $(".add-policy").addClass("hidden");
$(".policy-naming").addClass("hidden"); $(".policy-naming").addClass("hidden");
$(".policy-message").removeClass("hidden"); $(".policy-message").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/policies";
}, 1000);
} }
}, },
// on error // on error

@ -69,19 +69,8 @@
<div id="role-created-msg" class="container col-centered wr-content hidden"> <div id="role-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Permissions were assigned to the role successfully.</p> <p class="page-sub-title">Permissions were assigned to the role successfully.</p>
<br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click <br>You will be redirected to Roles Listing Page in a moment.
<b>"View Role List"</b> to complete the process and go back to the role list.
<hr /> <hr />
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
View Role List
</button>
<a href="{{@app.context}}/role/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another Role
</a>
</div> </div>
</div> </div>
<!-- /content --> <!-- /content -->

@ -184,6 +184,9 @@ $(document).ready(function () {
// Refreshing with success message // Refreshing with success message
$("#role-create-form").addClass("hidden"); $("#role-create-form").addClass("hidden");
$("#role-created-msg").removeClass("hidden"); $("#role-created-msg").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/roles";
}, 1000);
} }
}, function (data) { }, function (data) {
var payload = JSON.parse(data.responseText); var payload = JSON.parse(data.responseText);

@ -73,20 +73,7 @@
<div id="role-created-msg" class="container col-centered wr-content hidden"> <div id="role-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Role was updated successfully.</p> <p class="page-sub-title">Role was updated successfully.</p>
<br>Please click <b>"View Updated Role"</b>, if you wish to view the updated role or click <br>You will be redirected to Roles Listing Page in a moment.
<b>"View Role List"</b> to complete the process and go back to the role list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
View Role List
</button>
<a href="{{@app.context}}/roles/edit-role/{{role.roleName}}"
class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
View Updated Role
</a>
</div> </div>
</div> </div>
<!-- /content --> <!-- /content -->

@ -210,6 +210,9 @@ $(document).ready(function () {
// Refreshing with success message // Refreshing with success message
$("#role-create-form").addClass("hidden"); $("#role-create-form").addClass("hidden");
$("#role-created-msg").removeClass("hidden"); $("#role-created-msg").removeClass("hidden");
setTimeout(function() {
window.location.href = "/devicemgt/roles";
}, 1000);
} }
}, function (data) { }, function (data) {

@ -175,7 +175,7 @@
Upgrade Now Upgrade Now
</a> </a>
<a href="{{Main.Account.dropDown.[Request Extension].url}}" id="expire-req-ext-link" class="btn-operations"> <a href="{{Main.Account.dropDown.[Request Extension].url}}" id="expire-req-ext-link" class="btn-operations">
Request Exception Request Extension
</a> </a>
</div> </div>
</div> </div>

@ -75,6 +75,7 @@ function onRequest(context) {
//change menu item name //change menu item name
delete viewModal.Main.Account.color; delete viewModal.Main.Account.color;
delete viewModal.Main.Account["Request Extension"]; delete viewModal.Main.Account["Request Extension"];
viewModal.Main.Account.label = "Account";
} else if (!billingInfo.isPaidAccount) { } else if (!billingInfo.isPaidAccount) {
var accountContent = "Account"; var accountContent = "Account";
if (billingInfo.billingPlanStatus === status.ACTIVE || billingInfo.billingPlanStatus === status.EXTENDED) { if (billingInfo.billingPlanStatus === status.ACTIVE || billingInfo.billingPlanStatus === status.EXTENDED) {
@ -92,7 +93,7 @@ function onRequest(context) {
} else if (billingInfo.billingPlanStatus === status.INACTIVE) { } else if (billingInfo.billingPlanStatus === status.INACTIVE) {
isExpired = false; isExpired = false;
isTrial = true; isTrial = true;
accountContent = "Trial " + (trialPeriod) + " days tade"; accountContent = "Trial " + (trialPeriod) + " days to upgrade";
} }
//change menu item name //change menu item name
viewModal.Main.Account.label = accountContent; viewModal.Main.Account.label = accountContent;
@ -221,4 +222,4 @@ function onRequest(context) {
} }
return 0; return 0;
} }
} }

@ -86,7 +86,9 @@ $(document).ready(function () {
$("#change-password-success-link").click(function () { $("#change-password-success-link").click(function () {
hidePopup(); hidePopup();
}); });
window.location.href = "/devicemgt/logout"; setTimeout(function(){
window.location.href = "/devicemgt/logout";
},10000);
} }
}, function (jqXHR) { }, function (jqXHR) {
if (jqXHR.status == 400) { if (jqXHR.status == 400) {

@ -104,7 +104,7 @@
<hr> <hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x"> <div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<h5 class="text-center"> <h5 class="text-center">
You can now try to login using your new password. You will be logged out automatically, Please login using your new password.
</h5> </h5>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

@ -95,15 +95,35 @@
{{/if}} {{/if}}
{{#if permissions.TENANT_CONFIGURATION}} {{#if permissions.TENANT_CONFIGURATION}}
<li><a><i class="fw fw-settings"></i>Configuration Management</a> {{#if isCloud}}
<ul>
<li><a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a> <li>
</li> <a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>
<!-- todo change the permission and get the related permission --> Platform Configurations
<li><a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a> </a>
</li> </li>
</ul>
</li>
{{else}}
<li>
<a><i class="fw fw-settings"></i>Configuration Management</a>
<ul>
<li>
<a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>
Platform Configurations
</a>
</li>
<!-- todo change the permission and get the related permission -->
<li>
<a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>
Certificate Configurations
</a>
</li>
</ul>
</li>
{{/if}}
{{/if}} {{/if}}

@ -293,4 +293,20 @@ ul#noty_topRight_layout_container li{
a.new-notification { a.new-notification {
text-transform: capitalize; text-transform: capitalize;
} }
/**
* This is to fix the issue https://github.com/wso2/product-iots/issues/1354.
* Proper fix should be given for this.
*/
.modal {
z-index: 1000;
}
.modal-backdrop {
z-index: 999;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
color: #0f0f0f;
}

@ -1443,6 +1443,8 @@ footer a, footer a:hover {
} }
.message h4 .icon { .message h4 .icon {
display: block;
float: left;
padding-bottom: 3px; padding-bottom: 3px;
margin-right: 5px; margin-right: 5px;
} }
@ -6874,10 +6876,11 @@ select > option:hover {
} }
.dynamic-search-param { .dynamic-search-param {
background-color: lightgrey; background-color: #ffffff;
padding: 25px; padding: 25px;
border: 5px solid navy; border: 1px solid #bdbdbd;
margin: 25px; margin: 25px;
border-radius: 10px;
} }
.close-button-div { .close-button-div {

@ -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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -65,8 +65,13 @@ public class EmailSenderServiceImpl implements EmailSenderService {
for (String recipient : emailCtx.getRecipients()) { for (String recipient : emailCtx.getRecipients()) {
ContentProviderInfo info = emailCtx.getContentProviderInfo(); ContentProviderInfo info = emailCtx.getContentProviderInfo();
EmailData emailData; EmailData emailData;
String transportSenderName = "mailto";
try { try {
emailData = contentProvider.getContent(info.getTemplate(), info.getParams()); emailData = contentProvider.getContent(info.getTemplate(), info.getParams());
if(EmailSenderDataHolder.getInstance().getConfigurationContextService()
.getServerConfigContext().getAxisConfiguration().getTransportOut(transportSenderName) == null){
throw new EmailSendingFailedException("Email transport is not configured.");
}
} catch (ContentProcessingInterruptedException e) { } catch (ContentProcessingInterruptedException e) {
throw new EmailSendingFailedException("Error occurred while retrieving email content to be " + throw new EmailSendingFailedException("Error occurred while retrieving email content to be " +
"sent for recipient '" + recipient + "'", e); "sent for recipient '" + recipient + "'", e);

@ -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.66-SNAPSHOT</version> <version>3.0.93-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

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

Loading…
Cancel
Save