diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationService.java index 8e2843cdc3..5f122b593a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationService.java @@ -18,7 +18,6 @@ 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 javax.ws.rs.*; @@ -28,9 +27,7 @@ import javax.ws.rs.core.Response; /** * 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 { /** diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index ca12f79a5b..874bf1b726 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -30,6 +30,7 @@ import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.api.FaultGatewaysException; import org.wso2.carbon.apimgt.api.model.*; 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.context.PrivilegedCarbonContext; import org.wso2.carbon.governance.lcm.util.CommonUtil; @@ -78,15 +79,17 @@ public class APIPublisherServiceImpl implements APIPublisherService { + api.getId().getVersion() + "'"); } } else { - if (provider.getAPI(api.getId()).getStatus() == APIStatus.CREATED) { - provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION); - } - api.setStatus(APIStatus.PUBLISHED); - provider.updateAPI(api); - if (log.isDebugEnabled()) { - log.debug("An API already exists with the name '" + api.getId().getApiName() + - "', context '" + api.getContext() + "' and version '" - + api.getId().getVersion() + "'. Thus, the API config is updated"); + if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { + if (provider.getAPI(api.getId()).getStatus() == APIStatus.CREATED) { + provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION); + } + api.setStatus(APIStatus.PUBLISHED); + provider.updateAPI(api); + if (log.isDebugEnabled()) { + log.debug("An API already exists with the name '" + api.getId().getApiName() + + "', context '" + api.getContext() + "' and version '" + + api.getId().getVersion() + "'. Thus, the API config is updated"); + } } } provider.saveSwagger20Definition(api.getId(), createSwaggerDefinition(api)); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index ea5e524fc3..df9102e351 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -32,6 +32,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static final Log log = LogFactory.getLog(APIPublisherStartupHandler.class); private static int retryTime = 2000; private static final int CONNECTION_RETRY_FACTOR = 2; + private static final int MAX_RETRY_COUNT = 5; private static Stack failedAPIsStack = new Stack<>(); private static Stack currentAPIsStack; @@ -44,33 +45,49 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { @Override public void completedServerStartup() { -// APIPublisherDataHolder.getInstance().setServerStarted(true); -// currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis(); -// Thread t = new Thread(new Runnable() { -// @Override -// public void run() { -// if (log.isDebugEnabled()) { -// log.debug("Server has just started, hence started publishing unpublished APIs"); -// log.debug("Total number of unpublished APIs: " -// + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); -// } -// publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); -// while (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty()) { -// try { -// retryTime = retryTime * CONNECTION_RETRY_FACTOR; -// Thread.sleep(retryTime); -// } catch (InterruptedException te) { -// log.error("Error occurred while sleeping", te); -// } -// if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { -// publishAPIs(currentAPIsStack, failedAPIsStack); -// } else { -// publishAPIs(failedAPIsStack, currentAPIsStack); -// } -// } -// } -// }); -// t.start(); + APIPublisherDataHolder.getInstance().setServerStarted(true); + currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis(); + Thread t = new Thread(new Runnable() { + @Override + public void run() { + if (log.isDebugEnabled()) { + log.debug("Server has just started, hence started publishing unpublished APIs"); + log.debug("Total number of unpublished APIs: " + + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); + } + publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); + int retryCount = 0; + while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { + try { + retryTime = retryTime * CONNECTION_RETRY_FACTOR; + Thread.sleep(retryTime); + } catch (InterruptedException te) { + //do nothing. + } + Stack failedApis; + if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { + publishAPIs(currentAPIsStack, failedAPIsStack); + failedApis = failedAPIsStack; + } else { + publishAPIs(failedAPIsStack, currentAPIsStack); + failedApis = currentAPIsStack; + } + 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 apis, Stack failedStack) { @@ -79,7 +96,6 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { try { publisher.publishAPI(api); } catch (Exception e) { - log.error("Error occurred while publishing API '" + api.getId().getApiName() + "'"); failedStack.push(api); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 3e46d4182f..07452e5a0e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -24,15 +24,12 @@ import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.api.model.*; 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.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.base.MultitenantConstants; 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 java.util.*; @@ -117,8 +114,6 @@ public class APIPublisherUtil { // adding scopes to the api Set uriTemplates = config.getUriTemplates(); Map apiScopes = new HashMap<>(); - Scope existingScope; - String existingPermissions; if (uriTemplates != null) { // this creates distinct scopes list for (URITemplate template : uriTemplates) { @@ -130,13 +125,6 @@ public class APIPublisherUtil { } } Set 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 api.setScopes(scopes); @@ -152,6 +140,7 @@ public class APIPublisherUtil { } api.setUriTemplates(uriTemplates); } + api.setCorsConfiguration(APIUtil.getDefaultCorsConfiguration()); return api; } @@ -324,34 +313,4 @@ public class APIPublisherUtil { 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 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); - - } - } - } - } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/WebappPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/WebappPublisherUtil.java index ca2f0cba13..17e2edb9a8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/WebappPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/WebappPublisherUtil.java @@ -18,16 +18,7 @@ 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.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.parsers.DocumentBuilder; @@ -40,10 +31,6 @@ import java.io.File; */ 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 { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 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; - } - } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/WebappPublisherConfig.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/WebappPublisherConfig.java index 902d4838db..faf94c8191 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/WebappPublisherConfig.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/WebappPublisherConfig.java @@ -40,6 +40,7 @@ public class WebappPublisherConfig { private String host; private boolean isPublished; + private boolean isEnabledUpdateApi; private Profiles profiles; private static WebappPublisherConfig config; @@ -77,6 +78,15 @@ public class WebappPublisherConfig { 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) { isPublished = published; } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index 11e991f349..d2932f994e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -49,72 +49,72 @@ public class APIPublisherLifecycleListener implements LifecycleListener { @Override public void lifecycleEvent(LifecycleEvent lifecycleEvent) { -// if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance() -// .isPublished()) { -// StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); -// ServletContext servletContext = context.getServletContext(); -// String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); -// boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); -// -// String profile = System.getProperty(PROPERTY_PROFILE); -// -// if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase()) -// && isManagedApi) { -// try { -// AnnotationProcessor annotationProcessor = new AnnotationProcessor(context); -// Set annotatedAPIClasses = annotationProcessor. -// scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName()); -// -// List apiDefinitions = annotationProcessor.extractAPIInfo(servletContext, -// annotatedAPIClasses); -// -// for (APIResourceConfiguration apiDefinition : apiDefinitions) { -// -// APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); -// -// try { -// int tenantId = APIPublisherDataHolder.getInstance().getTenantManager(). -// getTenantId(apiConfig.getTenantDomain()); -// -// boolean isTenantActive = APIPublisherDataHolder.getInstance(). -// getTenantManager().isTenantActive(tenantId); -// -// if (isTenantActive) { -// apiConfig.init(); -// API api = APIPublisherUtil.getAPI(apiConfig); -// boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted(); -// if (isServerStarted) { -// APIPublisherService apiPublisherService = -// APIPublisherDataHolder.getInstance().getApiPublisherService(); -// if (apiPublisherService == null) { -// throw new IllegalStateException( -// "API Publisher service is not initialized properly"); -// } -// apiPublisherService.publishAPI(api); -// } else { -// if (log.isDebugEnabled()) { -// log.debug("Server has not started yet. Hence adding API '" + -// api.getId().getApiName() + "' to the queue"); -// } -// APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api); -// } -// } else { -// log.error("No tenant [" + apiConfig.getTenantDomain() + "] " + -// "found when publishing the Web app"); -// } -// } catch (Throwable e) { -// log.error("Error occurred while publishing API '" + apiConfig.getName() + -// "' with the context '" + apiConfig.getContext() + -// "' and version '" + apiConfig.getVersion() + "'", e); -// } -// } -// } catch (IOException e) { -// log.error("Error encountered while discovering annotated classes", e); -// } catch (ClassNotFoundException e) { -// log.error("Error while scanning class for annotations", e); -// } -// } -// } + if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance() + .isPublished()) { + StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); + ServletContext servletContext = context.getServletContext(); + String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); + boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); + + String profile = System.getProperty(PROPERTY_PROFILE); + + if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase()) + && isManagedApi) { + try { + AnnotationProcessor annotationProcessor = new AnnotationProcessor(context); + Set annotatedAPIClasses = annotationProcessor. + scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName()); + + List apiDefinitions = annotationProcessor.extractAPIInfo(servletContext, + annotatedAPIClasses); + + for (APIResourceConfiguration apiDefinition : apiDefinitions) { + + APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); + + try { + int tenantId = APIPublisherDataHolder.getInstance().getTenantManager(). + getTenantId(apiConfig.getTenantDomain()); + + boolean isTenantActive = APIPublisherDataHolder.getInstance(). + getTenantManager().isTenantActive(tenantId); + + if (isTenantActive) { + apiConfig.init(); + API api = APIPublisherUtil.getAPI(apiConfig); + boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted(); + if (isServerStarted) { + APIPublisherService apiPublisherService = + APIPublisherDataHolder.getInstance().getApiPublisherService(); + if (apiPublisherService == null) { + throw new IllegalStateException( + "API Publisher service is not initialized properly"); + } + apiPublisherService.publishAPI(api); + } else { + if (log.isDebugEnabled()) { + log.debug("Server has not started yet. Hence adding API '" + + api.getId().getApiName() + "' to the queue"); + } + APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api); + } + } else { + log.error("No tenant [" + apiConfig.getTenantDomain() + "] " + + "found when publishing the Web app"); + } + } catch (Throwable e) { + log.error("Error occurred while publishing API '" + apiConfig.getName() + + "' with the context '" + apiConfig.getContext() + + "' and version '" + apiConfig.getVersion() + "'", e); + } + } + } catch (IOException e) { + log.error("Error encountered while discovering annotated classes", e); + } catch (ClassNotFoundException 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java index deb4f513ad..08e6f268df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java @@ -26,13 +26,14 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import java.util.ArrayList; import java.util.List; -@ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given " + - "criteria as a collection") +@ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given" + + " criteria as a collection") public class ActivityList extends BasePaginatedResult { private List activities; - @ApiModelProperty(value = "List of devices returned") + @ApiModelProperty(value = "Returns the list of activities that match the offset and limit parameter values" + + " that were specified.") @JsonProperty("activities") public List getList() { return activities; @@ -46,7 +47,6 @@ public class ActivityList extends BasePaginatedResult { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{\n"); - sb.append(" count: ").append(getCount()).append(",\n"); sb.append(" devices: [").append(activities).append("\n"); sb.append("]}\n"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java index 92ec04424f..422a3d3008 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java @@ -23,13 +23,13 @@ import io.swagger.annotations.ApiModelProperty; public class BasePaginatedResult { - private int count; - /** * Number of Resources returned. */ - @ApiModelProperty(value = "Number of resources returned.") + @ApiModelProperty(value = "Number of total resources.", example = "2") @JsonProperty("count") + private int count; + public int getCount() { return count; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java index 311c4e0634..bfd9afe99d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java @@ -29,7 +29,8 @@ public class RoleList extends BasePaginatedResult { private List roles; - @ApiModelProperty(value = "List of roles returned") + @ApiModelProperty(value = "Returns the list of roles that match the offset and limit parameter values " + + "that were specified.") @JsonProperty("roles") public List getList() { return roles; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java index d048ea75fd..6dd545899a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Response; /** * 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") @Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example operation details " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java index f33b4041fd..79ed861d53 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.Response; /** * 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") @Api(value = "Configuration Management", description = "The general platform configuration management capabilities are exposed " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java index 0c4fd54ea2..a3a72f6acd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java @@ -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. */ -@API(name = "Device Analytics Dashboard", - version = "1.0.0", context = "/api/device-mgt/v1.0/dashboard", tags = {"devicemgt_admin"}) +@API(name = "DeviceAnalyticsDashboard", + version = "1.0.0", context = "/api/device-mgt/v1.0/dashboard", tags = {"device_management"}) @Path("/dashboard") @Api(value = "Device Analytics Dashboard", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index b185bd368d..bb31cd0e4d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -39,7 +39,7 @@ import javax.ws.rs.core.Response; /** * 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") @Api(value = "Device Management", description = "This API carries all device management related operations " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java index 8aa54a5378..6b79aa6c84 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java @@ -39,8 +39,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@API(name = "Device Type Management", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/device-types", - tags = {"devicemgt_admin"}) +@API(name = "DeviceTypeManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/device-types", + tags = {"device_management"}) @Path("/device-types") @Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java index 9611a27783..ce409aa02c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java @@ -53,7 +53,7 @@ import java.util.List; /** * Device group related REST-API. This can be used to manipulated device group related details. */ -@API(name = "Group Management", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"devicemgt_admin"}) +@API(name = "Group Management", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"}) @Path("/groups") @Api(value = "Device Group Management", description = "This API carries all device group management related operations " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java index e0a2a3b1f7..7d27488483 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java @@ -35,8 +35,8 @@ import javax.ws.rs.core.Response; /** * Notifications related REST-API. */ -@API(name = "Device Notification Management", version = "1.0.0", context = "/api/device-mgt/v1.0/notifications", - tags = {"devicemgt_admin"}) +@API(name = "DeviceNotificationManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/notifications", + tags = {"device_management"}) @Api(value = "Device Notification Management", description = "Device notification related operations can be found here.") @Path("/notifications") @Produces(MediaType.APPLICATION_JSON) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index 70edb9126f..8bee52deb8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -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, * groups. */ -@API(name = "Device Policy Management", version = "1.0.0", context = "/api/device-mgt/v1.0/policies", - tags = {"devicemgt_admin"}) +@API(name = "DevicePolicyManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/policies", + tags = {"device_management"}) @Api(value = "Device Policy Management", description = "This API carries all the necessary functionalities " + "around device policy management") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java index 0a9b5e8056..79c3946130 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java @@ -32,7 +32,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; 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") @Api(value = "Role Management", description = "Role management related operations can be found here.") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index 1a5e3440ef..b98c147446 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.Response; 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") @Api(value = "User Management", description = "User management related operations can be found here.") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java index fb7acdb95b..ed4ce0d8e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java @@ -33,7 +33,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; 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") @Api(value = "Application Management Administrative Service", description = "This an API intended to be used by " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java index 1f4e059375..3c4f57df81 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java @@ -29,8 +29,8 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@API(name = "Device Management Admin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/devices", - tags = {"devicemgt_admin"}) +@API(name = "DeviceManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/devices", + tags = {"device_management"}) @Path("/admin/devices") @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. " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java index b908520834..670fcab323 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -39,7 +39,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; 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") @Produces(MediaType.APPLICATION_JSON) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java index 026910d8e2..65a7c8f64e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java @@ -30,7 +30,7 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; 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") @Produces(MediaType.APPLICATION_JSON) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java index 45cadd4738..32503d4c3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java @@ -29,12 +29,12 @@ import java.util.HashMap; import java.util.Map; @SwaggerDefinition( - basePath = "/api-device-mgt-v1.0", + basePath = "/api/device-mgt/v1.0", host = "localhost:9443" ) public class SecurityDefinitionConfigurator implements ReaderListener { - public static final String TOKEN_AUTH_SCHEME = "tokenAuthScheme"; + public static final String TOKEN_AUTH_SCHEME = "swagger_auth"; @Override public void beforeScan(Reader reader, Swagger swagger) { @@ -45,9 +45,10 @@ public class SecurityDefinitionConfigurator implements ReaderListener { public void afterScan(Reader reader, Swagger swagger) { OAuth2Definition tokenScheme = new OAuth2Definition(); tokenScheme.setType("oauth2"); - tokenScheme.setFlow("password"); - tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth/token"); - tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth/authorize"); + tokenScheme.setFlow("application"); + tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token"); + tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize"); + tokenScheme.addScope("write:everything", "Full access"); Map schemes = new HashMap<>(); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java index 3a7f39b6e6..5b0e234218 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java @@ -28,12 +28,20 @@ import java.io.Serializable; "uniquely.") public class DeviceIdentifier implements Serializable{ + @ApiModelProperty( + name = "id", + value = "Identity of the device.", + required = true, + example = "123456") @JsonProperty(value = "id", required = true) - @ApiModelProperty(name = "id", value = "Identity of the device.", required = true) private String id; + @ApiModelProperty( + name = "type", + value = "Type of the device.", + required = true, + example = "android") @JsonProperty(value = "type", required = true) - @ApiModelProperty(name = "type", value = "Type of the device.", required = true) private String type; public DeviceIdentifier() {} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java index 2c720b4025..e7d01bd5c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java @@ -25,8 +25,8 @@ import io.swagger.annotations.ApiModelProperty; import java.util.List; -@ApiModel(value = "Activity", description = "Each activity instance has a unique identifier that can be " + - "used to identify an operation instance.") +@ApiModel(value = "Activity", description = "An activity instance carries a unique identifier that can be " + + "used to identify a particular operation instance uniquely") public class Activity { public enum Type { @@ -35,36 +35,40 @@ public class Activity { @ApiModelProperty( name = "activityId", - value = "The unique activity identifier", - required = true) + value = "Activity identifier", + required = true, + example = "ACTIVITY_1") @JsonProperty("activityId") private String activityId; @ApiModelProperty( name = "code", - value = "The activity code", - required = true) + value = "Activity code", + required = true, + example = "DEVICE_RING") @JsonProperty("code") private String code; @ApiModelProperty( name = "type", - value = "The type of the activity, such as CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY.", + value = "Activity type", required = true, - allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY") + allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY", + example = "COMMAND") @JsonProperty("type") private Type type; @ApiModelProperty( name = "createdTimeStamp", - value = "The recorded timestamp of when the activity took place.", - required = true) + value = "Timestamp recorded when the activity took place", + required = true, + example = "Thu Oct 06 11:18:47 IST 2016") @JsonProperty("createdTimestamp") private String createdTimeStamp; @ApiModelProperty( name = "activityStatuses", - value = "The collection of statuses for a given activity.", + value = "Collection of statuses corresponding to the activity", required = true) @JsonProperty("activityStatuses") private List activityStatus; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java index 28aeb08a76..1007c18058 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java @@ -43,7 +43,8 @@ public class ActivityStatus { @ApiModelProperty( name = "status", value = "Status of the activity performed.", - required = true) + required = true, + example = "PENDING") @JsonProperty("status") private Status status; @@ -57,7 +58,8 @@ public class ActivityStatus { @ApiModelProperty( name = "updatedTimestamp ", value = "Last updated time of the activity.", - required = true) + required = true, + example = "Thu Oct 06 11:18:47 IST 2016") @JsonProperty("updatedTimestamp") private String updatedTimestamp; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationResponse.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationResponse.java index 5b3e99104f..1d4ed19588 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationResponse.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationResponse.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.common.operation.mgt; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -26,10 +27,20 @@ import io.swagger.annotations.ApiModelProperty; + " responses") public class OperationResponse { - @ApiModelProperty(name = "response", value = "Operation response returned from the device", required = true) + @ApiModelProperty( + name = "response", + value = "Operation response returned from the device", + required = true, + example = "SUCCESSFUL") + @JsonProperty("response") private String response; - @ApiModelProperty(name = "receivedTimeStamp", value = "Time that the operation response received", - required = true) + + @ApiModelProperty( + name = "receivedTimeStamp", + value = "Time that the operation response received", + required = true, + example = "Thu Oct 06 11:18:47 IST 2016") + @JsonProperty("receivedTimeStamp") private String receivedTimeStamp; public String getResponse() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/task/TaskConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/task/TaskConfiguration.java index 8b099b1b24..14efb787f2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/task/TaskConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/task/TaskConfiguration.java @@ -79,6 +79,8 @@ public class TaskConfiguration { private String operationName; private int recurrency; + private List platforms; + @XmlElement(name = "Name", required = true) public String getOperationName() { @@ -97,5 +99,16 @@ public class TaskConfiguration { public void setRecurrency(int recurrency) { this.recurrency = recurrency; } + + @XmlElementWrapper(name = "Platforms") + @XmlElement(name = "platform", required = true) + public List getPlatforms() { + return platforms; + } + + public void setPlatforms(List platforms) { + this.platforms = platforms; + } + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 7f5f5f5e97..ea50220644 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -57,14 +57,6 @@ public class DeviceManagementDataHolder { private EmailSenderService emailSenderService; private PushNotificationProviderRepository pushNotificationProviderRepository; - public APIManagerConfiguration getApiManagerConfiguration() { - return apiManagerConfiguration; - } - - public void setApiManagerConfiguration(APIManagerConfiguration apiManagerConfiguration) { - this.apiManagerConfiguration = apiManagerConfiguration; - } - private APIManagerConfiguration apiManagerConfiguration; private DeviceManagementDataHolder() {} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index f871964569..7e1c95efda 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.device.mgt.common.DeviceManagementException; 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.spi.DeviceManagementService; 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.ApplicationManagerProviderServiceImpl; 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.permission.mgt.PermissionManagerServiceImpl; 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.DeviceManagementProviderServiceImpl; 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.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.ConfigurationContextService; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -120,10 +115,6 @@ public class DeviceManagementServiceComponent { private static List listeners = new ArrayList<>(); private static List deviceManagers = new ArrayList<>(); private static List 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) { synchronized (LOCK) { @@ -157,18 +148,11 @@ public class DeviceManagementServiceComponent { DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig(); - APIManagerConfiguration apiManagerConfiguration = new APIManagerConfiguration(); - apiManagerConfiguration.load(APIM_CONFIGURATION_PATH); - DeviceManagementDataHolder.getInstance().setApiManagerConfiguration(apiManagerConfiguration); - DeviceManagementDAOFactory.init(dsConfig); GroupManagementDAOFactory.init(dsConfig); NotificationManagementDAOFactory.init(dsConfig); OperationManagementDAOFactory.init(dsConfig); - String apiManagerDataSource = apiManagerConfiguration.getFirstProperty(DATA_SOURCE_NAME); - ScopeManagementDAOFactory.init(apiManagerDataSource); - /* Initialize Operation Manager */ this.initOperationsManager(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java index 1ced4b898f..4546002188 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java @@ -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.util.NotificationDAOUtil; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; 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. */ 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 public List getAllNotifications(PaginationRequest request, int tenantId) throws diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 5fc20e67d8..9465918956 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -314,7 +314,7 @@ public class OperationManagerImpl implements OperationManager { deviceId.getId() + "'"); } - EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); + EnrolmentInfo enrolmentInfo = this.getEnrolmentInfo(deviceId); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for given device " + "Identifier:" + deviceId.getId() + " and given type" + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/ScopeManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/ScopeManagementServiceImpl.java deleted file mode 100644 index e476fc5cad..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/ScopeManagementServiceImpl.java +++ /dev/null @@ -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 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 scopeKeys, String roleName) throws ScopeManagementException { - List scopes = new ArrayList<>(); - try { - List 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 getAllScopes() throws ScopeManagementException { - List 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 getScopesOfRole(String roleName) throws ScopeManagementException { - if (roleName == null || roleName.isEmpty()) { - throw new ScopeManagementException("Role name is null or empty"); - } - List filteredScopes = new ArrayList<>(); - try { - ScopeManagementDAOFactory.openConnection(); - List 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 scopes = this.getScopesOfRole(roleName); - String roles[]; - ArrayList 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); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAO.java deleted file mode 100644 index b15efcc2e7..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAO.java +++ /dev/null @@ -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 scopes) throws ScopeManagementDAOException; - - /** - * This method is used to retrieve all the scopes. - * - * @return List of scopes. - * @throws ScopeManagementDAOException - */ - List 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 getScopesHavingRole(String roleName) throws ScopeManagementDAOException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOException.java deleted file mode 100644 index 61ea7de2e2..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOException.java +++ /dev/null @@ -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); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOFactory.java deleted file mode 100644 index cb53d76f29..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOFactory.java +++ /dev/null @@ -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 currentConnection = new ThreadLocal(); - - 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; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOUtil.java deleted file mode 100644 index 570b4ce07d..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/ScopeManagementDAOUtil.java +++ /dev/null @@ -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); - } - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/impl/ScopeManagementDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/impl/ScopeManagementDAOImpl.java deleted file mode 100644 index 676da007d3..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/scope/mgt/dao/impl/ScopeManagementDAOImpl.java +++ /dev/null @@ -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 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 getAllScopes() throws ScopeManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - List 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 getScopesHavingRole(String roleName) throws ScopeManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - List 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 getScopesFromResultSet(ResultSet rs) throws SQLException { - List 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; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/TaskOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/TaskOperation.java index e7dc35b1bd..6777841ed3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/TaskOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/TaskOperation.java @@ -20,6 +20,8 @@ package org.wso2.carbon.device.mgt.core.task; +import java.util.List; + /** * This is the bean for the operations added by the task. */ @@ -27,6 +29,15 @@ public class TaskOperation { private String taskName; private int recurrentTimes; + private List taskPlatforms; + + public List getTaskPlatforms() { + return taskPlatforms; + } + + public void setTaskPlatforms(List taskPlatforms) { + this.taskPlatforms = taskPlatforms; + } public String getTaskName() { return taskName; @@ -43,5 +54,6 @@ public class TaskOperation { public void setRecurrentTimes(int recurrentTimes) { this.recurrentTimes = recurrentTimes; } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java index 5041f71a6c..dafd763e61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java @@ -53,16 +53,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { List ops = taskConfiguration.getOperations(); List taskOperations = new ArrayList<>(); - for (TaskConfiguration.Operation op : ops) { TaskOperation taskOperation = new TaskOperation(); taskOperation.setTaskName(op.getOperationName()); taskOperation.setRecurrentTimes(op.getRecurrency()); + taskOperation.setTaskPlatforms(op.getPlatforms()); taskOperations.add(taskOperation); } return taskOperations; } + public List getPlatformsForOperations(String opName) { + List operationPlatforms = new ArrayList<>(); + TaskConfiguration taskConfiguration = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration(); + List ops = taskConfiguration.getOperations(); + for (TaskConfiguration.Operation op : ops) { + if (op.getOperationName().equals(opName)) { + List platform = op.getPlatforms(); + for (String operationPlatform : platform) { + operationPlatforms.add(operationPlatform); + } + } + } + return operationPlatforms; + } + @Override public int getTaskFrequency() throws DeviceMgtTaskException { return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration(). @@ -84,29 +100,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { @Override public void addOperations() throws DeviceMgtTaskException { + List deviceTypes; DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). getDeviceManagementProvider(); try { - List deviceTypes = deviceManagementProviderService.getAvailableDeviceTypes(); List devices; List operations = this.getValidOperationNames(); - - for (String deviceType : deviceTypes) { - devices = deviceManagementProviderService.getAllDevices(deviceType); - if (!devices.isEmpty()) { - for (String str : operations) { - CommandOperation operation = new CommandOperation(); - operation.setEnabled(true); - operation.setType(Operation.Type.COMMAND); - operation.setCode(str); - deviceManagementProviderService.addOperation(deviceType, operation, - DeviceManagerUtil.getValidDeviceIdentifiers(devices)); - } - } else { - if (log.isDebugEnabled()) { - log.debug("No devices are available to perform the operations."); - } - } + for (String taskOperation : operations) { + deviceTypes = getPlatformsForOperations(taskOperation); + for (String deviceType : deviceTypes) { + devices = deviceManagementProviderService.getAllDevices(deviceType); + if (!devices.isEmpty()) { + for (String str : operations) { + CommandOperation operation = new CommandOperation(); + operation.setEnabled(true); + operation.setType(Operation.Type.COMMAND); + operation.setCode(str); + deviceManagementProviderService.addOperation(deviceType, operation, + DeviceManagerUtil.getValidDeviceIdentifiers(devices)); + } + } else { + if (log.isDebugEnabled()) { + log.debug("No devices are available to perform the operations."); + } + } + + } } } catch (InvalidDeviceException e) { throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e); @@ -145,6 +164,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { return opNames; } + + @Override public boolean isTaskOperation(String opName) { try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 97b955ae7d..9322773d37 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -19,7 +19,7 @@ "owner": "admin@carbon.super", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "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", "callbackUrl": "%https.ip%/api/device-mgt/v1.0" }, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index f38e2b69fa..26233a32d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -226,13 +226,14 @@ deviceModule = function () { publicMethods.getDevices = function (userName) { var url = devicemgtProps["httpsURL"] + - devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/user/" + userName; + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices"; return serviceInvokers.XMLHttp.get( url, function (responsePayload) { - for (var i = 0; i < responsePayload.length; i++) { - responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type); + var devices = JSON.parse(responsePayload.responseText).devices; + for (var i = 0; i < devices.length; i++) { + devices[i].thumb = utility.getDeviceThumb(devices[i].type); } - return responsePayload; + return devices; }, function (responsePayload) { log.error(responsePayload); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.notification.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.notification.listing/listing.hbs index b2b78e87c8..7e91f28497 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.notification.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.notification.listing/listing.hbs @@ -15,8 +15,20 @@ specific language governing permissions and limitations under the License. }} +{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.ui.title" pageTitle="Notification Listing"}} - +{{#zone "breadcrumbs"}} +
  • + + + +
  • +
  • + + Notifications + +
  • +{{/zone}} {{#zone "content"}} {{unit "cdmf.unit.notification.listing"}} {{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js index f9d8c14c2c..65445b3929 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js @@ -20,7 +20,10 @@ var sortUpdateBtn = "#sortUpdateBtn"; var sortedIDs; var dataTableSelection = '.DTTT_selected'; -$('#policy-grid').datatables_extended(); +var settings = { + "sorting": false +}; +$('#policy-grid').datatables_extended(settings); $(".icon .text").res_text(0.2); var saveNewPrioritiesButton = "#save-new-priorities-button"; @@ -90,7 +93,7 @@ function showPopup() { function hidePopup() { $(modalPopupContent).html(''); $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); + $('body').removeClass('modal-open').css('padding-right', '0px'); $('.modal-backdrop').remove(); } @@ -208,7 +211,7 @@ $(document).ready(function () { }, function () { $("#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()); showPopup(); $("a#save-policy-priorities-error-link").click(function () { @@ -222,7 +225,7 @@ $(document).ready(function () { $(".policy-unpublish-link").click(function () { var policyList = getSelectedPolicies(); 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()); showPopup(); } else { @@ -266,7 +269,7 @@ $(document).ready(function () { $(".policy-publish-link").click(function () { var policyList = getSelectedPolicies(); 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()); showPopup(); } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index b27dfbe698..d5cb812ce2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -45,9 +45,9 @@ var isInit = true; * 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); -} ); +}); /* @@ -72,7 +72,7 @@ function showPopup() { function hidePopup() { $(modalPopupContent).html(''); $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); + $('body').removeClass('modal-open').css('padding-right', '0px'); $('.modal-backdrop').remove(); } @@ -95,7 +95,7 @@ function loadRoles() { var objects = []; - $(data.roles).each(function( index ) { + $(data.roles).each(function (index) { objects.push( { name: data.roles[index], @@ -182,10 +182,13 @@ function loadRoles() { var options = { "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(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index 4a69e76672..43d6de1a83 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -50,9 +50,9 @@ var body = "body"; * 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); -} ); +}); /* * set popup maximum height function. @@ -75,7 +75,7 @@ function showPopup() { function hidePopup() { $(modalPopupContent).html(''); $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); + $('body').removeClass('modal-open').css('padding-right', '0px'); $('.modal-backdrop').remove(); } @@ -270,13 +270,14 @@ function loadUsers() { var objects = []; - $(data.users).each( function (index) { + $(data.users).each(function (index) { objects.push({ 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 : "", - emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress : "", - DT_RowId : "user-" + data.users[index].username}) + emailAddress: data.users[index].emailAddress ? data.users[index].emailAddress : "", + DT_RowId: "user-" + data.users[index].username + }) }); var json = { @@ -300,7 +301,7 @@ function loadUsers() { class: "remove-padding icon-only content-fill", data: null, render: function (data, type, row, meta) { - return '
    ' + + return '
    ' + '' + '
    '; } @@ -338,7 +339,7 @@ function loadUsers() { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, render: function (data, type, row, meta) { - var editbtn= '  ' + ' ' + @@ -377,13 +378,13 @@ function loadUsers() { ''; var returnbtnSet = ''; - if($("#can-edit").length > 0) { + if ($("#can-edit").length > 0) { returnbtnSet = returnbtnSet + editbtn; } - if($("#can-reset-password").length > 0) { + if ($("#can-reset-password").length > 0) { returnbtnSet = returnbtnSet + resetPasswordbtn; } - if($("#can-remove").length > 0) { + if ($("#can-remove").length > 0) { returnbtnSet = returnbtnSet + removebtn; } @@ -395,10 +396,14 @@ function loadUsers() { var options = { "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(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js index 339b60f069..bcbbbae3f9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js @@ -29,6 +29,15 @@ $.fn.datatables_extended = function(settings){ } //--- 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( $.extend({},{ bSortCellsTop: true, @@ -131,24 +140,41 @@ $.fn.datatables_extended = function(settings){ /** * create sorting dropdown menu for list table advance operations */ - var dropdownmenu = $(''); - $('.sort-row th', elem).each(function(){ - if(!$(this).hasClass('no-sort')){ - dropdownmenu.append('
  • ' + $(this).html() + '
  • '); - } - }); + var table = this; + if(table.hasClass('sorting-enabled')){ + var dropdownmenu = $(''); + $('.sort-row th', elem).each(function () { + if (!$(this).hasClass('no-sort')) { + dropdownmenu.append('
  • ' + $(this).html() + '
  • '); + } + }); + } + + function getAdvanceToolBar(){ + if(table.hasClass('sorting-enabled')){ + return '' + }else{ + return '' + }; + } + /** * 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( + getAdvanceToolBar() ); /** @@ -186,14 +212,14 @@ $.fn.datatables_extended = function(settings){ $(button).addClass("active").html('Cancel'); $(button).parent().next().children("button").removeClass("disabled"); // EMM related code - $(".viewEnabledIcon").unbind("click"); + $(document).off('click','.viewEnabledIcon'); //--- End of EMM related codes } else if ($(button).html() == 'Cancel'){ thisTable.removeClass("table-selectable"); $(button).addClass("active").html('Select'); $(button).parent().next().children().addClass("disabled"); // EMM related function - $(".viewEnabledIcon").bind("click", InitiateViewOption); + $(document).on('click','.viewEnabledIcon',InitiateViewOption); //--- End of EMM related codes } }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js index 3dc7ce83d0..243df02a4d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js @@ -29,13 +29,23 @@ * 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) { var elem = $(this); // EMM related function 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; @@ -44,22 +54,22 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte //--- End of EMM related codes $(elem).DataTable( - $.extend({},{ + $.extend({}, { serverSide: true, processing: false, searching: true, - ordering: false, + ordering: false, filter: false, bSortCellsTop: true, - ajax : { + ajax: { url: context + "/api/data-tables/invoker", - data : function (params) { + data: function (params) { var i; var searchParams = {}; for (i = 0; i < params.columns.length; i++) { searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value); } - if(options) { + if (options) { searchParams[options.searchKey] = encodeURIComponent(params.search.value); } params.filter = JSON.stringify(searchParams); @@ -78,14 +88,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte columns: columns, responsive: false, autoWidth: false, - dom:'<"dataTablesTop"' + - 'f' + - '<"dataTables_toolbar">' + - '>' + - 'rt' + - '<"dataTablesBottom"' + - 'lip' + - '>', + dom: '<"dataTablesTop"' + + 'f' + + '<"dataTables_toolbar">' + + '>' + + 'rt' + + '<"dataTablesBottom"' + + 'lip' + + '>', language: { searchPlaceholder: options.placeholder, search: '' @@ -110,7 +120,7 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte ); column - //.search(val ? '^' + val + '$' : '', true, false) + //.search(val ? '^' + val + '$' : '', true, false) .search(val ? val : '', true, false) .draw(); @@ -184,24 +194,42 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte /** * create sorting dropdown menu for list table advance operations */ - var dropdownmenu = $(''); - $('.sort-row th', elem).each(function () { - if (!$(this).hasClass('no-sort')) { - dropdownmenu.append('
  • ' + $(this).html() + '
  • '); + var table = this; + if (table.hasClass('sorting-enabled')) { + var dropdownmenu = $(''); + $('.sort-row th', elem).each(function () { + if (!$(this).hasClass('no-sort')) { + dropdownmenu.append('
  • ' + $(this).html() + '
  • '); + } + }); + } + + function getAdvanceToolBar() { + if (table.hasClass('sorting-enabled')) { + return '' + } else { + return '' } - }); + ; + } + /** * 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( + getAdvanceToolBar() ); /** @@ -239,14 +267,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte $(button).addClass("active").html('Cancel'); $(button).parent().next().children("button").removeClass("disabled"); // EMM related code - $(document).off('click','.viewEnabledIcon'); + $(document).off('click', '.viewEnabledIcon'); //--- End of EMM related codes } else if ($(button).html() == 'Cancel') { thisTable.removeClass("table-selectable"); $(button).addClass("active").html('Select'); $(button).parent().next().children().addClass("disabled"); // EMM related function - $(document).on('click','.viewEnabledIcon',InitiateViewOption); + $(document).on('click', '.viewEnabledIcon', InitiateViewOption); //--- End of EMM related codes } }); @@ -305,6 +333,6 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte } }) } - },settings) + }, settings) ); }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs index 3579228ec4..9c936870be 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs @@ -1,203 +1,515 @@ -{{! - 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. -}} +{{unit "mdm.unit.lib.leaflet"}} +{{unit "cdmf.unit.lib.qrcode"}} +{{unit "mdm.unit.device.qr-modal"}} {{#zone "content"}} -

    - Device {{device.name}} - {{#if device.viewModel.model}} - - ( {{device.viewModel.vendor}} {{device.viewModel.model}} ) - - {{/if}} -

    -
    -
    -
    -
    -
    - {{#defineZone "device-thumbnail"}} - - {{/defineZone}} + {{#if deviceFound}} + {{#if isAuthorized}} +

    + Device {{deviceView.name}} + {{#if deviceView.model}} + + ( {{deviceView.vendor}} {{deviceView.model}} ) + + {{/if}} +

    +
    +
    +
    +
    -
    -
    -
    - Device Overview - {{label}}
    - {{unit "cdmf.unit.device.overview-section" device=device}} - {{#defineZone "operation-status"}}{{/defineZone}} - {{#defineZone "device-opetations"}} +
    +
    Device + Overview +
    + {{#defineZone "device-detail-properties"}} + + + {{#if deviceView.deviceIdentifier}} + + + + + {{/if}} + {{#if deviceView.name}} + + + + + {{/if}} + {{#if deviceView.vendor}} + {{#if deviceView.model}} + + + + + {{/if}} + {{/if}} + {{#if deviceView.status}} + + + + + {{/if}} + {{#if deviceView.owner}} + + + + + {{/if}} + {{#if deviceView.ownership}} + + + + + {{/if}} + {{#if deviceView.imei}} + + + + + {{/if}} + {{#if deviceView.udid}} + + + + + {{/if}} + {{#if deviceView.osBuildDate}} + + + + + {{/if}} + {{#if deviceView.phoneNumber}} + + + + + {{/if}} + {{#if deviceView.lastUpdatedTime}} + + + + + {{/if}} + +
    Device ID{{deviceView.deviceIdentifier}}
    Name{{deviceView.name}}
    Model{{deviceView.vendor}} {{deviceView.model}}
    Status + {{#equal deviceView.status "ACTIVE"}}Active{{/equal}} + {{#equal deviceView.status "INACTIVE"}}Inactive{{/equal}} + {{#equal deviceView.status "BLOCKED"}}Blocked{{/equal}} + {{#equal deviceView.status "REMOVED"}}Removed{{/equal}} +
    Owner{{deviceView.owner}}
    Ownership{{deviceView.ownership}}
    IMEI{{deviceView.imei}}
    UDID{{deviceView.udid}}
    Firmware Build + Date + {{deviceView.osBuildDate}}
    Phone Number{{deviceView.phoneNumber}}
    Last Update{{deviceView.lastUpdatedTime}}
    + {{/defineZone}}
    Operations
    -
    - {{unit "cdmf.unit.device.operation-bar" device=device}} +
    + {{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}}
    - {{/defineZone}} +
    -
    -
    +
    + -
    -
    Policies
    -
    - -
    -
    - No policies found + {{#defineZone "device-detail-properties"}} +
    +
    + + + {{#if deviceView.isNotWindows}} +
    + + +
    +
    +
    + + {{#equal deviceView.deviceType "windows"}} +
    +

    Not + available yet

    +
    + {{/equal}} + {{#if deviceView.deviceInfoAvailable}} + {{#if deviceView.BatteryLevel}} +
    +
    +
    +
    BATTERY
    +
    +
    +
    + {{deviceView.BatteryLevel.value}} % +
    +
    +
    +
    +
    + {{/if}} + + + + + + + + + + + + + + + + {{#if deviceView.ramUsage}} +
    +
    +
    +
    RAM Usage
    +
    +
    +
    + {{deviceView.ramUsage.value}} % +
    +
    +
    +
    +
    + {{/if}} + {{#if deviceView.internalMemory}} +
    +
    +
    +
    Local Storage
    +
    +
    +
    +
    + {{deviceView.internalMemory.usage}} % + + TOTAL OF {{deviceView.internalMemory.total}} GB + +
    +
    +
    +
    +
    + {{/if}} + {{#if deviceView.externalMemory}} +
    +
    +
    +
    External Storage
    +
    +
    +
    + {{deviceView.externalMemory.usage}} % + + TOTAL OF {{deviceView.externalMemory.total}} GB + +
    +
    +
    +
    +
    + {{/if}} + {{else}} +
    +

    + + Battery, RAM and Storage related information are not + available yet. +

    +
    + {{/if}} +
    +
    +
    +
    + {{/if}} + +
    + + +
    +
    + + + + + + +
    +
    +
    +
    -
    -
    -
    - - - - - Add device specific policy -
    +
    + + +
    +
    + {{#if deviceView.location}} +
    +
    + {{else}} +
    +

    + + Device location information is not available. +

    +
    +

    +

    +

    + {{/if}} +
    +
    +
    +
    + + -
    -
    Device Location
    -
    -
    -
    -
    - Not available yet -
    -
    -
    -
    -
    -
    Operations Log
    -
    - -
    -
    - Not available yet +
    + + +
    +
    + + + + + + +
    +
    +

    + + There are no operations, performed yet on this device. +

    +
    +
    + + + + + + + + + + +
    Operation CodeStatusRequest created at
    +
    +
    -
    -
    + {{/defineZone}}
    -
    - {{/defineZone}} -
    + {{else}} +

    + Permission Denied +

    +
    + You are not authorized to view specified device in the system. + {{/if}} + {{else}} +

    + Device not found +

    +
    + You have tried to access either a removed or non-existing device. + {{/if}} {{/zone}} {{#zone "bottomJs"}} - {{js "js/device-view.js"}} - - - - + {{#if isAuthorized}} + + + + + + + {{js "js/device-detail.js"}} + + {{js "js/load-map.js"}} + {{/if}} {{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs index b542e9037c..b0ca5a7e98 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs @@ -21,10 +21,10 @@
    -
    -

    Device Notifications

    -
    -
    +

    + Device Notifications +

    +
    @@ -43,7 +43,7 @@
    -
    +
    No unread messages
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 29026b8278..f77c0f5a3f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -47,8 +47,11 @@ function loadNotifications() { viewModel["appContext"] = context; var content = template(viewModel); $("#ast-container").html(content); - $("#unread-notifications").datatables_extended(); - $("#all-notifications").datatables_extended(); + var settings = { + "sorting" : false + }; + $("#unread-notifications").datatables_extended(settings); + $("#all-notifications").datatables_extended(settings); } } }, @@ -65,15 +68,13 @@ function loadNotifications() { function showAdvanceOperation(operation, button) { $(button).addClass('selected'); $(button).siblings().removeClass('selected'); - if ($(button).attr("id") == 'allNotifications') { - $("#ast-container").html('
    You do not have any unread notifications
    '); + $("#noNotificationtxt").html('You do not have any unread notifications '); } else if ($(button).attr("id") == 'unReadNotifications') { - $("#ast-container").html('
    You do not have any notifications
    '); + $("#noNotificationtxt").html('You do not have any notifications '); } else { - $("#ast-container").html('
    You do not have any notifications
    '); + $("#noNotificationtxt").html('You do not have any notifications '); } - var hiddenOperation = ".wr-hidden-operations-content > div"; $(hiddenOperation + '[data-operation="' + operation + '"]').show(); $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); @@ -91,7 +92,7 @@ $(document).ready(function () { loadNotifications(); - $("#ast-container").on("click", ".new-notification", function (e) { + $("#ast-container").on("click", ".new-notification", function(e) { var notificationId = $(this).data("id"); // var redirectUrl = $(this).data("url"); var query = deviceMgtAPIBaseURI + "/notifications" + "/" + notificationId + "/mark-checked"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js index c22b5c2923..f5e03d86c8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js @@ -28,6 +28,16 @@ function inputIsValid(regExp, 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 () { var modalPopup = ".modal"; // var modalPopupContainer = modalPopup + " .modal-content"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs index d2aba63fdc..60ac43c41e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs @@ -31,12 +31,8 @@ {{/if}} -
    - {{defineZone "navbarBelow"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css index 7e81de65e0..02283db595 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css @@ -3054,7 +3054,7 @@ tbody.collapse.in { right: auto; } } -@media (max-width : 480px) { +@media (max-width : 768px) { .navbar-right .dropdown-menu-right { left: auto; right: 0; @@ -3901,6 +3901,33 @@ tbody.collapse.in { 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 { background-color: #f8f8f8; border-color: #e7e7e7; diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java index 393350445f..ba21fd81fd 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java +++ b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java @@ -109,7 +109,7 @@ public class EmailSenderServiceImpl implements EmailSenderService { Options options = new Options(); options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap); 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.setTo(new EndpointReference(EMAIL_URI_SCHEME + to)); diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java new file mode 100644 index 0000000000..8a5be8bc8d --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java @@ -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); + } + +} diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java index 55da4229b3..d117ef1eca 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java @@ -129,10 +129,13 @@ public class JWTClient { JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(response); AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); - accessTokenInfo.setAccessToken((String) jsonObject.get(JWTConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME)); - 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)); + String accessToken = (String) jsonObject.get(JWTConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); + if (accessToken != null && !accessToken.isEmpty()) { + accessTokenInfo.setAccessToken(accessToken); + 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; } catch (MalformedURLException e) { throw new JWTClientException("Invalid URL for token endpoint " + jwtConfig.getTokenEndpoint(), e); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 3c390780e6..ee86ca0804 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -147,7 +147,7 @@ public class PolicyManagerImpl implements PolicyManager { List existingFeaturesList = new ArrayList<>(); List newFeaturesList = new ArrayList<>(); - List feturesToDelete = new ArrayList<>(); + List featuresToDelete = new ArrayList<>(); List temp = new ArrayList<>(); List updateDFes = new ArrayList<>(); @@ -169,7 +169,7 @@ public class PolicyManagerImpl implements PolicyManager { // Check for the features to delete for (ProfileFeature feature : existingProfileFeaturesList) { if (!updateDFes.contains(feature.getFeatureCode())) { - feturesToDelete.add(feature); + featuresToDelete.add(feature); } } @@ -194,8 +194,8 @@ public class PolicyManagerImpl implements PolicyManager { featureDAO.addProfileFeatures(newFeaturesList, profileId); } - if (!feturesToDelete.isEmpty()) { - for (ProfileFeature pf : feturesToDelete) + if (!featuresToDelete.isEmpty()) { + for (ProfileFeature pf : featuresToDelete) featureDAO.deleteProfileFeatures(pf.getId()); } diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml index bae1565071..214e5aa38d 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml @@ -28,6 +28,10 @@ true + + + true + default diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index 97340bd5a3..fd2f2a5fe6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -51,14 +51,26 @@ DEVICE_INFO 1 + + android + ios + APPLICATION_LIST 5 + + android + ios + DEVICE_LOCATION 1 + + android + ios + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index 40adb654e0..414cad3662 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -102,8 +102,8 @@ CREATE TABLE DM_ENROLMENT_OP_MAPPING ( ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, STATUS VARCHAR(50) NULL, - CREATED_TIMESTAMP INTEGER NOT NULL, - UPDATED_TIMESTAMP INTEGER NOT NULL, + CREATED_TIMESTAMP BIGINT NOT NULL, + UPDATED_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_OPERATION_MAPPING_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -436,7 +436,7 @@ CREATE TABLE DM_DEVICE_LOCATION ( ZIP VARCHAR(10) NULL, STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, - UPDATE_TIMESTAMP INTEGER NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC), CONSTRAINT DM_DEVICE_LOCATION_DEVICE @@ -465,7 +465,7 @@ CREATE TABLE DM_DEVICE_DETAIL ( TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, PLUGGED_IN INTEGER NULL, - UPDATE_TIMESTAMP INTEGER NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE diff --git a/pom.xml b/pom.xml index 378ead1e73..acacfbbc51 100644 --- a/pom.xml +++ b/pom.xml @@ -1791,8 +1791,8 @@ 4.7.0 - 5.2.0 - 5.1.2 + 5.2.1 + 5.1.3 5.1.1