Format APPM source

merge-requests/173/head
lasanthaDLPDS 5 years ago
parent 345125c042
commit f48f939e7a

@ -28,24 +28,14 @@ import java.util.List;
*/
public interface LifecycleStateDAO {
/**
* To get the latest lifecycle state for the given application release id.
* @param applicationReleaseId id of the application release.
*
* @return Latest Lifecycle State for the given application release
* @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception.
*/
LifecycleState getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException;
/**
* To get the latest lifecycle state for the given application id and the application release UUID.
* @param appId id of the application.
* @param uuid UUID of the application release
*
* @return Latest Lifecycle State for the given application release
* @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception.
*/
LifecycleState getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException;
LifecycleState getLatestLifeCycleState(String uuid) throws LifeCycleManagementDAOException;
/**
* To get all changed lifecycle states for the given application release id.

@ -23,26 +23,42 @@ import org.wso2.carbon.device.application.mgt.core.exception.VisibilityManagemen
import java.util.List;
/**
* This interface provides the list of operations that are performed in the database
* layer with respect to the visibility.
* This interface provides the list of operations that are performed in the database layer with respect to the
* visibility.
*
*/
public interface VisibilityDAO {
/**
* To add unrestricted roles for a particular application.
/***
* This method is used to add unrestricted roles for a particular application.
*
* @param unrestrictedRoles unrestrictedRoles that could available the application.
* @throws VisibilityManagementDAOException Visiblity Management DAO Exception.
* @param unrestrictedRoles List of roles. User should have assigned at least one role from unrestricted role list
* to view the application.
* @param applicationId Id of the application.
* @param tenantId Tenant Id.
* @throws VisibilityManagementDAOException if an error occured while executing the query.
*/
void addUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId) throws
VisibilityManagementDAOException;
void addUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId)
throws VisibilityManagementDAOException;
/***
* This method is used to get unrestricted roles of an particular application.
*
* @param applicationId Id of the application.
* @param tenantId Tenant Id.
* @return List of unrestricted roles of the application.
* @throws VisibilityManagementDAOException if an error occured while executing the query.
*/
List<String> getUnrestrictedRoles(int applicationId, int tenantId) throws VisibilityManagementDAOException;
List<String> getUnrestrictedRolesByUUID(String uuid, int tenantId) throws VisibilityManagementDAOException;
void deleteUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId) throws
VisibilityManagementDAOException;
/***
* This method is used to delete unrestricted roles of an particular application.
*
* @param unrestrictedRoles List of unrestricted roles which are going to remove from the application.
* @param applicationId Id of the application.
* @param tenantId Tenant Id.
* @throws VisibilityManagementDAOException if an error occured while executing the query.
*/
void deleteUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId)
throws VisibilityManagementDAOException;
}

