Adding DAO layer changes

feature/appm-store/pbac
lasantha 7 years ago
parent 45c668ecce
commit d196e3e0e1

@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.common;
import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@ -28,10 +29,6 @@ import java.util.List;
*/
public class ApplicationRelease {
private enum ReleaseType {
PRODUCTION, ALPHA, BETA
}
@Exclude
private int id;
@ -51,14 +48,36 @@ public class ApplicationRelease {
private String screenshotLoc3;
private ReleaseType releaseType;
private String applicationCreator;
private String releaseType;
private Double price;
private Timestamp createdAt;
private String publishedBy;
private Timestamp publishedAt;
private int starts;
private String modifiedBy;
private Timestamp modifiedAt;
private ImageArtifact icon;
private ImageArtifact banner;
private String currentState;
private String previouseState;
private String stateModifiedBy;
private Timestamp stateModifiedAt;
private List<ImageArtifact> screenShots = new ArrayList<>();
private String appHashValue;
@ -67,10 +86,6 @@ public class ApplicationRelease {
private String metaData;
private List<Comment> comments;
private Lifecycle lifecycle;
public void setId(int id) {
this.id = id;
}
@ -91,7 +106,11 @@ public class ApplicationRelease {
this.uuid = uuid;
}
public void setReleaseType(ReleaseType releaseType) {
public String getReleaseType() {
return releaseType;
}
public void setReleaseType(String releaseType) {
this.releaseType = releaseType;
}
@ -127,10 +146,6 @@ public class ApplicationRelease {
return tenantId;
}
public ReleaseType getReleaseType() {
return releaseType;
}
public Double getPrice() {
return price;
}
@ -139,6 +154,38 @@ public class ApplicationRelease {
this.price = price;
}
public String getCurrentState() {
return currentState;
}
public void setCurrentState(String currentState) {
this.currentState = currentState;
}
public String getPreviouseState() {
return previouseState;
}
public void setPreviouseState(String previouseState) {
this.previouseState = previouseState;
}
public String getStateModifiedBy() {
return stateModifiedBy;
}
public void setStateModifiedBy(String stateModifiedBy) {
this.stateModifiedBy = stateModifiedBy;
}
public Timestamp getStateModifiedAt() {
return stateModifiedAt;
}
public void setStateModifiedAt(Timestamp stateModifiedAt) {
this.stateModifiedAt = stateModifiedAt;
}
public ImageArtifact getIcon() {
return icon;
}
@ -163,12 +210,6 @@ public class ApplicationRelease {
return metaData;
}
public List<Comment> getComments() { return comments; }
public void setComments(List<Comment> comments) {
this.comments = comments;
}
public String getAppStoredLoc() {
return appStoredLoc;
}
@ -209,11 +250,59 @@ public class ApplicationRelease {
this.screenshotLoc3 = screenshotLoc3;
}
public Lifecycle getLifecycle() {
return lifecycle;
public String getApplicationCreator() {
return applicationCreator;
}
public void setApplicationCreator(String applicationCreator) {
this.applicationCreator = applicationCreator;
}
public Timestamp getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
public String getPublishedBy() {
return publishedBy;
}
public void setPublishedBy(String publishedBy) {
this.publishedBy = publishedBy;
}
public Timestamp getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Timestamp publishedAt) {
this.publishedAt = publishedAt;
}
public int getStarts() {
return starts;
}
public void setStarts(int starts) {
this.starts = starts;
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Timestamp getModifiedAt() {
return modifiedAt;
}
public void setLifecycle(Lifecycle lifecycle) {
this.lifecycle = lifecycle;
public void setModifiedAt(Timestamp modifiedAt) {
this.modifiedAt = modifiedAt;
}
}

@ -18,18 +18,25 @@
*/
package org.wso2.carbon.device.application.mgt.common;
/**
* Represents a state in {@link Lifecycle}.
*/
import java.sql.Timestamp;
public class LifecycleState {
private int id;
private String name;
private String currentState;
private String previousState;
private String updatedBy;
private Timestamp updatedAt;
private int tenantId;
private String identifier;
private int releaseId;
private String description;
private int appId;
public int getId() {
return id;
@ -39,27 +46,60 @@ public class LifecycleState {
this.id = id;
}
public String getName() {
return name;
public String getCurrentState() {
return currentState;
}
public void setCurrentState(String currentState) {
this.currentState = currentState;
}
public String getPreviousState() {
return previousState;
}
public void setPreviousState(String previousState) {
this.previousState = previousState;
}
public void setName(String name) {
this.name = name;
public String getUpdatedBy() {
return updatedBy;
}
public String getIdentifier() {
return identifier;
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
public Timestamp getUpdatedAt() {
return updatedAt;
}
public String getDescription() {
return description;
public void setUpdatedAt(Timestamp updatedAt) {
this.updatedAt = updatedAt;
}
public void setDescription(String description) {
this.description = description;
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public int getReleaseId() {
return releaseId;
}
public void setReleaseId(int releaseId) {
this.releaseId = releaseId;
}
public int getAppId() {
return appId;
}
public void setAppId(int appId) {
this.appId = appId;
}
}

@ -19,9 +19,8 @@
package org.wso2.carbon.device.application.mgt.core.dao;
import org.wso2.carbon.device.application.mgt.common.*;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import java.sql.Timestamp;
import java.util.List;
/**
@ -104,16 +103,16 @@ public interface ApplicationDAO {
* @return Updated Application.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException;
Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException,
ApplicationManagementException;
/**
* To delete the application identified by the UUID
* To delete the application
*
* @param uuid UUID of the application.
* @param tenantId ID of tenant which the Application belongs to.
* @param appId ID of the application.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException;
void deleteApplication(int appId) throws ApplicationManagementDAOException;
/**
* To get the application count that satisfies gives search query.
@ -124,13 +123,6 @@ public interface ApplicationDAO {
*/
int getApplicationCount(Filter filter) throws ApplicationManagementDAOException;
/**
* To delete the properties of a application.
*
* @param applicationId ID of the application to delete the properties.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void deleteProperties(int applicationId) throws ApplicationManagementDAOException;
/**
* To delete the tags of a application.
@ -139,59 +131,5 @@ public interface ApplicationDAO {
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void deleteTags(int applicationId) throws ApplicationManagementDAOException;
/**
* To change the lifecycle state of the application.
*
* @param applicationUUID UUID of the application.
* @param lifecycleIdentifier New lifecycle state.
* @param username Name of the user.
* @param tenantId ID of the tenant.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username, int tenantId)
throws ApplicationManagementDAOException;
/**
* To get the next possible lifecycle states for the application.
*
* @param applicationUUID UUID of the application.
* @param tenantId ID of the tenant.
* @return Next possible lifecycle states.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
List<LifecycleStateTransition> getNextLifeCycleStates(String applicationUUID, int tenantId)
throws ApplicationManagementDAOException;
/**
* To get the next possible lifecycle states for the application.
*
* @param lifecycle lifecycle of the application.
* @param tenantId tenantId of the application useer.
* @param appReleaseId relesse id of the application.
* @param appId application id of the application.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
public void addLifecycle(Lifecycle lifecycle, int tenantId, int appReleaseId, int appId)
throws ApplicationManagementDAOException;
/**
* To update the screen-shot count of a application.
*
* @param applicationUUID UUID of the application.
* @param tenantId ID of the tenant.
* @param count New count of the screen-shots.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
void updateScreenShotCount(String applicationUUID, int tenantId, int count)
throws ApplicationManagementDAOException;
/**
* To check whether atleast one application exist under category.
*
* @param categoryName Name of the category.
* @return true if atleast one application exist under the given category, otherwise false.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
boolean isApplicationExist(String categoryName) throws ApplicationManagementDAOException;
}

@ -40,22 +40,29 @@ public interface ApplicationReleaseDAO {
/**
* To get a release details with the particular version.
* @param applicationUuid UUID of the application to get the release.
* @param applicationName name of the application to get the release.
* @param versionName Name of the version
* @param applicationType Type of the application release
* @param releaseType type of the release
* @param tenantId tenantId of the application
* @return ApplicationRelease for the particular version of the given application
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws
ApplicationRelease getRelease(String applicationName,String applicationType, String versionName,
String releaseType, int tenantId) throws
ApplicationManagementDAOException;
/**
* To get all the releases of a particular application.
*
* @param applicationUUID Application UUID
* @param applicationName Name of the Application
* @param applicationType Type of the Application
* @param tenantId tenant id of the application
* @return list of the application releases
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
List<ApplicationRelease> getApplicationReleases(String applicationUUID, int tenantId) throws
List<ApplicationRelease> getApplicationReleases(String applicationName, String applicationType, int tenantId) throws
ApplicationManagementDAOException;
/**
@ -66,6 +73,15 @@ public interface ApplicationReleaseDAO {
*/
ApplicationRelease updateRelease(ApplicationRelease applicationRelease) throws ApplicationManagementDAOException;
/**
* To update an Application release.
* @param id id of the ApplicationRelease that need to be updated.
* @param stars given stars for the application.
* @throws ApplicationManagementDAOException Application Management DAO Exception
*/
void updateStars(int id, int stars) throws ApplicationManagementDAOException;
/**
* To delete a particular release.
*
@ -75,23 +91,4 @@ public interface ApplicationReleaseDAO {
*/
void deleteRelease(int id, String version) throws ApplicationManagementDAOException;
/**
* To delete the propertied of a particular Application Release.
*
* @param id ID of the ApplicationRelease in which properties need to be deleted.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
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;
}

@ -1,43 +0,0 @@
/*
*
* Copyright (c) ${date}, 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.dao;
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.core.exception.LifeCycleManagementDAOException;
import java.util.List;
/**
* This is responsible for all the DAO operations related to Lifecycle state.
*/
public interface LifecycleDAO {
Lifecycle getLifeCycleOfApplication(int identifier) throws LifeCycleManagementDAOException;
List<Lifecycle> getLifecyclesOfAllAppVersions (int identifier) throws LifeCycleManagementDAOException;
void addLifecycle(Lifecycle lifecycle) throws LifeCycleManagementDAOException;
void updateLifecycleOfApplication(LifecycleState state) throws LifeCycleManagementDAOException;
void deleteLifecycleOfApplication(String identifier) throws LifeCycleManagementDAOException;
}

@ -29,12 +29,12 @@ import java.util.List;
*/
public interface LifecycleStateDAO {
LifecycleState getLifeCycleStateByIdentifier(String identifier) throws ApplicationManagementDAOException;
LifecycleState getLatestLifeCycleStateByReleaseID(int identifier) throws ApplicationManagementDAOException;
List<LifecycleState> getLifecycleStates() throws LifeCycleManagementDAOException;
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException;
void addLifecycleState(LifecycleState state) throws LifeCycleManagementDAOException;
void deleteLifecycleState(String identifier) throws LifeCycleManagementDAOException;
void deleteLifecycleState(int identifier) throws LifeCycleManagementDAOException;
}

@ -26,7 +26,6 @@ import org.wso2.carbon.device.application.mgt.core.dao.*;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.OracleApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecycle.GenericLifecycleImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.subscription.GenericSubscriptionDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.visibility.GenericVisibilityDAOImpl;
@ -160,23 +159,6 @@ public class ApplicationManagementDAOFactory {
throw new IllegalStateException("Database engine has not initialized properly.");
}
/**
* To get the instance of LifecycleDAOImplementation of the particular database engine.
* @return GenericLifecycleDAOImpl
*/
public static LifecycleDAO getLifecycleDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericLifecycleImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}
}
throw new IllegalStateException("Database engine has not initialized properly.");
}
/**
* This method initializes the databases by creating the database.
*

@ -111,12 +111,13 @@ public class Util {
*/
public static Application loadApplication(ResultSet rs) throws SQLException, JSONException {
Application application = new Application();
Application application = null;
int applicatioId = -1;
int iteration = 0;
while (rs.next()){
if (iteration == 0){
application = new Application();
applicatioId = rs.getInt("APP_ID");
application.setId(applicatioId);
application.setName(rs.getString("APP_NAME"));

@ -22,18 +22,15 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.*;
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.core.dao.ApplicationDAO;
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.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* This handles ApplicationDAO related operations.
@ -76,7 +73,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
return applicationId;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when application creation", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding the application", e);
} finally {
@ -93,8 +90,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
PreparedStatement stmt = null;
ResultSet rs = null;
int index = 0;
String sql = "INSERT INTO AP_APP_TAG (TAG, TENANT_ID, AP_APP_ID) "
+ "VALUES (?, ?, ?)";
String sql = "INSERT INTO AP_APP_TAG (TAG, TENANT_ID, AP_APP_ID) VALUES (?, ?, ?)";
try{
conn = this.getDBConnection();
conn.setAutoCommit(false);
@ -108,7 +104,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeBatch();
}catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when adding tags", e);
}catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} finally {
@ -125,8 +121,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
PreparedStatement stmt = null;
ResultSet rs = null;
int index = 0;
String sql = "INSERT INTO AP_UNRESTRICTED_ROLES (ROLE, TENANT_ID, AP_APP_ID) "
+ "VALUES (?, ?, ?)";
String sql = "INSERT INTO AP_UNRESTRICTED_ROLES (ROLE, TENANT_ID, AP_APP_ID) VALUES (?, ?, ?)";
try{
conn = this.getDBConnection();
conn.setAutoCommit(false);
@ -140,13 +135,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeBatch();
}catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when adding roles", e);
}catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
@ -175,13 +169,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
return isExist;
}catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when verifying application existence", e);
}catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
@ -258,12 +251,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
return applicationList;
}
@Override
public int getApplicationCount(Filter filter) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Getting application count from the database");
log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset()));
log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
}
Connection conn;
@ -336,8 +328,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred while getting application details with app name " + appName + " While executing query "
+ sql, e);
"Error occurred while getting application details with app name " + appName + " While executing query ", e);
} catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
} catch (DBConnectionException e) {
@ -348,228 +339,57 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
@Override
public void addLifecycle(Lifecycle lifecycle, int tenantId, int appReleaseId, int appId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Life cycle is created by" + lifecycle.getCreatedBy() + " at "
+ lifecycle.getCreatedAt());
}
public Application editApplication(Application application, int tenantId) throws ApplicationManagementException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getDBConnection();
String sql = "INSERT INTO AP_APP_LIFECYCLE (CREATED_BY, CREATED_TIMESTAMP, TENANT_ID, AP_APP_RELEASE_ID, "
+ "AP_APP_ID) VALUES (?, ?, ?, ? ,?);";
stmt = conn.prepareStatement(sql);
stmt.setString(1, lifecycle.getCreatedBy());
stmt.setTimestamp(2, (Timestamp) lifecycle.getCreatedAt());
stmt.setInt(3, tenantId);
stmt.setInt(4, appReleaseId);
stmt.setInt(5, appId);
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding the lifecycle of application", e);
} finally {
Util.cleanupResources(stmt, null);
}
Application existingApplication = this.getApplication(application.getName(), application.getType(), tenantId);
if (existingApplication == null){
throw new ApplicationManagementException("There doesn't have an application for updating");
}
@Override
public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName, int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Change Life cycle status change " + lifecycleIdentifier + "request received to the DAO "
+ "level for the application with " + "the UUID '" + applicationUUID + "' from the user "
+ userName);
}
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getDBConnection();
String sql = "UPDATE APPM_APPLICATION SET "
+ "LIFECYCLE_STATE_ID = (SELECT ID FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?), "
+ "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ? AND TENANT_ID "
+ "= ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, lifecycleIdentifier);
stmt.setString(2, userName);
stmt.setDate(3, new Date(System.currentTimeMillis()));
stmt.setString(4, applicationUUID);
stmt.setInt(5, tenantId);
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred while changing lifecycle of application: " + applicationUUID + " to: "
+ lifecycleIdentifier + " state.", e);
} finally {
Util.cleanupResources(stmt, null);
}
}
@Override
public List<LifecycleStateTransition> getNextLifeCycleStates(String applicationUUID, int tenantId)
throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM "
+ "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LC_STATE_TRANSITION WHERE "
+ "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) "
+ "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID";
try {
connection = this.getDBConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, applicationUUID);
preparedStatement.setInt(2, tenantId);
resultSet = preparedStatement.executeQuery();
List<LifecycleStateTransition> lifecycleStateTransitions = new ArrayList<>();
while (resultSet.next()) {
LifecycleStateTransition lifecycleStateTransition = new LifecycleStateTransition();
lifecycleStateTransition.setDescription(resultSet.getString(2));
lifecycleStateTransition.setNextState(resultSet.getString(1));
lifecycleStateTransition.setPermission(resultSet.getString(3));
lifecycleStateTransitions.add(lifecycleStateTransition);
}
return lifecycleStateTransitions;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error while getting the DBConnection for getting the life "
+ "cycle states for the application with the UUID : " + applicationUUID, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("SQL exception while executing the query '" + sql + "'.", e);
} finally {
Util.cleanupResources(preparedStatement, resultSet);
}
}
@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);
}
int index = 0;
String sql = "UPDATE AP_APP SET ";
}
@Override
public boolean isApplicationExist(String categoryName) throws ApplicationManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM APPM_APPLICATION WHERE APPLICATION_CATEGORY_ID = (SELECT ID FROM "
+ "APPM_APPLICATION_CATEGORY WHERE NAME = ?)";
try {
conn = this.getDBConnection();
stmt = conn.prepareStatement(sql);
stmt.setString(1, categoryName);
rs = stmt.executeQuery();
return rs.next();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Database Connection Exception while trying to check the " + "applications for teh category "
+ categoryName, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"SQL Exception while trying to get the application related with categories, while executing " + sql,
e);
} finally {
Util.cleanupResources(stmt, rs);
}
if (application.getName() != null && !application.getName().equals(existingApplication.getName())) {
sql += "NAME = ?, ";
}
@Override
public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
String sql = "";
boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported();
try {
conn = this.getDBConnection();
int index = 0;
sql += "UPDATE APPM_APPLICATION SET NAME = COALESCE (?, NAME), SHORT_DESCRIPTION = COALESCE "
+ "(?, SHORT_DESCRIPTION), DESCRIPTION = COALESCE (?, DESCRIPTION), SCREEN_SHOT_COUNT = "
+ "COALESCE (?, SCREEN_SHOT_COUNT), VIDEO_NAME = COALESCE (?, VIDEO_NAME), MODIFIED_AT = COALESCE "
+ "(?, MODIFIED_AT), ";
if (application.getPayment() != null) {
sql += " IS_FREE = COALESCE (?, IS_FREE), ";
if (application.getPayment().getPaymentCurrency() != null) {
sql += "PAYMENT_CURRENCY = COALESCE (?, PAYMENT_CURRENCY), ";
if (application.getType() != null && !application.getType().equals(existingApplication.getType())){
sql += "TYPE = ?, ";
}
sql += "PAYMENT_PRICE = COALESCE (?, PAYMENT_PRICE), ";
if (application.getAppCategory() != null && !application.getAppCategory().equals(existingApplication.getAppCategory())){
sql += "APP_CATEGORY = ?, ";
}
if (application.getCategory() != null && application.getCategory().getId() != 0) {
sql += "APPLICATION_CATEGORY_ID = COALESCE (?, APPLICATION_CATEGORY_ID), ";
if (application.getIsRestricted() != existingApplication.getIsRestricted()){
sql += "RESTRICTED = ? ";
}
if (application.getPlatform() != null && application.getPlatform().getId() != 0) {
sql += "PLATFORM_ID = COALESCE (?, PLATFORM_ID), ";
if (application.getIsFree() != existingApplication.getIsFree()){
sql += "IS_FREE = ? ";
}
sql += "TENANT_ID = COALESCE (?, TENANT_ID) WHERE UUID = ?";
sql += "WHERE ID = ?";
stmt = conn.prepareStatement(sql);
if (application.getName() != null && !application.getName().equals(existingApplication.getName())) {
stmt.setString(++index, application.getName());
stmt.setString(++index, application.getShortDescription());
stmt.setString(++index, application.getDescription());
stmt.setInt(++index, application.getScreenShotCount());
stmt.setString(++index, application.getVideoName());
stmt.setDate(++index, new Date(application.getModifiedAt().getTime()));
if (application.getPayment() != null) {
stmt.setBoolean(++index, application.getPayment().isFreeApp());
if (application.getPayment().getPaymentCurrency() != null) {
stmt.setString(++index, application.getPayment().getPaymentCurrency());
}
stmt.setFloat(++index, application.getPayment().getPaymentPrice());
if (application.getType() != null && !application.getType().equals(existingApplication.getType())){
stmt.setString(++index, application.getType());
}
if (application.getCategory() != null && application.getCategory().getId() != 0) {
stmt.setInt(++index, application.getCategory().getId());
if (application.getAppCategory() != null && !application.getAppCategory().equals(existingApplication.getAppCategory())){
stmt.setString(++index, application.getAppCategory());
}
if (application.getPlatform() != null && application.getPlatform().getId() != 0) {
stmt.setInt(++index, application.getPlatform().getId());
if (application.getIsRestricted() != existingApplication.getIsRestricted()){
stmt.setInt(++index, application.getIsRestricted());
}
if (application.getIsFree() != existingApplication.getIsFree()){
stmt.setInt(++index, application.getIsFree());
}
stmt.setInt(++index, tenantId);
stmt.setString(++index, application.getUuid());
stmt.executeUpdate();
application.setId(getApplicationId(application.getUuid(), tenantId));
sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, application.getId());
stmt.executeUpdate();
// delete existing properties and add new ones. if no properties are set, existing ones will be deleted.
sql = "DELETE FROM APPM_APPLICATION_PROPERTY WHERE APPLICATION_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, application.getId());
stmt.setInt(++index, application.getId());
stmt.executeUpdate();
insertApplicationTagsAndProperties(application, stmt, conn, isBatchExecutionSupported);
return application;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
@ -580,90 +400,21 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
/**
* To insert application properties and Tags
*
* @param application Application in which the properties and tags need to be inserted
*/
private void insertApplicationTagsAndProperties(Application application, PreparedStatement stmt, Connection
conn, boolean isBatchExecutionSupported) throws SQLException {
String sql;
if (application.getTags() != null && application.getTags().size() > 0) {
sql = "INSERT INTO APPM_APPLICATION_TAG (NAME, APPLICATION_ID) VALUES (?, ?); ";
stmt = conn.prepareStatement(sql);
for (String tag : application.getTags()) {
stmt.setString(1, tag);
stmt.setInt(2, application.getId());
if (isBatchExecutionSupported) {
stmt.addBatch();
} else {
stmt.execute();
}
}
if (isBatchExecutionSupported) {
stmt.executeBatch();
}
}
if (application.getProperties() != null && application.getProperties().size() > 0) {
sql = "INSERT INTO APPM_APPLICATION_PROPERTY (PROP_KEY, PROP_VAL, APPLICATION_ID) VALUES (?, ?, ?); ";
stmt = conn.prepareStatement(sql);
Iterator it = application.getProperties().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> property = (Map.Entry) it.next();
stmt.setString(1, property.getKey());
stmt.setString(2, property.getValue());
stmt.setInt(3, application.getId());
if (isBatchExecutionSupported) {
stmt.addBatch();
} else {
stmt.execute();
}
}
if (isBatchExecutionSupported) {
stmt.executeBatch();
}
}
}
@Override
public void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getDBConnection();
String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, uuid);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while deleting the application: " + uuid, e);
} finally {
Util.cleanupResources(stmt, null);
}
}
@Override
public void deleteProperties(int applicationId) throws ApplicationManagementDAOException {
public void deleteApplication(int appId) throws ApplicationManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getDBConnection();
String sql = "DELETE FROM APPM_APPLICATION_PROPERTY WHERE APPLICATION_ID = ?";
String sql = "DELETE FROM AP_APP WHERE ID = ? ";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, applicationId);
stmt.setInt(1, appId);
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred while deleting properties of application: " + applicationId, e);
throw new ApplicationManagementDAOException("Error occurred while deleting the application: " , e);
} finally {
Util.cleanupResources(stmt, null);
}
@ -717,5 +468,4 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
return id;
}
}

@ -25,23 +25,26 @@ import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* GenericApplicationReleaseDAOImpl holds the implementation of ApplicationRelease related DAO operations.
*/
public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements ApplicationReleaseDAO {
/**
* To insert the Application Release Details.
*
* @param appId Id of the application
* @param applicationRelease Application Release the properties of which that need to be inserted.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
@Override
public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId) throws
ApplicationManagementDAOException {
@ -51,7 +54,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
String sql = "INSERT INTO AP_APP_RELEASE (VERSION,TENANT_ID,UUID,RELEASE_TYPE,APP_PRICE,STORED_LOCATION, "
+ "BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, APP_HASH_VALUE,SHARED_WITH_ALL_TENANTS, "
+ "APP_META_INFO,AP_APP_ID) VALUES "
+ "APP_META_INFO,CREATED_BY,AP_APP_ID) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
int index = 0;
@ -71,13 +74,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
statement.setString(++index, applicationRelease.getAppHashValue());
statement.setInt(++index, applicationRelease.getIsSharedWithAllTenants());
statement.setString(++index, applicationRelease.getMetaData());
statement.setString(++index, applicationRelease.getApplicationCreator());
statement.setInt(++index, appId);
statement.executeUpdate();
resultSet = statement.getGeneratedKeys();
if (resultSet.next()) {
applicationRelease.setId(resultSet.getInt(1));
}
insertApplicationReleaseProperties(connection, applicationRelease);
return applicationRelease;
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
@ -90,142 +93,170 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
}
}
/**
* To get release details of a specific application.
*
* @param applicationName Name of the application.
* @param applicationType Type of the application.
* @param versionName version name of the application.
* @param releaseType type of the application release.
* @param tenantId Tenant Id
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
@Override
public ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId)
throws ApplicationManagementDAOException {
public ApplicationRelease getRelease(String applicationName,String applicationType, String versionName,
String releaseType, int tenantId) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
ResultSet resultSet = null;
String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE VERSION_NAME = ? AND APPM_APPLICATION_ID = "
+ "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ? and TENANT_ID = ?)";
ApplicationRelease applicationRelease = null;
ResultSet rsProperties = null;
String sql = "SELECT AR.ID AS RELESE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE,"
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, "
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR.PUBLISHED_BY, "
+ "AR.PUBLISHED_AT, AR.STARS, AL.CURRENT_STATE, AL.PREVIOUSE_STATE, AL.UPDATED_BY, AL.UPDATED_AT FROM "
+ "AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL "
+ "WHERE AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME=? AND TYPE=? AND TENANT_ID=?)"
+ " AND AR.VERSION=? AND AR.RELEASE_TYPE=? AND AL.AP_APP_RELEASE_ID=AR.ID "
+ "AND AL.TENANT_ID=AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setString(1, versionName);
statement.setString(2, applicationUuid);
statement.setString(1, applicationName);
statement.setString(2, applicationType);
statement.setInt(3, tenantId);
statement.setString(4, versionName);
statement.setString(5, releaseType);
resultSet = statement.executeQuery();
if (resultSet.next()) {
applicationRelease = new ApplicationRelease();
applicationRelease.setVersion(versionName);
applicationRelease.setDefault(resultSet.getBoolean("IS_DEFAULT"));
applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT"));
applicationRelease.setReleaseType(resultSet.getString("RELEASE_CHANNEL"));
applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS"));
applicationRelease.setResource(resultSet.getString("RELEASE_RESOURCE"));
sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID=?";
statement = connection.prepareStatement(sql);
statement.setInt(1, resultSet.getInt("ID"));
rsProperties = statement.executeQuery();
Map<String, String> properties = new HashMap<>();
while (rsProperties.next()) {
properties.put(rsProperties.getString("PROP_KEY"),
rsProperties.getString("PROP_VAL"));
}
applicationRelease.setProperties(properties);
applicationRelease.setId(resultSet.getInt("RELESE_ID"));
applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION"));
applicationRelease.setUuid(resultSet.getString("UUID"));
applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE"));
applicationRelease.setPrice(resultSet.getDouble("APP_PRICE"));
applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION"));
applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION"));
applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1"));
applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2"));
applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3"));
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setStarts(resultSet.getInt("STARS"));
applicationRelease.setCurrentState(resultSet.getString("CURRENT_STATE"));
applicationRelease.setPreviouseState(resultSet.getString("PREVIOUSE_STATE"));
applicationRelease.setStateModifiedBy(resultSet.getString("UPDATED_BY"));
applicationRelease.setStateModifiedAt(resultSet.getTimestamp("UPDATED_AT"));
}
return applicationRelease;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
+ "release details of the application with UUID " + applicationUuid + " and version " +
+ "release details of the application with " + applicationName + " and version " +
versionName, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error while getting release details of the application " +
applicationUuid + " and version " + versionName + " , while executing the query " + sql, e);
applicationName + " and version " + versionName + " , while executing the query " + sql, e);
} finally {
Util.cleanupResources(statement, resultSet);
Util.cleanupResources(null, rsProperties);
}
}
/**
* To insert the application release properties.
*
* @param applicationName Name of the application.
* @param applicationType Type of the application.
* @param tenantId Tenant Id
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
@Override
public List<ApplicationRelease> getApplicationReleases(String applicationUUID, int tenantId)
public List<ApplicationRelease> getApplicationReleases(String applicationName, String applicationType, int tenantId)
throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
ResultSet resultSet = null;
String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = (SELECT ID FROM "
+ "APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)";
List<ApplicationRelease> applicationReleases = new ArrayList<>();
ResultSet rsProperties = null;
String sql = "SELECT AR.ID AS RELESE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE,"
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS "
+ "SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, "
+ "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, "
+ "AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS FROM AP_APP_RELEASE AS "
+ "AR where AR.AP_APP_ID=(SELECT ID FROM AP_APP WHERE NAME = ? AND TYPE = ? "
+ "AND TENANT_ID = ?) AND AR.TENANT_ID = ? ;";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setString(1, applicationUUID);
statement.setInt(2, tenantId);
statement.setString(1, applicationName);
statement.setString(2, applicationType);
statement.setInt(3, tenantId);
statement.setInt(4, tenantId);
resultSet = statement.executeQuery();
while (resultSet.next()) {
ApplicationRelease applicationRelease = new ApplicationRelease();
applicationRelease.setVersion(resultSet.getString("VERSION_NAME"));
applicationRelease.setDefault(resultSet.getBoolean("IS_DEFAULT"));
applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT"));
applicationRelease.setReleaseType(resultSet.getString("RELEASE_CHANNEL"));
applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS"));
applicationRelease.setResource(resultSet.getString("RELEASE_RESOURCE"));
sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID= ?";
statement = connection.prepareStatement(sql);
statement.setInt(1, resultSet.getInt("ID"));
rsProperties = statement.executeQuery();
Map<String, String> properties = new HashMap<>();
while (rsProperties.next()) {
properties.put(rsProperties.getString("PROP_KEY"), rsProperties.getString("PROP_VAL"));
}
applicationRelease.setProperties(properties);
applicationRelease.setId(resultSet.getInt("RELESE_ID"));
applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION"));
applicationRelease.setUuid(resultSet.getString("UUID"));
applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE"));
applicationRelease.setPrice(resultSet.getDouble("APP_PRICE"));
applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION"));
applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION"));
applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1"));
applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2"));
applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3"));
applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE"));
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setStarts(resultSet.getInt("STARS"));
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 UUID " + applicationUUID, e);
+ "release details of the application with Name " + applicationName, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error while getting all the release details of the " + "application " + applicationUUID
"Error while getting all the release details of the " + applicationName + " application"
+ ", while executing the query " + sql, e);
} finally {
Util.cleanupResources(statement, resultSet);
Util.cleanupResources(null, rsProperties);
}
}
/**
* To Update starts of an application release.
*
* @param id Id of the application Release.
* @param stars given stars for the application release.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
@Override
public ApplicationRelease updateRelease(ApplicationRelease applicationRelease)
throws ApplicationManagementDAOException {
public void updateStars(int id, int stars) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE)," +
" RELEASE_CHANNEL = IFNULL (?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), " +
"IS_DEFAULT = IFNULL (?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
String sql = "UPDATE AP_APP_RELEASE SET STARS = ? WHERE ID = ?;";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setString(1, applicationRelease.getResource());
statement.setString(2, String.valueOf(applicationRelease.getReleaseType()));
statement.setString(3, applicationRelease.getReleaseDetails());
statement.setBoolean(4, applicationRelease.isDefault());
statement.setInt(5, applicationRelease.getApplication().getId());
statement.setString(6, applicationRelease.getVersion());
statement.setInt(1, stars);
statement.setInt(2, id);
statement.executeUpdate();
sql = "DELETE FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID = ?";
statement = connection.prepareStatement(sql);
statement.setInt(1, applicationRelease.getId());
statement.executeUpdate();
insertApplicationReleaseProperties(connection, applicationRelease);
return applicationRelease;
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Database connection exception while trying to update the "
+ "Application release for the application with UUID " + applicationRelease.getApplication()
.getUuid() + " for the version " + applicationRelease.getVersion(), e);
throw new ApplicationManagementDAOException(
"Database connection exception while trying to update the application release", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"SQL exception while updating the release ,while executing the query " + sql, e);
@ -234,11 +265,34 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
}
}
// have to complete
//Todo
/**
* To insert the application release properties.
*
* @param applicationRelease Application Release the properties of which that need to be inserted.
* @throws SQLException SQL Exception.
*/
@Override
public ApplicationRelease updateRelease(ApplicationRelease applicationRelease)
throws ApplicationManagementDAOException {
return applicationRelease;
}
//
/**
* To delete an application release.
*
* @param id Id of the application Release.
* @param version version name of the application release.
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
@Override
public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "DELETE FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
String sql = "DELETE FROM AP_APP_RELEASE WHERE ID = ? AND VERSION = ?";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
@ -257,116 +311,4 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
}
}
@Override
public void deleteReleaseProperties(int id) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "DELETE FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID = ?";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
statement.setInt(1, id);
statement.executeUpdate();
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException(
"Database connection exception while trying to delete the release properties ", e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"SQL exception while deleting the properties of application release with the id " + id, e);
} finally {
Util.cleanupResources(statement, null);
}
}
@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.
*
* @param connection Database Connection
* @param applicationRelease Application Release the properties of which that need to be inserted.
* @throws SQLException SQL Exception.
*/
private void insertApplicationReleaseProperties(Connection connection, ApplicationRelease applicationRelease)
throws SQLException {
String sql;
boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported();
if (applicationRelease.getProperties() != null && applicationRelease.getProperties().size() != 0) {
sql = "INSERT INTO APPM_RELEASE_PROPERTY (PROP_KEY, PROP_VALUE, APPLICATION_RELEASE_ID) VALUES (?,?,?)";
PreparedStatement statement = connection.prepareStatement(sql);
for (Object entry : applicationRelease.getProperties().entrySet()) {
Map.Entry<String, String> property = (Map.Entry) entry;
statement.setString(1, property.getKey());
statement.setString(2, property.getValue());
statement.setInt(3, applicationRelease.getId());
if (isBatchExecutionSupported) {
statement.addBatch();
} else {
statement.execute();
}
}
if (isBatchExecutionSupported) {
statement.executeBatch();
}
}
}
/**
* 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);
}
}
}

@ -1,187 +0,0 @@
/*
*
* Copyright (c) ${date}, 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.dao.impl.lifecycle;
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.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleDAO;
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.exception.LifeCycleManagementDAOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
/**
* Concrete implementation for Lifecycle related DB operations.
*/
public class GenericLifecycleImpl extends AbstractDAOImpl implements LifecycleDAO {
@Override
public Lifecycle getLifeCycleOfApplication(int identifier) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT ID, CREATED_BY, CREATED_TIMESTAMP, APPROVED, APPROVED_TIMESTAMP, APPROVED_BY, "
+ "PUBLISHED, PUBLISHED_BY, PUBLISHED_TIMESTAMP, RETIRED FROM AP_APP_LIFECYCLE WHERE "
+ "AP_APP_RELEASE_ID = ? ";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, identifier);
rs = stmt.executeQuery();
Lifecycle lifecycle = null;
if (rs.next()) {
lifecycle = new Lifecycle();
lifecycle.setId(rs.getInt("ID"));
lifecycle.setCreatedBy(rs.getString("CREATED_BY"));
lifecycle.setCreatedAt(rs.getDate("CREATED_TIMESTAMP"));
lifecycle.setIsApproved(rs.getInt("APPROVED"));
lifecycle.setApprovedAt(rs.getDate("APPROVED_TIMESTAMP"));
lifecycle.setApprovedBy(rs.getString("APPROVED_BY"));
lifecycle.setIsPublished(rs.getInt("PUBLISHED"));
lifecycle.setPublishedBy(rs.getString("PUBLISHED_BY"));
lifecycle.setPublishedAt(rs.getDate("PUBLISHED_TIMESTAMP"));
lifecycle.setIsRetired(rs.getInt("RETIRED"));
}
return lifecycle;
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while getting application List", e);
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
public List<Lifecycle> getLifecyclesOfAllAppVersions(int identifier) throws LifeCycleManagementDAOException {
List<Lifecycle> lifecycles = new ArrayList<>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT ID, CREATED_BY, CREATED_TIMESTAMP, APPROVED, APPROVED_TIMESTAMP, APPROVED_BY, "
+ "PUBLISHED, PUBLISHED_BY, PUBLISHED_TIMESTAMP, RETIRED FROM AP_APP_LIFECYCLE WHERE "
+ "AP_APP_ID = ? ";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, identifier);
rs = stmt.executeQuery();
while (rs.next()) {
Lifecycle lifecycle = new Lifecycle();
lifecycle.setId(rs.getInt("ID"));
lifecycle.setCreatedBy(rs.getString("CREATED_BY"));
lifecycle.setCreatedAt(rs.getDate("CREATED_TIMESTAMP"));
lifecycle.setIsApproved(rs.getInt("APPROVED"));
lifecycle.setApprovedAt(rs.getDate("APPROVED_TIMESTAMP"));
lifecycle.setApprovedBy(rs.getString("APPROVED_BY"));
lifecycle.setIsPublished(rs.getInt("PUBLISHED"));
lifecycle.setPublishedBy(rs.getString("PUBLISHED_BY"));
lifecycle.setPublishedAt(rs.getDate("PUBLISHED_TIMESTAMP"));
lifecycle.setIsRetired(rs.getInt("RETIRED"));
lifecycles.add(lifecycle);
}
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while retrieving lifecycle states.", e);
} finally {
Util.cleanupResources(stmt, rs);
}
return lifecycles;
}
@Override
public void addLifecycle(Lifecycle lifecycle) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "INSERT INTO AP_APP_LIFECYCLE ('CREATED_BY', 'CREATED_TIMESTAMP') VALUES (?, ?)";
stmt = conn.prepareStatement(sql);
stmt.setString(1, lifecycle.getCreatedBy());
stmt.setDate(2, new Date(lifecycle.getCreatedAt().getTime()));
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle ", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
// have to modify
@Override
public void updateLifecycleOfApplication(LifecycleState state) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "INSERT INTO APPM_LIFECYCLE_STATE ('NAME', 'IDENTIFIER',) VALUES (?, ?)";
stmt = conn.prepareStatement(sql);
stmt.setString(1, state.getName());
stmt.setString(2, state.getIdentifier());
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getIdentifier(), e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
public void deleteLifecycleOfApplication(String identifier) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "DELETE FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, identifier);
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while deleting lifecycle: " + identifier, e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
// end modification
}

