revert-70aa11f8
Shavindri 8 years ago
commit 1e32d5f89f

@ -18,7 +18,6 @@
package org.wso2.carbon.apimgt.application.extension.api; package org.wso2.carbon.apimgt.application.extension.api;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile; import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -28,9 +27,7 @@ import javax.ws.rs.core.Response;
/** /**
* This is the application registration service that exposed for apimApplicationRegistration * This is the application registration service that exposed for apimApplicationRegistration
*/ */
@API(name = "API Registration Service", version = "1.0.0",
context = "api-application-registration",
tags = {"devicemgt_admin"})
public interface ApiApplicationRegistrationService { public interface ApiApplicationRegistrationService {
/** /**

@ -30,6 +30,7 @@ import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.FaultGatewaysException; import org.wso2.carbon.apimgt.api.FaultGatewaysException;
import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.*;
import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.lcm.util.CommonUtil; import org.wso2.carbon.governance.lcm.util.CommonUtil;
@ -78,15 +79,17 @@ public class APIPublisherServiceImpl implements APIPublisherService {
+ api.getId().getVersion() + "'"); + api.getId().getVersion() + "'");
} }
} else { } else {
if (provider.getAPI(api.getId()).getStatus() == APIStatus.CREATED) { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) {
provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION); if (provider.getAPI(api.getId()).getStatus() == APIStatus.CREATED) {
} provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION);
api.setStatus(APIStatus.PUBLISHED); }
provider.updateAPI(api); api.setStatus(APIStatus.PUBLISHED);
if (log.isDebugEnabled()) { provider.updateAPI(api);
log.debug("An API already exists with the name '" + api.getId().getApiName() + if (log.isDebugEnabled()) {
"', context '" + api.getContext() + "' and version '" log.debug("An API already exists with the name '" + api.getId().getApiName() +
+ api.getId().getVersion() + "'. Thus, the API config is updated"); "', context '" + api.getContext() + "' and version '"
+ api.getId().getVersion() + "'. Thus, the API config is updated");
}
} }
} }
provider.saveSwagger20Definition(api.getId(), createSwaggerDefinition(api)); provider.saveSwagger20Definition(api.getId(), createSwaggerDefinition(api));

@ -32,6 +32,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(APIPublisherStartupHandler.class); private static final Log log = LogFactory.getLog(APIPublisherStartupHandler.class);
private static int retryTime = 2000; private static int retryTime = 2000;
private static final int CONNECTION_RETRY_FACTOR = 2; private static final int CONNECTION_RETRY_FACTOR = 2;
private static final int MAX_RETRY_COUNT = 5;
private static Stack<API> failedAPIsStack = new Stack<>(); private static Stack<API> failedAPIsStack = new Stack<>();
private static Stack<API> currentAPIsStack; private static Stack<API> currentAPIsStack;
@ -44,33 +45,49 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
@Override @Override
public void completedServerStartup() { public void completedServerStartup() {
// APIPublisherDataHolder.getInstance().setServerStarted(true); APIPublisherDataHolder.getInstance().setServerStarted(true);
// currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis(); currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis();
// Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
// @Override @Override
// public void run() { public void run() {
// if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
// log.debug("Server has just started, hence started publishing unpublished APIs"); log.debug("Server has just started, hence started publishing unpublished APIs");
// log.debug("Total number of unpublished APIs: " log.debug("Total number of unpublished APIs: "
// + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); + APIPublisherDataHolder.getInstance().getUnpublishedApis().size());
// } }
// publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); publisher = APIPublisherDataHolder.getInstance().getApiPublisherService();
// while (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty()) { int retryCount = 0;
// try { while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) {
// retryTime = retryTime * CONNECTION_RETRY_FACTOR; try {
// Thread.sleep(retryTime); retryTime = retryTime * CONNECTION_RETRY_FACTOR;
// } catch (InterruptedException te) { Thread.sleep(retryTime);
// log.error("Error occurred while sleeping", te); } catch (InterruptedException te) {
// } //do nothing.
// if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { }
// publishAPIs(currentAPIsStack, failedAPIsStack); Stack<API> failedApis;
// } else { if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) {
// publishAPIs(failedAPIsStack, currentAPIsStack); publishAPIs(currentAPIsStack, failedAPIsStack);
// } failedApis = failedAPIsStack;
// } } else {
// } publishAPIs(failedAPIsStack, currentAPIsStack);
// }); failedApis = currentAPIsStack;
// t.start(); }
retryCount++;
if (retryCount == MAX_RETRY_COUNT && !failedApis.isEmpty()) {
StringBuilder error = new StringBuilder();
error.append("Error occurred while publishing API ['");
while (!failedApis.isEmpty()) {
API api = failedApis.pop();
error.append(api.getId().getApiName() + ",");
}
error.append("']");
log.error(error.toString());
}
}
}
});
t.start();
} }
private void publishAPIs(Stack<API> apis, Stack<API> failedStack) { private void publishAPIs(Stack<API> apis, Stack<API> failedStack) {
@ -79,7 +96,6 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
try { try {
publisher.publishAPI(api); publisher.publishAPI(api);
} catch (Exception e) { } catch (Exception e) {
log.error("Error occurred while publishing API '" + api.getId().getApiName() + "'");
failedStack.push(api); failedStack.push(api);
} }
} }

@ -24,15 +24,12 @@ import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.*;
import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.core.util.Utils;
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementException;
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import java.util.*; import java.util.*;
@ -117,8 +114,6 @@ public class APIPublisherUtil {
// adding scopes to the api // adding scopes to the api
Set<URITemplate> uriTemplates = config.getUriTemplates(); Set<URITemplate> uriTemplates = config.getUriTemplates();
Map<String, Scope> apiScopes = new HashMap<>(); Map<String, Scope> apiScopes = new HashMap<>();
Scope existingScope;
String existingPermissions;
if (uriTemplates != null) { if (uriTemplates != null) {
// this creates distinct scopes list // this creates distinct scopes list
for (URITemplate template : uriTemplates) { for (URITemplate template : uriTemplates) {
@ -130,13 +125,6 @@ public class APIPublisherUtil {
} }
} }
Set<Scope> scopes = new HashSet<>(apiScopes.values()); Set<Scope> scopes = new HashSet<>(apiScopes.values());
// adding existing persisted roles to the scopes
try {
setExistingRoles(scopes);
} catch (ScopeManagementException | UserStoreException e) {
throw new APIManagementException("Error occurred while retrieving roles for the existing scopes");
}
// set current scopes to API // set current scopes to API
api.setScopes(scopes); api.setScopes(scopes);
@ -152,6 +140,7 @@ public class APIPublisherUtil {
} }
api.setUriTemplates(uriTemplates); api.setUriTemplates(uriTemplates);
} }
api.setCorsConfiguration(APIUtil.getDefaultCorsConfiguration());
return api; return api;
} }
@ -324,34 +313,4 @@ public class APIPublisherUtil {
return apiConfig; return apiConfig;
} }
/**
* This method is used to set the existing roles of the given scope.
*
* @param scopes List of scopes.
* @throws ScopeManagementException
*/
private static void setExistingRoles(Set<Scope> scopes) throws ScopeManagementException, UserStoreException {
String scopeKey;
String roles;
ScopeManagementService scopeManagementService = WebappPublisherUtil.getScopeManagementService();
UserRealm userRealm = WebappPublisherUtil.getUserRealm();
if (scopeManagementService == null) {
throw new ScopeManagementException("Error occurred while initializing scope management service");
} else if (userRealm == null) {
throw new UserStoreException("Error occurred while initializing realm service");
} else {
String adminRole = userRealm.getRealmConfiguration().getAdminRoleName();
for (Scope scope : scopes) {
scopeKey = scope.getKey();
roles = scopeManagementService.getRolesOfScope(scopeKey);
if (roles == null) {
roles = adminRole;
}
scope.setRoles(roles);
}
}
}
} }

@ -18,16 +18,7 @@
package org.wso2.carbon.apimgt.webapp.publisher; package org.wso2.carbon.apimgt.webapp.publisher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.user.core.service.RealmService;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -40,10 +31,6 @@ import java.io.File;
*/ */
public class WebappPublisherUtil { public class WebappPublisherUtil {
private static Log log = LogFactory.getLog(WebappPublisherUtil.class);
private static final int CARBON_SUPER = -1234;
public static Document convertToDocument(File file) throws WebappPublisherConfigurationFailedException { public static Document convertToDocument(File file) throws WebappPublisherConfigurationFailedException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
@ -57,32 +44,4 @@ public class WebappPublisherUtil {
} }
} }
public static ScopeManagementService getScopeManagementService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ScopeManagementService scopeManagementService =
(ScopeManagementService) ctx.getOSGiService(ScopeManagementService.class, null);
if (scopeManagementService == null) {
String msg = "Scope Management Service has not been initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return scopeManagementService;
}
/**
* Getting the current tenant's user realm
*/
public static UserRealm getUserRealm() throws UserStoreException {
RealmService realmService;
UserRealm realm;
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) {
throw new IllegalStateException("Realm service not initialized");
}
realm = realmService.getTenantUserRealm(CARBON_SUPER);
return realm;
}
} }

@ -40,6 +40,7 @@ public class WebappPublisherConfig {
private String host; private String host;
private boolean isPublished; private boolean isPublished;
private boolean isEnabledUpdateApi;
private Profiles profiles; private Profiles profiles;
private static WebappPublisherConfig config; private static WebappPublisherConfig config;
@ -77,6 +78,15 @@ public class WebappPublisherConfig {
return profiles; return profiles;
} }
@XmlElement(name = "EnabledUpdateApi", required = true)
public boolean isEnabledUpdateApi() {
return isEnabledUpdateApi;
}
public void setEnabledUpdateApi(boolean isEnabledUpdateApi) {
this.isEnabledUpdateApi = isEnabledUpdateApi;
}
public void setPublished(boolean published) { public void setPublished(boolean published) {
isPublished = published; isPublished = published;
} }