@ -21,7 +21,6 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.AppLifecycleState;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.dto.CategoryDTO;
@ -994,8 +993,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred when deleting category which has ID: " + categoryId + ". Executed query: "
+ sql;
String msg = "SQL Error occurred when deleting category which has ID: " + categoryId + ". Query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
@ -1111,7 +1109,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get distinct tag ids in tag mapping.");
}
String sql = "SELECT DISTINCT tm.AP_APP_TAG_ID AS ID FROM AP_APP_TAG_MAPPING tm";
String sql = "SELECT "
+ "DISTINCT "
+ "tm.AP_APP_TAG_ID AS ID "
+ "FROM AP_APP_TAG_MAPPING tm";
try {
Connection conn = this.getDBConnection();
List<Integer> distinctTagIds = new ArrayList<>();
@ -1142,40 +1143,39 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
log.debug("Request received in DAO Layer to add application tags which has application ID: "
+ applicationId);
}
Connection conn;
PreparedStatement stmt = null;
String sql = "INSERT INTO AP_APP_TAG_MAPPING "
+ "(AP_APP_TAG_ID, "
+ "AP_APP_ID, "
+ " TENANT_ID) "
+ "VALUES (?, ?, ?)";
try {
conn = this.getDBConnection();
stmt = conn.prepareStatement(sql);
for (Integer tagId : tagIds) {
stmt.setInt(1, tagId);
stmt.setInt(2, applicationId);
stmt.setInt(3, tenantId);
stmt.addBatch();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (Integer tagId : tagIds) {
stmt.setInt(1, tagId);
stmt.setInt(2, applicationId);
stmt.setInt(3, tenantId);
stmt.addBatch();
}
stmt.executeBatch();
}
stmt.executeBatch();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when adding tags", e);
String msg = "Error occurred while obtaining the DB connection to add tags for application which has ID: "
+ applicationId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} finally {
DAOUtil.cleanupResources(stmt, null);
String msg = "SQL Error occurred when adding tags for application which has the ID: " + applicationId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public List<String> getAppTags(int appId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get tags for given application.");
log.debug("Request received in DAO Layer to get tags of application which has application Id " + appId);
}
Connection conn;
List<String> tags = new ArrayList<>();
String sql = "SELECT tag.TAG AS TAG "
+ "FROM "
@ -1183,7 +1183,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "INNER JOIN AP_APP app ON tag_map.AP_APP_ID = app.ID "
+ "WHERE app.ID = ? AND app.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setInt(1, appId);
stmt.setInt(2, tenantId);
@ -1195,10 +1195,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
return tags;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when adding tags", e);
String msg = "Error occurred while obtaining the DB connection to get application tags. Application Id: "
+ appId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
String msg = "SQL error occured while getting application tags. ApplicationId: " + appId + " Executed "
+ "query " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -1207,7 +1212,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to verify whether tag is associated with an application.");
}
Connection conn;
String sql = "SELECT tm.AP_APP_ID AS ID "
+ "FROM AP_APP_TAG_MAPPING tm "
+ "WHERE "
@ -1215,7 +1219,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "tm.AP_APP_ID = ? AND "
+ "tm.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tagId);
stmt.setInt(2, applicationId);
@ -1225,28 +1229,31 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when verifying the existence of a tag mapping",
e);
String msg = "Error occurred while obtaining the DB connection when verifying the existence of a tag "
+ "mapping. Application ID " + applicationId + " tag ID: " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred when verifying the existence of a tag mapping.",
e);
String msg = "SQL Error occurred when verifying the existence of a tag mapping. Application ID "
+ applicationId + " tag ID " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public boolean hasTagMapping (int tagId, int tenantId) throws ApplicationManagementDAOException{
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to verify whether tag is associated with at least one application.");
log.debug("Request received in DAO Layer to verify whether tag is associated with at least one "
+ "application.");
}
Connection conn;
String sql = "SELECT tm.AP_APP_ID AS ID "
+ "FROM AP_APP_TAG_MAPPING tm "
+ "WHERE "
+ "tm.AP_APP_TAG_ID = ? AND "
+ "tm.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tagId);
stmt.setInt(2, tenantId);
@ -1255,28 +1262,31 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when verifying the existence of a tag mapping",
e);
String msg = "Error occurred while obtaining the DB connection to verify whether tag is associated with at "
+ "least one application. Tag ID " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred when verifying the existence of a tag mapping.",
e);
String msg = "Error occurred while executing the query to verify whether tag is associated with at least "
+ "one application. Tag ID " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void deleteApplicationTags(List<Integer> tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException{
public void deleteApplicationTags(List<Integer> tagIds, int applicationId, int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete Tag mappings.");
}
Connection conn;
String sql = "DELETE FROM "
+ "AP_APP_TAG_MAPPING WHERE "
+ "AP_APP_TAG_ID = ? AND "
+ "AP_APP_ID = ? AND "
+ "TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
for (Integer tagId : tagIds){
stmt.setInt(1, tagId);
@ -1287,10 +1297,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeBatch();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when deleting tag mapping", e);
String msg = "Error occurred while obtaining the DB connection to delete tag mapping. Application ID: "
+ applicationId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred when deleting tag mapping", e);
String msg = "SQL Error occurred while executing the query to delete tag mapping. Application ID: "
+ applicationId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -1299,7 +1314,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete Tag mapping.");
}
Connection conn;
String sql = "DELETE FROM "
+ "AP_APP_TAG_MAPPING "
+ "WHERE "
@ -1307,7 +1321,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "AP_APP_ID = ? AND "
+ "TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tagId);
stmt.setInt(2, applicationId);
@ -1315,103 +1329,111 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when deleting a tag mapping", e);
String msg = "Error occurred while obtaining the DB connection to delete a tag mapping. Application ID "
+ applicationId + " tag ID " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SQL Error occurred when deleting a tag mapping", e);
String msg = "SQL Error occurred while executing the query to delete a tag mapping. Application ID "
+ applicationId + " tag ID " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void deleteApplicationTags(int applicationId, int tenantId) throws ApplicationManagementDAOException{
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete application tags.");
log.debug("Request received in DAO Layer to delete application tags for application ID " + applicationId);
}
Connection conn;
String sql = "DELETE FROM "
+ "AP_APP_TAG_MAPPING "
+ "WHERE "
+ "AP_APP_ID = ? AND "
+ "TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, applicationId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when deleting application tags for application ID: "
+ applicationId, e);
String msg = "Error occurred while obtaining the DB connection when deleting application tags for "
+ "application ID: " + applicationId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred when deleting application tags for application ID: " + applicationId, e);
String msg = "SQL Error occurred when deleting application tags for application ID: " + applicationId + "."
+ " Executed query " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void deleteTagMapping(int tagId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete Tag mappings.");
log.debug("Request received in DAO Layer to delete application tag. Tag Id " + tagId);
}
Connection conn;
String sql = "DELETE FROM " +
"AP_APP_TAG_MAPPING " +
"WHERE " +
"AP_APP_ID = ? AND " +
"TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tagId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when deleting tag mapping of tag ID: " + tagId,
e);
String msg = "Error occurred while obtaining the DB connection when deleting application tag which has tag"
+ " ID: " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred when deleting tag mapping of tag ID: " + tagId,
e);
String msg = "SQL error occurred when deleting application tag which has tag ID: " + tagId + ". executed "
+ "query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void deleteTag(int tagId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete Tag mappings.");
log.debug("Request received in DAO Layer to delete Tag which has tag ID " + tagId);
}
Connection conn;
String sql = "DELETE FROM " +
"AP_APP_TAG " +
"WHERE " +
"ID = ? AND " +
"TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tagId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when deleting tag which has ID: " + tagId,
e);
String msg = "Error occurred while obtaining the DB connection when deleting tag which has ID: " + tagId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred when deleting tag which has ID: " + tagId,
e);
String msg = "SQL Error occurred when deleting tag which has ID: " + tagId + ". Executed query " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void updateTag(TagDTO tagDTO, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to update the Tag.");
log.debug("Request received in DAO Layer to update a Tag.");
}
Connection conn;
String sql = "UPDATE " +
"AP_APP_TAG tag " +
"SET tag.TAG = ? " +
@ -1419,7 +1441,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
"tag.ID = ? AND " +
"tag.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, tagDTO.getTagName());
stmt.setInt(2, tagDTO.getId());
@ -1427,21 +1449,23 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when updating tag which has ID: " + tagDTO
.getId(), e);
String msg = "Error occurred while obtaining the DB connection to update tag which has ID: "
+ tagDTO.getId();
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred when updating tag which has ID: " + tagDTO.getId(), e);
String msg = "SQL Error occurred when updating tag which has ID: " + tagDTO.getId() + ". Executed query: "
+ sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public List<String> getAppCategories(int appId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get categories for given application.");
log.debug("Request received in DAO Layer to get application categories for given application.");
}
Connection conn;
List<String> categories = new ArrayList<>();
String sql = "SELECT CATEGORY "
+ "FROM "
@ -1449,7 +1473,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "INNER JOIN AP_APP app ON cat_map.AP_APP_ID = app.ID "
+ "WHERE app.ID = ? AND app.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setInt(1, appId);
stmt.setInt(2, tenantId);
@ -1461,10 +1485,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
return categories;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when adding tags", e);
String msg = "Error occurred while obtaining the DB connection to get application categories for "
+ "application which has ID " + appId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
String msg = "SQL error occurred while executing query to get application categories for "
+ "application which has ID " + appId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -1473,14 +1502,13 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to verify whether tag is associated with at least one application.");
}
Connection conn;
String sql = "SELECT cm.AP_APP_ID AS ID "
+ "FROM AP_APP_CATEGORY_MAPPING cm "
+ "WHERE "
+ "cm.AP_APP_CATEGORY_ID = ? AND "
+ "cm.TENANT_ID = ?";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, categoryId);
stmt.setInt(2, tenantId);
@ -1489,53 +1517,56 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when verifying the existence of a category mapping",
e);
String msg = "Error occurred while obtaining the DB connection when verifying the existence of a category "
+ "mapping for category ID " + categoryId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred when verifying the existence of a category mapping.", e);
String msg = "SQL Error occurred when verifying the existence of a category mapping for category ID "
+ categoryId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public boolean isExistingAppName(String appName, int deviceTypeId, int tenantId) throws ApplicationManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
String sql;
String sql = "SELECT AP_APP.ID AS ID "
+ "FROM AP_APP "
+ "WHERE "
+ "AP_APP.NAME = ? AND "
+ "AP_APP.DEVICE_TYPE_ID = ? AND "
+ "AP_APP.TENANT_ID = ?";
try {
conn = this.getDBConnection();
sql = "SELECT AP_APP.ID AS ID "
+ "FROM AP_APP "
+ "WHERE "
+ "AP_APP.NAME = ? AND "
+ "AP_APP.DEVICE_TYPE_ID = ? AND "
+ "AP_APP.TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, appName);
stmt.setInt(2, deviceTypeId);
stmt.setInt(3, tenantId);
rs = stmt.executeQuery();
return rs.next();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setString(1, appName);
stmt.setInt(2, deviceTypeId);
stmt.setInt(3, tenantId);
try (ResultSet rs = stmt.executeQuery()){
return rs.next();
}
}
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
String msg = "Error occurred while obtaining the DB connection to check whether the existence of "
+ "application name for device type which has device type ID " + deviceTypeId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application List", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
String msg = "Error occurred while executing query to check whether the existence of application name for "
+ "device type which has device type ID " + deviceTypeId + ". executed query " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void deleteApplication(int appId, int tenantId) throws ApplicationManagementDAOException {
Connection conn;
String sql;
String sql = "DELETE FROM AP_APP "
+ "WHERE ID = ? AND "
+ "TENANT_ID = ?";
try {
conn = this.getDBConnection();
sql = "DELETE FROM AP_APP "
+ "WHERE ID = ? AND "
+ "TENANT_ID = ?";
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setInt(1, appId);
stmt.setInt(2, tenantId);
@ -1548,7 +1579,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while deleting application for application ID: " + appId;
String msg = "SQL Error occurred while deleting application for application ID: " + appId + " Executed "
+ "query " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}

@ -43,65 +43,53 @@ import java.util.List;
public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements LifecycleStateDAO {
private static final Log log = LogFactory.getLog(GenericLifecycleStateDAOImpl.class);
@Override
public LifecycleState getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT ID, CURRENT_STATE, PREVIOUS_STATE, TENANT_ID, UPDATED_AT, UPDATED_BY FROM "
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_RELEASE_ID=? ORDER BY UPDATED_AT DESC;";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, applicationReleaseId);
rs = stmt.executeQuery();
return constructLifecycle(rs);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while getting application List", e);
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest"
+ " lifecycle state for a specific application", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
}
}
public LifecycleState getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
@Override
public LifecycleState getLatestLifeCycleState(String uuid) throws LifeCycleManagementDAOException{
String sql = "SELECT "
+ "CURRENT_STATE, "
+ "PREVIOUS_STATE, "
+ "UPDATED_AT, "
+ "UPDATED_BY "
+ "FROM "
+ "AP_APP_LIFECYCLE_STATE "
+ "WHERE "
+ "AP_APP_RELEASE_ID = (SELECT ID FROM AP_APP_RELEASE WHERE UUID = ?) ORDER BY UPDATED_AT DESC";
try {
conn = this.getDBConnection();
String sql = "SELECT ID, CURRENT_STATE, PREVIOUS_STATE, TENANT_ID, UPDATED_AT, UPDATED_BY FROM "
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_ID=? AND AP_APP_RELEASE_ID=(SELECT ID FROM AP_APP_RELEASE "
+ "WHERE UUID=?) ORDER BY UPDATED_AT DESC;";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, appId);
stmt.setString(2, uuid);
rs = stmt.executeQuery();
return constructLifecycle(rs);
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, uuid);
try (ResultSet rs = stmt.executeQuery()){
return constructLifecycle(rs);
}
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get latest lifecycle state for a specific"
+ " application. Application release UUID: " + uuid;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while getting application List", e);
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest"
+ " lifecycle state for a specific application", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
}
String msg = "Error occurred while executing query to get latest lifecycle state for a specific "
+ "application. Application release UUID: " + uuid + ". Executed Query: " + sql;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
}
@Override
public String getAppReleaseCreatedUsername(int appId, String uuid, int tenantId) throws LifeCycleManagementDAOException{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT UPDATED_BY FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_ID=? AND "
+ "AP_APP_RELEASE_ID=(SELECT ID FROM AP_APP_RELEASE WHERE UUID=?) AND CURRENT_STATE = ? AND TENANT_ID = ?;";
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "UPDATED_BY "
+ "FROM AP_APP_LIFECYCLE_STATE "
+ "WHERE "
+ "AP_APP_ID = ? AND "
+ "AP_APP_RELEASE_ID = (SELECT ID FROM AP_APP_RELEASE WHERE UUID=?) AND "
+ "CURRENT_STATE = ? AND "
+ "TENANT_ID = ? ORDER BY UPDATED_AT DESC LIMIT 1";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, appId);
@ -127,9 +115,8 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
@Override
public List<LifecycleState> getLifecycleStates(int appReleaseId, int tenantId) throws LifeCycleManagementDAOException {
List<LifecycleState> lifecycleStates = new ArrayList<>();
Connection conn ;
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "CURRENT_STATE, "
+ "PREVIOUS_STATE, "
@ -138,99 +125,100 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
+ "FROM AP_APP_LIFECYCLE_STATE "
+ "WHERE AP_APP_RELEASE_ID = ? AND "
+ "TENANT_ID = ? "
+ "ORDER BY UPDATED_AT ASC;";
+ "ORDER BY UPDATED_AT ASC";
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setInt(1,appReleaseId);
stmt.setInt(2, tenantId);
try (ResultSet rs = stmt.executeQuery()){
while (rs.next()) {
LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setCurrentState(rs.getString("CURRENT_STATE"));
lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE"));
lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT"));
lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY"));
lifecycleStates.add(lifecycleState);
lifecycleStates.add(constructLifecycle(rs));
}
}
}
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection when getting "
+ "lifecycle states for an application", e);
String msg = "Error occurred while obtaining the DB connection when getting lifecycle states for an "
+ "application which has application ID: " + appReleaseId;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while retrieving lifecycle states.", e);
String msg = "SQL Error occurred while retrieving lifecycle states for application which has application "
+ "ID: " + appReleaseId;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
return lifecycleStates;
}
@Override
public void addLifecycleState(LifecycleState state, int appReleaseId, int tenantId) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
String sql = "INSERT INTO AP_APP_LIFECYCLE_STATE "
+ "(CURRENT_STATE, "
+ "PREVIOUS_STATE, "
+ "TENANT_ID, "
+ "UPDATED_BY, "
+ "UPDATED_AT, "
+ "REASON, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
try {
conn = this.getDBConnection();
String sql = "INSERT INTO AP_APP_LIFECYCLE_STATE "
+ "(CURRENT_STATE, "
+ "PREVIOUS_STATE, "
+ "TENANT_ID, "
+ "UPDATED_BY, "
+ "UPDATED_AT, "
+ "REASON, "
+ "AP_APP_RELEASE_ID, "
+ "AP_APP_ID) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE ID = ?));";
Connection conn = this.getDBConnection();
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
stmt = conn.prepareStatement(sql);
stmt.setString(1, state.getCurrentState().toUpperCase());
stmt.setString(2, state.getPreviousState().toUpperCase());
stmt.setInt(3, tenantId);
stmt.setString(4, state.getUpdatedBy());
stmt.setTimestamp(5, timestamp);
stmt.setString(6, state.getReasonForChange());
stmt.setInt(7, appReleaseId);
stmt.setInt(8, appReleaseId);
stmt.executeUpdate();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, state.getCurrentState().toUpperCase());
stmt.setString(2, state.getPreviousState().toUpperCase());
stmt.setInt(3, tenantId);
stmt.setString(4, state.getUpdatedBy());
stmt.setTimestamp(5, timestamp);
stmt.setString(6, state.getReasonForChange());
stmt.setInt(7, appReleaseId);
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
log.error("Error occurred while obtaining the DB connection.", e);
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
String msg = "Error occurred while obtaining the DB connection to add lifecycle state for application "
+ "release which has ID " + appReleaseId + ". Lifecycle state " + state.getCurrentState();
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
} catch (SQLException e) {
log.error("Error occurred while adding lifecycle: " + state.getCurrentState(), e);
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getCurrentState(), e);
} finally {
DAOUtil.cleanupResources(stmt, null);
String msg = "Error occurred while executing the query to add lifecycle state for application release which"
+ " has ID " + appReleaseId + ". Lifecycle state " + state.getCurrentState() + ". Executed query: "
+ sql;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
}
@Override
public void deleteLifecycleStateByReleaseId(int releaseId) throws LifeCycleManagementDAOException {
Connection conn;
String sql = "DELETE "
+ "FROM AP_APP_LIFECYCLE_STATE " +
"WHERE AP_APP_RELEASE_ID = ?";
try {
conn = this.getDBConnection();
String sql = "DELETE FROM " +
"AP_APP_LIFECYCLE_STATE " +
"WHERE AP_APP_RELEASE_ID = ?";
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, releaseId);
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
String msg = "Error occurred while obtaining the DB connection to delete lifecycle states for application "
+ "release ID: " + releaseId;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while deleting lifecycle for application "
+ "release ID: " + releaseId, e);
String msg = "Error occurred while executing the query to delete lifecycle states for application release"
+ " ID: " + releaseId + ". Executed query " + sql;
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
}
@Override
public void deleteLifecycleStates(List<Integer> appReleaseIds) throws LifeCycleManagementDAOException{
Connection conn;
String sql = "DELETE "
+ "FROM AP_APP_LIFECYCLE_STATE " +
"WHERE AP_APP_RELEASE_ID = ?";
try {
conn = this.getDBConnection();
String sql = "DELETE FROM " +
"AP_APP_LIFECYCLE_STATE " +
"WHERE AP_APP_RELEASE_ID = ?";
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (Integer releaseId : appReleaseIds) {
stmt.setInt(1, releaseId);
@ -239,29 +227,32 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
stmt.executeBatch();
}
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection for deleting "
+ "application life-cycle states for given application Ids.", e);
String msg = "Error occurred while obtaining the DB connection for deleting application life-cycle states "
+ "for given application Ids.";
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while deleting life-cycle states for given "
+ "application releases.", e);
String msg = "Error occurred while executing query to delete application life-cycle states for given "
+ "application Ids.";
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
}
private LifecycleState constructLifecycle(ResultSet rs) throws LifeCycleManagementDAOException {
LifecycleState lifecycleState = null;
try {
if (rs !=null && rs.next()) {
lifecycleState = new LifecycleState();
LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setCurrentState(rs.getString("CURRENT_STATE"));
lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE"));
lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT"));
lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY"));
}
} catch (SQLException e) {
throw new LifeCycleManagementDAOException(
"Error occurred while construct lifecycle state by retrieving data from SQL query", e);
String msg = "Error occurred while construct lifecycle state by data which is retrieved from SQL query";
log.error(msg);
throw new LifeCycleManagementDAOException(msg, e);
}
return lifecycleState;
return null;
}
}

