@ -22,11 +22,10 @@ import org.wso2.carbon.device.application.mgt.common.Platform;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException ;
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException ;
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO ;
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.exception.PlatformManagementDAOException ;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil ;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants ;
import java.sql.Connection ;
import java.sql.PreparedStatement ;
@ -38,108 +37,150 @@ import java.util.List;
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
@Override
public Platform getPlatformByIdentifier ( String identifier ) throws PlatformManagementDAOException {
Connection conn = null ;
PreparedStatement stmt = null ;
ResultSet rs = null ;
String sql = "" ;
try {
conn = this . getConnection ( ) ;
sql + = "SELECT * " ;
sql + = "FROM APPM_PLATFORM " ;
sql + = "WHERE IDENTIFIER = ? " ;
stmt = conn . prepareStatement ( sql ) ;
stmt . setString ( 1 , identifier ) ;
rs = stmt . executeQuery ( ) ;
Platform platform = null ;
if ( rs . next ( ) ) {
platform = new Platform ( ) ;
platform . setId ( rs . getInt ( "ID" ) ) ;
platform . setName ( rs . getString ( "NAME" ) ) ;
platform . setIdentifier ( rs . getString ( "IDENTIFIER" ) ) ;
}
return platform ;
} catch ( SQLException e ) {
throw new PlatformManagementDAOException ( "Error occurred while getting application List" , e ) ;
} catch ( DBConnectionException e ) {
throw new PlatformManagementDAOException ( "Error occurred while obtaining the DB connection." , e ) ;
} finally {
Util . cleanupResources ( stmt , rs ) ;
}
}
@Override
public void register ( String tenantDomain , Platform platform ) throws PlatformManagementDAOException {
public int register ( String tenantDomain , Platform platform ) throws PlatformManagementDAOException {
try {
ConnectionManagerUtil . beginTransaction ( ) ;
if ( getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) = = - 1 ) {
int platformId = getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) ;
if ( platformId = = - 1 ) {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
String insertToPlatform = "INSERT INTO APPM_PLATFORM ( CODE, TENANT_DOMAIN, NAME, DESCRIPTION, IS_SHARED, ICON_NAME)" +
" VALUES ( ?, ?, ?, ?, ?, ?)";
if ( ! platform . isFileBased ( ) ) {
String insertToPlatform = "INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_DOMAIN, NAME, FILE_BASED, DESCRIPTION, IS_SHARED, ICON_NAME)" +
" VALUES (?, ?, ?, ?, ?, ?, ?)" ;
PreparedStatement preparedStatement = connection . prepareStatement ( insertToPlatform ) ;
preparedStatement . setString ( 1 , platform . getIdentifier ( ) ) ;
preparedStatement . setString ( 2 , tenantDomain ) ;
preparedStatement . setString ( 3 , platform . getName ( ) ) ;
preparedStatement . setString ( 4 , platform . getDescription ( ) ) ;
preparedStatement . setBoolean ( 5 , platform . isShared ( ) ) ;
preparedStatement . setString ( 6 , platform . getIconName ( ) ) ;
preparedStatement . setBoolean ( 4 , false ) ;
preparedStatement . setString ( 5 , platform . getDescription ( ) ) ;
preparedStatement . setBoolean ( 6 , platform . isShared ( ) ) ;
preparedStatement . setString ( 7 , platform . getIconName ( ) ) ;
preparedStatement . execute ( ) ;
int platformID = getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) ;
platformId = getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) ;
String insertPlatformProps = "INSERT INTO APPM_PLATFORM_PROPERTIES (PLATFORM_ID, PROP_NAME, OPTIONAL, DEFAULT_VALUE) VALUES " +
"( ? , ?, ? , ?)" ;
for ( Platform . Property property : platform . getProperties ( ) ) {
preparedStatement = connection . prepareStatement ( insertPlatformProps ) ;
preparedStatement . setInt ( 1 , platformI D ) ;
preparedStatement . setInt ( 1 , platformId ) ;
preparedStatement . setString ( 2 , property . getName ( ) ) ;
preparedStatement . setBoolean ( 3 , property . isOptional ( ) ) ;
preparedStatement . setString ( 4 , property . getDefaultValue ( ) ) ;
preparedStatement . execute ( ) ;
}
} else {
String insertToPlatform = "INSERT INTO APPM_PLATFORM (IDENTIFIER, TENANT_DOMAIN, FILE_BASED)" +
" VALUES (?, ?, ?)" ;
PreparedStatement preparedStatement = connection . prepareStatement ( insertToPlatform ) ;
preparedStatement . setString ( 1 , platform . getIdentifier ( ) ) ;
preparedStatement . setString ( 2 , tenantDomain ) ;
preparedStatement . setBoolean ( 3 , true ) ;
preparedStatement . execute ( ) ;
}
if ( platformId = = - 1 ) {
platformId = getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) ;
}
ConnectionManagerUtil . commitTransaction ( ) ;
return platformId ;
} else {
if ( ! platform . isFileBased ( ) ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Platform - " + platform . getIdentifier ( )
+ " is already registered for tenant - " + tenantDomain ) ;
} else {
return platformId ;
}
} catch ( TransactionManagementException e ) {
}
} catch ( SQLException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Unable to start the transaction while trying to register the platform - "
+ platform . getIdentifier ( ) + " for tenant - " + tenantDomain , e ) ;
throw new PlatformManagementDAOException ( "Error while executing the SQL query. " , e ) ;
} catch ( PlatformManagementDAOException ex ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw ex ;
} catch ( DBConnectionException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Unable to obtain the connection while trying to register the platform - "
+ platform . getIdentifier ( ) + " for tenant - " + tenantDomain , e ) ;
} catch ( TransactionManagementException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occurred while performing the transaction on the database " +
"for adding the platform - " + platform . getIdentifier ( ) + " , tenant domain - " + tenantDomain ) ;
} finally {
ConnectionManagerUtil . closeConnection ( ) ;
}
}
@Override
public void update ( String tenantDomain , String oldPlatformIdentifier , Platform platform ) throws PlatformManagementDAOException {
try {
ConnectionManagerUtil . beginTransaction ( ) ;
int platformId = getPlatformId ( tenantDomain , oldPlatformIdentifier ) ;
if ( platformId ! = - 1 ) {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
if ( ! platform . isFileBased ( ) ) {
String insertToPlatform = "UPDATE APPM_PLATFORM SET IDENTIFIER = ?, NAME =?, DESCRIPTION=?, " +
"IS_SHARED=?, ICON_NAME=? WHERE ID = ?" ;
PreparedStatement preparedStatement = connection . prepareStatement ( insertToPlatform ) ;
preparedStatement . setString ( 1 , platform . getIdentifier ( ) ) ;
preparedStatement . setString ( 2 , platform . getName ( ) ) ;
preparedStatement . setString ( 3 , platform . getDescription ( ) ) ;
preparedStatement . setBoolean ( 4 , platform . isShared ( ) ) ;
preparedStatement . setString ( 5 , platform . getIconName ( ) ) ;
preparedStatement . execute ( ) ;
platformId = getPlatformId ( tenantDomain , platform . getIdentifier ( ) ) ;
String deletePlatformProps = "DELETE FROM APPM_PLATFORM_PROPERTIES WHERE PLATFORM_ID=?" ;
preparedStatement = connection . prepareStatement ( deletePlatformProps ) ;
preparedStatement . setInt ( 1 , platformId ) ;
preparedStatement . execute ( ) ;
String insertPlatformProps = "INSERT INTO APPM_PLATFORM_PROPERTIES (PLATFORM_ID, PROP_NAME, OPTIONAL," +
" DEFAULT_VALUE) VALUES ( ? , ?, ? , ?)" ;
for ( Platform . Property property : platform . getProperties ( ) ) {
preparedStatement = connection . prepareStatement ( insertPlatformProps ) ;
preparedStatement . setInt ( 1 , platformId ) ;
preparedStatement . setString ( 2 , property . getName ( ) ) ;
preparedStatement . setBoolean ( 3 , property . isOptional ( ) ) ;
preparedStatement . setString ( 4 , property . getDefaultValue ( ) ) ;
preparedStatement . execute ( ) ;
}
} else {
String insertToPlatform = "UPDATE APPM_PLATFORM SET IDENTIFIER = ? WHERE ID = ?" ;
PreparedStatement preparedStatement = connection . prepareStatement ( insertToPlatform ) ;
preparedStatement . setInt ( 1 , platformId ) ;
preparedStatement . execute ( ) ;
}
ConnectionManagerUtil . commitTransaction ( ) ;
} else {
throw new PlatformManagementDAOException ( "Cannot find any platform that was registered with identifier - "
+ platform . getIdentifier ( ) + " for tenant - " + tenantDomain ) ;
}
} catch ( SQLException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error while executing the SQL query. " , e ) ;
} catch ( PlatformManagementDAOException ex ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw ex ;
} catch ( DBConnectionException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Unable to obtain the connection while trying to register the platform - "
+ platform . getIdentifier ( ) + " for tenant - " + tenantDomain , e ) ;
} catch ( TransactionManagementException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occurred while performing the transaction on the database " +
"for adding the platform - " + platform . getIdentifier ( ) + " , tenant domain - " + tenantDomain ) ;
} finally {
ConnectionManagerUtil . closeConnection ( ) ;
}
}
private int getPlatformId ( String tenantDomain , String platformCode ) throws PlatformManagementDAOException {
String query = "SELECT ID FROM APPM_PLATFORM WHERE (TENANT_DOMAIN=? AND CODE=?) OR (IS_SHARED = TRUE AND CODE=?)" ;
private int getPlatformId ( String tenantDomain , String platform Identifier ) throws PlatformManagementDAOException {
String query = "SELECT ID FROM APPM_PLATFORM WHERE (TENANT_DOMAIN=? AND IDENTIFIER=?) OR (IS_SHARED = TRUE AND IDENTIFIER =?)";
try {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( query ) ;
preparedStatement . setString ( 1 , tenantDomain ) ;
preparedStatement . setString ( 2 , platformCode ) ;
preparedStatement . setString ( 3 , platformCode ) ;
preparedStatement . setString ( 2 , platform Identifier ) ;
preparedStatement . setString ( 3 , platform Identifier ) ;
ResultSet resultSet = preparedStatement . executeQuery ( ) ;
if ( resultSet . next ( ) ) {
return resultSet . getInt ( "ID" ) ;
@ -154,31 +195,29 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
@Override
public void unregister ( String tenantDomain , String platform Code ) throws PlatformManagementDAOException {
public void unregister ( String tenantDomain , String platform Idenfier ) throws PlatformManagementDAOException {
try {
ConnectionManagerUtil . beginTransaction ( ) ;
int platformId = getPlatformId ( tenantDomain , platform Code ) ;
int platformId = getPlatformId ( tenantDomain , platform Idenfier ) ;
if ( platformId ! = - 1 ) {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
String deletePlatform = "DELETE FROM APPM_PLATFORM WHERE ID = ?" ;
PreparedStatement preparedStatement = connection . prepareStatement ( deletePlatform ) ;
preparedStatement . setInt ( 1 , platformId ) ;
preparedStatement . execute ( ) ;
ConnectionManagerUtil . commitTransaction ( ) ;
} else {
throw new PlatformManagementDAOException ( "Platform - " + platformCode
throw new PlatformManagementDAOException ( "Platform identifier - " + platformIdenfier
+ " is already unregistered registered for tenant - " + tenantDomain ) ;
}
} catch ( TransactionManagementException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Unable to start the transaction while trying to register the platform - "
+ platform Code + " for tenant - " + tenantDomain , e ) ;
+ platform Idenfier + " for tenant - " + tenantDomain , e ) ;
} catch ( DBConnectionException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Unable to obtain the connection while trying to register the platform - "
+ platform Code + " for tenant - " + tenantDomain , e ) ;
+ platform Idenfier + " for tenant - " + tenantDomain , e ) ;
} catch ( SQLException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error while executing the SQL query. " , e ) ;
@ -190,26 +229,27 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
}
}
public void addMapping ( String tenantDomain , List < String > platform Code s) throws PlatformManagementDAOException {
String insertMapping = "INSERT INTO APPM_PLATFORM_TENANT_MAPPING(TENANT_DOMAIN, PLATFORM_ CODE ) VALUES (?, ?)";
public void addMapping ( String tenantDomain , List < String > platform Identifier s) throws PlatformManagementDAOException {
String insertMapping = "INSERT INTO APPM_PLATFORM_TENANT_MAPPING(TENANT_DOMAIN, PLATFORM_ ID ) VALUES (?, ?)";
try {
ConnectionManagerUtil . beginTransaction ( ) ;
for ( String platformCode : platformCodes ) {
if ( getTenantPlatformMapping ( tenantDomain , platformCode ) ! = - 1 ) {
for ( String platformIdentifier : platformIdentifiers ) {
if ( getTenantPlatformMapping ( tenantDomain , platformIdentifier ) ! = - 1 ) {
int platformId = getPlatformId ( tenantDomain , platformIdentifier ) ;
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( insertMapping ) ;
preparedStatement . setString ( 1 , tenantDomain ) ;
preparedStatement . set String( 2 , platformCode ) ;
preparedStatement . set Int( 2 , platformId ) ;
preparedStatement . execute ( ) ;
} else {
throw new PlatformManagementDAOException ( "Platform - " + platformCode + " is already assigned to tenant domain - " + tenantDomain ) ;
throw new PlatformManagementDAOException ( "Platform identifier - " + platformIdentifier + " is already assigned to tenant domain - " + tenantDomain ) ;
}
}
ConnectionManagerUtil . commitTransaction ( ) ;
} catch ( TransactionManagementException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occured while trying to add the mapping of platform - "
+ platform Code s. toString ( ) + " for tenant - " + tenantDomain , e ) ;
+ platform Identifier s. toString ( ) + " for tenant - " + tenantDomain , e ) ;
} catch ( DBConnectionException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occurred when getting the connection for the database. " , e ) ;
@ -224,13 +264,14 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
}
}
private int getTenantPlatformMapping ( String tenantDomain , String platformCode ) throws PlatformManagementDAOException {
String getMapping = "SELECT ID FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_DOMAIN=? AND PLATFORM_CODE=?" ;
private int getTenantPlatformMapping ( String tenantDomain , String platformIdentifier ) throws PlatformManagementDAOException {
String getMapping = "SELECT MAPPING.ID as ID FROM (SELECT ID FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_DOMAIN=?) MAPPING JOIN " +
"(SELECT ID FROM APPM_PLATFORM WHERE APPM_PLATFORM.IDENTIFIER=?) PLATFORM ON MAPPING.PLATFORM_ID=PLATFORM.ID" ;
try {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( getMapping ) ;
preparedStatement . setString ( 1 , tenantDomain ) ;
preparedStatement . setString ( 2 , platform Code ) ;
preparedStatement . setString ( 2 , platform Identifier ) ;
ResultSet resultSet = preparedStatement . executeQuery ( ) ;
if ( resultSet . next ( ) ) {
return resultSet . getInt ( "ID" ) ;
@ -244,30 +285,28 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
}
}
public void removeMapping ( String tenantDomain , String platform Code ) throws PlatformManagementDAOException {
public void removeMapping ( String tenantDomain , String platform Identifier ) throws PlatformManagementDAOException {
String deleteMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE ID = ?" ;
try {
ConnectionManagerUtil . beginTransaction ( ) ;
int mappingId = getTenantPlatformMapping ( tenantDomain , platform Code ) ;
int mappingId = getTenantPlatformMapping ( tenantDomain , platform Identifier ) ;
if ( mappingId ! = - 1 ) {
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( deleteMapping ) ;
preparedStatement . setInt ( 1 , mappingId ) ;
preparedStatement . execute ( ) ;
ConnectionManagerUtil . commitTransaction ( ) ;
} else {
throw new PlatformManagementDAOException ( "Platform - " + platform Code
throw new PlatformManagementDAOException ( "Platform - " + platform Identifier
+ " is already unassigned for tenant - " + tenantDomain ) ;
}
} catch ( TransactionManagementException | DBConnectionException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occurred while unassigning the platform - " + platform Code
throw new PlatformManagementDAOException ( "Error occurred while unassigning the platform - " + platform Identifier
+ " for tenant - " + tenantDomain ) ;
} catch ( SQLException e ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw new PlatformManagementDAOException ( "Error occur ed while executing the query - " + deleteMapping ) ;
throw new PlatformManagementDAOException ( "Error occur r ed while executing the query - " + deleteMapping ) ;
} catch ( PlatformManagementDAOException ex ) {
ConnectionManagerUtil . rollbackTransaction ( ) ;
throw ex ;
@ -276,19 +315,42 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
}
}
@Override
public void removeMappingTenants ( String platformIdentifier ) throws PlatformManagementDAOException {
int platformId = getPlatformId ( MultitenantConstants . SUPER_TENANT_DOMAIN_NAME , platformIdentifier ) ;
String getMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_DOMAIN != ? AND PLATFORM_ID=?" ;
try {
ConnectionManagerUtil . openConnection ( ) ;
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( getMapping ) ;
preparedStatement . setString ( 1 , MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ;
preparedStatement . setInt ( 2 , platformId ) ;
preparedStatement . execute ( ) ;
} catch ( DBConnectionException e ) {
throw new PlatformManagementDAOException ( "Error occured while obtaining the connection to get the existing " +
"Tenant - Platform Mapping." , e ) ;
} catch ( SQLException e ) {
throw new PlatformManagementDAOException ( "Error occured while executing the SQL query - " + getMapping , e ) ;
} finally {
ConnectionManagerUtil . closeConnection ( ) ;
}
}
@Override
public List < Platform > getPlatforms ( String tenantDomain ) throws PlatformManagementDAOException {
String selectQuery = "SELECT * FROM (SELECT * FROM APPM_PLATFORM WHERE TENANT_DOMAIN=? OR IS_SHARED = TRUE) PLATFORM " +
"LEFT JOIN APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM.CODE = MAPPING.PLATFORM_CODE" ;
String selectQuery = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM WHERE TENANT_DOMAIN=? OR IS_SHARED = TRUE AND FILE_BASED = FALS E) PLATFORM " +
"LEFT JOIN APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM. ID = MAPPING.PLATFORM_ID ";
try {
Connection connection = ConnectionManagerUtil . openConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( selectQuery ) ;
preparedStatement . setString ( 1 , tenantDomain ) ;
ResultSet resultSet = preparedStatement . executeQuery ( ) ;
List < Platform > platforms = new ArrayList < > ( ) ;
while ( resultSet . next ( ) ) {
String platformCode = resultSet . getString ( "PLATFORM.CODE" ) ;
String identifier = resultSet . getString ( "PLATFORM.IDENTIFIER ") ;
int mappingID = resultSet . getInt ( "MAPPING.ID" ) ;
Platform platform = getPlatform ( tenantDomain , platformCode ) ;
Platform platform = getPlatform ( tenantDomain , identifier ) ;
if ( mappingID ! = 0 ) {
platform . setEnabled ( true ) ;
} else {
@ -306,20 +368,22 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
}
}
public Platform getPlatform ( String tenantDomain , String platformCode ) throws PlatformManagementDAOException {
String platformQuery = "SELECT * FROM (SELECT * FROM APPM_PLATFORM WHERE (TENANT_DOMAIN=? AND CODE=?) OR (IS_SHARED = TRUE AND CODE=?)) PLATFORM " +
public Platform getPlatform ( String tenantDomain , String platformIdenfier ) throws PlatformManagementDAOException {
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 {
ConnectionManagerUtil . openConnection ( ) ;
Connection connection = ConnectionManagerUtil . getConnection ( ) ;
PreparedStatement preparedStatement = connection . prepareStatement ( platformQuery ) ;
preparedStatement . setString ( 1 , tenantDomain ) ;
preparedStatement . setString ( 2 , platform Code ) ;
preparedStatement . setString ( 3 , platform Code ) ;
preparedStatement . setString ( 2 , platform Idenfier ) ;
preparedStatement . setString ( 3 , platform Idenfier ) ;
ResultSet resultSet = preparedStatement . executeQuery ( ) ;
Platform platform = new Platform ( ) ;
if ( resultSet . next ( ) ) {
platform . setId ( resultSet . getInt ( "PLATFORM.ID" ) ) ;
platform . setIdentifier ( platform Code ) ;
platform . setIdentifier ( platform Idenfier ) ;
platform . setName ( resultSet . getString ( "PLATFORM.NAME" ) ) ;
platform . setIconName ( resultSet . getString ( "PLATFORM.DESCRIPTION" ) ) ;
platform . setIconName ( resultSet . getString ( "PLATFORM.ICON_NAME" ) ) ;
@ -337,12 +401,12 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
} while ( resultSet . next ( ) ) ;
platform . setProperties ( properties ) ;
} else {
platform . setIdentifier ( platform Code ) ;
platform . setIdentifier ( platform Idenfier ) ;
platform . setFileBased ( true ) ;
}
return platform ;
} catch ( DBConnectionException e ) {
throw new PlatformManagementDAOException ( "Error when loading the platform - " + platform Code , e ) ;
throw new PlatformManagementDAOException ( "Error when loading the platform - " + platform Idenfier , e ) ;
} catch ( SQLException e ) {
throw new PlatformManagementDAOException ( "Error in executing the query - " + platformQuery , e ) ;
}