@ -49,72 +49,72 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
@Override @Override
public void lifecycleEvent(LifecycleEvent lifecycleEvent) { public void lifecycleEvent(LifecycleEvent lifecycleEvent) {
// if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance() if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance()
// .isPublished()) { .isPublished()) {
// StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); StandardContext context = (StandardContext) lifecycleEvent.getLifecycle();
// ServletContext servletContext = context.getServletContext(); ServletContext servletContext = context.getServletContext();
// String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED);
// boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param);
//
// String profile = System.getProperty(PROPERTY_PROFILE); String profile = System.getProperty(PROPERTY_PROFILE);
//
// if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase()) if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase())
// && isManagedApi) { && isManagedApi) {
// try { try {
// AnnotationProcessor annotationProcessor = new AnnotationProcessor(context); AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
// Set<String> annotatedAPIClasses = annotationProcessor. Set<String> annotatedAPIClasses = annotationProcessor.
// scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName()); scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName());
//
// List<APIResourceConfiguration> apiDefinitions = annotationProcessor.extractAPIInfo(servletContext, List<APIResourceConfiguration> apiDefinitions = annotationProcessor.extractAPIInfo(servletContext,
// annotatedAPIClasses); annotatedAPIClasses);
//
// for (APIResourceConfiguration apiDefinition : apiDefinitions) { for (APIResourceConfiguration apiDefinition : apiDefinitions) {
//
// APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition);
//
// try { try {
// int tenantId = APIPublisherDataHolder.getInstance().getTenantManager(). int tenantId = APIPublisherDataHolder.getInstance().getTenantManager().
// getTenantId(apiConfig.getTenantDomain()); getTenantId(apiConfig.getTenantDomain());
//
// boolean isTenantActive = APIPublisherDataHolder.getInstance(). boolean isTenantActive = APIPublisherDataHolder.getInstance().
// getTenantManager().isTenantActive(tenantId); getTenantManager().isTenantActive(tenantId);
//
// if (isTenantActive) { if (isTenantActive) {
// apiConfig.init(); apiConfig.init();
// API api = APIPublisherUtil.getAPI(apiConfig); API api = APIPublisherUtil.getAPI(apiConfig);
// boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted(); boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted();
// if (isServerStarted) { if (isServerStarted) {
// APIPublisherService apiPublisherService = APIPublisherService apiPublisherService =
// APIPublisherDataHolder.getInstance().getApiPublisherService(); APIPublisherDataHolder.getInstance().getApiPublisherService();
// if (apiPublisherService == null) { if (apiPublisherService == null) {
// throw new IllegalStateException( throw new IllegalStateException(
// "API Publisher service is not initialized properly"); "API Publisher service is not initialized properly");
// } }
// apiPublisherService.publishAPI(api); apiPublisherService.publishAPI(api);
// } else { } else {
// if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
// log.debug("Server has not started yet. Hence adding API '" + log.debug("Server has not started yet. Hence adding API '" +
// api.getId().getApiName() + "' to the queue"); api.getId().getApiName() + "' to the queue");
// } }
// APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api); APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api);
// } }
// } else { } else {
// log.error("No tenant [" + apiConfig.getTenantDomain() + "] " + log.error("No tenant [" + apiConfig.getTenantDomain() + "] " +
// "found when publishing the Web app"); "found when publishing the Web app");
// } }
// } catch (Throwable e) { } catch (Throwable e) {
// log.error("Error occurred while publishing API '" + apiConfig.getName() + log.error("Error occurred while publishing API '" + apiConfig.getName() +
// "' with the context '" + apiConfig.getContext() + "' with the context '" + apiConfig.getContext() +
// "' and version '" + apiConfig.getVersion() + "'", e); "' and version '" + apiConfig.getVersion() + "'", e);
// } }
// } }
// } catch (IOException e) { } catch (IOException e) {
// log.error("Error encountered while discovering annotated classes", e); log.error("Error encountered while discovering annotated classes", e);
// } catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// log.error("Error while scanning class for annotations", e); log.error("Error while scanning class for annotations", e);
// } }
// } }
// } }
} }
//TODO : Need to implemented, to merge API Definitions in cases where implementation of an API Lies in two classes //TODO : Need to implemented, to merge API Definitions in cases where implementation of an API Lies in two classes

@ -33,7 +33,7 @@ import javax.ws.rs.core.Response;
/** /**
* Activity related REST-API implementation. * Activity related REST-API implementation.
*/ */
@API(name = "Activity Info Provider", version = "1.0.0", context = "/api/device-mgt/v1.0/activities", tags = {"devicemgt_admin"}) @API(name = "ActivityInfoProvider", version = "1.0.0", context = "/api/device-mgt/v1.0/activities", tags = {"device_management"})
@Path("/activities") @Path("/activities")
@Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example operation details " + @Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example operation details " +

@ -31,7 +31,7 @@ import javax.ws.rs.core.Response;
/** /**
* General Tenant Configuration REST-API. * General Tenant Configuration REST-API.
*/ */
@API(name = "Configuration Management", version = "1.0.0", context = "/api/device-mgt/v1.0/configuration", tags = {"devicemgt_admin"}) @API(name = "ConfigurationManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/configuration", tags = {"device_management"})
@Path("/configuration") @Path("/configuration")
@Api(value = "Configuration Management", description = "The general platform configuration management capabilities are exposed " + @Api(value = "Configuration Management", description = "The general platform configuration management capabilities are exposed " +

@ -30,8 +30,8 @@ import javax.ws.rs.core.Response;
/** /**
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics. * Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
*/ */
@API(name = "Device Analytics Dashboard", @API(name = "DeviceAnalyticsDashboard",
version = "1.0.0", context = "/api/device-mgt/v1.0/dashboard", tags = {"devicemgt_admin"}) version = "1.0.0", context = "/api/device-mgt/v1.0/dashboard", tags = {"device_management"})
@Path("/dashboard") @Path("/dashboard")
@Api(value = "Device Analytics Dashboard", @Api(value = "Device Analytics Dashboard",

@ -39,7 +39,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device related REST-API. This can be used to manipulated device related details. * Device related REST-API. This can be used to manipulated device related details.
*/ */
@API(name = "Device Management", version = "1.0.0", context = "/api/device-mgt/v1.0/devices", tags = {"devicemgt_admin"}) @API(name = "DeviceManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/devices", tags = {"device_management"})
@Path("/devices") @Path("/devices")
@Api(value = "Device Management", description = "This API carries all device management related operations " + @Api(value = "Device Management", description = "This API carries all device management related operations " +

@ -39,8 +39,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "Device Type Management", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/device-types", @API(name = "DeviceTypeManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/device-types",
tags = {"devicemgt_admin"}) tags = {"device_management"})
@Path("/device-types") @Path("/device-types")
@Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " + @Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " +

@ -35,7 +35,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "Group Management", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"devicemgt_admin"}) @API(name = "GroupManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"})
@Path("/groups") @Path("/groups")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)

@ -35,8 +35,8 @@ import javax.ws.rs.core.Response;
/** /**
* Notifications related REST-API. * Notifications related REST-API.
*/ */
@API(name = "Device Notification Management", version = "1.0.0", context = "/api/device-mgt/v1.0/notifications", @API(name = "DeviceNotificationManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/notifications",
tags = {"devicemgt_admin"}) tags = {"device_management"})
@Api(value = "Device Notification Management", description = "Device notification related operations can be found here.") @Api(value = "Device Notification Management", description = "Device notification related operations can be found here.")
@Path("/notifications") @Path("/notifications")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)

@ -37,8 +37,8 @@ import java.util.List;
* Policy related REST-API. This can be used to manipulated policies and associate them with devices, users, roles, * Policy related REST-API. This can be used to manipulated policies and associate them with devices, users, roles,
* groups. * groups.
*/ */
@API(name = "Device Policy Management", version = "1.0.0", context = "/api/device-mgt/v1.0/policies", @API(name = "DevicePolicyManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/policies",
tags = {"devicemgt_admin"}) tags = {"device_management"})
@Api(value = "Device Policy Management", description = "This API includes the functionality around device policy management") @Api(value = "Device Policy Management", description = "This API includes the functionality around device policy management")
@Path("/policies") @Path("/policies")

@ -32,7 +32,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@API(name = "Role Management", version = "1.0.0", context = "/api/device-mgt/v1.0/roles", tags = {"devicemgt_admin"}) @API(name = "RoleManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/roles", tags = {"device_management"})
@Path("/roles") @Path("/roles")
@Api(value = "Role Management", description = "Role management related operations can be found here.") @Api(value = "Role Management", description = "Role management related operations can be found here.")

@ -29,7 +29,7 @@ import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@API(name = "User Management", version = "1.0.0", context = "/api/device-mgt/v1.0/users", tags = {"devicemgt_admin"}) @API(name = "UserManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/users", tags = {"device_management"})
@Path("/users") @Path("/users")
@Api(value = "User Management", description = "User management related operations can be found here.") @Api(value = "User Management", description = "User management related operations can be found here.")

@ -33,7 +33,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "Application Management Admin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/applications", tags = {"devicemgt_admin"}) @API(name = "ApplicationManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/applications", tags = {"device_management"})
@Path("/admin/applications") @Path("/admin/applications")
@Api(value = "Application Management Administrative Service", description = "This an API intended to be used by " + @Api(value = "Application Management Administrative Service", description = "This an API intended to be used by " +

@ -29,8 +29,8 @@ import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "Device Management Admin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/devices", @API(name = "DeviceManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/devices",
tags = {"devicemgt_admin"}) tags = {"device_management"})
@Path("/admin/devices") @Path("/admin/devices")
@Api(value = "Device Management Administrative Service", description = "This an API intended to be used by " + @Api(value = "Device Management Administrative Service", description = "This an API intended to be used by " +
"'internal' components to log in as an admin user and do a selected number of operations. " + "'internal' components to log in as an admin user and do a selected number of operations. " +

@ -37,7 +37,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "Group Management Admin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/groups", tags = {"devicemgt_admin"}) @API(name = "GroupManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/groups", tags = {"device_management"})
@Path("/admin/groups") @Path("/admin/groups")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)

@ -30,7 +30,7 @@ import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@API(name = "User Management Admin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/users", tags = {"devicemgt_admin"}) @API(name = "UserManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/users", tags = {"device_management"})
@Path("/admin/users") @Path("/admin/users")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)

@ -79,6 +79,8 @@ public class TaskConfiguration {
private String operationName; private String operationName;
private int recurrency; private int recurrency;
private List<String> platforms;
@XmlElement(name = "Name", required = true) @XmlElement(name = "Name", required = true)
public String getOperationName() { public String getOperationName() {
@ -97,5 +99,16 @@ public class TaskConfiguration {
public void setRecurrency(int recurrency) { public void setRecurrency(int recurrency) {
this.recurrency = recurrency; this.recurrency = recurrency;
} }
@XmlElementWrapper(name = "Platforms")
@XmlElement(name = "platform", required = true)
public List<String> getPlatforms() {
return platforms;
}
public void setPlatforms(List<String> platforms) {
this.platforms = platforms;
}
} }
} }

