@Override public PagedConnObjectTOResult listConnObjects( final String key, final String anyTypeKey, final ConnObjectTOListQuery listQuery) { Pair<SearchResult, List<ConnObjectTO>> list = logic.listConnObjects( key, anyTypeKey, listQuery.getSize(), listQuery.getPagedResultsCookie(), getOrderByClauses(listQuery.getOrderBy())); PagedConnObjectTOResult result = new PagedConnObjectTOResult(); if (list.getLeft() != null) { result.setAllResultsReturned(list.getLeft().isAllResultsReturned()); result.setPagedResultsCookie(list.getLeft().getPagedResultsCookie()); result.setRemainingPagedResults(list.getLeft().getRemainingPagedResults()); } result.getResult().addAll(list.getRight()); UriBuilder builder = uriInfo.getAbsolutePathBuilder(); MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(); for (Map.Entry<String, List<String>> queryParam : queryParams.entrySet()) { builder = builder.queryParam(queryParam.getKey(), queryParam.getValue().toArray()); } if (StringUtils.isNotBlank(result.getPagedResultsCookie())) { result.setNext( builder .replaceQueryParam(PARAM_CONNID_PAGED_RESULTS_COOKIE, result.getPagedResultsCookie()) .build()); } return result; }
@Override public BulkActionResult bulk(final BulkAction bulkAction) { BulkActionResult result = new BulkActionResult(); if (bulkAction.getType() == BulkAction.Type.DELETE) { for (String name : bulkAction.getTargets()) { try { result.getResults().put(logic.delete(name).getKey(), BulkActionResult.Status.SUCCESS); } catch (Exception e) { LOG.error("Error performing delete for resource {}", name, e); result.getResults().put(name, BulkActionResult.Status.FAILURE); } } } return result; }
@Override public ConnObjectTO readConnObject(final String key, final String anyTypeKey, final Long anyKey) { return logic.readConnObject(key, anyTypeKey, anyKey); }
@Override public List<ResourceTO> list() { return logic.list(); }
@Override public ResourceTO read(final String key) { return logic.read(key); }
@Override public void delete(final String key) { logic.delete(key); }
@Override public void update(final ResourceTO resourceTO) { logic.update(resourceTO); }
@Override public Response create(final ResourceTO resourceTO) { ResourceTO created = logic.create(resourceTO); URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build(); return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build(); }
@Override public void check(final ResourceTO resourceTO) { logic.check(resourceTO); }