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