use of com.rdbcache.models.KvIdType in project rdbcache by rdbcache.
the class RdbcacheApis method trace_post.
/**
* trace_post post multiple items
*
* get error messages by trace id list
*
* @param request HttpServletRequest
* @param traceIds List trace id list
* @return ResponseEntity
*/
@RequestMapping(value = { "/rdbcache/v1/trace" }, method = RequestMethod.POST)
public ResponseEntity<?> trace_post(HttpServletRequest request, @RequestBody List<String> traceIds) {
if (traceIds == null || traceIds.size() == 0) {
throw new BadRequestException("missing trace ids");
}
if (traceIds.contains("*")) {
throw new BadRequestException("no * allowed as trace id");
}
if (request.getParameterMap().size() != 0) {
throw new BadRequestException("no query string is needed");
}
Context context = new Context(true, true);
KvPairs pairs = new KvPairs();
Request.process(context, request, pairs);
LOGGER.trace("pairs(" + pairs.size() + "): " + pairs.printKey());
for (String referenced_id : traceIds) {
Optional<KvPair> optional = AppCtx.getKvPairRepo().findById(new KvIdType(referenced_id, "trace"));
if (optional.isPresent()) {
pairs.add(optional.get());
} else {
pairs.add(new KvPair(referenced_id));
}
}
return Response.send(context, pairs);
}
Aggregations