|
|
|
@ -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.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.Rating;
|
|
|
|
|
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.common.Util;
|
|
|
|
|
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 java.sql.Connection;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -47,7 +43,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(GenericApplicationReleaseDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* To insert the Application Release Details.
|
|
|
|
|
*
|
|
|
|
@ -56,18 +51,15 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId) throws
|
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
@Override public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
|
|
|
|
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, " +
|
|
|
|
|
"APP_HASH_VALUE,"
|
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,CREATED_BY,AP_APP_ID) "
|
|
|
|
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?);";
|
|
|
|
|
+ "STORED_LOCATION, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, APP_HASH_VALUE,"
|
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
String generatedColumns[] = { "ID" };
|
|
|
|
@ -89,7 +81,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
statement.setString(++index, applicationRelease.getAppHashValue());
|
|
|
|
|
statement.setInt(++index, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
|
statement.setString(++index, applicationRelease.getMetaData());
|
|
|
|
|
statement.setString(++index, applicationRelease.getApplicationCreator());
|
|
|
|
|
statement.setInt(++index, appId);
|
|
|
|
|
statement.executeUpdate();
|
|
|
|
|
resultSet = statement.getGeneratedKeys();
|
|
|
|
@ -109,7 +100,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 applicationType Type of the application.
|
|
|
|
@ -118,23 +109,21 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
|
@Override public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
|
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, "
|
|
|
|
|
+ "AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, AR.BANNER_LOCATION, "
|
|
|
|
|
+ "AR.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 HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
|
|
|
|
+ "AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, "
|
|
|
|
|
+ "AL.CURRENT_STATE, AL.PREVIOUSE_STATE, AL.UPDATED_BY, AL.UPDATED_AT FROM "
|
|
|
|
|
+ "AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE "
|
|
|
|
|
+ "AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME=? AND TYPE=? AND TENANT_ID=?) "
|
|
|
|
|
+ "AND AR.VERSION=? AND AR.RELEASE_TYPE=? AND AL.AP_APP_RELEASE_ID=AR.ID "
|
|
|
|
|
+ "AND AL.TENANT_ID=AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID AS UUID, AR.RELEASE_TYPE AS "
|
|
|
|
|
+ "RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE AS APP_PRICE, AR.STORED_LOCATION AS "
|
|
|
|
|
+ "STORED_LOCATION, AR.BANNER_LOCATION AS BANNER_LOCATION, AR.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 "
|
|
|
|
|
+ "HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO AS APP_META_INFO , "
|
|
|
|
|
+ "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 AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE "
|
|
|
|
|
+ "NAME=? AND TYPE=? AND TENANT_ID=?) AND AR.VERSION=? AND AR.RELEASE_TYPE=? AND "
|
|
|
|
|
+ "AL.AP_APP_RELEASE_ID=AR.ID AND AL.TENANT_ID=AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
@ -152,11 +141,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
return null;
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
|
+ "release details of the application with " + applicationName + " and version " +
|
|
|
|
|
versionName, e);
|
|
|
|
|
+ "release details of the application with " + applicationName + " and version " + versionName, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error while getting release details of the application " +
|
|
|
|
|
applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error while getting release details of the application " + applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
|
}
|
|
|
|
@ -170,21 +158,21 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws
|
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
@Override public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.PACKAGE_NAME, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR" +
|
|
|
|
|
".RELEASE_TYPE, AR.APP_PRICE, AR.STORED_LOCATION, AR.ICON_LOCATION, AR.BANNER_LOCATION, AR" +
|
|
|
|
|
".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 " +
|
|
|
|
|
"HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR" +
|
|
|
|
|
".PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AL.CURRENT_STATE, AL.PREVIOUSE_STATE, AL.UPDATED_BY, " +
|
|
|
|
|
"AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL 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;";
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE, "
|
|
|
|
|
+ "AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
|
|
|
|
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.PACKAGE_NAME AS "
|
|
|
|
|
+ "PACKAGE_NAME, AR.APP_HASH_VALUE AS HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
|
|
|
|
+ "AR.APP_META_INFO AS APP_META_INFO, 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 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 {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
@ -200,14 +188,12 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
return null;
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Database connection exception while trying to get the release details of the " +
|
|
|
|
|
"application id: " + applicationId + "and UUID of the application release: " +
|
|
|
|
|
releaseUuid, e);
|
|
|
|
|
"Database connection exception while trying to get the release details of the " + "application id: "
|
|
|
|
|
+ applicationId + "and UUID of the application release: " + releaseUuid, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error while getting release details of the application id: " + applicationId +
|
|
|
|
|
" and theUUID of the application " +
|
|
|
|
|
"release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
|
"Error while getting release details of the application id: " + applicationId
|
|
|
|
|
+ " and theUUID of the application " + "release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
|
}
|
|
|
|
@ -216,62 +202,42 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
/**
|
|
|
|
|
* To insert the application release properties.
|
|
|
|
|
*
|
|
|
|
|
* @param applicationName Name of the application.
|
|
|
|
|
* @param applicationType Type of the application.
|
|
|
|
|
* @param applicationId Id of the application.
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<ApplicationRelease> getReleases(String applicationName, String applicationType, int tenantId)
|
|
|
|
|
@Override public List<ApplicationRelease> getReleases(int applicationId, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
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,"
|
|
|
|
|
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.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 HASH_VALUE, "
|
|
|
|
|
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, "
|
|
|
|
|
+ "AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AR.RATING FROM AP_APP_RELEASE AS "
|
|
|
|
|
+ "AR where AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME = ? AND TYPE = ? "
|
|
|
|
|
+ "AND TENANT_ID = ?) AND AR.TENANT_ID = ? ;";
|
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE "
|
|
|
|
|
+ "AS RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, "
|
|
|
|
|
+ "AR.BANNER_LOCATION, AR.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 HASH_VALUE, "
|
|
|
|
|
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO AS APP_META_INFO, "
|
|
|
|
|
+ "AR.RATING AS RATING FROM AP_APP_RELEASE AS AR where AR.AP_APP_ID=? AND AR.TENANT_ID = ?;";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
|
statement.setString(1, applicationName);
|
|
|
|
|
statement.setString(2, applicationType);
|
|
|
|
|
statement.setInt(3, tenantId);
|
|
|
|
|
statement.setInt(4, tenantId);
|
|
|
|
|
statement.setInt(1, applicationId);
|
|
|
|
|
statement.setInt(2, tenantId);
|
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
|
|
|
|
|
|
while (resultSet.next()) {
|
|
|
|
|
ApplicationRelease applicationRelease = new ApplicationRelease();
|
|
|
|
|
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"));
|
|
|
|
|
ApplicationRelease applicationRelease = constructApplicationRelease(resultSet);
|
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return applicationReleases;
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
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) {
|
|
|
|
|
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);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
@ -318,7 +284,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
@ -342,11 +307,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param rating given stars for the application release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public void updateRatingValue(String uuid, double rating, int ratedUsers)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
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 {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
@ -371,8 +336,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
@ -408,18 +372,14 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
|
@Override public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
String sql =
|
|
|
|
|
"UPDATE AP_APP_RELEASE " +
|
|
|
|
|
"SET VERSION = ? , UUID = ? , RELEASE_TYPE = ? , PACKAGE_NAME = ? " +
|
|
|
|
|
", APP_PRICE = ? , STORED_LOCATION = ? , ICON_LOCATION = ? , BANNER_LOCATION = ? , " +
|
|
|
|
|
"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 = ?;";
|
|
|
|
|
String sql = "UPDATE AP_APP_RELEASE SET VERSION = ?, UUID = ?, RELEASE_TYPE = ?, PACKAGE_NAME = ?,"
|
|
|
|
|
+ " APP_PRICE = ?, STORED_LOCATION = ?, BANNER_LOCATION = ?, 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 {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
@ -429,17 +389,16 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
statement.setString(4, applicationRelease.getPackageName());
|
|
|
|
|
statement.setDouble(5, applicationRelease.getPrice());
|
|
|
|
|
statement.setString(6, applicationRelease.getAppStoredLoc());
|
|
|
|
|
statement.setString(7, applicationRelease.getIconLoc());
|
|
|
|
|
statement.setString(8, applicationRelease.getBannerLoc());
|
|
|
|
|
statement.setString(9, applicationRelease.getScreenshotLoc1());
|
|
|
|
|
statement.setString(10, applicationRelease.getScreenshotLoc2());
|
|
|
|
|
statement.setString(11, applicationRelease.getScreenshotLoc3());
|
|
|
|
|
statement.setString(12, applicationRelease.getAppHashValue());
|
|
|
|
|
statement.setInt(13, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
|
statement.setString(14, applicationRelease.getMetaData());
|
|
|
|
|
statement.setInt(15, applicationId);
|
|
|
|
|
statement.setInt(16, tenantId);
|
|
|
|
|
statement.setInt(17, applicationRelease.getId());
|
|
|
|
|
statement.setString(7, applicationRelease.getBannerLoc());
|
|
|
|
|
statement.setString(8, applicationRelease.getScreenshotLoc1());
|
|
|
|
|
statement.setString(9, applicationRelease.getScreenshotLoc2());
|
|
|
|
|
statement.setString(10, applicationRelease.getScreenshotLoc3());
|
|
|
|
|
statement.setString(11, applicationRelease.getAppHashValue());
|
|
|
|
|
statement.setInt(12, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
|
statement.setString(13, applicationRelease.getMetaData());
|
|
|
|
|
statement.setInt(14, applicationId);
|
|
|
|
|
statement.setInt(15, tenantId);
|
|
|
|
|
statement.setInt(16, applicationRelease.getId());
|
|
|
|
|
statement.executeUpdate();
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
@ -460,8 +419,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param version version name of the application release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
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
|
|
|
|
|
*
|
|
|
|
|
* @param resultSet result set obtained from the query executing.
|
|
|
|
|
* @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.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
|
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
|
|
|
|
|
|
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
|
return applicationRelease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|