diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 64815672f2f..ab50ccc8abf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -457,7 +457,7 @@ public interface DeviceManagementService { String ifModifiedSince); @PUT - @Path("/{type}/{id}/status") + @Path("/{type}/{id}") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/DeviceApplicationMapping.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/DeviceApplicationMapping.java deleted file mode 100644 index 26f65398d01..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/DeviceApplicationMapping.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.device.mgt.common.app.mgt; - -public class DeviceApplicationMapping { - - private String deviceIdentifier; - - private String applicationUUID; - - private String versionName; - - private boolean installed; - - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } - - public String getApplicationUUID() { - return applicationUUID; - } - - public void setApplicationUUID(String applicationUUID) { - this.applicationUUID = applicationUUID; - } - - public String getVersionName() { - return versionName; - } - - public void setVersionName(String versionName) { - this.versionName = versionName; - } - - public boolean isInstalled() { - return installed; - } - - public void setInstalled(boolean installed) { - this.installed = installed; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index e7acf3ff33d..53f7da75af1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.app.mgt; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; @@ -28,10 +29,10 @@ import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.DeviceApplicationMapping; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO; import org.wso2.carbon.device.mgt.core.dao.ApplicationMappingDAO; @@ -76,13 +77,13 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem @Override public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, - String status) throws ApplicationManagementException { + String status) throws ApplicationManagementException { } @Override public String getApplicationStatus(DeviceIdentifier deviceId, - Application application) throws ApplicationManagementException { + Application application) throws ApplicationManagementException { return null; } @@ -193,96 +194,21 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem } } - private boolean contains(DeviceApplicationMapping deviceApp, List installedApps) { - boolean installed = false; - for (Application app : installedApps) { - if (app.getApplicationIdentifier().equals(deviceApp.getApplicationUUID()) && app.getVersion().equals(deviceApp.getVersionName())) { - installed = true; - break; - } - } - return installed; - } - @Override public void updateApplicationListInstalledInDevice( DeviceIdentifier deviceIdentifier, List applications) throws ApplicationManagementException { - - try { - DeviceManagementDAOFactory.beginTransaction(); - List installedDeviceApps = new ArrayList<>(); - List uninstalledDeviceApps = new ArrayList<>(); - List deviceApps = applicationMappingDAO.getApplicationsOfDevice(deviceIdentifier.getId(), false); - for (DeviceApplicationMapping deviceApp : deviceApps) { - if (contains(deviceApp, applications)) { - if (!deviceApp.isInstalled()) { - // device app mapping is recorded as not installed (i.e. install app operation has been sent to device) - // as the app list sent from the device contains this, app is now installed in the device - // so we can mark the device app mapping entry as installed. - deviceApp.setInstalled(true); - applicationMappingDAO.updateDeviceApplicationMapping(deviceApp); - } - } else { - if (deviceApp.isInstalled()) { - // we have a device-app mapping in the installed state in the db. but app is not installed in the device. - // which implies that a previously installed app has been uninstalled from the device. so we have to remove the device app mapping - applicationMappingDAO.removeApplicationMapping(deviceApp); - } - } - } - DeviceManagementDAOFactory.commitTransaction(); - - } catch (DeviceManagementDAOException | TransactionManagementException e) { - String msg = "Failed to update application list of the device " + deviceIdentifier; - throw new ApplicationManagementException(msg, e); - + if (log.isDebugEnabled()) { + log.debug("Updating application list for device: " + deviceIdentifier.toString()); } - } - - public void updateApplicationListInstalledInDeviceDep( - DeviceIdentifier deviceIdentifier, - List applications) throws ApplicationManagementException { - - try { - DeviceManagementDAOFactory.beginTransaction(); - List installedDeviceApps = new ArrayList<>(); - List uninstalledDeviceApps = new ArrayList<>(); - List deviceApps = applicationMappingDAO.getApplicationsOfDevice(deviceIdentifier.getId(), false); - for (DeviceApplicationMapping deviceApp : deviceApps) { - if (contains(deviceApp, applications)) { - // if device app is pending mark device app as installed - if (!deviceApp.isInstalled()) { - deviceApp.setInstalled(true); - applicationMappingDAO.updateDeviceApplicationMapping(deviceApp); - } - } else { - if (deviceApp.isInstalled()) { - // this means we have a device-app mapping in the installed state in the db. but app is not installed in the device. - // which implies that a previously installed app has been uninstalled from the device. so we have to remove the device app mapping - applicationMappingDAO.removeApplicationMapping(deviceApp); - } - } - } - DeviceManagementDAOFactory.commitTransaction(); - - } catch (DeviceManagementDAOException | TransactionManagementException e) { - String msg = "Failed to update application list of the device " + deviceIdentifier; - throw new ApplicationManagementException(msg, e); - - } - List installedAppList = getApplicationListForDevice(deviceIdentifier); try { Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier, false); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - if (log.isDebugEnabled()) { - log.debug("Device:" + device.getId() + ":identifier:" + deviceIdentifier.getId()); - } if (log.isDebugEnabled()) { - log.debug("num of apps installed:" + installedAppList.size()); + log.debug("Number of apps installed:" + installedAppList.size()); } List appsToAdd = new ArrayList<>(); List appIdsToRemove = new ArrayList<>(installedAppList.size()); @@ -303,6 +229,15 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem List applicationsToMap = new ArrayList<>(); for (Application application : applications) { + // Adding N/A if application doesn't have a version. Also truncating the application version, + // if length of the version is greater than maximum allowed length. + if (application.getVersion() == null) { + application.setVersion("N/A"); + } else if (application.getVersion().length() > + DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) { + application.setVersion(StringUtils.abbreviate(application.getVersion(), + DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH)); + } if (!installedAppList.contains(application)) { installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), application.getVersion(), tenantId); @@ -335,24 +270,34 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem if (log.isDebugEnabled()) { log.debug("num of remove app Ids:" + appIdsToRemove.size()); } - DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new ApplicationManagementException("Error occurred saving application list to the device", e); + String msg = "Error occurred saving application list of the device " + deviceIdentifier.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } catch (TransactionManagementException e) { - throw new ApplicationManagementException("Error occurred while initializing transaction", e); + String msg = "Error occurred while initializing transaction for saving application list to the device " + + deviceIdentifier.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } catch (DeviceManagementException e) { - throw new ApplicationManagementException("Error occurred obtaining the device object.", e); + String msg = "Error occurred obtaining the device object for device " + deviceIdentifier.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (Exception e) { + String msg = "Exception occurred saving application list of the device " + deviceIdentifier.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } } @Override - public List getApplicationListForDevice( - DeviceIdentifier deviceId) throws ApplicationManagementException { - Device device = null; + public List getApplicationListForDevice(DeviceIdentifier deviceId) + throws ApplicationManagementException { + Device device; try { device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false); @@ -363,19 +308,27 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem if (device == null) { if (log.isDebugEnabled()) { log.debug("No device is found upon the device identifier '" + deviceId.getId() + - "' and type '" + deviceId.getType() + "'. Therefore returning null"); + "' and type '" + deviceId.getType() + "'. Therefore returning empty app list"); } - return null; + return new ArrayList<>(); } try { DeviceManagementDAOFactory.openConnection(); return applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId()); } catch (DeviceManagementDAOException e) { - throw new ApplicationManagementException("Error occurred while fetching the Application List of '" + - deviceId.getType() + "' device carrying the identifier'" + deviceId.getId(), e); + String msg = "Error occurred while fetching the Application List of device " + deviceId.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } catch (SQLException e) { - throw new ApplicationManagementException("Error occurred while opening a connection to the data source", e); - } finally { + String msg = "Error occurred while opening a connection to the data source to get application " + + "list of the device " + deviceId.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (Exception e) { + String msg = "Exception occurred getting application list of the device " + deviceId.toString(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { DeviceManagementDAOFactory.closeConnection(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java index 15fa42c31d9..eb96a6185a3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java @@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.core.dao; import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.DeviceApplicationMapping; import java.util.List; @@ -35,12 +34,4 @@ public interface ApplicationMappingDAO { void removeApplicationMapping(int deviceId, int enrolmentId, List appIdList, int tenantId) throws DeviceManagementDAOException; - - int addDeviceApplicationMapping(DeviceApplicationMapping deviceApp) throws DeviceManagementDAOException; - - void updateDeviceApplicationMapping(DeviceApplicationMapping deviceApp) throws DeviceManagementDAOException; - - List getApplicationsOfDevice(String deviceIdentifier, boolean installed) throws DeviceManagementDAOException; - - void removeApplicationMapping(DeviceApplicationMapping deviceApp) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java index cd4d248ad17..8642620ccbb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java @@ -21,23 +21,18 @@ package org.wso2.carbon.device.mgt.core.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.DeviceApplicationMapping; import org.wso2.carbon.device.mgt.core.dao.ApplicationMappingDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.dto.operation.mgt.ProfileOperation; import java.io.*; import java.sql.*; -import java.util.ArrayList; import java.util.List; -import java.util.Properties; public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { - private static Log log = LogFactory.getLog(ApplicationMappingDAOImpl.class); + private static final Log log = LogFactory.getLog(ApplicationMappingDAOImpl.class); @Override public int addApplicationMapping(int deviceId, int applicationId, @@ -181,128 +176,6 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { } } - @Override - public int addDeviceApplicationMapping(DeviceApplicationMapping deviceApp) throws - DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int mappingId = -1; - try { - conn = getConnection(); - String sql = "SELECT ID FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_IDENTIFIER = ? AND " + - "APPLICATION_UUID = ? AND VERSION_NAME = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceApp.getDeviceIdentifier()); - stmt.setString(2, deviceApp.getApplicationUUID()); - stmt.setString(3, deviceApp.getVersionName()); - rs = stmt.executeQuery(); - - if (!rs.next()) { - sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_IDENTIFIER, APPLICATION_UUID, VERSION_NAME," + - "INSTALLED) VALUES (?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[]{"id"}); - stmt.setString(1, deviceApp.getDeviceIdentifier()); - stmt.setString(2, deviceApp.getApplicationUUID()); - stmt.setString(3, deviceApp.getVersionName()); - stmt.setBoolean(4, deviceApp.isInstalled()); - stmt.executeUpdate(); - - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - mappingId = rs.getInt(1); - } - return mappingId; - } else { - log.warn("Device[" + deviceApp.getDeviceIdentifier() + "] application[" + deviceApp.getApplicationUUID() + "] mapping already " + - "exists in the DB"); - return -1; - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while adding device application mapping to DB", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public void updateDeviceApplicationMapping(DeviceApplicationMapping deviceApp) throws - DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = getConnection(); - String sql = "UPDATE DM_DEVICE_APPLICATION_MAPPING " + - "SET INSTALLED = ? " + - "WHERE DEVICE_IDENTIFIER = ? AND APPLICATION_UUID = ? AND VERSION_NAME = ?"; - stmt = conn.prepareStatement(sql); - stmt.setBoolean(1, deviceApp.isInstalled()); - stmt.setString(2, deviceApp.getDeviceIdentifier()); - stmt.setString(3, deviceApp.getApplicationUUID()); - stmt.setString(3, deviceApp.getVersionName()); - stmt.executeUpdate(); - - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while adding device application mapping to DB", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public List getApplicationsOfDevice(String deviceIdentifier, boolean installed) throws - DeviceManagementDAOException { - List applications = new ArrayList<>(); - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int mappingId = -1; - try { - conn = getConnection(); - String sql = "SELECT APPLICATION_UUID, VERSION_NAME FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_IDENTIFIER = ? AND INSTALLED = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceIdentifier); - stmt.setBoolean(2, installed); - rs = stmt.executeQuery(); - - while (rs.next()) { - DeviceApplicationMapping deviceApp = new DeviceApplicationMapping(); - deviceApp.setDeviceIdentifier(deviceIdentifier); - deviceApp.setApplicationUUID(rs.getString(1)); - deviceApp.setVersionName(rs.getString(2)); - deviceApp.setInstalled(true); - applications.add(deviceApp); - } - return applications; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while adding device application mapping to DB", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public void removeApplicationMapping(DeviceApplicationMapping deviceApp) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - try { - String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_IDENTIFIER = ? AND " + - "APPLICATION_UUID = ? AND VERSION_NAME = ?"; - - conn = this.getConnection(); - stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceApp.getDeviceIdentifier()); - stmt.setString(2, deviceApp.getApplicationUUID()); - stmt.setString(3, deviceApp.getVersionName()); - stmt.executeUpdate(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while removing device application mapping", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - } - private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } 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 fccdc8a86c3..65decec77f1 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 @@ -149,9 +149,6 @@ public class DeviceManagementServiceComponent { @SuppressWarnings("unused") protected void activate(ComponentContext componentContext) { - - log.info("CALLING Crazy ............."); - try { if (log.isDebugEnabled()) { log.debug("Initializing device management core bundle"); 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 1dfed191183..ecb7463be27 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 @@ -37,11 +37,6 @@ 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.DeviceNotFoundException; -import org.wso2.carbon.device.mgt.common.app.mgt.DeviceApplicationMapping; -import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; -import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber; -import org.wso2.carbon.device.mgt.core.dao.ApplicationMappingDAO; -import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceNotification; import org.wso2.carbon.device.mgt.common.DevicePropertyNotification; import org.wso2.carbon.device.mgt.common.DeviceTypeNotFoundException; @@ -74,6 +69,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; +import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; +import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; @@ -92,6 +89,7 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException; import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.core.geo.GeoCluster; import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; @@ -134,7 +132,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private DeviceTypeDAO deviceTypeDAO; private EnrollmentDAO enrollmentDAO; private ApplicationDAO applicationDAO; - private ApplicationMappingDAO applicationMappingDAO; private DeviceManagementPluginRepository pluginRepository; public DeviceManagementProviderServiceImpl() { @@ -151,7 +148,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); this.enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO(); - this.applicationMappingDAO = DeviceManagementDAOFactory.getApplicationMappingDAO(); } @Override @@ -2582,20 +2578,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv pullNotificationSubscriber.execute(deviceIdentifier, operation); } - public void addDeviceApplicationMapping(DeviceApplicationMapping deviceApp) throws DeviceManagementException { - try { - DeviceManagementDAOFactory.openConnection(); - applicationMappingDAO.addDeviceApplicationMapping(deviceApp); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while adding device application mapping for device " - + deviceApp.getDeviceIdentifier() + " and application " + deviceApp.getApplicationUUID(), e); - } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); - } finally { - DeviceManagementDAOFactory.closeConnection(); - } - } - /** * Returns all the device-info including location of the given device. */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Exit_alert.siddhiql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Exit_alert.siddhiql index ac9a9aa2d5d..1e72dd1d4b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Exit_alert.siddhiql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Exit_alert.siddhiql @@ -24,10 +24,6 @@ from withinStream[isWithin == false] select id, owner, latitude, longitude,timeStamp, type, speed, heading, "ALERTED" as state, str:concat("The ", type, " device `", id, "` of $owner is outside $areaName area!") as information, true as notify insert into dataOut; -from dataIn[id != "$deviceId"] -select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information -insert into dataOut; - from withinStream[isWithin == true] select id, owner, latitude, longitude,timeStamp, type, speed, heading, "NORMAL" as state, "" as information, false as notify insert into dataOut; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql index 9f45f287919..2309f64df30 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/resources/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql @@ -19,10 +19,6 @@ from dataIn[speed >= $speedAlertValue and id == "$deviceId" and owner == "$owner select id, owner, latitude, longitude, timeStamp, type, speed, heading, "ALERTED" as state, str:concat("The ", type, " device `", id, "` of $owner is traveling at ", math:round(speed), "km/h and is exceeding the $speedAlertValuekm/h speed limit") as information, true as notify insert into dataOut; -from dataIn[id != "$deviceId"] -select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information -insert into dataOut; - from dataIn[speed < $speedAlertValue and id == "$deviceId" and owner == "$owner"] select id, owner, latitude, longitude, timeStamp, type, speed, heading, "NORMAL" as state, str:concat("The ", type, " device `", id, "` of $owner is travailing at normal speed.") as information, false as notify insert into dataOut; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml index e64d03c7c38..f24ee57be23 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml @@ -468,7 +468,7 @@ --> 100 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options index 80e56b83f2f..ba8e3c6c20f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options @@ -62,7 +62,7 @@ org.eclipse.osgi/defaultprofile/logfilename = # requested. org.eclipse.osgi/defaultprofile/logsynchronously = false -# Specify the length of the default profile implementation log buffer. +# Specify the size of the default profile implementation log buffer. org.eclipse.osgi/defaultprofile/buffersize = 256 #### Monitoring settings diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml index 48a58944bfe..765865b4759 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml @@ -47,7 +47,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag index fd09d4f4ac7..a214f536e9d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag @@ -45,18 +45,12 @@ if (!user) { } else { queryString = "?" + queryString; } -<<<<<<< Updated upstream var deviceType = request.getParameter("deviceType"); // need a better solution here deviceTypeConfig = utility.getDeviceTypeConfig(deviceType); if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) { -======= - var type = request.getParameter("type"); // need a better solution here - deviceTypeConfig = utility.getDeviceTypeConfig(type); - if (deviceTypeConfig && deviceTypeConfig.type.downloadAgentUri) { ->>>>>>> Stashed changes hearders = [{"name": constants["ACCEPT_IDENTIFIER"], "value": constants["APPLICATION_ZIP"]}]; - sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceTypeConfig.type.downloadAgentUri; + sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceTypeConfig.deviceType.downloadAgentUri; serviceInvokers.HttpClient.get(sketchDownloadEndPoint + queryString, function (responsePayload, responseHeaders) { if (responseHeaders) { for (var i = 0; i < responseHeaders.length; i++) { @@ -115,18 +109,18 @@ if (!user) { } else if (uriMatcher.match("/{context}/api/devices/types")) { result = deviceModule.listDeviceTypes(); - } else if (uriMatcher.match("/{context}/api/devices/{type}/{deviceId}/remove")) { + } else if (uriMatcher.match("/{context}/api/devices/{deviceType}/{deviceId}/remove")) { var elements = uriMatcher.elements(); var deviceId = elements.deviceId; - var type = elements.type; - result = deviceModule.removeDevice(type, deviceId); + var deviceType = elements.deviceType; + result = deviceModule.removeDevice(deviceType, deviceId); - } else if (uriMatcher.match("/{context}/api/devices/{type}/{deviceId}/update")) { + } else if (uriMatcher.match("/{context}/api/devices/{deviceType}/{deviceId}/update")) { var elements = uriMatcher.elements(); var deviceId = elements.deviceId; - var type = elements.type; + var deviceType = elements.deviceType; var deviceName = request.getParameter("name"); - result = deviceModule.updateDevice(type, deviceId, deviceName); + result = deviceModule.updateDevice(deviceType, deviceId, deviceName); } else if (uriMatcher.match("/{context}/api/devices")) { var url = request.getParameter("url"); var draw = request.getParameter("draw"); 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 index 60d7bd0158c..c581aad791c 100644 --- 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 @@ -26,7 +26,7 @@ var serviceInvokers = require("/app/modules/oauth/token-protected-service-invoke var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; if (uriMatcher.match("/{context}/api/operation/paginate")) { - var type = request.getParameter("type"); + var deviceType = request.getParameter("deviceType"); var deviceId = request.getParameter("deviceId"); var owner = request.getParameter("owner"); var index = request.getParameter("start"); @@ -34,7 +34,7 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { var search = request.getParameter("search[value]"); var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + - "/devices/" + type + "/" + deviceId + "/operations?owner=" + owner + "&offset=" + index + "&limit=" + length; + "/devices/" + deviceType + "/" + deviceId + "/operations?owner=" + owner + "&offset=" + index + "&limit=" + length; serviceInvokers.XMLHttp.get( restAPIEndpoint, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/stats-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/stats-api.jag index a217947ce7d..6919a492a3c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/stats-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/stats-api.jag @@ -26,7 +26,7 @@ var serviceInvokers = require("/app/modules/oauth/token-protected-service-invoke var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; if (uriMatcher.match("/{context}/api/stats/paginate")) { - var type = request.getParameter("type"); + var deviceType = request.getParameter("deviceType"); var deviceId = request.getParameter("deviceId"); var from = request.getParameter("from"); var to = request.getParameter("to"); @@ -35,7 +35,7 @@ if (uriMatcher.match("/{context}/api/stats/paginate")) { var keys = request.getParameter("attributes"); keys = JSON.parse(keys); var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/events/" - + type + "/" + deviceId + "?offset=" + index +"&limit=" + length + "&from="+ from + "&to=" + to; + + deviceType + "/" + deviceId + "?offset=" + index +"&limit=" + length + "&from="+ from + "&to=" + to; serviceInvokers.XMLHttp.get( restAPIEndpoint, function (restAPIResponse) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs index 5495c48000c..f2120857e07 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs @@ -37,7 +37,7 @@
  • - + {{deviceName}}
  • 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.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.hbs index b9d34a6219f..70c449653cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.type.view/view.hbs @@ -39,7 +39,7 @@
  • - + {{label}}
  • @@ -50,7 +50,7 @@
    - {{! dynamically resolves device type-view unit according to type URI param }} + {{! dynamically resolves device type-view unit according to deviceType URI param }} {{unit deviceTypeViewUnitName}}
    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 d2392ad0310..0ff41a245bc 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 @@ -399,7 +399,7 @@ {{/defineZone}} @@ -63,22 +63,22 @@
    -

    {{type.displayName}}

    +

    {{deviceType.displayName}}


    -

    {{#defineZone "deviceTypeHeading"}}Connect your {{type.displayName}} device +

    {{#defineZone "deviceTypeHeading"}}Connect your {{deviceType.displayName}} device to the WSO2 device cloud. {{/defineZone}}

    - +
    - {{#if type.prepareSteps}} + {{#if deviceType.prepareSteps}}

    Prepare


    Get your device ready


      - {{#itr type.prepareSteps}} + {{#itr deviceType.prepareSteps}}

      0{{key}} {{{value}}}

      {{/itr}}
    @@ -112,26 +112,26 @@
    {{/if}} - {{#if type.schematicDiagram}} + {{#if deviceType.schematicDiagram}}

    Schematic Diagram


    Click on the image to zoom

    - - + +

    {{/if}} - {{#if type.quickStartup}} + {{#if deviceType.quickStartup}}

    Connect (Quick Start)


    Internet of Things Foundation Quickstart connection


      - {{#itr type.quickStartup}} + {{#itr deviceType.quickStartup}}

      0{{key}} {{{value}}}

      {{/itr}}
    @@ -139,17 +139,17 @@
    {{/if}} - {{#if type.additionalHtml}} - {{{type.additionalHtml}}} + {{#if deviceType.additionalHtml}} + {{{deviceType.additionalHtml}}} {{/if}}
    -{{#if type.showQRCode}} +{{#if deviceType.showQRCode}} -