From 1db2b40790b4ce67ed5556599884bc7414e7eff4 Mon Sep 17 00:00:00 2001 From: manoj Date: Tue, 13 Jan 2015 10:43:59 +0530 Subject: [PATCH 01/25] Android Services Refactor --- .../carbon/device/mgt/core/DeviceManager.java | 1 + .../device/mgt/core/DeviceManagerImpl.java | 3 +- .../config/DeviceConfigurationManager.java | 4 - .../core/service/DeviceManagementService.java | 110 +++++++++--------- .../src/main/java/cdm/api/android/Device.java | 4 +- .../main/java/cdm/api/android/Enrollment.java | 6 +- product/modules/p2-profile-gen/pom.xml | 19 ++- 7 files changed, 74 insertions(+), 73 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java index 124939f8bd7..ad95758d323 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java @@ -21,6 +21,7 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationManager; +import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import java.util.List; 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 a2b6496747b..a242e3df31f 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 @@ -58,8 +58,7 @@ public class DeviceManagerImpl implements DeviceManager { this.getDeviceDAO().addDevice(deviceDto); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", - e); + throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", e); } return status; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java index 3c5a6073a2c..f9f99ffba94 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java @@ -71,8 +71,4 @@ public class DeviceConfigurationManager { return currentDeviceConfig; } - public DataSourceConfig getDataSourceConfig() { - return currentDeviceConfig.getDeviceMgtRepository().getDataSourceConfig(); - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java index 0cbb3a1cdf4..8ddebb57409 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java @@ -19,7 +19,6 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationManager; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; import org.wso2.carbon.device.mgt.core.DeviceManager; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; @@ -27,60 +26,61 @@ import java.util.List; public class DeviceManagementService implements DeviceManager { - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device); - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device); - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .disenrollDevice(deviceId); - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().isActive(deviceId); - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setActive(deviceId, status); - } - - @Override - public List getAllDevices(String type) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().getAllDevices(type); - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().updateDeviceInfo(device); - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setOwnership(deviceId, ownershipType); - } + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device); + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device); + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager() + .disenrollDevice(deviceId); + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId); + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().isActive(deviceId); + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().setActive(deviceId, status); + } + + @Override + public List getAllDevices(String type) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().getAllDevices(type); + } + + @Override + public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) + throws DeviceManagementException { + + Device device = DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); + return device; + } + + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().updateDeviceInfo(device); + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) + throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager() + .setOwnership(deviceId, ownershipType); + } @Override public OperationManager getOperationManager(String type) throws DeviceManagementException { 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 f1cdfc64f48..19a67b99599 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 @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ +//org.wso2.carbon.... package cdm.api.android; import cdm.api.android.common.AndroidAgentException; @@ -65,7 +66,6 @@ public class Device { } catch (DeviceManagementException e) { msg = "Error occurred while fetching the device list."; LOG.error(msg, e); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } } @@ -80,7 +80,6 @@ public class Device { try { dmService = AndroidAPIUtils.getDeviceManagementService(); - } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; LOG.error(errorMsg, deviceMgtServiceEx); @@ -94,7 +93,6 @@ public class Device { Response.status(HttpStatus.SC_NOT_FOUND); } return device; - } catch (DeviceManagementException deviceMgtEx) { msg = "Error occurred while fetching the device information."; LOG.error(msg, deviceMgtEx); 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 5c93765f525..6a4e00079e7 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 @@ -101,9 +101,9 @@ public class Enrollment { } return responseMsg; } catch (DeviceManagementException deviceMgtEx) { - String errormsg = "Error occurred while enrollment of the device."; - log.error(errormsg, deviceMgtEx); - throw new AndroidAgentException(errormsg, deviceMgtEx); + String errorMsg = "Error occurred while enrollment of the device."; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index f1524dbb38b..95a5e55d257 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -153,12 +153,19 @@ org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version} - - - org.wso2.carbon:org.wso2.carbon.registry.extensions.server.feature:${carbon.platform.version} - + + + org.wso2.carbon:org.wso2.carbon.registry.extensions.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.registry.ws.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.registry.ui.menu.governance.feature:${carbon.platform.version} + + + + + org.wso2.carbon:org.wso2.carbon.governance.metadata.feature:4.2.2 + org.wso2.carbon:org.wso2.carbon.governance.lifecycle.management.feature:4.2.1 + org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version} From b2f89320f7ae84654ea1394e3455af70b375f837 Mon Sep 17 00:00:00 2001 From: manoj Date: Tue, 13 Jan 2015 10:59:10 +0530 Subject: [PATCH 02/25] Android JAX RS Refactor --- .../device/mgt/core/LicenseManager.java | 30 ++ .../cdm/api/android/util/AndroidAPIUtils.java | 27 +- .../api/android/util/AndroidConstants.java | 21 +- .../java/cdm/api/android/util/Message.java | 25 +- .../src/repository/conf/registry.xml | 304 ++++++++++++++++++ 5 files changed, 370 insertions(+), 37 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java create mode 100644 product/modules/distribution/src/repository/conf/registry.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java new file mode 100644 index 00000000000..0275a1bc202 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java @@ -0,0 +1,30 @@ +/* + * + * * 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 + * * + * * 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.core; + +import org.wso2.carbon.device.mgt.core.dto.DeviceType; + +public class LicenseManager { + +/* public void addLicense(DeviceType deviceType,String langCode, String + );*/ + +} 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 e0e418b8a28..c7717041009 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,20 +1,19 @@ /* * 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 + * 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 + * 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; @@ -32,7 +31,6 @@ 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); @@ -42,7 +40,8 @@ public class AndroidAPIUtils { public static DeviceManagementService getDeviceManagementService() throws DeviceManagementServiceException{ - // until complete login this is use to load super tenant context + //TODO: complete login change super tenent 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 f3880536c27..0dcb9e59de6 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,20 +1,19 @@ /* * 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. + * 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 + * 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 5361ff0d4c5..f5e34cf7ec4 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,20 +1,21 @@ /* * 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/distribution/src/repository/conf/registry.xml b/product/modules/distribution/src/repository/conf/registry.xml new file mode 100644 index 00000000000..70ab4ea5a18 --- /dev/null +++ b/product/modules/distribution/src/repository/conf/registry.xml @@ -0,0 +1,304 @@ + + + + + + + + wso2registry + false + true + / + + + + + jdbc/WSO2CarbonDB + + + + + + + + + + .* + + + + + + + + + + + application/vnd.wso2-service+xml + + + + + + + + + /_system/governance/event/topics/registry/notifications/.* + + + + + + + + + + + /trunk/policies/ + + + application/policy+xml + + + + + + + + true + + /trunk/schemas/ + + + application/x-xsd+xml + + + + + + + + + + + + + .* + + + + + + + .* + + + + + + + workflow-config + + + + + + + + + + + + + + + + + + + + 60 + 2 + + 50 + + 10 + + /_system/local/repository/components/org.wso2.carbon.registry/indexing/lastaccesstime + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + /trunk/services/ + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + From 92503ac0fe93605eadb8c83c6ad130af4888e975 Mon Sep 17 00:00:00 2001 From: harshanL Date: Fri, 16 Jan 2015 17:52:31 +0530 Subject: [PATCH 03/25] Added CDM-REST APIs --- .../device/mgt/common/DefaultOperation.java | 30 ---- .../carbon/device/mgt/common/Operation.java | 73 +++++--- .../device/mgt/common/OperationData.java | 75 -------- .../device/mgt/common/OperationFactory.java | 24 --- .../device/mgt/common/OperationManager.java | 29 +++- .../mgt/core/DeviceManagementRepository.java | 3 +- .../DeviceManagementServiceComponent.java | 3 +- .../AbstractMobileOperationManager.java | 17 +- .../dao/MobileDeviceManagementDAOFactory.java | 22 ++- .../dao/impl/DeviceOperationDAOImpl.java | 26 +-- .../mobile/dao/impl/MobileDeviceDAOImpl.java | 14 +- .../device/mgt/mobile/dto/MobileDevice.java | 18 ++ .../AndroidMobileOperationManager.java | 22 ++- .../util/MobileDeviceManagementUtil.java | 6 + .../main/java/cdm/api/android/Operation.java | 116 +++++++++++++ .../src/main/java/cdm/api/android/Test.java | 3 +- .../cdm/api/android/util/AndroidAPIUtils.java | 5 +- .../jax-rs/src/main/webapp/WEB-INF/web.xml | 4 - .../modules/distribution/src/assembly/bin.xml | 16 +- .../src/repository/dbscripts/cdm/h2.sql | 4 +- .../repository/dbscripts/cdm/plugins/h2.sql | 2 + product/modules/rest-api/pom.xml | 161 ++++++++++++++++++ .../org/wso2/carbon/cdm/api/Operation.java | 111 ++++++++++++ .../cdm/api/common/CDMAPIException.java | 57 +++++++ .../carbon/cdm/api/common/ErrorHandler.java | 30 ++++ .../carbon/cdm/api/common/ErrorMessage.java | 39 +++++ .../api/context/DeviceOperationContext.java | 52 ++++++ .../carbon/cdm/api/util/CDMAPIConstants.java | 23 +++ .../wso2/carbon/cdm/api/util/CDMAPIUtils.java | 51 ++++++ .../org/wso2/carbon/cdm/api/util/Message.java | 46 +++++ .../webapp/META-INF/webapp-classloading.xml | 33 ++++ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 40 +++++ .../rest-api/src/main/webapp/WEB-INF/web.xml | 37 ++++ product/pom.xml | 2 +- 34 files changed, 1002 insertions(+), 192 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DefaultOperation.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java create mode 100644 product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Operation.java create mode 100644 product/modules/rest-api/pom.xml create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/Operation.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/common/CDMAPIException.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/common/ErrorHandler.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/common/ErrorMessage.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/context/DeviceOperationContext.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/util/CDMAPIConstants.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/util/CDMAPIUtils.java create mode 100644 product/modules/rest-api/src/main/java/org/wso2/carbon/cdm/api/util/Message.java create mode 100644 product/modules/rest-api/src/main/webapp/META-INF/webapp-classloading.xml create mode 100644 product/modules/rest-api/src/main/webapp/WEB-INF/cxf-servlet.xml create mode 100644 product/modules/rest-api/src/main/webapp/WEB-INF/web.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DefaultOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DefaultOperation.java deleted file mode 100644 index f947e7f45ff..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DefaultOperation.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2012, 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.common; - -public class DefaultOperation implements Operation { - - @Override - public void init() { - - } - - @Override - public void execute() { - - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java index 8424142f7d8..755be0b5ccc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java @@ -1,33 +1,60 @@ -/** - * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * Copyright (c) 2015, 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 + * 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package org.wso2.carbon.device.mgt.common; -/** - * This class needs to be implemented by all - */ -public interface Operation { +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Properties; + +@XmlRootElement +public class Operation { + + public enum Type { + CONFIG, MESSAGE, INFO + } + + private String code; + private Properties properties; + private Type type; + + @XmlElement + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @XmlElement + public Properties getProperties() { + return properties; + } - /** - * Initializes any start-up resources required to execute a particular operation - */ - void init(); + public void setProperties(Properties properties) { + this.properties = properties; + } - /** - * Executes the functionality configured within the method implementation - */ - void execute(); + @XmlElement + public Type getType() { + return type; + } -} + public void setType(Type type) { + this.type = type; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java deleted file mode 100644 index 9cb0ad63d58..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java +++ /dev/null @@ -1,75 +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.common; - -import java.util.Properties; - -public class OperationData { - - public enum Type { - CONFIG, MESSAGE, STATE - } - - private String name; - private boolean state; - private Properties properties; - private String text; - private Type type; - - public OperationData(String name, Type type) { - this.type = type; - this.name = name; - } - - public OperationData(String name, boolean state) { - this.name = name; - this.type = Type.STATE; - this.state = state; - } - - public OperationData(String name, Properties properties) { - this.name = name; - this.type = Type.CONFIG; - this.properties = properties; - } - - public OperationData(String name, String text) { - this.name = name; - this.type = Type.MESSAGE; - this.text = text; - } - - public Type getType() { - return type; - } - - public boolean getState() { - return state; - } - - public String getText() { - return text; - } - - public Properties getProperties() { - return properties; - } - - public String getName() { - return name; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java deleted file mode 100644 index 0c29aac79b8..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2012, 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.common; - -public class OperationFactory { - - public static Operation getOperation(String type) { - return null; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java index f1446bda5dd..e11f5740a35 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java @@ -15,8 +15,33 @@ */ package org.wso2.carbon.device.mgt.common; +import java.util.List; + +/** + * This represents the Device Operation management functionality which should be implemented by + * the device type plugins. + */ public interface OperationManager { - boolean executeOperation(); + /** + * Method to add a operation to a device or a set of devices. + * + * @param operation Operation to be added + * @param devices List of DeviceIdentifiers to execute the operation + * @throws OperationManagementException If some unusual behaviour is observed while adding the + * operation + */ + public boolean addOperation(Operation operation, List devices) + throws OperationManagementException; + + /** + * Method to retrieve the list of available operations to a device. + * + * @param deviceId DeviceIdentifier of the device + * @throws OperationManagementException If some unusual behaviour is observed while fetching the + * operation list. + */ + public List getOperations(DeviceIdentifier deviceId) + throws OperationManagementException; -} +} \ No newline at end of file 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 3f3340c1f38..9cf5ed8f3a6 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 @@ -50,5 +50,4 @@ public class DeviceManagementRepository { public Map getProviders() { return providers; } - -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index daa67845bb6..68d53be206e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -51,6 +51,7 @@ import org.wso2.carbon.user.core.service.RealmService; */ public class DeviceManagementServiceComponent { + public static final String SETUP_OPTION = "setup"; private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); @@ -67,7 +68,7 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager); /* If -Dsetup option enabled then create device management database schema */ - String setupOption = System.getProperty("setup"); + String setupOption = System.getProperty(SETUP_OPTION); if (setupOption != null) { if (log.isDebugEnabled()) { log.debug("-Dsetup is enabled. Device management repository schema initialization is about " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java index e969045d15e..4ddddf6ad0a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java @@ -15,10 +15,21 @@ */ package org.wso2.carbon.device.mgt.mobile; -import org.wso2.carbon.device.mgt.common.OperationManager; +import org.wso2.carbon.device.mgt.common.*; -public abstract class AbstractMobileOperationManager implements OperationManager { +import java.util.List; +public abstract class AbstractMobileOperationManager implements OperationManager { + @Override + public List getOperations(DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + return null; + } -} + @Override + public boolean addOperation(Operation operation, List devices) throws + OperationManagementException { + return true; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index 2d85c05df2f..e60e0ec17d4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.DataSourceListener; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.dao.impl.MobileDeviceDAOImpl; +import org.wso2.carbon.device.mgt.mobile.dao.impl.*; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator; @@ -52,6 +52,26 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener { return new MobileDeviceDAOImpl(dataSource); } + public static OperationDAO getOperationDAO(){ + return new OperationDAOImpl(dataSource); + } + + public static OperationPropertyDAO geOperationPropertyDAO(){ + return new OperationPropertyDAOImpl(dataSource); + } + + public static DeviceOperationDAO getDeviceOperationDAO(){ + return new DeviceOperationDAOImpl(dataSource); + } + + public static FeatureDAO getFeatureDAO(){ + return new FeatureDAOImpl(dataSource); + } + + public static FeaturePropertyDAO getFeaturePropertyDAO(){ + return new FeaturePropertyDAOImpl(dataSource); + } + public static MobileDataSourceConfig getMobileDeviceManagementConfig() { return mobileDataSourceConfig; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java index 26c5884d995..8f6b6a80581 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java @@ -49,7 +49,9 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { } } catch (SQLException e) { String msg = "Error occurred while adding device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";; + deviceOperation.getDeviceId() + " and operation id - " + + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION"; + ; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -79,7 +81,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { } } catch (SQLException e) { String msg = "Error occurred while updating device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION"; + deviceOperation.getDeviceId() + " and operation id - " + + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -102,12 +105,13 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { stmt.setString(1, deviceId); stmt.setInt(2, operationId); int rows = stmt.executeUpdate(); - if(rows>0){ + if (rows > 0) { status = true; } } catch (SQLException e) { - String msg = "Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" + - deviceId + " and operation id - " + operationId; + String msg = + "Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" + + deviceId + " and operation id - " + operationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -139,8 +143,9 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { break; } } catch (SQLException e) { - String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + - deviceId + " and operation id - " + operationId; + String msg = + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + + deviceId + " and operation id - " + operationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -155,7 +160,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { Connection conn = null; PreparedStatement stmt = null; DeviceOperation deviceOperation = null; - List deviceOperations=new ArrayList(); + List deviceOperations = new ArrayList(); try { conn = this.getConnection(); String selectDBQuery = @@ -173,8 +178,9 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { break; } } catch (SQLException e) { - String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + - deviceId; + String msg = + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + + deviceId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java index 66c547bdc54..7425fac75e3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java @@ -64,6 +64,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setModel(resultSet.getString(6)); mobileDevice.setVendor(resultSet.getString(7)); + mobileDevice.setLatitude(resultSet.getString(8)); + mobileDevice.setLongitude(resultSet.getString(9)); break; } } catch (SQLException e) { @@ -87,7 +89,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { conn = this.getConnection(); String createDBQuery = "INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," + - "DEVICE_MODEL, VENDOR) VALUES (?, ?, ?, ?, ?, ?, ?)"; + "DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileDevice.getMobileDeviceId()); @@ -97,6 +99,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { stmt.setString(5, mobileDevice.getOsVersion()); stmt.setString(6, mobileDevice.getModel()); stmt.setString(7, mobileDevice.getVendor()); + stmt.setString(8, mobileDevice.getLatitude()); + stmt.setString(8, mobileDevice.getLongitude()); int rows = stmt.executeUpdate(); if(rows>0){ status = true; @@ -122,7 +126,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { conn = this.getConnection(); String updateDBQuery = "UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," + - "DEVICE_MODEL = ?, VENDOR = ? WHERE MOBILE_DEVICE_ID = ?"; + "DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ? WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, mobileDevice.getRegId()); stmt.setString(2, mobileDevice.getImei()); @@ -130,7 +134,9 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { stmt.setString(4, mobileDevice.getOsVersion()); stmt.setString(5, mobileDevice.getModel()); stmt.setString(6, mobileDevice.getVendor()); - stmt.setString(7, mobileDevice.getMobileDeviceId()); + stmt.setString(7, mobileDevice.getLatitude()); + stmt.setString(8, mobileDevice.getLongitude()); + stmt.setString(9, mobileDevice.getMobileDeviceId()); int rows = stmt.executeUpdate(); if(rows>0){ status = true; @@ -192,6 +198,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setModel(resultSet.getString(6)); mobileDevice.setVendor(resultSet.getString(7)); + mobileDevice.setLatitude(resultSet.getString(8)); + mobileDevice.setLongitude(resultSet.getString(9)); mobileDevices.add(mobileDevice); } return mobileDevices; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java index 8a783e52a2e..8c188c3c9e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java @@ -30,6 +30,8 @@ public class MobileDevice implements Serializable { private String osVersion; private String model; private String vendor; + private String latitude; + private String longitude; public String getMobileDeviceId() { return mobileDeviceId; @@ -86,4 +88,20 @@ public class MobileDevice implements Serializable { public void setVendor(String vendor) { this.vendor = vendor; } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } } 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 61f3d94f1f9..e4a69a72b40 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 @@ -15,13 +15,25 @@ */ package org.wso2.carbon.device.mgt.mobile.impl.android; +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.mobile.AbstractMobileOperationManager; +import java.util.List; + public class AndroidMobileOperationManager extends AbstractMobileOperationManager { - @Override - public boolean executeOperation() { - return false; - } + @Override + public boolean addOperation(Operation operation, List devices) throws + OperationManagementException { + return false; + } + + @Override + public List getOperations(DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + return null; + } -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index 99b8ff6a1c7..3a045b7e9df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -41,6 +41,8 @@ public class MobileDeviceManagementUtil { private static final String MOBILE_DEVICE_VENDOR = "vendor"; private static final String MOBILE_DEVICE_OS_VERSION = "osVersion"; private static final String MOBILE_DEVICE_MODEL = "model"; + private static final String MOBILE_DEVICE_LATITUDE = "latitude"; + private static final String MOBILE_DEVICE_LONGITUDE = "longitude"; public static Document convertToDocument(File file) throws DeviceManagementException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -86,6 +88,8 @@ public class MobileDeviceManagementUtil { mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); + mobileDevice.setLatitude(getPropertyValue(device,MOBILE_DEVICE_LATITUDE)); + mobileDevice.setLongitude(getPropertyValue(device,MOBILE_DEVICE_LONGITUDE)); } return mobileDevice; } @@ -101,6 +105,8 @@ public class MobileDeviceManagementUtil { propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel())); propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion())); propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor())); + propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE,mobileDevice.getLatitude())); + propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE,mobileDevice.getLongitude())); device.setProperties(propertyList); device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Operation.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Operation.java new file mode 100644 index 00000000000..f6e580273ca --- /dev/null +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Operation.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2015, 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 cdm.api.android; + +import cdm.api.android.common.AndroidAgentException; +import cdm.api.android.util.AndroidAPIUtils; +import cdm.api.android.util.Message; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import java.util.List; + +/** + * Android Device Operation REST-API implementation. + */ +@Produces({ "application/json", "application/xml" }) +@Consumes({ "application/json", "application/xml" }) +public class Operation { + + private static Log log = LogFactory.getLog(Operation.class); + + @GET + @Path("{id}") + public List getAllOperations( + @PathParam("id") String id) throws + AndroidAgentException { + List operations; + String msg; + DeviceManagementService dmService; + + try { + dmService = AndroidAPIUtils.getDeviceManagementService(); + } catch (DeviceManagementServiceException deviceMgtServiceEx) { + msg = "Device management service error"; + log.error(msg, deviceMgtServiceEx); + throw new AndroidAgentException(msg, deviceMgtServiceEx); + } + + try { + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); + operations = dmService.getOperationManager( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID) + .getOperations(deviceIdentifier); + Response.status(HttpStatus.SC_OK); + return operations; + } catch (DeviceManagementException e) { + msg = "Error occurred while fetching the operation manager for the device type."; + log.error(msg, e); + Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); + throw new AndroidAgentException(msg, e); + } catch (OperationManagementException e) { + msg = "Error occurred while fetching the operation list for the device."; + log.error(msg, e); + Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); + throw new AndroidAgentException(msg, e); + } + } + + @PUT + public Message updateOperation() throws + AndroidAgentException { + String msg; + DeviceManagementService dmService; + Message responseMsg = new Message(); + + try { + dmService = AndroidAPIUtils.getDeviceManagementService(); + + } catch (DeviceManagementServiceException deviceMgtServiceEx) { + msg = "Device management service error"; + log.error(msg, deviceMgtServiceEx); + throw new AndroidAgentException(msg, deviceMgtServiceEx); + } + + try { + boolean result = dmService.getOperationManager("").addOperation(null, null); + if (result) { + Response.status(HttpStatus.SC_OK); + responseMsg.setResponseMessage("Device has already enrolled"); + } else { + Response.status(HttpStatus.SC_NOT_FOUND); + responseMsg.setResponseMessage("Operation not found"); + } + return responseMsg; + } catch (DeviceManagementException e) { + msg = "Error occurred while fetching the operation manager for the device type."; + log.error(msg, e); + Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); + throw new AndroidAgentException(msg, e); + } catch (OperationManagementException e) { + msg = "Error occurred while updating the operation status for the device."; + log.error(msg, e); + Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); + throw new AndroidAgentException(msg, e); + } + } +} \ No newline at end of file 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 caf7cf5382b..fd63ede3b08 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 @@ -32,5 +32,4 @@ public class Test { throw new DeviceManagementException("test ex"); } - -} +} \ No newline at end of file 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 c7717041009..eb38b993ebd 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 @@ -50,8 +50,9 @@ public class AndroidAPIUtils { dmService = (DeviceManagementService) ctx.getOSGiService(DeviceManagementService.class, null); if (dmService == null){ - log.error("device management service not initialized"); - throw new DeviceManagementServiceException("device management service not initialized"); + String msg = "Device management service not initialized"; + log.error(msg); + throw new DeviceManagementServiceException(msg); } PrivilegedCarbonContext.endTenantFlow(); return dmService; 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 1a5ca4fedd8..2154304d9ea 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 @@ -25,10 +25,6 @@ org.apache.cxf.transport.servlet.CXFServlet - - service-list-stylesheet - servicelist.css - 1 diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 8af63134c06..ac4ba28cdc4 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -128,7 +128,8 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/ + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/ wso2cdm-${project.version}/repository/resources/rxts/ @@ -205,8 +206,11 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources - ${project.artifactId}-${project.version}/repository/resources + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources + + ${project.artifactId}-${project.version}/repository/resources + @@ -241,6 +245,12 @@ 755 + + ../rest-api/target/wso2cdm-api.war + wso2cdm-${pom.version}/repository/deployment/server/webapps + + 755 + + + + + + + false + + + CXF,Carbon + diff --git a/product/modules/rest-api/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/rest-api/src/main/webapp/WEB-INF/cxf-servlet.xml new file mode 100644 index 00000000000..a3725edfc40 --- /dev/null +++ b/product/modules/rest-api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/product/modules/rest-api/src/main/webapp/WEB-INF/web.xml b/product/modules/rest-api/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..5a0ce211b39 --- /dev/null +++ b/product/modules/rest-api/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + CDM-API + + JAX-WS/JAX-RS CDM Endpoint + JAX-WS/JAX-RS Servlet + CXFServlet + + org.apache.cxf.transport.servlet.CXFServlet + + 1 + + + CXFServlet + /* + + + 60 + + diff --git a/product/pom.xml b/product/pom.xml index 0d2fdedd5e9..ce49dcadd10 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -34,7 +34,7 @@ WSO2 Connected Device Manager (CDM) - Parent - + modules/rest-api modules/agents/windows/jax-rs modules/agents/android/jax-rs modules/p2-profile-gen From 1d45b494f18b72c2be966ebb2772ac43718c8970 Mon Sep 17 00:00:00 2001 From: DilanUA Date: Fri, 16 Jan 2015 19:02:59 +0530 Subject: [PATCH 04/25] Method signature of updatePolicy method in org.wso2.carbon.policy.mgt.common.Policy.PolicyDAO was updated --- .../java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java | 2 +- .../wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java index 944bf89a9ef..ea489507743 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java @@ -28,7 +28,7 @@ public interface PolicyDAO { int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException; - void updatePolicy(int id) throws PolicyManagerDAOException; + void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException; Policy getPolicy() throws PolicyManagerDAOException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index 41c37e7ce17..1280a7d0c86 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -39,7 +39,6 @@ public class PolicyDAOImpl implements PolicyDAO { @Override public int addPolicy(Policy policy) throws PolicyManagerDAOException { - return 0; } @@ -54,7 +53,7 @@ public class PolicyDAOImpl implements PolicyDAO { } @Override - public void updatePolicy(int id) throws PolicyManagerDAOException { + public void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException { } From 40ee310f42fb5d55ec2d1d9b12eff8a0a7bd1258 Mon Sep 17 00:00:00 2001 From: inosh-perera Date: Fri, 16 Jan 2015 20:14:48 +0530 Subject: [PATCH 05/25] returning auto incremented id --- .../carbon/device/mgt/mobile/dao/OperationDAO.java | 4 ++-- .../device/mgt/mobile/dao/impl/OperationDAOImpl.java | 11 +++++++---- .../client/src/org/wso2/cdm/agent/ServerDetails.java | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java index 8fba815ace8..dbb824b5565 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java @@ -13,10 +13,10 @@ public interface OperationDAO { /** * Add a new operation to plugin operation table. * @param operation Operation object that holds data related to the operation to be inserted. - * @return The status of the operation. If the insert was successful or not. + * @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned. * @throws MobileDeviceManagementDAOException */ - boolean addOperation(Operation operation) throws MobileDeviceManagementDAOException; + int addOperation(Operation operation) throws MobileDeviceManagementDAOException; /** * Update a operation in the operation table. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java index 3e578690527..ffac537cd6c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java @@ -26,9 +26,9 @@ public class OperationDAOImpl implements OperationDAO { } @Override - public boolean addOperation(Operation operation) + public int addOperation(Operation operation) throws MobileDeviceManagementDAOException { - boolean status = false; + int status = -1; Connection conn = null; PreparedStatement stmt = null; try { @@ -36,12 +36,15 @@ public class OperationDAOImpl implements OperationDAO { String createDBQuery = "INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; - stmt = conn.prepareStatement(createDBQuery); + stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" }); stmt.setString(1, operation.getFeatureCode()); stmt.setInt(2, operation.getCreatedDate()); int rows = stmt.executeUpdate(); if (rows > 0) { - status = true; + ResultSet rs = stmt.getGeneratedKeys(); + if (rs != null && rs.next()) { + status = rs.getInt(1); + } } } catch (SQLException e) { String msg = "Error occurred while adding feature code - '" + diff --git a/product/modules/agents/android/client/src/org/wso2/cdm/agent/ServerDetails.java b/product/modules/agents/android/client/src/org/wso2/cdm/agent/ServerDetails.java index 5643b791e95..5c65322b5b5 100644 --- a/product/modules/agents/android/client/src/org/wso2/cdm/agent/ServerDetails.java +++ b/product/modules/agents/android/client/src/org/wso2/cdm/agent/ServerDetails.java @@ -86,6 +86,7 @@ public class ServerDetails extends Activity { getResources().getString(R.string.shared_pref_ip)); regId = Preference.get(context.getApplicationContext().getApplicationContext(), getResources().getString(R.string.shared_pref_regId)); + //heck if we have the IP saved previously. if (ipSaved != null) { serverIP.setText(ipSaved); CommonUtilities.setServerURL(ipSaved); From a31767d1148ca13f0707f51d4336a549e8a8b9e9 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 12:46:14 +0530 Subject: [PATCH 06/25] Adding test cases for device repository handling and device management config initialization --- .../core/config/DeviceManagementConfig.java | 2 +- .../config/DeviceManagementRepository.java | 2 +- .../config/datasource/DataSourceConfig.java | 4 +- .../datasource/JNDILookupDefinition.java | 4 +- .../dao/util/DeviceManagementDAOUtil.java | 5 +- .../mgt/core/DeviceManagementConfigTests.java | 95 +++++++++++++++ .../core/DeviceManagementRepositoryTests.java | 35 ++++++ .../mgt/core/TestDeviceManagerService.java | 90 ++++++++++++++ .../carbon/device/mgt/core/TestUtils.java | 54 +++++++++ .../mgt/core/dao/DeviceMgtDAOTestSuite.java | 110 +++++++++--------- .../malformed-cdm-config-no-ds-config.xml | 26 +++++ .../malformed-cdm-config-no-jndi.config.xml | 26 +++++ .../malformed-cdm-config-no-mgt-repo.xml | 26 +++++ .../schema/DeviceManagementConfigSchema.xsd | 31 +++++ .../src/test/resources/testng.xml | 3 +- 15 files changed, 449 insertions(+), 64 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index 8735df0fe59..678f20d8f02 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -28,7 +28,7 @@ public final class DeviceManagementConfig { private DeviceManagementRepository deviceMgtRepository; - @XmlElement(name = "ManagementRepository", nillable = false) + @XmlElement(name = "ManagementRepository", required = true) public DeviceManagementRepository getDeviceMgtRepository() { return deviceMgtRepository; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java index b84ef0388f9..a6bd91a519d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java @@ -29,7 +29,7 @@ public class DeviceManagementRepository { private DataSourceConfig dataSourceConfig; - @XmlElement(name = "DataSourceConfiguration", nillable = false) + @XmlElement(name = "DataSourceConfiguration", required = false) public DataSourceConfig getDataSourceConfig() { return dataSourceConfig; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java index f8b07312a17..bc7f98e9255 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java @@ -21,14 +21,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** - * Class for holding data source configuration in cdm-config.xml at parsing with JAXB + * Class for holding data source configuration in malformed-cdm-config-no-mgt-repo.xml at parsing with JAXB */ @XmlRootElement(name = "DataSourceConfiguration") public class DataSourceConfig { private JNDILookupDefinition jndiLookupDefintion; - @XmlElement(name = "JndiLookupDefinition", nillable = true) + @XmlElement(name = "JndiLookupDefinition", required = true) public JNDILookupDefinition getJndiLookupDefintion() { return jndiLookupDefintion; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java index 2d0004f52cb..bc85ffb143f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java @@ -27,7 +27,7 @@ public class JNDILookupDefinition { private String jndiName; private List jndiProperties; - @XmlElement(name = "Name", nillable = false) + @XmlElement(name = "Name", required = false) public String getJndiName() { return jndiName; } @@ -36,7 +36,7 @@ public class JNDILookupDefinition { this.jndiName = jndiName; } - @XmlElementWrapper(name = "Environment", nillable = false) + @XmlElementWrapper(name = "Environment", required = false) @XmlElement(name = "Property", nillable = false) public List getJndiProperties() { return jndiProperties; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 20fa5e23548..04f03a765a5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -63,7 +63,8 @@ public final class DeviceManagementDAOUtil { } /** - * Get id of the current tenant + * Get id of the current tenant. + * * @return tenant id * @throws DeviceManagementDAOException if an error is observed when getting tenant id */ @@ -94,7 +95,7 @@ public final class DeviceManagementDAOUtil { return (DataSource) InitialContext.doLookup(dataSourceName); } final InitialContext context = new InitialContext(jndiProperties); - return (DataSource) context.doLookup(dataSourceName); + return (DataSource) context.lookup(dataSourceName); } catch (Exception e) { throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java new file mode 100644 index 00000000000..ee4625c8fc4 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2012, 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.core; + +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.Test; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; + +public class DeviceManagementConfigTests { + + private static final Log log = LogFactory.getLog(DeviceManagementConfigTests.class); + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY = + "./src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG = + "./src/test/resources/config/malformed-cdm-config-no-ds-config.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG = + "./src/test/resources/config/malformed-cdm-config-no-jndi-config.xml"; + private static final String TEST_CONFIG_SCHEMA_LOCATION = + "./src/test/resources/config/schema/DeviceManagementConfigSchema.xsd"; + + private Schema schema; + + @BeforeClass + private void initSchema() { + File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + try { + schema = sf.newSchema(deviceManagementSchemaConfig); + } catch (SAXException e) { + Assert.fail("Invalid schema found", e); + } + } + + @Test() + public void testMandateManagementRepositoryElement() { + File malformedConfig = + new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); + this.validateConfig(malformedConfig); + } + + @Test + public void testMandateDataSourceConfigurationElement() { + File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); + this.validateConfig(malformedConfig); + } + + @Test + public void testMandateJndiLookupDefinitionElement() { + File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); + this.validateConfig(malformedConfig); + } + + private void validateConfig(File malformedConfig) { + try { + JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class); + Unmarshaller um = ctx.createUnmarshaller(); + um.setSchema(this.getSchema()); + um.unmarshal(malformedConfig); + Assert.assertTrue(false); + } catch (JAXBException e) { + e.printStackTrace(); + Assert.assertTrue(true); + } + } + + private Schema getSchema() { + return schema; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java new file mode 100644 index 00000000000..a023665e402 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2012, 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.core; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; + +public class DeviceManagementRepositoryTests { + + @Test + public void testAddDeviceManagementService() { + DeviceManagerService sourceProvider = new TestDeviceManagerService(); + DeviceManagementRepository repository = new DeviceManagementRepository(); + repository.addDeviceManagementProvider(sourceProvider); + + DeviceManagerService targetProvider = + repository.getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); + Assert.assertEquals(targetProvider.getProviderType(), sourceProvider.getProviderType()); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java new file mode 100644 index 00000000000..8d217b5eb4d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2012, 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.core; + +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.OperationManager; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; + +import java.util.List; + +public class TestDeviceManagerService implements DeviceManagerService { + + public static final String DEVICE_TYPE_TEST = "Test"; + + @Override + public String getProviderType() { + return TestDeviceManagerService.DEVICE_TYPE_TEST; + } + + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + return false; + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + return false; + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return false; + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + return false; + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return false; + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { + return false; + } + + @Override + public List getAllDevices() throws DeviceManagementException { + return null; + } + + @Override + public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return null; + } + + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return false; + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { + return false; + } + + @Override + public OperationManager getOperationManager() throws DeviceManagementException { + return null; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java new file mode 100644 index 00000000000..a12560cc33f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2012, 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.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class TestUtils { + + private static final Log log = LogFactory.getLog(TestUtils.class); + + public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing result set", e); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing prepared statement", e); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing database connection", e); + } + } + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java index 98bb0d43721..93d29a77572 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java @@ -25,6 +25,7 @@ import org.testng.annotations.Parameters; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.TestUtils; import org.wso2.carbon.device.mgt.core.common.DBTypes; import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration; import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations; @@ -40,42 +41,33 @@ import javax.xml.bind.Unmarshaller; import java.io.File; import java.sql.*; import java.util.Date; -import java.util.Iterator; public class DeviceMgtDAOTestSuite { - private TestDBConfiguration testDBConfiguration; - private DeviceType devType = new DeviceType(); - private Connection conn = null; - private Statement stmt = null; - @BeforeClass @Parameters("dbType") public void setUpDB(String dbTypeStr) throws Exception { - DBTypes dbType = DBTypes.valueOf(dbTypeStr); - testDBConfiguration = getTestDBConfiguration(dbType); + TestDBConfiguration dbConfig = getTestDBConfiguration(dbType); switch (dbType) { - case H2: - createH2DB(testDBConfiguration); - BasicDataSource testDataSource = new BasicDataSource(); - testDataSource.setDriverClassName(testDBConfiguration.getDriverClass()); - testDataSource.setUrl(testDBConfiguration.getConnectionUrl()); - testDataSource.setUsername(testDBConfiguration.getUserName()); - testDataSource.setPassword(testDBConfiguration.getPwd()); - DeviceManagementDAOFactory.init(testDataSource); - default: + case H2: + createH2DB(dbConfig); + BasicDataSource testDataSource = new BasicDataSource(); + testDataSource.setDriverClassName(dbConfig.getDriverClass()); + testDataSource.setUrl(dbConfig.getConnectionUrl()); + testDataSource.setUsername(dbConfig.getUserName()); + testDataSource.setPassword(dbConfig.getPwd()); + DeviceManagementDAOFactory.init(testDataSource); + default: } } private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException, DeviceManagementException { - File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); - Document doc = null; - testDBConfiguration = null; - TestDBConfigurations testDBConfigurations = null; + Document doc; + TestDBConfigurations dbConfigs; doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); JAXBContext testDBContext = null; @@ -83,92 +75,100 @@ public class DeviceMgtDAOTestSuite { try { testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); + dbConfigs = (TestDBConfigurations) unmarshaller.unmarshal(doc); } catch (JAXBException e) { throw new DeviceManagementDAOException("Error parsing test db configurations", e); } - Iterator itrDBConfigs = testDBConfigurations.getDbTypesList().iterator(); - while (itrDBConfigs.hasNext()) { - testDBConfiguration = itrDBConfigs.next(); - if (testDBConfiguration.getDbType().equals(dbType.toString())) { - break; + for (TestDBConfiguration config : dbConfigs.getDbTypesList()) { + if (config.getDbType().equals(dbType.toString())) { + return config; } } - - return testDBConfiguration; + return null; } private void createH2DB(TestDBConfiguration testDBConf) throws Exception { - - Class.forName(testDBConf.getDriverClass()); - conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); - stmt.close(); - conn.close(); - + Connection conn = null; + Statement stmt = null; + try { + Class.forName(testDBConf.getDriverClass()); + conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); + stmt = conn.createStatement(); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } } @Test public void addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException { - DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - devType.setName("IOS"); + DeviceType deviceType = new DeviceType(); + deviceType.setName("IOS"); - deviceTypeMgtDAO.addDeviceType(devType); + deviceTypeMgtDAO.addDeviceType(deviceType); Long deviceTypeId = null; + Connection conn = null; + Statement stmt = null; try { conn = DeviceManagementDAOFactory.getDataSource().getConnection(); stmt = conn.createStatement(); - ResultSet resultSet = stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'"); + ResultSet resultSet = + stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'"); while (resultSet.next()) { deviceTypeId = resultSet.getLong(1); } - conn.close(); } catch (SQLException sqlEx) { throw new DeviceManagementDAOException("error in fetch device type by name IOS", sqlEx); + } finally { + TestUtils.cleanupResources(conn, stmt, null); } Assert.assertNotNull(deviceTypeId, "Device Type Id is null"); - devType.setId(deviceTypeId); + deviceType.setId(deviceTypeId); } - @Test(dependsOnMethods = { "addDeviceTypeTest" }) + @Test(dependsOnMethods = {"addDeviceTypeTest"}) public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException { - DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO(); Device device = new Device(); - device.setDateOfEnrollment(new Date().getTime()); device.setDateOfLastUpdate(new Date().getTime()); device.setDescription("test description"); device.setStatus(Status.ACTIVE); device.setDeviceIdentificationId("111"); - device.setDeviceType(devType.getId().intValue()); + + DeviceType deviceType = new DeviceType(); + deviceType.setId(Long.parseLong("1")); + + device.setDeviceType(deviceType.getId().intValue()); device.setOwnerShip(OwnerShip.BYOD.toString()); device.setOwnerId("111"); device.setTenantId(-1234); deviceMgtDAO.addDevice(device); Long deviceId = null; + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; try { conn = DeviceManagementDAOFactory.getDataSource().getConnection(); - stmt = conn.createStatement(); - ResultSet resultSet = stmt - .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'"); + stmt = conn.prepareStatement("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'"); + rs = stmt.executeQuery(); - while (resultSet.next()) { - deviceId = resultSet.getLong(1); + while (rs.next()) { + deviceId = rs.getLong(1); } - conn.close(); - } catch (SQLException sqlEx) { - throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx); + } catch (SQLException e) { + throw new DeviceManagementDAOException("error in fetch device by device identification id", e); + } finally { + TestUtils.cleanupResources(conn, stmt, rs); } Assert.assertNotNull(deviceId, "Device Id is null"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml new file mode 100644 index 00000000000..a2a20ccd46a --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml @@ -0,0 +1,26 @@ + + + + + + + + jdbc/DEVICE_MGT_DS + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml new file mode 100644 index 00000000000..5a4e934dc51 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml @@ -0,0 +1,26 @@ + + + + + + + + jdbc/DEVICE_MGT_DS + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml new file mode 100644 index 00000000000..6f2b60631ce --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml @@ -0,0 +1,26 @@ + + + + + + + + jdbc/DEVICE_MGT_DS + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd new file mode 100644 index 00000000000..85cac09f39f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index 1bf0f08f81c..66ecc2ad1e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -21,8 +21,9 @@ - + + \ No newline at end of file From 2b1a5dd6c4c43233809b8c1086687a9b2b50c9ac Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 12:58:14 +0530 Subject: [PATCH 07/25] code cleanup --- .../carbon/device/mgt/core/DeviceManagementConfigTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java index ee4625c8fc4..e6fbb8fa5d0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java @@ -48,9 +48,9 @@ public class DeviceManagementConfigTests { @BeforeClass private void initSchema() { File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); - SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { - schema = sf.newSchema(deviceManagementSchemaConfig); + schema = factory.newSchema(deviceManagementSchemaConfig); } catch (SAXException e) { Assert.fail("Invalid schema found", e); } @@ -83,7 +83,7 @@ public class DeviceManagementConfigTests { um.unmarshal(malformedConfig); Assert.assertTrue(false); } catch (JAXBException e) { - e.printStackTrace(); + log.error("Error while unmarsharlling the device management config", e); Assert.assertTrue(true); } } From daa13e3732dc14f5c4a999429f6a573b3e1a6d29 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 13:25:32 +0530 Subject: [PATCH 08/25] Fixing licensing headers --- .../mgt/core/DeviceManagementConfigTests.java | 2 +- .../mgt/core/DeviceManagementRepositoryTests.java | 2 +- .../config/schema/DeviceManagementConfigSchema.xsd | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java index e6fbb8fa5d0..3770542a555 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index a023665e402..b657a9f03b7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd index 85cac09f39f..31337c4260b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd @@ -1,4 +1,18 @@ + From 233f9e8d1f715006239adaa5172f9c8acf2668fb Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 13:27:23 +0530 Subject: [PATCH 09/25] Renaming DeviceMgtDAOTestSuite.java to DeviceManagementDAOTests.java --- ...DeviceMgtDAOTestSuite.java => DeviceManagementDAOTests.java} | 2 +- .../src/test/resources/testng.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/{DeviceMgtDAOTestSuite.java => DeviceManagementDAOTests.java} (99%) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java similarity index 99% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java index 93d29a77572..f41c60097c6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java @@ -42,7 +42,7 @@ import java.io.File; import java.sql.*; import java.util.Date; -public class DeviceMgtDAOTestSuite { +public class DeviceManagementDAOTests { @BeforeClass @Parameters("dbType") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index 66ecc2ad1e2..2c5fe6fe7de 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -21,7 +21,7 @@ - + From 9e695ecc85ef663145f8643db3bffd95dc8c20e4 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 13:53:26 +0530 Subject: [PATCH 10/25] Adding test cases to test unregistering a device management service from the device management repository --- .../mgt/core/DeviceManagementRepository.java | 15 +++++-- .../device/mgt/core/dao/DeviceTypeDAO.java | 2 + .../mgt/core/dao/impl/DeviceTypeDAOImpl.java | 5 +++ .../mgt/core/util/DeviceManagerUtil.java | 41 +++++++++++++++---- .../core/DeviceManagementRepositoryTests.java | 28 +++++++++++-- 5 files changed, 75 insertions(+), 16 deletions(-) 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 9cf5ed8f3a6..3e7b41aaee6 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 @@ -35,19 +35,26 @@ public class DeviceManagementRepository { public void addDeviceManagementProvider(DeviceManagerService provider) { String deviceType = provider.getProviderType(); - providers.put(deviceType, provider); try { DeviceManagerUtil.registerDeviceType(deviceType); + } catch (DeviceManagementException e) { + log.error("Exception occurred while registering the device type.",e); + } + providers.put(deviceType, provider); + } + + public void removeDeviceManagementProvider(DeviceManagerService provider) { + String deviceType = provider.getProviderType(); + try { + DeviceManagerUtil.unregisterDeviceType(deviceType); } catch (DeviceManagementException e) { log.error("Exception occured while registering the device type.",e); } + providers.remove(deviceType); } public DeviceManagerService getDeviceManagementProvider(String type) { return providers.get(type); } - public Map getProviders() { - return providers; - } } \ No newline at end of file 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 29c08d9ca2d..afeb42eaa3d 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 @@ -37,4 +37,6 @@ public interface DeviceTypeDAO { Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException; + void removeDeviceType(DeviceType deviceType) 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/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 049ed042444..98e6a98c2c2 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 @@ -124,6 +124,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { return deviceTypeId; } + @Override + public void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { + + } + 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/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 ab71bdc5ca6..b973ebd06e2 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 @@ -87,24 +87,47 @@ public final class DeviceManagerUtil { /** * Adds a new device type to the database if it does not exists. * - * @param deviceTypeName device type + * @param deviceType device type * @return status of the operation */ - public static boolean registerDeviceType(String deviceTypeName) throws DeviceManagementException{ - boolean status = false; + public static boolean registerDeviceType(String deviceType) throws DeviceManagementException { + boolean status; try { DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceTypeName); - if(deviceTypeId == null){ - DeviceType deviceType = new DeviceType(); - deviceType.setName(deviceTypeName); - deviceTypeDAO.addDeviceType(deviceType); + Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType); + if (deviceTypeId == null) { + DeviceType dt = new DeviceType(); + dt.setName(deviceType); + deviceTypeDAO.addDeviceType(dt); } status = true; } catch (DeviceManagementDAOException e) { - String msg = "Error occurred while registering the device type " + deviceTypeName; + String msg = "Error occurred while registering the device type " + deviceType; throw new DeviceManagementException(msg, e); } return status; } + + /** + * Unregisters an existing device type from the device management metadata repository. + * + * @param deviceType device type + * @return status of the operation + */ + public static boolean unregisterDeviceType(String deviceType) throws DeviceManagementException { + try { + DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); + Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType); + if (deviceTypeId == null) { + DeviceType dt = new DeviceType(); + dt.setName(deviceType); + deviceTypeDAO.removeDeviceType(dt); + } + return true; + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred while registering the device type " + deviceType; + throw new DeviceManagementException(msg, e); + } + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index b657a9f03b7..bc4707b86de 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -16,20 +16,42 @@ package org.wso2.carbon.device.mgt.core; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; public class DeviceManagementRepositoryTests { + private DeviceManagementRepository repository; + + @BeforeClass + public void initRepository() { + this.repository = new DeviceManagementRepository(); + } + @Test public void testAddDeviceManagementService() { DeviceManagerService sourceProvider = new TestDeviceManagerService(); - DeviceManagementRepository repository = new DeviceManagementRepository(); - repository.addDeviceManagementProvider(sourceProvider); + this.getRepository().addDeviceManagementProvider(sourceProvider); DeviceManagerService targetProvider = - repository.getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); + this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); + Assert.assertEquals(targetProvider.getProviderType(), sourceProvider.getProviderType()); } + @Test(dependsOnMethods = "testAddDeviceManagementService") + public void testRemoveDeviceManagementService() { + DeviceManagerService sourceProvider = new TestDeviceManagerService(); + this.getRepository().removeDeviceManagementProvider(sourceProvider); + + DeviceManagerService targetProvider = + this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); + Assert.assertNull(targetProvider); + } + + private DeviceManagementRepository getRepository() { + return repository; + } + } From 5f242d616577f96f6dd86d6224c84f2bd2e400aa Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 13:57:36 +0530 Subject: [PATCH 11/25] code cleanup --- .../carbon/device/mgt/core/DeviceManagementRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3e7b41aaee6..87ea306cef6 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 @@ -38,7 +38,7 @@ public class DeviceManagementRepository { try { DeviceManagerUtil.registerDeviceType(deviceType); } catch (DeviceManagementException e) { - log.error("Exception occurred while registering the device type.",e); + log.error("Exception occurred while registering the device type.", e); } providers.put(deviceType, provider); } @@ -48,7 +48,7 @@ public class DeviceManagementRepository { try { DeviceManagerUtil.unregisterDeviceType(deviceType); } catch (DeviceManagementException e) { - log.error("Exception occured while registering the device type.",e); + log.error("Exception occurred while registering the device type.", e); } providers.remove(deviceType); } From 29bfc6f09f372edf64529f2a6860b180fc7e5f32 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 14:16:27 +0530 Subject: [PATCH 12/25] More code cleanups --- .../mgt/core/DeviceManagementConstants.java | 27 +++++++++++ .../DeviceManagementServiceComponent.java | 45 ++++++++++++------- .../core/DeviceManagementRepositoryTests.java | 1 + 3 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java new file mode 100644 index 00000000000..8af1724de77 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2015, 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.core; + +public final class DeviceManagementConstants { + + public static final class Common { + private Common() { + throw new AssertionError(); + } + public static final String PROPERTY_SETUP = "setup"; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 68d53be206e..96a591ef755 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -23,6 +23,7 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; import org.wso2.carbon.device.mgt.core.DeviceManager; import org.wso2.carbon.device.mgt.core.DeviceManagerImpl; @@ -51,12 +52,14 @@ import org.wso2.carbon.user.core.service.RealmService; */ public class DeviceManagementServiceComponent { - public static final String SETUP_OPTION = "setup"; private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); protected void activate(ComponentContext componentContext) { try { + if (log.isDebugEnabled()) { + log.debug("Initializing device management core bundle"); + } /* Initializing Device Management Configuration */ DeviceConfigurationManager.getInstance().initConfig(); DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); @@ -68,19 +71,24 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager); /* If -Dsetup option enabled then create device management database schema */ - String setupOption = System.getProperty(SETUP_OPTION); + String setupOption = System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP); if (setupOption != null) { if (log.isDebugEnabled()) { log.debug("-Dsetup is enabled. Device management repository schema initialization is about " + "to begin"); } - setupDeviceManagementSchema(dsConfig); + this.setupDeviceManagementSchema(dsConfig); } + if (log.isDebugEnabled()) { + log.debug("Registering OSGi service DeviceManagementService"); + } BundleContext bundleContext = componentContext.getBundleContext(); bundleContext.registerService(DeviceManagementService.class.getName(), new DeviceManagementService(), null); - + if (log.isDebugEnabled()) { + log.debug("Device management core bundle has been successfully initialized"); + } } catch (Throwable e) { String msg = "Error occurred while initializing device management core bundle"; log.error(msg, e); @@ -91,38 +99,43 @@ public class DeviceManagementServiceComponent { DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config); log.info("Initializing device management repository database schema"); - // catch generic exception. If any error occurs wrap and throw DeviceManagementException try { initializer.createRegistryDatabase(); } catch (Exception e) { throw new DeviceManagementException("Error occurred while initializing Device Management " + "database schema", e); } + if (log.isDebugEnabled()) { + log.debug("Device management metadata repository schema has been successfully initialized"); + } } /** - * Sets Device Manager services - * @param deviceManager An instance of DeviceManagerService + * Sets Device Manager service. + * @param deviceManagerService An instance of DeviceManagerService */ - protected void setDeviceManagerService(DeviceManagerService deviceManager) { + protected void setDeviceManagerService(DeviceManagerService deviceManagerService) { if (log.isDebugEnabled()) { - log.debug("Setting Device Management Service"); + log.debug("Setting Device Management Service Provider : '" + + deviceManagerService.getProviderType() + "'"); } - this.getPluginRepository().addDeviceManagementProvider(deviceManager); + this.getPluginRepository().addDeviceManagementProvider(deviceManagerService); } /** - * Unsets Device Management services - * @param deviceManager An instance of DeviceManagerService + * Unsets Device Management service. + * @param deviceManagerService An Instance of DeviceManagerService */ - protected void unsetDeviceManagerService(DeviceManagerService deviceManager) { + protected void unsetDeviceManagerService(DeviceManagerService deviceManagerService) { if (log.isDebugEnabled()) { - log.debug("Unsetting Device Management Service"); + log.debug("Unsetting Device Management Service Provider : '" + + deviceManagerService.getProviderType() + "'"); } + this.getPluginRepository().removeDeviceManagementProvider(deviceManagerService); } /** - * Sets Realm Service + * Sets Realm Service. * @param realmService An instance of RealmService */ protected void setRealmService(RealmService realmService) { @@ -133,7 +146,7 @@ public class DeviceManagementServiceComponent { } /** - * Unsets Realm Service + * Unsets Realm Service. * @param realmService An instance of RealmService */ protected void unsetRealmService(RealmService realmService) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index bc4707b86de..c6cfc919d45 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -47,6 +47,7 @@ public class DeviceManagementRepositoryTests { DeviceManagerService targetProvider = this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); + Assert.assertNull(targetProvider); } From b7984c18b674b4d362ecf351c5468be036b920db Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 14:34:26 +0530 Subject: [PATCH 13/25] Code cleanup --- .../DeviceManagementServiceComponent.java | 1 + .../mgt/core/DeviceManagementConfigTests.java | 10 +- .../AbstractMobileOperationManager.java | 20 +- .../dao/MobileDeviceManagementDAOFactory.java | 127 +++++----- .../util/MobileDeviceManagementDAOUtil.java | 235 ++++++++---------- .../android/AndroidDeviceManagerService.java | 19 +- .../AndroidMobileOperationManager.java | 20 +- .../impl/ios/IOSDeviceManagerService.java | 1 - 8 files changed, 209 insertions(+), 224 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 96a591ef755..311e59d9616 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -50,6 +50,7 @@ import org.wso2.carbon.user.core.service.RealmService; * bind="setDeviceManagerService" * unbind="unsetDeviceManagerService" */ +@SuppressWarnings("unused") public class DeviceManagementServiceComponent { private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java index 3770542a555..15a6b5ccd95 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java @@ -60,22 +60,22 @@ public class DeviceManagementConfigTests { public void testMandateManagementRepositoryElement() { File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); - this.validateConfig(malformedConfig); + this.validateMalformedConfig(malformedConfig); } @Test public void testMandateDataSourceConfigurationElement() { File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); - this.validateConfig(malformedConfig); + this.validateMalformedConfig(malformedConfig); } @Test public void testMandateJndiLookupDefinitionElement() { File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); - this.validateConfig(malformedConfig); + this.validateMalformedConfig(malformedConfig); } - private void validateConfig(File malformedConfig) { + private void validateMalformedConfig(File malformedConfig) { try { JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class); Unmarshaller um = ctx.createUnmarshaller(); @@ -83,7 +83,7 @@ public class DeviceManagementConfigTests { um.unmarshal(malformedConfig); Assert.assertTrue(false); } catch (JAXBException e) { - log.error("Error while unmarsharlling the device management config", e); + log.error("Error occurred while unmarsharlling device management config", e); Assert.assertTrue(true); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java index 4ddddf6ad0a..d4e7d608c35 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java @@ -21,15 +21,15 @@ import java.util.List; public abstract class AbstractMobileOperationManager implements OperationManager { - @Override - public List getOperations(DeviceIdentifier deviceIdentifier) - throws OperationManagementException { - return null; - } + @Override + public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { + return null; + } + + @Override + public boolean addOperation(Operation operation, + List devices) throws OperationManagementException { + return true; + } - @Override - public boolean addOperation(Operation operation, List devices) throws - OperationManagementException { - return true; - } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index e60e0ec17d4..dc270e5ff6b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.dao; 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.mobile.DataSourceListener; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.impl.*; @@ -31,66 +32,68 @@ import javax.sql.DataSource; */ public class MobileDeviceManagementDAOFactory implements DataSourceListener { - private static DataSource dataSource; - private static MobileDataSourceConfig mobileDataSourceConfig; - private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); - - public MobileDeviceManagementDAOFactory() { - - } - - public void init(){ - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - if(dataSource!=null){ - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - }else{ - MobileDeviceManagementBundleActivator.registerDataSourceListener(this); - } - } - - public static MobileDeviceDAO getMobileDeviceDAO() { - return new MobileDeviceDAOImpl(dataSource); - } - - public static OperationDAO getOperationDAO(){ - return new OperationDAOImpl(dataSource); - } - - public static OperationPropertyDAO geOperationPropertyDAO(){ - return new OperationPropertyDAOImpl(dataSource); - } - - public static DeviceOperationDAO getDeviceOperationDAO(){ - return new DeviceOperationDAOImpl(dataSource); - } - - public static FeatureDAO getFeatureDAO(){ - return new FeatureDAOImpl(dataSource); - } - - public static FeaturePropertyDAO getFeaturePropertyDAO(){ - return new FeaturePropertyDAOImpl(dataSource); - } - - public static MobileDataSourceConfig getMobileDeviceManagementConfig() { - return mobileDataSourceConfig; - } - - public static void setMobileDataSourceConfig( - MobileDataSourceConfig mobileDataSourceConfig) { - MobileDeviceManagementDAOFactory.mobileDataSourceConfig = - mobileDataSourceConfig; - } - - public static DataSource getDataSource() { - return dataSource; - } - - @Override - public void notifyObserver() { - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - if(dataSource!=null){ - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - } - } + private static DataSource dataSource; + private static MobileDataSourceConfig mobileDataSourceConfig; + private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); + + public MobileDeviceManagementDAOFactory() { + + } + + public void init() throws DeviceManagementException { + dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); + if (dataSource != null) { + MobileDeviceManagementDAOUtil.createDataSource(dataSource); + } else { + MobileDeviceManagementBundleActivator.registerDataSourceListener(this); + } + } + + public static MobileDeviceDAO getMobileDeviceDAO() { + return new MobileDeviceDAOImpl(dataSource); + } + + public static OperationDAO getOperationDAO() { + return new OperationDAOImpl(dataSource); + } + + public static OperationPropertyDAO geOperationPropertyDAO() { + return new OperationPropertyDAOImpl(dataSource); + } + + public static DeviceOperationDAO getDeviceOperationDAO() { + return new DeviceOperationDAOImpl(dataSource); + } + + public static FeatureDAO getFeatureDAO() { + return new FeatureDAOImpl(dataSource); + } + + public static FeaturePropertyDAO getFeaturePropertyDAO() { + return new FeaturePropertyDAOImpl(dataSource); + } + + public static MobileDataSourceConfig getMobileDeviceManagementConfig() { + return mobileDataSourceConfig; + } + + public static void setMobileDataSourceConfig( + MobileDataSourceConfig mobileDataSourceConfig) { + MobileDeviceManagementDAOFactory.mobileDataSourceConfig = + mobileDataSourceConfig; + } + + public static DataSource getDataSource() { + return dataSource; + } + + @Override + public void notifyObserver() { + try { + dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); + MobileDeviceManagementDAOUtil.createDataSource(dataSource); + } catch (DeviceManagementException e) { + log.error("Error occurred while resolving mobile device management metadata repository data source", e); + } + } } 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 e8ab4660d27..146a33bcbf2 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 @@ -37,136 +37,119 @@ import java.util.List; */ public class MobileDeviceManagementDAOUtil { - private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); + private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); - /** - * Resolve data source from the data source definition. - * - * @param config Mobile data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(MobileDataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - try { - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource( - jndiConfig.getJndiName(), jndiProperties); - } catch (DeviceManagementException e) { - if (log.isDebugEnabled()) { - log.debug("Error in looking up data source: " + e.getMessage()); - } - log.error(e); - } - } else { - try { - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource( - jndiConfig.getJndiName(), null); - } catch (DeviceManagementException e) { - if (log.isDebugEnabled()) { - log.debug("Error in looking up data source: " + e.getMessage()); - } - log.error(e); - } - } - } - return dataSource; - } + /** + * Resolve data source from the data source definition. + * + * @param config Mobile data source configuration + * @return data source resolved from the data source definition + */ + public static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException { + DataSource dataSource = null; + if (config == null) { + throw new RuntimeException("Device Management Repository data source configuration " + + "is null and thus, is not initialized"); + } + JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + if (jndiConfig != null) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device Management Repository data source using the JNDI " + + "Lookup Definition"); + } + List jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable(); + for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { + jndiProperties.put(prop.getName(), prop.getValue()); + } + dataSource = + MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + } else { + dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); + } + } + return dataSource; + } - public static DataSource lookupDataSource(String dataSourceName, - final Hashtable jndiProperties) - throws DeviceManagementException { - try { - if (jndiProperties == null || jndiProperties.isEmpty()) { - return (DataSource) InitialContext.doLookup(dataSourceName); - } - final InitialContext context = new InitialContext(jndiProperties); - return (DataSource) context.doLookup(dataSourceName); - } catch (Exception e) { - throw new DeviceManagementException( - "Error in looking up data source: " + e.getMessage(), e); - } - } + public static DataSource lookupDataSource(String dataSourceName, + final Hashtable jndiProperties) + throws DeviceManagementException { + try { + if (jndiProperties == null || jndiProperties.isEmpty()) { + return (DataSource) InitialContext.doLookup(dataSourceName); + } + final InitialContext context = new InitialContext(jndiProperties); + return (DataSource) context.lookup(dataSourceName); + } catch (Exception e) { + String msg = "Error in looking up data source: " + e.getMessage(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + } - public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } + public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing result set", e); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing prepared statement", e); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing database connection", e); + } + } + } - /** - * Initializes the creation of mobile device management schema if -Dsetup has provided. - * - * @param dataSource Mobile data source - */ - public static void createDataSource(DataSource dataSource) { - 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(dataSource); - } catch (DeviceManagementException e) { - log.error( - "Exception occurred while initializing mobile device management database schema", - e); - } - } - } + /** + * Initializes the creation of mobile device management schema if -Dsetup has provided. + * + * @param dataSource Mobile data source + */ + public static void createDataSource(DataSource dataSource) { + 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(dataSource); + } catch (DeviceManagementException e) { + log.error("Exception occurred while initializing mobile device management database schema", e); + } + } + } - /** - * Creates the mobile device management schema. - * - * @param dataSource Mobile data source - */ - public static void setupMobileDeviceManagementSchema(DataSource dataSource) throws - DeviceManagementException { - MobileDeviceManagementSchemaInitializer initializer = - new MobileDeviceManagementSchemaInitializer(dataSource); - log.info("Initializing mobile device management repository database schema"); - try { - initializer.createRegistryDatabase(); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while initializing Mobile Device Management " + - "database schema", e); - } - } + /** + * Creates the mobile device management schema. + * + * @param dataSource Mobile data source + */ + public static void setupMobileDeviceManagementSchema(DataSource dataSource) throws + DeviceManagementException { + MobileDeviceManagementSchemaInitializer initializer = + new MobileDeviceManagementSchemaInitializer(dataSource); + log.info("Initializing mobile device management repository database schema"); + try { + initializer.createRegistryDatabase(); + } catch (Exception e) { + throw new DeviceManagementException("Error occurred while initializing Mobile Device Management " + + "database schema", e); + } + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java index b0feb672225..39499134c03 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java @@ -47,7 +47,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService { @Override public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status = false; + boolean status; MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); try { status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice); @@ -62,7 +62,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService { @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status = false; + boolean status; MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); try { status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() @@ -78,7 +78,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService { @Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean status = false; + boolean status; try { status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() .deleteDevice(deviceId.getId()); @@ -122,7 +122,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService { @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device = null; + Device device; try { MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO(). getDevice(deviceId.getId()); @@ -143,14 +143,13 @@ public class AndroidDeviceManagerService implements DeviceManagerService { @Override public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - boolean status = false; + boolean status; MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); try { status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() .updateDevice(mobileDevice); } catch (MobileDeviceManagementDAOException e) { - String msg = - "Error while updating the Android device : " + device.getDeviceIdentifier(); + String msg = "Error while updating the Android device : " + device.getDeviceIdentifier(); log.error(msg, e); throw new DeviceManagementException(msg, e); } @@ -166,9 +165,9 @@ public class AndroidDeviceManagerService implements DeviceManagerService { getAllDevices(); if (mobileDevices != null) { devices = new ArrayList(); - for (int x = 0; x < mobileDevices.size(); x++) { - devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevices.get(x))); - } + for (MobileDevice mobileDevice : mobileDevices) { + devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); + } } } catch (MobileDeviceManagementDAOException e) { String msg = "Error while fetching all Android devices."; 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 e4a69a72b40..11bb592df6d 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 @@ -24,16 +24,16 @@ import java.util.List; public class AndroidMobileOperationManager extends AbstractMobileOperationManager { - @Override - public boolean addOperation(Operation operation, List devices) throws - OperationManagementException { - return false; - } + @Override + public boolean addOperation(Operation operation, List devices) throws + OperationManagementException { + return false; + } - @Override - public List getOperations(DeviceIdentifier deviceIdentifier) - throws OperationManagementException { - return null; - } + @Override + public List getOperations(DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + return null; + } } \ No newline at end of file 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 ebb6038b9d3..1265aea0178 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 @@ -88,5 +88,4 @@ public class IOSDeviceManagerService implements DeviceManagerService { return true; } - } From a4b022edd46625b437f6ced848000b32f00fe1b7 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 17:58:37 +0530 Subject: [PATCH 14/25] Excluding unnecessary transtive dependencies getting downloaded --- .../integration/tests-common/ui-pages/pom.xml | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/product/modules/integration/tests-common/ui-pages/pom.xml b/product/modules/integration/tests-common/ui-pages/pom.xml index a26af8b05ae..2906ce7f404 100644 --- a/product/modules/integration/tests-common/ui-pages/pom.xml +++ b/product/modules/integration/tests-common/ui-pages/pom.xml @@ -35,11 +35,48 @@ WSO2 CDM - Integration Test Ui Pages - org.wso2.carbon org.wso2.carbon.integration.common.admin.client compile + + + org.wso2.carbon + org.wso2.carbon.user.mgt.stub + + + org.wso2.carbon + org.wso2.carbon.logging.view.stub + + + org.wso2.carbon + org.wso2.carbon.ndatasource.stub + + + org.wso2.carbon + org.wso2.carbon.server.admin.stub + + + org.wso2.carbon + org.wso2.carbon.throttle.stub + + + org.wso2.carbon + org.wso2.carbon.tenant.mgt.stub + + + org.wso2.carbon + org.wso2.carbon.application.mgt.stub + + + org.wso2.carbon + org.wso2.carbon.security.mgt.stub + + + org.wso2.carbon + org.wso2.carbon.identity.user.profile.stub + + org.wso2.carbon.automation From c6cdf85c118d0dcfc46b9325f5a1150b1e444d68 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sun, 18 Jan 2015 18:48:02 +0530 Subject: [PATCH 15/25] Fixing start up issues caused by not having proper API management related database schemas available --- product/modules/distribution/pom.xml | 34 +++++++++++++++++++ .../modules/distribution/src/assembly/bin.xml | 22 +++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml index 8fbfc24aa94..c1320559229 100644 --- a/product/modules/distribution/pom.xml +++ b/product/modules/distribution/pom.xml @@ -132,6 +132,40 @@ + + + create-api-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + 3-extract-docs-from-components package diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index ac4ba28cdc4..98e5d19a837 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -187,6 +187,17 @@ + + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt + + wso2cdm-${project.version}/dbscripts/apimgt + + */** + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules @@ -220,6 +231,7 @@ 755 + wso2cdm-${project.version}/lib/endorsed @@ -238,7 +250,6 @@ - ../agents/android/jax-rs/target/cdm-android-api.war wso2cdm-${pom.version}/repository/deployment/server/webapps @@ -429,6 +440,15 @@ 644 + + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2AM_DB.h2.db + + ${pom.artifactId}-${pom.version}/repository/database + WSO2AM_DB.h2.db + 644 + From 9b57455bcc101fb3e2bf7896603adbbab388a6c1 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:43:22 +0530 Subject: [PATCH 16/25] Renaming data source names --- .../src/main/resources/conf/mobile-config.xml | 4 ++-- .../src/main/resources/conf/cdm-config.xml | 2 +- .../conf/datasources/cdm-datasources.xml | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml index bac7bdd5c89..0593de9a935 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml @@ -19,7 +19,7 @@ - jdbc/MOBILE_MGT_DS + jdbc/MobileDM_DS @@ -28,7 +28,7 @@ enrollment - admin + admin enrollment 1.0.0 http://localhost:9763/ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index 87176d63837..49d19d69fdc 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -18,7 +18,7 @@ - jdbc/DEVICE_MGT_DS + jdbc/DM_DS diff --git a/product/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml b/product/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml index 0797b85da8a..7d35742b6fa 100755 --- a/product/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml +++ b/product/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml @@ -5,14 +5,14 @@ - DEVICE_MGT_DS + DM_DS The datasource used for CDM - jdbc/DEVICE_MGT_DS + jdbc/DM_DS - jdbc:h2:repository/database/WSO2DEVICEMGT_DB;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:repository/database/WSO2DM_DB;DB_CLOSE_ON_EXIT=FALSE wso2carbon wso2carbon org.h2.Driver @@ -25,14 +25,14 @@ - MOBILE_MGT_DS + MobileDM_DS The datasource used for CDM Mobile Device Management - jdbc/MOBILE_MGT_DS + jdbc/MobileDM_DS - jdbc:h2:repository/database/WSO2MOBILE_DB;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:repository/database/WSO2MobileDM_DB;DB_CLOSE_ON_EXIT=FALSE wso2carbon wso2carbon org.h2.Driver @@ -45,7 +45,7 @@ - WSO2DEVICE_DB + WSO2AM_DS The datasource used for CDM jdbc/WSO2AM_DB From 3c425ab0ebc07044cd92e27e412f18d9768d9c09 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:46:04 +0530 Subject: [PATCH 17/25] Configuring device management related schemas to be copied to dbscripts directory during the feature installation --- .../src/main/resources/dbscripts/cdm/h2.sql | 26 ++++++++++++++ .../main/resources/dbscripts/cdm/mysql.sql | 35 +++++++++++++++++++ .../src/main/resources/p2.inf | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql new file mode 100644 index 00000000000..783acaa8de7 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE +( + ID INT(11) auto_increment NOT NULL, + NAME VARCHAR(300) NULL DEFAULT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE +( + ID INT auto_increment NOT NULL, + DESCRIPTION TEXT NULL DEFAULT NULL, + NAME VARCHAR(100) NULL DEFAULT NULL, + DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, + OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, + STATUS VARCHAR(15) NULL DEFAULT NULL, + DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, + OWNER VARCHAR(45) NULL DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION +); +-- TO:DO - Remove this INSERT sql statement. +Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql new file mode 100644 index 00000000000..bc04de8732b --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -0,0 +1,35 @@ +-- ----------------------------------------------------- +-- Table `DM_DEVICE_TYPE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` ( + `ID` INT(11) NOT NULL , + `NAME` VARCHAR(300) NULL DEFAULT NULL , + PRIMARY KEY (`ID`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `DM_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE` ( + `ID` VARCHAR(20) NOT NULL , + `DESCRIPTION` TEXT NULL DEFAULT NULL , + `NAME` VARCHAR(100) NULL DEFAULT NULL , + `DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL , + `DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL , + `OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL , + `STATUS` VARCHAR(15) NULL DEFAULT NULL , + `DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL , + `DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL , + `OWNER` VARCHAR(45) NULL DEFAULT NULL , + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (`ID`) , + INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) , + CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2` + FOREIGN KEY (`DEVICE_TYPE_ID` ) + REFERENCES `DM_DEVICE_TYPE` (`ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf index b5222094b32..eabcf094d8d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf @@ -1,3 +1,3 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\ - +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\ From 83c9ae42b58e0d800545ec37aa371ce9346e1bea Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:48:19 +0530 Subject: [PATCH 18/25] Fixing NPE thrown at server startup as a result of APIManagerConfigurationService not being available while the JAX-RS services are registered as APIs --- .../pom.xml | 1 - ...obileDeviceManagementServiceComponent.java | 169 ++++++++++++++++++ 2 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java 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 6e478297219..d51aafc1574 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 @@ -52,7 +52,6 @@ ${project.artifactId} ${project.version} Device Management Mobile Impl Bundle - org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator org.wso2.carbon.device.mgt.mobile.internal org.osgi.framework, 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 new file mode 100644 index 00000000000..650f439d289 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -0,0 +1,169 @@ +/** + * Copyright (c) 2015, 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.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +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.core.ServerStartupHandler; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.DataSourceListener; +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; +import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent" + * immediate="true" + * @scr.reference name="api.manager.config.service" + * interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService" + * cardinality="1..1" + * policy="dynamic" + * bind="setAPIManagerConfigurationService" + * unbind="unsetAPIManagerConfigurationService" + *

+ * Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while + * initializing APIMgtDAOs when trying to register APIs programmatically. APIMgtDAO needs to be proper cleaned up + * to avoid as an ideal fix + */ +public class MobileDeviceManagementServiceComponent { + + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; + + 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(); + + /* Initialize the datasource configuration */ + MobileDeviceConfigurationManager.getInstance().initConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() + .getMobileDeviceManagementConfig(); + MobileDataSourceConfig dsConfig = + config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); + + MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); + + 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"); + } + } + + 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(); + + /* 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 + } + + +} From 07e3dc9644f6eed5c566ef80e9d797e220e2f8e4 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:53:42 +0530 Subject: [PATCH 19/25] Fixing exception getting swallowed in deactivate method of the service component --- .../mobile/internal/MobileDeviceManagementBundleActivator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java index 2d1fb04ad20..4f2b8ff50f0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java @@ -105,7 +105,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B services */ this.removeAPIs(); } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle"); + log.error("Error occurred while de-activating Mobile Device Management bundle", e); } } From b331f708dd5d4c9f7f08d712ca0735fd2cf27bef Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:54:57 +0530 Subject: [PATCH 20/25] Adding default H2 database related file contents to be packed during the phase where the final distribution is created --- product/modules/distribution/pom.xml | 34 +++++++++++++++++++ .../modules/distribution/src/assembly/bin.xml | 18 +++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml index c1320559229..c7ac210bf7c 100644 --- a/product/modules/distribution/pom.xml +++ b/product/modules/distribution/pom.xml @@ -98,6 +98,40 @@ maven-antrun-plugin + + + create-device-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + create-idp-mgt-schema diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 98e5d19a837..0209ac3aa4e 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -208,10 +208,10 @@ - + - src/repository/dbscripts/ - wso2cdm-${project.version}/dbscripts + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm + wso2cdm-${project.version}/dbscripts/cdm */** @@ -443,12 +443,22 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2AM_DB.h2.db + target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2AM_DB.h2.db ${pom.artifactId}-${pom.version}/repository/database WSO2AM_DB.h2.db 644 + + + + target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2DM_DB.h2.db + + ${pom.artifactId}-${pom.version}/repository/database + WSO2DM_DB.h2.db + 644 + + From 043bfb774214aace3e9b18137066fd4c8d5f5c77 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:58:41 +0530 Subject: [PATCH 21/25] Code cleanup --- .../org.wso2.carbon.device.mgt.mobile.impl/pom.xml | 1 + .../internal/MobileDeviceManagementServiceComponent.java | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) 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 d51aafc1574..8bec5af4809 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 @@ -52,6 +52,7 @@ ${project.artifactId} ${project.version} Device Management Mobile Impl Bundle + org.wso2.carbon.device.mgt.mobile.internal org.osgi.framework, 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 650f439d289..cbcdb4dbab9 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,10 +24,8 @@ 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.core.ServerStartupHandler; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; -import org.wso2.carbon.device.mgt.mobile.DataSourceListener; 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; @@ -38,7 +36,6 @@ import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil; -import java.util.ArrayList; import java.util.List; /** @@ -52,7 +49,7 @@ import java.util.List; * unbind="unsetAPIManagerConfigurationService" *

* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while - * initializing APIMgtDAOs when trying to register APIs programmatically. APIMgtDAO needs to be proper cleaned up + * initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up * to avoid as an ideal fix */ public class MobileDeviceManagementServiceComponent { @@ -165,5 +162,4 @@ public class MobileDeviceManagementServiceComponent { //do nothing } - } From 74b8a32be354f7fd654f124f09d441b3a61b0867 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 01:04:35 +0530 Subject: [PATCH 22/25] Fixing exception getting swallowed in activate method of the service component --- .../mobile/internal/MobileDeviceManagementServiceComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cbcdb4dbab9..195929bb2f9 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 @@ -95,7 +95,7 @@ public class MobileDeviceManagementServiceComponent { 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"); + log.error("Error occurred while activating Mobile Device Management Service Component", e); } } From 207a51a2692d8c5c0df604f542bc0a5ee7bbf2a6 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 19 Jan 2015 09:20:53 +0530 Subject: [PATCH 23/25] Added license headers with changes --- .../AbstractMobileOperationManager.java | 21 +++++----- .../mgt/mobile/dao/DeviceOperationDAO.java | 16 +++++++ .../device/mgt/mobile/dao/FeatureDAO.java | 16 +++++++ .../mgt/mobile/dao/FeaturePropertyDAO.java | 16 +++++++ .../device/mgt/mobile/dao/OperationDAO.java | 16 +++++++ .../mgt/mobile/dao/OperationPropertyDAO.java | 16 +++++++ .../dao/impl/DeviceOperationDAOImpl.java | 26 +++++++++--- .../mgt/mobile/dao/impl/FeatureDAOImpl.java | 16 +++++++ .../dao/impl/FeaturePropertyDAOImpl.java | 16 +++++++ .../mobile/dao/impl/MobileDeviceDAOImpl.java | 2 +- .../mgt/mobile/dao/impl/OperationDAOImpl.java | 20 ++++++++- .../dao/impl/OperationPropertyDAOImpl.java | 16 +++++++ .../mgt/mobile/dto/DeviceOperation.java | 33 +++++++++++---- .../carbon/device/mgt/mobile/dto/Feature.java | 25 +++++++++-- .../mgt/mobile/dto/FeatureProperty.java | 25 +++++++++-- .../device/mgt/mobile/dto/Operation.java | 42 +++++++++++++++---- .../mgt/mobile/dto/OperationProperty.java | 33 +++++++++++---- .../AndroidMobileOperationManager.java | 24 ++++++++++- .../util/MobileDeviceManagementUtil.java | 17 +++++++- 19 files changed, 343 insertions(+), 53 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java index 4ddddf6ad0a..9bdb8c42fd6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java @@ -1,18 +1,19 @@ -/** - * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * Copyright (c) 2014 - 2015, 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 + * 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. + * 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; import org.wso2.carbon.device.mgt.common.*; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/DeviceOperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/DeviceOperationDAO.java index 4273e13b5ac..b0f24f7240a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/DeviceOperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/DeviceOperationDAO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao; import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java index 37ac430c83d..0997dd03217 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao; import org.wso2.carbon.device.mgt.mobile.dto.Feature; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java index e0d60ddc167..7a023be3281 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao; import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java index dbb824b5565..dc00711688f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationDAO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao; import org.wso2.carbon.device.mgt.mobile.dto.Operation; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationPropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationPropertyDAO.java index de012babb8f..d4d0c451ddf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationPropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/OperationPropertyDAO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao; import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java index 8f6b6a80581..0baf28f2f08 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/DeviceOperationDAOImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao.impl; import org.apache.commons.logging.Log; @@ -40,9 +56,9 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, deviceOperation.getDeviceId()); - stmt.setInt(2, deviceOperation.getOperationId()); - stmt.setInt(3, deviceOperation.getSentDate()); - stmt.setInt(4, deviceOperation.getReceivedDate()); + stmt.setLong(2, deviceOperation.getOperationId()); + stmt.setLong(3, deviceOperation.getSentDate()); + stmt.setLong(4, deviceOperation.getReceivedDate()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -71,8 +87,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO { String updateDBQuery = "UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setInt(1, deviceOperation.getSentDate()); - stmt.setInt(2, deviceOperation.getReceivedDate()); + stmt.setLong(1, deviceOperation.getSentDate()); + stmt.setLong(2, deviceOperation.getReceivedDate()); stmt.setString(3, deviceOperation.getDeviceId()); stmt.setInt(4, deviceOperation.getOperationId()); int rows = stmt.executeUpdate(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java index ba82b9d5b6f..bd30662a4d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao.impl; import org.apache.commons.logging.Log; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java index 64473f0bff7..e81b25208db 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao.impl; import org.apache.commons.logging.Log; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java index 7425fac75e3..ee81a893f20 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java @@ -222,4 +222,4 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { throw new MobileDeviceManagementDAOException(msg, e); } } -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java index ffac537cd6c..913719bcaf7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationDAOImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao.impl; import org.apache.commons.logging.Log; @@ -38,7 +54,7 @@ public class OperationDAOImpl implements OperationDAO { stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" }); stmt.setString(1, operation.getFeatureCode()); - stmt.setInt(2, operation.getCreatedDate()); + stmt.setLong(2, operation.getCreatedDate()); int rows = stmt.executeUpdate(); if (rows > 0) { ResultSet rs = stmt.getGeneratedKeys(); @@ -69,7 +85,7 @@ public class OperationDAOImpl implements OperationDAO { "UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, operation.getFeatureCode()); - stmt.setInt(2, operation.getCreatedDate()); + stmt.setLong(2, operation.getCreatedDate()); stmt.setInt(3, operation.getOperationId()); int rows = stmt.executeUpdate(); if (rows > 0) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationPropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationPropertyDAOImpl.java index 42ed4604b85..6f856a41dc3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationPropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/OperationPropertyDAOImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dao.impl; import org.apache.commons.logging.Log; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/DeviceOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/DeviceOperation.java index 84e55037423..a4f85723d57 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/DeviceOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/DeviceOperation.java @@ -1,13 +1,30 @@ +/* + * Copyright (c) 2015, 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.dto; /** * DTO of Operations. */ public class DeviceOperation { - String deviceId; - int operationId; - int sentDate; - int receivedDate; + + private String deviceId; + private int operationId; + private long sentDate; + private long receivedDate; public String getDeviceId() { return deviceId; @@ -25,19 +42,19 @@ public class DeviceOperation { this.operationId = operationId; } - public int getSentDate() { + public long getSentDate() { return sentDate; } - public void setSentDate(int sentDate) { + public void setSentDate(long sentDate) { this.sentDate = sentDate; } - public int getReceivedDate() { + public long getReceivedDate() { return receivedDate; } - public void setReceivedDate(int receivedDate) { + public void setReceivedDate(long receivedDate) { this.receivedDate = receivedDate; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java index 0c10e8eab95..2fb173b568b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015, 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.dto; import java.io.Serializable; @@ -6,10 +22,11 @@ import java.io.Serializable; * DTO of features. */ public class Feature implements Serializable { - int id; - String code; - String name; - String description; + + private int id; + private String code; + private String name; + private String description; public int getId() { return id; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java index 4f72e878e95..cdbdad4f43b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java @@ -1,12 +1,29 @@ +/* + * Copyright (c) 2014 - 2015, 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.dto; /** * DTO of feature property. Represents a property of a feature. */ public class FeatureProperty { - int propertyId; - String property; - String featureID; + + private int propertyId; + private String property; + private String featureID; public String getFeatureID() { return featureID; @@ -32,4 +49,4 @@ public class FeatureProperty { this.property = property; } -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Operation.java index 855ba6c6062..ce10e703ade 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Operation.java @@ -1,12 +1,32 @@ +/* + * Copyright (c) 2014 - 2015, 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.dto; +import java.util.List; + /** * DTO of operation. */ public class Operation { - int operationId; - String featureCode; - int createdDate; + + private int operationId; + private String featureCode; + private long createdDate; + private List properties; public int getOperationId() { return operationId; @@ -16,6 +36,14 @@ public class Operation { this.operationId = operationId; } + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + public String getFeatureCode() { return featureCode; } @@ -24,13 +52,11 @@ public class Operation { this.featureCode = featureCode; } - public int getCreatedDate() { + public long getCreatedDate() { return createdDate; } - public void setCreatedDate(int createdDate) { + public void setCreatedDate(long createdDate) { this.createdDate = createdDate; } - - -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/OperationProperty.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/OperationProperty.java index 2800807979b..f47a23bd895 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/OperationProperty.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/OperationProperty.java @@ -1,13 +1,30 @@ +/* + * Copyright (c) 2014 - 2015, 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.dto; /** * DTO of operation property. */ public class OperationProperty { - int operationPropertyId; - int getOperationId; - int propertyId; - String value; + + private int operationPropertyId; + private int operationId; + private int propertyId; + private String value; public String getValue() { return value; @@ -26,11 +43,11 @@ public class OperationProperty { } public int getOperationId() { - return getOperationId; + return operationId; } - public void setOperationId(int getOperationId) { - this.getOperationId = getOperationId; + public void setOperationId(int operationId) { + this.operationId = operationId; } public int getPropertyId() { @@ -41,4 +58,4 @@ public class OperationProperty { this.propertyId = propertyId; } -} +} \ No newline at end of file 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 e4a69a72b40..50c359068fe 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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. @@ -15,18 +15,40 @@ */ 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.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Operation; import org.wso2.carbon.device.mgt.common.OperationManagementException; 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.DeviceOperation; +import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; import java.util.List; public class AndroidMobileOperationManager extends AbstractMobileOperationManager { + private static final Log log = LogFactory.getLog(AndroidMobileOperationManager.class); + @Override public boolean addOperation(Operation operation, List devices) throws OperationManagementException { + try { + MobileDeviceManagementDAOFactory.getOperationDAO().addOperation( + new org.wso2.carbon.device.mgt.mobile.dto.Operation()); + MobileDeviceManagementDAOFactory.geOperationPropertyDAO() + .addOperationProperty(new OperationProperty()); + MobileDeviceManagementDAOFactory.getDeviceOperationDAO() + .addDeviceOperation(new DeviceOperation()); + } catch (MobileDeviceManagementDAOException e) { + String msg = "Error while updating the enrollment of the Android device : " + + devices.get(0).getId(); + log.error(msg, e); + throw new OperationManagementException(msg, e); + } return false; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index 3a045b7e9df..6734efcc242 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -22,12 +22,13 @@ import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.dto.Operation; +import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * Provides utility methods required by the mobile device management bundle. @@ -112,4 +113,16 @@ public class MobileDeviceManagementUtil { } return device; } + + public static Operation convertToOperation(org.wso2.carbon.device.mgt.common.Operation operation){ + Operation mobileOperation = new Operation(); + List properties = new LinkedList(); + mobileOperation.setFeatureCode(operation.getCode()); + mobileOperation.setCreatedDate(new Date().getTime()); + Properties operationProperties = operation.getProperties(); + for(String key : operationProperties.stringPropertyNames()) { + String value = operationProperties.getProperty(key); + } + return mobileOperation; + } } From cbe13288d081b304edb9da7d5c6ac7e22f2546aa Mon Sep 17 00:00:00 2001 From: DilanUA Date: Mon, 19 Jan 2015 15:08:42 +0530 Subject: [PATCH 24/25] [1] Copyright notices of policy-mgt component classes were updated. [2] Mispelled getJndiLookupDefinition() of org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig was updated. --- .../carbon/policy/evaluator/PDPException.java | 32 ++++++++--------- .../policy/evaluator/spi/PDPService.java | 33 +++++++++-------- .../carbon/policy/mgt/common/Feature.java | 32 ++++++++--------- .../common/FeatureManagementException.java | 32 ++++++++--------- .../mgt/common/FeatureManagerService.java | 35 +++++++++--------- .../wso2/carbon/policy/mgt/common/Policy.java | 32 ++++++++--------- .../mgt/common/PolicyManagementException.java | 32 ++++++++--------- .../mgt/common/PolicyManagerService.java | 36 +++++++++---------- .../mgt/common/impl/PolicyManagement.java | 32 ++++++++--------- .../config/PolicyConfigurationManager.java | 5 ++- .../core/config/PolicyManagementConfig.java | 6 +++- .../config/PolicyManagementRepository.java | 6 +++- .../config/datasource/DataSourceConfig.java | 16 +++++---- .../datasource/JNDILookupDefinition.java | 5 ++- .../carbon/policy/mgt/core/dao/PolicyDAO.java | 32 ++++++++--------- .../core/dao/PolicyManagementDAOFactory.java | 34 +++++++++--------- .../core/dao/PolicyManagerDAOException.java | 32 ++++++++--------- .../mgt/core/dao/impl/PolicyDAOImpl.java | 32 ++++++++--------- .../dao/util/PolicyManagementDAOUtil.java | 32 ++++++++--------- .../internal/PolicyManagementDataHolder.java | 32 ++++++++--------- .../PolicyManagementServiceComponent.java | 25 +++++++------ .../core/util/PolicyManagementConstants.java | 33 +++++++++-------- .../mgt/core/util/PolicyManagerUtil.java | 34 +++++++++--------- 23 files changed, 315 insertions(+), 305 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java index c650e371a43..4d09570bd6d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 2005-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 -* -* 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. -*/ + * 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 + * + * 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.policy.evaluator; diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java index 9c3f33da346..486143d5f83 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java @@ -1,25 +1,24 @@ /* -* 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 -* -* 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. -*/ + * 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 + * + * 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.policy.evaluator.spi; public interface PDPService { - } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java index 9183c810be9..525b8c103cf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 2005-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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java index cd87922b6e8..bc9328a120c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java @@ -1,20 +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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java index 3737303e5a4..0b329b196b0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java @@ -1,27 +1,24 @@ /* -* 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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.FeatureManagementException; - import java.util.List; public interface FeatureManagerService { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index a52bd487e62..3caf70ee6a0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -1,20 +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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java index 524f669d6a1..976ddccd31a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 2005-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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java index 0e9605b3480..56e5b890155 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java @@ -1,27 +1,23 @@ /* -* 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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.common; -import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; - /** * This interface defines the policy management which should be implemented by the plugins */ diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java index c528dd504ee..28a810008af 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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. + */ package org.wso2.carbon.policy.mgt.common.impl; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java index 957bf952846..391467056db 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java @@ -1,10 +1,13 @@ /* * 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 - * http://www.apache.org/licenses/LICENSE-2. + * + * 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 diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java index 3f85d0285d0..3ea56ada8fe 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java @@ -1,10 +1,13 @@ /* * 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 - * http://www.apache.org/licenses/LICENSE-2. + * + * 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 @@ -12,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.wso2.carbon.policy.mgt.core.config; import javax.xml.bind.annotation.XmlElement; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java index e7d86235157..a794e0eb039 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java @@ -1,10 +1,13 @@ /* * 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 - * http://www.apache.org/licenses/LICENSE-2. + * + * 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 @@ -12,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.wso2.carbon.policy.mgt.core.config; import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java index d451b0442de..153e6bc23de 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java @@ -1,10 +1,13 @@ /* * 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 - * http://www.apache.org/licenses/LICENSE-2. + * + * 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 @@ -24,15 +27,14 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "DataSourceConfiguration") public class DataSourceConfig { - private JNDILookupDefinition jndiLookupDefintion; + private JNDILookupDefinition jndiLookupDefinition; @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefintion() { - return jndiLookupDefintion; + public JNDILookupDefinition getJndiLookupDefinition() { + return jndiLookupDefinition; } - public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) { - this.jndiLookupDefintion = jndiLookupDefintion; + public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { + this.jndiLookupDefinition = jndiLookupDefinition; } - } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java index 32fa2de644e..392f74c8b53 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java @@ -1,10 +1,13 @@ /* * 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 - * http://www.apache.org/licenses/LICENSE-2. + * + * 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 diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java index ea489507743..4eea93533ac 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.dao; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java index f1d9cf56cab..ab889b02b57 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.dao; @@ -55,7 +55,7 @@ public class PolicyManagementDAOFactory { throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized"); } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); if (jndiConfig != null) { if (log.isDebugEnabled()) { log.debug("Initializing Device Management Repository data source using the JNDI " + diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java index 4913f6752cd..7a827057a7a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.dao; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index 1280a7d0c86..cc5bda07df4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.dao.impl; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java index 75363231ed8..5157c4e2aa6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.dao.util; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java index afbf02eca0f..6bca58de050 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 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. -*/ + * 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 + * + * 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.policy.mgt.core.internal; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java index b12455ab763..9877da75412 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java @@ -1,18 +1,21 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 org.wso2.carbon.policy.mgt.core.internal; import org.apache.commons.logging.Log; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java index 22883e5e639..ae646b953b6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java @@ -1,24 +1,23 @@ /* -* 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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.core.util; public final class PolicyManagementConstants { - public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml"; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index 52760126873..95886e7f32f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -1,20 +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 -* -* 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. -*/ + * 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 + * + * 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.policy.mgt.core.util; @@ -61,7 +61,7 @@ public class PolicyManagerUtil { throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized"); } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); if (jndiConfig != null) { if (log.isDebugEnabled()) { log.debug("Initializing Device Management Repository data source using the JNDI " + From e093d53b43cc99a6914eacd9a87dfd86d2cb56c4 Mon Sep 17 00:00:00 2001 From: DilanUA Date: Mon, 19 Jan 2015 15:46:33 +0530 Subject: [PATCH 25/25] Copyright notices of policy-mgt classes were updated. --- .../org.wso2.carbon.policy.evalutor/pom.xml | 32 +++++++++---------- .../carbon/policy/evaluator/PDPException.java | 18 +++++------ .../policy/evaluator/spi/PDPService.java | 19 +++++------ .../org.wso2.carbon.policy.mgt.common/pom.xml | 32 +++++++++---------- .../carbon/policy/mgt/common/Feature.java | 18 +++++------ .../common/FeatureManagementException.java | 18 +++++------ .../mgt/common/FeatureManagerService.java | 19 +++++------ .../wso2/carbon/policy/mgt/common/Policy.java | 18 +++++------ .../mgt/common/PolicyManagementException.java | 18 +++++------ .../mgt/common/PolicyManagerService.java | 18 +++++------ .../mgt/common/impl/PolicyManagement.java | 18 +++++------ .../mgt/common/PolicyManagementTestCase.java | 31 ++++++++---------- .../mgt/common/utils/PolicyCreator.java | 30 ++++++++--------- .../org.wso2.carbon.policy.mgt.core/pom.xml | 32 +++++++++---------- .../config/PolicyConfigurationManager.java | 18 +++++------ .../core/config/PolicyManagementConfig.java | 18 +++++------ .../config/PolicyManagementRepository.java | 18 +++++------ .../config/datasource/DataSourceConfig.java | 18 +++++------ .../datasource/JNDILookupDefinition.java | 18 +++++------ .../carbon/policy/mgt/core/dao/PolicyDAO.java | 18 +++++------ .../core/dao/PolicyManagementDAOFactory.java | 18 +++++------ .../core/dao/PolicyManagerDAOException.java | 18 +++++------ .../mgt/core/dao/impl/PolicyDAOImpl.java | 18 +++++------ .../dao/util/PolicyManagementDAOUtil.java | 18 +++++------ .../internal/PolicyManagementDataHolder.java | 18 +++++------ .../PolicyManagementServiceComponent.java | 18 +++++------ .../core/util/PolicyManagementConstants.java | 18 +++++------ .../mgt/core/util/PolicyManagerUtil.java | 18 +++++------ components/policy-mgt/pom.xml | 31 +++++++++--------- .../pom.xml | 29 +++++++++-------- features/policy-mgt/pom.xml | 31 +++++++++--------- 31 files changed, 305 insertions(+), 359 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml index 790e2952733..ebb177d66c3 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml @@ -1,21 +1,21 @@ + + ~ 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. + --> + diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java index 4d09570bd6d..88c20944631 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.evaluator; diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java index 486143d5f83..3ab1e4bdc7f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java @@ -1,24 +1,21 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.evaluator.spi; - public interface PDPService { } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 76d141791d9..f6384a31b6d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -1,21 +1,21 @@ + + ~ 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. + --> + diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java index 525b8c103cf..383dc59c789 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java index bc9328a120c..a870eba7182 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java index 0b329b196b0..405625697e0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java @@ -1,22 +1,19 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index 3caf70ee6a0..845f908e4a1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java index 976ddccd31a..a5d45dc269f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java index 56e5b890155..db21219687a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java index 28a810008af..8fd5e24d24b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.common.impl; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java index 5e28b2154c2..456614089e7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java @@ -1,20 +1,18 @@ /* -* Copyright (c) 2005-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 -* -* 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. -*/ + * Copyright (c) 2015, 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.wos2.carbon.policy.mgt.common; @@ -36,7 +34,6 @@ public class PolicyManagementTestCase { private PolicyManagement policyManagement = new PolicyManagement(); - @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device") public void testAddPolicy() throws FeatureManagementException, PolicyManagementException { Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java index 4807334e969..5141919e019 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java @@ -1,20 +1,18 @@ /* -* Copyright (c) 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. -*/ + * Copyright (c) 2015, 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.wos2.carbon.policy.mgt.common.utils; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 5b9b7deb789..1918eebf9bb 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -1,21 +1,21 @@ + + ~ 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. + --> + diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java index 391467056db..1dd6558e1a7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.config; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java index 3ea56ada8fe..d73f37f0c0c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.config; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java index a794e0eb039..9b7b8aa7671 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.config; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java index 153e6bc23de..b15fd65c6d1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.config.datasource; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java index 392f74c8b53..40fdc5d17ba 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.config.datasource; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java index 4eea93533ac..09c7c9ee997 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.dao; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java index ab889b02b57..f91dd4ffeb6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.dao; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java index 7a827057a7a..89a85870a78 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.dao; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index cc5bda07df4..6d94f02e8af 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.dao.impl; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java index 5157c4e2aa6..b8e978491a7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.dao.util; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java index 6bca58de050..fc0770f5d00 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.internal; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java index 9877da75412..8fadd5e858e 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.internal; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java index ae646b953b6..4c387fc4b92 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.util; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index 95886e7f32f..558e53c9290 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -1,19 +1,17 @@ /* * 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. + * 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 + * 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 org.wso2.carbon.policy.mgt.core.util; diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 44645e77f1b..05e9bd4613b 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -1,21 +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 + ~ + ~ 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. + --> + + ~ 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. + --> + + ~ 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. + -->