Minor fixes to mysql script and refactoring

feature/appm-store/pbac
megala21 7 years ago
parent 17c23b9674
commit 053008932d

@ -433,6 +433,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@Override @Override
@GET @GET
@Path("/image-artifacts/{uuid}") @Path("/image-artifacts/{uuid}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID, public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID,
@QueryParam("name") String name, @QueryParam("count") int count) { @QueryParam("name") String name, @QueryParam("count") int count) {
if (name == null || name.isEmpty()) { if (name == null || name.isEmpty()) {

@ -25,7 +25,7 @@ import java.util.List;
/** /**
* ApplicationReleaseManager is responsible for handling all the operations related with * ApplicationReleaseManager is responsible for handling all the operations related with
* {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updation , * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updating ,
* deletion and viewing. * deletion and viewing.
* *
*/ */

@ -27,7 +27,6 @@ import org.wso2.carbon.device.application.mgt.common.Lifecycle;
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.Platform; import org.wso2.carbon.device.application.mgt.common.Platform;
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.core.util.JSONUtil;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;

@ -181,11 +181,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
applicationList.setApplications(applications); applicationList.setApplications(applications);
applicationList.setPagination(pagination); applicationList.setPagination(pagination);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application List", e); throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant"
+ " " + tenantId + ". While executing " + sql, e);
} catch (JSONException e) { } catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); throw new ApplicationManagementDAOException("Error occurred while parsing JSON, while getting application"
+ " list for the tenant " + tenantId, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection while "
+ "getting application list for the tenant " + tenantId, e);
} finally { } finally {
Util.cleanupResources(stmt, rs); Util.cleanupResources(stmt, rs);
} }
@ -385,7 +388,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
statement.setInt(1, count); statement.setInt(1, count);
statement.setString(2, applicationUUID); statement.setString(2, applicationUUID);
statement.setInt(3, tenantId); statement.setInt(3, tenantId);
statement.executeUpdate();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot " throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot "
+ "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId); + "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId);

@ -96,20 +96,25 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count); DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count - 1);
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.commitDBTransaction();
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Transaction Management exception while trying to " throw new ApplicationStorageManagementException("Transaction Management exception while trying to "
+ "update the screen-shot count of the application " + applicationUUID + " for the tenant " + "update the screen-shot count of the application " + applicationUUID + " for the tenant "
+ tenantId, e); + tenantId, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Database connection management exception while " throw new ApplicationStorageManagementException("Database connection management exception while "
+ "trying to update the screen-shot count for the application " + applicationUUID + " for the" + "trying to update the screen-shot count for the application " + applicationUUID + " for the"
+ " tenant " + tenantId, e); + " tenant " + tenantId, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to" throw new ApplicationStorageManagementException("Application Management DAO exception while trying to"
+ " update the screen-shot count for the application " + applicationUUID + " for the tenant " + " update the screen-shot count for the application " + applicationUUID + " for the tenant "
+ tenantId, e); + tenantId, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
} }
} }
} }

@ -305,8 +305,8 @@ CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` (
CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1`
FOREIGN KEY (`PLATFORM_ID`) FOREIGN KEY (`PLATFORM_ID`)
REFERENCES `APPM_PLATFORM` (`ID`) REFERENCES `APPM_PLATFORM` (`ID`)
ON DELETE NO ACTION ON DELETE CASCADE
ON UPDATE NO ACTION) ON UPDATE CASCADE )
ENGINE = InnoDB ENGINE = InnoDB
COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings';

Loading…
Cancel
Save