@Path("/{key-name}") @PUT @AuditPolicy(AuditDetail.REQUEST_BODY) public void create(FullHttpRequest httpRequest, HttpResponder httpResponder, @PathParam("namespace-id") String namespace, @PathParam("key-name") String name) throws Exception { SecureKeyId secureKeyId = new SecureKeyId(namespace, name); SecureKeyCreateRequest secureKeyCreateRequest; try { secureKeyCreateRequest = parseBody(httpRequest); } catch (IOException e) { SecureKeyCreateRequest dummy = new SecureKeyCreateRequest("<description>", "<data>", ImmutableMap.of("key", "value")); throw new BadRequestException("Unable to parse the request. The request body should be of the following format." + " \n" + GSON.toJson(dummy)); } if (Strings.isNullOrEmpty(secureKeyCreateRequest.getData()) || secureKeyCreateRequest.getData().trim().isEmpty()) { throw new BadRequestException("The data field must not be null or empty. The data will be stored securely " + "under provided key name."); } secureStoreManager.put(namespace, name, secureKeyCreateRequest.getData(), secureKeyCreateRequest.getDescription(), secureKeyCreateRequest.getProperties()); httpResponder.sendStatus(HttpResponseStatus.OK); }