diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java
index 3454559912..f70ab278a5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Device.java
@@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.api;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.core.service.DeviceManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@@ -30,7 +31,9 @@ import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -231,4 +234,52 @@ public class Device {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
-}
\ No newline at end of file
+
+ /**
+ * Update device.
+ *
+ * @return update status.
+ */
+ @PUT
+ @Path("type/{type}/id/{deviceId}")
+ public Response updateDevice(@PathParam("type") String deviceType, @PathParam("deviceId") String deviceId,
+ org.wso2.carbon.device.mgt.common.Device updatedDevice) {
+ try {
+ DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setType(deviceType);
+ deviceIdentifier.setId(deviceId);
+ org.wso2.carbon.device.mgt.common.Device device = deviceManagementService.getDevice(deviceIdentifier);
+ device.setName(updatedDevice.getName());
+ device.setDescription(updatedDevice.getDescription());
+ Boolean response = deviceManagementService.modifyEnrollment(device);
+ return Response.status(Response.Status.OK).entity(response).build();
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while fetching the list of device types.";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
+ /**
+ * disenroll device.
+ *
+ * @return disenrollment status.
+ */
+ @DELETE
+ @Path("type/{type}/id/{deviceId}")
+ public Response disenrollDevice(@PathParam("type") String deviceType, @PathParam("deviceId") String deviceId) {
+ try {
+ DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setType(deviceType);
+ deviceIdentifier.setId(deviceId);
+ Boolean response = deviceManagementService.disenrollDevice(deviceIdentifier);
+ return Response.status(Response.Status.OK).entity(response).build();
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while fetching the list of device types.";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java
index bcbe451109..a0d789b00f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Policy.java
@@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
-import org.wso2.carbon.device.mgt.jaxrs.util.MDMUtil;
+import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
@@ -62,7 +62,7 @@ public class Policy {
policy.setPolicyName(policyWrapper.getPolicyName());
policy.setProfileId(policyWrapper.getProfileId());
policy.setDescription(policyWrapper.getDescription());
- policy.setProfile(MDMUtil.convertProfile(policyWrapper.getProfile()));
+ policy.setProfile(DeviceMgtUtil.convertProfile(policyWrapper.getProfile()));
policy.setOwnershipType(policyWrapper.getOwnershipType());
policy.setRoles(policyWrapper.getRoles());
policy.setUsers(policyWrapper.getUsers());
@@ -82,7 +82,7 @@ public class Policy {
policy.setPolicyName(policyWrapper.getPolicyName());
policy.setProfileId(policyWrapper.getProfileId());
policy.setDescription(policyWrapper.getDescription());
- policy.setProfile(MDMUtil.convertProfile(policyWrapper.getProfile()));
+ policy.setProfile(DeviceMgtUtil.convertProfile(policyWrapper.getProfile()));
policy.setOwnershipType(policyWrapper.getOwnershipType());
policy.setRoles(policyWrapper.getRoles());
policy.setUsers(policyWrapper.getUsers());
@@ -181,7 +181,7 @@ public class Policy {
policy.setId(policyId);
policy.setProfileId(policyWrapper.getProfileId());
policy.setDescription(policyWrapper.getDescription());
- policy.setProfile(MDMUtil.convertProfile(policyWrapper.getProfile()));
+ policy.setProfile(DeviceMgtUtil.convertProfile(policyWrapper.getProfile()));
policy.setOwnershipType(policyWrapper.getOwnershipType());
policy.setRoles(policyWrapper.getRoles());
policy.setUsers(policyWrapper.getUsers());
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java
similarity index 98%
rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMUtil.java
rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java
index 1c9f188148..c2f5c2b701 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMUtil.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java
@@ -24,7 +24,7 @@ import org.wso2.carbon.policy.mgt.common.Profile;
import java.util.ArrayList;
import java.util.List;
-public class MDMUtil {
+public class DeviceMgtUtil {
public static Profile convertProfile(org.wso2.carbon.device.mgt.jaxrs.beans.Profile mdmProfile) {
Profile profile = new Profile();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
index e99164cdb2..1768fa9160 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
@@ -206,6 +206,20 @@
GET
+
+ Modify user device
+ /device-mgt/user/devices/update
+ /devices/type/*/id/*
+ PUT
+
+
+
+ Remove user device
+ /device-mgt/user/devices/remove
+ /devices/type/*/id/*
+ DELETE
+
+
@@ -241,6 +255,13 @@
/devices/name/*/*
GET
+
+
+ List All Own Devices
+ /device-mgt/user/devices/list
+ /devices/user/*
+ GET
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ProvisioningConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ProvisioningConfig.java
new file mode 100644
index 0000000000..a82904001c
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ProvisioningConfig.java
@@ -0,0 +1,39 @@
+/*
+ * 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.common;
+
+public class ProvisioningConfig {
+
+ private String providerTenantDomain;
+ private boolean isSharedWithAllTenants;
+
+ public ProvisioningConfig(String providerTenantDomain, boolean sharedWithAllTenants) {
+ this.providerTenantDomain = providerTenantDomain;
+ isSharedWithAllTenants = sharedWithAllTenants;
+ }
+
+ public String getProviderTenantDomain() {
+ return providerTenantDomain;
+ }
+
+ public boolean isSharedWithAllTenants() {
+ return isSharedWithAllTenants;
+ }
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/PushNotificationConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/PushNotificationConfig.java
new file mode 100644
index 0000000000..8bced1717e
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/PushNotificationConfig.java
@@ -0,0 +1,41 @@
+/*
+ * 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.common.push.notification;
+
+import java.util.Set;
+
+public class PushNotificationConfig {
+
+ private String type;
+ private Set properties;
+
+ public PushNotificationConfig(String type, Set properties) {
+ this.type = type;
+ this.properties = properties;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public Set getProperties() {
+ return properties;
+ }
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
index 80bf030305..25f11458c1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
@@ -18,13 +18,11 @@
*/
package org.wso2.carbon.device.mgt.common.spi;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
+import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
-import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
-
-import java.util.List;
+import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
/**
* Composite interface that acts as the SPI exposing all device management as well as application management
@@ -32,33 +30,16 @@ import java.util.List;
*/
public interface DeviceManagementService {
- /**
- * Method to retrieve the provider type that implements DeviceManager interface.
- *
- * @return Returns provider type
- */
- String getType();
-
- /**
- * This returns the tenant domain of the provider.
- * @return
- */
- String getProviderTenantDomain();
-
- /**
- * returns true if the device type is shared between all tenants and false if its not.
- *
- * @return
- */
- boolean isSharedWithAllTenants();
-
void init() throws DeviceManagementException;
+ String getType();
+
DeviceManager getDeviceManager();
ApplicationManager getApplicationManager();
- void notifyOperationToDevices(Operation operation,
- List deviceIds) throws DeviceManagementException;
+ ProvisioningConfig getProvisioningConfig();
+
+ PushNotificationConfig getPushNotificationConfig();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
index 594d1be5e7..5403bf2a1b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
@@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
+import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
@@ -44,8 +45,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
String deviceType = provider.getType();
- String tenantDomain = provider.getProviderTenantDomain();
- boolean isSharedWithAllTenants = provider.isSharedWithAllTenants();
+
+ ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
+ String tenantDomain = provisioningConfig.getProviderTenantDomain();
+ boolean isSharedWithAllTenants = provisioningConfig.isSharedWithAllTenants();
int tenantId = DeviceManagerUtil.getTenantId(tenantDomain);
if (tenantId == -1) {
throw new DeviceManagementException("No tenant available for tenant domain " + tenantDomain);
@@ -57,7 +60,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
provider.init();
DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants);
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType,
- provider.getDeviceManager().requireDeviceAuthorization());
+ provider.getDeviceManager().requireDeviceAuthorization());
}
} catch (DeviceManagementException e) {
@@ -75,13 +78,15 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
}
public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
- String deviceTypeName=provider.getType();
- if(provider.isSharedWithAllTenants()){
- DeviceTypeIdentifier deviceTypeIdentifier =new DeviceTypeIdentifier(deviceTypeName);
+ String deviceTypeName = provider.getType();
+
+ ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
+ if (provisioningConfig.isSharedWithAllTenants()) {
+ DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName);
providers.remove(deviceTypeIdentifier);
- }else{
- int providerTenantId=DeviceManagerUtil.getTenantId(provider.getProviderTenantDomain());
- DeviceTypeIdentifier deviceTypeIdentifier =new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
+ } else {
+ int providerTenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
+ DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
providers.remove(deviceTypeIdentifier);
}
}
@@ -113,15 +118,17 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
for (DeviceManagementService provider : providers.values()) {
try {
provider.init();
- int tenantId=DeviceManagerUtil.getTenantId(provider.getProviderTenantDomain());
- DeviceManagerUtil.registerDeviceType(provider.getType(), tenantId, provider.isSharedWithAllTenants());
+
+ ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
+ int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
+ DeviceManagerUtil.registerDeviceType(provider.getType(), tenantId, provisioningConfig.isSharedWithAllTenants());
//TODO:
//This is a temporory fix.
//windows and IOS cannot resolve user info by extracting certs
//until fix that, use following variable to enable and disable of checking user authorization.
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
- provider.getDeviceManager().requireDeviceAuthorization());
+ provider.getDeviceManager().requireDeviceAuthorization());
} catch (Throwable e) {
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
etc - should not block the initialization of other device management providers */
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 73487be49c..88bd74cdaa 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
@@ -753,17 +753,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
public void notifyOperationToDevices(Operation operation, List deviceIds)
throws DeviceManagementException {
- try {
- for (DeviceIdentifier deviceId : deviceIds) {
- DeviceManagementService dms =
- getPluginRepository().getDeviceManagementService(deviceId.getType(), this.getTenantId());
- dms.notifyOperationToDevices(operation, deviceIds);
- }
- } catch (DeviceManagementException deviceMgtEx) {
- String errorMsg = "Error in notify operations to plugins for app installation:" +
- deviceMgtEx.getErrorMessage();
- log.error(errorMsg, deviceMgtEx);
- throw new DeviceManagementException(errorMsg, deviceMgtEx);
+ for (DeviceIdentifier deviceId : deviceIds) {
+ DeviceManagementService dms =
+ getPluginRepository().getDeviceManagementService(deviceId.getType(), this.getTenantId());
+ //TODO FIX THIS WITH PUSH NOTIFICATIONS
+ //dms.notifyOperationToDevices(operation, deviceIds);
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
index 1e8c533d7e..67e7d2a4f8 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
@@ -20,8 +20,10 @@ package org.wso2.carbon.device.mgt.core;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
+import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import java.util.List;
@@ -40,14 +42,6 @@ public class TestDeviceManagementService implements DeviceManagementService {
return providerType;
}
- @Override
- public String getProviderTenantDomain() { return tenantDomain;}
-
- @Override
- public boolean isSharedWithAllTenants() {
- return true;
- }
-
@Override
public void init() throws DeviceManagementException {
@@ -64,9 +58,13 @@ public class TestDeviceManagementService implements DeviceManagementService {
}
@Override
- public void notifyOperationToDevices(Operation operation, List deviceIds)
- throws DeviceManagementException {
+ public ProvisioningConfig getProvisioningConfig() {
+ return new ProvisioningConfig(tenantDomain, false);
+ }
+ @Override
+ public PushNotificationConfig getPushNotificationConfig() {
+ return null;
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
index c2865c13b4..43ee2fc82c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
@@ -97,61 +97,6 @@ deviceModule = function () {
}
};
- /*
- @Deprecated
- */
- publicMethods.listDevicesForUser = function (username) {
- var carbonUser = session.get(constants.USER_SESSION_KEY);
- var utility = require('/app/modules/utility.js').utility;
- if (!carbonUser) {
- log.error("User object was not found in the session");
- throw constants.ERRORS.USER_NOT_FOUND;
- }
- try {
- utility.startTenantFlow(carbonUser);
- var deviceManagementService = utility.getDeviceManagementService();
- var devices = deviceManagementService.getDevicesOfUser(username);
- var deviceList = [];
- var i, device, propertiesList, deviceObject;
- for (i = 0; i < devices.size(); i++) {
- device = devices.get(i);
- propertiesList = DeviceManagerUtil.convertDevicePropertiesToMap(device.getProperties());
-
- deviceObject = {};
- deviceObject[constants.DEVICE_IDENTIFIER] =
- privateMethods.validateAndReturn(device.getDeviceIdentifier());
- deviceObject[constants.DEVICE_NAME] =
- privateMethods.validateAndReturn(device.getName());
- deviceObject[constants.DEVICE_OWNERSHIP] =
- privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwnership());
- deviceObject[constants.DEVICE_OWNER] =
- privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwner());
- deviceObject[constants.DEVICE_TYPE] =
- privateMethods.validateAndReturn(device.getType());
- deviceObject[constants.DEVICE_PROPERTIES] = {};
- if (device.getType() == constants.PLATFORM_IOS) {
- deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
- privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_PRODUCT));
- deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] = constants.VENDOR_APPLE;
- } else {
- deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
- privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_MODEL));
- deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] =
- privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_VENDOR));
- }
- deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_OS_VERSION] =
- privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_OS_VERSION));
-
- deviceList.push(deviceObject);
- }
- return deviceList;
- } catch (e) {
- throw e;
- } finally {
- utility.endTenantFlow();
- }
- };
-
/*
@Deprecated
*/
@@ -298,8 +243,7 @@ deviceModule = function () {
deviceObject[constants["DEVICE_PROPERTIES"]] = properties;
return deviceObject;
}
- }
- ,
+ },
function (responsePayload) {
var response = {};
response["status"] = "error";
@@ -321,8 +265,7 @@ deviceModule = function () {
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
- }
- ,
+ },
function (responsePayload) {
log.error(responsePayload);
return -1;
@@ -335,8 +278,7 @@ deviceModule = function () {
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
- }
- ,
+ },
function (responsePayload) {
log.error(responsePayload);
return -1;
@@ -344,14 +286,12 @@ deviceModule = function () {
);
};
-
publicMethods.getDeviceTypes = function () {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
- }
- ,
+ },
function (responsePayload) {
log.error(responsePayload);
return -1;
@@ -383,86 +323,20 @@ deviceModule = function () {
return license;
};
- publicMethods.getOwnDevices = function () {
- var listAllDevicesEndPoint = deviceCloudService + "/device/user/" + user.username + "/all";
- var result = get(listAllDevicesEndPoint, {}, "json");
- var devices = result.data;
- var device;
- for (var d in devices){
- device = devices[d];
- device.assetId = publicMethods.getAssetId(device.deviceType);
- }
- return result;
- };
-
- publicMethods.getAllPermittedDevices = function () {
- var groupModule = require("/app/modules/group.js").groupModule;
-
- var result = publicMethods.getUnGroupedDevices();
- var unGroupedDevices = result.data;
- var user_groups = groupModule.getGroups().data;
- var allDevices = [];
- var deviceCount = unGroupedDevices.length;
- for (var g in user_groups) {
- var deviceInGroup = user_groups[g].devices;
- deviceCount += deviceInGroup.length;
- if (deviceInGroup && deviceInGroup.length == 0) {
- delete user_groups[g]["devices"];
- }
- var device;
- for (var d in deviceInGroup){
- device = deviceInGroup[d];
- device.assetId = publicMethods.getAssetId(device.type);
- }
- allDevices.push(user_groups[g]);
- }
- allDevices.push({id: 0, devices: unGroupedDevices});
- result.data = allDevices;
- result.device_count = deviceCount;
- return result;
- };
-
- publicMethods.removeDevice = function (deviceType, deviceId) {
- var carbonUser = session.get(constants.USER_SESSION_KEY);
- if (!carbonUser) {
- log.error("User object was not found in the session");
- throw constants.ERRORS.USER_NOT_FOUND;
- }
- try {
- utility.startTenantFlow(carbonUser);
- var deviceManagementService = utility.getDeviceManagementService();
- var deviceIdentifier = new DeviceIdentifier();
- deviceIdentifier.setType(deviceType);
- deviceIdentifier.setId(deviceId);
- return deviceManagementService.disenrollDevice(deviceIdentifier);
- } catch (e) {
- throw e;
- } finally {
- utility.endTenantFlow();
- }
- };
-
- publicMethods.updateDevice = function (deviceType, deviceId, deviceName) {
- var carbonUser = session.get(constants.USER_SESSION_KEY);
- if (!carbonUser) {
- log.error("User object was not found in the session");
- throw constants.ERRORS.USER_NOT_FOUND;
- }
- try {
- utility.startTenantFlow(carbonUser);
- var deviceManagementService = utility.getDeviceManagementService();
- var deviceIdentifier = new DeviceIdentifier();
- deviceIdentifier.setType(deviceType);
- deviceIdentifier.setId(deviceId);
- var device = deviceManagementService.getDevice(deviceIdentifier);
- device.setName(deviceName);
- return deviceManagementService.modifyEnrollment(device);
- } catch (e) {
- throw e;
- } finally {
- utility.endTenantFlow();
- }
+ publicMethods.getDevices = function (userName) {
+ var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName;
+ return serviceInvokers.XMLHttp.get(
+ url, function (responsePayload) {
+ for (var i = 0; i < responsePayload.length; i++) {
+ responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type);
+ }
+ return responsePayload;
+ },
+ function (responsePayload) {
+ log.error(responsePayload);
+ return -1;
+ }
+ );
};
-
return publicMethods;
}();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js
index 490ee8aee5..a4ee8c1256 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js
@@ -67,8 +67,7 @@ policyModule = function () {
policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"];
policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"];
policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]["name"];
- policyObjectToView["icon"] = devicemgtProps["httpsURL"] + devicemgtProps["appContext"] +
- "public/cdmf.unit.device.type." + policyObjectToView["platform"] + ".type-view/images/thumb.png";
+ policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]);
policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"];
policyObjectToView["roles"] = privateMethods.
getElementsInAString(policyObjectFromRestEndpoint["roles"]);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js
index 07fbe79cc7..185c2fa029 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js
@@ -18,6 +18,9 @@
var utility;
utility = function () {
+
+ var constants = require('/app/modules/constants.js');
+ var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
var log = new Log("/app/modules/utility.js");
var JavaClass = Packages.java.lang.Class;
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -104,26 +107,43 @@ utility = function () {
};
publicMethods.getOperationIcon = function (deviceType, operation) {
- var iconPath = "/app/units/cdmf.unit.device.type."
- + deviceType + ".type-view/public/images/operations/" + operation + ".png";
+ var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");
+ var iconPath = "/app/units/" + unitName + "/public/images/operations/" + operation + ".png";
var icon = new File(iconPath);
if (icon.isExists()) {
- return "public/cdmf.unit.device.type." + deviceType + ".type-view/images/operations/" + operation + ".png";
+ return devicemgtProps["appContext"] + "public/" + unitName + "/images/operations/" + operation + ".png";
} else {
return null;
}
};
publicMethods.getDeviceThumb = function (deviceType) {
- var iconPath = "/app/units/cdmf.unit.device.type."
- + deviceType + ".type-view/public/images/thumb.png";
+ var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");
+ var iconPath = "/app/units/" + unitName + "/public/images/thumb.png";
var icon = new File(iconPath);
if (icon.isExists()) {
- return "/devicemgt/public/cdmf.unit.device.type." + deviceType + ".type-view/images/thumb.png";
+ return devicemgtProps["appContext"] + "public/" + unitName + "/images/thumb.png";
} else {
return null;
}
};
+ publicMethods.getTenantedDeviceUnitName = function (deviceType, unitPostfix) {
+ var user = session.get(constants.USER_SESSION_KEY);
+ if (!user) {
+ log.error("User object was not found in the session");
+ throw constants.ERRORS.USER_NOT_FOUND;
+ }
+ var unitName = user.domain + "cdmf.unit.device.type." + deviceType + "." + unitPostfix;
+ if (new File("/app/units/" + unitName).isExists()) {
+ return unitName;
+ }
+ unitName = "cdmf.unit.device.type." + deviceType + "." + unitPostfix;
+ if (new File("/app/units/" + unitName).isExists()) {
+ return unitName;
+ }
+ return null;
+ };
+
return publicMethods;
}();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.js
index 517c375afe..693769dd11 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.js
@@ -39,9 +39,8 @@ function onRequest(context) {
}
return {
- "deviceTypeViewUnitName": "cdmf.unit.device.type." + deviceType + ".type-view",
+ "deviceTypeViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "type-view"),
"deviceType": deviceType,
"label" : configs["deviceType"]["label"]
};
}
-
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.js
index 54200bef94..21ce993020 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.js
@@ -17,6 +17,7 @@
*/
function onRequest(context){
+ var utility = require("/app/modules/utility.js").utility;
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlebars Helper equal needs 2 parameters");
@@ -28,6 +29,5 @@ function onRequest(context){
});
var deviceType = context.uriParams.deviceType;
-
- return {"deviceViewUnitName" : "cdmf.unit.device.type." + deviceType + ".device-view"};
-}
\ No newline at end of file
+ return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")};
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs
index e890993cd9..2966fa09a2 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs
@@ -326,7 +326,6 @@
{{#zone "bottomJs"}}
{{js "js/listing.js"}}
-{{/zone}}
\ No newline at end of file
+{{/zone}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
index 6a376bb028..0dbaa5cff0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
@@ -35,8 +35,8 @@ function onRequest(context) {
if (currentUser) {
page.permissions = {};
page.permissions.list = stringify(userModule.getUIPermissions());
- if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/add")) {
- permissions.enroll = true;
+ if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/add")) {
+ page.permissions.enroll = true;
}
page.currentUser = currentUser;
var deviceCount = 0;
@@ -58,7 +58,8 @@ function onRequest(context) {
deviceTypes.push({
"type": data[i].name,
"category": deviceType.category,
- "label": deviceType.label
+ "label": deviceType.label,
+ "thumb": utility.getDeviceThumb(data[i].name)
});
}
}
@@ -66,4 +67,4 @@ function onRequest(context) {
}
}
return page;
-}
\ 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.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
index 545c12eee0..8fb5a9e958 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
@@ -96,7 +96,7 @@ $(document).ready(function () {
console.log(message);
}, function(message){
console.log(message.content);
- });
+ });
});
});
@@ -213,6 +213,16 @@ function loadDevices(searchType, searchParam){
return type;
}
+ function getDeviceTypeThumb(type) {
+ var deviceTypes = deviceListing.data("deviceTypes");
+ for (var i = 0; i < deviceTypes.length; i++) {
+ if (deviceTypes[i].type == type) {
+ return deviceTypes[i].thumb;
+ }
+ }
+ return type;
+ }
+
$('#device-grid').datatables_extended ({
serverSide: true,
processing: false,
@@ -233,7 +243,7 @@ function loadDevices(searchType, searchParam){
},
columnDefs: [
{ targets: 0, data: 'name', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
- return '';
+ return '';
}},
{ targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
@@ -582,21 +592,19 @@ function attachDeviceEvents() {
$("a.remove-device-link").click(function () {
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
- var removeDeviceAPI = "/devicemgt/api/devices/" + deviceType + "/" + deviceId + "/remove";
+ var serviceURL = "/devicemgt_admin/devices/type/" + deviceType + "/id/" + deviceId;
$(modalPopupContent).html($('#remove-device-modal-content').html());
showPopup();
$("a#remove-device-yes-link").click(function () {
- var postOperationRequest = $.ajax({
- url: removeDeviceAPI,
- method: "post"
- });
- postOperationRequest.done(function (data) {
+ invokerUtil.delete(serviceURL, function (message) {
$(modalPopupContent).html($('#remove-device-200-content').html());
- window.location.reload(false);
- });
- postOperationRequest.fail(function (jqXHR, textStatus) {
+ setTimeout(function () {
+ hidePopup();
+ location.reload(false);
+ }, 2000);
+ }, function (message) {
displayDeviceErrors(jqXHR);
});
});
@@ -604,7 +612,6 @@ function attachDeviceEvents() {
$("a#remove-device-cancel-link").click(function () {
hidePopup();
});
-
});
/**
@@ -616,7 +623,7 @@ function attachDeviceEvents() {
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
var deviceName = $(this).data("devicename");
- var editDeviceAPI = "/devicemgt/api/devices/" + deviceType + "/" + deviceId + "/update?name=";
+ var serviceURL = "/devicemgt_admin/devices/type/" + deviceType + "/id/" + deviceId;
$(modalPopupContent).html($('#edit-device-modal-content').html());
$('#edit-device-name').val(deviceName);
@@ -624,18 +631,13 @@ function attachDeviceEvents() {
$("a#edit-device-yes-link").click(function () {
var newDeviceName = $('#edit-device-name').val();
- var postOperationRequest = $.ajax({
- url: editDeviceAPI + newDeviceName,
- method: "post"
- });
- postOperationRequest.done(function (data) {
+ invokerUtil.put(serviceURL, {"name": newDeviceName}, function (message) {
$(modalPopupContent).html($('#edit-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
- });
- postOperationRequest.fail(function (jqXHR, textStatus) {
+ }, function (message) {
displayDeviceErrors(jqXHR);
});
});
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.create.wizard/wizard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.create.wizard/wizard.js
index a95b0994d3..47c96c9792 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.create.wizard/wizard.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.create.wizard/wizard.js
@@ -16,11 +16,13 @@
* under the License.
*/
-function onRequest(context){
+function onRequest(context) {
+ var utility = require("/app/modules/utility.js").utility;
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
- if (arguments.length < 3)
+ if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
- if( lvalue!=rvalue ) {
+ }
+ if (lvalue != rvalue) {
return options.inverse(this);
} else {
return options.fn(this);
@@ -28,5 +30,5 @@ function onRequest(context){
});
var deviceType = context.uriParams.deviceType;
- return {"policyWizardUnitName" : "cdmf.unit.device.type." + deviceType + ".policy-wizard"};
-}
\ No newline at end of file
+ return {"policyWizardUnitName": utility.getTenantedDeviceUnitName(deviceType, "policy-wizard")};
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.edit/edit.js
index f9a7822ece..e39d8b9316 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.edit/edit.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.edit/edit.js
@@ -17,6 +17,7 @@
*/
function onRequest(context) {
+ var utility = require("/app/modules/utility.js").utility;
var deviceType = request.getParameter("type");
- return {"deviceTypePolicyEdit" : "cdmf.unit.device.type." + deviceType + ".policy-edit"};
-}
\ No newline at end of file
+ return {"deviceTypePolicyEdit": utility.getTenantedDeviceUnitName(deviceType, "policy-edit")};
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js
index 1628ffabc2..58829242be 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js
@@ -17,6 +17,7 @@
*/
function onRequest(context) {
+ var utility = require("/app/modules/utility.js").utility;
var deviceType = request.getParameter("type");
- return {"deviceTypePolicyView" : "cdmf.unit.device.type." + deviceType + ".policy-view"};
-}
\ No newline at end of file
+ return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view")};
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs
index db43efbb36..af1ffee163 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs
@@ -43,8 +43,7 @@
our {{deviceTypeLabel}} device
-
+
{{/each}}
@@ -55,8 +54,6 @@
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/listing.js"}}
-{{/zone}}
\ No newline at end of file
+{{/zone}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
index 6ba12ac2bd..fecc522807 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
@@ -42,21 +42,23 @@ function onRequest(context) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
}
}
- if (deviceCategory == 'virtual'){
+ if (deviceCategory == 'virtual') {
virtualDeviceTypesList.push({
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceTypes[i].name,
"deviceCategory": deviceCategory,
- "deviceTypeId": deviceTypes[i].id
+ "deviceTypeId": deviceTypes[i].id,
+ "thumb": utility.getDeviceThumb(deviceTypes[i].name)
});
- }else{
+ } else {
deviceTypesList.push({
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceTypes[i].name,
"deviceCategory": deviceCategory,
- "deviceTypeId": deviceTypes[i].id
+ "deviceTypeId": deviceTypes[i].id,
+ "thumb": utility.getDeviceThumb(deviceTypes[i].name)
});
}
}
@@ -69,4 +71,4 @@ function onRequest(context) {
throw new Error("Unable to fetch device types!");
}
return viewModel;
-}
\ 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.device.types.listing/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js
index 94fe4baaa2..82f54ad056 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js
@@ -125,7 +125,6 @@ var deviceTypeCount, compiledDeviceTypesCount = 0;
function loadDevices(searchType, searchParam){
var deviceListing = $("#device-listing");
var deviceListingSrc = deviceListing.attr("src");
- var imageResource = deviceListing.data("image-resource");
var currentUser = deviceListing.data("currentUser");
$('#ast-container').html("");
@@ -133,7 +132,7 @@ function loadDevices(searchType, searchParam){
if(deviceTypesList.length > 0){
for (var i = 0; i < deviceTypesList.length; i++) {
var viewModel = {};
- viewModel.imageLocation = imageResource;
+ viewModel.thumb = deviceTypesList[i].thumb;
viewModel.appContext = clientJsAppContext;
viewModel.deviceTypeName = deviceTypesList[i].deviceTypeName;
viewModel.deviceTypeId = deviceTypesList[i].deviceTypeId;
@@ -240,4 +239,4 @@ $(document).ready(function () {
window.document.location = $(this).data('href');
})
-});
\ 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.device.types.listing/public/templates/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs
index ed26908293..3d17d9a10f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs
@@ -3,7 +3,7 @@
-
+
|
@@ -18,4 +18,4 @@
Select
|
-
\ 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.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
index c4f6b2ba42..3e09ae185d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
@@ -17,19 +17,12 @@
*/
function onRequest(context) {
- var log = new Log("create.js");
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
var utility = require("/app/modules/utility.js").utility;
var userModule = require("/app/modules/user.js")["userModule"];
- var JFile = Packages.java.io.File;
- var sep = JFile.separator;
-
- var systemProcess = require('process');
- var parent = 'file:///' + (systemProcess.getProperty('jaggery.home') ||
- systemProcess.getProperty('carbon.home')).replace(/[\\]/g, '/').replace(/^[\/]/g, '');
var types = {};
types["types"] = [];
var typesListResponse = userModule.getPlatforms();
@@ -41,9 +34,7 @@ function onRequest(context) {
if (configs && configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
}
- var policyWizard = new File(parent + sep + "repository" + sep + "deployment" + sep + "server" + sep +
- "jaggeryapps" + sep + "devicemgt" + sep + "app" + sep + "units" + sep +
- "cdmf.unit.device.type." + deviceType + ".policy-wizard");
+ var policyWizard = new File("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard"));
if(policyWizard.isExists()){
typesListResponse["content"][type]["icon"] = utility.getDeviceThumb(deviceType);
typesListResponse["content"][type]["label"] = deviceTypeLabel;
@@ -52,4 +43,4 @@ function onRequest(context) {
}
}
return types;
-}
\ 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.ui.navbar.nav-menu/nav-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs
index b40e3564d7..2f9ca7e054 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs
@@ -8,7 +8,7 @@
Admin Dashboard
{{/if}}
- {{#if permissions.LIST_DEVICES}}
+ {{#if permissions.LIST_OWN_DEVICES}}
Device Management
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs
index ae363ac1a6..9ed2c501fd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs
@@ -91,7 +91,7 @@
+ src="{{thumb}}"/>
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js
index 2b2622a440..a4f690df46 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js
@@ -41,9 +41,8 @@ function onRequest(context) {
if (response["status"] == "success") {
userRoles = response["content"];
}
-
var deviceModule = require("/app/modules/device.js").deviceModule;
- devices = deviceModule.listDevicesForUser(userName);
+ devices = deviceModule.getDevices(userName);
}
return {"user": user, "userRoles": userRoles, "devices": devices};
-}
\ No newline at end of file
+}
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java
index b8c72b619a..13711f43b0 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java
@@ -87,10 +87,8 @@ public class PolicyManagementServiceComponent {
componentContext.getBundleContext().registerService(
PolicyManagerService.class.getName(), new PolicyManagerServiceImpl(), null);
-
-
- PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
- getDeviceManagementConfigRepository().getPolicyConfiguration();
+ PolicyConfiguration policyConfiguration =
+ DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
if(policyConfiguration.getMonitoringEnable()) {
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFequency());
@@ -104,8 +102,8 @@ public class PolicyManagementServiceComponent {
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
try {
- PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
- getDeviceManagementConfigRepository().getPolicyConfiguration();
+ PolicyConfiguration policyConfiguration =
+ DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
if (policyConfiguration.getMonitoringEnable()) {
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
taskScheduleService.stopTask();
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
index fa5e8ae7f3..9f6df4969c 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
@@ -72,9 +72,8 @@ public class MonitoringManagerImpl implements MonitoringManager {
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.monitoringDAO = PolicyManagementDAOFactory.getMonitoringDAO();
this.complianceDecisionPoint = new ComplianceDecisionPointImpl();
- this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
- getDeviceManagementConfigRepository().getPolicyConfiguration();
-
+ this.policyConfiguration =
+ DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
}
@Override
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java
index 04fac4505c..75a58da1e8 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java
@@ -43,8 +43,8 @@ public class TaskScheduleServiceImpl implements TaskScheduleService {
public TaskScheduleServiceImpl() {
- this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
- getDeviceManagementConfigRepository().getPolicyConfiguration();
+ this.policyConfiguration =
+ DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
}
@Override
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java
index 26fd3db790..56b52a3290 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java
@@ -218,7 +218,7 @@ public class PolicyManagerUtil {
if (monitoringFrequency == 0) {
PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().
- getDeviceManagementConfig().getDeviceManagementConfigRepository().getPolicyConfiguration();
+ getDeviceManagementConfig().getPolicyConfiguration();
monitoringFrequency = policyConfiguration.getMonitoringFrequency();
}