mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
partial fix on app update apis
This commit is contained in:
parent
69e172cffc
commit
4e7f1e4047
@ -84,17 +84,6 @@ public interface ApplicationDAO {
|
|||||||
*/
|
*/
|
||||||
Application getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException;
|
Application getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* To get the application with the given id
|
|
||||||
*
|
|
||||||
* @param id ID of the application.
|
|
||||||
* @param tenantId ID of the tenant.
|
|
||||||
* @return the application
|
|
||||||
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
||||||
*/
|
|
||||||
Application getApplicationById(String id, int tenantId) throws
|
|
||||||
ApplicationManagementDAOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the application with the given uuid
|
* To get the application with the given uuid
|
||||||
*
|
*
|
||||||
|
|||||||
@ -67,6 +67,18 @@ public interface ApplicationReleaseDAO {
|
|||||||
List<ApplicationRelease> getReleases(String applicationName, String applicationType, int tenantId) throws
|
List<ApplicationRelease> getReleases(String applicationName, String applicationType, int tenantId) throws
|
||||||
ApplicationManagementDAOException;
|
ApplicationManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the release by state.
|
||||||
|
*
|
||||||
|
* @param appId Id of the Application
|
||||||
|
* @param tenantId tenant id of the application
|
||||||
|
* @param state state of the application
|
||||||
|
* @return list of the application releases
|
||||||
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
||||||
|
*/
|
||||||
|
List<ApplicationRelease> getReleaseByState(int appId, int tenantId, String state)
|
||||||
|
throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To update an Application release.
|
* To update an Application release.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -21,13 +21,18 @@ package org.wso2.carbon.device.application.mgt.core.dao.common;
|
|||||||
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.json.JSONException;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.application.mgt.common.*;
|
import org.wso2.carbon.device.application.mgt.common.*;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Application;
|
import org.wso2.carbon.device.application.mgt.common.Application;
|
||||||
import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
|
import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.config.Configuration;
|
import org.wso2.carbon.device.application.mgt.core.config.Configuration;
|
||||||
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -131,19 +136,20 @@ public class Util {
|
|||||||
application.setSubType(rs.getString("SUB_TYPE"));
|
application.setSubType(rs.getString("SUB_TYPE"));
|
||||||
application.setPaymentCurrency(rs.getString("CURRENCY"));
|
application.setPaymentCurrency(rs.getString("CURRENCY"));
|
||||||
application.setIsRestricted(rs.getBoolean("RESTRICTED"));
|
application.setIsRestricted(rs.getBoolean("RESTRICTED"));
|
||||||
|
application.setDeviceTypeId(rs.getInt("DEVICE_TYPE_ID"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag tag = new Tag();
|
// Tag tag = new Tag();
|
||||||
tag.setTagName(rs.getString("APP_TAG"));
|
// tag.setTagName(rs.getString("APP_TAG"));
|
||||||
UnrestrictedRole unrestrictedRole = new UnrestrictedRole();
|
// UnrestrictedRole unrestrictedRole = new UnrestrictedRole();
|
||||||
unrestrictedRole.setRole(rs.getString("ROLE"));
|
// unrestrictedRole.setRole(rs.getString("ROLE"));
|
||||||
if (application.getTags() != null && application.getTags().contains(tag)) {
|
// if (application.getTags() != null && application.getTags().contains(tag)) {
|
||||||
application.getTags().add(tag);
|
// application.getTags().add(tag);
|
||||||
}
|
// }
|
||||||
if (application.getUnrestrictedRoles() != null && application.getUnrestrictedRoles()
|
// if (application.getUnrestrictedRoles() != null && application.getUnrestrictedRoles()
|
||||||
.contains(unrestrictedRole)) {
|
// .contains(unrestrictedRole)) {
|
||||||
application.getUnrestrictedRoles().add(unrestrictedRole);
|
// application.getUnrestrictedRoles().add(unrestrictedRole);
|
||||||
}
|
// }
|
||||||
iteration++;
|
iteration++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,4 +223,84 @@ public class Util {
|
|||||||
}
|
}
|
||||||
return paginationRequest;
|
return paginationRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ApplicationManager applicationManager;
|
||||||
|
private static ApplicationStorageManager applicationStorageManager;
|
||||||
|
private static SubscriptionManager subscriptionManager;
|
||||||
|
|
||||||
|
public static ApplicationManager getApplicationManager() {
|
||||||
|
if (applicationManager == null) {
|
||||||
|
synchronized (Util.class) {
|
||||||
|
if (applicationManager == null) {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
applicationManager =
|
||||||
|
(ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
||||||
|
if (applicationManager == null) {
|
||||||
|
String msg = "Application Manager service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return applicationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the Application Storage Manager from the osgi context.
|
||||||
|
* @return ApplicationStoreManager instance in the current osgi context.
|
||||||
|
*/
|
||||||
|
public static ApplicationStorageManager getApplicationStorageManager() {
|
||||||
|
if (applicationStorageManager == null) {
|
||||||
|
synchronized (Util.class) {
|
||||||
|
if (applicationStorageManager == null) {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
applicationStorageManager = (ApplicationStorageManager) ctx
|
||||||
|
.getOSGiService(ApplicationStorageManager.class, null);
|
||||||
|
if (applicationStorageManager == null) {
|
||||||
|
String msg = "Application Storage Manager service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return applicationStorageManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the Subscription Manager from the osgi context.
|
||||||
|
* @return SubscriptionManager instance in the current osgi context.
|
||||||
|
*/
|
||||||
|
public static SubscriptionManager getSubscriptionManager() {
|
||||||
|
if (subscriptionManager == null) {
|
||||||
|
synchronized (Util.class) {
|
||||||
|
if (subscriptionManager == null) {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
subscriptionManager =
|
||||||
|
(SubscriptionManager) ctx.getOSGiService(SubscriptionManager.class, null);
|
||||||
|
if (subscriptionManager == null) {
|
||||||
|
String msg = "Subscription Manager service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return subscriptionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
if (deviceManagementProviderService == null) {
|
||||||
|
String msg = "DeviceImpl Management provider service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -337,48 +337,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getApplicationById(String id, int tenantId) throws
|
|
||||||
ApplicationManagementDAOException {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Getting application with the id:" + id);
|
|
||||||
}
|
|
||||||
Connection conn;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
conn = this.getDBConnection();
|
|
||||||
String sql =
|
|
||||||
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
||||||
+ "AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE ,AP_APP.CURRENCY AS CURRENCY,"
|
|
||||||
+ " AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLE.ROLE "
|
|
||||||
+ "AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLE WHERE AP_APP.NAME=? AND "
|
|
||||||
+ "AP_APP.APP_ID= ? AND AP_APP.TENANT_ID=?;";
|
|
||||||
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
stmt.setString(1, id);
|
|
||||||
stmt.setInt(2, tenantId);
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Successfully retrieved basic details of the application with the id:" + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Util.loadApplication(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new ApplicationManagementDAOException(
|
|
||||||
"Error occurred while getting application details with app id " + id +
|
|
||||||
" While executing query ", e);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
|
|
||||||
} catch (DBConnectionException e) {
|
|
||||||
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
||||||
} finally {
|
|
||||||
Util.cleanupResources(stmt, rs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application getApplicationById(int applicationId, int tenantId) throws
|
public Application getApplicationById(int applicationId, int tenantId) throws
|
||||||
ApplicationManagementDAOException {
|
ApplicationManagementDAOException {
|
||||||
@ -391,11 +349,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
try {
|
try {
|
||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, " +
|
||||||
+ "AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE ,AP_APP.CURRENCY AS CURRENCY, "
|
"AP_APP.APP_CATEGORY AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE ," +
|
||||||
+ "AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLE.ROLE "
|
"AP_APP.CURRENCY AS CURRENCY, AP_APP.RESTRICTED AS RESTRICTED, " +
|
||||||
+ "AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLE WHERE AP_APP.ID=? AND "
|
"DM_DEVICE_TYPE_ID AS DEVICE_TYPE_ID " +
|
||||||
+ "AP_APP.TENANT_ID=?;";
|
"FROM AP_APP " +
|
||||||
|
"WHERE AP_APP.ID=? AND AP_APP.TENANT_ID=?;";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, applicationId);
|
stmt.setInt(1, applicationId);
|
||||||
|
|||||||
@ -64,9 +64,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
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, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, APP_HASH_VALUE,"
|
+ "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) "
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,CREATED_BY,AP_APP_ID) "
|
||||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?);";
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?);";
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
String generatedColumns[] = {"ID"};
|
String generatedColumns[] = {"ID"};
|
||||||
@ -80,6 +81,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
statement.setString(++index, String.valueOf(applicationRelease.getPackageName()));
|
statement.setString(++index, String.valueOf(applicationRelease.getPackageName()));
|
||||||
statement.setDouble(++index, applicationRelease.getPrice());
|
statement.setDouble(++index, applicationRelease.getPrice());
|
||||||
statement.setString(++index, applicationRelease.getAppStoredLoc());
|
statement.setString(++index, applicationRelease.getAppStoredLoc());
|
||||||
|
statement.setString(++index, applicationRelease.getIconLoc());
|
||||||
statement.setString(++index, applicationRelease.getBannerLoc());
|
statement.setString(++index, applicationRelease.getBannerLoc());
|
||||||
statement.setString(++index, applicationRelease.getScreenshotLoc1());
|
statement.setString(++index, applicationRelease.getScreenshotLoc1());
|
||||||
statement.setString(++index, applicationRelease.getScreenshotLoc2());
|
statement.setString(++index, applicationRelease.getScreenshotLoc2());
|
||||||
@ -123,7 +125,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
Connection connection;
|
Connection connection;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
String sql = "SELECT AR.ID AS RELESE_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, AR.RELEASE_TYPE, "
|
||||||
+ "AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, AR.BANNER_LOCATION, "
|
+ "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 "
|
+ "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, "
|
+ "SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
||||||
@ -175,9 +177,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
Connection connection;
|
Connection connection;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
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.PACKAGE_NAME, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR" +
|
||||||
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
".RELEASE_TYPE, AR.APP_PRICE, AR.STORED_LOCATION, AR.ICON_LOCATION, AR.BANNER_LOCATION, AR" +
|
||||||
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS " +
|
".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" +
|
"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, " +
|
".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 " +
|
"AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE " +
|
||||||
@ -276,6 +278,63 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ApplicationRelease> getReleaseByState(int appId, int tenantId, String state) throws
|
||||||
|
ApplicationManagementDAOException {
|
||||||
|
Connection connection;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
||||||
|
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.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, AR.RATING FROM AP_APP_RELEASE AS "
|
||||||
|
+ "AR where AR.TENANT_ID = ? AND AR.AP_APP_ID=(SELECT AP_APP_ID" +
|
||||||
|
" FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_ID = ? AND CURRENT_STATE = ? AND TENANT_ID = ?);";
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = this.getDBConnection();
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
statement.setInt(1, tenantId);
|
||||||
|
statement.setInt(2, appId);
|
||||||
|
statement.setString(3, state);
|
||||||
|
statement.setInt(4, tenantId);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
ApplicationRelease applicationRelease = new ApplicationRelease();
|
||||||
|
applicationRelease.setId(resultSet.getInt("RELEASE_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.setIconLoc(resultSet.getString("ICON_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);
|
||||||
|
}
|
||||||
|
return applicationReleases;
|
||||||
|
} catch (DBConnectionException e) {
|
||||||
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
||||||
|
+ "release details of the application with id " + appId, e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new ApplicationManagementDAOException(
|
||||||
|
"Error while getting all the release details of the app id" + appId + " application"
|
||||||
|
+ ", while executing the query " + sql, e);
|
||||||
|
} finally {
|
||||||
|
Util.cleanupResources(statement, resultSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Update starts of an application release.
|
* To Update starts of an application release.
|
||||||
*
|
*
|
||||||
@ -354,11 +413,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
throws ApplicationManagementDAOException {
|
throws ApplicationManagementDAOException {
|
||||||
Connection connection;
|
Connection connection;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
String sql = "UPDATE AP_APP_RELEASE SET VERSION = ? AND UUID = ? AND RELEASE_TYPE = ? AND PACKAGE_NAME = ? "
|
String sql =
|
||||||
+ "AND APP_PRICE = ? AND STORED_LOCATION = ? AND BANNER_LOCATION = ? AND SC_1_LOCATION = ? "
|
"UPDATE AP_APP_RELEASE " +
|
||||||
+ "AND SC_2_LOCATION = ? AND SC_3_LOCATION = ? AND APP_HASH_VALUE = ? AND SHARED_WITH_ALL_TENANTS = ? "
|
"SET VERSION = ? , UUID = ? , RELEASE_TYPE = ? , PACKAGE_NAME = ? " +
|
||||||
+ "AND APP_META_INFO = ? AND CREATED_BY = ? AND CREATED_AT = ? WHERE AP_APP_ID = ? AND TENANT_ID = ? "
|
", APP_PRICE = ? , STORED_LOCATION = ? , ICON_LOCATION = ? , BANNER_LOCATION = ? , " +
|
||||||
+ "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);
|
||||||
@ -368,15 +429,17 @@ 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.getBannerLoc());
|
statement.setString(7, applicationRelease.getIconLoc());
|
||||||
statement.setString(8, applicationRelease.getScreenshotLoc1());
|
statement.setString(8, applicationRelease.getBannerLoc());
|
||||||
statement.setString(9, applicationRelease.getScreenshotLoc2());
|
statement.setString(9, applicationRelease.getScreenshotLoc1());
|
||||||
statement.setString(10, applicationRelease.getScreenshotLoc3());
|
statement.setString(10, applicationRelease.getScreenshotLoc2());
|
||||||
statement.setString(11, applicationRelease.getAppHashValue());
|
statement.setString(11, applicationRelease.getScreenshotLoc3());
|
||||||
statement.setInt(12, applicationRelease.getIsSharedWithAllTenants());
|
statement.setString(12, applicationRelease.getAppHashValue());
|
||||||
statement.setString(13, applicationRelease.getMetaData());
|
statement.setInt(13, applicationRelease.getIsSharedWithAllTenants());
|
||||||
statement.setString(14, applicationRelease.getApplicationCreator());
|
statement.setString(14, applicationRelease.getMetaData());
|
||||||
statement.setTimestamp(15, new Timestamp(System.currentTimeMillis()));
|
statement.setInt(15, applicationId);
|
||||||
|
statement.setInt(16, tenantId);
|
||||||
|
statement.setInt(17, applicationRelease.getId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
throw new ApplicationManagementDAOException(
|
throw new ApplicationManagementDAOException(
|
||||||
@ -435,6 +498,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
applicationRelease.setPrice(resultSet.getDouble("APP_PRICE"));
|
applicationRelease.setPrice(resultSet.getDouble("APP_PRICE"));
|
||||||
applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION"));
|
applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION"));
|
||||||
applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION"));
|
applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION"));
|
||||||
|
applicationRelease.setIconLoc(resultSet.getString("ICON_LOCATION"));
|
||||||
applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1"));
|
applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1"));
|
||||||
applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2"));
|
applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2"));
|
||||||
applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3"));
|
applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3"));
|
||||||
@ -442,7 +506,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
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.setApplicationCreator(resultSet.getString("CREATED_BY"));
|
||||||
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
||||||
|
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.application.mgt.core.exception;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom exception class for wrapping BadRequest related exceptions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BadRequestException extends ApplicationManagementException {
|
||||||
|
|
||||||
|
public BadRequestException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BadRequestException(String message) {
|
||||||
|
setMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.application.mgt.core.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception class that is corresponding to 401 Forbidden response
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ForbiddenException extends ApplicationManagementException {
|
||||||
|
|
||||||
|
public ForbiddenException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForbiddenException(String message) {
|
||||||
|
setMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.application.mgt.core.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
public class UnexpectedServerErrorException extends ApplicationManagementException {
|
||||||
|
|
||||||
|
public UnexpectedServerErrorException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnexpectedServerErrorException(String message) {
|
||||||
|
setMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -31,18 +31,21 @@ import org.wso2.carbon.device.application.mgt.common.ApplicationSubscriptionType
|
|||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Filter;
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
||||||
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
||||||
import org.wso2.carbon.device.application.mgt.common.SortingOrder;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.Tag;
|
import org.wso2.carbon.device.application.mgt.common.Tag;
|
||||||
import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole;
|
import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole;
|
||||||
import org.wso2.carbon.device.application.mgt.common.User;
|
import org.wso2.carbon.device.application.mgt.common.User;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
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.common.exception.RequestValidatingException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
||||||
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.LifecycleStateDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
||||||
@ -51,7 +54,6 @@ import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
|
|||||||
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
import org.wso2.carbon.user.api.UserRealm;
|
import org.wso2.carbon.user.api.UserRealm;
|
||||||
@ -59,6 +61,7 @@ import org.wso2.carbon.user.api.UserStoreException;
|
|||||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -277,18 +280,20 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application getApplicationById(int id) throws ApplicationManagementException {
|
public Application getApplicationById(int appId, String state, boolean handleConnections) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
Application application;
|
Application application;
|
||||||
boolean isAppAllowed = false;
|
boolean isAppAllowed = false;
|
||||||
List<ApplicationRelease> applicationReleases;
|
List<ApplicationRelease> applicationReleases = null;
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
if (handleConnections) {
|
||||||
|
ConnectionManagerUtil.openDBConnection();
|
||||||
|
}
|
||||||
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
||||||
.getApplicationById(id, tenantId);
|
.getApplicationById(appId, tenantId);
|
||||||
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
||||||
applicationReleases = getReleases(application.getId());
|
applicationReleases = getReleaseInState(appId, state);
|
||||||
application.setApplicationReleases(applicationReleases);
|
application.setApplicationReleases(applicationReleases);
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
@ -305,14 +310,18 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationReleases = getReleases(application.getId());
|
if (state != null) {
|
||||||
|
applicationReleases = getReleaseInState(appId, state);
|
||||||
|
}
|
||||||
application.setApplicationReleases(applicationReleases);
|
application.setApplicationReleases(applicationReleases);
|
||||||
return application;
|
return application;
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"User-store exception while getting application with the application id " + id);
|
"User-store exception while getting application with the application id " + appId);
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
if (handleConnections) {
|
||||||
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +462,20 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ApplicationRelease> getReleaseInState(int applicationId, String state) throws
|
||||||
|
ApplicationManagementException {
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
|
|
||||||
|
Application application = getApplicationIfAccessible(applicationId);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Request is received to retrieve all the releases related with the application " + application
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
ConnectionManagerUtil.getDBConnection();
|
||||||
|
return this.applicationReleaseDAO.getReleaseByState(applicationId, tenantId, state);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> deleteApplication(int applicationId) throws ApplicationManagementException {
|
public List<String> deleteApplication(int applicationId) throws ApplicationManagementException {
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
@ -648,7 +671,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
* @param applicationUuid UUID of the Application.
|
* @param applicationUuid UUID of the Application.
|
||||||
* @return Application related with the UUID
|
* @return Application related with the UUID
|
||||||
*/
|
*/
|
||||||
public ApplicationRelease getAppReleaseIfExists(int applicationId, String applicationUuid) throws
|
private ApplicationRelease getAppReleaseIfExists(int applicationId, String applicationUuid) throws
|
||||||
ApplicationManagementException {
|
ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
ApplicationRelease applicationRelease;
|
ApplicationRelease applicationRelease;
|
||||||
@ -662,19 +685,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
||||||
+ "parameter to get the relevant application.");
|
+ "parameter to get the relevant application.");
|
||||||
}
|
}
|
||||||
ConnectionManagerUtil.getDBConnection();
|
|
||||||
applicationRelease = this.applicationReleaseDAO.getReleaseByIds(applicationId, applicationUuid, tenantId);
|
applicationRelease = this.applicationReleaseDAO.getReleaseByIds(applicationId, applicationUuid, tenantId);
|
||||||
if (applicationRelease == null) {
|
if (applicationRelease == null) {
|
||||||
throw new ApplicationManagementException("Doesn't exist a application release for application ID: " +
|
log.error("Doesn't exist a application release for application ID: " + applicationId
|
||||||
applicationId + "and application UUID: " +
|
+ "and application UUID: " + applicationUuid);
|
||||||
applicationUuid);
|
|
||||||
}
|
}
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease) throws
|
||||||
public ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease) throws
|
|
||||||
ApplicationManagementException {
|
ApplicationManagementException {
|
||||||
validateAppReleasePayload(applicationRelease);
|
validateAppReleasePayload(applicationRelease);
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
@ -682,9 +702,57 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
log.debug("Updating the Application release. UUID: " + applicationRelease.getUuid() + ", " +
|
log.debug("Updating the Application release. UUID: " + applicationRelease.getUuid() + ", " +
|
||||||
"Application Id: " + appId);
|
"Application Id: " + appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applicationRelease = this.applicationReleaseDAO.updateRelease(appId, applicationRelease, tenantId);
|
||||||
|
return applicationRelease;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationRelease updateApplicationImageArtifact(int appId, String uuid, InputStream iconFileStream, InputStream
|
||||||
|
bannerFileStream, List<InputStream> attachments)
|
||||||
|
throws ApplicationManagementException, ResourceManagementException {
|
||||||
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
||||||
|
ApplicationRelease applicationRelease;
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.getDBConnection();
|
||||||
applicationRelease = this.applicationReleaseDAO.updateRelease(appId, applicationRelease, tenantId);
|
applicationRelease = getAppReleaseIfExists(appId, uuid);
|
||||||
|
if (applicationRelease == null) {
|
||||||
|
throw new NotFoundException("No App release associated with the app Id " + appId + "and UUID "+ uuid);
|
||||||
|
}
|
||||||
|
applicationStorageManager
|
||||||
|
.updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
||||||
|
updateRelease(appId, applicationRelease);
|
||||||
|
return applicationRelease;
|
||||||
|
} finally {
|
||||||
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationRelease updateApplicationArtifact(int appId, String uuid, InputStream binaryFile)
|
||||||
|
throws ApplicationManagementException, ResourceManagementException, RequestValidatingException, DeviceManagementException {
|
||||||
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
||||||
|
ApplicationRelease applicationRelease;
|
||||||
|
try {
|
||||||
|
ConnectionManagerUtil.getDBConnection();
|
||||||
|
applicationRelease = getAppReleaseIfExists(appId, uuid);
|
||||||
|
|
||||||
|
Application application = getApplicationById(appId, null, false);
|
||||||
|
|
||||||
|
List<DeviceType> deviceTypes = Util.getDeviceManagementService().getDeviceTypes();
|
||||||
|
for (DeviceType deviceType:deviceTypes) {
|
||||||
|
if (deviceType.getId() == application.getDeviceTypeId()) {
|
||||||
|
application.setDeviceType(deviceType.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (applicationRelease == null) {
|
||||||
|
throw new NotFoundException("No App release associated with the app Id " + appId + "and UUID "+ uuid);
|
||||||
|
}
|
||||||
|
applicationStorageManager
|
||||||
|
.updateReleaseArtifacts(applicationRelease, application.getType(), application.getDeviceType(),
|
||||||
|
binaryFile);
|
||||||
|
updateRelease(appId, applicationRelease);
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
@ -762,8 +830,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
throw new ApplicationManagementException("Failed to get lifecycle state", e);
|
throw new ApplicationManagementException("Failed to get lifecycle state", e);
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
throw new ApplicationManagementException("Failed to get application and application management", e);
|
throw new ApplicationManagementException("Failed to get application and application management", e);
|
||||||
} finally {
|
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
|
||||||
}
|
}
|
||||||
return lifecycleState;
|
return lifecycleState;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,8 +133,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream,
|
public void updateImageArtifacts(ApplicationRelease applicationRelease, InputStream
|
||||||
InputStream bannerFileStream, List<InputStream> screenShotStreams)
|
iconFileStream, InputStream bannerFileStream, List<InputStream> screenShotStreams)
|
||||||
throws ResourceManagementException {
|
throws ResourceManagementException {
|
||||||
|
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
@ -164,9 +164,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uploadImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, screenShotStreams);
|
|
||||||
} catch (ApplicationStorageManagementException e) {
|
} catch (ApplicationStorageManagementException e) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
|
||||||
throw new ApplicationStorageManagementException("Application Storage exception while trying to"
|
throw new ApplicationStorageManagementException("Application Storage exception while trying to"
|
||||||
+ " update the screen-shot count for the application Release " + applicationRelease.getUuid() +
|
+ " update the screen-shot count for the application Release " + applicationRelease.getUuid() +
|
||||||
" for the tenant " + tenantId, e);
|
" for the tenant " + tenantId, e);
|
||||||
@ -235,7 +233,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
+ applicationRelease.getUuid(), e);
|
+ applicationRelease.getUuid(), e);
|
||||||
} catch (ParsingException e) {
|
} catch (ParsingException e) {
|
||||||
throw new ApplicationStorageManagementException(
|
throw new ApplicationStorageManagementException(
|
||||||
"Error occured while parsing the artifact file. Application release UUID is " + applicationRelease
|
"Error occurred while parsing the artifact file. Application release UUID is " + applicationRelease
|
||||||
.getUuid(), e);
|
.getUuid(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +293,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException {
|
public void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException {
|
||||||
String artifactPath = storagePath + directoryPath;
|
File artifact = new File(directoryPath);
|
||||||
File artifact = new File(artifactPath);
|
|
||||||
|
|
||||||
if (artifact.exists()) {
|
if (artifact.exists()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user