@ -47,7 +47,6 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
public List<Integer> addDeviceSubscription(String subscribedBy, List<Integer> deviceIds,
String subscribedFrom, String installStatus, int releaseId, int tenantId)
throws ApplicationManagementDAOException {
Connection conn;
String sql = "INSERT INTO "
+ "AP_DEVICE_SUBSCRIPTION("
+ "SUBSCRIBED_BY, "
@ -59,7 +58,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
+ "TENANT_ID) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
@ -103,10 +102,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
public List<Integer> updateDeviceSubscription(String updateBy, List<Integer> deviceIds,
boolean isUnsubscribed, String actionTriggeredFrom, String installStatus, int releaseId, int tenantId)
throws ApplicationManagementDAOException {
Connection conn;
try {
conn = this.getDBConnection();
String sql = "UPDATE AP_DEVICE_SUBSCRIPTION SET ";
if (isUnsubscribed) {
@ -121,6 +117,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
"AP_APP_RELEASE_ID = ? AND " +
"TENANT_ID = ?";
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
@ -144,27 +141,31 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to update the device subscriptions of application.";
String msg = "Error occurred while obtaining the DB connection to update device subscriptions of "
+ "application. Updated by: " + updateBy + " and updating action triggered from "
+ actionTriggeredFrom;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred when obtaining database connection for updating the device subscriptions of application.";
String msg = "Error occurred when obtaining database connection for updating the device subscriptions of "
+ "application. Updated by: " + updateBy + " and updating action triggered from "
+ actionTriggeredFrom;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override public void addOperationMapping(int operationId, List<Integer> deviceSubscriptionIds, int tenantId)
@Override
public void addOperationMapping(int operationId, List<Integer> deviceSubscriptionIds, int tenantId)
throws ApplicationManagementDAOException {
Connection conn;
String sql = "INSERT INTO "
+ "AP_APP_SUB_OP_MAPPING("
+ "OPERATION_ID, "
+ "AP_DEVICE_SUBSCRIPTION_ID, "
+ "TENANT_ID) "
+ "VALUES (?, ?, ?)";
try {
String sql = "INSERT INTO "
+ "AP_APP_SUB_OP_MAPPING("
+ "OPERATION_ID, "
+ "AP_DEVICE_SUBSCRIPTION_ID, "
+ "TENANT_ID) "
+ "VALUES (?, ?, ?)";
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (Integer subId : deviceSubscriptionIds) {
stmt.setInt(1, operationId);
@ -177,31 +178,35 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
stmt.executeBatch();
}
} catch (SQLException | DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while adding operation subscription mapping to DB",
e);
} catch (DBConnectionException e) {
String msg = "Error occurred while getting database connection to add operation subscription mapping to DB";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to add operation subscription mapping to DB. Executed "
+ "query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void addUserSubscriptions(int tenantId, String subscribedBy, List<String> users, int releaseId)
throws ApplicationManagementDAOException {
Connection conn;
String sql = "INSERT INTO "
+ "AP_USER_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "USER_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
try {
String sql = "INSERT INTO "
+ "AP_USER_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "USER_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
for (String user : users) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
stmt.setInt(1, tenantId);
stmt.setString(2, subscribedBy);
stmt.setTimestamp(3, timestamp);
@ -209,35 +214,42 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
stmt.setInt(5, releaseId);
stmt.addBatch();
if (log.isDebugEnabled()) {
log.debug("Adding a mapping to user[" + user + "] to the application release[" + releaseId + "]");
log.debug("Adding an user subscription for user " + user + " and application release which "
+ "has Id " + releaseId + " to the database.");
}
}
stmt.executeBatch();
}
} catch (SQLException | DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB",
e);
} catch (DBConnectionException e) {
String msg = "Error occurred while getting database connection to add user subscription. Subscribing user "
+ "is " + subscribedBy;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to add user subscription. Subscribing user is "
+ subscribedBy + " and executed query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void addRoleSubscriptions(int tenantId, String subscribedBy, List<String> roles, int releaseId)
throws ApplicationManagementDAOException {
Connection conn;
String sql = "INSERT INTO "
+ "AP_ROLE_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "ROLE_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
try {
String sql = "INSERT INTO "
+ "AP_ROLE_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "ROLE_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
for (String role : roles) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
stmt.setInt(1, tenantId);
stmt.setString(2, subscribedBy);
stmt.setTimestamp(3, timestamp);
@ -245,35 +257,42 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
stmt.setInt(5, releaseId);
stmt.addBatch();
if (log.isDebugEnabled()) {
log.debug("Adding a mapping to role[" + role + "] to the application release[" + releaseId + "]");
log.debug("Adding a role subscription for role " + role + " and application release which "
+ "has Id " + releaseId + " to the database.");
}
}
stmt.executeBatch();
}
} catch (SQLException | DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while adding role subscription to APPM DB",
e);
} catch (DBConnectionException e) {
String msg = "Error occurred while getting database connection to add role subscription. Subscribing role "
+ "is " + subscribedBy;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to add role subscription. Subscribing role is "
+ subscribedBy + " and executed query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void addGroupSubscriptions(int tenantId, String subscribedBy, List<String> groups, int releaseId)
throws ApplicationManagementDAOException {
Connection conn;
String sql = "INSERT INTO "
+ "AP_GROUP_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "GROUP_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
try {
String sql = "INSERT INTO "
+ "AP_GROUP_SUBSCRIPTION("
+ "TENANT_ID, "
+ "SUBSCRIBED_BY, "
+ "SUBSCRIBED_TIMESTAMP, "
+ "GROUP_NAME, "
+ "AP_APP_RELEASE_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
for (String group : groups) {
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
stmt.setInt(1, tenantId);
stmt.setString(2, subscribedBy);
stmt.setTimestamp(3, timestamp);
@ -281,14 +300,22 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
stmt.setInt(5, releaseId);
stmt.addBatch();
if (log.isDebugEnabled()) {
log.debug("Adding a mapping to group[" + group + "] to the application release[" + releaseId + "]");
log.debug("Adding a group subscription for role " + group + " and application release which "
+ "has Id " + releaseId + " to the database.");
}
}
stmt.executeBatch();
}
} catch (SQLException | DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while adding group subscription to APPM DB",
e);
} catch (DBConnectionException e) {
String msg = "Error occurred while getting database connection to add group subscription. Subscribing "
+ "group is " + subscribedBy;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to add group subscription. Subscribing group is "
+ subscribedBy + " and executed query: " + sql;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -299,20 +326,19 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
log.debug("Getting device subscriptions for the application release id " + appReleaseId
+ " from the database");
}
Connection conn;
String sql = "SELECT "
+ "DS.ID AS ID, "
+ "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, "
+ "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, "
+ "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, "
+ "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, "
+ "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, "
+ "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, "
+ "DS.DM_DEVICE_ID AS DEVICE_ID "
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
+ "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.TENANT_ID=?";
try {
conn = this.getDBConnection();
String sql = "SELECT "
+ "DS.ID AS ID, "
+ "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, "
+ "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, "
+ "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, "
+ "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, "
+ "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, "
+ "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, "
+ "DS.DM_DEVICE_ID AS DEVICE_ID "
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
+ "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.TENANT_ID=?";
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
@ -324,15 +350,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
return DAOUtil.loadDeviceSubscriptions(rs);
}
}
} catch (SQLException e) {
String msg =
"Error occurred while getting device subscription data for application ID: " + appReleaseId + ".";
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection for getting device subscription for "
+ "application Id: " + appReleaseId + ".";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (DBConnectionException e) {
String msg =
"Error occurred while obtaining the DB connection for getting device subscription for applicationID: "
+ appReleaseId + ".";
} catch (SQLException e) {
String msg = "Error occurred while getting device subscription data for application ID: " + appReleaseId;
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
@ -377,12 +401,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
return deviceSubscriptionDTOHashMap;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when getting device subscriptions for given "
+ "device Ids.", e);
String msg = "Error occurred while obtaining the DB connection to get device subscriptions for given device"
+ " Ids.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SWL Error occurred while getting device subscriptions for given"
+ " device Ids.", e);
String msg = "SQL Error occurred while getting device subscriptions for given device Ids.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -415,12 +441,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
return subscribedUsers;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when getting subscribed users for given "
+ "user names.", e);
String msg = "Error occurred while obtaining the DB connection to get already subscribed users for given "
+ "user names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SWL Error occurred while getting suscribed users for given"
+ " user names.", e);
String msg = "SQL Error occurred while getting subscribed users for given user names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -428,8 +456,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
public List<String> getSubscribedRoleNames(List<String> roles, int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug(
"Request received in DAO Layer to get already subscribed role names for given list of role names.");
log.debug("Request received in DAO Layer to get already subscribed role names for given list of roles.");
}
try {
Connection conn = this.getDBConnection();
@ -454,12 +481,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
return subscribedUsers;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when getting subscribed roles for given "
+ "role names.", e);
String msg = "Error occurred while obtaining the DB connection to getg subscribed roles for given role "
+ "names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SWL Error occurred while getting subscribes roles for given"
+ " role names.", e);
String msg = "SWL Error occurred while getting subscribes roles for given role names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -467,7 +496,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
public List<String> getSubscribedGroupNames(List<String> groups, int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed groups for given list of group names.");
log.debug("Request received in DAO Layer to get already subscribed groups for given list of groups.");
}
try {
Connection conn = this.getDBConnection();
@ -492,12 +521,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
return subscribedUsers;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when getting subscribed groups for given "
+ "group names.", e);
String msg = "Error occurred while obtaining the DB connection to get already subscribed groups for given "
+ "group names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SWL Error occurred while getting subscribed groups for given"
+ " group names.", e);
String msg = "SQL Error occurred while getting already subscribed groups for given group names.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@ -530,20 +561,22 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
return subscribedDevices;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection when getting subscribed device Ids for given "
+ "device Id list.", e);
String msg = "Error occurred while obtaining the DB connection to get subscribed device Ids for given "
+ "device Id list.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SWL Error occurred while getting subscribed device ids for "
+ "given devie Id list.", e);
} }
String msg = "SQL Error occurred while getting already subscribed device ids for given device Id list.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void updateSubscriptions(int tenantId, String updateBy, List<String> paramList, int releaseId,
String subType, String action) throws ApplicationManagementDAOException {
Connection conn;
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
String sql = "UPDATE ";
if (SubsciptionType.USER.toString().equalsIgnoreCase(subType)) {
sql += "AP_USER_SUBSCRIPTION SET ";
@ -583,11 +616,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
stmt.executeBatch();
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to update the user subscriptions of application.";
String msg = "Error occurred while obtaining the DB connection to update the user subscriptions of "
+ "application.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred when obtaining database connection for updating the user subscriptions of application.";
String msg = "Error occurred when obtaining database connection for updating the user subscriptions of "
+ "application.";
log.error(msg);
throw new ApplicationManagementDAOException(msg, e);
}
@ -596,9 +631,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override
public List<Integer> getDeviceSubIdsForOperation(int operationId, int tenantId)
throws ApplicationManagementDAOException {
Connection conn;
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
List<Integer> deviceSubIds = new ArrayList<>();
String sql = "SELECT "
+ "ID "
@ -631,9 +665,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override
public boolean updateDeviceSubStatus(int deviceId, List<Integer> deviceSubIds, String status, int tenantId)
throws ApplicationManagementDAOException {
Connection conn;
try {
conn = this.getDBConnection();
Connection conn = this.getDBConnection();
int index = 1;
StringJoiner joiner = new StringJoiner(",",
"UPDATE AP_DEVICE_SUBSCRIPTION SET STATUS = ? "

@ -21,7 +21,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.VisibilityManagementDAOException;
@ -43,87 +42,56 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
public void addUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId) throws
VisibilityManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to add unrestricted roles");
log.debug("Request received in DAO Layer to add unrestricted roles for application which has application"
+ " ID " + applicationId);
}
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
String sql = "INSERT INTO AP_UNRESTRICTED_ROLE (ROLE, TENANT_ID, AP_APP_ID) VALUES (?, ?, ?)";
try{
conn = this.getDBConnection();
conn.setAutoCommit(false);
stmt = conn.prepareStatement(sql);
for (String role : unrestrictedRoles) {
stmt.setString(1, role);
stmt.setInt(2, tenantId);
stmt.setInt(3, applicationId);
stmt.addBatch();
String sql = "INSERT INTO "
+ "AP_UNRESTRICTED_ROLE "
+ "(ROLE, "
+ "TENANT_ID, "
+ "AP_APP_ID) "
+ "VALUES (?, ?, ?)";
try {
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (String role : unrestrictedRoles) {
stmt.setString(1, role);
stmt.setInt(2, tenantId);
stmt.setInt(3, applicationId);
stmt.addBatch();
}
stmt.executeBatch();
}
stmt.executeBatch();
}catch (DBConnectionException e) {
throw new VisibilityManagementDAOException("Error occurred while obtaining the DB connection when adding roles", e);
}catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection when adding unrestricted roles for "
+ "application which has Id " + applicationId;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to add unrestricted roles for application which has Id "
+ applicationId + ". Executed query " + sql;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
}
}
@Override
public List<String> getUnrestrictedRoles(int applicationId, int tenantId) throws VisibilityManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get unrestricted roles");
log.debug("Request received in DAO Layer to get unrestricted roles for application which has application "
+ "ID " + applicationId);
}
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<String> unrestrictedRoles = new ArrayList<>();
String sql = "SELECT ROLE "
+ "FROM AP_UNRESTRICTED_ROLE "
+ "WHERE AP_APP_ID = ? AND TENANT_ID = ?";
try{
conn = this.getDBConnection();
conn.setAutoCommit(false);
stmt = conn.prepareStatement(sql);
stmt.setInt(1, applicationId);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery();
while (rs.next()){
unrestrictedRoles.add(rs.getString("ROLE"));
}
return unrestrictedRoles;
}catch (DBConnectionException e) {
throw new VisibilityManagementDAOException("Error occurred while obtaining the DB connection when adding roles", e);
}catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public List<String> getUnrestrictedRolesByUUID(String uuid, int tenantId) throws VisibilityManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get unrestricted roles for UUID: " + uuid);
}
Connection conn;
List<String> unrestrictedRoles = new ArrayList<>();
String sql = "SELECT ROLE FROM AP_UNRESTRICTED_ROLE "
+ "WHERE "
+ "AP_APP_ID = (SELECT AR.AP_APP_ID FROM AP_APP_RELEASE AR WHERE AR.UUID = ? AND AR.TENANT_ID = ? ) "
+ "AND TENANT_ID = ?";
+ "WHERE AP_APP_ID = ? AND "
+ "TENANT_ID = ?";
try {
conn = this.getDBConnection();
conn.setAutoCommit(false);
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, uuid);
stmt.setInt(1, applicationId);
stmt.setInt(2, tenantId);
stmt.setInt(3, tenantId);
try (ResultSet rs = stmt.executeQuery();) {
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
unrestrictedRoles.add(rs.getString("ROLE"));
}
@ -131,43 +99,51 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
}
}
} catch (DBConnectionException e) {
throw new VisibilityManagementDAOException(
"Error occurred while obtaining the DB connection when getting unrestricted roles for UUID: "
+ uuid, e);
String msg = "Error occurred while obtaining the DB connection to get unrestricted roles for application "
+ "which has application Id " + applicationId;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
} catch (SQLException e) {
throw new VisibilityManagementDAOException(
"Error occurred while getting unrestricted roles for UUID: " + uuid, e);
String msg = "Error occurred while executing query to get unrestricted roles for application which has "
+ "application Id " + applicationId + ". Executed query: " + sql;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
}
}
@Override
public void deleteUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId) throws VisibilityManagementDAOException {
public void deleteUnrestrictedRoles(List<String> unrestrictedRoles, int applicationId, int tenantId)
throws VisibilityManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to delete unrestricted roles");
log.debug("Request received in DAO Layer to delete unrestricted roles of application which has "
+ "application Id " + applicationId);
}
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
String sql = "DELETE FROM AP_UNRESTRICTED_ROLE WHERE AP_APP_ID = ? AND ROLE = ? AND TENANT_ID = ?;";
try{
conn = this.getDBConnection();
conn.setAutoCommit(false);
stmt = conn.prepareStatement(sql);
for (String role : unrestrictedRoles) {
stmt.setInt(1, applicationId);
stmt.setString(2, role);
stmt.setInt(3, tenantId);
stmt.addBatch();
String sql = "DELETE "
+ "FROM AP_UNRESTRICTED_ROLE "
+ "WHERE AP_APP_ID = ? AND "
+ "ROLE = ? AND "
+ "TENANT_ID = ?";
try {
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (String role : unrestrictedRoles) {
stmt.setInt(1, applicationId);
stmt.setString(2, role);
stmt.setInt(3, tenantId);
stmt.addBatch();
}
stmt.executeBatch();
}
stmt.executeBatch();
}catch (DBConnectionException e) {
throw new VisibilityManagementDAOException("Error occurred while obtaining the DB connection when adding roles", e);
}catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally {
DAOUtil.cleanupResources(stmt, rs);
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to delete unrestricted roles of an "
+ "application which has application Id " + applicationId;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while executing query to delete unrestricted roles of an application which has"
+ " application Id " + applicationId + ". executed query: " + sql;
log.error(msg);
throw new VisibilityManagementDAOException(msg, e);
}
}
}

