use of com.formkiq.stacks.api.ApiDocumentTagItemResponse in project formkiq-core by formkiq.
the class DocumentTagRequestHandler method get.
@Override
public ApiRequestHandlerResponse get(final LambdaLogger logger, final ApiGatewayRequestEvent event, final ApiAuthorizer authorizer, final AwsServiceCache awsservice) throws Exception {
String documentId = event.getPathParameters().get("documentId");
String tagKey = event.getPathParameters().get("tagKey");
String siteId = authorizer.getSiteId();
DocumentTag tag = awsservice.documentService().findDocumentTag(siteId, documentId, tagKey);
if (tag == null) {
throw new NotFoundException("Tag " + tagKey + " not found.");
}
ApiDocumentTagItemResponse resp = new ApiDocumentTagItemResponse();
resp.setKey(tagKey);
resp.setValue(tag.getValue());
resp.setValues(tag.getValues());
resp.setInsertedDate(tag.getInsertedDate());
resp.setUserId(tag.getUserId());
resp.setType(tag.getType() != null ? tag.getType().name().toLowerCase() : null);
resp.setDocumentId(tag.getDocumentId());
return new ApiRequestHandlerResponse(SC_OK, resp);
}
use of com.formkiq.stacks.api.ApiDocumentTagItemResponse in project formkiq-core by formkiq.
the class DocumentTagsRequestHandler method get.
@Override
public ApiRequestHandlerResponse get(final LambdaLogger logger, final ApiGatewayRequestEvent event, final ApiAuthorizer authorizer, final AwsServiceCache awsservice) throws Exception {
CacheService cacheService = awsservice.documentCacheService();
ApiPagination pagination = getPagination(cacheService, event);
int limit = pagination != null ? pagination.getLimit() : getLimit(logger, event);
PaginationMapToken ptoken = pagination != null ? pagination.getStartkey() : null;
String siteId = authorizer.getSiteId();
String documentId = event.getPathParameters().get("documentId");
PaginationResults<DocumentTag> results = awsservice.documentService().findDocumentTags(siteId, documentId, ptoken, limit);
results.getResults().forEach(r -> r.setDocumentId(null));
ApiPagination current = createPagination(cacheService, event, pagination, results.getToken(), limit);
List<DocumentTag> tags = subList(results.getResults(), limit);
List<ApiDocumentTagItemResponse> list = tags.stream().map(t -> {
ApiDocumentTagItemResponse r = new ApiDocumentTagItemResponse();
r.setDocumentId(t.getDocumentId());
r.setInsertedDate(t.getInsertedDate());
r.setKey(t.getKey());
r.setValue(t.getValue());
r.setValues(t.getValues());
r.setUserId(t.getUserId());
r.setType(t.getType() != null ? t.getType().name().toLowerCase() : null);
return r;
}).collect(Collectors.toList());
ApiDocumentTagsItemResponse resp = new ApiDocumentTagsItemResponse();
resp.setTags(list);
resp.setPrevious(current.getPrevious());
resp.setNext(current.hasNext() ? current.getNext() : null);
return new ApiRequestHandlerResponse(SC_OK, resp);
}
Aggregations