@ -57,14 +57,6 @@ public class DeviceManagementDataHolder {
private EmailSenderService emailSenderService; private EmailSenderService emailSenderService;
private PushNotificationProviderRepository pushNotificationProviderRepository; private PushNotificationProviderRepository pushNotificationProviderRepository;
public APIManagerConfiguration getApiManagerConfiguration() {
return apiManagerConfiguration;
}
public void setApiManagerConfiguration(APIManagerConfiguration apiManagerConfiguration) {
this.apiManagerConfiguration = apiManagerConfiguration;
}
private APIManagerConfiguration apiManagerConfiguration; private APIManagerConfiguration apiManagerConfiguration;
private DeviceManagementDataHolder() {} private DeviceManagementDataHolder() {}

@ -21,7 +21,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
@ -33,7 +32,6 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService; import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagerProviderServiceImpl; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagerProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
@ -51,7 +49,6 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository; import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -61,10 +58,8 @@ import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.ConfigurationContextService;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -120,10 +115,6 @@ public class DeviceManagementServiceComponent {
private static List<PluginInitializationListener> listeners = new ArrayList<>(); private static List<PluginInitializationListener> listeners = new ArrayList<>();
private static List<DeviceManagementService> deviceManagers = new ArrayList<>(); private static List<DeviceManagementService> deviceManagers = new ArrayList<>();
private static List<DeviceManagerStartupListener> startupListeners = new ArrayList<>(); private static List<DeviceManagerStartupListener> startupListeners = new ArrayList<>();
private DeviceManagementPluginRepository pluginRepository = new DeviceManagementPluginRepository();
private static final String APIM_CONFIGURATION_PATH = CarbonUtils.getCarbonHome() + File.separator + "repository" +
File.separator + "conf" + File.separator + "api-manager.xml";
private static final String DATA_SOURCE_NAME = "DataSourceName";
public static void registerPluginInitializationListener(PluginInitializationListener listener) { public static void registerPluginInitializationListener(PluginInitializationListener listener) {
synchronized (LOCK) { synchronized (LOCK) {
@ -157,18 +148,11 @@ public class DeviceManagementServiceComponent {
DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig(); DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig();
APIManagerConfiguration apiManagerConfiguration = new APIManagerConfiguration();
apiManagerConfiguration.load(APIM_CONFIGURATION_PATH);
DeviceManagementDataHolder.getInstance().setApiManagerConfiguration(apiManagerConfiguration);
DeviceManagementDAOFactory.init(dsConfig); DeviceManagementDAOFactory.init(dsConfig);
GroupManagementDAOFactory.init(dsConfig); GroupManagementDAOFactory.init(dsConfig);
NotificationManagementDAOFactory.init(dsConfig); NotificationManagementDAOFactory.init(dsConfig);
OperationManagementDAOFactory.init(dsConfig); OperationManagementDAOFactory.init(dsConfig);
String apiManagerDataSource = apiManagerConfiguration.getFirstProperty(DATA_SOURCE_NAME);
ScopeManagementDAOFactory.init(apiManagerDataSource);
/* Initialize Operation Manager */ /* Initialize Operation Manager */
this.initOperationsManager(); this.initOperationsManager();

@ -24,10 +24,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,6 +32,36 @@ import java.util.List;
* This class holds the Oracle implementation of NotificationDAO which can be used to support Oracle db syntax. * This class holds the Oracle implementation of NotificationDAO which can be used to support Oracle db syntax.
*/ */
public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl { public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
@Override
public int addNotification(int deviceId, int tenantId, Notification notification) throws
NotificationManagementException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs;
int notificationId = -1;
try {
conn = NotificationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION, TENANT_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql, new int[] { 1 });
stmt.setInt(1, deviceId);
stmt.setInt(2, notification.getOperationId());
stmt.setString(3, notification.getStatus().toString());
stmt.setString(4, notification.getDescription());
stmt.setInt(5, tenantId);
stmt.execute();
rs = stmt.getGeneratedKeys();
if (rs.next()) {
notificationId = rs.getInt(1);
}
} catch (Exception e) {
throw new NotificationManagementException(
"Error occurred while adding the " + "Notification for device id : " + deviceId, e);
} finally {
NotificationDAOUtil.cleanupResources(stmt, null);
}
return notificationId;
}
@Override @Override
public List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws public List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws

@ -314,7 +314,7 @@ public class OperationManagerImpl implements OperationManager {
deviceId.getId() + "'"); deviceId.getId() + "'");
} }
EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); EnrolmentInfo enrolmentInfo = this.getEnrolmentInfo(deviceId);
if (enrolmentInfo == null) { if (enrolmentInfo == null) {
throw new OperationManagementException("Device not found for given device " + throw new OperationManagementException("Device not found for given device " +
"Identifier:" + deviceId.getId() + " and given type" + "Identifier:" + deviceId.getId() + " and given type" +

@ -1,173 +0,0 @@
/*
* Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.scope.mgt;
import org.apache.commons.lang.StringUtils;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementException;
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAO;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOException;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOFactory;
import java.lang.annotation.Inherited;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* This is an implementation of a Scope Management Service.
*/
public class ScopeManagementServiceImpl implements ScopeManagementService {
private ScopeManagementDAO scopeManagementDAO;
public ScopeManagementServiceImpl() {
this.scopeManagementDAO = ScopeManagementDAOFactory.getScopeManagementDAO();
}
@Override
public void updateScopes(List<Scope> scopes) throws ScopeManagementException {
try {
ScopeManagementDAOFactory.beginTransaction();
scopeManagementDAO.updateScopes(scopes);
ScopeManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
ScopeManagementDAOFactory.rollbackTransaction();
throw new ScopeManagementException("Transactional error occurred while adding the scopes.", e);
} catch (ScopeManagementDAOException e) {
ScopeManagementDAOFactory.rollbackTransaction();
throw new ScopeManagementException("Error occurred while adding the scopes to database.", e);
} finally {
ScopeManagementDAOFactory.closeConnection();
}
}
@Override
public void updateScopes(List<String> scopeKeys, String roleName) throws ScopeManagementException {
List<Scope> scopes = new ArrayList<>();
try {
List<Scope> allScopes = this.getAllScopes();
for (Scope scope : allScopes) {
for (String key : scopeKeys) {
if (scope.getKey().equals(key)) {
scope.setRoles(scope.getRoles() + "," + roleName);
scopes.add(scope);
}
}
}
ScopeManagementDAOFactory.beginTransaction();
scopeManagementDAO.updateScopes(scopes);
ScopeManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
ScopeManagementDAOFactory.rollbackTransaction();
throw new ScopeManagementException("Transactional error occurred while adding the scopes.", e);
} catch (ScopeManagementDAOException e) {
ScopeManagementDAOFactory.rollbackTransaction();
throw new ScopeManagementException("Error occurred while adding the scopes to database.", e);
} finally {
ScopeManagementDAOFactory.closeConnection();
}
}
@Override
public List<Scope> getAllScopes() throws ScopeManagementException {
List<Scope> scopes = new ArrayList<>();
try {
ScopeManagementDAOFactory.openConnection();
scopes = scopeManagementDAO.getAllScopes();
} catch (SQLException e) {
throw new ScopeManagementException("SQL error occurred while retrieving scopes from database.", e);
} catch (ScopeManagementDAOException e) {
throw new ScopeManagementException("Error occurred while retrieving scopes from database.", e);
} finally {
ScopeManagementDAOFactory.closeConnection();
}
return scopes;
}
@Override
public String getRolesOfScope(String scopeKey) throws ScopeManagementException {
String roles;
if (scopeKey == null || scopeKey.isEmpty()) {
throw new ScopeManagementException("Scope key is null or empty");
}
try {
ScopeManagementDAOFactory.openConnection();
roles = scopeManagementDAO.getRolesOfScope(scopeKey);
} catch (SQLException e) {
throw new ScopeManagementException("SQL error occurred while retrieving roles of scope from database.", e);
} catch (ScopeManagementDAOException e) {
throw new ScopeManagementException("Error occurred while retrieving roles of scope from database.", e);
} finally {
ScopeManagementDAOFactory.closeConnection();
}
return roles;
}
@Override
public List<Scope> getScopesOfRole(String roleName) throws ScopeManagementException {
if (roleName == null || roleName.isEmpty()) {
throw new ScopeManagementException("Role name is null or empty");
}
List<Scope> filteredScopes = new ArrayList<>();
try {
ScopeManagementDAOFactory.openConnection();
List<Scope> allScopes = scopeManagementDAO.getScopesHavingRole(roleName);
String roles[];
for (Scope scope : allScopes) {
roles = scope.getRoles().split(",");
for (String role : roles) {
if (roleName.equals(role.trim())) {
filteredScopes.add(scope);
}
}
}
} catch (SQLException e) {
throw new ScopeManagementException("SQL error occurred while retrieving scopes of role from database.", e);
} catch (ScopeManagementDAOException e) {
throw new ScopeManagementException("Error occurred while retrieving scopes of role from database.", e);
} finally {
ScopeManagementDAOFactory.closeConnection();
}
return filteredScopes;
}
@Override
public void removeScopes(String roleName) throws ScopeManagementException {
List<Scope> scopes = this.getScopesOfRole(roleName);
String roles[];
ArrayList<String> filteredRoles = new ArrayList<>();
for (Scope scope : scopes) {
roles = scope.getRoles().split(",");
for (String role : roles) {
if (!roleName.equals(role.trim())) {
filteredRoles.add(role);
}
}
scope.setRoles(StringUtils.join(filteredRoles, ","));
filteredRoles.clear();
}
this.updateScopes(scopes);
}
}

@ -1,64 +0,0 @@
/*
* Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.scope.mgt.dao;
import org.wso2.carbon.apimgt.api.model.Scope;
import java.util.List;
/**
* This interface contains the basic database operations related to scope management.
*/
public interface ScopeManagementDAO {
/**
* This method is used to update the list of scopes.
*
* @param scopes List of scopes to be updated.
* @throws ScopeManagementDAOException
*/
void updateScopes(List<Scope> scopes) throws ScopeManagementDAOException;
/**
* This method is used to retrieve all the scopes.
*
* @return List of scopes.
* @throws ScopeManagementDAOException
*/
List<Scope> getAllScopes() throws ScopeManagementDAOException;
/**
* This method is to retrieve the roles of the given scope
* @param scopeKey key of the scope
* @return List of roles
* @throws ScopeManagementDAOException
*/
String getRolesOfScope(String scopeKey) throws ScopeManagementDAOException;
/**
* This method is to retrieve all the scopes of the given role name.
* Thus it returns the scopes even if the part of the given name is matched.
*
* @param roleName Role name
* @return List of scopes
* @throws ScopeManagementDAOException
*/
List<Scope> getScopesHavingRole(String roleName) throws ScopeManagementDAOException;
}

@ -1,57 +0,0 @@
/*
* Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.scope.mgt.dao;
public class ScopeManagementDAOException extends Exception {
private static final long serialVersionUID = -315127931137771199L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public ScopeManagementDAOException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public ScopeManagementDAOException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public ScopeManagementDAOException(String msg) {
super(msg);
setErrorMessage(msg);
}
public ScopeManagementDAOException() {
super();
}
public ScopeManagementDAOException(Throwable cause) {
super(cause);
}
}

@ -1,139 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.scope.mgt.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.IllegalTransactionStateException;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.impl.ScopeManagementDAOImpl;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
public class ScopeManagementDAOFactory {
private static final Log log = LogFactory.getLog(ScopeManagementDAOFactory.class);
private static DataSource dataSource;
private static String databaseEngine;
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
public static ScopeManagementDAO getScopeManagementDAO() {
return new ScopeManagementDAOImpl();
}
public static void init(String dataSourceName) {
dataSource = resolveDataSource(dataSourceName);
try {
databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName();
} catch (SQLException e) {
log.error("Error occurred while retrieving config.datasource connection", e);
}
}
public static void beginTransaction() throws TransactionManagementException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new TransactionManagementException(
"Error occurred while retrieving config.datasource connection", e);
}
}
public static void openConnection() throws SQLException {
currentConnection.set(dataSource.getConnection());
}
public static Connection getConnection() throws SQLException {
if (currentConnection.get() == null) {
throw new IllegalTransactionStateException("No connection is associated with the current transaction. " +
"This might have ideally caused by not properly initiating the transaction via " +
"'beginTransaction'/'openConnection' methods");
}
return currentConnection.get();
}
public static void closeConnection() {
Connection con = currentConnection.get();
if (con != null) {
try {
con.close();
} catch (SQLException e) {
log.error("Error occurred while close the connection");
}
currentConnection.remove();
}
}
public static void commitTransaction() {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.commit();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence commit " +
"has not been attempted");
}
}
} catch (SQLException e) {
log.error("Error occurred while committing the transaction", e);
}
}
public static void rollbackTransaction() {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.rollback();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence rollback " +
"has not been attempted");
}
}
} catch (SQLException e) {
log.error("Error occurred while roll-backing the transaction", e);
}
}
/**
* Resolve data source from the data source name.
*
* @param dataSourceName data source name
* @return data source resolved from the data source definition
*/
private static DataSource resolveDataSource(String dataSourceName) {
DataSource dataSource;
if (dataSourceName == null || dataSourceName.isEmpty()) {
throw new RuntimeException("Scope Management Repository data source configuration is null and " +
"thus, is not initialized");
}
if (log.isDebugEnabled()) {
log.debug("Initializing Scope Management Repository data source using the JNDI Lookup Definition");
}
dataSource = DeviceManagementDAOUtil.lookupDataSource(dataSourceName, null);
return dataSource;
}
}

@ -1,57 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.mgt.core.scope.mgt.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ScopeManagementDAOUtil {
private static final Log log = LogFactory.getLog(ScopeManagementDAOUtil.class);
public static void cleanupResources(Statement stmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
log.warn("Error occurred while closing the result set", e);
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Error occurred while closing the statement", e);
}
}
}
public static void cleanupResources(Statement stmt) {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Error occurred while closing the statement", e);
}
}
}
}

@ -1,148 +0,0 @@
/*
* Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.scope.mgt.dao.impl;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAO;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOException;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class ScopeManagementDAOImpl implements ScopeManagementDAO {
@Override
public void updateScopes(List<Scope> scopes) throws ScopeManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getConnection();
String sql = "UPDATE IDN_OAUTH2_SCOPE SET ROLES=? WHERE SCOPE_KEY=?";
stmt = conn.prepareStatement(sql);
// creating a batch request
for (Scope scope : scopes) {
stmt.setString(1, scope.getRoles());
stmt.setString(2, scope.getKey());
stmt.addBatch();
}
stmt.executeBatch();
} catch (SQLException e) {
throw new ScopeManagementDAOException("Error occurred while updating the details of the scopes.", e);
} finally {
ScopeManagementDAOUtil.cleanupResources(stmt, rs);
}
}
public List<Scope> getAllScopes() throws ScopeManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<Scope> scopes;
try {
conn = this.getConnection();
String sql = "SELECT * FROM IDN_OAUTH2_SCOPE";
stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery();
scopes = this.getScopesFromResultSet(rs);
return scopes;
} catch (SQLException e) {
throw new ScopeManagementDAOException("Error occurred while fetching the details of the scopes.", e);
} finally {
ScopeManagementDAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public String getRolesOfScope(String scopeKey) throws ScopeManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
String roles = null;
try {
conn = this.getConnection();
String sql = "SELECT ROLES FROM IDN_OAUTH2_SCOPE WHERE SCOPE_KEY = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, scopeKey);
rs = stmt.executeQuery();
if (rs.next()) {
roles = rs.getString("ROLES");
}
return roles;
} catch (SQLException e) {
throw new ScopeManagementDAOException("Error occurred while fetching the details of the scopes.", e);
} finally {
ScopeManagementDAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public List<Scope> getScopesHavingRole(String roleName) throws ScopeManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<Scope> scopes;
try {
conn = this.getConnection();
String sql = "SELECT * FROM IDN_OAUTH2_SCOPE WHERE ROLES LIKE ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, "%" + roleName + "%");
rs = stmt.executeQuery();
scopes = this.getScopesFromResultSet(rs);
return scopes;
} catch (SQLException e) {
throw new ScopeManagementDAOException("Error occurred while fetching the details of the scopes.", e);
} finally {
ScopeManagementDAOUtil.cleanupResources(stmt, rs);
}
}
private Connection getConnection() throws SQLException {
return ScopeManagementDAOFactory.getConnection();
}
private List<Scope> getScopesFromResultSet(ResultSet rs) throws SQLException {
List<Scope> scopes = new ArrayList<>();
Scope scope;
while (rs.next()) {
scope = new Scope();
scope.setKey(rs.getString("SCOPE_KEY"));
scope.setName(rs.getString("NAME"));
scope.setDescription(rs.getString("DESCRIPTION"));
scope.setRoles(rs.getString("ROLES"));
scopes.add(scope);
}
return scopes;
}
}

@ -20,6 +20,8 @@
package org.wso2.carbon.device.mgt.core.task; package org.wso2.carbon.device.mgt.core.task;
import java.util.List;
/** /**
* This is the bean for the operations added by the task. * This is the bean for the operations added by the task.
*/ */
@ -27,6 +29,15 @@ public class TaskOperation {
private String taskName; private String taskName;
private int recurrentTimes; private int recurrentTimes;
private List<String> taskPlatforms;
public List<String> getTaskPlatforms() {
return taskPlatforms;
}
public void setTaskPlatforms(List<String> taskPlatforms) {
this.taskPlatforms = taskPlatforms;
}
public String getTaskName() { public String getTaskName() {
return taskName; return taskName;
@ -43,5 +54,6 @@ public class TaskOperation {
public void setRecurrentTimes(int recurrentTimes) { public void setRecurrentTimes(int recurrentTimes) {
this.recurrentTimes = recurrentTimes; this.recurrentTimes = recurrentTimes;
} }
} }

@ -53,16 +53,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations(); List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
List<TaskOperation> taskOperations = new ArrayList<>(); List<TaskOperation> taskOperations = new ArrayList<>();
for (TaskConfiguration.Operation op : ops) { for (TaskConfiguration.Operation op : ops) {
TaskOperation taskOperation = new TaskOperation(); TaskOperation taskOperation = new TaskOperation();
taskOperation.setTaskName(op.getOperationName()); taskOperation.setTaskName(op.getOperationName());
taskOperation.setRecurrentTimes(op.getRecurrency()); taskOperation.setRecurrentTimes(op.getRecurrency());
taskOperation.setTaskPlatforms(op.getPlatforms());
taskOperations.add(taskOperation); taskOperations.add(taskOperation);
} }
return taskOperations; return taskOperations;
} }
public List<String> getPlatformsForOperations(String opName) {
List<String> operationPlatforms = new ArrayList<>();
TaskConfiguration taskConfiguration =
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration();
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
for (TaskConfiguration.Operation op : ops) {
if (op.getOperationName().equals(opName)) {
List<String> platform = op.getPlatforms();
for (String operationPlatform : platform) {
operationPlatforms.add(operationPlatform);
}
}
}
return operationPlatforms;
}
@Override @Override
public int getTaskFrequency() throws DeviceMgtTaskException { public int getTaskFrequency() throws DeviceMgtTaskException {
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration(). return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
@ -84,29 +100,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override @Override
public void addOperations() throws DeviceMgtTaskException { public void addOperations() throws DeviceMgtTaskException {
List<String> deviceTypes;
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
getDeviceManagementProvider(); getDeviceManagementProvider();
try { try {
List<String> deviceTypes = deviceManagementProviderService.getAvailableDeviceTypes();
List<Device> devices; List<Device> devices;
List<String> operations = this.getValidOperationNames(); List<String> operations = this.getValidOperationNames();
for (String taskOperation : operations) {
for (String deviceType : deviceTypes) { deviceTypes = getPlatformsForOperations(taskOperation);
devices = deviceManagementProviderService.getAllDevices(deviceType); for (String deviceType : deviceTypes) {
if (!devices.isEmpty()) { devices = deviceManagementProviderService.getAllDevices(deviceType);
for (String str : operations) { if (!devices.isEmpty()) {
CommandOperation operation = new CommandOperation(); for (String str : operations) {
operation.setEnabled(true); CommandOperation operation = new CommandOperation();
operation.setType(Operation.Type.COMMAND); operation.setEnabled(true);
operation.setCode(str); operation.setType(Operation.Type.COMMAND);
deviceManagementProviderService.addOperation(deviceType, operation, operation.setCode(str);
DeviceManagerUtil.getValidDeviceIdentifiers(devices)); deviceManagementProviderService.addOperation(deviceType, operation,
} DeviceManagerUtil.getValidDeviceIdentifiers(devices));
} else { }
if (log.isDebugEnabled()) { } else {
log.debug("No devices are available to perform the operations."); if (log.isDebugEnabled()) {
} log.debug("No devices are available to perform the operations.");
} }
}
}
} }
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e); throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
@ -145,6 +164,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
return opNames; return opNames;
} }
@Override @Override
public boolean isTaskOperation(String opName) { public boolean isTaskOperation(String opName) {
try { try {

@ -19,7 +19,7 @@
"owner": "admin@carbon.super", "owner": "admin@carbon.super",
"dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register",
"apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants",
"grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer", "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer",
"tokenScope": "admin", "tokenScope": "admin",
"callbackUrl": "%https.ip%/api/device-mgt/v1.0" "callbackUrl": "%https.ip%/api/device-mgt/v1.0"
}, },

@ -226,13 +226,14 @@ deviceModule = function () {
publicMethods.getDevices = function (userName) { publicMethods.getDevices = function (userName) {
var url = devicemgtProps["httpsURL"] + var url = devicemgtProps["httpsURL"] +
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/user/" + userName; devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices";
return serviceInvokers.XMLHttp.get( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url, function (responsePayload) {
for (var i = 0; i < responsePayload.length; i++) { var devices = JSON.parse(responsePayload.responseText).devices;
responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type); for (var i = 0; i < devices.length; i++) {
devices[i].thumb = utility.getDeviceThumb(devices[i].type);
} }
return responsePayload; return devices;
}, },
function (responsePayload) { function (responsePayload) {
log.error(responsePayload); log.error(responsePayload);

@ -15,8 +15,20 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.ui.title" pageTitle="Notification Listing"}} {{unit "cdmf.unit.ui.title" pageTitle="Notification Listing"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/notification-listing">
Notifications
</a>
</li>
{{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.notification.listing"}} {{unit "cdmf.unit.notification.listing"}}
{{/zone}} {{/zone}}

@ -20,7 +20,10 @@
var sortUpdateBtn = "#sortUpdateBtn"; var sortUpdateBtn = "#sortUpdateBtn";
var sortedIDs; var sortedIDs;
var dataTableSelection = '.DTTT_selected'; var dataTableSelection = '.DTTT_selected';
$('#policy-grid').datatables_extended(); var settings = {
"sorting": false
};
$('#policy-grid').datatables_extended(settings);
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
var saveNewPrioritiesButton = "#save-new-priorities-button"; var saveNewPrioritiesButton = "#save-new-priorities-button";
@ -90,7 +93,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -208,7 +211,7 @@ $(document).ready(function () {
}, },
function () { function () {
$("#save-policy-priorities-error-content").find(".message-from-server").html( $("#save-policy-priorities-error-content").find(".message-from-server").html(
"Message From Server : " + data["statusText"]); "Message From Server : " + data["statusText"]);
$(modalPopupContent).html($('#save-policy-priorities-error-content').html()); $(modalPopupContent).html($('#save-policy-priorities-error-content').html());
showPopup(); showPopup();
$("a#save-policy-priorities-error-link").click(function () { $("a#save-policy-priorities-error-link").click(function () {
@ -222,7 +225,7 @@ $(document).ready(function () {
$(".policy-unpublish-link").click(function () { $(".policy-unpublish-link").click(function () {
var policyList = getSelectedPolicies(); var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates(); var statusList = getSelectedPolicyStates();
if ( ($.inArray( 'Inactive/Updated', statusList ) > -1) || ($.inArray( 'Inactive', statusList ) > -1) ) { if (($.inArray('Inactive/Updated', statusList) > -1) || ($.inArray('Inactive', statusList) > -1)) {
$(modalPopupContent).html($("#errorPolicyUnPublishSelection").html()); $(modalPopupContent).html($("#errorPolicyUnPublishSelection").html());
showPopup(); showPopup();
} else { } else {
@ -266,7 +269,7 @@ $(document).ready(function () {
$(".policy-publish-link").click(function () { $(".policy-publish-link").click(function () {
var policyList = getSelectedPolicies(); var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates(); var statusList = getSelectedPolicyStates();
if ( ($.inArray( 'Active/Updated', statusList ) > -1) || ($.inArray( 'Active', statusList ) > -1) ) { if (($.inArray('Active/Updated', statusList) > -1) || ($.inArray('Active', statusList) > -1)) {
$(modalPopupContent).html($("#errorPolicyPublishSelection").html()); $(modalPopupContent).html($("#errorPolicyPublishSelection").html());
showPopup(); showPopup();
} else { } else {

@ -45,9 +45,9 @@ var isInit = true;
* the font icons change the size to respective screen resolution. * the font icons change the size to respective screen resolution.
* *
*/ */
$(document).on( 'draw.dt', function () { $(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
} ); });
/* /*
@ -72,7 +72,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -95,7 +95,7 @@ function loadRoles() {
var objects = []; var objects = [];
$(data.roles).each(function( index ) { $(data.roles).each(function (index) {
objects.push( objects.push(
{ {
name: data.roles[index], name: data.roles[index],
@ -182,10 +182,13 @@ function loadRoles() {
var options = { var options = {
"placeholder": "Search By Role Name", "placeholder": "Search By Role Name",
"searchKey" : "filter" "searchKey": "filter"
};
var settings = {
"sorting": false
}; };
$('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options); $('#role-grid').datatables_extended_serverside_paging(settings, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
loadingContent.hide(); loadingContent.hide();
} }

@ -5,13 +5,14 @@
<i class="square-element text fw fw-user"></i> <i class="square-element text fw fw-user"></i>
</div> </div>
</td> </td>
<td class="fade-edge remove-padding-top" >{{roleName}}</td> <td class="fade-edge remove-padding-top">{{roleName}}</td>
<td class="text-right content-fill text-left-on-grid-view no-wrap"> <td class="text-right content-fill text-left-on-grid-view no-wrap">
{{#unequal adminRole roleName }} {{#unequal adminRole roleName }}
{{#if canEdit}} {{#if canEdit}}
<a onclick="javascript:loadRoleBasedActionURL('edit', '{{roleName}}')" data-role="{{roleName}}" data-click-event="edit-form" <a onclick="javascript:loadRoleBasedActionURL('edit', '{{roleName}}')" data-role="{{roleName}}"
class="btn padding-reduce-on-grid-view edit-role-link"> data-click-event="edit-form"
class="btn padding-reduce-on-grid-view edit-role-link" title="Edit Role">
<span class="fw-stack fw-lg"> <span class="fw-stack fw-lg">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-user fw-stack-1x"></i> <i class="fw fw-user fw-stack-1x"></i>
@ -21,10 +22,12 @@
<i class="fw fw-edit fw-stack-1x fw-inverse"></i> <i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span> </span>
</span> </span>
<span class="hidden-xs hidden-on-grid-view">Edit</span> <span class="hidden-xs hidden-on-grid-view">Edit</span>
</a> </a>
<a onclick="javascript:loadRoleBasedActionURL('edit-permission', '{{roleName}}')" data-role="{{roleName}}" <a onclick="javascript:loadRoleBasedActionURL('edit-permission', '{{roleName}}')"
data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link"> data-role="{{roleName}}"
data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link"
title="Edit Role Permissions">
<span class="fw-stack fw-lg"> <span class="fw-stack fw-lg">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-security-policy fw-stack-1x"></i> <i class="fw fw-security-policy fw-stack-1x"></i>
@ -34,18 +37,19 @@
<i class="fw fw-edit fw-stack-1x fw-inverse"></i> <i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span> </span>
</span> </span>
<span class="hidden-xs hidden-on-grid-view">Edit Permission</span> <span class="hidden-xs hidden-on-grid-view">Edit Permission</span>
</a> </a>
{{/if}} {{/if}}
{{#if canRemove}} {{#if canRemove}}
<a data-role="{{roleName}}" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-role-link"> <a data-role="{{roleName}}" data-click-event="remove-form"
class="btn padding-reduce-on-grid-view remove-role-link" title="Remove Role">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i> <i class="fw fw-delete fw-stack-1x"></i>
</span> </span>
<span class="hidden-xs hidden-on-grid-view">Remove</span> <span class="hidden-xs hidden-on-grid-view">Remove</span>
</a> </a>
{{/if}} {{/if}}
{{/unequal}} {{/unequal}}
</td> </td>
</tr> </tr>

@ -50,9 +50,9 @@ var body = "body";
* the font icons change the size to respective screen resolution. * the font icons change the size to respective screen resolution.
* *
*/ */
$(document).on( 'draw.dt', function () { $(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
} ); });
/* /*
* set popup maximum height function. * set popup maximum height function.
@ -75,7 +75,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -270,13 +270,14 @@ function loadUsers() {
var objects = []; var objects = [];
$(data.users).each( function (index) { $(data.users).each(function (index) {
objects.push({ objects.push({
filter: data.users[index].username, filter: data.users[index].username,
firstname: data.users[index].firstname ? data.users[index].firstname : "" , firstname: data.users[index].firstname ? data.users[index].firstname : "",
lastname: data.users[index].lastname ? data.users[index].lastname : "", lastname: data.users[index].lastname ? data.users[index].lastname : "",
emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress : "", emailAddress: data.users[index].emailAddress ? data.users[index].emailAddress : "",
DT_RowId : "user-" + data.users[index].username}) DT_RowId: "user-" + data.users[index].username
})
}); });
var json = { var json = {
@ -300,7 +301,7 @@ function loadUsers() {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<div class="thumbnail icon viewEnabledIcon" data-url="' + context +'/user/view?username=' + data.filter + '">' + return '<div class="thumbnail icon viewEnabledIcon" data-url="' + context + '/user/view?username=' + data.filter + '">' +
'<i class="square-element text fw fw-user" style="font-size: 74px;"></i>' + '<i class="square-element text fw fw-user" style="font-size: 74px;"></i>' +
'</div>'; '</div>';
} }
@ -338,7 +339,7 @@ function loadUsers() {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null, data: null,
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
var editbtn= '&nbsp;<a data-toggle="tooltip" data-placement="bottom" title="Edit User"href="' + context + '/user/edit?username=' + data.filter + '" data-username="' + data.filter + '" ' + var editbtn = '&nbsp;<a data-toggle="tooltip" data-placement="bottom" title="Edit User"href="' + context + '/user/edit?username=' + data.filter + '" data-username="' + data.filter + '" ' +
'data-click-event="edit-form" ' + 'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-user-link"> ' + 'class="btn padding-reduce-on-grid-view edit-user-link"> ' +
'<span class="fw-stack"> ' + '<span class="fw-stack"> ' +
@ -377,13 +378,13 @@ function loadUsers() {
'</a>'; '</a>';
var returnbtnSet = ''; var returnbtnSet = '';
if($("#can-edit").length > 0) { if ($("#can-edit").length > 0) {
returnbtnSet = returnbtnSet + editbtn; returnbtnSet = returnbtnSet + editbtn;
} }
if($("#can-reset-password").length > 0) { if ($("#can-reset-password").length > 0) {
returnbtnSet = returnbtnSet + resetPasswordbtn; returnbtnSet = returnbtnSet + resetPasswordbtn;
} }
if($("#can-remove").length > 0) { if ($("#can-remove").length > 0) {
returnbtnSet = returnbtnSet + removebtn; returnbtnSet = returnbtnSet + removebtn;
} }
@ -395,10 +396,14 @@ function loadUsers() {
var options = { var options = {
"placeholder": "Search By Username", "placeholder": "Search By Username",
"searchKey" : "filter" "searchKey": "filter"
};
var settings = {
"sorting": false
}; };
$('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options); $('#user-grid').datatables_extended_serverside_paging(settings, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options);
$(loadingContentView).hide(); $(loadingContentView).hide();
} }

@ -29,6 +29,15 @@ $.fn.datatables_extended = function(settings){
} }
//--- End of EMM related codes //--- End of EMM related codes
/*
* Work around for accessing settings params inside datatable functions
*/
if(settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting){
elem.addClass('sorting-enabled');
}else{
elem.addClass('sorting-disabled');
}
$(elem).DataTable( $(elem).DataTable(
$.extend({},{ $.extend({},{
bSortCellsTop: true, bSortCellsTop: true,
@ -131,24 +140,41 @@ $.fn.datatables_extended = function(settings){
/** /**
* create sorting dropdown menu for list table advance operations * create sorting dropdown menu for list table advance operations
*/ */
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>'); var table = this;
$('.sort-row th', elem).each(function(){ if(table.hasClass('sorting-enabled')){
if(!$(this).hasClass('no-sort')){ var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>'); $('.sort-row th', elem).each(function () {
} if (!$(this).hasClass('no-sort')) {
}); dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
}
});
}
function getAdvanceToolBar(){
if(table.hasClass('sorting-enabled')){
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
'</ul>'
}else{
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'</ul>'
};
}
/** /**
* append advance operations to list table toolbar * append advance operations to list table toolbar
*/ */
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' + $('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html(
'<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' + getAdvanceToolBar()
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>'+dropdownmenu[0].outerHTML+'</li>' +
'</ul>'
); );
/** /**
@ -186,14 +212,14 @@ $.fn.datatables_extended = function(settings){
$(button).addClass("active").html('Cancel'); $(button).addClass("active").html('Cancel');
$(button).parent().next().children("button").removeClass("disabled"); $(button).parent().next().children("button").removeClass("disabled");
// EMM related code // EMM related code
$(".viewEnabledIcon").unbind("click"); $(document).off('click','.viewEnabledIcon');
//--- End of EMM related codes //--- End of EMM related codes
} else if ($(button).html() == 'Cancel'){ } else if ($(button).html() == 'Cancel'){
thisTable.removeClass("table-selectable"); thisTable.removeClass("table-selectable");
$(button).addClass("active").html('Select'); $(button).addClass("active").html('Select');
$(button).parent().next().children().addClass("disabled"); $(button).parent().next().children().addClass("disabled");
// EMM related function // EMM related function
$(".viewEnabledIcon").bind("click", InitiateViewOption); $(document).on('click','.viewEnabledIcon',InitiateViewOption);
//--- End of EMM related codes //--- End of EMM related codes
} }
}); });

@ -29,13 +29,23 @@
* For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x * For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x
*/ */
$.fn.datatables_extended_serverside_paging = function (settings , url, dataFilter, $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter,
columns, fnCreatedRow, fnDrawCallback, options) { columns, fnCreatedRow, fnDrawCallback, options) {
var elem = $(this); var elem = $(this);
// EMM related function // EMM related function
if (InitiateViewOption) { if (InitiateViewOption) {
$(document).on('click','.viewEnabledIcon',InitiateViewOption); $(document).on('click', '.viewEnabledIcon', InitiateViewOption);
}
//--- End of EMM related codes
/*
* Work around for accessing settings params inside datatable functions
*/
if (settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting) {
elem.addClass('sorting-enabled');
} else {
elem.addClass('sorting-disabled');
} }
var deviceType; var deviceType;
@ -44,22 +54,22 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
//--- End of EMM related codes //--- End of EMM related codes
$(elem).DataTable( $(elem).DataTable(
$.extend({},{ $.extend({}, {
serverSide: true, serverSide: true,
processing: false, processing: false,
searching: true, searching: true,
ordering: false, ordering: false,
filter: false, filter: false,
bSortCellsTop: true, bSortCellsTop: true,
ajax : { ajax: {
url: context + "/api/data-tables/invoker", url: context + "/api/data-tables/invoker",
data : function (params) { data: function (params) {
var i; var i;
var searchParams = {}; var searchParams = {};
for (i = 0; i < params.columns.length; i++) { for (i = 0; i < params.columns.length; i++) {
searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value); searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value);
} }
if(options) { if (options) {
searchParams[options.searchKey] = encodeURIComponent(params.search.value); searchParams[options.searchKey] = encodeURIComponent(params.search.value);
} }
params.filter = JSON.stringify(searchParams); params.filter = JSON.stringify(searchParams);
@ -78,14 +88,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
columns: columns, columns: columns,
responsive: false, responsive: false,
autoWidth: false, autoWidth: false,
dom:'<"dataTablesTop"' + dom: '<"dataTablesTop"' +
'f' + 'f' +
'<"dataTables_toolbar">' + '<"dataTables_toolbar">' +
'>' + '>' +
'rt' + 'rt' +
'<"dataTablesBottom"' + '<"dataTablesBottom"' +
'lip' + 'lip' +
'>', '>',
language: { language: {
searchPlaceholder: options.placeholder, searchPlaceholder: options.placeholder,
search: '' search: ''
@ -110,7 +120,7 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
); );
column column
//.search(val ? '^' + val + '$' : '', true, false) //.search(val ? '^' + val + '$' : '', true, false)
.search(val ? val : '', true, false) .search(val ? val : '', true, false)
.draw(); .draw();
@ -184,24 +194,42 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
/** /**
* create sorting dropdown menu for list table advance operations * create sorting dropdown menu for list table advance operations
*/ */
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>'); var table = this;
$('.sort-row th', elem).each(function () { if (table.hasClass('sorting-enabled')) {
if (!$(this).hasClass('no-sort')) { var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>'); $('.sort-row th', elem).each(function () {
if (!$(this).hasClass('no-sort')) {
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
}
});
}
function getAdvanceToolBar() {
if (table.hasClass('sorting-enabled')) {
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
'</ul>'
} else {
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'</ul>'
} }
}); ;
}
/** /**
* append advance operations to list table toolbar * append advance operations to list table toolbar
*/ */
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' + $('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html(
'<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' + getAdvanceToolBar()
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
'</ul>'
); );
/** /**
@ -239,14 +267,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
$(button).addClass("active").html('Cancel'); $(button).addClass("active").html('Cancel');
$(button).parent().next().children("button").removeClass("disabled"); $(button).parent().next().children("button").removeClass("disabled");
// EMM related code // EMM related code
$(document).off('click','.viewEnabledIcon'); $(document).off('click', '.viewEnabledIcon');
//--- End of EMM related codes //--- End of EMM related codes
} else if ($(button).html() == 'Cancel') { } else if ($(button).html() == 'Cancel') {
thisTable.removeClass("table-selectable"); thisTable.removeClass("table-selectable");
$(button).addClass("active").html('Select'); $(button).addClass("active").html('Select');
$(button).parent().next().children().addClass("disabled"); $(button).parent().next().children().addClass("disabled");
// EMM related function // EMM related function
$(document).on('click','.viewEnabledIcon',InitiateViewOption); $(document).on('click', '.viewEnabledIcon', InitiateViewOption);
//--- End of EMM related codes //--- End of EMM related codes
} }
}); });
@ -305,6 +333,6 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
} }
}) })
} }
},settings) }, settings)
); );
}; };

@ -1,203 +1,515 @@
{{! {{unit "mdm.unit.lib.leaflet"}}
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. {{unit "cdmf.unit.lib.qrcode"}}
{{unit "mdm.unit.device.qr-modal"}}
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "content"}} {{#zone "content"}}
<h1 class="page-sub-title device-id device-select" data-deviceid="{{device.deviceIdentifier}}" data-type="{{device.type}}"> {{#if deviceFound}}
Device {{device.name}} {{#if isAuthorized}}
{{#if device.viewModel.model}} <h1 class="page-sub-title device-id device-select"
<span class="lbl-device"> data-deviceid="{{deviceView.deviceIdentifier}}" data-type="{{deviceView.deviceType}}"
( {{device.viewModel.vendor}} {{device.viewModel.model}} ) data-ownership="{{deviceView.ownership}}">
</span> Device {{deviceView.name}}
{{/if}} {{#if deviceView.model}}
</h1> <span class="lbl-device">
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;"> ( {{deviceView.vendor}} {{deviceView.model}} )
<div class="media"> </span>
<div id="device_overview"> {{/if}}
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2"> </h1>
<div class="thumbnail icon"> <div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
{{#defineZone "device-thumbnail"}} <div class="media">
<i class="square-element text fw fw-mobile"></i> <div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
{{/defineZone}} <div class="thumbnail icon"><i class="square-element text fw fw-mobile"></i></div>
</div> </div>
</div> <div class="media-body asset-desc add-padding-left-5x">
<div class="media-body asset-desc add-padding-left-5x"> <div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Device
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px"> Overview
Device Overview - {{label}}</div> </div>
{{unit "cdmf.unit.device.overview-section" device=device}} {{#defineZone "device-detail-properties"}}
{{#defineZone "operation-status"}}{{/defineZone}} <table class="table table-responsive table-striped" id="members">
{{#defineZone "device-opetations"}} <tbody>
{{#if deviceView.deviceIdentifier}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Device ID</td>
<td style="padding:10px 15px;">{{deviceView.deviceIdentifier}}</td>
</tr>
{{/if}}
{{#if deviceView.name}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Name</td>
<td style="padding:10px 15px;">{{deviceView.name}}</td>
</tr>
{{/if}}
{{#if deviceView.vendor}}
{{#if deviceView.model}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Model</td>
<td style="padding:10px 15px;">{{deviceView.vendor}} {{deviceView.model}}</td>
</tr>
{{/if}}
{{/if}}
{{#if deviceView.status}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal deviceView.status "ACTIVE"}}<span><i
class="fw fw-ok icon-success"></i>Active</span>{{/equal}}
{{#equal deviceView.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal deviceView.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal deviceView.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
</td>
</tr>
{{/if}}
{{#if deviceView.owner}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
<td style="padding:10px 15px;">{{deviceView.owner}}</td>
</tr>
{{/if}}
{{#if deviceView.ownership}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Ownership</td>
<td style="padding:10px 15px;">{{deviceView.ownership}}</td>
</tr>
{{/if}}
{{#if deviceView.imei}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">IMEI</td>
<td style="padding:10px 15px;">{{deviceView.imei}}</td>
</tr>
{{/if}}
{{#if deviceView.udid}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">UDID</td>
<td style="padding:10px 15px;">{{deviceView.udid}}</td>
</tr>
{{/if}}
{{#if deviceView.osBuildDate}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Firmware Build
Date
</td>
<td style="padding:10px 15px;">{{deviceView.osBuildDate}}</td>
</tr>
{{/if}}
{{#if deviceView.phoneNumber}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Phone Number</td>
<td style="padding:10px 15px;">{{deviceView.phoneNumber}}</td>
</tr>
{{/if}}
{{#if deviceView.lastUpdatedTime}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Last Update</td>
<td style="padding:10px 15px;">{{deviceView.lastUpdatedTime}}</td>
</tr>
{{/if}}
</tbody>
</table>
{{/defineZone}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px"> <div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Operations Operations
</div> </div>
<div class="add-margin-top-4x" style="height: 90px;"> <div class="add-margin-top-4x">
{{unit "cdmf.unit.device.operation-bar" device=device}} {{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}}
</div> </div>
{{/defineZone}} </div>
</div> </div>
</div> <div class="media tab-responsive">
</div> <div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs">
<ul class="list-group nav nav-pills nav-stacked" role="tablist">
{{#if deviceView.isNotWindows}}
<li role="presentation" class="list-group-item active">
<a href="#device_details_tab" role="tab" data-toggle="tab"
aria-controls="device_details_tab">
<i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span>
</a>
</li>
{{/if}}
{{#if deviceView.isNotWindows}}
<li role="presentation" class="list-group-item">
{{else}}
<li role="presentation" class="list-group-item active">
{{/if}}
<li role="presentation" class="list-group-item">
<a href="#policy_compliance_tab" role="tab" data-toggle="tab"
aria-controls="policy_compliance_tab">
<i class="icon fw fw-policy"></i><span class="hidden-sm">Policy Compliance</span>
</a>
</li>
{{#if deviceView.isNotWindows}}
<li role="presentation" class="list-group-item">
<a href="#device_location_tab" role="tab" data-toggle="tab"
data-lat="{{deviceView.location.latitude}}"
data-long="{{deviceView.location.longitude}}"
aria-controls="device_location_tab">
<i class="icon fw fw-map-location"></i><span
class="hidden-sm">Device Location</span>
</a>
</li>
<li role="presentation" class="list-group-item">
<a href="#installed_applications_tab" role="tab" data-toggle="tab"
aria-controls="installed_applications_tab">
<i class="icon fw fw-application"></i><span class="hidden-sm">Installed Applications</span>
</a>
</li>
{{/if}}
{{#if deviceView.isNotRemoved}}
{{#defineZone "device-detail-properties"}} <li role="presentation" class="list-group-item">
<div class="media"> <a href="#event_log_tab" role="tab" data-toggle="tab"
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2"> aria-controls="event_log_tab">
<ul class="list-group" role="tablist"> <i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
<li class="active"><a class="list-group-item" </a>
href="#device_details" </li>
role="tab" data-toggle="tab"
aria-controls="device_details">Device
Details</a>
</li>
<li><a class="list-group-item" href="#policies"
role="tab"
data-toggle="tab" aria-controls="policies">Policies</a>
</li>
<li><a class="list-group-item" href="#policy_compliance"
role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy
Compliance</a>
</li>
<li><a class="list-group-item" href="#device_location"
role="tab"
data-toggle="tab" aria-controls="device_location">Device
Location</a>
</li>
<li><a class="list-group-item" href="#event_log" role="tab"
data-toggle="tab" aria-controls="event_log">Operations
Log</a></li>
</ul>
</div>
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
<div class="panel panel-default tab-pane active" {{/if}}
id="device_details" role="tabpanel" </ul>
aria-labelledby="device_details">
{{unit "cdmf.unit.device.details" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policies" role="tabpanel" {{#defineZone "device-detail-properties"}}
aria-labelledby="policies"> <div class="media-body add-padding-left-5x remove-padding-xs">
<div class="panel-heading">Policies</div> <div class="panel-group tab-content remove-padding" id="tabs" data-status="{{deviceView.isNotRemoved}}"role="tablist"
<div class="panel-body"> aria-multiselectable="true">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div class="arrow-left hidden-xs"></div>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{#if deviceView.isNotWindows}}
<i class="fw fw-settings fw-spin fw-2x"></i> <div class="panel panel-default" role="tabpanel" id="device_details_tab">
&nbsp;&nbsp;&nbsp; <div class="panel-heading visible-xs collapsed" id="device_details">
Loading Policies . . . <h4 class="panel-title">
<br> <a role="button" data-toggle="collapse" data-parent="#tabs"
<br> href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
</div> <i class="fw fw-mobile fw-2x"></i>
<div id="policy-list-container"> Device Details
<div class="panel-body"> <i class="caret-updown fw fw-down"></i>
No policies found </a>
</h4>
</div>
<div class="panel-heading display-none-xs">Device Details</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="device_details">
<div class="panel-body ">
<div class="device-detail-body">
<!-- device summary -->
{{#equal deviceView.deviceType "windows"}}
<div class="message message-info">
<h4 class="remove-margin"><i class="icon fw fw-info"></i>Not
available yet</h4>
</div>
{{/equal}}
{{#if deviceView.deviceInfoAvailable}}
{{#if deviceView.BatteryLevel}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">BATTERY</div>
<div>
<div class="tile-icon"><i
class="fw fw-battery"></i></div>
<div class="tile-stats">
{{deviceView.BatteryLevel.value}} %
</div>
</div>
</div>
</div>
</div>
{{/if}}
<!--{{#if deviceView.cpuUsage}}-->
<!--<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">-->
<!--<div class="col-md-12">-->
<!--<div class="wr-stats-board-tile">-->
<!--<div class="tile-name">CPU Usage</div>-->
<!--<div>-->
<!--<div class="tile-icon"><i class="fw fw-dashboard"></i></div>-->
<!--<div class="tile-stats">-->
<!--{{deviceView.cpuUsage.value}} %-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--{{/if}}-->
{{#if deviceView.ramUsage}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">RAM Usage</div>
<div>
<div class="tile-icon"><i
class="fw fw-hardware"></i></div>
<div class="tile-stats">
{{deviceView.ramUsage.value}} %
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if deviceView.internalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">Local Storage</div>
<div>
<div class="tile-icon"><i
class="fw fw-hdd"></i>
</div>
<div class="tile-stats">
{{deviceView.internalMemory.usage}} %
<span class="tile-stats-free">
TOTAL OF {{deviceView.internalMemory.total}} GB
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if deviceView.externalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">External Storage</div>
<div>
<div class="tile-icon"><i
class="fw fw-usb-drive"></i></div>
<div class="tile-stats">
{{deviceView.externalMemory.usage}} %
<span class="tile-stats-free">
TOTAL OF {{deviceView.externalMemory.total}} GB
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{else}}
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
Battery, RAM and Storage related information are not
available yet.
</h4>
</div>
{{/if}}
</div>
</div>
</div>
</div>
{{/if}}
<div class="panel panel-default visible-xs-block" role="tabpanel"
id="policy_compliance_tab">
<div class="panel-heading visible-xs collapsed" id="policy_compliance">
<h4 class="panel-title">
<a role="button"
data-toggle="collapse" data-parent="#tabs" href="#collapseTwo"
aria-expanded="true" aria-controls="collapseTwo">
<i class="fw fw-policy fw-2x"></i>
Policy Compliance
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Policy Compliance
<span>
<a href="javascript:void(0);" id="refresh-policy">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="policy_compliance">
<div class="panel-body ">
<span class="visible-xs add-padding-2x text-right">
<a href="javascript:void(0);" id="refresh-policy">
<i class="fw fw-refresh"></i>
</a>
</span>
<div id="policy-spinner"
class="wr-advance-operations-init add-padding-bottom-2x add-padding-bottom-4x hidden">
<i class="fw fw-settings fw-spin fw-2x"></i>Loading Policy
Compliance...
</div>
<div id="policy-list-container">
</div>
</div>
</div>
</div> </div>
<br class="c-both"/> <div class="panel panel-default visible-xs-block" role="tabpanel"
</div> id="device_location_tab">
</div> <div class="panel-heading visible-xs collapsed" id="device_location">
<a class="padding-left" <h4 class="panel-title">
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}"> <a role="button" data-toggle="collapse" data-parent="#tabs"
<span class="fw-stack"> href="#collapseThree" aria-expanded="true" aria-controls="collapseThree">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-map-location fw-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i> Device Location
</span> Add device specific policy</a> <i class="caret-updown fw fw-down"></i>
</div> </a>
</h4>
</div>
<div class="panel-heading display-none-xs">Device Location</div>
<div id="collapseThree" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="device_location">
<div class="panel-body">
{{#if deviceView.location}}
<div id="device-location"
data-lat="{{deviceView.location.latitude}}"
data-long="{{deviceView.location.longitude}}">
</div>
{{else}}
<div id="map-error" class="message message-warning">
<h4 class="remove-margin">
<i class="icon fw fw-warning"></i>
Device location information is not available.
</h4>
</div>
<p class="add-padding-5x"></p>
<p class="add-padding-5x"></p>
<p class="add-padding-5x"></p>
{{/if}}
</div>
</div>
</div>
<div class="panel panel-default visible-xs-block" role="tabpanel"
id="installed_applications_tab">
<div class="panel-heading visible-xs collapsed" id="installed_applications">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#tabs"
href="#collapseFour" aria-expanded="true" aria-controls="collapseFour">
<i class="fw fw-application fw-2x"></i>
Installed Applications
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Installed Applications
<div class="panel panel-default tab-pane" id="policy_compliance" <span>
role="tabpanel" aria-labelledby="policy_compliance"> <a href="javascript:void(0);" id="refresh-apps">
<div class="panel-heading">Policy Compliance <span><a <i class="fw fw-refresh"></i>
href="#" id="refresh-policy"><i </a>
class="fw fw-refresh"></i></a></span></div> </span>
<div class="panel-body"> </div>
<div id="policy-spinner" <div id="collapseFour" class="panel-collapse collapse in" role="tabpanel"
class="wr-advance-operations-init hidden"> aria-labelledby="installed_applications">
<br> <div class="panel-body">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="visible-xs add-padding-2x text-right">
<i class="fw fw-settings fw-spin fw-2x"></i> <a href="javascript:void(0);" id="refresh-apps">
&nbsp;&nbsp;&nbsp; <i class="fw fw-refresh"></i>
Loading Policy Compliance . . . </a>
<br> </span>
<br> <div id="apps-spinner" class="wr-advance-operations-init hidden">
</div> <i class="fw fw-settings fw-spin fw-2x"></i> Loading Applications
<div id="policy-list-container"> List...
<div class="panel-body"> </div>
Not available yet <div id="applications-list-container">
<div class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
No applications found.
</h4>
<p>Please try refreshing in a while.</p>
</div>
</div>
</div>
</div>
</div> </div>
<br class="c-both"/> <div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab">
</div> <div class="panel-heading visible-xs collapsed" id="event_log">
</div> <h4 class="panel-title">
</div> <a role="button" data-toggle="collapse" data-parent="#tabs"
<div class="panel panel-default tab-pane" id="device_location" href="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
role="tabpanel" aria-labelledby="device_location"> <i class="fw fw-text fw-2x"></i>
<div class="panel-heading">Device Location</div> Operations Log
<div class="panel-body"> <i class="caret-updown fw fw-down"></i>
<div id="device-location" </a>
data-lat="{{device.viewModel.location.latitude}}" </h4>
data-long="{{device.viewModel.location.longitude}}" </div>
style="height:450px" class="panel-body"> <div class="panel-heading display-none-xs">
</div> Operations Log
<div id="map-error" class="panel-body">
Not available yet <span>
</div> <a href="javascript:void(0);" id="refresh-operations">
<br class="c-both"/> <i class="fw fw-refresh"></i>
</div> </a>
</div> </span>
<div class="panel panel-default tab-pane" id="event_log" </div>
role="tabpanel" aria-labelledby="event_log"> <div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
<div class="panel-heading">Operations Log <span><a href="#" aria-labelledby="event_log">
id="refresh-operations"><i <div class="panel-body">
class="fw fw-refresh"></i></a></span></div> <span class="visible-xs add-padding-2x text-right">
<div class="panel-body"> <a href="javascript:void(0);" id="refresh-operations">
<div id="operations-spinner" <i class="fw fw-refresh"></i>
class="wr-advance-operations-init hidden"> </a>
<br> </span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <div id="operations-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i> Loading Operations Log...
&nbsp;&nbsp;&nbsp; </div>
Loading Operations Log . . . <div id="operations-log-container">
<br> <div class="message message-info">
<br> <h4 class="remove-margin">
</div> <i class="icon fw fw-info"></i>
<div id="operations-log-container"> There are no operations, performed yet on this device.
<div class="panel-body"> </h4>
Not available yet </div>
</div>
<table class="table table-striped table-hover table-bordered display data-table"
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div> </div>
<br class="c-both"/>
</div> </div>
</div> </div>
</div> {{/defineZone}}
</div> </div>
</div> </div>
</div> {{else}}
{{/defineZone}} <h1 class="page-sub-title">
</div> Permission Denied
</h1>
<br>
You are not authorized to view specified device in the system.
{{/if}}
{{else}}
<h1 class="page-sub-title">
Device not found
</h1>
<br>
You have tried to access either a removed or non-existing device.
{{/if}}
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
{{js "js/device-view.js"}} {{#if isAuthorized}}
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs" <!--suppress HtmlUnknownTarget -->
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" <script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
type="text/x-handlebars-template"></script> data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
<script id="policy-list" src="{{@unit.publicUri}}/templates/policy-list.hbs" type="text/x-handlebars-template"></script>
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" <!--suppress HtmlUnknownTarget -->
type="text/x-handlebars-template"></script> <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" type="text/x-handlebars-template"></script>
type="text/x-handlebars-template"></script> <!--suppress HtmlUnknownTarget -->
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs" <script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
{{js "js/load-map.js"}}
{{/if}}
{{/zone}} {{/zone}}

@ -21,10 +21,10 @@
<div class="col-md-12"> <div class="col-md-12">
<!-- content --> <!-- content -->
<div id="config-save-form" class="container col-centered wr-content"> <div id="config-save-form" class="container col-centered wr-content">
<br> <h1 class="page-sub-title">
<h4> Device Notifications </h4> Device Notifications
<br> </h1>
<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">
@ -43,7 +43,7 @@
</div> </div>
<div class="wr-hidden-operations-content col-lg-8" id="ast-container"> <div class="wr-hidden-operations-content col-lg-8" id="ast-container">
<div class="panel-body"> <div id="noNotificationtxt" class="panel-body">
No unread messages No unread messages
</div> </div>
</div> </div>

@ -47,8 +47,11 @@ function loadNotifications() {
viewModel["appContext"] = context; viewModel["appContext"] = context;
var content = template(viewModel); var content = template(viewModel);
$("#ast-container").html(content); $("#ast-container").html(content);
$("#unread-notifications").datatables_extended(); var settings = {
$("#all-notifications").datatables_extended(); "sorting" : false
};
$("#unread-notifications").datatables_extended(settings);
$("#all-notifications").datatables_extended(settings);
} }
} }
}, },
@ -65,15 +68,13 @@ function loadNotifications() {
function showAdvanceOperation(operation, button) { function showAdvanceOperation(operation, button) {
$(button).addClass('selected'); $(button).addClass('selected');
$(button).siblings().removeClass('selected'); $(button).siblings().removeClass('selected');
if ($(button).attr("id") == 'allNotifications') { if ($(button).attr("id") == 'allNotifications') {
$("#ast-container").html('<div class="panel-body">You do not have any unread notifications </div>'); $("#noNotificationtxt").html('You do not have any unread notifications ');
} else if ($(button).attr("id") == 'unReadNotifications') { } else if ($(button).attr("id") == 'unReadNotifications') {
$("#ast-container").html('<div class="panel-body">You do not have any notifications </div>'); $("#noNotificationtxt").html('You do not have any notifications ');
} else { } else {
$("#ast-container").html('<div class="panel-body">You do not have any notifications </div>'); $("#noNotificationtxt").html('You do not have any notifications ');
} }
var hiddenOperation = ".wr-hidden-operations-content > div"; var hiddenOperation = ".wr-hidden-operations-content > div";
$(hiddenOperation + '[data-operation="' + operation + '"]').show(); $(hiddenOperation + '[data-operation="' + operation + '"]').show();
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
@ -91,7 +92,7 @@ $(document).ready(function () {
loadNotifications(); loadNotifications();
$("#ast-container").on("click", ".new-notification", function (e) { $("#ast-container").on("click", ".new-notification", function(e) {
var notificationId = $(this).data("id"); var notificationId = $(this).data("id");
// var redirectUrl = $(this).data("url"); // var redirectUrl = $(this).data("url");
var query = deviceMgtAPIBaseURI + "/notifications" + "/" + notificationId + "/mark-checked"; var query = deviceMgtAPIBaseURI + "/notifications" + "/" + notificationId + "/mark-checked";

@ -28,6 +28,16 @@ function inputIsValid(regExp, inputString) {
return regExp.test(inputString); return regExp.test(inputString);
} }
/*
* Fix for the modal popup overlay disappear bug
*/
$('.modal').on('hidden.bs.modal', function () {
if ($('.modal-backdrop').length == 2) {
$('.modal-backdrop')[0].remove()
}
});
$(document).ready(function () { $(document).ready(function () {
var modalPopup = ".modal"; var modalPopup = ".modal";
// var modalPopupContainer = modalPopup + " .modal-content"; // var modalPopupContainer = modalPopup + " .modal-content";
@ -82,7 +92,8 @@ $(document).ready(function () {
$(errorMsg).text("Your current password does not match with the provided value."); $(errorMsg).text("Your current password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
$(errorMsg).text("An unexpected error occurred. Please try again later."); var response = JSON.parse(jqXHR.responseText).message;
$(errorMsg).text(response);
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} }
} }

@ -31,12 +31,8 @@
{{/if}} {{/if}}
</span> </span>
</a> </a>
<ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown" <ul class="dropdown-menu dropdown-menu-right slideInDown"
role="menu"> role="menu">
<li class="dropdown-header visible-xs">
{{@user.username}}<span class="caret"></span>
</li>
<li class="divider visible-xs"></li>
<li> <li>
<a href="javascript:void(0)" id="change-password">Change password</a> <a href="javascript:void(0)" id="change-password">Change password</a>
</li> </li>

@ -5180,18 +5180,17 @@ a:hover.multi-view.remove.enabled {
} }
a.grid-input-add { a.grid-input-add {
padding-top: 10px; margin-top:10px;
padding-bottom: 8px; margin-bottom:10px;
color: #9F9F9F; font-size: 14px;
text-decoration: none; border:1px solid #526A84;
float: left;
font-size: 15px;
} }
a.grid-input-add:hover, a.grid-input-add:active,a.grid-input-add:focus {
a:hover.grid-input-add { color:#333;
color: #A7E43A; border:1px solid #fff;
} }
a.grid-input-remove { a.grid-input-remove {
padding-top: 4px; padding-top: 4px;
padding-right: 10px; padding-right: 10px;

@ -30,13 +30,11 @@
</button> </button>
{{defineZone "navbarHeader"}} {{defineZone "navbarHeader"}}
</div> </div>
<div class="navbar-collapse collapse" aria-expanded="false"> <div id="navbar" class="navbar-collapse collapse" aria-expanded="false">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{{defineZone "navbarCollapsableLeftItems"}} {{defineZone "navbarCollapsableLeftItems"}}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> {{defineZone "navbarCollapsableRightItems"}}
{{defineZone "navbarCollapsableRightItems"}}
</ul>
</div> </div>
</div> </div>
{{defineZone "navbarBelow"}} {{defineZone "navbarBelow"}}

@ -3054,7 +3054,7 @@ tbody.collapse.in {
right: auto; right: auto;
} }
} }
@media (max-width : 480px) { @media (max-width : 768px) {
.navbar-right .dropdown-menu-right { .navbar-right .dropdown-menu-right {
left: auto; left: auto;
right: 0; right: 0;
@ -3901,6 +3901,33 @@ tbody.collapse.in {
margin-right: 0; margin-right: 0;
} }
} }
@media (max-width: 768px) {
.navbar-right {
margin-right: -15px;
}
.navbar-default .navbar-toggle{
}
.navbar-default .navbar-toggle .icon-bar{
background-color:#fff!important;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus{
background-color:#526a84!important;
}
.navbar-default .navbar-toggle:hover .icon-bar, .navbar-default .navbar-toggle:focus .icon-bar{
background-color:#798EA5!important;
}
.navbar-toggle {
margin-right: 10px;
padding: 13px;
margin-top: 0px;
margin-bottom: 0px;
}
#navbar .navbar-nav{
margin:0px;
border-bottom:1px solid #798EA5;
}
}
.navbar-default { .navbar-default {
background-color: #f8f8f8; background-color: #f8f8f8;
border-color: #e7e7e7; border-color: #e7e7e7;

@ -109,7 +109,7 @@ public class EmailSenderServiceImpl implements EmailSenderService {
Options options = new Options(); Options options = new Options();
options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap); options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
options.setProperty("FORCE_CONTENT_TYPE_BASED_FORMATTER", "true"); options.setProperty("FORCE_CONTENT_TYPE_BASED_FORMATTER", "true");
options.setProperty(Constants.Configuration.MESSAGE_TYPE, "text/html"); options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/xml");
options.setProperty(Constants.Configuration.CONTENT_TYPE, "text/html"); options.setProperty(Constants.Configuration.CONTENT_TYPE, "text/html");
options.setTo(new EndpointReference(EMAIL_URI_SCHEME + to)); options.setTo(new EndpointReference(EMAIL_URI_SCHEME + to));

@ -0,0 +1,32 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.wso2.carbon.device.mgt.oauth.extensions.OAuthExtUtils;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
@SuppressWarnings("unused")
public class ExtendedPasswordGrantHandler extends org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler {
@Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) {
return OAuthExtUtils.setScopes(tokReqMsgCtx);
}
}

@ -129,10 +129,13 @@ public class JWTClient {
JSONParser jsonParser = new JSONParser(); JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(response); JSONObject jsonObject = (JSONObject) jsonParser.parse(response);
AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); AccessTokenInfo accessTokenInfo = new AccessTokenInfo();
accessTokenInfo.setAccessToken((String) jsonObject.get(JWTConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME)); String accessToken = (String) jsonObject.get(JWTConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME);
accessTokenInfo.setRefreshToken((String) jsonObject.get(JWTConstants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); if (accessToken != null && !accessToken.isEmpty()) {
accessTokenInfo.setExpiresIn((Long) jsonObject.get(JWTConstants.OAUTH_EXPIRES_IN)); accessTokenInfo.setAccessToken(accessToken);
accessTokenInfo.setTokenType((String) jsonObject.get(JWTConstants.OAUTH_TOKEN_TYPE)); accessTokenInfo.setRefreshToken((String) jsonObject.get(JWTConstants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME));
accessTokenInfo.setExpiresIn((Long) jsonObject.get(JWTConstants.OAUTH_EXPIRES_IN));
accessTokenInfo.setTokenType((String) jsonObject.get(JWTConstants.OAUTH_TOKEN_TYPE));
}
return accessTokenInfo; return accessTokenInfo;
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
throw new JWTClientException("Invalid URL for token endpoint " + jwtConfig.getTokenEndpoint(), e); throw new JWTClientException("Invalid URL for token endpoint " + jwtConfig.getTokenEndpoint(), e);

@ -147,7 +147,7 @@ public class PolicyManagerImpl implements PolicyManager {
List<ProfileFeature> existingFeaturesList = new ArrayList<>(); List<ProfileFeature> existingFeaturesList = new ArrayList<>();
List<ProfileFeature> newFeaturesList = new ArrayList<>(); List<ProfileFeature> newFeaturesList = new ArrayList<>();
List<ProfileFeature> feturesToDelete = new ArrayList<>(); List<ProfileFeature> featuresToDelete = new ArrayList<>();
List<String> temp = new ArrayList<>(); List<String> temp = new ArrayList<>();
List<String> updateDFes = new ArrayList<>(); List<String> updateDFes = new ArrayList<>();
@ -169,7 +169,7 @@ public class PolicyManagerImpl implements PolicyManager {
// Check for the features to delete // Check for the features to delete
for (ProfileFeature feature : existingProfileFeaturesList) { for (ProfileFeature feature : existingProfileFeaturesList) {
if (!updateDFes.contains(feature.getFeatureCode())) { if (!updateDFes.contains(feature.getFeatureCode())) {
feturesToDelete.add(feature); featuresToDelete.add(feature);
} }
} }
@ -194,8 +194,8 @@ public class PolicyManagerImpl implements PolicyManager {
featureDAO.addProfileFeatures(newFeaturesList, profileId); featureDAO.addProfileFeatures(newFeaturesList, profileId);
} }
if (!feturesToDelete.isEmpty()) { if (!featuresToDelete.isEmpty()) {
for (ProfileFeature pf : feturesToDelete) for (ProfileFeature pf : featuresToDelete)
featureDAO.deleteProfileFeatures(pf.getId()); featureDAO.deleteProfileFeatures(pf.getId());
} }
@ -892,9 +892,9 @@ public class PolicyManagerImpl implements PolicyManager {
Policy policySaved = policyDAO.getAppliedPolicy(deviceId, device.getEnrolmentInfo().getId()); Policy policySaved = policyDAO.getAppliedPolicy(deviceId, device.getEnrolmentInfo().getId());
if (policySaved != null && policySaved.getId() != 0) { if (policySaved != null && policySaved.getId() != 0) {
if (policy.getId() != policySaved.getId()) { // if (policy.getId() != policySaved.getId()) {
policyDAO.updateEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy); policyDAO.updateEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy);
} // }
} else { } else {
policyDAO.addEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy); policyDAO.addEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy);
} }

@ -28,6 +28,10 @@
<!-- If it is true, the APIs of this instance will be published to the defined host --> <!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI> <PublishAPI>true</PublishAPI>
<!-- If it is true, the APIs of this instance will be updated when the webapps are redeployed -->
<EnabledUpdateApi>true</EnabledUpdateApi>
<!--Webapp will be published only when running below profiles--> <!--Webapp will be published only when running below profiles-->
<Profiles> <Profiles>
<Profile>default</Profile> <Profile>default</Profile>

@ -51,14 +51,26 @@
<Operation> <Operation>
<Name>DEVICE_INFO</Name> <Name>DEVICE_INFO</Name>
<RecurrentTimes>1</RecurrentTimes> <RecurrentTimes>1</RecurrentTimes>
<Platforms>
<platform>android</platform>
<platform>ios</platform>
</Platforms>
</Operation> </Operation>
<Operation> <Operation>
<Name>APPLICATION_LIST</Name> <Name>APPLICATION_LIST</Name>
<RecurrentTimes>5</RecurrentTimes> <RecurrentTimes>5</RecurrentTimes>
<Platforms>
<platform>android</platform>
<platform>ios</platform>
</Platforms>
</Operation> </Operation>
<Operation> <Operation>
<Name>DEVICE_LOCATION</Name> <Name>DEVICE_LOCATION</Name>
<RecurrentTimes>1</RecurrentTimes> <RecurrentTimes>1</RecurrentTimes>
<Platforms>
<platform>android</platform>
<platform>ios</platform>
</Platforms>
</Operation> </Operation>
</Operations> </Operations>
</TaskConfiguration> </TaskConfiguration>

@ -102,8 +102,8 @@ CREATE TABLE DM_ENROLMENT_OP_MAPPING (
ENROLMENT_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL,
OPERATION_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL,
STATUS VARCHAR(50) NULL, STATUS VARCHAR(50) NULL,
CREATED_TIMESTAMP INTEGER NOT NULL, CREATED_TIMESTAMP BIGINT NOT NULL,
UPDATED_TIMESTAMP INTEGER NOT NULL, UPDATED_TIMESTAMP BIGINT NOT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_DM_DEVICE_OPERATION_MAPPING_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES CONSTRAINT FK_DM_DEVICE_OPERATION_MAPPING_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
@ -436,7 +436,7 @@ CREATE TABLE DM_DEVICE_LOCATION (
ZIP VARCHAR(10) NULL, ZIP VARCHAR(10) NULL,
STATE VARCHAR(45) NULL, STATE VARCHAR(45) NULL,
COUNTRY VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL,
UPDATE_TIMESTAMP INTEGER NOT NULL, UPDATE_TIMESTAMP BIGINT NOT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC), INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC),
CONSTRAINT DM_DEVICE_LOCATION_DEVICE CONSTRAINT DM_DEVICE_LOCATION_DEVICE
@ -465,7 +465,7 @@ CREATE TABLE DM_DEVICE_DETAIL (
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL,
PLUGGED_IN INTEGER NULL, PLUGGED_IN INTEGER NULL,
UPDATE_TIMESTAMP INTEGER NOT NULL, UPDATE_TIMESTAMP BIGINT NOT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC), INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC),
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE

@ -1791,8 +1791,8 @@
<carbon.deployment.version>4.7.0</carbon.deployment.version> <carbon.deployment.version>4.7.0</carbon.deployment.version>
<!-- Carbon Identity --> <!-- Carbon Identity -->
<carbon.identity.framework.version>5.2.0</carbon.identity.framework.version> <carbon.identity.framework.version>5.2.1</carbon.identity.framework.version>
<identity.inbound.auth.oauth.version>5.1.2</identity.inbound.auth.oauth.version> <identity.inbound.auth.oauth.version>5.1.3</identity.inbound.auth.oauth.version>
<identity.inbound.auth.saml.version>5.1.1</identity.inbound.auth.saml.version> <identity.inbound.auth.saml.version>5.1.1</identity.inbound.auth.saml.version>
<!-- Carbon Multi-tenancy --> <!-- Carbon Multi-tenancy -->

Loading…
Cancel
Save