use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project identity-api-server by wso2.
the class ServerScriptLibrariesService method createScriptLibraryResponse.
/**
* Create the script library response.
*
* @param scriptLibrary script library object.
* @return scriptLibraryResponse
*/
private ScriptLibraryResponse createScriptLibraryResponse(FunctionLibrary scriptLibrary) {
ScriptLibraryResponse scriptLibraryResponse = new ScriptLibraryResponse();
scriptLibraryResponse.setName(scriptLibrary.getFunctionLibraryName());
scriptLibraryResponse.setDescription(scriptLibrary.getDescription());
try {
String displayName = URLEncoder.encode(scriptLibrary.getFunctionLibraryName(), StandardCharsets.UTF_8.name());
scriptLibraryResponse.setContentRef(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + SCRIPT_LIBRARY_PATH_COMPONENT + "/%s" + SCRIPT_LIBRARY_CONTENT_PATH, displayName)).toString().replace("+", "%20"));
return scriptLibraryResponse;
} catch (UnsupportedEncodingException e) {
FunctionLibraryManagementException error = new FunctionLibraryManagementException(Constants.ErrorMessage.ERROR_CODE_ERROR_ENCODING_URL.getMessage(), e);
throw handleScriptLibraryError(error, Constants.ErrorMessage.ERROR_CODE_ERROR_ENCODING_URL);
}
}
Aggregations