|
|
@ -41,8 +41,7 @@ import java.util.List;
|
|
|
|
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
|
|
|
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
|
|
|
private static Log log = LogFactory.getLog(GenericPlatformDAOImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(GenericPlatformDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public int register(int tenantId, Platform platform) throws PlatformManagementDAOException {
|
|
|
|
public int register(int tenantId, Platform platform) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int platformId = getPlatformId(tenantId, platform.getIdentifier());
|
|
|
|
int platformId = getPlatformId(tenantId, platform.getIdentifier());
|
|
|
@ -50,7 +49,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
String insertToPlatform = "INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_ID, NAME, FILE_BASED, "
|
|
|
|
String insertToPlatform = "INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_ID, NAME, FILE_BASED, "
|
|
|
|
+ "DESCRIPTION, IS_SHARED, ICON_NAME)" + " VALUES (?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
+ "DESCRIPTION, IS_SHARED, ICON_NAME, IS_DEFAULT_TENANT_MAPPING)" + " VALUES (?, ?, ?, ?, "
|
|
|
|
|
|
|
|
+ "?, ?, ?, ?)";
|
|
|
|
preparedStatement = connection.prepareStatement(insertToPlatform);
|
|
|
|
preparedStatement = connection.prepareStatement(insertToPlatform);
|
|
|
|
preparedStatement.setString(1, platform.getIdentifier());
|
|
|
|
preparedStatement.setString(1, platform.getIdentifier());
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
@ -59,6 +59,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
preparedStatement.setString(5, platform.getDescription());
|
|
|
|
preparedStatement.setString(5, platform.getDescription());
|
|
|
|
preparedStatement.setBoolean(6, platform.isShared());
|
|
|
|
preparedStatement.setBoolean(6, platform.isShared());
|
|
|
|
preparedStatement.setString(7, platform.getIconName());
|
|
|
|
preparedStatement.setString(7, platform.getIconName());
|
|
|
|
|
|
|
|
preparedStatement.setBoolean(8, platform.isDefaultTenantMapping());
|
|
|
|
preparedStatement.execute();
|
|
|
|
preparedStatement.execute();
|
|
|
|
|
|
|
|
|
|
|
|
platformId = getPlatformId(tenantId, platform.getIdentifier());
|
|
|
|
platformId = getPlatformId(tenantId, platform.getIdentifier());
|
|
|
@ -78,11 +79,14 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
String insertToPlatform =
|
|
|
|
String insertToPlatform =
|
|
|
|
"INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_ID, FILE_BASED)" + " VALUES (?, ?, ?)";
|
|
|
|
"INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_ID, FILE_BASED, IS_SHARED, "
|
|
|
|
|
|
|
|
+ "IS_DEFAULT_TENANT_MAPPING) VALUES (?, ?, ?, ?, ?)";
|
|
|
|
preparedStatement = connection.prepareStatement(insertToPlatform);
|
|
|
|
preparedStatement = connection.prepareStatement(insertToPlatform);
|
|
|
|
preparedStatement.setString(1, platform.getIdentifier());
|
|
|
|
preparedStatement.setString(1, platform.getIdentifier());
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
|
preparedStatement.setBoolean(3, true);
|
|
|
|
preparedStatement.setBoolean(3, true);
|
|
|
|
|
|
|
|
preparedStatement.setBoolean(4, platform.isShared());
|
|
|
|
|
|
|
|
preparedStatement.setBoolean(5, platform.isDefaultTenantMapping());
|
|
|
|
preparedStatement.execute();
|
|
|
|
preparedStatement.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (platformId == -1) {
|
|
|
|
if (platformId == -1) {
|
|
|
@ -109,9 +113,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public void update(int tenantId, String oldPlatformIdentifier, Platform platform)
|
|
|
|
public void update(int tenantId, String oldPlatformIdentifier, Platform platform) throws
|
|
|
|
throws PlatformManagementDAOException {
|
|
|
|
PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int platformId = getPlatformId(tenantId, oldPlatformIdentifier);
|
|
|
|
int platformId = getPlatformId(tenantId, oldPlatformIdentifier);
|
|
|
@ -121,7 +124,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
if (platformId != -1) {
|
|
|
|
if (platformId != -1) {
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
String insertToPlatform = "UPDATE APPM_PLATFORM SET DESCRIPTION=?, IS_SHARED=?, ICON_NAME=?";
|
|
|
|
String insertToPlatform = "UPDATE APPM_PLATFORM SET DESCRIPTION=?, IS_SHARED=?, ICON_NAME=?, "
|
|
|
|
|
|
|
|
+ "IS_DEFAULT_TENANT_MAPPING=?";
|
|
|
|
if (!isIdentifierNull) {
|
|
|
|
if (!isIdentifierNull) {
|
|
|
|
insertToPlatform += ",IDENTIFIER = ? ";
|
|
|
|
insertToPlatform += ",IDENTIFIER = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -133,19 +137,20 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
preparedStatement.setString(1, platform.getDescription());
|
|
|
|
preparedStatement.setString(1, platform.getDescription());
|
|
|
|
preparedStatement.setBoolean(2, platform.isShared());
|
|
|
|
preparedStatement.setBoolean(2, platform.isShared());
|
|
|
|
preparedStatement.setString(3, platform.getIconName());
|
|
|
|
preparedStatement.setString(3, platform.getIconName());
|
|
|
|
|
|
|
|
preparedStatement.setBoolean(4, platform.isDefaultTenantMapping());
|
|
|
|
|
|
|
|
|
|
|
|
if (!isIdentifierNull && !isNameNull) {
|
|
|
|
if (!isIdentifierNull && !isNameNull) {
|
|
|
|
preparedStatement.setString(4, platform.getIdentifier());
|
|
|
|
preparedStatement.setString(5, platform.getIdentifier());
|
|
|
|
|
|
|
|
preparedStatement.setString(6, platform.getName());
|
|
|
|
|
|
|
|
preparedStatement.setInt(7, platformId);
|
|
|
|
|
|
|
|
} else if (isIdentifierNull && !isNameNull) {
|
|
|
|
preparedStatement.setString(5, platform.getName());
|
|
|
|
preparedStatement.setString(5, platform.getName());
|
|
|
|
preparedStatement.setInt(6, platformId);
|
|
|
|
preparedStatement.setInt(6, platformId);
|
|
|
|
} else if (isIdentifierNull && !isNameNull) {
|
|
|
|
|
|
|
|
preparedStatement.setString(4, platform.getName());
|
|
|
|
|
|
|
|
preparedStatement.setInt(5, platformId);
|
|
|
|
|
|
|
|
} else if (!isIdentifierNull) {
|
|
|
|
} else if (!isIdentifierNull) {
|
|
|
|
preparedStatement.setString(4, platform.getIdentifier());
|
|
|
|
preparedStatement.setString(5, platform.getIdentifier());
|
|
|
|
preparedStatement.setInt(5, platformId);
|
|
|
|
preparedStatement.setInt(6, platformId);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
preparedStatement.setInt(4, platformId);
|
|
|
|
preparedStatement.setInt(5, platformId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
preparedStatement.execute();
|
|
|
|
preparedStatement.execute();
|
|
|
|
|
|
|
|
|
|
|
@ -217,10 +222,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override public void unregister(int tenantId, String platformIdenfier, boolean isFileBased)
|
|
|
|
@Override
|
|
|
|
throws PlatformManagementDAOException {
|
|
|
|
public void unregister(int tenantId, String platformIdenfier, boolean isFileBased) throws
|
|
|
|
|
|
|
|
PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Platform platform = getPlatform(tenantId, platformIdenfier);
|
|
|
|
Platform platform = getPlatform(tenantId, platformIdenfier);
|
|
|
@ -284,8 +287,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int getTenantPlatformMapping(int tenantId, String platformIdentifier) throws
|
|
|
|
private int getTenantPlatformMapping(int tenantId, String platformIdentifier)
|
|
|
|
PlatformManagementDAOException {
|
|
|
|
throws PlatformManagementDAOException {
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
String getMapping = "SELECT MAPPING.ID as ID FROM (SELECT ID, PLATFORM_ID FROM APPM_PLATFORM_TENANT_MAPPING "
|
|
|
|
String getMapping = "SELECT MAPPING.ID as ID FROM (SELECT ID, PLATFORM_ID FROM APPM_PLATFORM_TENANT_MAPPING "
|
|
|
@ -312,8 +315,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
String deleteMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE ID = ?";
|
|
|
|
String deleteMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE ID = ?";
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -338,8 +340,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public void removeMappingTenants(String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
public void removeMappingTenants(String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
int platformId = getPlatformId(MultitenantConstants.SUPER_TENANT_ID, platformIdentifier);
|
|
|
|
int platformId = getPlatformId(MultitenantConstants.SUPER_TENANT_ID, platformIdentifier);
|
|
|
|
String getMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_ID != ? AND PLATFORM_ID=?";
|
|
|
|
String getMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_ID != ? AND PLATFORM_ID=?";
|
|
|
@ -360,23 +361,21 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override public List<Platform> getPlatforms(int tenantId) throws PlatformManagementDAOException {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<Platform> getPlatforms(int tenantId) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("GetPlaforms request received for the tenant ID " + tenantId);
|
|
|
|
log.debug("GetPlaforms request received for the tenant ID " + tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String selectQuery =
|
|
|
|
String selectQuery = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM "
|
|
|
|
"SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM WHERE TENANT_ID=? OR "
|
|
|
|
+ "WHERE TENANT_ID=? OR IS_SHARED = TRUE ) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
|
|
|
+ "IS_SHARED = TRUE AND FILE_BASED = FALSE) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
|
|
|
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID AND MAPPING.TENANT_ID = ?";
|
|
|
|
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID";
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
preparedStatement = connection.prepareStatement(selectQuery);
|
|
|
|
preparedStatement = connection.prepareStatement(selectQuery);
|
|
|
|
preparedStatement.setInt(1, tenantId);
|
|
|
|
preparedStatement.setInt(1, tenantId);
|
|
|
|
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
|
resultSet = preparedStatement.executeQuery();
|
|
|
|
resultSet = preparedStatement.executeQuery();
|
|
|
|
List<Platform> platforms = new ArrayList<>();
|
|
|
|
List<Platform> platforms = new ArrayList<>();
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -413,9 +412,9 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
public Platform getPlatform(String tenantDomain, String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
public Platform getPlatform(String tenantDomain, String platformIdentifier) throws PlatformManagementDAOException {
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
String platformQuery = "SELECT * FROM (SELECT * FROM APPM_PLATFORM WHERE (TENANT_DOMAIN=? AND IDENTIFIER=?) " +
|
|
|
|
String platformQuery = "SELECT * FROM (SELECT * FROM APPM_PLATFORM WHERE (TENANT_DOMAIN=? AND IDENTIFIER=?) "
|
|
|
|
"OR (IS_SHARED = TRUE AND IDENTIFIER=?) AND FILE_BASED = FALSE ) PLATFORM " +
|
|
|
|
+ "OR (IS_SHARED = TRUE AND IDENTIFIER=?) AND FILE_BASED = FALSE ) PLATFORM "
|
|
|
|
"LEFT JOIN APPM_PLATFORM_PROPERTIES PROPS ON PLATFORM.ID = PROPS.PLATFORM_ID";
|
|
|
|
+ "LEFT JOIN APPM_PLATFORM_PROPERTIES PROPS ON PLATFORM.ID = PROPS.PLATFORM_ID";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
preparedStatement = connection.prepareStatement(platformQuery);
|
|
|
|
preparedStatement = connection.prepareStatement(platformQuery);
|
|
|
@ -457,8 +456,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public Platform getPlatform(int tenantId, String identifier) throws PlatformManagementDAOException {
|
|
|
|
public Platform getPlatform(int tenantId, String identifier) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
@ -467,13 +465,15 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
sql = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER, PLATFORM.FILE_BASED, PLATFORM.ID, PLATFORM.NAME, PLATFORM"
|
|
|
|
sql = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER, PLATFORM.FILE_BASED, PLATFORM.ID, PLATFORM.NAME, PLATFORM"
|
|
|
|
+ ".DESCRIPTION, PLATFORM.ICON_NAME, PLATFORM.IS_SHARED FROM (SELECT * FROM APPM_PLATFORM WHERE "
|
|
|
|
+ ".DESCRIPTION, PLATFORM.ICON_NAME, PLATFORM.IS_SHARED, PLATFORM.IS_DEFAULT_TENANT_MAPPING FROM "
|
|
|
|
+ "IDENTIFIER= ? AND (TENANT_ID=? OR IS_SHARED = TRUE AND FILE_BASED = FALSE)) PLATFORM LEFT JOIN "
|
|
|
|
+ "(SELECT * FROM APPM_PLATFORM WHERE IDENTIFIER= ? AND (TENANT_ID=? OR IS_SHARED = TRUE)) "
|
|
|
|
+ "APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID";
|
|
|
|
+ "PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID "
|
|
|
|
|
|
|
|
+ "AND MAPPING.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, identifier);
|
|
|
|
stmt.setString(1, identifier);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
stmt.setInt(3, tenantId);
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
Platform platform = null;
|
|
|
|
Platform platform = null;
|
|
|
@ -481,15 +481,15 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
|
platform = new Platform();
|
|
|
|
platform = new Platform();
|
|
|
|
platform.setFileBased(rs.getBoolean(3));
|
|
|
|
platform.setFileBased(rs.getBoolean(3));
|
|
|
|
|
|
|
|
|
|
|
|
platform.setIdentifier(rs.getString(2));
|
|
|
|
platform.setIdentifier(rs.getString(2));
|
|
|
|
|
|
|
|
platform.setShared(rs.getBoolean(8));
|
|
|
|
|
|
|
|
platform.setDefaultTenantMapping(rs.getBoolean(9));
|
|
|
|
|
|
|
|
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
platform.setId(rs.getInt(4));
|
|
|
|
platform.setId(rs.getInt(4));
|
|
|
|
platform.setName(rs.getString(5));
|
|
|
|
platform.setName(rs.getString(5));
|
|
|
|
platform.setDescription(rs.getString(6));
|
|
|
|
platform.setDescription(rs.getString(6));
|
|
|
|
platform.setIconName(rs.getString(7));
|
|
|
|
platform.setIconName(rs.getString(7));
|
|
|
|
platform.setShared(rs.getBoolean(8));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.getInt(1) != 0) {
|
|
|
|
if (rs.getInt(1) != 0) {
|
|
|
|
platform.setEnabled(true);
|
|
|
|
platform.setEnabled(true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -499,17 +499,17 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return platform;
|
|
|
|
return platform;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new PlatformManagementDAOException("Error occurred while getting platform with the identifier " +
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
identifier + ", for the tenant : " + tenantId, e);
|
|
|
|
"Error occurred while getting platform with the identifier " + identifier + ", for the tenant : "
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
+ tenantId, e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new PlatformManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
throw new PlatformManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override public void removePlatforms(int tenantId) throws PlatformManagementDAOException {
|
|
|
|
public void removePlatforms(int tenantId) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
String sql = "DELETE FROM APPM_PLATFORM WHERE TENANT_ID = ?";
|
|
|
|
String sql = "DELETE FROM APPM_PLATFORM WHERE TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
@ -519,13 +519,118 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|
|
|
preparedStatement.setInt(1, tenantId);
|
|
|
|
preparedStatement.setInt(1, tenantId);
|
|
|
|
preparedStatement.executeUpdate();
|
|
|
|
preparedStatement.executeUpdate();
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new PlatformManagementDAOException("Database connection error while removing the platforms for the "
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
+ "tenant - " + tenantId);
|
|
|
|
"Database connection error while removing the platforms for the " + "tenant - " + tenantId);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new PlatformManagementDAOException("SQL exception while executing the query " + sql + " for "
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
+ "the tenant : " + tenantId);
|
|
|
|
"SQL exception while executing the query " + sql + " for " + "the tenant : " + tenantId);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(preparedStatement, null);
|
|
|
|
Util.cleanupResources(preparedStatement, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)
|
|
|
|
|
|
|
|
throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
|
|
String sql = "SELECT ID from APPM_PLATFORM where IDENTIFIER = ? AND (TENANT_ID = ? OR (TENANT_ID = ? AND "
|
|
|
|
|
|
|
|
+ "IS_SHARED = true)";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Connection connection = this.getDBConnection();
|
|
|
|
|
|
|
|
preparedStatement = connection.prepareStatement(sql);
|
|
|
|
|
|
|
|
preparedStatement.setString(1, platformIdentifier);
|
|
|
|
|
|
|
|
preparedStatement.setInt(2, tenantId);
|
|
|
|
|
|
|
|
preparedStatement.setInt(3, MultitenantConstants.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
resultSet = preparedStatement.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resultSet.next()) {
|
|
|
|
|
|
|
|
return resultSet.getInt(1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
|
|
|
|
"Database connection error while removing the platfor for the " + "tenant - " + tenantId);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
|
|
|
|
"SQL exception while executing the query " + sql + " for " + "the tenant : " + tenantId);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
Util.cleanupResources(preparedStatement, resultSet);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override public Platform getTenantOwnedPlatform(int tenantId, String platformIdentifier)
|
|
|
|
|
|
|
|
throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
String sql = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
sql = "SELECT * from APPM_PLATFORM WHERE TENANT_ID = ? AND IDENTIFIER = ?";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
|
|
|
|
stmt.setString(2, platformIdentifier);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Platform platform = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
platform = new Platform();
|
|
|
|
|
|
|
|
platform.setFileBased(rs.getBoolean("FILE_BASED"));
|
|
|
|
|
|
|
|
platform.setIdentifier(rs.getString("IDENTIFIER"));
|
|
|
|
|
|
|
|
platform.setShared(rs.getBoolean("IS_SHARED"));
|
|
|
|
|
|
|
|
platform.setDefaultTenantMapping(rs.getBoolean("IS_DEFAULT_TENANT_MAPPING"));
|
|
|
|
|
|
|
|
if (!platform.isFileBased()) {
|
|
|
|
|
|
|
|
platform.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
platform.setName(rs.getString("NAME"));
|
|
|
|
|
|
|
|
platform.setDescription(rs.getString("DESCRIPTION"));
|
|
|
|
|
|
|
|
platform.setIconName(rs.getString("ICON_NAME"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return platform;
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException("Error occurred while executing the query : " + sql + " for "
|
|
|
|
|
|
|
|
+ "getting platforms owned by tenant : " + tenantId, e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while obtaining the DB connection for getting " + "platforms owned by tenant : "
|
|
|
|
|
|
|
|
+ tenantId, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int getMultiTenantPlatforms(String identifier) throws PlatformManagementDAOException {
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
String sql = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
sql = "SELECT ID from APPM_PLATFORM WHERE TENANT_ID != ? AND IDENTIFIER=?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setInt(1, MultitenantConstants.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
stmt.setString(2, identifier);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
return rs.getInt(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException("Database Connection exception while trying to get the tenants "
|
|
|
|
|
|
|
|
+ "which has the platforms with the platform identifier : " + identifier, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException("SQL exception while executing the query " + sql + " to get the"
|
|
|
|
|
|
|
|
+ " tenants which has the platform with the platform identifier : " + identifier, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|