use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceSearchAttribute in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method getConfigPreference.
/**
* Get governance connector properties according to the search attribute.
*
* @param preferenceSearchAttribute Governance connector details.
* @return Governance connector properties for the given connector or properties.
*/
public List<PreferenceResp> getConfigPreference(List<PreferenceSearchAttribute> preferenceSearchAttribute) {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
List<PreferenceResp> preferenceRespList = new ArrayList<>();
for (PreferenceSearchAttribute prefSearchAttr : preferenceSearchAttribute) {
String connectorName = prefSearchAttr.getConnectorName();
List<String> expectedProperties = prefSearchAttr.getProperties();
Property[] properties;
try {
ConnectorConfig connectorConfig = identityGovernanceService.getConnectorWithConfigs(tenantDomain, connectorName);
if (connectorConfig == null) {
throw handleBadRequestError(GovernanceConstants.ErrorMessage.ERROR_CODE_INCORRECT_CONNECTOR_NAME, connectorName);
}
properties = connectorConfig.getProperties();
PreferenceResp preferenceResp = buildPreferenceRespDTO(connectorName, properties, expectedProperties);
preferenceRespList.add(preferenceResp);
} catch (IdentityGovernanceException e) {
GovernanceConstants.ErrorMessage errorEnum = GovernanceConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_CONNECTOR_PREFERENCES;
Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
throw handleException(e, errorEnum, status);
}
}
return preferenceRespList;
}
Aggregations