|
|
@ -52,7 +52,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void initialize(int tenantId) throws PlatformManagementException {
|
|
|
|
public void initialize(int tenantId) throws PlatformManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
List<Platform> platforms = DAOFactory.getPlatformDAO().getPlatforms(tenantId);
|
|
|
|
List<Platform> platforms = DAOFactory.getPlatformDAO().getPlatforms(tenantId);
|
|
|
|
List<String> platformIdentifiers = new ArrayList<>();
|
|
|
|
List<String> platformIdentifiers = new ArrayList<>();
|
|
|
|
for (Platform platform : platforms) {
|
|
|
|
for (Platform platform : platforms) {
|
|
|
@ -61,19 +61,22 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, platformIdentifiers);
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, platformIdentifiers);
|
|
|
|
ConnectionManagerUtil.commitTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Transaction Management Exception while initializing the " + "platforms for the tenant : "
|
|
|
|
"Transaction Management Exception while initializing the " + "platforms for the tenant : "
|
|
|
|
+ tenantId, e);
|
|
|
|
+ tenantId, e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while initializing the " + "platforms for the tenant : " + tenantId,
|
|
|
|
"Database Connection Exception while initializing the " + "platforms for the tenant : " + tenantId,
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -86,13 +89,18 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
+ "PlatformManager level");
|
|
|
|
+ "PlatformManager level");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openConnection();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
platforms = DAOFactory.getPlatformDAO().getPlatforms(tenantId);
|
|
|
|
platforms = DAOFactory.getPlatformDAO().getPlatforms(tenantId);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (DBConnectionException | TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while getting the platforms for the tenant : " + tenantId, e);
|
|
|
|
"Database Connection Exception while getting the platforms for the tenant : " + tenantId, e);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Number of platforms received from DAO layer is " + platforms.size() + " for the tenant "
|
|
|
|
log.debug("Number of platforms received from DAO layer is " + platforms.size() + " for the tenant "
|
|
|
@ -128,17 +136,22 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
Platform platform = getPlatformFromInMemory(tenantId, identifier);
|
|
|
|
Platform platform = getPlatformFromInMemory(tenantId, identifier);
|
|
|
|
if (platform == null) {
|
|
|
|
if (platform == null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openConnection();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
platform = DAOFactory.getPlatformDAO().getPlatform(tenantId, identifier);
|
|
|
|
platform = DAOFactory.getPlatformDAO().getPlatform(tenantId, identifier);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
if (platform != null) {
|
|
|
|
if (platform != null) {
|
|
|
|
return platform;
|
|
|
|
return platform;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException | TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to get the " + "platform with the id :" + identifier
|
|
|
|
"Database Connection Exception while trying to get the " + "platform with the id :" + identifier
|
|
|
|
+ " for the tenant : " + tenantId, e);
|
|
|
|
+ " for the tenant : " + tenantId, e);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Platform(platform);
|
|
|
|
return new Platform(platform);
|
|
|
@ -175,7 +188,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
+ " cannot be shared by the tenant domain - " + tenantId);
|
|
|
|
+ " cannot be shared by the tenant domain - " + tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
int platformId = DAOFactory.getPlatformDAO().register(tenantId, platform);
|
|
|
|
int platformId = DAOFactory.getPlatformDAO().register(tenantId, platform);
|
|
|
|
if (platform.isFileBased()) {
|
|
|
|
if (platform.isFileBased()) {
|
|
|
|
platform.setId(platformId);
|
|
|
|
platform.setId(platformId);
|
|
|
@ -187,7 +200,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
if (tenantPlatforms.get(platform.getIdentifier()) == null) {
|
|
|
|
if (tenantPlatforms.get(platform.getIdentifier()) == null) {
|
|
|
|
tenantPlatforms.put(platform.getIdentifier(), platform);
|
|
|
|
tenantPlatforms.put(platform.getIdentifier(), platform);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
"Platform - " + platform.getIdentifier() + " is already registered!");
|
|
|
|
"Platform - " + platform.getIdentifier() + " is already registered!");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -204,24 +217,27 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, getListOfString(platform.getIdentifier()));
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, getListOfString(platform.getIdentifier()));
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementException("Error occurred while assigning the platforms for tenants!",
|
|
|
|
throw new PlatformManagementException("Error occurred while assigning the platforms for tenants!",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConnectionManagerUtil.commitTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Transaction Management Exception while trying to register a " + "platform with id " + platform
|
|
|
|
"Transaction Management Exception while trying to register a " + "platform with id " + platform
|
|
|
|
.getIdentifier() + " for tenant " + tenantId);
|
|
|
|
.getIdentifier() + " for tenant " + tenantId);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to register a " + "platform with id " + platform
|
|
|
|
"Database Connection Exception while trying to register a " + "platform with id " + platform
|
|
|
|
.getIdentifier() + " for tenant " + tenantId);
|
|
|
|
.getIdentifier() + " for tenant " + tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -234,11 +250,11 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
+ " cannot be shared by the tenant domain - " + tenantId);
|
|
|
|
+ " cannot be shared by the tenant domain - " + tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
Platform oldPlatform = DAOFactory.getPlatformDAO().getPlatform(tenantId, oldPlatformIdentifier);
|
|
|
|
Platform oldPlatform = DAOFactory.getPlatformDAO().getPlatform(tenantId, oldPlatformIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
if (oldPlatform == null) {
|
|
|
|
if (oldPlatform == null) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
"Cannot update platform. Platform with identifier : " + oldPlatformIdentifier
|
|
|
|
"Cannot update platform. Platform with identifier : " + oldPlatformIdentifier
|
|
|
|
+ " does not exist.");
|
|
|
|
+ " does not exist.");
|
|
|
@ -247,7 +263,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
Platform existingPlatform = DAOFactory.getPlatformDAO().getPlatform(tenantId, platform.getIdentifier());
|
|
|
|
Platform existingPlatform = DAOFactory.getPlatformDAO().getPlatform(tenantId, platform.getIdentifier());
|
|
|
|
|
|
|
|
|
|
|
|
if (existingPlatform != null) {
|
|
|
|
if (existingPlatform != null) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
throw new PlatformManagementException(
|
|
|
|
"Cannot update the identifier of the platform from '" + oldPlatformIdentifier + "' to '"
|
|
|
|
"Cannot update the identifier of the platform from '" + oldPlatformIdentifier + "' to '"
|
|
|
|
+ platform.getIdentifier() + "'. Another platform exists "
|
|
|
|
+ platform.getIdentifier() + "'. Another platform exists "
|
|
|
@ -288,7 +304,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, getListOfString(platform.getIdentifier()));
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, getListOfString(platform.getIdentifier()));
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementException("Error occurred while assigning the platforms for tenants!",
|
|
|
|
throw new PlatformManagementException("Error occurred while assigning the platforms for tenants!",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -296,19 +312,22 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
if (!platform.isShared() && oldPlatform.isShared()) {
|
|
|
|
if (!platform.isShared() && oldPlatform.isShared()) {
|
|
|
|
DAOFactory.getPlatformDAO().removeMappingTenants(platform.getIdentifier());
|
|
|
|
DAOFactory.getPlatformDAO().removeMappingTenants(platform.getIdentifier());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConnectionManagerUtil.commitTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Transaction Management Exception while trying to update " + "platform : " + oldPlatformIdentifier
|
|
|
|
"Transaction Management Exception while trying to update " + "platform : " + oldPlatformIdentifier
|
|
|
|
+ " of tenant :" + tenantId);
|
|
|
|
+ " of tenant :" + tenantId);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to update " + "platform : " + oldPlatformIdentifier
|
|
|
|
"Database Connection Exception while trying to update " + "platform : " + oldPlatformIdentifier
|
|
|
|
+ " of tenant :" + tenantId);
|
|
|
|
+ " of tenant :" + tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -321,7 +340,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void unregister(int tenantId, String identifier, boolean isFileBased) throws PlatformManagementException {
|
|
|
|
public void unregister(int tenantId, String identifier, boolean isFileBased) throws PlatformManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
DAOFactory.getPlatformDAO().unregister(tenantId, identifier, isFileBased);
|
|
|
|
DAOFactory.getPlatformDAO().unregister(tenantId, identifier, isFileBased);
|
|
|
|
|
|
|
|
|
|
|
|
if (isFileBased) {
|
|
|
|
if (isFileBased) {
|
|
|
@ -330,33 +349,41 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
tenantPlatforms.remove(identifier);
|
|
|
|
tenantPlatforms.remove(identifier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConnectionManagerUtil.commitTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Transaction Management Exception while trying to un-register " + "the platform with identifier : "
|
|
|
|
"Transaction Management Exception while trying to un-register " + "the platform with identifier : "
|
|
|
|
+ identifier + " tenant :" + tenantId, e);
|
|
|
|
+ identifier + " tenant :" + tenantId, e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.rollbackTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to un-register " + "the platform with identifier : "
|
|
|
|
"Database Connection Exception while trying to un-register " + "the platform with identifier : "
|
|
|
|
+ identifier + " tenant :" + tenantId, e);
|
|
|
|
+ identifier + " tenant :" + tenantId, e);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addMapping(int tenantId, List<String> platformIdentifiers) throws PlatformManagementException {
|
|
|
|
public void addMapping(int tenantId, List<String> platformIdentifiers) throws PlatformManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openConnection();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, platformIdentifiers);
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, platformIdentifiers);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (DBConnectionException | TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to add tenant " + "mapping for tenant ID : "
|
|
|
|
"Database Connection Exception while trying to add tenant " + "mapping for tenant ID : "
|
|
|
|
+ tenantId);
|
|
|
|
+ tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -370,13 +397,86 @@ public class PlatformManagerImpl implements PlatformManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementException {
|
|
|
|
public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openConnection();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
DAOFactory.getPlatformDAO().removeMapping(tenantId, platformIdentifier);
|
|
|
|
DAOFactory.getPlatformDAO().removeMapping(tenantId, platformIdentifier);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (DBConnectionException | TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
throw new PlatformManagementDAOException(
|
|
|
|
"Database Connection Exception while trying to remove tenant mapping for tenant ID : " + tenantId);
|
|
|
|
"Database Connection Exception while trying to remove tenant mapping for tenant ID : " + tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void updatePlatformStatus(int tenantId, String platformIdentifier, String status)
|
|
|
|
|
|
|
|
throws PlatformManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
Platform platform = DAOFactory.getPlatformDAO().getPlatform(tenantId, platformIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (platform == null) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
throw new PlatformManagementException("Platform with identifier : " + platformIdentifier + " does not"
|
|
|
|
|
|
|
|
+ " exist for the tenant with id " + tenantId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
boolean isEnabledNewStatus = status.equalsIgnoreCase("ENABLED");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the platform is already in the same status. No need to enable the platform again
|
|
|
|
|
|
|
|
if (isEnabledNewStatus == platform.isEnabled()) {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Platform with identifier : " + platformIdentifier + " is already in " +
|
|
|
|
|
|
|
|
(isEnabledNewStatus ? "Enabled" : "Disabled") + " status. No need to update.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (isEnabledNewStatus) {
|
|
|
|
|
|
|
|
DAOFactory.getPlatformDAO().addMapping(tenantId, getListOfString(platform.getIdentifier()));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DAOFactory.getPlatformDAO().removeMapping(tenantId, platform.getIdentifier());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Platform with identifier : " + platformIdentifier + " successfully " +
|
|
|
|
|
|
|
|
(isEnabledNewStatus ? "Enabled" : "Disabled"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (TransactionManagementException | DBConnectionException ex) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException("Database exception while trying to update the status of platform "
|
|
|
|
|
|
|
|
+ "with identifier '" + platformIdentifier + "' for the tenant" + tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void removePlatforms(int tenantId) throws PlatformManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
DAOFactory.getPlatformDAO().removePlatforms(tenantId);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (TransactionManagementException | DBConnectionException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new PlatformManagementDAOException("Database exception while trying to remove all the platforms for"
|
|
|
|
|
|
|
|
+ " the tenant " + tenantId);
|
|
|
|
|
|
|
|
} catch (PlatformManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|