@ -294,14 +294,16 @@ public class ReviewManagerImpl implements ReviewManager {
if (reviewDTO.getRootParentId() == -1 && reviewDTO.getImmediateParentId() == -1) {
if (!reviewDTO.getReleaseUuid().equals(uuid)) {
isActiveReview = false;
} else if (updatingReview.getRating() > 0 && updatingReview.getRating() != reviewDTO.getRating()) {
Runnable task = () -> ReviewManagerImpl.this
.calculateRating(updatingReview.getRating(), reviewDTO.getRating(), uuid, tenantId);
new Thread(task).start();
reviewDTO.setRating(updatingReview.getRating());
}
if (!reviewDTO.getContent().equals(updatingReview.getContent())) {
reviewDTO.setContent(updatingReview.getContent());
} else {
if (updatingReview.getRating() > 0 && updatingReview.getRating() != reviewDTO.getRating()) {
Runnable task = () -> ReviewManagerImpl.this
.calculateRating(updatingReview.getRating(), reviewDTO.getRating(), uuid, tenantId);
new Thread(task).start();
reviewDTO.setRating(updatingReview.getRating());
}
if (!reviewDTO.getContent().equals(updatingReview.getContent())) {
reviewDTO.setContent(updatingReview.getContent());
}
}
} else {
if (!reviewDTO.getReleaseUuid().equals(uuid)) {
@ -775,7 +777,7 @@ public class ReviewManagerImpl implements ReviewManager {
List<String> uuids = applicationDTO.getApplicationReleaseDTOs().stream().map(ApplicationReleaseDTO::getUuid)
.collect(Collectors.toList());
List<Integer> appRatings = this.reviewDAO.getAllAppRatingValues(uuids, tenantId);
double appAverageRatingValue = appRatings.stream().mapToDouble(x -> x).average().orElse(Double.NaN);
double appAverageRatingValue = appRatings.stream().mapToDouble(x -> x).average().orElse(0.0);
this.applicationDAO.updateApplicationRating(uuid, appAverageRatingValue, tenantId);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred when getting application data or updating application rating value.";

@ -29,11 +29,8 @@ import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
import org.wso2.carbon.device.application.mgt.store.api.services.admin.ReviewManagementStoreAdminAPI;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
/**

@ -81,7 +81,6 @@ CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE(
UPDATED_BY VARCHAR(100) NOT NULL,
UPDATED_AT TIMESTAMP NOT NULL,
AP_APP_RELEASE_ID INTEGER NOT NULL,
AP_APP_ID INTEGER NOT NULL,
REASON TEXT DEFAULT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1

Loading…
Cancel
Save