From 63721cb79dc1301835feac2188e22ddad27fc082 Mon Sep 17 00:00:00 2001 From: milanperera Date: Tue, 28 Jul 2015 15:34:38 +0530 Subject: [PATCH 1/5] Refactored --- .../DynamicClientRegistrationUtil.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java index 4a64d6368d..0cdb0a097f 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java @@ -43,30 +43,26 @@ import java.util.Arrays; public class DynamicClientRegistrationUtil { + private static final String TOKEN_SCOPE = "tokenScope"; private static final Log log = LogFactory.getLog(DynamicClientRegistrationUtil.class); public static OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); - //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. - String userId = profile.getOwner(); String applicationName = profile.getClientName(); - String grantType = profile.getGrantType(); if (log.isDebugEnabled()) { log.debug("Trying to create OAuth application: '" + applicationName + "'"); } - String callBackURL = profile.getCallbackUrl(); - String tokenScope = profile.getTokenScope(); String tokenScopes[] = new String[1]; tokenScopes[0] = tokenScope; - oAuthApplicationInfo.addParameter("tokenScope", Arrays.toString(tokenScopes)); + oAuthApplicationInfo.addParameter(TOKEN_SCOPE, Arrays.toString(tokenScopes)); OAuthApplicationInfo info; try { - info = createOAuthApplication(userId, applicationName, callBackURL, grantType); + info = createOAuthApplication(profile); } catch (Exception e) { throw new APIManagementException("Can not create OAuth application : " + applicationName, e); } @@ -98,8 +94,15 @@ public class DynamicClientRegistrationUtil { } public static OAuthApplicationInfo createOAuthApplication( - String userId, String applicationName, String callbackUrl, String grantType) + RegistrationProfile profile) throws APIManagementException, IdentityException { + + //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. + String userId = profile.getOwner(); + String applicationName = profile.getClientName(); + String grantType = profile.getGrantType(); + String callbackUrl = profile.getCallbackUrl(); + if (userId == null || userId.isEmpty()) { return null; } From 53302070e6b96a31e7723ebbd62a45298beb0e62 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 30 Jul 2015 15:16:12 +0530 Subject: [PATCH 2/5] Code cleanup, adding file system based license manager, fixing some design issue in CommandOperationDAOImpl --- .../core/operation/mgt/dao/OperationDAO.java | 1 + .../mgt/dao/impl/CommandOperationDAOImpl.java | 37 ++++++------ .../mgt/dao/impl/ConfigOperationDAOImpl.java | 9 ++- .../mgt/dao/impl/OperationDAOImpl.java | 16 +++--- .../pom.xml | 8 ++- .../file/FileSystemBasedLicenseManager.java | 57 +++++++++++++++++++ .../GenericArtifactManagerFactory.java | 2 +- .../RegistryBasedLicenseManager.java | 3 +- 8 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/file/FileSystemBasedLicenseManager.java rename components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/{ => registry}/GenericArtifactManagerFactory.java (97%) rename components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/{ => registry}/RegistryBasedLicenseManager.java (98%) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java index 5c6751776b..9c0f998153 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -46,4 +46,5 @@ public interface OperationDAO { void addOperationResponse(int enrolmentId, int operationId, Object operationResponse) throws OperationManagementDAOException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java index ccc5ce811f..bc499d8a3f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java @@ -58,7 +58,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { try { Connection connection = OperationManagementDAOFactory.getConnection(); stmt = connection.prepareStatement( - "UPDATE DM_COMMAND_OPERATION O SET O.ENABLED=? WHERE O.OPERATION_ID=?"); + "UPDATE DM_COMMAND_OPERATION O SET O.ENABLED = ? WHERE O.OPERATION_ID = ?"); stmt.setBoolean(1, operation.isEnabled()); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); @@ -72,9 +72,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { @Override public void deleteOperation(int id) throws OperationManagementDAOException { - super.deleteOperation(id); PreparedStatement stmt = null; try { + super.deleteOperation(id); + Connection connection = OperationManagementDAOFactory.getConnection(); stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID = ?"); stmt.setInt(1, id); @@ -93,7 +94,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { CommandOperation commandOperation = null; try { Connection conn = OperationManagementDAOFactory.getConnection(); - String sql = "SELECT OPERATION_ID, ENABLED FROM DM_COMMAND_OPERATION WHERE OPERATION_ID=?"; + String sql = "SELECT OPERATION_ID, ENABLED FROM DM_COMMAND_OPERATION WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, id); rs = stmt.executeQuery(); @@ -113,21 +114,19 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { } @Override - public List getOperationsByDeviceAndStatus(int enrolmentId, - Operation.Status status) throws OperationManagementDAOException { + public List getOperationsByDeviceAndStatus( + int enrolmentId, Operation.Status status) throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; - Operation operation; - - List operations = new ArrayList<>(); - List commandOperations = new ArrayList<>(); CommandOperation commandOperation; + List commandOperations = new ArrayList<>(); try { Connection conn = OperationManagementDAOFactory.getConnection(); - String sql = "SELECT co.OPERATION_ID,ENABLED FROM DM_COMMAND_OPERATION co " + - "INNER JOIN (SELECT * FROM DM_ENROLMENT_OPERATION_MAPPING WHERE ENROLMENT_ID=? " + - "AND STATUS=? ) dm ON dm.OPERATION_ID = co.OPERATION_ID"; + String sql = "SELECT o.ID, co1.ENABLED, co1.STATUS, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE FROM (SELECT co.OPERATION_ID, co.ENABLED FROM DM_COMMAND_OPERATION co " + + "INNER JOIN (SELECT ENROLMENT_ID, OPERATION_ID, STATUS FROM DM_ENROLMENT_OPERATION_MAPPING WHERE ENROLMENT_ID = ? " + + "AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID) co1 INNER JOIN OPERATION o ON co1.OPERATION_ID = o.ID"; + stmt = conn.prepareStatement(sql); stmt.setInt(1, enrolmentId); stmt.setString(2, status.toString()); @@ -137,15 +136,13 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { commandOperation = new CommandOperation(); commandOperation.setEnabled(rs.getInt("ENABLED") != 0); commandOperation.setId(rs.getInt("OPERATION_ID")); + commandOperation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + commandOperation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); + commandOperation.setCreatedTimeStamp(rs.getString("CREATED_TIMESTAMP")); + commandOperation.setReceivedTimeStamp(rs.getString("RECEIVED_TIMESTAMP")); + commandOperation.setCode(rs.getString("OPERATION_CODE")); commandOperations.add(commandOperation); } - - for(CommandOperation cmOperation : commandOperations){ - operation = super.getOperation(cmOperation.getId()); - operation.setEnabled(cmOperation.isEnabled()); - operation.setStatus(status); - operations.add(operation); - } } catch (SQLException e) { throw new OperationManagementDAOException("SQL error occurred while retrieving the operation available " + "for the device'" + enrolmentId + "' with status '" + status.toString(), e); @@ -153,7 +150,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { OperationManagementDAOUtil.cleanupResources(stmt, rs); OperationManagementDAOFactory.closeConnection(); } - return operations; + return commandOperations; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java index c05e80fce6..b88f0fc6e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java @@ -63,7 +63,7 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("DELETE DM_CONFIG_OPERATION WHERE OPERATION_ID = ?"); + stmt = connection.prepareStatement("DELETE DM_CONFIG_OPERATION WHERE OPERATION_ID = ?") ; stmt.setInt(1, id); stmt.executeUpdate(); } catch (SQLException e) { @@ -152,8 +152,8 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl { } @Override - public List getOperationsByDeviceAndStatus( - int enrolmentId, Operation.Status status) throws OperationManagementDAOException { + public List getOperationsByDeviceAndStatus(int enrolmentId, + Operation.Status status) throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; ConfigOperation configOperation; @@ -164,13 +164,12 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl { try { Connection conn = OperationManagementDAOFactory.getConnection(); String sql = "SELECT co.OPERATION_ID, co.OPERATION_CONFIG FROM DM_CONFIG_OPERATION co " + - "INNER JOIN (SELECT * FROM DM_ENROLMENT_OPERATION_MAPPING WHERE ENROLMENT_ID = ? " + + "INNER JOIN (SELECT * FROM DM_ENROLMENT_OPERATION_MAPPING WHERE ENROLMENT_ID = ? " + "AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID"; stmt = conn.prepareStatement(sql); stmt.setInt(1, enrolmentId); stmt.setString(2, status.toString()); - rs = stmt.executeQuery(); while (rs.next()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java index 438e9a88e9..4aa0e70dbd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java @@ -70,8 +70,8 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP = ? " + - "WHERE O.ID = ?"); + stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=? " + + "WHERE O.ID=?"); stmt.setTimestamp(1, new Timestamp(new Date().getTime())); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); @@ -87,8 +87,8 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OPERATION_MAPPING O SET O.STATUS = ? " + - "WHERE O.ENROLMENT_ID = ? and O.OPERATION_ID = ?"); + stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OPERATION_MAPPING O SET O.STATUS=? " + + "WHERE O.ENROLMENT_ID=? and O.OPERATION_ID=?"); stmt.setString(1, status.toString()); stmt.setInt(2, enrolmentId); stmt.setInt(3, operationId); @@ -110,7 +110,7 @@ public class OperationDAOImpl implements OperationDAO { ObjectOutputStream oos = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("INSERT INTO DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, DEVICE_ID, " + + stmt = connection.prepareStatement("INSERT INTO DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID,DEVICE_ID," + "OPERATION_RESPONSE) VALUES(?, ?, ?)"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); @@ -240,7 +240,7 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; ResultSet rs = null; Operation operation; - List operations = new ArrayList<>(); + List operations = new ArrayList(); try { Connection conn = OperationManagementDAOFactory.getConnection(); String sql = "SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE " + @@ -281,7 +281,7 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; ResultSet rs = null; Operation operation; - List operations = new ArrayList<>(); + List operations = new ArrayList(); try { Connection conn = OperationManagementDAOFactory.getConnection(); String sql = "SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, " + @@ -360,7 +360,7 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; ResultSet rs = null; Operation operation; - List operations = new ArrayList<>(); + List operations = new ArrayList(); try { Connection conn = OperationManagementDAOFactory.getConnection(); String sql = "SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE FROM " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 03ebbf7385..c897a06f7c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -38,6 +38,10 @@ org.apache.ws.commons.axiom axiom-api + + org.wso2.carbon + org.wso2.carbon.utils + @@ -64,7 +68,9 @@ org.wso2.carbon.registry.api, org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.exceptions, - org.wso2.carbon.registry.core.session + org.wso2.carbon.registry.core.session, + javax.xml.bind, + org.wso2.carbon.utils diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/file/FileSystemBasedLicenseManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/file/FileSystemBasedLicenseManager.java new file mode 100644 index 0000000000..30878f924c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/file/FileSystemBasedLicenseManager.java @@ -0,0 +1,57 @@ +/* + * 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.device.mgt.extensions.license.mgt.file; + +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; +import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.File; + +public class FileSystemBasedLicenseManager implements LicenseManager { + + private static final String PATH_MOBILE_PLUGIN_CONF_DIR = + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins"; + + @Override + public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { + try { + String licenseConfigPath = + PATH_MOBILE_PLUGIN_CONF_DIR + File.separator + deviceType + File.separator + "license.xml"; + File licenseConfig = new File(licenseConfigPath); + JAXBContext context = JAXBContext.newInstance(License.class); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return (License) unmarshaller.unmarshal(licenseConfig); + } catch (JAXBException e) { + throw new LicenseManagementException("Error occurred while un-marshalling license configuration " + + "used for '" + deviceType + "' platform from file system", e); + } + } + + @Override + public void addLicense(String deviceType, License license) throws LicenseManagementException { + throw new UnsupportedOperationException("'addLicense' method is not supported in " + + "FileSystemBasedLicenseManager"); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/GenericArtifactManagerFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/GenericArtifactManagerFactory.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/GenericArtifactManagerFactory.java rename to components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/GenericArtifactManagerFactory.java index 1b52502a36..cb062a4d42 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/GenericArtifactManagerFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/GenericArtifactManagerFactory.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.extensions.license.mgt; +package org.wso2.carbon.device.mgt.extensions.license.mgt.registry; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/RegistryBasedLicenseManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java similarity index 98% rename from components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/RegistryBasedLicenseManager.java rename to components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java index b5b092ddb2..420c2799cb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/RegistryBasedLicenseManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java @@ -17,7 +17,7 @@ * */ -package org.wso2.carbon.device.mgt.extensions.license.mgt; +package org.wso2.carbon.device.mgt.extensions.license.mgt.registry; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.RegistryType; @@ -38,6 +38,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; +@SuppressWarnings("unused") public class RegistryBasedLicenseManager implements LicenseManager { private Registry registry; From 84bc22f9f306544f3e73dec90c3db83ea4fdc145 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 30 Jul 2015 16:56:45 +0530 Subject: [PATCH 3/5] Setting default values for fields validFrom and validTo --- .../wso2/carbon/device/mgt/common/license/mgt/License.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java index 7044eb4916..d41a64ab82 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java @@ -35,6 +35,11 @@ public class License { private Date validTo; private String text; + public License() { + this.validFrom = new Date(); + this.validFrom = new Date(); + } + @XmlElement(name = "Provider", required = true) public String getProvider() { return provider; From 508082808c04078d5f96a6976897bd109e8ef928 Mon Sep 17 00:00:00 2001 From: milanperera Date: Thu, 30 Jul 2015 17:10:12 +0530 Subject: [PATCH 4/5] Fixed a bug in commons.licence --- .../org/wso2/carbon/device/mgt/common/license/mgt/License.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java index d41a64ab82..fb7d3a4fdf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java @@ -36,7 +36,7 @@ public class License { private String text; public License() { - this.validFrom = new Date(); + this.validTo = new Date(); this.validFrom = new Date(); } From e30956b619d3ccddbb1440a336cf16067393770f Mon Sep 17 00:00:00 2001 From: milanperera Date: Thu, 30 Jul 2015 18:34:56 +0530 Subject: [PATCH 5/5] Fixed an issue in SQL query of getPendingOperations(CommandOp) --- .../core/operation/mgt/dao/impl/CommandOperationDAOImpl.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/operation/mgt/dao/impl/CommandOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java index bc499d8a3f..d2fbb991b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java @@ -123,9 +123,9 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { List commandOperations = new ArrayList<>(); try { Connection conn = OperationManagementDAOFactory.getConnection(); - String sql = "SELECT o.ID, co1.ENABLED, co1.STATUS, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE FROM (SELECT co.OPERATION_ID, co.ENABLED FROM DM_COMMAND_OPERATION co " + + String sql = "SELECT o.ID, co1.ENABLED, co1.STATUS, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE FROM (SELECT co.OPERATION_ID, co.ENABLED, dm.STATUS FROM DM_COMMAND_OPERATION co " + "INNER JOIN (SELECT ENROLMENT_ID, OPERATION_ID, STATUS FROM DM_ENROLMENT_OPERATION_MAPPING WHERE ENROLMENT_ID = ? " + - "AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID) co1 INNER JOIN OPERATION o ON co1.OPERATION_ID = o.ID"; + "AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID) co1 INNER JOIN DM_OPERATION o ON co1.OPERATION_ID = o.ID"; stmt = conn.prepareStatement(sql); stmt.setInt(1, enrolmentId);