use of org.wso2.carbon.identity.api.server.fetch.remote.v1.model.StatusListResponse in project identity-api-server by wso2.
the class ServerRemoteFetchConfigManagementService method createStatusListResponse.
/**
* This method is used to create status list from list of deployment revisions.
* This method uses java stream api to count successful deployments and failed deployments.
*
* @param deploymentRevisions List of deployment revisions.
* @return StatusListResponse.
*/
private StatusListResponse createStatusListResponse(List<DeploymentRevision> deploymentRevisions) {
StatusListResponse statusListResponse = new StatusListResponse();
if (CollectionUtils.isNotEmpty(deploymentRevisions)) {
List<StatusListItem> statusListItemList = new ArrayList<>();
for (DeploymentRevision deploymentRevision : deploymentRevisions) {
StatusListItem statusListItem = populateDeploymentRevision(deploymentRevision);
statusListItemList.add(statusListItem);
}
statusListResponse.setRemoteFetchRevisionStatuses(statusListItemList);
statusListResponse.setSuccessfulDeployments((int) deploymentRevisions.stream().filter(Objects::nonNull).filter(deploymentRevision -> deploymentRevision.getDeploymentStatus().name().equals(RemoteFetchConfigurationConstants.SUCCESS)).count());
statusListResponse.setFailedDeployments((int) deploymentRevisions.stream().filter(Objects::nonNull).filter(deploymentRevision -> deploymentRevision.getDeploymentStatus().name().equals(RemoteFetchConfigurationConstants.FAIL)).count());
Date date = deploymentRevisions.stream().map(DeploymentRevision::getLastSynchronizedDate).max(Date::compareTo).orElse(null);
convertDateToStringIfNotNull(date, statusListResponse::setLastSynchronizedTime);
return statusListResponse;
} else {
statusListResponse.setCount(0);
}
return statusListResponse;
}
use of org.wso2.carbon.identity.api.server.fetch.remote.v1.model.StatusListResponse in project identity-api-server by wso2.
the class ServerRemoteFetchConfigManagementService method createRemoteFetchConfigurationResponse.
/**
* This method is used to create GET response from remote fetch configuration id.
*
* @param remoteFetchConfiguration remote fetch configuration domain object.
* @return RemoteFetchConfigurationGetResponse.
* @throws RemoteFetchCoreException RemoteFetchCoreException
*/
private RemoteFetchConfigurationGetResponse createRemoteFetchConfigurationResponse(RemoteFetchConfiguration remoteFetchConfiguration) throws RemoteFetchCoreException {
RemoteFetchConfigurationGetResponse remoteFetchConfigurationGetResponse = new RemoteFetchConfigurationGetResponse();
ActionListenerAttributes actionListenerAttributes = createActionListenerAttributeProperties(remoteFetchConfiguration);
RepositoryManagerAttributes repositoryManagerAttributes = createRepositoryManagerAttributeProperties(remoteFetchConfiguration);
remoteFetchConfigurationGetResponse.setActionListenerAttributes(actionListenerAttributes);
remoteFetchConfigurationGetResponse.setRepositoryManagerAttributes(repositoryManagerAttributes);
remoteFetchConfigurationGetResponse.setConfigurationDeployerAttributes(null);
setIfNotNull(remoteFetchConfiguration.getRemoteFetchConfigurationId(), remoteFetchConfigurationGetResponse::setId);
setIfNotNull(remoteFetchConfiguration.isEnabled(), remoteFetchConfigurationGetResponse::setIsEnabled);
setIfNotNull(remoteFetchConfiguration.getRemoteFetchName(), remoteFetchConfigurationGetResponse::setRemoteFetchName);
setIfNotNull(remoteFetchConfiguration.getRepositoryManagerType(), remoteFetchConfigurationGetResponse::setRepositoryManagerType);
setIfNotNull(remoteFetchConfiguration.getConfigurationDeployerType(), remoteFetchConfigurationGetResponse::setConfigurationDeployerType);
setIfNotNull(remoteFetchConfiguration.getRepositoryManagerType(), remoteFetchConfigurationGetResponse::setRepositoryManagerType);
StatusListResponse statusListResponse = this.createStatusListResponse(RemoteFetchServiceHolder.getRemoteFetchConfigurationService().getDeploymentRevisions(remoteFetchConfiguration.getRemoteFetchConfigurationId()));
remoteFetchConfigurationGetResponse.setStatus(statusListResponse);
return remoteFetchConfigurationGetResponse;
}
Aggregations