use of org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException in project airavata by apache.
the class TenantProfileServiceHandler method updateGateway.
@Override
@SecurityCheck
public boolean updateGateway(AuthzToken authzToken, Gateway updatedGateway) throws TenantProfileServiceException, AuthorizationException, TException {
try {
// if admin password token changes then copy the admin password and store under this gateway id and then update the admin password token
Gateway existingGateway = tenantProfileRepository.getGateway(updatedGateway.getAiravataInternalGatewayId());
if (updatedGateway.getIdentityServerPasswordToken() != null && (existingGateway.getIdentityServerPasswordToken() == null || !existingGateway.getIdentityServerPasswordToken().equals(updatedGateway.getIdentityServerPasswordToken()))) {
copyAdminPasswordToGateway(authzToken, updatedGateway);
}
if (tenantProfileRepository.update(updatedGateway) != null) {
logger.debug("Updated gateway-profile with ID: " + updatedGateway.getGatewayId());
// replicate tenant at end-places
ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.TENANT, CrudType.UPDATE, updatedGateway), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
return true;
} else {
return false;
}
} catch (Exception ex) {
logger.error("Error updating gateway-profile, reason: " + ex.getMessage(), ex);
TenantProfileServiceException exception = new TenantProfileServiceException();
exception.setMessage("Error updating gateway-profile, reason: " + ex.getMessage());
return false;
}
}
use of org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException in project airavata by apache.
the class ProfileServiceClientFactory method createTenantProfileServiceClient.
public static TenantProfileService.Client createTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
try {
TTransport transport = new TSocket(serverHost, serverPort);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
return new TenantProfileService.Client(multiplexedProtocol);
} catch (TTransportException e) {
throw new TenantProfileServiceException(e.getMessage());
}
}
use of org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException in project airavata by apache.
the class TenantProfileServiceHandler method deleteGateway.
@Override
@SecurityCheck
public boolean deleteGateway(AuthzToken authzToken, String airavataInternalGatewayId, String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
try {
logger.debug("Deleting Airavata gateway-profile with ID: " + gatewayId + "Internal ID: " + airavataInternalGatewayId);
boolean deleteSuccess = tenantProfileRepository.delete(airavataInternalGatewayId);
if (deleteSuccess) {
// delete tenant at end-places
ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.TENANT, CrudType.DELETE, // approvalstatus is not used for delete, hence set dummy value
new Gateway(gatewayId, GatewayApprovalStatus.DEACTIVATED)), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
}
return deleteSuccess;
} catch (Exception ex) {
logger.error("Error deleting gateway-profile, reason: " + ex.getMessage(), ex);
TenantProfileServiceException exception = new TenantProfileServiceException();
exception.setMessage("Error deleting gateway-profile, reason: " + ex.getMessage());
throw exception;
}
}
use of org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException in project airavata by apache.
the class TenantProfileServiceHandler method addGateway.
@Override
@SecurityCheck
public String addGateway(AuthzToken authzToken, Gateway gateway) throws TenantProfileServiceException, AuthorizationException, TException {
try {
// Assign UUID to gateway
gateway.setAiravataInternalGatewayId(UUID.randomUUID().toString());
if (!checkDuplicateGateway(gateway)) {
// If admin password, copy it in the credential store under the requested gateway's gatewayId
if (gateway.getIdentityServerPasswordToken() != null) {
copyAdminPasswordToGateway(authzToken, gateway);
}
gateway = tenantProfileRepository.create(gateway);
if (gateway != null) {
logger.info("Added Airavata Gateway with Id: " + gateway.getGatewayId());
// replicate tenant at end-places only if status is APPROVED
if (gateway.getGatewayApprovalStatus().equals(GatewayApprovalStatus.APPROVED)) {
logger.info("Gateway with ID: {}, is now APPROVED, replicating to subscribers.", gateway.getGatewayId());
ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.TENANT, CrudType.CREATE, gateway), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
}
// return internal id
return gateway.getAiravataInternalGatewayId();
} else {
throw new Exception("Gateway object is null.");
}
} else {
throw new TenantProfileServiceException("An approved Gateway already exists with the same GatewayId, Name or URL");
}
} catch (Exception ex) {
logger.error("Error adding gateway-profile, reason: " + ex.getMessage(), ex);
TenantProfileServiceException exception = new TenantProfileServiceException();
exception.setMessage("Error adding gateway-profile, reason: " + ex.getMessage());
throw exception;
}
}
Aggregations