public byte[] getNewRowFromDb() { boolean isFirstElement = mainId == null; Row row = inflateRow(); if (row != null) { try { ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); mapper.setVisibility(JsonMethod.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY); String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(row); json = isFirstElement ? "" + json : "," + json; return json.getBytes(); } catch (Exception e) { throw new AqlException("Failed to convert Aql Result to JSON", e); } } return null; }
public JacksonContextResolver() throws Exception { this.mapper = new ObjectMapper() .setDefaultTyping(new OvirtTypeResolverBuilder()) .configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false) .configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(DeserializationConfig.Feature.FAIL_ON_NULL_FOR_PRIMITIVES, false) .configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setVisibilityChecker(mapper.getSerializationConfig().getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.NON_PRIVATE) .withGetterVisibility(JsonAutoDetect.Visibility.NONE) .withSetterVisibility(JsonAutoDetect.Visibility.NONE) .withCreatorVisibility(JsonAutoDetect.Visibility.DEFAULT)); mapper.registerModule(new OvirtSdkEnhancer()); }
public Std with(JsonAutoDetect ann) { if (ann == null) return this; Std curr = this; JsonMethod[] incl = ann.value(); Visibility v; v = hasMethod(incl, JsonMethod.GETTER) ? ann.getterVisibility() : Visibility.NONE; curr = curr.withGetterVisibility(v); v = hasMethod(incl, JsonMethod.IS_GETTER) ? ann.isGetterVisibility() : Visibility.NONE; curr = curr.withIsGetterVisibility(v); v = hasMethod(incl, JsonMethod.SETTER) ? ann.setterVisibility() : Visibility.NONE; curr = curr.withSetterVisibility(v); v = hasMethod(incl, JsonMethod.CREATOR) ? ann.creatorVisibility() : Visibility.NONE; curr = curr.withCreatorVisibility(v); v = hasMethod(incl, JsonMethod.FIELD) ? ann.fieldVisibility() : Visibility.NONE; curr = curr.withFieldVisibility(v); return curr; }
public SlackInfo tokenAuthen(String token, String proxyUrl, int proxyPort) { HttpClient client = new HttpClient(); if (proxyUrl != null) { HostConfiguration hostConfiguration = new HostConfiguration(); hostConfiguration.setProxyHost(new ProxyHost(proxyUrl, proxyPort)); client.setHostConfiguration(hostConfiguration); } GetMethod getMethod = new GetMethod(SLACK_RTM_AUTHEN_URL + token); SlackInfo slackInfo = new SlackInfo(); try { int httpStatus = client.executeMethod(getMethod); if (httpStatus == HttpStatus.SC_OK) { ObjectMapper mapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper.readValue(getMethod.getResponseBodyAsStream(), SlackInfo.class); } else { slackInfo.setError("http_status_" + httpStatus); return slackInfo; } } catch (IOException ex) { slackInfo.setError("exception " + ex.getMessage()); Logger.getLogger(SlackAuthen.class.getName()).log(Level.SEVERE, null, ex); } finally { getMethod.releaseConnection(); } return slackInfo; }
private String generateRangeJson() throws IOException { Range range = new Range(offset, rowsCount, rowsCount, limit); ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); mapper.setVisibility(JsonMethod.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY); return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(range); }
public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass paramAnnotatedClass, VisibilityChecker<?> paramVisibilityChecker) { JsonAutoDetect localJsonAutoDetect = (JsonAutoDetect)paramAnnotatedClass.getAnnotation(JsonAutoDetect.class); if (localJsonAutoDetect == null) return paramVisibilityChecker; return paramVisibilityChecker.with(localJsonAutoDetect); }
public Std(JsonAutoDetect.Visibility paramVisibility1, JsonAutoDetect.Visibility paramVisibility2, JsonAutoDetect.Visibility paramVisibility3, JsonAutoDetect.Visibility paramVisibility4, JsonAutoDetect.Visibility paramVisibility5) { this._getterMinLevel = paramVisibility1; this._isGetterMinLevel = paramVisibility2; this._setterMinLevel = paramVisibility3; this._creatorMinLevel = paramVisibility4; this._fieldMinLevel = paramVisibility5; }
public Std(JsonAutoDetect paramJsonAutoDetect) { JsonMethod[] arrayOfJsonMethod = paramJsonAutoDetect.value(); JsonAutoDetect.Visibility localVisibility1; JsonAutoDetect.Visibility localVisibility2; label51: JsonAutoDetect.Visibility localVisibility3; label75: JsonAutoDetect.Visibility localVisibility4; if (hasMethod(arrayOfJsonMethod, JsonMethod.GETTER)) { localVisibility1 = paramJsonAutoDetect.getterVisibility(); this._getterMinLevel = localVisibility1; if (!hasMethod(arrayOfJsonMethod, JsonMethod.IS_GETTER)) break label137; localVisibility2 = paramJsonAutoDetect.isGetterVisibility(); this._isGetterMinLevel = localVisibility2; if (!hasMethod(arrayOfJsonMethod, JsonMethod.SETTER)) break label145; localVisibility3 = paramJsonAutoDetect.setterVisibility(); this._setterMinLevel = localVisibility3; if (!hasMethod(arrayOfJsonMethod, JsonMethod.CREATOR)) break label153; localVisibility4 = paramJsonAutoDetect.creatorVisibility(); label99: this._creatorMinLevel = localVisibility4; if (!hasMethod(arrayOfJsonMethod, JsonMethod.FIELD)) break label161; } label137: label145: label153: label161: for (JsonAutoDetect.Visibility localVisibility5 = paramJsonAutoDetect.fieldVisibility(); ; localVisibility5 = JsonAutoDetect.Visibility.NONE) { this._fieldMinLevel = localVisibility5; return; localVisibility1 = JsonAutoDetect.Visibility.NONE; break; localVisibility2 = JsonAutoDetect.Visibility.NONE; break label51; localVisibility3 = JsonAutoDetect.Visibility.NONE; break label75; localVisibility4 = JsonAutoDetect.Visibility.NONE; break label99; } }
public Std withCreatorVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT) paramVisibility = DEFAULT._creatorMinLevel; if (this._creatorMinLevel == paramVisibility) return this; JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel; JsonAutoDetect.Visibility localVisibility2 = this._isGetterMinLevel; JsonAutoDetect.Visibility localVisibility3 = this._setterMinLevel; JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel; return new Std(localVisibility1, localVisibility2, localVisibility3, paramVisibility, localVisibility4); }
public Std withFieldVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT) paramVisibility = DEFAULT._fieldMinLevel; if (this._fieldMinLevel == paramVisibility) return this; return new Std(this._getterMinLevel, this._isGetterMinLevel, this._setterMinLevel, this._creatorMinLevel, paramVisibility); }
public Std withGetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT) paramVisibility = DEFAULT._getterMinLevel; if (this._getterMinLevel == paramVisibility) return this; JsonAutoDetect.Visibility localVisibility1 = this._isGetterMinLevel; JsonAutoDetect.Visibility localVisibility2 = this._setterMinLevel; JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel; JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel; return new Std(paramVisibility, localVisibility1, localVisibility2, localVisibility3, localVisibility4); }
public Std withIsGetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT) paramVisibility = DEFAULT._isGetterMinLevel; if (this._isGetterMinLevel == paramVisibility) return this; JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel; JsonAutoDetect.Visibility localVisibility2 = this._setterMinLevel; JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel; JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel; return new Std(localVisibility1, paramVisibility, localVisibility2, localVisibility3, localVisibility4); }
public Std withSetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT) paramVisibility = DEFAULT._setterMinLevel; if (this._setterMinLevel == paramVisibility) return this; JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel; JsonAutoDetect.Visibility localVisibility2 = this._isGetterMinLevel; JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel; JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel; return new Std(localVisibility1, localVisibility2, paramVisibility, localVisibility3, localVisibility4); }
/** * Constructor used for building instance that has minumum visibility * levels as indicated by given annotation instance * * @param ann Annotations to use for determining minimum visibility levels */ public Std(JsonAutoDetect ann) { JsonMethod[] incl = ann.value(); // let's combine checks for enabled/disabled, with minimimum level checks: _getterMinLevel = hasMethod(incl, JsonMethod.GETTER) ? ann.getterVisibility() : Visibility.NONE; _isGetterMinLevel = hasMethod(incl, JsonMethod.IS_GETTER) ? ann.isGetterVisibility() : Visibility.NONE; _setterMinLevel = hasMethod(incl, JsonMethod.SETTER) ? ann.setterVisibility() : Visibility.NONE; _creatorMinLevel = hasMethod(incl, JsonMethod.CREATOR) ? ann.creatorVisibility() : Visibility.NONE; _fieldMinLevel = hasMethod(incl, JsonMethod.FIELD) ? ann.fieldVisibility() : Visibility.NONE; }
public DefaultObjectMapper() { configure(SerializationConfig.Feature.INDENT_OUTPUT, true); configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); setSerializationInclusion(JsonSerialize.Inclusion.ALWAYS); configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); setVisibility(JsonMethod.ALL, JsonAutoDetect.Visibility.PUBLIC_ONLY); }
public JacksonObjectMapperWithOptions() { super(); this.getJsonFactory().setCharacterEscapes(new HTMLCharacterEscapes()); configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); configure(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true); configure(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true); setVisibilityChecker(VisibilityChecker.Std.defaultInstance().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); }
/** * Constructs a {@link StatsManager}. * @param storageManager the {@link StorageManager} to be used to fetch the {@link Store}s * @param partitionIds a {@link List} of {@link PartitionId}s that are going to be fetched * @param registry the {@link MetricRegistry} to be used for {@link StatsManagerMetrics} * @param config the {@link StatsManagerConfig} to be used to configure the output file path and publish period * @param time the {@link Time} instance to be used for reporting * @throws IOException */ StatsManager(StorageManager storageManager, List<PartitionId> partitionIds, MetricRegistry registry, StatsManagerConfig config, Time time) throws IOException { this.storageManager = storageManager; totalPartitionIds = partitionIds; statsOutputFile = new File(config.outputFilePath); publishPeriodInSecs = config.publishPeriodInSecs; initialDelayInSecs = config.initialDelayUpperBoundInSecs; metrics = new StatsManagerMetrics(registry); mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); this.time = time; }
public <T> String marshall(T input) { Assert.notNull(input); jsonMapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY); jsonMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class"); try { return jsonMapper.writeValueAsString(input); } catch(Exception e) { throw new MappingException(e.getMessage(), e); } }
public VisibilityChecker$Std(JsonAutoDetect.Visibility paramVisibility1, JsonAutoDetect.Visibility paramVisibility2, JsonAutoDetect.Visibility paramVisibility3, JsonAutoDetect.Visibility paramVisibility4, JsonAutoDetect.Visibility paramVisibility5) { this._getterMinLevel = paramVisibility1; this._isGetterMinLevel = paramVisibility2; this._setterMinLevel = paramVisibility3; this._creatorMinLevel = paramVisibility4; this._fieldMinLevel = paramVisibility5; }
public VisibilityChecker$Std(JsonAutoDetect paramJsonAutoDetect) { JsonMethod[] arrayOfJsonMethod = paramJsonAutoDetect.value(); JsonAutoDetect.Visibility localVisibility1; JsonAutoDetect.Visibility localVisibility2; label51: JsonAutoDetect.Visibility localVisibility3; label75: JsonAutoDetect.Visibility localVisibility4; if (hasMethod(arrayOfJsonMethod, JsonMethod.GETTER)) { localVisibility1 = paramJsonAutoDetect.getterVisibility(); this._getterMinLevel = localVisibility1; if (!hasMethod(arrayOfJsonMethod, JsonMethod.IS_GETTER)) break label137; localVisibility2 = paramJsonAutoDetect.isGetterVisibility(); this._isGetterMinLevel = localVisibility2; if (!hasMethod(arrayOfJsonMethod, JsonMethod.SETTER)) break label145; localVisibility3 = paramJsonAutoDetect.setterVisibility(); this._setterMinLevel = localVisibility3; if (!hasMethod(arrayOfJsonMethod, JsonMethod.CREATOR)) break label153; localVisibility4 = paramJsonAutoDetect.creatorVisibility(); label99: this._creatorMinLevel = localVisibility4; if (!hasMethod(arrayOfJsonMethod, JsonMethod.FIELD)) break label161; } label137: label145: label153: label161: for (JsonAutoDetect.Visibility localVisibility5 = paramJsonAutoDetect.fieldVisibility(); ; localVisibility5 = JsonAutoDetect.Visibility.NONE) { this._fieldMinLevel = localVisibility5; return; localVisibility1 = JsonAutoDetect.Visibility.NONE; break; localVisibility2 = JsonAutoDetect.Visibility.NONE; break label51; localVisibility3 = JsonAutoDetect.Visibility.NONE; break label75; localVisibility4 = JsonAutoDetect.Visibility.NONE; break label99; } }
public Std withCreatorVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT); for (JsonAutoDetect.Visibility localVisibility = DEFAULT._creatorMinLevel; ; localVisibility = paramVisibility) { if (this._creatorMinLevel == localVisibility) return this; return new Std(this._getterMinLevel, this._isGetterMinLevel, this._setterMinLevel, localVisibility, this._fieldMinLevel); } }
public Std withFieldVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT); for (JsonAutoDetect.Visibility localVisibility = DEFAULT._fieldMinLevel; ; localVisibility = paramVisibility) { if (this._fieldMinLevel == localVisibility) return this; return new Std(this._getterMinLevel, this._isGetterMinLevel, this._setterMinLevel, this._creatorMinLevel, localVisibility); } }
public Std withGetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT); for (JsonAutoDetect.Visibility localVisibility = DEFAULT._getterMinLevel; ; localVisibility = paramVisibility) { if (this._getterMinLevel == localVisibility) return this; return new Std(localVisibility, this._isGetterMinLevel, this._setterMinLevel, this._creatorMinLevel, this._fieldMinLevel); } }
public Std withIsGetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT); for (JsonAutoDetect.Visibility localVisibility = DEFAULT._isGetterMinLevel; ; localVisibility = paramVisibility) { if (this._isGetterMinLevel == localVisibility) return this; return new Std(this._getterMinLevel, localVisibility, this._setterMinLevel, this._creatorMinLevel, this._fieldMinLevel); } }
public Std withSetterVisibility(JsonAutoDetect.Visibility paramVisibility) { if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT); for (JsonAutoDetect.Visibility localVisibility = DEFAULT._setterMinLevel; ; localVisibility = paramVisibility) { if (this._setterMinLevel == localVisibility) return this; return new Std(this._getterMinLevel, this._isGetterMinLevel, localVisibility, this._creatorMinLevel, this._fieldMinLevel); } }
@Override public VC with(JsonAutoDetect ann) { return this; }
public Std with(JsonAutoDetect paramJsonAutoDetect) { if (paramJsonAutoDetect == null) return this; JsonMethod[] arrayOfJsonMethod = paramJsonAutoDetect.value(); JsonAutoDetect.Visibility localVisibility1; JsonAutoDetect.Visibility localVisibility2; label55: JsonAutoDetect.Visibility localVisibility3; label82: JsonAutoDetect.Visibility localVisibility4; label109: Std localStd4; if (hasMethod(arrayOfJsonMethod, JsonMethod.GETTER)) { localVisibility1 = paramJsonAutoDetect.getterVisibility(); Std localStd1 = withGetterVisibility(localVisibility1); if (!hasMethod(arrayOfJsonMethod, JsonMethod.IS_GETTER)) break label151; localVisibility2 = paramJsonAutoDetect.isGetterVisibility(); Std localStd2 = localStd1.withIsGetterVisibility(localVisibility2); if (!hasMethod(arrayOfJsonMethod, JsonMethod.SETTER)) break label159; localVisibility3 = paramJsonAutoDetect.setterVisibility(); Std localStd3 = localStd2.withSetterVisibility(localVisibility3); if (!hasMethod(arrayOfJsonMethod, JsonMethod.CREATOR)) break label167; localVisibility4 = paramJsonAutoDetect.creatorVisibility(); localStd4 = localStd3.withCreatorVisibility(localVisibility4); if (!hasMethod(arrayOfJsonMethod, JsonMethod.FIELD)) break label175; } label151: label159: label167: label175: for (JsonAutoDetect.Visibility localVisibility5 = paramJsonAutoDetect.fieldVisibility(); ; localVisibility5 = JsonAutoDetect.Visibility.NONE) { return localStd4.withFieldVisibility(localVisibility5); localVisibility1 = JsonAutoDetect.Visibility.NONE; break; localVisibility2 = JsonAutoDetect.Visibility.NONE; break label55; localVisibility3 = JsonAutoDetect.Visibility.NONE; break label82; localVisibility4 = JsonAutoDetect.Visibility.NONE; break label109; } }
HelixClusterAggregator(long relevantTimePeriodInMinutes) { relevantTimePeriodInMs = TimeUnit.MINUTES.toMillis(relevantTimePeriodInMinutes); mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); }
public HelixClusterAggregatorTest() { clusterAggregator = new HelixClusterAggregator(RELEVANT_PERIOD_IN_MINUTES); mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); }