Refine search
requestBody = new ObjectMapper().writeValueAsString(request); } catch (JsonProcessingException e) { LOG.error("Error processing JSON request: {}", e.getMessage()); return null; return access; } catch (JsonProcessingException e) { LOG.error("Error processing JSON response: {}", e.getMessage()); return null; LOG.error("Exception authenticating using KeystoneV3 {}", e.getMessage()); return null;
if ("priority".equals(context)) { AnalystClusterRequest task = mapper.readValue(request.getInputStream(), AnalystClusterRequest.class); broker.enqueuePriorityTask(task, response); .readValue(request.getInputStream(), new TypeReference<List<AnalystClusterRequest>>() { }); response.setDetailMessage("Could not decode/encode JSON payload. " + jpex.getMessage()); LOG.info("Error processing JSON from client", jpex); } catch (Exception ex) {
/** * Converts a JSON String into a Field object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Field object represented by the provided JSON */ public static Field fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Field.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Sim object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Sim object represented by the provided JSON */ public static Sim fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Sim.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
private List<SearchResult> searchUsingRestApi(String tenant, List<String> queries) { List<SearchResult> results = new ArrayList<>(); Timer.Context multiSearchCtx = searchTimer.time(); int hitsCount; try { queryBatchHistogram.update(queries.size()); String response = elasticsearchRestHelper.fetch( ELASTICSEARCH_INDEX_NAME_READ, ELASTICSEARCH_DOCUMENT_TYPE, tenant, queries); List<SearchResult> searchResults = getSearchResults(response); hitsCount = searchResults.size(); results.addAll(searchResults); } catch (JsonProcessingException e) { log.error("Elasticsearch metrics query failed for tenantId {}. {}", tenant, e.getMessage()); throw new RuntimeException(String.format("searchUsingRestApi failed with message: %s", e.getMessage()), e); } catch (IOException e) { log.error("Elasticsearch metrics query failed for tenantId {}. {}", tenant, e.getMessage()); throw new RuntimeException(String.format("searchUsingRestApi failed with message: %s", e.getMessage()), e); } finally { multiSearchCtx.stop(); } searchResultsSizeHistogram.update(hitsCount); return dedupResults(results); }
static UserDefinedClassifier readJsonFile(String content) throws IOException { try { return mapper.readValue(content, UserDefinedClassifier.class); } catch (JsonProcessingException e) { LOGGER.error(e.getMessage(), e); return null; } }
/** * Converts a JSON String into a NewKey object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return NewKey object represented by the provided JSON */ public static NewKey fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, NewKey.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
static UserDefinedClassifier readJsonFile(InputStream inputStream) throws IOException { try { return mapper.readValue(inputStream, UserDefinedClassifier.class); } catch (JsonProcessingException e) { LOGGER.error(e.getMessage(), e); return null; } }
/** * Converts a JSON String into a Invite object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Invite object represented by the provided JSON */ public static Invite fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Invite.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
private static Map<String,Object> readFragment(File file, String ext) throws IOException { ObjectMapper mapper = new ObjectMapper("json".equals(ext) ? new JsonFactory() : new YAMLFactory()); TypeReference<HashMap<String,Object>> typeRef = new TypeReference<HashMap<String,Object>>() {}; try { Map<String, Object> ret = mapper.readValue(file, typeRef); return ret != null ? ret : new HashMap<String, Object>(); } catch (JsonProcessingException e) { throw new JsonMappingException(String.format("[%s] %s", file, e.getMessage()), e.getLocation(), e); } }
/** * Converts a JSON String into a Message object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Message object represented by the provided JSON */ public static Message fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Message.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Trigger object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Trigger object represented by the provided JSON */ public static Trigger fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Trigger.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Role object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Role object represented by the provided JSON */ public static Role fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Role.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Task object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Task object represented by the provided JSON */ public static Task fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Task.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Binding object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Binding object represented by the provided JSON */ public static Binding fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Binding.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Country object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Country object represented by the provided JSON */ public static Country fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Country.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Service object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Service object represented by the provided JSON */ public static Service fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Service.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Key object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Key object represented by the provided JSON */ public static Key fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Key.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Role object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Role object represented by the provided JSON */ public static Role fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Role.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }
/** * Converts a JSON String into a Aws object using the provided ObjectMapper. * * @param json Raw JSON String * @param objectMapper Jackson ObjectMapper * @return Aws object represented by the provided JSON */ public static Aws fromJson(final String json, final ObjectMapper objectMapper) { // Convert all checked exceptions to Runtime try { return objectMapper.readValue(json, Aws.class); } catch (final JsonMappingException | JsonParseException e) { throw new ApiException(e.getMessage(), e); } catch (final IOException e) { throw new ApiConnectionException(e.getMessage(), e); } }