diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java index d41ba45a62..c36877d950 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java @@ -116,7 +116,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD public DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } @@ -302,7 +302,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } @@ -416,7 +416,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } @@ -531,7 +531,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD public List getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java index feb8b7024a..9c2f693186 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java @@ -188,7 +188,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java index b1a725e2bf..74f0cc4ee6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java @@ -190,7 +190,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java index a84b906f34..a4284938d2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java @@ -190,7 +190,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java index 26986df2fe..e8c8570a0d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java @@ -188,7 +188,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, SQLException { - if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { + if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) { throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } 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 b09c1e8149..0f966baf3b 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 @@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; +import org.wso2.carbon.email.sender.core.service.EmailSenderService; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; @@ -36,6 +37,7 @@ import java.util.HashMap; public class DeviceManagementDataHolder { + private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); private RealmService realmService; private TenantManager tenantManager; private DeviceManagementProviderService deviceManagerProvider; @@ -49,12 +51,8 @@ public class DeviceManagementDataHolder { private HashMap requireDeviceAuthorization = new HashMap<>(); private DeviceAccessAuthorizationService deviceAccessAuthorizationService; private GroupManagementProviderService groupManagementProviderService; - private TaskService taskService; - //private EmailSenderService emailSenderService; - - - private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); + private EmailSenderService emailSenderService; private DeviceManagementDataHolder() {} @@ -74,6 +72,10 @@ public class DeviceManagementDataHolder { this.setTenantManager(realmService); } + public TenantManager getTenantManager() { + return tenantManager; + } + private void setTenantManager(RealmService realmService) { if (realmService == null) { throw new IllegalStateException("Realm service is not initialized properly"); @@ -81,10 +83,6 @@ public class DeviceManagementDataHolder { this.tenantManager = realmService.getTenantManager(); } - public TenantManager getTenantManager() { - return tenantManager; - } - public DeviceManagementProviderService getDeviceManagementProvider() { return deviceManagerProvider; } @@ -189,13 +187,13 @@ public class DeviceManagementDataHolder { public void setTaskService(TaskService taskService) { this.taskService = taskService; } -// -// public EmailSenderService getEmailSenderService() { -// return emailSenderService; -// } -// -// public void setEmailSenderService(EmailSenderService emailSenderService) { -// this.emailSenderService = emailSenderService; -// } + + public EmailSenderService getEmailSenderService() { + return emailSenderService; + } + + public void setEmailSenderService(EmailSenderService emailSenderService) { + this.emailSenderService = emailSenderService; + } } 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 35f7e50f00..09ac3fcd90 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 @@ -54,6 +54,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceIm import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; +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; @@ -100,6 +101,12 @@ import java.util.List; * policy="dynamic" * bind="setConfigurationContextService" * unbind="unsetConfigurationContextService" + * @scr.reference name="email.sender.service" + * interface="org.wso2.carbon.email.sender.core.service.EmailSenderService" + * cardinality="0..1" + * policy="dynamic" + * bind="setEmailSenderService" + * unbind="unsetEmailSenderService" */ public class DeviceManagementServiceComponent { @@ -360,4 +367,18 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setConfigurationContextService(null); } + protected void setEmailSenderService(EmailSenderService emailSenderService) { + if (log.isDebugEnabled()) { + log.debug("Setting Email Sender Service"); + } + DeviceManagementDataHolder.getInstance().setEmailSenderService(emailSenderService); + } + + protected void unsetEmailSenderService(EmailSenderService emailSenderService) { + if (log.isDebugEnabled()) { + log.debug("Un-setting Email Sender Service"); + } + DeviceManagementDataHolder.getInstance().setEmailSenderService(null); + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 9d5e6b46d5..3324da66ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -47,6 +47,9 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import org.wso2.carbon.email.sender.core.ContentProviderInfo; +import org.wso2.carbon.email.sender.core.EmailContext; +import org.wso2.carbon.email.sender.core.EmailSendingFailedException; import org.wso2.carbon.email.sender.core.TypedValue; import org.wso2.carbon.user.api.UserStoreException; @@ -540,14 +543,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl())); params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP, new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl())); -// try { -// EmailContext ctx = -// new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-enrollment", params), -// metaInfo.getRecipients()).build(); -//// DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); -// } catch (EmailSendingFailedException e) { -// throw new DeviceManagementException("Error occurred while sending enrollment invitation", e); -// } + try { + EmailContext ctx = + new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-enrollment", params), + metaInfo.getRecipients()).build(); + DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); + } catch (EmailSendingFailedException e) { + throw new DeviceManagementException("Error occurred while sending enrollment invitation", e); + } } @Override @@ -565,14 +568,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl())); params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP, new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl())); -// try { -// EmailContext ctx = -// new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-registration", params), -// metaInfo.getRecipients()).build(); -// DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); -// } catch (EmailSendingFailedException e) { -// throw new DeviceManagementException("Error occurred while sending user registration notification", e); -// } + try { + EmailContext ctx = + new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-registration", params), + metaInfo.getRecipients()).build(); + DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); + } catch (EmailSendingFailedException e) { + throw new DeviceManagementException("Error occurred while sending user registration notification", e); + } } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag deleted file mode 100644 index 16d01c99a8..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag +++ /dev/null @@ -1,62 +0,0 @@ -<% -/* - * Copyright (c) 2015, 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. - */ -var uri = request.getRequestURI(); -var uriMatcher = new URIMatcher(String(uri)); - -var log = new Log("/api/operation-api.jag"); - -var utility = require('/app/modules/utility.js').utility; -var constants = require('/app/modules/constants.js'); -var operationModule = require("/app/modules/operation.js").operationModule; - -response.contentType = 'application/json'; - -var user = session.get(constants.USER_SESSION_KEY); - -var result; - -if (!user) { - response.sendRedirect("/devicemgt/login?#login-required"); - exit(); -} else { - if (uriMatcher.match("/{context}/api/operations/{deviceType}/stats")) { - var deviceType = uriMatcher.elements().deviceType; - var deviceId = request.getParameter("deviceId"); - var monitorOperations = operationModule.getMonitorOperations(deviceType); - var stats = []; - result = {}; - for (var op in monitorOperations) { - result = operationModule.handleGETOperation(deviceType, monitorOperations[op].operation, monitorOperations[op].name, deviceId); - stats.push(result.data); - } - result.data = stats; - } else if (uriMatcher.match("/{context}/api/operations/{deviceType}/{operation}")) { - var deviceType = uriMatcher.elements().deviceType; - var operation = uriMatcher.elements().operation; - var deviceId = request.getParameter("deviceId"); - var params = request.getAllParameters(); - result = operationModule.handlePOSTOperation(deviceType, operation, deviceId, params); - } -} - -// returning the result. -if (result) { - print(result); -} -%> diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag deleted file mode 100644 index fb9e2215d2..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag +++ /dev/null @@ -1,55 +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. - */ - -var uri = request.getRequestURI(); -var uriMatcher = new URIMatcher(String(uri)); - -var log = new Log("api/policy-api.jag"); - -var constants = require("/app/modules/constants.js"); -var policyModule = require("/app/modules/policy.js").policyModule; - -var deviceType, deviceId; - -var user = session.get(constants.USER_SESSION_KEY); - -var responseProcessor = require('utils').response; -response.contentType = 'application/json'; - -if (!user) { - response = responseProcessor.buildErrorResponse(response, 401, "Unauthorized"); -} else { - if (uriMatcher.match("/{context}/api/policies/add")) { - var content = request.getContent(); - var policyName = content.policyName; - var policyDefinition = content.profile.policyDefinition; - var policyDescription = content.profile.policyDescription; - deviceType = content.profile.deviceType.name; - deviceId = content.deviceId; - try { - response.content = policyModule.addPolicy(policyName, deviceType, policyDefinition, - policyDescription, deviceId); - } catch (e) { - log.error("Exception occurred while trying to add new policy under name:" + policyName, e); - // http status code 500 refers to - Internal Server Error. - responseProcessor.buildErrorResponse(response, 500, "Internal server error"); - } - } -} -%> diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs index 8852bbd67e..71e6eded33 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs @@ -48,7 +48,8 @@
- +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs index 7074e69854..5960212352 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs @@ -15,8 +15,7 @@
+{{#zone "bottomJs"}} + {{js "js/platform-configuration.js"}} +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js new file mode 100644 index 0000000000..f2704873a4 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js @@ -0,0 +1,120 @@ +/* + * 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. + */ + +$(document).ready(function () { + + var configParams = { + "NOTIFIER_TYPE": "notifierType", + "NOTIFIER_FREQUENCY": "notifierFrequency" + }; + + var responseCodes = { + "CREATED": "Created", + "SUCCESS": "201", + "INTERNAL_SERVER_ERROR": "Internal Server Error" + }; + + /** + * Checks if provided input is valid against RegEx input. + * + * @param regExp Regular expression + * @param inputString Input string to check + * @returns {boolean} Returns true if input matches RegEx + */ + function isPositiveInteger(str) { + return /^\+?(0|[1-9]\d*)$/.test(str); + } + + invokerUtil.get( + "/devicemgt_admin/configuration", + function (data) { + data = JSON.parse(data); + if (data && data.configuration) { + for (var i = 0; i < data.configuration.length; i++) { + var config = data.configuration[i]; + if (config.name == configParams["NOTIFIER_FREQUENCY"]) { + $("input#monitoring-config-frequency").val(config.value / 1000); + } + } + } + }, function (data) { + console.log(data); + }); + + /** + * Following click function would execute + * when a user clicks on "Save" button + * on General platform configuration page in WSO2 EMM Console. + */ + $("button#save-general-btn").click(function () { + var notifierFrequency = $("input#monitoring-config-frequency").val(); + var errorMsgWrapper = "#email-config-error-msg"; + var errorMsg = "#email-config-error-msg span"; + + if (!notifierFrequency) { + $(errorMsg).text("Monitoring frequency is a required field. It cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } else if (!isPositiveInteger(notifierFrequency)) { + $(errorMsg).text("Provided monitoring frequency is invalid. "); + $(errorMsgWrapper).removeClass("hidden"); + } else { + var addConfigFormData = {}; + var configList = new Array(); + + var monitorFrequency = { + "name": configParams["NOTIFIER_FREQUENCY"], + "value": String((notifierFrequency * 1000)), + "contentType": "text" + }; + + configList.push(monitorFrequency); + addConfigFormData.configuration = configList; + + var addConfigAPI = "/devicemgt_admin/configuration"; + invokerUtil.post( + addConfigAPI, + addConfigFormData, + function (data) { + data = JSON.parse(data); + if (data.statusCode == responseCodes["SUCCESS"]) { + $("#config-save-form").addClass("hidden"); + $("#record-created-msg").removeClass("hidden"); + } else if (data == 500) { + $(errorMsg).text("Exception occurred at backend."); + } else if (data == 403) { + $(errorMsg).text("Action was not permitted."); + } else { + $(errorMsg).text("An unexpected error occurred."); + } + + $(errorMsgWrapper).removeClass("hidden"); + }, function (data) { + data = data.status; + if (data == 500) { + $(errorMsg).text("Exception occurred at backend."); + } else if (data == 403) { + $(errorMsg).text("Action was not permitted."); + } else { + $(errorMsg).text("An unexpected error occurred."); + } + $(errorMsgWrapper).removeClass("hidden"); + } + ); + } + }); +}); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js index 32c7106125..489eee0bc2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js @@ -254,7 +254,7 @@ $(document).ready(function () { if (data.errorMessage) { $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); $(errorMsgWrapper).removeClass("hidden"); - } else if (data["status"] == 201) { + } else if (data["statusCode"] == 201) { // Clearing user input fields. $("input#username").val(""); $("input#firstname").val(""); @@ -265,17 +265,17 @@ $(document).ready(function () { $("#user-create-form").addClass("hidden"); $("#user-created-msg").removeClass("hidden"); generateQRCode("#user-created-msg .qr-code"); - } else if (data["status"] == 409) { + } else if (data["statusCode"] == 409) { $(errorMsg).text(data["messageFromServer"]); $(errorMsgWrapper).removeClass("hidden"); - } else if (data["status"] == 500) { + } else if (data["statusCode"] == 500) { $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); $(errorMsgWrapper).removeClass("hidden"); } }, function (data) { - if (data["status"] == 409) { + if (data["statusCode"] == 409) { $(errorMsg).text("User : " + username + " already exists. Pick another username."); - } else if (data["status"] == 500) { + } else if (data["statusCode"] == 500) { $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); } else { $(errorMsg).text(data.errorMessage); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf index 10170e9457..28ddcefb6c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf @@ -11,10 +11,6 @@ "url": "/api/groups/*", "path": "/api/group-api.jag" }, - { - "url": "/api/operations/*", - "path": "/api/operation-api.jag" - }, { "url": "/api/policies/*", "path": "/api/policy-api.jag" diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm deleted file mode 100644 index 25b3b26a0c..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm +++ /dev/null @@ -1,72 +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. -*# - - You have been invited to enroll your device in WSO2 EMM - - - - WSO2 Enterprise Mobility Manager - - -
-
-
-
- WSO2 -
-
-
-

- Hi $first-name, -

- -

- You have been invited to enrol your device in WSO2 Enterprise Mobility Manager. - Click here to download the WSO2 EMM client application to begin device - enrolment.

- -

- Should you need assistance, please contact your administrator. -

- -

- Regards, -

- -

- WSO2 EMM Administrator -

-
-
- - - - -
WSO2
-
-
-
- - - ]]> - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm deleted file mode 100644 index 56e95625e0..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm +++ /dev/null @@ -1,82 +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. -*# - - You have successfully been registered in WSO2 EMM - - - - WSO2 Enterprise Mobility Manager - - -
-
-
-
- WSO2 -
-
-
-

- Hi $first-name, -

- -

- You have been registered in WSO2 Enterprise Mobility Manager and invited to enrol your device. - Click here to download the WSO2 EMM client application to begin device - enrolment.

- -

- Use following credentials to log in to WSO2 EMM client application. -

- -

- Username: $username -
- Password: $password -

- -

- Should you need assistance, please contact your administrator. -

- -

- Regards, -

- -

- WSO2 EMM Administrator -

-
-
- - - - -
WSO2
-
-
-
- - - ]]> - -
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf index 63d198338f..a53516b80e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf @@ -3,5 +3,4 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/remote-appmanager-config.xml,target:${installFolder}/../../conf/etc/remote-appmanager-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\ \ No newline at end of file