Merge pull request #913 from Megala21/appm_new

Fixing some tenant related issues in Application Management and some improvements
feature/appm-store/pbac
Megala Uthayakumar 7 years ago committed by GitHub
commit c10f4e3587

@ -232,7 +232,6 @@ public interface ApplicationManagementAPI {
required = true) required = true)
@Valid Application application); @Valid Application application);
@POST @POST
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -649,4 +648,98 @@ public interface ApplicationManagementAPI {
name = "version", name = "version",
value = "Version of the application") value = "Version of the application")
@QueryParam("version") String version); @QueryParam("version") String version);
@GET
@Path("/image-artifacts/{uuid}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "Delete the releases of a particular applicaion",
notes = "This will delete the releases or specific release of an application",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:application:get")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully deleted the Application release."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while deleting the release of a"
+ "particular application.",
response = ErrorResponse.class)
})
Response getApplicationImageArtifacts(
@ApiParam(
name = "UUID",
value = "Unique identifier of the Application",
required = true)
@PathParam("uuid") String applicationUUID,
@ApiParam(
name = "name",
value = "Name of the artifact to be retrieved",
required = true)
@QueryParam("name") String name,
@ApiParam(
name = "count",
value = "Count of the screen-shot artifact to be retrieved",
required = false)
@QueryParam("count") int count);
@PUT
@Consumes("application/json")
@Path("/{uuid}/{version}/{channel}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Make the particular application release as default or not",
notes = "Make the particular application release as default or not",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:application-mgt:login")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully retrieved the lifecycle states.",
response = List.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while getting the life-cycle states.",
response = ErrorResponse.class)
})
Response updateDefaultVersion(
@ApiParam(
name = "UUID",
value = "Unique identifier of the Application",
required = true)
@PathParam("uuid") String applicationUUID,
@ApiParam(
name = "Version",
value = "Version of the Application Release",
required = true)
@PathParam("version") String version,
@ApiParam(
name = "Release Channel",
value = "Release Channel",
required = true)
@PathParam("channel") String channel,
@ApiParam(
name = "isDefault",
value = "Whether to make it default or not",
required = false)
@QueryParam("isDefault") boolean isDefault);
} }

@ -425,7 +425,51 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
+ applicationUUID).build(); + applicationUUID).build();
} }
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
log.error("Error while deleting application release with the applicaion UUID " + applicationUUID, e); log.error("Error while deleting application release with the application UUID " + applicationUUID, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Override
@GET
@Path("/image-artifacts/{uuid}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID,
@QueryParam("name") String name, @QueryParam("count") int count) {
if (name == null || name.isEmpty()) {
return Response.status(Response.Status.BAD_REQUEST).entity("Name should not be null. Name is mandatory to"
+ " retrieve the particular image artifact of the release").build();
}
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
try {
InputStream imageArtifact = applicationStorageManager.getImageArtifact(applicationUUID, name, count);
FileStreamingOutput fileStreamingOutput = new FileStreamingOutput(imageArtifact);
Response.ResponseBuilder response = Response.status(Response.Status.OK).entity(fileStreamingOutput);
response.header("Content-Disposition", "attachment; filename=\"" + name + "\"");
return response.build();
} catch (ApplicationStorageManagementException e) {
log.error("Application Storage Management Exception while getting the image artifact " + name + " of "
+ "the application with UUID " + applicationUUID, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Override
@PUT
@Consumes("application/json")
@Path("/{uuid}/{version}/{channel}")
public Response updateDefaultVersion(@PathParam("uuid") String applicationUUID, @PathParam("version") String
version, @PathParam("channel") String channel, @QueryParam("isDefault") boolean isDefault) {
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
try {
applicationReleaseManager.changeDefaultRelease(applicationUUID, version, isDefault, channel);
return Response.status(Response.Status.OK)
.entity("Successfully changed the default version for the " + "release channel " + channel
+ " for the application UUID " + applicationUUID).build();
} catch (ApplicationManagementException e) {
log.error("Application Release Management Exception while changing the default release for the release "
+ "channel " + channel + " for the application with UUID " + applicationUUID + " for the version "
+ version);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
} }
} }

@ -43,14 +43,8 @@ public class Application {
private String description; private String description;
private String iconName;
private String bannerName;
private String videoName; private String videoName;
private List<String> screenshots;
private List<String> tags; private List<String> tags;
private Platform platform; private Platform platform;
@ -73,6 +67,8 @@ public class Application {
private Visibility visibility; private Visibility visibility;
private int screenShotCount;
private User user; private User user;
public int getId() { public int getId() {
@ -155,22 +151,6 @@ public class Application {
this.description = description; this.description = description;
} }
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
}
public String getBannerName() {
return bannerName;
}
public void setBannerName(String bannerName) {
this.bannerName = bannerName;
}
public String getVideoName() { public String getVideoName() {
return videoName; return videoName;
} }
@ -179,14 +159,6 @@ public class Application {
this.videoName = videoName; this.videoName = videoName;
} }
public List<String> getScreenshots() {
return screenshots;
}
public void setScreenshots(List<String> screenshots) {
this.screenshots = screenshots;
}
public List<String> getTags() { public List<String> getTags() {
return tags; return tags;
} }
@ -251,6 +223,14 @@ public class Application {
this.user = user; this.user = user;
} }
public void setScreenShotCount (int screenShotCount) {
this.screenShotCount = screenShotCount;
}
public int getScreenShotCount() {
return screenShotCount;
}
@Override @Override
public String toString() { public String toString() {
return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : " return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : "

@ -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.
* *
*/ */
@ -59,11 +59,15 @@ public interface ApplicationReleaseManager {
public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException; public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException;
/** /**
* To make a release as the default one for an application. * To make a particular application release as the default / not default-one
* * @param uuid UUID of the application
* @param id ID of the ApplicationRelease, that need to be made default. * @param version Version of the application
* @param isDefault is default or not.
* @param releaseChannel Release channel to make the
* @throws ApplicationManagementException Application Management Exception.
*/ */
public void makeDefaultRelease(int id) throws ApplicationManagementException; public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel)
throws ApplicationManagementException;
/** /**
* To update with a new release for an Application. * To update with a new release for an Application.

@ -83,4 +83,16 @@ public interface ApplicationStorageManager {
*/ */
public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws
ApplicationStorageManagementException; ApplicationStorageManagementException;
/**
* To get particular image artifact of the application.
*
* @param applicationUUID UUID of the application, to retrieve the image artifact.
* @param name Name of the artifact - icon/banner/screenshot
* @param count Position of a parameter to get the image artifact.
* @return the relevant image artifact.
* @throws ApplicationStorageManagementException Application Storage Management Exception.
*/
public InputStream getImageArtifact(String applicationUUID, String name, int count) throws
ApplicationStorageManagementException;
} }

@ -35,15 +35,15 @@ public interface ApplicationDAO {
Application createApplication(Application application) throws ApplicationManagementDAOException; Application createApplication(Application application) throws ApplicationManagementDAOException;
ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException; ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException;
Application getApplication(String uuid) throws ApplicationManagementDAOException; Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException;
int getApplicationId(String uuid) throws ApplicationManagementDAOException; int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException;
Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException; Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException;
void deleteApplication(String uuid) throws ApplicationManagementDAOException; void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException;
int getApplicationCount(Filter filter) throws ApplicationManagementDAOException; int getApplicationCount(Filter filter) throws ApplicationManagementDAOException;
@ -57,10 +57,13 @@ public interface ApplicationDAO {
void addRelease(ApplicationRelease release) throws ApplicationManagementDAOException; void addRelease(ApplicationRelease release) throws ApplicationManagementDAOException;
void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username) throws void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username, int tenantId) throws
ApplicationManagementDAOException; ApplicationManagementDAOException;
List<LifecycleStateTransition> getNextLifeCycleStates(String applicationUUID, int tenantId) throws List<LifecycleStateTransition> getNextLifeCycleStates(String applicationUUID, int tenantId) throws
ApplicationManagementDAOException; ApplicationManagementDAOException;
void updateScreenShotCount(String applicationUUID, int tenantId, int count) throws
ApplicationManagementDAOException;
} }

