diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java index b11f90bb5e..0ce8dde4a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java @@ -25,9 +25,9 @@ import java.util.Properties; @XmlRootElement public class Operation { - public enum Type { - CONFIG, MESSAGE, INFO, COMMAND - } + public enum Type { + CONFIG, MESSAGE, INFO, COMMAND + } public enum Status { IN_PROGRES, PENDING, COMPLETED, ERROR diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 08ab0c6d9e..1e533ba592 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -47,16 +47,18 @@ public class OperationManagerImpl implements OperationManager { private OperationDAO commandOperationDAO; private OperationDAO configOperationDAO; - private OperationDAO simpleOperationDAO; + private OperationDAO profileOperationDAO; private OperationMappingDAO operationMappingDAO; private DeviceDAO deviceDAO; + private OperationDAO operationDAO; public OperationManagerImpl() { commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO(); configOperationDAO = OperationManagementDAOFactory.getConfigOperationDAO(); - simpleOperationDAO = OperationManagementDAOFactory.getSimpleOperationDAO(); + profileOperationDAO = OperationManagementDAOFactory.getProfileOperationDAO(); operationMappingDAO = OperationManagementDAOFactory.getOperationMappingDAO(); deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); + operationDAO = OperationManagementDAOFactory.getOperationDAO(); } @Override @@ -100,7 +102,21 @@ public class OperationManagerImpl implements OperationManager { @Override public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { - return null; + try { + OperationManagementDAOFactory.beginTransaction(); + + operationDAO.getNextOperation(deviceId); + + OperationManagementDAOFactory.commitTransaction(); + return null; + } catch (OperationManagementDAOException e) { + try { + OperationManagementDAOFactory.rollbackTransaction(); + } catch (OperationManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e1); + } + throw new OperationManagementException("Error occurred while adding operation", e); + } } @Override @@ -115,7 +131,7 @@ public class OperationManagerImpl implements OperationManager { } else if (operation instanceof ConfigOperation) { return configOperationDAO; } else { - return simpleOperationDAO; + return profileOperationDAO; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java similarity index 72% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java index 2f31c3107e..7138dce8da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java @@ -18,7 +18,18 @@ */ package org.wso2.carbon.device.mgt.core.operation.mgt; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import java.io.Serializable; + +public class ProfileOperation extends ConfigOperation implements Serializable { + + private Object payload; + + public Object getPayload() { + return payload; + } + + public void setPayload(Object payload) { + this.payload = payload; + } -public class SimpleOperation extends Operation { } 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 597962d19e..2b2fe05740 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 @@ -18,6 +18,7 @@ */ package org.wso2.carbon.device.mgt.core.operation.mgt.dao; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import java.util.List; @@ -28,12 +29,14 @@ public interface OperationDAO { int updateOperation(Operation operation) throws OperationManagementDAOException; - int deleteOperation(int id) throws OperationManagementDAOException; + int deleteOperation(int operationId) throws OperationManagementDAOException; - Operation getOperation(int id) throws OperationManagementDAOException; + Operation getOperation(int operationId) throws OperationManagementDAOException; List getOperations() throws OperationManagementDAOException; List getOperations(String status) throws OperationManagementDAOException; + Operation getNextOperation(DeviceIdentifier deviceId) 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/OperationManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java index bae92c0ab9..ca0a3b696e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -23,10 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.CommandOperationDAOImpl; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.ConfigOperationDAOImpl; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.OperationMappingDAOImpl; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.SimpleOperationDAOImpl; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.*; import javax.sql.DataSource; import java.sql.Connection; @@ -48,14 +45,18 @@ public class OperationManagementDAOFactory { return new ConfigOperationDAOImpl(); } - public static OperationDAO getSimpleOperationDAO() { - return new SimpleOperationDAOImpl(); + public static OperationDAO getProfileOperationDAO() { + return new ProfileOperationDAOImpl(); } public static OperationMappingDAO getOperationMappingDAO() { return new OperationMappingDAOImpl(); } + public static OperationDAO getOperationDAO() { + return new OperationDAOImpl(); + } + public static void init(DataSource dtSource) { dataSource = dtSource; } 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 6a004fe914..4560b2bde6 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 @@ -18,20 +18,20 @@ */ package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; -import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class CommandOperationDAOImpl extends AbstractOperationDAO { +public class CommandOperationDAOImpl extends OperationDAOImpl { @Override public int addOperation(Operation operation) throws OperationManagementDAOException { @@ -79,4 +79,9 @@ public class CommandOperationDAOImpl extends AbstractOperationDAO { return null; } + @Override + public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { + return null; + } + } 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 e95ef93ef7..bab2c47fad 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 @@ -18,14 +18,13 @@ */ package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationDAO; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; -import javax.sql.DataSource; import java.util.List; -public class ConfigOperationDAOImpl extends AbstractOperationDAO { +public class ConfigOperationDAOImpl extends OperationDAOImpl { @Override public int addOperation(Operation operation) throws OperationManagementDAOException { @@ -57,4 +56,9 @@ public class ConfigOperationDAOImpl extends AbstractOperationDAO { return null; } + @Override + public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { + return null; + } + } 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/AbstractOperationDAO.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 similarity index 70% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.java rename to 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 de8ba47afa..8a16d533fa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.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 @@ -18,6 +18,7 @@ */ package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.*; @@ -28,8 +29,9 @@ import java.sql.ResultSet; import java.sql.Timestamp; import java.util.Date; import java.sql.SQLException; +import java.util.List; -public abstract class AbstractOperationDAO implements OperationDAO { +public class OperationDAOImpl implements OperationDAO { public int addOperation(Operation operation) throws OperationManagementDAOException { PreparedStatement stmt = null; @@ -57,4 +59,33 @@ public abstract class AbstractOperationDAO implements OperationDAO { } } + @Override + public int updateOperation(Operation operation) throws OperationManagementDAOException { + return 0; + } + + @Override + public int deleteOperation(int id) throws OperationManagementDAOException { + return 0; + } + + public Operation getOperation(int id) throws OperationManagementDAOException { + return null; + } + + @Override + public List getOperations() throws OperationManagementDAOException { + return null; + } + + @Override + public List getOperations(String status) throws OperationManagementDAOException { + return null; + } + + @Override + public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { + return null; + } + } 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/ProfileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java new file mode 100644 index 0000000000..4210b3bb6e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java @@ -0,0 +1,155 @@ +/* + * 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.core.operation.mgt.dao.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; + +import java.io.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +public class ProfileOperationDAOImpl extends OperationDAOImpl { + + private static final Log log = LogFactory.getLog(ProfileOperationDAOImpl.class); + + public int addOperation(Operation operation) throws OperationManagementDAOException { + int operationId = super.addOperation(operation); + ProfileOperation profileOp = (ProfileOperation) operation; + Connection conn = OperationManagementDAOFactory.getConnection(); + + PreparedStatement stmt = null; + ResultSet rs = null; + ByteArrayOutputStream bao = null; + ObjectOutputStream oos = null; + try { + bao = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(bao); + oos.writeObject(profileOp); + + stmt = conn.prepareStatement("INSERT INTO DM_PROFILE_OPERATION(OPERATION_ID, PAYLOAD) VALUES(?, ?)"); + stmt.setInt(1, operationId); + stmt.setBytes(2, bao.toByteArray()); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while adding profile operation", e); + } catch (IOException e) { + throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e); + } finally { + if (bao != null) { + try { + bao.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ByteArrayOutputStream", e); + } + } + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ObjectOutputStream", e); + } + } + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + return operationId; + } + + @Override + public int updateOperation(Operation operation) throws OperationManagementDAOException { + return 0; + } + + @Override + public int deleteOperation(int id) throws OperationManagementDAOException { + return 0; + } + + @Override + public Operation getOperation(int operationId) throws OperationManagementDAOException { + Connection conn = OperationManagementDAOFactory.getConnection(); + + PreparedStatement stmt = null; + ResultSet rs = null; + ByteArrayInputStream bais = null; + ObjectInputStream ois = null; + try { + stmt = conn.prepareStatement("SELECT PAYLOAD FROM DM_PROFILE_OPERATION WHERE ID = ?"); + stmt.setInt(1, operationId); + rs = stmt.executeQuery(); + + byte[] payload = new byte[0]; + if (rs.next()) { + payload = rs.getBytes("PAYLOAD"); + } + + bais = new ByteArrayInputStream(payload); + ois = new ObjectInputStream(bais); + return (ProfileOperation) ois.readObject(); + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while adding profile operation", e); + } catch (IOException e) { + throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e); + } catch (ClassNotFoundException e) { + throw new OperationManagementDAOException("Error occurred while casting retrieved payload as a " + + "ProfileOperation object", e); + } finally { + if (bais != null) { + try { + bais.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ByteArrayOutputStream", e); + } + } + if (ois != null) { + try { + ois.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ObjectOutputStream", e); + } + } + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + } + + @Override + public List getOperations() throws OperationManagementDAOException { + return null; + } + + @Override + public List getOperations(String status) throws OperationManagementDAOException { + return null; + } + + @Override + public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { + return null; + } + +} 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/SimpleOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java deleted file mode 100644 index f9a11f04ae..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; - -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; - -import javax.sql.DataSource; -import java.util.List; - -public class SimpleOperationDAOImpl extends AbstractOperationDAO { - - @Override - public int updateOperation(Operation operation) throws OperationManagementDAOException { - return 0; - } - - @Override - public int deleteOperation(int id) throws OperationManagementDAOException { - return 0; - } - - @Override - public Operation getOperation(int id) throws OperationManagementDAOException { - return null; - } - - @Override - public List getOperations() throws OperationManagementDAOException { - return null; - } - - @Override - public List getOperations(String status) throws OperationManagementDAOException { - return null; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index fc2da462a6..7d9e89d5c2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -83,7 +83,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } public FeatureManager getFeatureManager(String type) throws DeviceManagementException { - return null; + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getFeatureManager(type); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java index b0d136cd67..5eac2092a8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java @@ -89,7 +89,7 @@ public class DeviceManagementBaseTest { try { conn = this.getDataSource().getConnection(); stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'"); } catch(Exception e){ log.error(e); throw e; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java index cad951a07a..8af831b5b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java @@ -108,7 +108,7 @@ public class DeviceManagementDAOTests { try { conn = this.getDataSource().getConnection(); stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql similarity index 88% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql index 9bffc6639c..b8b3376aff 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql @@ -45,6 +45,14 @@ CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION ( + OPERATION_ID INTEGER NOT NULL, + PAYLOAD BLOB NOT NULL, + PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java index eb5326b15f..790fa7f246 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java @@ -20,11 +20,11 @@ package org.wso2.carbon.policy.evaluator.utils; public class Constants { - public static final String DENY_OVERRIDES="deny_overrides"; - public static final String PERMIT_OVERRIDES="permit_overrides"; - public static final String FIRST_APPLICABLE="first_applicable"; - public static final String LAST_APPLICABLE="last_applicable"; - public static final String ALL_APPLICABLE="all_applicable"; - public static final String HIGHEST_APPLICABLE="highest_applicable"; - public static final String LOWEST_APPLICABLE="lowest_applicable"; + public static final String DENY_OVERRIDES = "deny_overrides"; + public static final String PERMIT_OVERRIDES = "permit_overrides"; + public static final String FIRST_APPLICABLE = "first_applicable"; + public static final String LAST_APPLICABLE = "last_applicable"; + public static final String ALL_APPLICABLE = "all_applicable"; + public static final String HIGHEST_APPLICABLE = "highest_applicable"; + public static final String LOWEST_APPLICABLE = "lowest_applicable"; }