@ -39,59 +39,68 @@ import java.util.List;
public class GenericLifecycleStateImpl extends AbstractDAOImpl implements LifecycleStateDAO {
@Override
public LifecycleState getLifeCycleStateByIdentifier(String identifier) throws ApplicationManagementDAOException {
public LifecycleState getLatestLifeCycleStateByReleaseID(int identifier) throws ApplicationManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT * FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ? ";
String sql = "SELECT ID, CURRENT_STATE, PREVIOUSE_STATE, TENANT_ID, UPDATED_AT, UPDATED_BY FROM "
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_RELEASE_ID=? ORDER BY UPDATED_AT DESC;";
stmt = conn.prepareStatement(sql);
stmt.setString(1, identifier);
stmt.setInt(1, identifier);
rs = stmt.executeQuery();
LifecycleState lifecycleState = null;
if (rs.next()) {
lifecycleState = new LifecycleState();
lifecycleState.setId(rs.getInt("ID"));
lifecycleState.setName(rs.getString("NAME"));
lifecycleState.setIdentifier(rs.getString("IDENTIFIER"));
lifecycleState.setDescription(rs.getString("DESCRIPTION"));
lifecycleState.setCurrentState(rs.getString("CURRENT_STATE"));
lifecycleState.setPreviousState(rs.getString("PREVIOUSE_STATE"));
lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT"));
lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY"));
}
return lifecycleState;
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application List", 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 to get latest"
+ " lifecycle state for a specific application", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
public List<LifecycleState> getLifecycleStates() throws LifeCycleManagementDAOException {
public List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException {
List<LifecycleState> lifecycleStates = new ArrayList<>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
int index = 0;
try {
conn = this.getDBConnection();
String sql = "SELECT IDENTIFIER, NAME, DESCRIPTION FROM APPM_LIFECYCLE_STATE";
String sql = "SELECT ID, CURRENT_STATE, PREVIOUSE_STATE, TENANT_ID, UPDATED_AT, UPDATED_BY FROM "
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_RELEASE_ID = ? ORDER BY UPDATED_AT ASC;";
stmt = conn.prepareStatement(sql);
stmt.setInt(++index,appReleaseId);
rs = stmt.executeQuery();
while (rs.next()) {
LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setIdentifier(rs.getString("IDENTIFIER"));
lifecycleState.setName(rs.getString("NAME"));
lifecycleState.setDescription(rs.getString("DESCRIPTION"));
lifecycleState.setId(rs.getInt("ID"));
lifecycleState.setCurrentState(rs.getString("CURRENT_STATE"));
lifecycleState.setPreviousState(rs.getString("PREVIOUSE_STATE"));
lifecycleState.setTenantId(rs.getInt("TENANT_ID"));
lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT"));
lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY"));
lifecycleStates.add(lifecycleState);
}
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection when getting "
+ "lifecycle states for an application", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while retrieving lifecycle states.", e);
} finally {
@ -104,35 +113,38 @@ public class GenericLifecycleStateImpl extends AbstractDAOImpl implements Lifecy
public void addLifecycleState(LifecycleState state) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "INSERT INTO APPM_LIFECYCLE_STATE ('NAME', 'IDENTIFIER', 'DESCRIPTION') VALUES (?, ?, ?)";
String sql = "INSERT INTO AP_APP_LIFECYCLE_STATE (CURRENT_STATE, PREVIOUSE_STATE, TENANT_ID, UPDATED_BY, "
+ "AP_APP_RELEASE_ID, AP_APP_ID) VALUES (?,?, ?, ?,?,?);";
stmt = conn.prepareStatement(sql);
stmt.setString(1, state.getName());
stmt.setString(2, state.getIdentifier());
stmt.setString(3, state.getDescription());
stmt.setString(1, state.getCurrentState());
stmt.setString(2, state.getPreviousState());
stmt.setInt(3, state.getTenantId());
stmt.setString(4, state.getUpdatedBy());
stmt.setInt(5, state.getReleaseId());
stmt.setInt(6, state.getAppId());
stmt.executeUpdate();
} catch (DBConnectionException e) {
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) {
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getIdentifier(), e);
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getCurrentState(), e);
} finally {
Util.cleanupResources(stmt, rs);
Util.cleanupResources(stmt, null);
}
}
@Override
public void deleteLifecycleState(String identifier) throws LifeCycleManagementDAOException {
public void deleteLifecycleState(int identifier) throws LifeCycleManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "DELETE FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?";
String sql = "DELETE FROM AP_APP_LIFECYCLE_STATE WHERE ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, identifier);
stmt.setInt(1, identifier);
stmt.executeUpdate();
} catch (DBConnectionException e) {

@ -26,21 +26,17 @@ import org.wso2.carbon.device.application.mgt.common.*;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleDAO;
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
import org.wso2.carbon.device.application.mgt.core.exception.ValidationException;
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.HelperUtil;
import org.wso2.carbon.device.mgt.core.dao.*;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.Date;
import java.util.List;
/**

Loading…
Cancel
Save