Search in sources :

Example 1 with TenantProfileServiceException

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;
    }
}
Also used : TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) Gateway(org.apache.airavata.model.workspace.Gateway) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 2 with TenantProfileServiceException

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());
    }
}
Also used : TMultiplexedProtocol(org.apache.thrift.protocol.TMultiplexedProtocol) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TProtocol(org.apache.thrift.protocol.TProtocol) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 3 with TenantProfileServiceException

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;
    }
}
Also used : TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) Gateway(org.apache.airavata.model.workspace.Gateway) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 4 with TenantProfileServiceException

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;
    }
}
Also used : TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Aggregations

TenantProfileServiceException (org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 AuthorizationException (org.apache.airavata.model.error.AuthorizationException)3 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)3 TException (org.apache.thrift.TException)3 Gateway (org.apache.airavata.model.workspace.Gateway)2 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 TMultiplexedProtocol (org.apache.thrift.protocol.TMultiplexedProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 TSocket (org.apache.thrift.transport.TSocket)1 TTransport (org.apache.thrift.transport.TTransport)1 TTransportException (org.apache.thrift.transport.TTransportException)1