Search in sources :

Example 1 with SearchRequest

use of io.jans.configapi.rest.model.SearchRequest in project jans by JanssenProject.

the class BaseResource method createSearchRequest.

protected SearchRequest createSearchRequest(String schemas, String filter, String sortBy, String sortOrder, Integer startIndex, Integer count, String attrsList, String excludedAttrsList) {
    if (log.isDebugEnabled()) {
        log.debug("Search Request params:: - schemas:{}, filter:{}, sortBy:{}, sortOrder:{}, startIndex:{}, count:{}, attrsList:{}, excludedAttrsList:{} ", escapeLog(schemas), escapeLog(filter), escapeLog(sortBy), escapeLog(sortOrder), escapeLog(startIndex), escapeLog(count), escapeLog(attrsList), escapeLog(excludedAttrsList));
    }
    SearchRequest searchRequest = new SearchRequest();
    // Validation
    checkNotEmpty(schemas, "Schema");
    int maxCount = getMaxCount();
    log.debug(" count:{}, maxCount:{}", count, maxCount);
    if (count > maxCount) {
        thorwBadRequestException("Maximum number of results per page is " + maxCount);
    }
    count = count == null ? maxCount : count;
    log.debug(" count:{} ", count);
    // Per spec, a negative value SHALL be interpreted as "0" for count
    if (count < 0) {
        count = 0;
    }
    // SCIM searches are 1 indexed
    startIndex = (startIndex == null || startIndex < 1) ? 1 : startIndex;
    if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue())) {
        sortOrder = SortOrder.ASCENDING.getValue();
    }
    searchRequest.setSchemas(schemas);
    searchRequest.setAttributes(attrsList);
    searchRequest.setExcludedAttributes(excludedAttrsList);
    searchRequest.setFilter(filter);
    searchRequest.setSortBy(sortBy);
    searchRequest.setSortOrder(sortOrder);
    searchRequest.setStartIndex(startIndex);
    searchRequest.setCount(count);
    searchRequest.setMaxCount(getMaxCount());
    return searchRequest;
}
Also used : SearchRequest(io.jans.configapi.rest.model.SearchRequest)

Example 2 with SearchRequest

use of io.jans.configapi.rest.model.SearchRequest in project jans by JanssenProject.

the class ClientsResource method getOpenIdConnectClients.

@GET
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_READ_ACCESS })
public Response getOpenIdConnectClients(@DefaultValue(DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, @DefaultValue("") @QueryParam(value = ApiConstants.PATTERN) String pattern, @DefaultValue(DEFAULT_LIST_START_INDEX) @QueryParam(value = ApiConstants.START_INDEX) int startIndex, @QueryParam(value = ApiConstants.SORT_BY) String sortBy, @QueryParam(value = ApiConstants.SORT_ORDER) String sortOrder) throws EncryptionException {
    if (logger.isDebugEnabled()) {
        logger.debug("Client serach param - limit:{}, pattern:{}, startIndex:{}, sortBy:{}, sortOrder:{}", escapeLog(limit), escapeLog(pattern), escapeLog(startIndex), escapeLog(sortBy), escapeLog(sortOrder));
    }
    SearchRequest searchReq = createSearchRequest(clientService.getDnForClient(null), pattern, sortBy, sortOrder, startIndex, limit, null, null);
    final List<Client> clients = this.doSearch(searchReq);
    log.trace("Client serach result:{}", clients);
    return Response.ok(getClients(clients)).build();
}
Also used : SearchRequest(io.jans.configapi.rest.model.SearchRequest) Client(io.jans.as.common.model.registration.Client) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Aggregations

SearchRequest (io.jans.configapi.rest.model.SearchRequest)2 Client (io.jans.as.common.model.registration.Client)1 ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)1