public void invokeService()

in services/src/main/java/org/apache/custos/service/management/TenantActivationTask.java [78:141]


    public void invokeService(T data) {
        try {
            if (data instanceof UpdateStatusResponse) {
                long tenantId = ((UpdateStatusResponse) data).getTenantId();
                LOGGER.debug("Invoking tenant activation task for tenant " + tenantId);

                GetTenantRequest tenantRequest = GetTenantRequest.newBuilder()
                        .setTenantId(tenantId)
                        .build();

                GetTenantResponse tenantRes = tenantProfileService.getTenant(tenantRequest);

                Tenant tenant = tenantRes.getTenant();

                if (tenant != null) {

                    GetCredentialRequest request = GetCredentialRequest
                            .newBuilder()
                            .setId(tenant.getAdminUsername())
                            .setOwnerId(tenantId)
                            .setType(Type.INDIVIDUAL)
                            .build();
                    CredentialMetadata metadata = credentialStoreService.getCredential(request);

                    if (metadata != null && metadata.getSecret() != null) {

                        Tenant newTenant = tenant.toBuilder().setAdminPassword(metadata.getSecret()).build();
                        GetCredentialRequest iamClientRequest = GetCredentialRequest
                                .newBuilder()
                                .setOwnerId(tenantId)
                                .setType(Type.IAM)
                                .build();
                        CredentialMetadata iamMetadata = credentialStoreService.getCredential(iamClientRequest);

                        UpdateStatusResponse response;
                        if (iamMetadata == null || iamMetadata.getId() == null || StringUtils.isBlank(iamMetadata.getId())) {
                            response = this.activateTenant(newTenant, Constants.SYSTEM, false);
                        } else {
                            response = this.activateTenant(newTenant, Constants.SYSTEM, true);
                        }

                        invokeNextTask((U) response);

                    } else {
                        String msg = "Admin password not found  for admin  " + tenant.getAdminUsername();
                        LOGGER.error(msg);
                        getServiceCallback().onError(new ServiceException(msg, null, null));
                    }
                } else {
                    String msg = "Tenant not found  for Id  " + tenantId;
                    LOGGER.error(msg);
                    getServiceCallback().onError(new ServiceException(msg, null, null));
                }
            } else {
                String msg = "Invalid payload type ";
                LOGGER.error(msg);
                getServiceCallback().onError(new ServiceException(msg, null, null));
            }
        } catch (Exception ex) {
            String msg = "Error occurred  " + ex.getCause();
            LOGGER.error(msg, ex);
            getServiceCallback().onError(new ServiceException(msg, ex.getCause(), null));
        }
    }