From 0cd90fc349b9161e5ef867814cce1431f6c47bf8 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 22 Dec 2014 16:47:32 +0530 Subject: [PATCH 1/9] Added device type to DB when registering the plugin --- .../mgt/core/DeviceManagementRepository.java | 13 +- .../device/mgt/core/DeviceManagerImpl.java | 247 +++++++++--------- .../carbon/device/mgt/core/dao/DeviceDAO.java | 2 - .../device/mgt/core/dao/DeviceTypeDAO.java | 2 + .../mgt/core/dao/impl/DeviceDAOImpl.java | 32 --- .../mgt/core/dao/impl/DeviceTypeDAOImpl.java | 150 +++++++---- .../mgt/core/util/DeviceManagerUtil.java | 21 ++ .../pom.xml | 17 ++ .../MobileDeviceConfigurationManager.java | 2 +- .../MobileDeviceManagementRepository.java | 2 +- .../datasource/JNDILookupDefinition.java | 2 +- .../datasource/MobileDataSourceConfig.java | 2 +- .../MobileDeviceManagementDAOException.java | 2 +- .../util/MobileDeviceManagementDAOUtil.java | 6 +- .../impl/ios/IOSDeviceManagerService.java | 2 +- .../mgt/mobile/util/DeviceManagementUtil.java | 45 ---- product/modules/agents/android/jax-rs/pom.xml | 2 +- .../src/main/java/cdm/api/android/Device.java | 34 +++ .../src/repository/dbscripts/cdm/h2.sql | 6 +- 19 files changed, 329 insertions(+), 260 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/DeviceManagementUtil.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java index 7be4549289..1b59cd4a9a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java @@ -15,13 +15,18 @@ */ package org.wso2.carbon.device.mgt.core; +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.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.util.HashMap; import java.util.Map; public class DeviceManagementRepository { + private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); private Map providers; public DeviceManagementRepository() { @@ -29,7 +34,13 @@ public class DeviceManagementRepository { } public void addDeviceManagementProvider(DeviceManagerService provider) { - providers.put(provider.getProviderType(), provider); + String deviceType = provider.getProviderType(); + try { + DeviceManagerUtil.registerDeviceType(deviceType); + } catch (DeviceManagementException e) { + log.error("Exception occured while registering the device type.",e); + } + providers.put(deviceType, provider); } public DeviceManagerService getDeviceManagementProvider(String type) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java index 19df597820..11abd2f702 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java @@ -29,126 +29,131 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.util.List; -public class DeviceManagerImpl implements DeviceManager{ - - private DeviceDAO deviceDAO; - private DeviceTypeDAO deviceTypeDAO; - private DeviceManagementConfig config; - private DeviceManagementRepository pluginRepository; - - public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) { - this.config = config; - this.pluginRepository = pluginRepository; - this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); - this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(device.getType()); - boolean status = dms.enrollDevice(device); - try { - this.getDeviceTypeDAO().getDeviceType(); - org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice( - device); - - Integer deviceTypeId = this.getDeviceDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); - deviceDto.setDeviceType(deviceTypeId); - this.getDeviceDAO().addDevice(deviceDto); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while enrolling the device '" + - device.getId() + "'", e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(device.getType()); - boolean status = dms.modifyEnrollment(device); - try { - this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device)); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while modifying the device '" + - device.getId() + "'", e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.disenrollDevice(deviceId); - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.isEnrolled(deviceId); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.isActive(deviceId); - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.setActive(deviceId, status); - } - - @Override - public List getAllDevices(String type) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(type); - return dms.getAllDevices(); - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.getDevice(deviceId); - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device); - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.setOwnership(deviceId, ownershipType); - } - - public OperationManager getOperationManager(String type) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(type); - return dms.getOperationManager(); - } - - public DeviceDAO getDeviceDAO() { - return deviceDAO; - } - - public DeviceTypeDAO getDeviceTypeDAO() { - return deviceTypeDAO; - } - - public DeviceManagementRepository getPluginRepository() { - return pluginRepository; - } +public class DeviceManagerImpl implements DeviceManager { + + private DeviceDAO deviceDAO; + private DeviceTypeDAO deviceTypeDAO; + private DeviceManagementConfig config; + private DeviceManagementRepository pluginRepository; + + public DeviceManagerImpl(DeviceManagementConfig config, + DeviceManagementRepository pluginRepository) { + this.config = config; + this.pluginRepository = pluginRepository; + this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); + this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); + } + + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(device.getType()); + boolean status = dms.enrollDevice(device); + try { + this.getDeviceTypeDAO().getDeviceType(); + org.wso2.carbon.device.mgt.core.dto.Device deviceDto = + DeviceManagementDAOUtil.convertDevice( + device); + + Integer deviceTypeId = + this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); + deviceDto.setDeviceType(deviceTypeId); + this.getDeviceDAO().addDevice(deviceDto); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while enrolling the device '" + + device.getId() + "'", e); + } + return status; + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(device.getType()); + boolean status = dms.modifyEnrollment(device); + try { + this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device)); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while modifying the device '" + + device.getId() + "'", e); + } + return status; + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.disenrollDevice(deviceId); + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.isEnrolled(deviceId); + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.isActive(deviceId); + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) + throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.setActive(deviceId, status); + } + + @Override + public List getAllDevices(String type) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(type); + return dms.getAllDevices(); + } + + @Override + public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.getDevice(deviceId); + } + + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(device.getType()); + return dms.updateDeviceInfo(device); + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) + throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); + return dms.setOwnership(deviceId, ownershipType); + } + + public OperationManager getOperationManager(String type) throws DeviceManagementException { + DeviceManagerService dms = + this.getPluginRepository().getDeviceManagementProvider(type); + return dms.getOperationManager(); + } + + public DeviceDAO getDeviceDAO() { + return deviceDAO; + } + + public DeviceTypeDAO getDeviceTypeDAO() { + return deviceTypeDAO; + } + + public DeviceManagementRepository getPluginRepository() { + return pluginRepository; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index ea9c148c81..9a51679ca3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -36,6 +36,4 @@ public interface DeviceDAO { Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException; List getDevices() throws DeviceManagementDAOException; - - Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java index 1947922f56..f421a58bd6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java @@ -36,4 +36,6 @@ public interface DeviceTypeDAO { DeviceIdentifier getDeviceType() throws DeviceManagementDAOException; + Integer getDeviceTypeIdByDeviceTypeName(String type) 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/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index dd85092825..5961165d0b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -102,38 +102,6 @@ public class DeviceDAOImpl implements DeviceDAO { return null; } - @Override - public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException { - - Connection conn = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - Integer deviceTypeId = null; - - try { - conn = this.getConnection(); - String createDBQuery = - "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, type); - resultSet = stmt.executeQuery(); - - while(resultSet.next()){ - deviceTypeId = resultSet.getInt(1); - } - - } catch (SQLException e) { - String msg = "Error occurred while fetch device type id for device type '" + type + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - - return deviceTypeId; - } - private Connection getConnection() throws DeviceManagementDAOException { try { return dataSource.getConnection(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java index aa1386c86b..ebcaeb1984 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java @@ -15,6 +15,8 @@ */ 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.DeviceIdentifier; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; @@ -24,55 +26,113 @@ import org.wso2.carbon.device.mgt.core.dto.DeviceType; import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; public class DeviceTypeDAOImpl implements DeviceTypeDAO { - private DataSource dataSource; - - public DeviceTypeDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - try { - stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)"); - stmt.setString(1, deviceType.getName()); - stmt.execute(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while registering the device type '" + - deviceType.getName() + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - } - - @Override - public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - - } - - @Override - public List getDeviceTypes() throws DeviceManagementDAOException { - return null; - } - - @Override - public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException { - return new DeviceIdentifier(); - } - - private Connection getConnection() throws DeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " + - "management metadata repository datasource", e); - } - } + private DataSource dataSource; + private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class); + public DeviceTypeDAOImpl(DataSource dataSource) { + this.dataSource = dataSource; + } + + @Override + public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)"); + stmt.setString(1, deviceType.getName()); + stmt.execute(); + } catch (SQLException e) { + String msg = "Error occurred while registering the device type '" + + deviceType.getName() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + } + + @Override + public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { + + } + + @Override + public List getDeviceTypes() throws DeviceManagementDAOException { + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + List deviceTypes = new ArrayList(); + try { + stmt = conn.prepareStatement( + "SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE"); + ResultSet results = stmt.executeQuery(); + while (results.next()) { + DeviceType deviceType = new DeviceType(); + deviceType.setId(results.getLong("DEVICE_TYPE_ID")); + deviceType.setName(results.getString("DEVICE_TYPE")); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching the registered device types"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return deviceTypes; + } + + @Override + public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException { + return null; + } + + @Override + public Integer getDeviceTypeIdByDeviceTypeName(String type) + throws DeviceManagementDAOException { + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet resultSet = null; + Integer deviceTypeId = null; + + try { + conn = this.getConnection(); + String createDBQuery = + "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?"; + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, type); + resultSet = stmt.executeQuery(); + + while (resultSet.next()) { + deviceTypeId = resultSet.getInt(1); + } + + } catch (SQLException e) { + String msg = "Error occurred while fetch device type id for device type '" + type + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + + return deviceTypeId; + } + + private Connection getConnection() throws DeviceManagementDAOException { + try { + return dataSource.getConnection(); + } catch (SQLException e) { + String msg = "Error occurred while obtaining a connection from the device " + + "management metadata repository datasource"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index f008423a4e..94da96c419 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -21,7 +21,11 @@ import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; +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.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import javax.sql.DataSource; import javax.xml.parsers.DocumentBuilder; @@ -80,4 +84,21 @@ public final class DeviceManagerUtil { return dataSource; } + public static boolean registerDeviceType(String deviceTypeName) throws DeviceManagementException{ + boolean status = false; + try { + DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); + Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceTypeName); + if(deviceTypeId == null){ + DeviceType deviceType = new DeviceType(); + deviceType.setName(deviceTypeName); + deviceTypeDAO.addDeviceType(deviceType); + } + status = true; + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred while registering the device type " + deviceTypeName; + throw new DeviceManagementException(msg, e); + } + return status; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index ed184b1943..aabc554c47 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java index 604b3278be..551aa1ddad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java @@ -27,7 +27,7 @@ import javax.xml.bind.Unmarshaller; import java.io.File; /** - * Class responsible for the mobile device manager configuration initialization + * Class responsible for the mobile device manager configuration initialization. */ public class MobileDeviceConfigurationManager { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java index ee16af2179..5a595be13c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java @@ -21,7 +21,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** - * Class for holding management repository data + * Class for holding management repository data. */ @XmlRootElement(name = "ManagementRepository") public class MobileDeviceManagementRepository { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java index 40f88a4202..f868b914ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java @@ -20,7 +20,7 @@ import javax.xml.bind.annotation.*; import java.util.List; /** - * Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB + * Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB. */ @XmlRootElement(name = "JndiLookupDefinition") public class JNDILookupDefinition { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java index 98e06c1507..2b9c570c9f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java @@ -20,7 +20,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** - * Class for holding data source configuration in mobile-config.xml at parsing with JAXB + * Class for holding data source configuration in mobile-config.xml at parsing with JAXB. */ @XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java index 2bf9b21cf8..22f02a9498 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java @@ -49,7 +49,7 @@ public class MobileDeviceManagementDAOException extends Exception { } /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message + * Constructs a new MobileDeviceManagementDAOException with the specified detail message. * * @param message the detail message. */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java index 600fcf52f9..e8ab4660d2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java @@ -40,7 +40,7 @@ public class MobileDeviceManagementDAOUtil { private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); /** - * Resolve data source from the data source definition + * Resolve data source from the data source definition. * * @param config Mobile data source configuration * @return data source resolved from the data source definition @@ -128,7 +128,7 @@ public class MobileDeviceManagementDAOUtil { } /** - * Initializes the creation of mobile device management schema if -Dsetup has provided + * Initializes the creation of mobile device management schema if -Dsetup has provided. * * @param dataSource Mobile data source */ @@ -151,7 +151,7 @@ public class MobileDeviceManagementDAOUtil { } /** - * Creates the mobile device management schema + * Creates the mobile device management schema. * * @param dataSource Mobile data source */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java index 798c922cc7..ebb6038b9d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java @@ -22,7 +22,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; import java.util.List; /** - * This represents the iOS implementation of DeviceManagerService. * + * This represents the iOS implementation of DeviceManagerService. */ public class IOSDeviceManagerService implements DeviceManagerService { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/DeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/DeviceManagementUtil.java deleted file mode 100644 index 4c7bc8bb31..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/DeviceManagementUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.mobile.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; - -public class DeviceManagementUtil { - - private static final Log log = LogFactory.getLog(DeviceManagementUtil.class); - - public static Document convertToDocument(File file) throws DeviceManagementException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document : " + e.getMessage(), e); - } - } - -} diff --git a/product/modules/agents/android/jax-rs/pom.xml b/product/modules/agents/android/jax-rs/pom.xml index ff4e139e64..45fbb86f0c 100644 --- a/product/modules/agents/android/jax-rs/pom.xml +++ b/product/modules/agents/android/jax-rs/pom.xml @@ -1,5 +1,5 @@ + ~ 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. +--> 2.6.1 4.8.2 - diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index e1d3c7d200..f1cdfc64f4 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. + * 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 cdm.api.android; import cdm.api.android.common.AndroidAgentException; @@ -38,7 +39,7 @@ import java.util.List; @Consumes({ "application/json", "application/xml" }) public class Device { - private static Log log = LogFactory.getLog(Device.class); + private static Log LOG = LogFactory.getLog(Device.class); @GET public List getAllDevices() throws AndroidAgentException { @@ -52,28 +53,27 @@ public class Device { } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceMgtServiceEx); - throw new AndroidAgentException(); + LOG.error(errorMsg, deviceMgtServiceEx); + throw new AndroidAgentException(errorMsg, deviceMgtServiceEx); } try { - devices = dmService.getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); Response.status(HttpStatus.SC_OK); + return devices; } catch (DeviceManagementException e) { msg = "Error occurred while fetching the device list."; - log.error(msg, e); + LOG.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); - } - return devices; } @GET @Path("{id}") public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) throws AndroidAgentException { + String msg; DeviceManagementService dmService; org.wso2.carbon.device.mgt.common.Device device; @@ -83,21 +83,23 @@ public class Device { } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceMgtServiceEx); + LOG.error(errorMsg, deviceMgtServiceEx); throw new AndroidAgentException(errorMsg, deviceMgtServiceEx); } + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); try { device = dmService.getDevice(deviceIdentifier); if (device == null) { Response.status(HttpStatus.SC_NOT_FOUND); } + return device; + } catch (DeviceManagementException deviceMgtEx) { msg = "Error occurred while fetching the device information."; - log.error(msg, deviceMgtEx); + LOG.error(msg, deviceMgtEx); throw new AndroidAgentException(msg, deviceMgtEx); } - return device; } @PUT @@ -115,7 +117,7 @@ public class Device { } catch (DeviceManagementServiceException deviceManagementServiceException) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceManagementServiceException); + LOG.error(errorMsg, deviceManagementServiceException); } try { @@ -133,9 +135,16 @@ public class Device { } catch (DeviceManagementException deviceMgtEx) { String msg = "Error occurred while modifying the device information."; - log.error(msg, deviceMgtEx); + LOG.error(msg, deviceMgtEx); throw new AndroidAgentException(msg, deviceMgtEx); } + } + @POST + @Path("/device/license") + @Produces ("text/plain") + public String getLicense() { + //TODO: need to implement fetch license from core + return "License Agreement"; } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java index 3dff018c54..5c93765f52 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java @@ -1,17 +1,19 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. + * 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 cdm.api.android; @@ -40,14 +42,6 @@ public class Enrollment { private static Log log = LogFactory.getLog(Enrollment.class); - /* - * Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD", - * "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"}, - * {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"}, - * {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"}, - * {"name":"osVersion","value":"5.0.0"}]} - * - **/ @POST public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException { @@ -75,7 +69,6 @@ public class Enrollment { log.error(errorMsg, deviceMgtEx); throw new AndroidAgentException(errorMsg, deviceMgtEx); } - } @GET @@ -106,25 +99,14 @@ public class Enrollment { Response.status(HttpStatus.SC_NOT_FOUND); responseMsg.setResponseMessage("Device not found"); } - return responseMsg; - } catch (DeviceManagementException deviceMgtEx) { String errormsg = "Error occurred while enrollment of the device."; log.error(errormsg, deviceMgtEx); throw new AndroidAgentException(errormsg, deviceMgtEx); } - } - /* - * Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD", - * "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"}, - * {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"}, - * {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"}, - * {"name":"osVersion","value":"5.0.0"}]} - * - **/ @PUT @Path("{id}") public Message modifyEnrollment(@PathParam("id") String id, org.wso2.carbon.device.mgt.common.Device device) @@ -157,19 +139,17 @@ public class Enrollment { return responseMsg; - } catch (DeviceManagementException e) { + } catch (DeviceManagementException deviceMgtEx) { String errorMsg = "Error occurred while modifying enrollment of the device"; - log.error(errorMsg, e); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); - responseMsg.setResponseMessage(errorMsg); - return responseMsg; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } @DELETE @Path("{id}") - public Message disenrollDevice(@PathParam("id") String id) throws AndroidAgentException { + public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException { DeviceManagementService dmService; Message responseMsg = new Message(); @@ -195,14 +175,12 @@ public class Enrollment { responseMsg.setResponseMessage("Device not found"); Response.status(HttpStatus.SC_NOT_FOUND); } - return responseMsg; + } catch (DeviceManagementException deviceMgtEx) { String errorMsg = "Error occurred while dis enrolling the device"; log.error(errorMsg, deviceMgtEx); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); - responseMsg.setResponseMessage(errorMsg); - return responseMsg; + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java index 5af6c8f3d7..caf7cf5382 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java @@ -11,7 +11,9 @@ import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; - +/** + * This is a Test class + */ @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) public class Test { diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java index 84523d396a..138a3fa952 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java @@ -1,24 +1,22 @@ /* * Copyright (c) 2014, 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 + * 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 + * 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. + * 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 cdm.api.android.common; - public class AndroidAgentException extends Exception{ private static final long serialVersionUID = 7950151650447893900L; diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java index 698ce3ffec..de3d0c523f 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java @@ -1,21 +1,20 @@ /* * Copyright (c) 2014, 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 + * 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 + * 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. + * 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 cdm.api.android.common; import org.wso2.carbon.device.mgt.common.DeviceManagementException; diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java index 7f526900d6..d166f105d4 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java @@ -1,21 +1,20 @@ /* * Copyright (c) 2014, 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 + * 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 + * 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. + * 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 cdm.api.android.common; diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java index e2ae093a0c..e0e418b8a2 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. - */ - + * 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 cdm.api.android.util; import org.apache.commons.logging.Log; @@ -31,6 +32,7 @@ public class AndroidAPIUtils { private static Log log = LogFactory.getLog(AndroidAPIUtils.class); public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) { + DeviceIdentifier identifier = new DeviceIdentifier(); identifier.setId(deviceId); identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); @@ -41,7 +43,6 @@ public class AndroidAPIUtils { public static DeviceManagementService getDeviceManagementService() throws DeviceManagementServiceException{ // until complete login this is use to load super tenant context - DeviceManagementService dmService; PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java index 0dcb9e59de..f3880536c2 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * 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 + * 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. - */ - + * 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 cdm.api.android.util; /** diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java index f5e34cf7ec..5361ff0d4c 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java @@ -1,21 +1,20 @@ /* * Copyright (c) 2014, 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 + * 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 + * 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. - */ - + * 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 cdm.api.android.util; import javax.xml.bind.annotation.XmlElement; diff --git a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index 693d44557d..7f7e753d17 100644 --- a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,21 +1,21 @@ - - + ~ 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. +--> - + @@ -60,8 +60,6 @@ - - diff --git a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml index b12b2cf4e8..1a5ca4fedd 100644 --- a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml +++ b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml @@ -1,19 +1,21 @@ + ~ 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. +--> CDM-Android-API