下面列出了javax.ws.rs.core.UriBuilder#queryParam() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Upon detecting a redirect, either add cookie to response or re-write URL of new
* location to co-relate next request.
*
* @param event the event.
*/
public void controllerRedirectEvent(@Observes ControllerRedirectEvent event) {
if (request.getAttribute(SCOPE_ID) != null) {
if (usingCookies()) {
Cookie cookie = new Cookie(COOKIE_NAME, request.getAttribute(SCOPE_ID).toString());
cookie.setPath(request.getContextPath());
cookie.setMaxAge(600);
cookie.setHttpOnly(true);
response.addCookie(cookie);
} else {
final ContainerResponseContext crc = ((ControllerRedirectEventImpl) event).getContainerResponseContext();
final UriBuilder builder = UriBuilder.fromUri(crc.getStringHeaders().getFirst(HttpHeaders.LOCATION));
builder.queryParam(SCOPE_ID, request.getAttribute(SCOPE_ID).toString());
crc.getHeaders().putSingle(HttpHeaders.LOCATION, builder.build());
}
}
}
@Override
public void updateStashTime(String id, long timestamp, List<String> placements, long expiredTimestamp, String dataCenter) {
checkNotNull(id, "id");
checkNotNull(placements, "placements");
checkNotNull(dataCenter, "dataCenter");
try {
UriBuilder uriBuilder = _compactionControlSource.clone()
.segment("_compcontrol", "stash-time", id)
.queryParam("timestamp", timestamp)
.queryParam("expiredTimestamp", expiredTimestamp)
.queryParam("dataCenter", dataCenter);
for (String placement : placements) {
uriBuilder.queryParam("placement", placement);
}
URI uri = uriBuilder.build();
_client.resource(uri)
.type(MediaType.APPLICATION_JSON_TYPE)
.header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey)
.post();
} catch (UniformInterfaceException e) {
throw convertException(e);
}
}
public HttpResponse findPetsByStatusForHttpResponse(List<String> status) throws IOException {
// verify the required parameter 'status' is set
if (status == null) {
throw new IllegalArgumentException("Missing the required parameter 'status' when calling findPetsByStatus");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/findByStatus");
if (status != null) {
String key = "status";
Object value = status;
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = null;
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute();
}
/**
* This method is the same to {@link #createLinkHeader(Page, String, Map, Object...)} except of
* receiving multivalued query parameters.
*/
protected String createLinkHeader(
Page<?> page, String method, ListMultimap<String, Object> queryParams, Object... pathParams) {
final UriBuilder ub = getServiceContext().getServiceUriBuilder().path(getClass(), method);
for (Map.Entry<String, Object> queryParam : queryParams.entries()) {
ub.queryParam(queryParam.getKey(), queryParam.getValue());
}
return PagingUtil.createLinkHeader(page, ub.build(pathParams));
}
public URI getRefreshUrl(boolean authSessionIdParam) {
UriBuilder uriBuilder = LoginActionsService.loginActionsBaseUrl(getUriInfo())
.path(AuthenticationProcessor.this.flowPath)
.queryParam(Constants.CLIENT_ID, getAuthenticationSession().getClient().getClientId())
.queryParam(Constants.TAB_ID, getAuthenticationSession().getTabId());
if (authSessionIdParam) {
uriBuilder.queryParam(LoginActionsService.AUTH_SESSION_ID, getAuthenticationSession().getParentSession().getId());
}
return uriBuilder
.build(getRealm().getName());
}
public HttpResponse testEndpointParametersForHttpResponse(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Map<String, Object> params) throws IOException {
// verify the required parameter 'number' is set
if (number == null) {
throw new IllegalArgumentException("Missing the required parameter 'number' when calling testEndpointParameters");
}// verify the required parameter '_double' is set
if (_double == null) {
throw new IllegalArgumentException("Missing the required parameter '_double' when calling testEndpointParameters");
}// verify the required parameter 'patternWithoutDelimiter' is set
if (patternWithoutDelimiter == null) {
throw new IllegalArgumentException("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters");
}// verify the required parameter '_byte' is set
if (_byte == null) {
throw new IllegalArgumentException("Missing the required parameter '_byte' when calling testEndpointParameters");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = new EmptyContent();
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
public HttpResponse placeOrderForHttpResponse(Order body, Map<String, Object> params) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling placeOrder");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/store/order");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
@Override
public URI getActionUrl(String code) {
UriBuilder uriBuilder = LoginActionsService.loginActionsBaseUrl(getUriInfo())
.path(AuthenticationProcessor.this.flowPath)
.queryParam(LoginActionsService.SESSION_CODE, code)
.queryParam(Constants.EXECUTION, getExecution().getId())
.queryParam(Constants.CLIENT_ID, getAuthenticationSession().getClient().getClientId())
.queryParam(Constants.TAB_ID, getAuthenticationSession().getTabId());
if (getUriInfo().getQueryParameters().containsKey(LoginActionsService.AUTH_SESSION_ID)) {
uriBuilder.queryParam(LoginActionsService.AUTH_SESSION_ID, getAuthenticationSession().getParentSession().getId());
}
return uriBuilder
.build(getRealm().getName());
}
public HttpResponse createUserForHttpResponse(User body, Map<String, Object> params) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUser");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
public HttpResponse createUsersWithArrayInputForHttpResponse(List<User> body, Map<String, Object> params) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUsersWithArrayInput");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user/createWithArray");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
public HttpResponse createUsersWithListInputForHttpResponse(List<User> body, Map<String, Object> params) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUsersWithListInput");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user/createWithList");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
public URI callCustomerDbAudienceRequiredUrl(boolean attachAudienceScope) {
UriBuilder builder = getUriBuilder().clone().path("call-customer-db-audience-required");
if (attachAudienceScope) {
builder.queryParam("scope", "customer-db-audience-required");
}
return builder.build();
}
private void addPictureUrl(ApplicationListItem application) {
final UriBuilder ub = uriInfo.getBaseUriBuilder();
final UriBuilder uriBuilder = ub.path("organizations").path(GraviteeContext.getCurrentOrganization())
.path("environments").path(GraviteeContext.getCurrentEnvironment())
.path("applications").path(application.getId()).path("picture");
if (application.getPicture() != null) {
// force browser to get if updated
uriBuilder.queryParam("hash", application.getPicture().hashCode());
application.setPicture(null);
}
application.setPictureUrl(uriBuilder.build().toString());
}
public void openLogout() {
UriBuilder b = OIDCLoginProtocolService.logoutUrl(UriBuilder.fromUri(baseUrl));
if (redirectUri != null) {
b.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri);
}
driver.navigate().to(b.build(realm).toString());
}
public HttpResponse testBodyWithQueryParamsForHttpResponse(String query, java.io.InputStream body, String mediaType) throws IOException {
// verify the required parameter 'query' is set
if (query == null) {
throw new IllegalArgumentException("Missing the required parameter 'query' when calling testBodyWithQueryParams");
}// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling testBodyWithQueryParams");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake/body-with-query-params");
if (query != null) {
String key = "query";
Object value = query;
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String localVarUrl = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = body == null ?
apiClient.new JacksonJsonHttpContent(null) :
new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute();
}
@Override
public void filter(ContainerRequestContext context) {
Message m = JAXRSUtils.getCurrentMessage();
if (checkSecurityContext(m)) {
return;
}
try {
SamlRequestInfo info = createSamlRequestInfo(m);
String urlEncodedRequest =
URLEncoder.encode(info.getSamlRequest(), StandardCharsets.UTF_8.name());
UriBuilder ub = UriBuilder.fromUri(getIdpServiceAddress());
ub.queryParam(SSOConstants.SAML_REQUEST, urlEncodedRequest);
ub.queryParam(SSOConstants.RELAY_STATE, info.getRelayState());
if (isSignRequest()) {
signRequest(urlEncodedRequest, info.getRelayState(), ub);
}
String contextCookie = createCookie(SSOConstants.RELAY_STATE,
info.getRelayState(),
info.getWebAppContext(),
info.getWebAppDomain());
context.abortWith(Response.seeOther(ub.build())
.header(HttpHeaders.CACHE_CONTROL, "no-cache, no-store")
.header("Pragma", "no-cache")
.header(HttpHeaders.SET_COOKIE, contextCookie)
.build());
} catch (Exception ex) {
LOG.log(Level.FINE, ex.getMessage(), ex);
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
public HttpResponse uploadFileForHttpResponse(Long petId, Map<String, Object> params) throws IOException {
// verify the required parameter 'petId' is set
if (petId == null) {
throw new IllegalArgumentException("Missing the required parameter 'petId' when calling uploadFile");
}
// create a map of path variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("petId", petId);
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}/uploadImage");
// Copy the params argument if present, to allow passing in immutable maps
Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
for (Map.Entry<String, Object> entry: allParams.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
}
String localVarUrl = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(localVarUrl);
HttpContent content = new EmptyContent();
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
/**
* Send a update account email to the user
*
* An email contains a link the user can click to perform a set of required actions.
* The redirectUri and clientId parameters are optional. If no redirect is given, then there will
* be no link back to click after actions have completed. Redirect uri must be a valid uri for the
* particular clientId.
*
* @param redirectUri Redirect uri
* @param clientId Client id
* @param lifespan Number of seconds after which the generated token expires
* @param actions required actions the user needs to complete
* @return
*/
@Path("execute-actions-email")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response executeActionsEmail(@QueryParam(OIDCLoginProtocol.REDIRECT_URI_PARAM) String redirectUri,
@QueryParam(OIDCLoginProtocol.CLIENT_ID_PARAM) String clientId,
@QueryParam("lifespan") Integer lifespan,
List<String> actions) {
auth.users().requireManage(user);
if (user.getEmail() == null) {
return ErrorResponse.error("User email missing", Status.BAD_REQUEST);
}
if (!user.isEnabled()) {
throw new WebApplicationException(
ErrorResponse.error("User is disabled", Status.BAD_REQUEST));
}
if (redirectUri != null && clientId == null) {
throw new WebApplicationException(
ErrorResponse.error("Client id missing", Status.BAD_REQUEST));
}
if (clientId == null) {
clientId = Constants.ACCOUNT_MANAGEMENT_CLIENT_ID;
}
ClientModel client = realm.getClientByClientId(clientId);
if (client == null) {
logger.debugf("Client %s doesn't exist", clientId);
throw new WebApplicationException(
ErrorResponse.error("Client doesn't exist", Status.BAD_REQUEST));
}
if (!client.isEnabled()) {
logger.debugf("Client %s is not enabled", clientId);
throw new WebApplicationException(
ErrorResponse.error("Client is not enabled", Status.BAD_REQUEST));
}
String redirect;
if (redirectUri != null) {
redirect = RedirectUtils.verifyRedirectUri(session, redirectUri, client);
if (redirect == null) {
throw new WebApplicationException(
ErrorResponse.error("Invalid redirect uri.", Status.BAD_REQUEST));
}
}
if (lifespan == null) {
lifespan = realm.getActionTokenGeneratedByAdminLifespan();
}
int expiration = Time.currentTime() + lifespan;
ExecuteActionsActionToken token = new ExecuteActionsActionToken(user.getId(), expiration, actions, redirectUri, clientId);
try {
UriBuilder builder = LoginActionsService.actionTokenProcessor(session.getContext().getUri());
builder.queryParam("key", token.serialize(session, realm, session.getContext().getUri()));
String link = builder.build(realm.getName()).toString();
this.session.getProvider(EmailTemplateProvider.class)
.setAttribute(Constants.TEMPLATE_ATTR_REQUIRED_ACTIONS, token.getRequiredActions())
.setRealm(realm)
.setUser(user)
.sendExecuteActions(link, TimeUnit.SECONDS.toMinutes(lifespan));
//audit.user(user).detail(Details.EMAIL, user.getEmail()).detail(Details.CODE_ID, accessCode.getCodeId()).success();
adminEvent.operation(OperationType.ACTION).resourcePath(session.getContext().getUri()).success();
return Response.noContent().build();
} catch (EmailException e) {
ServicesLogger.LOGGER.failedToSendActionsEmail(e);
return ErrorResponse.error("Failed to send execute actions email", Status.INTERNAL_SERVER_ERROR);
}
}
/**
* Sign a request according to the redirect binding spec for Web SSO
*/
private void signRequest(
String authnRequest,
String relayState,
UriBuilder ub
) throws Exception {
Crypto crypto = getSignatureCrypto();
if (crypto == null) {
LOG.warning("No crypto instance of properties file configured for signature");
throw ExceptionUtils.toInternalServerErrorException(null, null);
}
String signatureUser = getSignatureUsername();
if (signatureUser == null) {
LOG.warning("No user configured for signature");
throw ExceptionUtils.toInternalServerErrorException(null, null);
}
CallbackHandler callbackHandler = getCallbackHandler();
if (callbackHandler == null) {
LOG.warning("No CallbackHandler configured to supply a password for signature");
throw ExceptionUtils.toInternalServerErrorException(null, null);
}
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias(signatureUser);
X509Certificate[] issuerCerts = crypto.getX509Certificates(cryptoType);
if (issuerCerts == null) {
throw new Exception(
"No issuer certs were found to sign the request using name: " + signatureUser
);
}
String sigAlgo = getSignatureAlgorithm();
String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
LOG.fine("automatic sig algo detection: " + pubKeyAlgo);
if ("DSA".equalsIgnoreCase(pubKeyAlgo)) {
sigAlgo = SSOConstants.DSA_SHA1;
}
LOG.fine("Using Signature algorithm " + sigAlgo);
ub.queryParam(SSOConstants.SIG_ALG, URLEncoder.encode(sigAlgo, StandardCharsets.UTF_8.name()));
// Get the password
WSPasswordCallback[] cb = {new WSPasswordCallback(signatureUser, WSPasswordCallback.SIGNATURE)};
callbackHandler.handle(cb);
String password = cb[0].getPassword();
// Get the private key
PrivateKey privateKey = crypto.getPrivateKey(signatureUser, password);
// Sign the request
String jceSigAlgo = JCEMapper.translateURItoJCEID(sigAlgo);
Signature signature = Signature.getInstance(jceSigAlgo);
signature.initSign(privateKey);
String requestToSign =
SSOConstants.SAML_REQUEST + "=" + authnRequest + "&"
+ SSOConstants.RELAY_STATE + "=" + relayState + "&"
+ SSOConstants.SIG_ALG + "=" + URLEncoder.encode(sigAlgo, StandardCharsets.UTF_8.name());
signature.update(requestToSign.getBytes(StandardCharsets.UTF_8));
byte[] signBytes = signature.sign();
String encodedSignature = Base64.getEncoder().encodeToString(signBytes);
// Clean the private key from memory when we're done
try {
privateKey.destroy();
} catch (DestroyFailedException ex) {
// ignore
}
ub.queryParam(SSOConstants.SIGNATURE, URLEncoder.encode(encodedSignature, StandardCharsets.UTF_8.name()));
}
private ApiListItem convert(ApiEntity api) {
final ApiListItem apiItem = new ApiListItem();
apiItem.setId(api.getId());
apiItem.setName(api.getName());
apiItem.setVersion(api.getVersion());
apiItem.setDescription(api.getDescription());
final UriBuilder ub = uriInfo.getBaseUriBuilder();
final UriBuilder uriBuilder = ub.path("apis").path(api.getId()).path("picture");
if (api.getPicture() != null) {
// force browser to get if updated
uriBuilder.queryParam("hash", api.getPicture().hashCode());
}
apiItem.setPictureUrl(uriBuilder.build().toString());
apiItem.setCategories(api.getCategories());
apiItem.setCreatedAt(api.getCreatedAt());
apiItem.setUpdatedAt(api.getUpdatedAt());
apiItem.setLabels(api.getLabels());
apiItem.setCategories(api.getCategories());
apiItem.setPrimaryOwner(api.getPrimaryOwner());
if (api.getVisibility() != null) {
apiItem.setVisibility(io.gravitee.rest.api.model.Visibility.valueOf(api.getVisibility().toString()));
}
if (api.getState() != null) {
apiItem.setState(Lifecycle.State.valueOf(api.getState().toString()));
}
if (api.getProxy() != null) {
apiItem.setVirtualHosts(api.getProxy().getVirtualHosts());
}
if (ratingService.isEnabled()) {
final RatingSummaryEntity ratingSummary = ratingService.findSummaryByApi(api.getId());
apiItem.setRate(ratingSummary.getAverageRate());
apiItem.setNumberOfRatings(ratingSummary.getNumberOfRatings());
}
apiItem.setTags(api.getTags());
if (api.getLifecycleState() != null) {
apiItem.setLifecycleState(ApiLifecycleState.valueOf(api.getLifecycleState().toString()));
}
return apiItem;
}