@ -45,7 +45,8 @@ public interface ApplicationReleaseDAO {
* @return ApplicationRelease for the particular version of the given application * @return ApplicationRelease for the particular version of the given application
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
ApplicationRelease getRelease(String applicationUuid, String versionName) throws ApplicationManagementDAOException; ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws
ApplicationManagementDAOException;
/** /**
* To get all the releases of a particular application. * To get all the releases of a particular application.
@ -54,7 +55,8 @@ public interface ApplicationReleaseDAO {
* @return list of the application releases * @return list of the application releases
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
List<ApplicationRelease> getApplicationReleases(String applicationUUID) throws ApplicationManagementDAOException; List<ApplicationRelease> getApplicationReleases(String applicationUUID, int tenantId) throws
ApplicationManagementDAOException;
/** /**
* To update an Application release. * To update an Application release.
@ -80,4 +82,16 @@ public interface ApplicationReleaseDAO {
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
void deleteReleaseProperties(int id) throws ApplicationManagementDAOException; void deleteReleaseProperties(int id) throws ApplicationManagementDAOException;
/**
* To change the default version of a particular release channel.
* @param uuid UUID of the application
* @param version Version of the application
* @param isDefault true if the request is to make the application as default one unless false
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel, int tenantId)
throws ApplicationManagementDAOException;
} }

@ -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;
@ -63,10 +62,8 @@ public class Util {
application.setIdentifier(rs.getString("IDENTIFIER")); application.setIdentifier(rs.getString("IDENTIFIER"));
application.setShortDescription(rs.getString("SHORT_DESCRIPTION")); application.setShortDescription(rs.getString("SHORT_DESCRIPTION"));
application.setDescription(rs.getString("DESCRIPTION")); application.setDescription(rs.getString("DESCRIPTION"));
application.setIconName(rs.getString("ICON_NAME")); application.setScreenShotCount(rs.getInt("SCREEN_SHOT_COUNT"));
application.setBannerName(rs.getString("BANNER_NAME"));
application.setVideoName(rs.getString("VIDEO_NAME")); application.setVideoName(rs.getString("VIDEO_NAME"));
application.setScreenshots(JSONUtil.jsonArrayStringToList(rs.getString("SCREENSHOTS")));
application.setCreatedAt(rs.getDate("CREATED_AT")); application.setCreatedAt(rs.getDate("CREATED_AT"));
application.setModifiedAt(rs.getDate("MODIFIED_AT")); application.setModifiedAt(rs.getDate("MODIFIED_AT"));
application.setUser(new User(rs.getString("CREATED_BY"), rs.getInt("TENANT_ID"))); application.setUser(new User(rs.getString("CREATED_BY"), rs.getInt("TENANT_ID")));

@ -33,7 +33,6 @@ 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.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
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.application.mgt.core.util.JSONUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date; import java.sql.Date;
@ -65,34 +64,32 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported();
int index = 0;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, ICON_NAME, " sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, "
+ "BANNER_NAME, VIDEO_NAME, SCREENSHOTS, CREATED_BY, CREATED_AT, MODIFIED_AT, " + "VIDEO_NAME, SCREEN_SHOT_COUNT, CREATED_BY, CREATED_AT, MODIFIED_AT, "
+ "APPLICATION_CATEGORY_ID, PLATFORM_ID, TENANT_ID, LIFECYCLE_STATE_ID, " + "APPLICATION_CATEGORY_ID, PLATFORM_ID, TENANT_ID, LIFECYCLE_STATE_ID, "
+ "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES " + "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, application.getUuid()); stmt.setString(++index, application.getUuid());
stmt.setString(2, application.getIdentifier()); stmt.setString(++index, application.getIdentifier());
stmt.setString(3, application.getName()); stmt.setString(++index, application.getName());
stmt.setString(4, application.getShortDescription()); stmt.setString(++index, application.getShortDescription());
stmt.setString(5, application.getDescription()); stmt.setString(++index, application.getDescription());
stmt.setString(6, application.getIconName()); stmt.setString(++index, application.getVideoName());
stmt.setString(7, application.getBannerName()); stmt.setInt(++index, application.getScreenShotCount());
stmt.setString(8, application.getVideoName()); stmt.setString(++index, application.getUser().getUserName());
stmt.setString(9, JSONUtil.listToJsonArrayString(application.getScreenshots())); stmt.setDate(++index, new Date(application.getCreatedAt().getTime()));
stmt.setString(10, application.getUser().getUserName()); stmt.setDate(++index, new Date(application.getModifiedAt().getTime()));
stmt.setDate(11, new Date(application.getCreatedAt().getTime())); stmt.setInt(++index, application.getCategory().getId());
stmt.setDate(12, new Date(application.getModifiedAt().getTime())); stmt.setInt(++index, application.getPlatform().getId());
stmt.setInt(13, application.getCategory().getId()); stmt.setInt(++index, application.getUser().getTenantId());
stmt.setInt(14, application.getPlatform().getId()); stmt.setInt(++index, application.getCurrentLifecycle().getLifecycleState().getId());
stmt.setInt(15, application.getUser().getTenantId()); stmt.setDate(++index, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime()));
stmt.setInt(16, application.getCurrentLifecycle().getLifecycleState().getId()); stmt.setString(++index, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy());
stmt.setDate(17, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime()));
stmt.setString(18, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy());
stmt.executeUpdate(); stmt.executeUpdate();
rs = stmt.getGeneratedKeys(); rs = stmt.getGeneratedKeys();
@ -112,7 +109,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
@Override @Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException { public ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Getting application data from the database"); log.debug("Getting application data from the database");
log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset())); log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset()));
@ -125,6 +122,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
ApplicationList applicationList = new ApplicationList(); ApplicationList applicationList = new ApplicationList();
List<Application> applications = new ArrayList<>(); List<Application> applications = new ArrayList<>();
Pagination pagination = new Pagination(); Pagination pagination = new Pagination();
int index = 0;
if (filter == null) { if (filter == null) {
throw new ApplicationManagementDAOException("Filter need to be instantiated"); throw new ApplicationManagementDAOException("Filter need to be instantiated");
@ -140,15 +138,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS "
+ "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON "
+ "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS "
+ "LS ON APP.LIFECYCLE_STATE_ID = LS.ID "; + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? ";
if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
sql += "WHERE APP.NAME LIKE ? "; sql += "AND APP.NAME LIKE ? ";
} }
sql += "LIMIT ?,?;"; sql += "LIMIT ?,?;";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
int index = 0; stmt.setInt(++index, tenantId);
if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); stmt.setString(++index, "%" + filter.getSearchQuery() + "%");
} }
@ -183,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);
} }
@ -243,11 +244,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
@Override @Override
public Application getApplication(String uuid) throws ApplicationManagementDAOException { public Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Getting application with the UUID(" + uuid + ") from the database"); log.debug("Getting application with the UUID(" + uuid + ") from the database");
} }
Connection conn = null; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
@ -260,10 +261,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS "
+ "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON "
+ "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS "
+ "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ?"; + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, uuid); stmt.setString(1, uuid);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -301,8 +303,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
@Override @Override
public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName) throws public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName, int tenantId)
ApplicationManagementDAOException { throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Change Life cycle status change " + lifecycleIdentifier + "request received to the DAO " log.debug("Change Life cycle status change " + lifecycleIdentifier + "request received to the DAO "
+ "level for the application with " + "the UUID '" + applicationUUID + "' from the user " + "level for the application with " + "the UUID '" + applicationUUID + "' from the user "
@ -314,12 +316,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
conn = this.getDBConnection(); conn = this.getDBConnection();
String sql = "UPDATE APPM_APPLICATION SET " String sql = "UPDATE APPM_APPLICATION SET "
+ "LIFECYCLE_STATE_ID = (SELECT ID FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?), " + "LIFECYCLE_STATE_ID = (SELECT ID FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?), "
+ "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ?"; + "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ? AND TENANT_ID "
+ "= ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, lifecycleIdentifier); stmt.setString(1, lifecycleIdentifier);
stmt.setString(2, userName); stmt.setString(2, userName);
stmt.setDate(3, new Date(System.currentTimeMillis())); stmt.setDate(3, new Date(System.currentTimeMillis()));
stmt.setString(4, applicationUUID); stmt.setString(4, applicationUUID);
stmt.setInt(5, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} 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.", e);
@ -341,13 +345,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM " String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM "
+ "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LIFECYCLE_STATE_TRANSITION WHERE " + "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LIFECYCLE_STATE_TRANSITION WHERE "
+ "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ?)) " + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) "
+ "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID"; + "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID";
try { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
preparedStatement = connection.prepareStatement(sql); preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, applicationUUID); preparedStatement.setString(1, applicationUUID);
preparedStatement.setInt(2, tenantId);
resultSet = preparedStatement.executeQuery(); resultSet = preparedStatement.executeQuery();
List<LifecycleStateTransition> lifecycleStateTransitions = new ArrayList<>(); List<LifecycleStateTransition> lifecycleStateTransitions = new ArrayList<>();
@ -370,6 +375,31 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
} }
@Override
public void updateScreenShotCount(String applicationUUID, int tenantId, int count)
throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION SET SCREEN_SHOT_COUNT = ? where UUID = ? and TENANT_ID = ?";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setInt(1, count);
statement.setString(2, applicationUUID);
statement.setInt(3, tenantId);
statement.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot "
+ "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SQL exception while executing the query '" + sql + "' .", e);
} finally {
Util.cleanupResources(statement, null);
}
}
@Override @Override
public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException { public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException {
Connection conn; Connection conn;
@ -380,9 +410,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
conn = this.getDBConnection(); conn = this.getDBConnection();
int index = 0; int index = 0;
sql += "UPDATE APPM_APPLICATION SET NAME = IFNULL (?, NAME), SHORT_DESCRIPTION = IFNULL " sql += "UPDATE APPM_APPLICATION SET NAME = IFNULL (?, NAME), SHORT_DESCRIPTION = IFNULL "
+ "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), ICON_NAME = IFNULL (?, ICON_NAME)" + "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), SCREEN_SHOT_COUNT = IFNULL (?, "
+ ", BANNER_NAME = IFNULL (?, BANNER_NAME), VIDEO_NAME = IFNULL (?, VIDEO_NAME), " + "SCREEN_SHOT_COUNT), VIDEO_NAME = IFNULL (?, VIDEO_NAME), "
+ "SCREENSHOTS = IFNULL (?, SCREENSHOTS), MODIFIED_AT = IFNULL (?, MODIFIED_AT), "; + "MODIFIED_AT = IFNULL (?, MODIFIED_AT), ";
if (application.getPayment() != null) { if (application.getPayment() != null) {
sql += " IS_FREE = IFNULL (?, IS_FREE), "; sql += " IS_FREE = IFNULL (?, IS_FREE), ";
@ -404,10 +434,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.setString(++index, application.getName()); stmt.setString(++index, application.getName());
stmt.setString(++index, application.getShortDescription()); stmt.setString(++index, application.getShortDescription());
stmt.setString(++index, application.getDescription()); stmt.setString(++index, application.getDescription());
stmt.setString(++index, application.getIconName()); stmt.setInt(++index, application.getScreenShotCount());
stmt.setString(++index, application.getBannerName());
stmt.setString(++index, application.getVideoName()); stmt.setString(++index, application.getVideoName());
stmt.setString(++index, JSONUtil.listToJsonArrayString(application.getScreenshots()));
stmt.setDate(++index, new Date(application.getModifiedAt().getTime())); stmt.setDate(++index, new Date(application.getModifiedAt().getTime()));
if (application.getPayment() != null) { if (application.getPayment() != null) {
stmt.setBoolean(++index, application.getPayment().isFreeApp()); stmt.setBoolean(++index, application.getPayment().isFreeApp());
@ -427,7 +455,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.setString(++index, application.getUuid()); stmt.setString(++index, application.getUuid());
stmt.executeUpdate(); stmt.executeUpdate();
application.setId(getApplicationId(application.getUuid())); application.setId(getApplicationId(application.getUuid(), tenantId));
sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?"; sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
@ -499,14 +527,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
@Override @Override
public void deleteApplication(String uuid) throws ApplicationManagementDAOException { public void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ?"; String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, uuid); stmt.setString(1, uuid);
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -561,7 +590,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
@Override @Override
public int getApplicationId(String uuid) throws ApplicationManagementDAOException { public int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -569,9 +598,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
int id = 0; int id = 0;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ?"; sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, uuid); stmt.setString(1, uuid);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (rs.next()) { if (rs.next()) {
id = rs.getInt(1); id = rs.getInt(1);

@ -27,7 +27,12 @@ import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
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.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import java.sql.*; import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -44,6 +49,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
Connection connection; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
if (applicationRelease.isDefault()) {
}
String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RESOURCE, RELEASE_CHANNEL ," String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RESOURCE, RELEASE_CHANNEL ,"
+ "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)"; + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)";
int index = 0; int index = 0;
@ -79,13 +88,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} }
@Override @Override
public ApplicationRelease getRelease(String applicationUuid, String versionName) public ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId)
throws ApplicationManagementDAOException { throws ApplicationManagementDAOException {
Connection connection; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE VERSION_NAME = ? AND APPM_APPLICATION_ID = " String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE VERSION_NAME = ? AND APPM_APPLICATION_ID = "
+ "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ?)"; + "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ? and TENANT_ID = ?)";
ApplicationRelease applicationRelease = null; ApplicationRelease applicationRelease = null;
ResultSet rsProperties = null; ResultSet rsProperties = null;
@ -94,6 +103,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
statement.setString(1, versionName); statement.setString(1, versionName);
statement.setString(2, applicationUuid); statement.setString(2, applicationUuid);
statement.setInt(3, tenantId);
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
@ -132,13 +142,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} }
@Override @Override
public List<ApplicationRelease> getApplicationReleases(String applicationUUID) public List<ApplicationRelease> getApplicationReleases(String applicationUUID, int tenantId)
throws ApplicationManagementDAOException { throws ApplicationManagementDAOException {
Connection connection; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = (SELECT ID FROM " String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = (SELECT ID FROM "
+ "APPM_APPLICATION WHERE UUID = ?)"; + "APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)";
List<ApplicationRelease> applicationReleases = new ArrayList<>(); List<ApplicationRelease> applicationReleases = new ArrayList<>();
ResultSet rsProperties = null; ResultSet rsProperties = null;
@ -146,6 +156,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
statement.setString(1, applicationUUID); statement.setString(1, applicationUUID);
statement.setInt(2, tenantId);
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -264,6 +275,40 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} }
} }
@Override
public void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel,
int tenantId) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = ? AND RELEASE_CHANNEL = ? WHERE "
+ "APPM_APPLICATION_ID = (SELECT ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) "
+ "AND VERSION_NAME = ?";
try {
if (isDefault) {
removeDefaultReleases(uuid, releaseChannel, tenantId);
}
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setBoolean(1, isDefault);
statement.setString(2, releaseChannel.toUpperCase());
statement.setString(3, uuid);
statement.setInt(4, tenantId);
statement.setString(5, version);
statement.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Database Connection exception while try to change the " + "default release of the release channel "
+ releaseChannel + " for the application " + uuid, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"SQL Exception while trying to change the default release of " + "the release channel "
+ releaseChannel + " for the application " + uuid, e);
} finally {
Util.cleanupResources(statement, null);
}
}
/** /**
* To insert the application release properties. * To insert the application release properties.
* @param connection Database Connection * @param connection Database Connection
@ -294,4 +339,30 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} }
} }
} }
/**
* To make all the releases of particular release channel as non-default ones.
*
* @param uuid UUID of the Application.
* @param releaseChannel ReleaseChannel for which we need to make all the releases as non-default ones.
* @param tenantId ID of the tenant.
* @throws DBConnectionException Database Connection Exception.
* @throws SQLException SQL Exception.
*/
private void removeDefaultReleases(String uuid, String releaseChannel, int tenantId)
throws DBConnectionException, SQLException {
PreparedStatement statement = null;
try {
Connection connection = this.getDBConnection();
String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = FALSE WHERE APPM_APPLICATION_ID = (SELECT "
+ "ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) AND RELEASE_CHANNEL = ?";
statement = connection.prepareStatement(sql);
statement.setString(1, uuid);
statement.setInt(2, tenantId);
statement.setString(3, releaseChannel.toUpperCase());
statement.executeUpdate();
} finally {
Util.cleanupResources(statement, null);
}
}
} }

