|
|
@ -21,22 +21,18 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application.release
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Application;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Rating;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Rating;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -47,30 +43,26 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(GenericApplicationReleaseDAOImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(GenericApplicationReleaseDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To insert the Application Release Details.
|
|
|
|
* To insert the Application Release Details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param appId Id of the application
|
|
|
|
* @param appId Id of the application
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId)
|
|
|
|
public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId) throws
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "INSERT INTO AP_APP_RELEASE (VERSION,TENANT_ID,UUID,RELEASE_TYPE, PACKAGE_NAME, APP_PRICE,"
|
|
|
|
String sql = "INSERT INTO AP_APP_RELEASE (VERSION,TENANT_ID,UUID,RELEASE_TYPE, PACKAGE_NAME, APP_PRICE,"
|
|
|
|
+ "STORED_LOCATION,ICON_LOCATION, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, " +
|
|
|
|
+ "STORED_LOCATION, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, APP_HASH_VALUE,"
|
|
|
|
"APP_HASH_VALUE,"
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,CREATED_BY,AP_APP_ID) "
|
|
|
|
|
|
|
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?);";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
int index = 0;
|
|
|
|
String generatedColumns[] = {"ID"};
|
|
|
|
String generatedColumns[] = { "ID" };
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
statement = connection.prepareStatement(sql, generatedColumns);
|
|
|
|
statement = connection.prepareStatement(sql, generatedColumns);
|
|
|
@ -89,7 +81,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
statement.setString(++index, applicationRelease.getAppHashValue());
|
|
|
|
statement.setString(++index, applicationRelease.getAppHashValue());
|
|
|
|
statement.setInt(++index, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
statement.setInt(++index, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
statement.setString(++index, applicationRelease.getMetaData());
|
|
|
|
statement.setString(++index, applicationRelease.getMetaData());
|
|
|
|
statement.setString(++index, applicationRelease.getApplicationCreator());
|
|
|
|
|
|
|
|
statement.setInt(++index, appId);
|
|
|
|
statement.setInt(++index, appId);
|
|
|
|
statement.executeUpdate();
|
|
|
|
statement.executeUpdate();
|
|
|
|
resultSet = statement.getGeneratedKeys();
|
|
|
|
resultSet = statement.getGeneratedKeys();
|
|
|
@ -102,39 +93,37 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
"SQL Exception while trying to release an application by executing the query " + sql, e);
|
|
|
|
"SQL Exception while trying to release an application by executing the query " + sql, e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to release a new version" , e);
|
|
|
|
"Database Connection Exception while trying to release a new version", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To get release details of a specific application.
|
|
|
|
* To get latest updated app release details of a specific application.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param applicationName Name of the application.
|
|
|
|
* @param applicationName Name of the application.
|
|
|
|
* @param applicationType Type of the application.
|
|
|
|
* @param applicationType Type of the application.
|
|
|
|
* @param versionName version name of the application.
|
|
|
|
* @param versionName version name of the application.
|
|
|
|
* @param releaseType type of the application release.
|
|
|
|
* @param releaseType type of the application release.
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
|
|
|
|
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, "
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID AS UUID, AR.RELEASE_TYPE AS "
|
|
|
|
+ "AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, AR.BANNER_LOCATION, "
|
|
|
|
+ "RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE AS APP_PRICE, AR.STORED_LOCATION AS "
|
|
|
|
+ "AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS "
|
|
|
|
+ "STORED_LOCATION, AR.BANNER_LOCATION AS BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
|
|
|
+ "SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
|
|
|
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS "
|
|
|
|
+ "AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, "
|
|
|
|
+ "HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO AS APP_META_INFO , "
|
|
|
|
+ "AL.CURRENT_STATE, AL.PREVIOUSE_STATE, AL.UPDATED_BY, AL.UPDATED_AT FROM "
|
|
|
|
+ "AR.RATING AS RATING, AL.CURRENT_STATE, AL.PREVIOUS_STATE, AL.UPDATED_BY, AL.UPDATED_AT FROM "
|
|
|
|
+ "AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE "
|
|
|
|
+ "AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE "
|
|
|
|
+ "AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME=? AND TYPE=? AND TENANT_ID=?) "
|
|
|
|
+ "NAME=? AND TYPE=? AND TENANT_ID=?) AND AR.VERSION=? AND AR.RELEASE_TYPE=? AND "
|
|
|
|
+ "AND AR.VERSION=? AND AR.RELEASE_TYPE=? AND AL.AP_APP_RELEASE_ID=AR.ID "
|
|
|
|
+ "AL.AP_APP_RELEASE_ID=AR.ID AND AL.TENANT_ID=AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
+ "AND AL.TENANT_ID=AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
@ -152,11 +141,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
+ "release details of the application with " + applicationName + " and version " +
|
|
|
|
+ "release details of the application with " + applicationName + " and version " + versionName, e);
|
|
|
|
versionName, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error while getting release details of the application " +
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
"Error while getting release details of the application " + applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -166,25 +154,25 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
* To get release details of a specific application.
|
|
|
|
* To get release details of a specific application.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param applicationId ID of the application.
|
|
|
|
* @param applicationId ID of the application.
|
|
|
|
* @param releaseUuid UUID of the application release.
|
|
|
|
* @param releaseUuid UUID of the application release.
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId)
|
|
|
|
public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.PACKAGE_NAME, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR" +
|
|
|
|
String sql =
|
|
|
|
".RELEASE_TYPE, AR.APP_PRICE, AR.STORED_LOCATION, AR.ICON_LOCATION, AR.BANNER_LOCATION, AR" +
|
|
|
|
"SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE, "
|
|
|
|
".SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS " +
|
|
|
|
+ "AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
|
|
|
"HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR" +
|
|
|
|
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.PACKAGE_NAME AS "
|
|
|
|
".PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AL.CURRENT_STATE, AL.PREVIOUSE_STATE, AL.UPDATED_BY, " +
|
|
|
|
+ "PACKAGE_NAME, AR.APP_HASH_VALUE AS HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
|
|
|
"AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE " +
|
|
|
|
+ "AR.APP_META_INFO AS APP_META_INFO, AR.RATING AS RATING, AL.CURRENT_STATE, AL.PREVIOUS_STATE, "
|
|
|
|
"AR.AP_APP_ID = ? AND AR.UUID = ? AND AR.TENANT_ID = ? AND AL.AP_APP_RELEASE_ID=AR.ID AND " +
|
|
|
|
+ "AL.UPDATED_BY, AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL "
|
|
|
|
"AL.TENANT_ID = AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
+ "WHERE AR.AP_APP_ID = ? AND AR.UUID = ? AND AR.TENANT_ID = ? AND AL.AP_APP_RELEASE_ID=AR.ID "
|
|
|
|
|
|
|
|
+ "AND AL.TENANT_ID = AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
@ -200,14 +188,12 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
"Database connection exception while trying to get the release details of the " +
|
|
|
|
"Database connection exception while trying to get the release details of the " + "application id: "
|
|
|
|
"application id: " + applicationId + "and UUID of the application release: " +
|
|
|
|
+ applicationId + "and UUID of the application release: " + releaseUuid, e);
|
|
|
|
releaseUuid, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
"Error while getting release details of the application id: " + applicationId +
|
|
|
|
"Error while getting release details of the application id: " + applicationId
|
|
|
|
" and theUUID of the application " +
|
|
|
|
+ " and theUUID of the application " + "release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
"release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -216,62 +202,42 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To insert the application release properties.
|
|
|
|
* To insert the application release properties.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param applicationName Name of the application.
|
|
|
|
* @param applicationId Id of the application.
|
|
|
|
* @param applicationType Type of the application.
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public List<ApplicationRelease> getReleases(int applicationId, int tenantId)
|
|
|
|
public List<ApplicationRelease> getReleases(String applicationName, String applicationType, int tenantId)
|
|
|
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
|
|
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
|
|
|
String sql = "SELECT AR.ID AS RELESE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE,"
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE "
|
|
|
|
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS "
|
|
|
|
+ "AS RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, "
|
|
|
|
+ "SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, "
|
|
|
|
+ "AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS SCREEN_SHOT_2, "
|
|
|
|
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, "
|
|
|
|
+ "AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, "
|
|
|
|
+ "AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AR.RATING FROM AP_APP_RELEASE AS "
|
|
|
|
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO AS APP_META_INFO, "
|
|
|
|
+ "AR where AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME = ? AND TYPE = ? "
|
|
|
|
+ "AR.RATING AS RATING FROM AP_APP_RELEASE AS AR where AR.AP_APP_ID=? AND AR.TENANT_ID = ?;";
|
|
|
|
+ "AND TENANT_ID = ?) AND AR.TENANT_ID = ? ;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement.setString(1, applicationName);
|
|
|
|
statement.setInt(1, applicationId);
|
|
|
|
statement.setString(2, applicationType);
|
|
|
|
statement.setInt(2, tenantId);
|
|
|
|
statement.setInt(3, tenantId);
|
|
|
|
|
|
|
|
statement.setInt(4, tenantId);
|
|
|
|
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
while (resultSet.next()) {
|
|
|
|
while (resultSet.next()) {
|
|
|
|
ApplicationRelease applicationRelease = new ApplicationRelease();
|
|
|
|
ApplicationRelease applicationRelease = constructApplicationRelease(resultSet);
|
|
|
|
applicationRelease.setId(resultSet.getInt("RELESE_ID"));
|
|
|
|
|
|
|
|
applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION"));
|
|
|
|
|
|
|
|
applicationRelease.setUuid(resultSet.getString("UUID"));
|
|
|
|
|
|
|
|
applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE"));
|
|
|
|
|
|
|
|
applicationRelease.setPrice(resultSet.getDouble("APP_PRICE"));
|
|
|
|
|
|
|
|
applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION"));
|
|
|
|
|
|
|
|
applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION"));
|
|
|
|
|
|
|
|
applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1"));
|
|
|
|
|
|
|
|
applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2"));
|
|
|
|
|
|
|
|
applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3"));
|
|
|
|
|
|
|
|
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
|
|
|
|
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
|
|
|
|
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
|
|
|
|
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return applicationReleases;
|
|
|
|
return applicationReleases;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
+ "release details of the application with Name " + applicationName, e);
|
|
|
|
+ "release details of the application with app ID: " + applicationId, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
"Error while getting all the release details of the " + applicationName + " application"
|
|
|
|
"Error while getting all the release details of the app ID: " + applicationId
|
|
|
|
+ ", while executing the query " + sql, e);
|
|
|
|
+ ", while executing the query " + sql, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
@ -318,7 +284,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
|
|
|
|
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
|
|
|
|
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -338,15 +303,15 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To Update starts of an application release.
|
|
|
|
* To Update starts of an application release.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
* @param rating given stars for the application release.
|
|
|
|
* @param rating given stars for the application release.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public void updateRatingValue(String uuid, double rating, int ratedUsers)
|
|
|
|
public void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
String sql = "UPDATE AP_APP_RELEASE SET RATING = ? AND RATED_USERS = ? WHERE UUID = ?;";
|
|
|
|
String sql = "UPDATE AP_APP_RELEASE SET RATING = ?,RATED_USERS = ? WHERE UUID = ?;";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
@ -371,8 +336,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
@ -385,7 +349,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
statement.setInt(2, tenantId);
|
|
|
|
statement.setInt(2, tenantId);
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
if (resultSet.next()){
|
|
|
|
if (resultSet.next()) {
|
|
|
|
rating = new Rating();
|
|
|
|
rating = new Rating();
|
|
|
|
rating.setRatingValue(resultSet.getDouble("RATING"));
|
|
|
|
rating.setRatingValue(resultSet.getDouble("RATING"));
|
|
|
|
rating.setNoOfUsers(resultSet.getInt("RATED_USERS"));
|
|
|
|
rating.setNoOfUsers(resultSet.getInt("RATED_USERS"));
|
|
|
@ -408,18 +372,14 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
String sql =
|
|
|
|
String sql = "UPDATE AP_APP_RELEASE SET VERSION = ?, UUID = ?, RELEASE_TYPE = ?, PACKAGE_NAME = ?,"
|
|
|
|
"UPDATE AP_APP_RELEASE " +
|
|
|
|
+ " APP_PRICE = ?, STORED_LOCATION = ?, BANNER_LOCATION = ?, SC_1_LOCATION = ?, SC_2_LOCATION = ?,"
|
|
|
|
"SET VERSION = ? , UUID = ? , RELEASE_TYPE = ? , PACKAGE_NAME = ? " +
|
|
|
|
+ " SC_3_LOCATION = ?, APP_HASH_VALUE = ?, SHARED_WITH_ALL_TENANTS = ?, APP_META_INFO = ? "
|
|
|
|
", APP_PRICE = ? , STORED_LOCATION = ? , ICON_LOCATION = ? , BANNER_LOCATION = ? , " +
|
|
|
|
+ "WHERE AP_APP_ID = ? AND TENANT_ID = ? AND ID = ?;";
|
|
|
|
"SC_1_LOCATION = ? , SC_2_LOCATION = ? , SC_3_LOCATION = ? , APP_HASH_VALUE = ? " +
|
|
|
|
|
|
|
|
", SHARED_WITH_ALL_TENANTS = ? , APP_META_INFO = ? " +
|
|
|
|
|
|
|
|
"WHERE AP_APP_ID = ? AND TENANT_ID = ? AND ID = ?;";
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
@ -429,17 +389,16 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
statement.setString(4, applicationRelease.getPackageName());
|
|
|
|
statement.setString(4, applicationRelease.getPackageName());
|
|
|
|
statement.setDouble(5, applicationRelease.getPrice());
|
|
|
|
statement.setDouble(5, applicationRelease.getPrice());
|
|
|
|
statement.setString(6, applicationRelease.getAppStoredLoc());
|
|
|
|
statement.setString(6, applicationRelease.getAppStoredLoc());
|
|
|
|
statement.setString(7, applicationRelease.getIconLoc());
|
|
|
|
statement.setString(7, applicationRelease.getBannerLoc());
|
|
|
|
statement.setString(8, applicationRelease.getBannerLoc());
|
|
|
|
statement.setString(8, applicationRelease.getScreenshotLoc1());
|
|
|
|
statement.setString(9, applicationRelease.getScreenshotLoc1());
|
|
|
|
statement.setString(9, applicationRelease.getScreenshotLoc2());
|
|
|
|
statement.setString(10, applicationRelease.getScreenshotLoc2());
|
|
|
|
statement.setString(10, applicationRelease.getScreenshotLoc3());
|
|
|
|
statement.setString(11, applicationRelease.getScreenshotLoc3());
|
|
|
|
statement.setString(11, applicationRelease.getAppHashValue());
|
|
|
|
statement.setString(12, applicationRelease.getAppHashValue());
|
|
|
|
statement.setInt(12, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
statement.setInt(13, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
statement.setString(13, applicationRelease.getMetaData());
|
|
|
|
statement.setString(14, applicationRelease.getMetaData());
|
|
|
|
statement.setInt(14, applicationId);
|
|
|
|
statement.setInt(15, applicationId);
|
|
|
|
statement.setInt(15, tenantId);
|
|
|
|
statement.setInt(16, tenantId);
|
|
|
|
statement.setInt(16, applicationRelease.getId());
|
|
|
|
statement.setInt(17, applicationRelease.getId());
|
|
|
|
|
|
|
|
statement.executeUpdate();
|
|
|
|
statement.executeUpdate();
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
@ -456,12 +415,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To delete an application release.
|
|
|
|
* To delete an application release.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param id Id of the application Release.
|
|
|
|
* @param id Id of the application Release.
|
|
|
|
* @param version version name of the application release.
|
|
|
|
* @param version version name of the application release.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
String sql = "DELETE FROM AP_APP_RELEASE WHERE ID = ? AND VERSION = ?";
|
|
|
|
String sql = "DELETE FROM AP_APP_RELEASE WHERE ID = ? AND VERSION = ?";
|
|
|
@ -483,8 +441,46 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean verifyReleaseExistence(int appId, String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Verifying application release existence by application id:" + appId
|
|
|
|
|
|
|
|
+ " and application release uuid: " + uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
String sql =
|
|
|
|
|
|
|
|
"SELECT AR.ID AS RELEASE_ID FROM AP_APP_RELEASE AS AR WHERE AR.AP_APP_ID = ? AND AR.UUID = ? AND "
|
|
|
|
|
|
|
|
+ "AR.TENANT_ID = ?;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
|
|
|
|
stmt.setString(2, uuid);
|
|
|
|
|
|
|
|
stmt.setInt(3, tenantId);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Successfully retrieved basic details of the application release with the application ID "
|
|
|
|
|
|
|
|
+ appId + " Application release uuid: " + uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return rs.next();
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while getting application release details with app ID: " + appId
|
|
|
|
|
|
|
|
+ " App release uuid: " + uuid + " While executing query ", e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method is capable to construct {@link ApplicationRelease} and return the object
|
|
|
|
* This method is capable to construct {@link ApplicationRelease} and return the object
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param resultSet result set obtained from the query executing.
|
|
|
|
* @param resultSet result set obtained from the query executing.
|
|
|
|
* @throws SQLException SQL exception while accessing result set data.
|
|
|
|
* @throws SQLException SQL exception while accessing result set data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -505,9 +501,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
|
|
|
|
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
|
|
|
|
|
|
|
|
return applicationRelease;
|
|
|
|
return applicationRelease;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|