Search in sources :

Example 1 with RemoteFetchConfigurationListResponse

use of org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListResponse in project identity-api-server by wso2.

the class ServerRemoteFetchConfigManagementService method getRemoteFetchConfigs.

/**
 * Get list of remote fetch configurations.
 *
 * @return RemoteFetchConfigurationListResponse.
 */
public RemoteFetchConfigurationListResponse getRemoteFetchConfigs() {
    OptionalInt optionalIntLimit = OptionalInt.empty();
    OptionalInt optionalIntOffset = OptionalInt.empty();
    try {
        return createRemoteFetchConfigurationListResponse(RemoteFetchServiceHolder.getRemoteFetchConfigurationService().getBasicRemoteFetchConfigurationList(optionalIntLimit, optionalIntOffset));
    } catch (RemoteFetchCoreException e) {
        throw handleRemoteFetchConfigurationException(e, RemoteFetchConfigurationConstants.ErrorMessage.ERROR_CODE_ERROR_LISTING_RF_CONFIGS, null);
    }
}
Also used : RemoteFetchCoreException(org.wso2.carbon.identity.remotefetch.common.exceptions.RemoteFetchCoreException) OptionalInt(java.util.OptionalInt)

Example 2 with RemoteFetchConfigurationListResponse

use of org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListResponse in project identity-api-server by wso2.

the class ServerRemoteFetchConfigManagementService method createRemoteFetchConfigurationListResponse.

/**
 * This method is used to create list response from basic remote fetch configuration.
 * This method is create list item from basic remote fetch configuration list items.
 *
 * @param basicRemoteFetchConfigurationList List response.
 * @return RemoteFetchConfigurationListResponse.
 */
private RemoteFetchConfigurationListResponse createRemoteFetchConfigurationListResponse(List<BasicRemoteFetchConfiguration> basicRemoteFetchConfigurationList) {
    RemoteFetchConfigurationListResponse remoteFetchConfigurationListResponse = new RemoteFetchConfigurationListResponse();
    if (CollectionUtils.isNotEmpty(basicRemoteFetchConfigurationList)) {
        List<RemoteFetchConfigurationListItem> remoteFetchConfigurations = new ArrayList<>();
        for (BasicRemoteFetchConfiguration basicRemoteFetchConfiguration : basicRemoteFetchConfigurationList) {
            RemoteFetchConfigurationListItem remoteFetchConfigurationListItem = populateRemoteFetchConfigurationListResponse(basicRemoteFetchConfiguration);
            remoteFetchConfigurations.add(remoteFetchConfigurationListItem);
        }
        remoteFetchConfigurationListResponse.setRemotefetchConfigurations(remoteFetchConfigurations);
        remoteFetchConfigurationListResponse.setCount(remoteFetchConfigurations.size());
    } else {
        remoteFetchConfigurationListResponse.setCount(0);
    }
    return remoteFetchConfigurationListResponse;
}
Also used : BasicRemoteFetchConfiguration(org.wso2.carbon.identity.remotefetch.common.BasicRemoteFetchConfiguration) RemoteFetchConfigurationListItem(org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListItem) ArrayList(java.util.ArrayList) RemoteFetchConfigurationListResponse(org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListResponse)

Aggregations

ArrayList (java.util.ArrayList)1 OptionalInt (java.util.OptionalInt)1 RemoteFetchConfigurationListItem (org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListItem)1 RemoteFetchConfigurationListResponse (org.wso2.carbon.identity.api.server.fetch.remote.v1.model.RemoteFetchConfigurationListResponse)1 BasicRemoteFetchConfiguration (org.wso2.carbon.identity.remotefetch.common.BasicRemoteFetchConfiguration)1 RemoteFetchCoreException (org.wso2.carbon.identity.remotefetch.common.exceptions.RemoteFetchCoreException)1