@ -46,7 +46,6 @@ import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException; 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.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -158,10 +157,10 @@ public class ApplicationManagerImpl implements ApplicationManager {
try { try {
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
int appId = applicationDAO.getApplicationId(uuid); int appId = applicationDAO.getApplicationId(uuid, tenantId);
applicationDAO.deleteTags(appId); applicationDAO.deleteTags(appId);
applicationDAO.deleteProperties(appId); applicationDAO.deleteProperties(appId);
applicationDAO.deleteApplication(uuid); applicationDAO.deleteApplication(uuid, tenantId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
@ -174,15 +173,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
return applicationDAO.getApplications(filter); return applicationDAO.getApplications(filter, tenantId);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
@Override @Override
@ -190,6 +188,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationManagementException { ApplicationManagementException {
boolean isAvailableNextState = false; boolean isAvailableNextState = false;
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
List<LifecycleStateTransition> nextLifeCycles = getLifeCycleStates(applicationUuid); List<LifecycleStateTransition> nextLifeCycles = getLifeCycleStates(applicationUuid);
for (LifecycleStateTransition lifecycleStateTransition : nextLifeCycles) { for (LifecycleStateTransition lifecycleStateTransition : nextLifeCycles) {
@ -210,7 +209,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName); applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName, tenantId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
@ -278,20 +277,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public Application getApplication(String uuid) throws ApplicationManagementException { public Application getApplication(String uuid) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
return DAOFactory.getApplicationDAO().getApplication(uuid); return DAOFactory.getApplicationDAO().getApplication(uuid, tenantId);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
public void uploadArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream,
List<InputStream> screenShotStreams)
throws ApplicationManagementException {
}
/** /**
* To check whether current user is application owner or admin. * To check whether current user is application owner or admin.
* *
@ -310,7 +304,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID); Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID, tenantId);
return application.getUser().getUserName().equals(userName) return application.getUser().getUserName().equals(userName)
&& application.getUser().getTenantId() == tenantId; && application.getUser().getTenantId() == tenantId;
} finally { } finally {

@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.core.impl;
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.wso2.carbon.context.PrivilegedCarbonContext;
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.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
@ -64,6 +65,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
@Override @Override
public ApplicationRelease getRelease(String applicationUuid, String version) throws public ApplicationRelease getRelease(String applicationUuid, String version) throws
ApplicationManagementException { ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Application application = validateApplication(applicationUuid); Application application = validateApplication(applicationUuid);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Application release retrieval request is received for the application " + log.debug("Application release retrieval request is received for the application " +
@ -71,7 +73,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version); return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version, tenantId);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -79,6 +81,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
@Override @Override
public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException { public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Application application = validateApplication(applicationUuid); Application application = validateApplication(applicationUuid);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request is received to retrieve all the releases related with the application " + log.debug("Request is received to retrieve all the releases related with the application " +
@ -86,15 +89,33 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid); return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid, tenantId);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
@Override @Override
public void makeDefaultRelease(int id) throws ApplicationManagementException { public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) throws
ApplicationManagementException {
Application application = validateApplication(uuid);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) {
log.debug("Request received to change the default release for the release channel " + releaseChannel
+ "for the application " + application.toString());
}
try {
ConnectionManagerUtil.beginDBTransaction();
DAOFactory.getApplicationReleaseDAO()
.changeReleaseDefault(uuid, version, isDefault, releaseChannel, tenantId);
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw e;
} finally {
ConnectionManagerUtil.closeDBConnection();
}
} }
@Override @Override

@ -21,12 +21,18 @@ package org.wso2.carbon.device.application.mgt.core.impl;
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.wso2.carbon.context.PrivilegedCarbonContext;
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.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
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.ApplicationStorageManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.core.dao.common.DAOFactory;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.Constants;
import java.io.File; import java.io.File;
@ -36,6 +42,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -47,18 +54,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public void uploadImageArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream, public void uploadImageArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream,
List<InputStream> screenShotStreams) throws ApplicationStorageManagementException { List<InputStream> screenShotStreams) throws ApplicationStorageManagementException {
Application application; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { Application application = validateApplication(applicationUUID);
application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for " + "the application with UUID "
+ applicationUUID);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not "
+ "exist. Cannot upload the artifacts to non-existing application.");
}
String artifactDirectoryPath = Constants.artifactPath + application.getId(); String artifactDirectoryPath = Constants.artifactPath + application.getId();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Artifact Directory Path for saving the artifacts related with application " + applicationUUID log.debug("Artifact Directory Path for saving the artifacts related with application " + applicationUUID
@ -66,10 +63,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
createArtifactDirectory(artifactDirectoryPath); createArtifactDirectory(artifactDirectoryPath);
if (iconFileStream != null) { if (iconFileStream != null) {
String iconName = application.getIconName();
iconName = (iconName == null) ? "icon" : iconName;
try { try {
saveFile(iconFileStream, artifactDirectoryPath + File.separator + iconName); saveFile(iconFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0]);
} catch (IOException e) { } catch (IOException e) {
throw new ApplicationStorageManagementException( throw new ApplicationStorageManagementException(
"IO Exception while saving the icon file in the server for " + "the application " "IO Exception while saving the icon file in the server for " + "the application "
@ -77,10 +72,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
} }
if (bannerFileStream != null) { if (bannerFileStream != null) {
String bannerName = application.getBannerName();
bannerName = (bannerName == null) ? "banner" : bannerName;
try { try {
saveFile(bannerFileStream, artifactDirectoryPath + File.separator + bannerName); saveFile(bannerFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1]);
} catch (IOException e) { } catch (IOException e) {
throw new ApplicationStorageManagementException( throw new ApplicationStorageManagementException(
"IO Exception while saving the banner file in the server for" + " the application " "IO Exception while saving the banner file in the server for" + " the application "
@ -88,18 +81,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
} }
if (screenShotStreams != null) { if (screenShotStreams != null) {
int count = 1; int count = application.getScreenShotCount() + 1;
String screenshotName; String screenshotName;
List<String> screenShotNames = application.getScreenshots();
boolean isScreenShotNameExist = (screenShotNames == null || screenShotNames.isEmpty());
int screenShotNameLength = isScreenShotNameExist ? screenShotNames.size() : 0;
for (InputStream screenshotStream : screenShotStreams) { for (InputStream screenshotStream : screenShotStreams) {
try { try {
if (isScreenShotNameExist && count <= screenShotNameLength) { screenshotName = Constants.IMAGE_ARTIFACTS[2] + count;
screenshotName = screenShotNames.get(count);
} else {
screenshotName = "screenshot_" + count;
}
saveFile(screenshotStream, artifactDirectoryPath + File.separator + screenshotName); saveFile(screenshotStream, artifactDirectoryPath + File.separator + screenshotName);
count++; count++;
} catch (IOException e) { } catch (IOException e) {
@ -108,24 +94,35 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
e); e);
} }
} }
try {
ConnectionManagerUtil.beginDBTransaction();
DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count - 1);
ConnectionManagerUtil.commitDBTransaction();
} catch (TransactionManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Transaction Management exception while trying to "
+ "update the screen-shot count of the application " + applicationUUID + " for the tenant "
+ tenantId, e);
} catch (DBConnectionException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Database connection management exception while "
+ "trying to update the screen-shot count for the application " + applicationUUID + " for the"
+ " tenant " + tenantId, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to"
+ " update the screen-shot count for the application " + applicationUUID + " for the tenant "
+ tenantId, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
} }
} }
@Override @Override
public void uploadReleaseArtifacts(String applicationUUID, String versionName, InputStream binaryFile) public void uploadReleaseArtifacts(String applicationUUID, String versionName, InputStream binaryFile)
throws ApplicationStorageManagementException { throws ApplicationStorageManagementException {
Application application; Application application = validateApplication(applicationUUID);
try {
application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for " + "the application with UUID "
+ applicationUUID);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not "
+ "exist. Cannot upload release artifacts for not existing application.");
}
String artifactDirectoryPath = Constants.artifactPath + application.getId(); String artifactDirectoryPath = Constants.artifactPath + application.getId();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Artifact Directory Path for saving the application release related artifacts related with " log.debug("Artifact Directory Path for saving the application release related artifacts related with "
@ -148,18 +145,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public InputStream getReleasedArtifacts(String applicationUUID, String versionName) public InputStream getReleasedArtifacts(String applicationUUID, String versionName)
throws ApplicationStorageManagementException { throws ApplicationStorageManagementException {
Application application; Application application = validateApplication(applicationUUID);
try {
application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for " + "the application with UUID "
+ applicationUUID);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not "
+ "exist. Cannot retrieve release artifacts for not existing application.");
}
String artifactPath = Constants.artifactPath + application.getId() + File.separator + versionName; String artifactPath = Constants.artifactPath + application.getId() + File.separator + versionName;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -182,18 +168,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException { public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException {
Application application; Application application = validateApplication(applicationUUID);
try {
application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for " + "the application with UUID "
+ applicationUUID);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not "
+ "exist. Cannot delete the artifacts of a non-existing application.");
}
String artifactDirectoryPath = Constants.artifactPath + application.getId(); String artifactDirectoryPath = Constants.artifactPath + application.getId();
File artifactDirectory = new File(artifactDirectoryPath); File artifactDirectory = new File(artifactDirectoryPath);
@ -205,18 +180,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public void deleteApplicationReleaseArtifacts(String applicationUUID, String version) public void deleteApplicationReleaseArtifacts(String applicationUUID, String version)
throws ApplicationStorageManagementException { throws ApplicationStorageManagementException {
Application application; Application application = validateApplication(applicationUUID);
try {
application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for " + "the application with UUID "
+ applicationUUID);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not "
+ "exist. Cannot delete the artifacts of a non-existing application.");
}
String artifactPath = Constants.artifactPath + application.getId() + File.separator + version; String artifactPath = Constants.artifactPath + application.getId() + File.separator + version;
File artifact = new File(artifactPath); File artifact = new File(artifactPath);
@ -225,8 +189,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
} }
@Override public void deleteAllApplicationReleaseArtifacts(String applicationUUID) @Override
throws ApplicationStorageManagementException { public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws
ApplicationStorageManagementException {
Application application = validateApplication(applicationUUID);
try { try {
List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getReleaseManager() List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getReleaseManager()
.getReleases(applicationUUID); .getReleases(applicationUUID);
@ -240,6 +206,31 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
} }
@Override
public InputStream getImageArtifact(String applicationUUID, String name, int count) throws
ApplicationStorageManagementException {
Application application = validateApplication(applicationUUID);
validateImageArtifactNames(name);
String imageArtifactPath = Constants.artifactPath + application.getId() + File.separator + name.toLowerCase();
if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) {
imageArtifactPath += count;
}
File imageFile = new File(imageArtifactPath);
if (!imageFile.exists()) {
throw new ApplicationStorageManagementException(
"Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID);
} else {
try {
return new FileInputStream(imageArtifactPath);
} catch (FileNotFoundException e) {
throw new ApplicationStorageManagementException(
"File not found exception while trying to get the image artifact " + name + " for the "
+ "application " + applicationUUID, e);
}
}
}
/** /**
* To save a file in a given location. * To save a file in a given location.
* *
@ -294,4 +285,44 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
artifactDirectory.delete(); artifactDirectory.delete();
} }
/**
* To validate the image artifact names.
* @param name Name of the image artifact.
* @throws ApplicationStorageManagementException Application Storage Management Exception
*/
private void validateImageArtifactNames(String name) throws ApplicationStorageManagementException {
if (name == null || name.isEmpty()) {
throw new ApplicationStorageManagementException("Image artifact name cannot be null or empty. It is a "
+ "required parameter");
}
if (!Arrays.asList(Constants.IMAGE_ARTIFACTS).contains(name.toLowerCase())) {
throw new ApplicationStorageManagementException("Provide artifact name is not valid. Please provide the "
+ "name among " + Arrays.toString(Constants.IMAGE_ARTIFACTS));
}
}
/**
* To validate the Application before storing and retrieving the artifacts of a particular application.
*
* @param uuid UUID of the Application
* @return {@link Application} if it is validated
* @throws ApplicationStorageManagementException Application Storage Management Exception will be thrown if a
* valid application related with the specific UUID
* could not be found.
*/
private Application validateApplication(String uuid) throws ApplicationStorageManagementException {
Application application = null;
try {
application = DataHolder.getInstance().getApplicationManager().getApplication(uuid);
} catch (ApplicationManagementException e) {
throw new ApplicationStorageManagementException(
"Exception while retrieving the application details for the application with UUID "
+ uuid);
}
if (application == null) {
throw new ApplicationStorageManagementException("Application with UUID " + uuid + " does not exist.");
}
return application;
}
} }

@ -58,4 +58,9 @@ public class Constants {
* Path to save the Application related artifacts. * Path to save the Application related artifacts.
*/ */
public static String artifactPath = ""; public static String artifactPath = "";
/**
* Name of the image artifacts that are saved in the file system.
*/
public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"};
} }

@ -61,7 +61,6 @@
</Extensions> </Extensions>
<Artifacts> <Artifacts>
<ImageLocation>${carbon.home}/repository/resources/mobileapps/images/</ImageLocation> <BinaryLocation>repository/resources/mobileapps/</BinaryLocation>
<BinaryLocation>${carbon.home}/repository/resources/mobileapps/binary/</BinaryLocation>
</Artifacts> </Artifacts>
</ApplicationManagementConfiguration> </ApplicationManagementConfiguration>

@ -125,10 +125,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` (
`NAME` VARCHAR(100) NOT NULL, `NAME` VARCHAR(100) NOT NULL,
`SHORT_DESCRIPTION` VARCHAR(255) NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL,
`DESCRIPTION` TEXT NULL, `DESCRIPTION` TEXT NULL,
`ICON_NAME` VARCHAR(100) NULL, `SCREEN_SHOT_COUNT` INT DEFAULT 0,
`BANNER_NAME` VARCHAR(100) NULL,
`VIDEO_NAME` VARCHAR(100) NULL, `VIDEO_NAME` VARCHAR(100) NULL,
`SCREENSHOTS` TEXT NULL,
`CREATED_BY` VARCHAR(255) NULL, `CREATED_BY` VARCHAR(255) NULL,
`CREATED_AT` DATETIME NOT NULL, `CREATED_AT` DATETIME NOT NULL,
`MODIFIED_AT` DATETIME NULL, `MODIFIED_AT` DATETIME NULL,
@ -183,7 +181,7 @@ CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
VERSION_NAME VARCHAR(100) NOT NULL, VERSION_NAME VARCHAR(100) NOT NULL,
RESOURCE TEXT NULL, RESOURCE TEXT NULL,
RELEASE_CHANNEL VARCHAR(50) NULL, RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA',
RELEASE_DETAILS TEXT NULL, RELEASE_DETAILS TEXT NULL,
CREATED_AT DATETIME NOT NULL, CREATED_AT DATETIME NOT NULL,
APPM_APPLICATION_ID INT NOT NULL, APPM_APPLICATION_ID INT NOT NULL,

@ -126,10 +126,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` (
`NAME` VARCHAR(100) NOT NULL, `NAME` VARCHAR(100) NOT NULL,
`SHORT_DESCRIPTION` VARCHAR(255) NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL,
`DESCRIPTION` TEXT NULL, `DESCRIPTION` TEXT NULL,
`ICON_NAME` VARCHAR(100) NULL,
`BANNER_NAME` VARCHAR(100) NULL,
`VIDEO_NAME` VARCHAR(100) NULL, `VIDEO_NAME` VARCHAR(100) NULL,
`SCREENSHOTS` TEXT NULL, `SCREEN_SHOT_COUNT` INT DEFAULT 0,
`CREATED_BY` VARCHAR(255) NULL, `CREATED_BY` VARCHAR(255) NULL,
`CREATED_AT` DATETIME NOT NULL, `CREATED_AT` DATETIME NOT NULL,
`MODIFIED_AT` DATETIME NULL, `MODIFIED_AT` DATETIME NULL,
@ -191,7 +189,7 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` (
`ID` INT NOT NULL AUTO_INCREMENT UNIQUE , `ID` INT NOT NULL AUTO_INCREMENT UNIQUE ,
`VERSION_NAME` VARCHAR(100) NOT NULL, `VERSION_NAME` VARCHAR(100) NOT NULL,
`RESOURCE` TEXT NULL, `RESOURCE` TEXT NULL,
`RELEASE_CHANNEL` VARCHAR(50) NULL, `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA',
`RELEASE_DETAILS` TEXT NULL, `RELEASE_DETAILS` TEXT NULL,
`CREATED_AT` DATETIME NOT NULL, `CREATED_AT` DATETIME NOT NULL,
`APPM_APPLICATION_ID` INT NOT NULL, `APPM_APPLICATION_ID` INT NOT NULL,
@ -307,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