|
|
|
@ -84,7 +84,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
return applicationId;
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when application creation", 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 {
|
|
|
|
@ -113,7 +114,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
stmt.executeBatch();
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when adding tags", 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 {
|
|
|
|
@ -146,7 +148,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
return isExist;
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection when verifying application existence", 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 {
|
|
|
|
@ -167,7 +170,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
ApplicationList applicationList = new ApplicationList();
|
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY"
|
|
|
|
|
+ " AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP.RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
|
+
|
|
|
|
|
" AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP.RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, " +
|
|
|
|
|
"AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
|
+ "AS APP_UNRESTRICTED_ROLES FROM ((AP_APP LEFT JOIN AP_APP_TAG ON AP_APP.ID = AP_APP_TAG.AP_APP_ID) "
|
|
|
|
|
+ "LEFT JOIN AP_UNRESTRICTED_ROLES ON AP_APP.ID = AP_UNRESTRICTED_ROLES.AP_APP_ID) "
|
|
|
|
|
+ "WHERE AP_APP.TENANT_ID = ?";
|
|
|
|
@ -224,7 +229,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
+ " " + tenantId + ". While executing " + sql, e);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection while "
|
|
|
|
|
+ "getting application list for the tenant " + tenantId, e);
|
|
|
|
|
+ "getting application list for the tenant " + tenantId,
|
|
|
|
|
e);
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while parsing JSON ", e);
|
|
|
|
|
} finally {
|
|
|
|
@ -325,9 +331,13 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS " +
|
|
|
|
|
"APP_TAG, AP_UNRESTRICTED_ROLES.ROLE AS AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES " +
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
|
+
|
|
|
|
|
"AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG" +
|
|
|
|
|
".TAG AS " +
|
|
|
|
|
"APP_TAG, AP_UNRESTRICTED_ROLES.ROLE AS AS ROLE FROM AP_APP, AP_APP_TAG, " +
|
|
|
|
|
"AP_UNRESTRICTED_ROLES " +
|
|
|
|
|
"WHERE AP_APP.NAME=? AND AP_APP.TYPE= ? AND AP_APP.TENANT_ID=?;";
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
@ -345,7 +355,8 @@ 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 ", 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) {
|
|
|
|
@ -366,9 +377,13 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY " +
|
|
|
|
|
"AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, " +
|
|
|
|
|
"AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.ID=?" +
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP" +
|
|
|
|
|
".APP_CATEGORY " +
|
|
|
|
|
"AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG" +
|
|
|
|
|
".TAG AS APP_TAG, " +
|
|
|
|
|
"AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE " +
|
|
|
|
|
"AP_APP.ID=?" +
|
|
|
|
|
" AND AP_APP.TENANT_ID=?;";
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
@ -385,7 +400,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error occurred while getting application details with app id " + applicationId + " While executing query ", e);
|
|
|
|
|
"Error occurred while getting application details with app id " + applicationId +
|
|
|
|
|
" While executing query ", e);
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
@ -406,8 +422,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
Boolean isAppExist = false;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP_TAG.TAG, AP_UNRESTRICTED_ROLES.ROLE AS RELESE_ID FROM "
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
|
+
|
|
|
|
|
"AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP_TAG.TAG, AP_UNRESTRICTED_ROLES.ROLE AS RELESE_ID" +
|
|
|
|
|
" FROM "
|
|
|
|
|
+ "AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.ID=?;";
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
@ -426,7 +445,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error occurred while getting application details with app ID " + appId + " While executing query ", e);
|
|
|
|
|
"Error occurred while getting application details with app ID " + appId + " While executing query ",
|
|
|
|
|
e);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
|
} finally {
|
|
|
|
@ -447,14 +467,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
String sql = "UPDATE AP_APP SET ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (application.getName() != null && !application.getName().equals(existingApplication.getName())) {
|
|
|
|
|
sql += "NAME = ?, ";
|
|
|
|
|
}
|
|
|
|
|
if (application.getType() != null && !application.getType().equals(existingApplication.getType())) {
|
|
|
|
|
sql += "TYPE = ?, ";
|
|
|
|
|
}
|
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(existingApplication.getAppCategory())) {
|
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(
|
|
|
|
|
existingApplication.getAppCategory())) {
|
|
|
|
|
sql += "APP_CATEGORY = ?, ";
|
|
|
|
|
}
|
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
@ -473,7 +493,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
if (application.getType() != null && !application.getType().equals(existingApplication.getType())) {
|
|
|
|
|
stmt.setString(2, application.getType());
|
|
|
|
|
}
|
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(existingApplication.getAppCategory())) {
|
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(
|
|
|
|
|
existingApplication.getAppCategory())) {
|
|
|
|
|
stmt.setString(3, application.getAppCategory());
|
|
|
|
|
}
|
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
|