use of com.formkiq.lambda.apigateway.ApiResponse in project formkiq-core by formkiq.
the class DocumentTagRequestHandler method delete.
@Override
public ApiRequestHandlerResponse delete(final LambdaLogger logger, final ApiGatewayRequestEvent event, final ApiAuthorizer authorizer, final AwsServiceCache awsservice) throws Exception {
String siteId = authorizer.getSiteId();
Map<String, String> map = event.getPathParameters();
String documentId = map.get("documentId");
String tagKey = map.get("tagKey");
DocumentService documentService = awsservice.documentService();
DocumentTag docTag = documentService.findDocumentTag(siteId, documentId, tagKey);
if (docTag == null) {
throw new NotFoundException("Tag '" + tagKey + "' not found.");
}
documentService.removeTags(siteId, documentId, Arrays.asList(tagKey));
ApiResponse resp = new ApiMessageResponse("Removed '" + tagKey + "' from document '" + documentId + "'.");
return new ApiRequestHandlerResponse(SC_OK, resp);
}
use of com.formkiq.lambda.apigateway.ApiResponse in project formkiq-core by formkiq.
the class DocumentTagValueRequestHandler method delete.
@Override
public ApiRequestHandlerResponse delete(final LambdaLogger logger, final ApiGatewayRequestEvent event, final ApiAuthorizer authorizer, final AwsServiceCache awsservice) throws Exception {
String siteId = authorizer.getSiteId();
Map<String, String> map = event.getPathParameters();
String documentId = map.get("documentId");
String tagKey = map.get("tagKey");
String tagValue = map.get("tagValue");
DocumentService documentService = awsservice.documentService();
boolean removed = documentService.removeTag(siteId, documentId, tagKey, tagValue);
if (!removed) {
throw new NotFoundException("Tag/Value combination not found.");
}
ApiResponse resp = new ApiMessageResponse("Removed Tag from document '" + documentId + "'.");
return new ApiRequestHandlerResponse(SC_OK, resp);
}
Aggregations