From df09c4bd3c6b75a62ac04afe1238c980cf9c8a4d Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Fri, 23 Jan 2015 18:39:28 +0530 Subject: [PATCH 01/11] * Added method to the mobile feature DAO to get features by type * Changed method - getFeaturePropertyOfFeature to accept a string * Added Device Type to the Feature DAO implementations * Changed Device Feature properties DAO for Int * Implemented the get feature by type to android operation manager --- .../mgt/mobile/dao/MobileFeatureDAO.java | 9 +++ .../mobile/dao/MobileFeaturePropertyDAO.java | 2 +- .../mobile/dao/impl/MobileFeatureDAOImpl.java | 69 ++++++++++++++----- .../impl/MobileFeaturePropertyDAOImpl.java | 12 ++-- .../device/mgt/mobile/dto/MobileFeature.java | 8 +++ .../AndroidMobileOperationManager.java | 44 ++++++++++-- 6 files changed, 115 insertions(+), 29 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java index 8b516443ac..28a6aafe93 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java @@ -87,4 +87,13 @@ public interface MobileFeatureDAO { * @throws MobileDeviceManagementDAOException */ List getAllFeatures() throws MobileDeviceManagementDAOException; + + /** + * Retrieve all the features from plugin specific database for a Device Type. + * @param deviceType - Device type. + * @return Feature object list. + * @throws MobileDeviceManagementDAOException + */ + List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java index a61a598a97..fce7df41be 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java @@ -70,7 +70,7 @@ public interface MobileFeaturePropertyDAO { * @return Feature property object that holds data of the feature property represented by propertyId. * @throws MobileDeviceManagementDAOException */ - List getFeaturePropertyOfFeature(String featureId) + List getFeaturePropertyOfFeature(Integer featureId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java index 6f983089d8..89fa32915e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java @@ -18,8 +18,8 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; @@ -51,12 +51,13 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; + "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileFeature.getCode()); stmt.setString(2, mobileFeature.getName()); stmt.setString(3, mobileFeature.getDescription()); + stmt.setString(4, mobileFeature.getDeviceType()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -81,12 +82,13 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ? WHERE FEATURE_ID = ?"; + "UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ? WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, mobileFeature.getCode()); stmt.setString(2, mobileFeature.getName()); stmt.setString(3, mobileFeature.getDescription()); - stmt.setInt(4, mobileFeature.getId()); + stmt.setString(4, mobileFeature.getDeviceType()); + stmt.setInt(5, mobileFeature.getId()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -163,16 +165,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = ?"; + "SELECT FEATURE_ID,DEVICE_TYPE, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, featureCode); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileFeature = new MobileFeature(); mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); + mobileFeature.setDeviceType(resultSet.getString(2)); + mobileFeature.setCode(resultSet.getString(3)); + mobileFeature.setName(resultSet.getString(4)); + mobileFeature.setDescription(resultSet.getString(5)); break; } } catch (SQLException e) { @@ -195,16 +198,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE FEATURE_ID = ?"; + "SELECT FEATURE_ID,DEVICE_TYPE, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, featureID); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileFeature = new MobileFeature(); mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); + mobileFeature.setDeviceType(resultSet.getString(2)); + mobileFeature.setCode(resultSet.getString(3)); + mobileFeature.setName(resultSet.getString(4)); + mobileFeature.setDescription(resultSet.getString(5)); break; } } catch (SQLException e) { @@ -227,15 +231,16 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE"; + "SELECT FEATURE_ID,DEVICE_TYPE, CODE, NAME, DESCRIPTION FROM MBL_FEATURE"; stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileFeature = new MobileFeature(); mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); + mobileFeature.setDeviceType(resultSet.getString(2)); + mobileFeature.setCode(resultSet.getString(3)); + mobileFeature.setName(resultSet.getString(4)); + mobileFeature.setDescription(resultSet.getString(5)); mobileFeatures.add(mobileFeature); } return mobileFeatures; @@ -248,6 +253,38 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { } } + @Override + public List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException { + Connection conn = null; + PreparedStatement stmt = null; + MobileFeature mobileFeature; + List mobileFeatures = new ArrayList(); + try { + conn = this.getConnection(); + String selectDBQuery = + "SELECT FEATURE_ID, DEVICE_TYPE, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE DEVICE_TYPE = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceType); + ResultSet resultSet = stmt.executeQuery(); + while (resultSet.next()) { + mobileFeature = new MobileFeature(); + mobileFeature.setId(resultSet.getInt(1)); + mobileFeature.setDeviceType(resultSet.getString(2)); + mobileFeature.setCode(resultSet.getString(3)); + mobileFeature.setName(resultSet.getString(4)); + mobileFeature.setDescription(resultSet.getString(5)); + mobileFeatures.add(mobileFeature); + } + return mobileFeatures; + } catch (SQLException e) { + String msg = "Error occurred while fetching all features.'"; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + }finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + } + private Connection getConnection() throws MobileDeviceManagementDAOException { try { return dataSource.getConnection(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java index f99a2c7f04..759bba19b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java @@ -56,7 +56,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileFeatureProperty.getProperty()); - stmt.setString(2, mobileFeatureProperty.getFeatureID()); + stmt.setInt(2, mobileFeatureProperty.getFeatureID()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -83,7 +83,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { String updateDBQuery = "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileFeatureProperty.getFeatureID()); + stmt.setInt(1, mobileFeatureProperty.getFeatureID()); stmt.setString(2, mobileFeatureProperty.getProperty()); int rows = stmt.executeUpdate(); if (rows > 0) { @@ -143,7 +143,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { while (resultSet.next()) { mobileFeatureProperty = new MobileFeatureProperty(); mobileFeatureProperty.setProperty(resultSet.getString(1)); - mobileFeatureProperty.setFeatureID(resultSet.getString(2)); + mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); break; } } catch (SQLException e) { @@ -158,7 +158,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { } @Override - public List getFeaturePropertyOfFeature(String featureId) + public List getFeaturePropertyOfFeature(Integer featureId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -169,12 +169,12 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { String selectDBQuery = "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, featureId); + stmt.setInt(1, featureId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileFeatureProperty = new MobileFeatureProperty(); mobileFeatureProperty.setProperty(resultSet.getString(1)); - mobileFeatureProperty.setFeatureID(resultSet.getString(2)); + mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); FeatureProperties.add(mobileFeatureProperty); } return FeatureProperties; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java index 38b6944d61..9bfed2780d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java @@ -24,6 +24,7 @@ import java.io.Serializable; public class MobileFeature implements Serializable { private int id; + private String deviceType; private String code; private String name; private String description; @@ -60,4 +61,11 @@ public class MobileFeature implements Serializable { this.description = description; } + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java index aeb22ba7bc..765dabd095 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java @@ -17,15 +17,13 @@ package org.wso2.carbon.device.mgt.mobile.impl.android; 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.common.Operation; -import org.wso2.carbon.device.mgt.common.OperationManagementException; +import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; -import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation; -import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; +import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; +import org.wso2.carbon.device.mgt.mobile.dao.MobileFeaturePropertyDAO; +import org.wso2.carbon.device.mgt.mobile.dto.*; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import java.util.ArrayList; @@ -155,4 +153,38 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage } return operations; } + + @Override + public List getFeaturesForDeviceType(String deviceType) throws FeatureManagementException { + MobileFeatureDAO featureDAO = MobileDeviceManagementDAOFactory.getFeatureDAO(); + MobileFeaturePropertyDAO featurePropertyDAO = MobileDeviceManagementDAOFactory.getFeaturePropertyDAO(); + List features = new ArrayList(); + try { + List mobileFeatures = featureDAO.getFeatureByDeviceType(deviceType); + for (MobileFeature mobileFeature : mobileFeatures) { + Feature feature = new Feature(); + feature.setId(mobileFeature.getId()); + feature.setDeviceType(mobileFeature.getDeviceType()); + feature.setName(mobileFeature.getName()); + List metadataEntries = new ArrayList(); + List properties = + featurePropertyDAO.getFeaturePropertyOfFeature(mobileFeature.getId()); + for (MobileFeatureProperty property : properties) { + Feature.MetadataEntry metaEntry = new Feature.MetadataEntry(); + metaEntry.setId(property.getFeatureID()); + metaEntry.setValue(property.getProperty()); + metadataEntries.add(metaEntry); + } + feature.setMetadataEntries(metadataEntries); + features.add(feature); + } + } catch (MobileDeviceManagementDAOException e) { + String msg = + "Error while fetching the features for the device type " + + deviceType; + log.error(msg, e); + throw new FeatureManagementException(msg, e); + } + return features; + } } \ No newline at end of file From e40424c7583f3f4e3ebc3b60ecfda3bf7b97a1e2 Mon Sep 17 00:00:00 2001 From: harshanL Date: Fri, 23 Jan 2015 19:44:16 +0530 Subject: [PATCH 02/11] Added copying mobile db scripts to bin.xml & refactored code --- .../impl/dao/MobileFeatureDAOTestSuite.java | 11 ++++- .../modules/distribution/src/assembly/bin.xml | 2 +- .../jax-rs/src/main/java/Licenses.java | 45 ------------------- .../mobileservices/android/Test.java | 35 --------------- 4 files changed, 10 insertions(+), 83 deletions(-) delete mode 100644 product/modules/mobileservices/agents/android/jax-rs/src/main/java/Licenses.java delete mode 100644 product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Test.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java index de81ff5a6d..0f94b06a7d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java @@ -19,6 +19,8 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao; import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; @@ -44,6 +46,7 @@ import java.util.List; public class MobileFeatureDAOTestSuite { + private static final Log log = LogFactory.getLog(MobileFeatureDAOTestSuite.class); public static final String MBL_FEATURE_NAME = "Camera"; private static final String MBL_FEATURE_CODE = "500A"; public static final String MBL_FEATURE_DESCRIPTION = "Camera enable or disable"; @@ -139,6 +142,7 @@ public class MobileFeatureDAOTestSuite { } conn.close(); } catch (SQLException e) { + log.error("Error in retrieving Mobile Feature data ", e); throw new MobileDeviceManagementDAOException("Error in retrieving Mobile Feature data ", e); } finally { @@ -182,6 +186,7 @@ public class MobileFeatureDAOTestSuite { } conn.close(); } catch (SQLException e) { + log.error("Error in deleting Mobile Feature data ", e); throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", e); } finally { @@ -228,6 +233,7 @@ public class MobileFeatureDAOTestSuite { } conn.close(); } catch (SQLException e) { + log.error("Error in deleting Mobile Feature data ", e); throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", e); } finally { @@ -252,8 +258,8 @@ public class MobileFeatureDAOTestSuite { stmt = conn.createStatement(); ResultSet resultSet = stmt .executeQuery( - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = " + - MBL_FEATURE_UPDATED_CODE); + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = '" + + MBL_FEATURE_UPDATED_CODE + "'"); while (resultSet.next()) { testMblFeature.setId(resultSet.getInt(1)); testMblFeature.setCode(resultSet.getString(2)); @@ -262,6 +268,7 @@ public class MobileFeatureDAOTestSuite { } conn.close(); } catch (SQLException e) { + log.error("Error in updating Mobile Feature data ", e); throw new MobileDeviceManagementDAOException("Error in updating Mobile Feature data ", e); } finally { diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 7420ae1f65..0a4cbc57a7 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -210,7 +210,7 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm + ../distribution/src/repository/dbscripts/cdm wso2mdm-${project.version}/dbscripts/cdm */** diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/Licenses.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/Licenses.java deleted file mode 100644 index aa49c5939f..0000000000 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/Licenses.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * * - * * WSO2 Inc. licenses this file to you under the Apache License, - * * Version 2.0 (the "License"); you may not use this file except - * * in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, - * * software distributed under the License is distributed on an - * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * * KIND, either express or implied. See the License for the - * * specific language governing permissions and limitations - * * under the License. - * / - */ - -import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.License; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Produces; - -/** - * License Management related JAX RS APIs - */ - -@Produces({ "application/json", "application/xml" }) -@Consumes({ "application/json", "application/xml" }) -public class Licenses { - - private static Log log = LogFactory.getLog(Licenses.class); - - @GET - public License getLicense(String deviceType) throws AndroidAgentException { - return null; - } - -} diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Test.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Test.java deleted file mode 100644 index ee9e562127..0000000000 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Test.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.wso2.cdmserver.mobileservices.android; - -import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.Device; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -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 { - - @GET - public List getAllDevices() throws DeviceManagementException{ - - Device dev = new Device(); - dev.setName("test1"); - dev.setDateOfEnrolment(11111111L); - dev.setDateOfLastUpdate(992093209L); - dev.setDescription("sassasaas"); - - ArrayList listdevices = new ArrayList(); - listdevices.add(dev); - throw new DeviceManagementException("test ex"); - - } -} From da34270a61548df08a45ed17182a7a9393572bac Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 23 Jan 2015 20:53:50 +0530 Subject: [PATCH 03/11] Fixing API Manager related issues --- ...obileDeviceManagementServiceComponent.java | 214 ++++++++---------- .../src/assembly/filter.properties | 2 +- 2 files changed, 93 insertions(+), 123 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index 28606783db..2d0dc8c916 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -24,8 +24,11 @@ import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.apimgt.impl.APIManagerFactory; +import org.wso2.carbon.apimgt.impl.utils.APIMgtDBUtil; +import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.MobileDeviceManagementStartupObserver; import org.wso2.carbon.device.mgt.mobile.config.APIConfig; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; @@ -55,134 +58,101 @@ import java.util.List; */ public class MobileDeviceManagementServiceComponent { - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration iOSServiceRegRef; - private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration serverStartupObserverRef; - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); + private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the datasource configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - MobileDataSourceConfig dsConfig = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); - - MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); - MobileDeviceManagementDAOFactory.init(); - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( - MobileDeviceManagementDAOFactory.getDataSource()); - } catch (DeviceManagementException e) { - log.error( - "Exception occurred while initializing mobile device management database schema", - e); - } - } - - androidServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new AndroidDeviceManagerService(), null); - iOSServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new IOSDeviceManagerService(), null); - windowsServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new WindowsDeviceManagerService(), null); - - /* Initialize all API configurations with corresponding API Providers */ - this.initAPIConfigs(); - /* Publish all mobile device management related JAX-RS services as APIs */ - this.publishAPIs(); - - if (log.isDebugEnabled()) { - log.debug( - "Mobile Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", - e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - - androidServiceRegRef.unregister(); - iOSServiceRegRef.unregister(); - windowsServiceRegRef.unregister(); + MobileDeviceConfigurationManager.getInstance().initConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() + .getMobileDeviceManagementConfig(); + MobileDataSourceConfig dsConfig = + config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); + + MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); + MobileDeviceManagementDAOFactory.init(); + String setupOption = System.getProperty("setup"); + if (setupOption != null) { + if (log.isDebugEnabled()) { + log.debug( + "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + + "to begin"); + } + try { + MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( + MobileDeviceManagementDAOFactory.getDataSource()); + } catch (DeviceManagementException e) { + log.error("Exception occurred while initializing mobile device management database schema", e); + } + } + + androidServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new AndroidDeviceManagerService(), null); + iOSServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new IOSDeviceManagerService(), null); + windowsServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new WindowsDeviceManagerService(), null); + + serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class, + new MobileDeviceManagementStartupObserver(), null); + if (log.isDebugEnabled()) { + log.debug("Mobile Device Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Mobile Device Management Service Component", e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Mobile Device Management Service Component"); + } + try { + androidServiceRegRef.unregister(); + iOSServiceRegRef.unregister(); + windowsServiceRegRef.unregister(); + serverStartupObserverRef.unregister(); /* Removing all APIs published upon start-up for mobile device management related JAX-RS services */ - this.removeAPIs(); - if (log.isDebugEnabled()) { - log.debug( - "Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle", e); - } - } - - private void initAPIConfigs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - try { - APIProvider provider = - APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); - apiConfig.init(provider); - } catch (APIManagementException e) { - throw new DeviceManagementException( - "Error occurred while initializing API Config '" + - apiConfig.getName() + "'", e); - } - } - } - - private void publishAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); - } - } - - private void removeAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); - } - } - - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } + this.removeAPIs(); + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Mobile Device Management bundle", e); + } + } + + private void removeAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); + } + } + + protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } + + protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } } diff --git a/product/modules/distribution/src/assembly/filter.properties b/product/modules/distribution/src/assembly/filter.properties index 19404cf6e9..6910642d58 100644 --- a/product/modules/distribution/src/assembly/filter.properties +++ b/product/modules/distribution/src/assembly/filter.properties @@ -1,5 +1,5 @@ product.name=WSO2 Mobile Device Manager -product.version=1.0.0-SNAPSHOT +product.version=2.0.0-SNAPSHOT product.key=MDM hotdeployment=true hotupdate=true From bdb522d0e5fc34c30443366e0e4e786ba078d72f Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 23 Jan 2015 21:18:54 +0530 Subject: [PATCH 04/11] Delete license rxt --- .../src/repository/resources/rxts/license.rxt | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 product/modules/distribution/src/repository/resources/rxts/license.rxt diff --git a/product/modules/distribution/src/repository/resources/rxts/license.rxt b/product/modules/distribution/src/repository/resources/rxts/license.rxt deleted file mode 100644 index 2fc84c6db9..0000000000 --- a/product/modules/distribution/src/repository/resources/rxts/license.rxt +++ /dev/null @@ -1,47 +0,0 @@ - - - /license/@{overview_provider}/@{overview_name}/@{overview_language}/@{overview_version} - overview_name - - - - - - - - - - - - - - - - - - - - Provider - - - Name - - - Language - - - Version - - - Validity From - - - Validity To - - - License - -
-
-
From 7dc6a987c74ca58cec6e36d923e7db082f03c6c3 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 23 Jan 2015 21:19:26 +0530 Subject: [PATCH 05/11] Remove license rxt file from MDM --- product/modules/distribution/src/assembly/bin.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 7420ae1f65..9fbb55b7f6 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -127,13 +127,6 @@
- - - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/ - - wso2mdm-${project.version}/repository/resources/rxts/ - - src/repository/conf/datasources wso2mdm-${project.version}/repository/conf/datasources From e9ebd884459fe142ce7277449f493f3d508302a3 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 23 Jan 2015 21:29:32 +0530 Subject: [PATCH 06/11] Configuring logging for test cases --- .../pom.xml | 3 ++ .../src/test/resources/log4j.properties | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties 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 cdad607b63..5180e45ed2 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 @@ -73,6 +73,9 @@ maven-surefire-plugin 2.18 + + file:src/test/resources/log4j.properties + src/test/resources/testng.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties new file mode 100644 index 0000000000..7da6d6c9e1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties @@ -0,0 +1,32 @@ +# +# Copyright 2009 WSO2, Inc. (http://wso2.com) +# +# 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. +# + +# +# This is the log4j configuration file used by WSO2 Carbon +# +# IMPORTANT : Please do not remove or change the names of any +# of the Appenders defined here. The layout pattern & log file +# can be changed using the WSO2 Carbon Management Console, and those +# settings will override the settings in this file. +# + +log4j.rootLogger=DEBUG, STD_OUT + +# Redirect log messages to console +log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender +log4j.appender.STD_OUT.Target=System.out +log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout +log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n From f296fb763e07a9cd4ef653d6bbe9447fd29c0371 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 23 Jan 2015 21:36:02 +0530 Subject: [PATCH 07/11] Configuring product.name and product.version variables to be replaced with appropriate filter properties --- product/modules/distribution/src/assembly/bin.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 0a4cbc57a7..5cdad53d4b 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -470,5 +470,11 @@ 644 + + target/wso2carbon-core-${carbon.kernel.version}/repository/conf/carbon.xml + ${pom.artifactId}-${pom.version}/repository/conf/ + true + + From 9a89aa81128b20bf94f31f2ad3334628e55d389f Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Fri, 23 Jan 2015 21:37:16 +0530 Subject: [PATCH 08/11] Adding the sso features and changing the filter.properties --- .../src/assembly/filter.properties | 2 +- product/modules/p2-profile-gen/pom.xml | 87 ++++++++++++++++++- 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/product/modules/distribution/src/assembly/filter.properties b/product/modules/distribution/src/assembly/filter.properties index 19404cf6e9..6910642d58 100644 --- a/product/modules/distribution/src/assembly/filter.properties +++ b/product/modules/distribution/src/assembly/filter.properties @@ -1,5 +1,5 @@ product.name=WSO2 Mobile Device Manager -product.version=1.0.0-SNAPSHOT +product.version=2.0.0-SNAPSHOT product.key=MDM hotdeployment=true hotupdate=true diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index 0329734c5f..5cb9a53ee6 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -182,7 +182,7 @@ org.wso2.carbon:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.platform.version} - org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.identity.core.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version} @@ -262,10 +262,46 @@ - org.wso2.carbon:org.wso2.carbon.identity.self.registration.server.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.identity.self.registration.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.security.mgt.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.application.authenticator.basicauth.server.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.sso.saml.feature:${carbon.platform.version} + + + + + org.wso2.carbon:org.wso2.carbon.identity.user.profile.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.application.mgt.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.idp.mgt.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.identity.mgt.feature:${carbon.platform.version} + + + + @@ -378,7 +414,7 @@ ${carbon.platform.version}
- org.wso2.carbon.identity.core.server.feature.group + org.wso2.carbon.identity.core.feature.group ${carbon.platform.version} @@ -431,7 +467,7 @@ - org.wso2.carbon.identity.self.registration.server.feature.group + org.wso2.carbon.identity.self.registration.feature.group ${carbon.platform.version} @@ -494,6 +530,49 @@ org.wso2.carbon.um.ws.service.client.feature.group ${carbon.platform.version} + + + + + org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group + + ${carbon.platform.version} + + + + org.wso2.carbon.identity.application.authentication.framework.server.feature.group + + ${carbon.platform.version} + + + org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group + ${carbon.platform.version} + + + org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature.group + ${carbon.platform.version} + + + + + org.wso2.carbon.identity.user.profile.feature.group + ${carbon.platform.version} + + + org.wso2.carbon.identity.application.mgt.feature.group + ${carbon.platform.version} + + + org.wso2.carbon.idp.mgt.feature.group + ${carbon.platform.version} + + + org.wso2.carbon.identity.mgt.feature.group + ${carbon.platform.version} + + + + From 3f7b93163be76a7ba33c7b07554a5ff80543d89a Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Fri, 23 Jan 2015 22:03:01 +0530 Subject: [PATCH 09/11] * Added a description to the feature implementation * Added the feature insert, changed the feature_id to int and added device_type to features * Included the updated database file * Developed the feature to view device features * Developed the implementation to call the Operation Manager from the UI --- .../AndroidMobileOperationManager.java | 1 + .../repository/database/WSO2MobileDM_DB.h2.db | Bin 45056 -> 1093632 bytes .../repository/dbscripts/cdm/plugins/h2.sql | 8 +++- .../dbscripts/cdm/plugins/mysql.sql | 5 +++ .../jaggeryapps/cdm/api/mobile/device-api.jag | 1 + .../cdm/api/mobile/operation-api.jag | 40 ++++++++++++++++++ .../jaggeryapps/cdm/client/javascript/main.js | 20 ++++++++- .../jaggeryapps/cdm/includes/footer.jag | 20 ++++++++- .../repository/jaggeryapps/cdm/jaggery.conf | 4 ++ .../jaggeryapps/cdm/modules/device.js | 40 +++++++++++++++--- .../jaggeryapps/cdm/pages/dashboard.jag | 1 + .../jaggeryapps/cdm/pages/device.jag | 19 ++++++--- 12 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/operation-api.jag diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java index cd6d04cb9c..96706117e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java @@ -166,6 +166,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage feature.setId(mobileFeature.getId()); feature.setDeviceType(mobileFeature.getDeviceType()); feature.setName(mobileFeature.getName()); + feature.setDescription(mobileFeature.getDescription()); List metadataEntries = new ArrayList(); List properties = featurePropertyDAO.getFeaturePropertyOfFeature(mobileFeature.getId()); diff --git a/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db b/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db index 78086440fdc9634924760809b633ef648247456a..361e1db39d23d458f9ed4ace29d112f5802a6dc1 100644 GIT binary patch delta 6943 zcmeI#d2|!i9>DRL$t3BP?xmD&H!YMFrqG=tpk!+sTbi1-AR?q}VntR_P{b6l;4TpN z1tab&A}T710r!31w`tsPLvdI1@xBSAdd~BCIOqNOn$yqiZ8CG`&i(!FFVikv>C)}N zn1SC9*s@HDzEm&2WDLN-ttm0P&Hw!AhJnWM`~Sz+7Tb37Cb7Dl z#$gzPu^5NLaRkQ020I*Z!i752qXBLliAFSG0-E7L3y$LYQe^d8(S~+R#3USz$v6g6 za4e=`8hq%$bj-j^%))FOhdDSNoj3t=aU$knJ{Djh7IA%PF;2n~oQzYj6p{2e6{lf2 zPR9zIfyjAXScz3wjWf}WHCT(Ya5m1txi}B!;{sfWb?~pJ*?<5p!o|1*m*O&9jw^5_ zuEN#Wh-(nUwb+E~a6N9ojkpOn;}+bC+i*MXz@6BPyCV0oh0fjBihFP`?!z|Rj|cD| zw&Ni@j2(CcA?(C1Jc`HgIG(_hcnVMB89a;U@H}3?i+CxrjxW=B1+U^YypA{UCf>r^ zcn9y|J-m+(@F8^cAdHXjF+Rbk_zb)8IljP`_zGWR55B>-TwmIY@9;f-z>oL|KjRnt zir=sgzvB=53;PdL4O!;50s~YSVS*Vkh(#RYkpK%4kpzD-O$t(xhIC|L05UNUSr~+D zAnn1kcdi4!mvCt@DvV}YM$Ar@gVPQntLj8m`_%Wx`A!*ZOC6*vQt^SiJT ztFRhpq8n?l7H8pXoP%?59?r)F@Lx!?4(qW20bGQOaS1NPWw;zy;7VMDtFaN+Ac$+R z3D@Cz+<+T#6K=*WxD~hIcHDtGBk|u%=Pqo)-PnqIa4+t|Hr$T~@F2G1Av}y7cmyHr z#4bFF$M86wz>|0iPvaRpi|6n>UWmm1MLI9xWxRq{@fu#o8+a3M;cdKwckv$H#|QWj zI(iVsNB9_@;8T2t-S`||;7fdkudyc*zi;p@_ToEyk00JN=z(KjXsIUF+7TVV_x54Oo%c4=bOnf z3t7SgN6N+<4fz|2MUu$T_e;G$+ob%!zTra731n-z{?IU`uF!QpzFOgR)w#T`W{0aabhxf`>*~zJW{;!6l}lxR?QQ8rIz5{VAlAtp-?cjOVcyo(xrt)HCG7Bslj&HVY5z=oZ+l7N^zVJ zQpgb}CfdA?2Aj9Is@k^E)FztSo0_zag0P&UCk!^km8dz^cIp0b(pLK|s;$lKY3`BM zhcoWgV@J-|=GUbGVdDd|Gq#5dcRvA(_lhbn_b zl1~&R_(rQKgmHqy>$0_pWx70GPtYVG*6Q(B>Be~`HJLzcRf4TXhmEK^_0+cyL_#+j zHj6t42J+6#GKBp3fwFEP=LTB3)BPpf#DTDMs0Lq~#}}F%s@E&0Nm|EKQk~T;w|m7p z#p85|`%Jx&)RpC3MJsa^r_X6ys@UE2CtfJywIo~byK*sGe59nt?)}Op@u6u_3UYz?BR^*O0#W3Sne{Emz9-t zRhyiyR)^Q!GOKmhMyW#NDsd&l!v!n!>>I*qE952@(an}kMTYd$Ws=~bTp0d774D9t zf@~OKFc}B$*K66g2ahZ4>qR?DqX()1#gMXOZ)C{*f^8fxgg@CldXRZYwmB`&Ea#i{ zT1`D-)WJdiGDfGAq6({;Th!>OtJBIf%~j4`OOl4_Qj)2R-KFLhhmvCJ%d~QJkX6kp z(bW_+OQ>1HLMf746q>aPHPfo5X`wVRNlNF;(oj-Iz3M07(?)R2gpTSstx~H}Q>>&& zQ*gaBORO>`3pH6y36*sDlv1mv8wyoTXliQ6Dm4Zh)e>v5nifhoxyp(~v6>!Al-h%Z ziCUFbt<`9wv|1sAni0zDvddbfNs0Vtm1JdUkLc|u(r?J3u_F^1a_Ue+is3jGNKR1y z+y2{fVE;vjvnUF?(78Yz9?0k(KEKLdS6)$9R_Cj%s44eV*=igiODA7 zBbs`XW0tFoi8grDQc8h4AWta@6s;+Y=e;9OQ%6v6mh={@seVO~%_MqSG|}_^G0}U& zmQSR{U>ruvF+?mY8nImEP$HJsH|M-GlbV}D;toBS(~<0Dj!nzd=-0)fK+o#@-ijI< zm_4GZhFaKHi{eW9M#@hysd;RU;)4T4Z@+nx$`-L&TB7%F8Zpem*e$DMRn2Dwmj9(( zi@?>T;|lwRv!6VS&J8R&T6PGtF%#Lqe;-@aWs0Ivrp-q zIa{2#VCLM&^U0sDt+_EDnYW4~6 DQVd7p delta 57 tcmZp8;MDMdX#oe%EZql>8Nh(WceCTQFYK5ilO$Lf*@1Gu*cT~G002UQ6WIU& diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql index aab99bd146..86e0de45ff 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql @@ -20,6 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( `FEATURE_ID` INT NOT NULL AUTO_INCREMENT , + `DEVICE_TYPE` VARCHAR(45) NOT NULL , `CODE` VARCHAR(45) NOT NULL , `NAME` VARCHAR(100) NULL , `DESCRIPTION` VARCHAR(200) NULL , @@ -74,10 +75,15 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( `PROPERTY` VARCHAR(45) NOT NULL , - `FEATURE_ID` VARCHAR(45) NOT NULL , + `FEATURE_ID` INT NOT NULL , PRIMARY KEY (`PROPERTY`) , CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1` FOREIGN KEY (`FEATURE_ID` ) REFERENCES `MBL_FEATURE` (`FEATURE_ID` ) ON DELETE NO ACTION ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Inserts +-- ----------------------------------------------------- +Insert into MBL_FEATURE (DEVICE_TYPE_ID,CODE, NAME, DESCRIPTION) VALUES ('android', "503A", "DEVICE_LOCK", "Device lock"); \ No newline at end of file diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql index 3e6ee30a5f..2928514d4a 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql @@ -20,6 +20,7 @@ ENGINE = InnoDB; -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, + `DEVICE_TYPE_ID` INT NOT NULL, `CODE` VARCHAR(45) NULL, `NAME` VARCHAR(100) NULL, `DESCRIPTION` VARCHAR(200) NULL, @@ -97,4 +98,8 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( ENGINE = InnoDB; +-- ----------------------------------------------------- +-- Inserts +-- ----------------------------------------------------- +Insert into MBL_FEATURE (DEVICE_TYPE_ID,CODE, NAME, DESCRIPTION) VALUES ('android', "503A", "DEVICE_LOCK", "Device lock"); diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag index 783176d285..298a62d763 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag @@ -22,6 +22,7 @@ var uri = request.getRequestURI(); var callPath=uri.replace("/cdm/api/",""); var log = new Log(); var deviceModule = require("/modules/device.js"); + if (uri != null) { var uriMatcher = new URIMatcher(callPath); log.info(callPath); diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/operation-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/operation-api.jag new file mode 100644 index 0000000000..b11875d1eb --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/operation-api.jag @@ -0,0 +1,40 @@ +<% +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var verb = request.getMethod(); +var uri = request.getRequestURI(); +var callPath=uri.replace("/cdm/api/",""); +var log = new Log(); +var deviceModule = require("/modules/device.js"); + +if (uri != null) { + var uriMatcher = new URIMatcher(callPath); + //log.info(callPath); + log.info(uriMatcher.match("operation/{type}/{deviceid}/{operation}")); + if (uriMatcher.match("operation/{type}/{deviceid}/{operation}")) { + + var deviceId = uriMatcher.elements().deviceid; + var type = uriMatcher.elements().type; + var operation = uriMatcher.elements().operation; + var result = deviceModule.performOperation(deviceId, operation,[],type); + + + } +} +%> \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js index 0fa9dd49d8..af57503dac 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js @@ -21,4 +21,22 @@ function identifierFormatter(value, row, index) { value, '' ].join(''); -} \ No newline at end of file +} + +var currentDeviceOperation; +var currentDevice; +var currentDeviceType; +function performOperation(){ + currentDevice = $("#deviceMain").data("deviceid"); + currentDeviceType = $("#deviceMain").data("devicetype"); + $.post("/cdm/api/operation/"+currentDeviceType+"/"+currentDevice+"/"+currentDeviceOperation,function(){ + $('#confirmModel').modal('hide'); + }); +} + +$(document).ready(function(){ + $(".device-operation").click(function(){ + currentDeviceOperation = $(this).data("operation"); + $('#confirmModel').modal('show'); + }); +}); \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/includes/footer.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/includes/footer.jag index 49db93e039..a62b5cfb80 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/includes/footer.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/includes/footer.jag @@ -1,3 +1,21 @@ <% // footer includes -%> \ No newline at end of file +%> + + \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf index efc8b12576..92697a30fa 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf @@ -10,6 +10,10 @@ "url": "/dashboard", "path": "/pages/dashboard.jag" }, + { + "url" : "/api/operation/*", + "path": "/api/mobile/operation-api.jag" + }, { "url": "/api/devices/mobile/*", "path": "/api/mobile/device-api.jag" diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js index 13d77bc291..59fd1ba0c5 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js @@ -19,16 +19,16 @@ var utility = require("/modules/utility.js"); var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier; var DeviceManagerUtil = Packages.org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +var Operation = Packages.org.wso2.carbon.device.mgt.common.Operation; +var Type = Packages.org.wso2.carbon.device.mgt.common.Operation.Type; +var Properties = Packages.java.util.Properties; +var ArrayList = Packages.java.util.ArrayList; var log = new Log(); var deviceManagementService = utility.getDeviceManagementService(); var listDevices = function () { - var devices = deviceManagementService.getAllDevices("android"); - var deviceList = []; - - for (i = 0; i < devices.size(); i++) { var device = devices.get(i); @@ -54,10 +54,38 @@ var getDevice = function(type, deviceId){ return device; } -var viewDevice = function(type, deviceId){ +var getOperations = function(type){ + var features = deviceManagementService.getOperationManager("android").getFeaturesForDeviceType(type); + var featuresConverted = []; + for (i = 0; i < features.size(); i++) { + var feature = features.get(i); + featuresConverted.push({ + "featureName": feature.getName(), + "featureDescription": feature.getDescription() + }); + } + return featuresConverted; +} +var performOperation = function(deviceId, featureName, properties, type){ + var operation = new Operation(); + operation.setCode(featureName); + operation.setType(Type.COMMAND); + var props = new Properties(); + for (i = 0; i < properties.length; i++) { + var object = properties[i]; + props.setProperty(object.key,object.value); + } + operation.setProperties(props); + var deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId) + deviceIdentifier.setType(type); + var deviceList = new ArrayList(); + deviceList.add(deviceIdentifier); + deviceManagementService.getOperationManager("android").addOperation(operation, deviceList); +} +var viewDevice = function(type, deviceId){ var device = this.getDevice(type, deviceId); - var propertiesList = DeviceManagerUtil.convertPropertiesToMap(device.getProperties()); var entries = propertiesList.entrySet(); var iterator = entries.iterator(); diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag index 46c5cd3dad..8bf721890f 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag @@ -73,6 +73,7 @@ var title="WSO2 CDM"; <% + include("/includes/footer.jag"); include("/includes/layout-footer.jag"); %> diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag index 91977bdade..17a14734d5 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag @@ -35,22 +35,26 @@ var title="WSO2 CDM"; var deviceId = uriMatcher.elements().deviceid; var type = uriMatcher.elements().type; var device = deviceModule.viewDevice(type, deviceId); + var operations = deviceModule.getOperations("android"); %> -
+

<%=device.name%>

- - + <% + } +%>
@@ -97,6 +101,7 @@ var title="WSO2 CDM";
<% + include("/includes/footer.jag"); include("/includes/layout-footer.jag"); %> From fb72682da040f20168bacb256c2ec00f9bd0125c Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 23 Jan 2015 22:06:06 +0530 Subject: [PATCH 10/11] Adding API Publisher and Store Features to p2-profile --- .../modules/distribution/src/assembly/bin.xml | 27 ++++++++++++++++++- product/modules/p2-profile-gen/pom.xml | 26 +++++++++++++----- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 5cdad53d4b..2882a42435 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -223,13 +223,38 @@ ${project.artifactId}-${project.version}/repository/resources - + + src/repository/jaggeryapps wso2mdm-${project.version}/repository/deployment/server/jaggeryapps 755 + + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.platform.version}/repository/deployment/server/jaggeryapps/publisher/ + wso2am-${pom.version}/repository/deployment/server/jaggeryapps/publisher + + publisherLogo/** + publisherTheme/** + publisherSite/** + footer/** + localstyles.css + + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.platform.version}/repository/deployment/server/jaggeryapps/store/ + wso2am-${pom.version}/repository/deployment/server/jaggeryapps/store + + storeLogo/** + storeSite/** + base-page/** + login/** + styles-layout.css + + diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index 0329734c5f..27161b93ca 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -259,12 +259,18 @@ org.wso2.carbon:org.wso2.carbon.governance.lifecycle.management.feature:${carbon.platform.version} - - - + + org.wso2.carbon:org.wso2.carbon.identity.self.registration.server.feature:${carbon.platform.version} - + + + + org.wso2.carbon:org.wso2.carbon.apimgt.publisher.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.apimgt.store.feature:${carbon.platform.version} + @@ -429,14 +435,12 @@ ${carbon.platform.version} - org.wso2.carbon.identity.self.registration.server.feature.group ${carbon.platform.version} - org.wso2.carbon.registry.core.feature.group ${carbon.platform.version} @@ -494,6 +498,16 @@ org.wso2.carbon.um.ws.service.client.feature.group ${carbon.platform.version} + + + + org.wso2.carbon.apimgt.publisher.feature.group + ${carbon.platform.version} + + + org.wso2.carbon.apimgt.store.feature.group + ${carbon.platform.version} + From 95e538c324a8df55543cdfe87a34c1f1a7c5d38c Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 23 Jan 2015 22:31:34 +0530 Subject: [PATCH 11/11] Fixing issues related to copying API manager publisher and store related jaggery webapps --- product/modules/distribution/src/assembly/bin.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 2882a42435..2f6d46d395 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -234,8 +234,8 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.platform.version}/repository/deployment/server/jaggeryapps/publisher/ - wso2am-${pom.version}/repository/deployment/server/jaggeryapps/publisher + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaggeryapps/publisher/ + wso2mdm-${project.version}/repository/deployment/server/jaggeryapps/publisher publisherLogo/** publisherTheme/** @@ -245,8 +245,8 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.platform.version}/repository/deployment/server/jaggeryapps/store/ - wso2am-${pom.version}/repository/deployment/server/jaggeryapps/store + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaggeryapps/store/ + wso2mdm-${project.version}/repository/deployment/server/jaggeryapps/store storeLogo/** storeSite/**