本文整理了Java中com.vmware.xenon.common.Utils.toJsonHtml()
方法的一些代码示例,展示了Utils.toJsonHtml()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.toJsonHtml()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:toJsonHtml
暂无
代码示例来源:origin: vmware/xenon
private void markServiceInConflict(ServiceDocument state, ServiceDocument bestPeerRsp) {
logWarning("State in conflict. Local: %s, Among peers: %s",
Utils.toJsonHtml(state), Utils.toJsonHtml(bestPeerRsp));
}
}
代码示例来源:origin: vmware/admiral
private void sendPostAttach(URI uri, Object body, CompletionHandler completionHandler) {
String msg = String.format("Sending POST for attach to %s with body (possibly truncated):"
+ "%n---%n%1.1024s%n---%n", uri, Utils.toJsonHtml(body));
logger.finest(msg);
sendRequest(Service.Action.POST, uri, body, completionHandler, ClientMode.ATTACH);
}
代码示例来源:origin: vmware/admiral
private void sendPost(URI uri, Object body, ClientMode mode,
CompletionHandler completionHandler) {
if (ClientMode.LARGE_DATA != mode) {
String msg = String.format("Sending POST to %s with body (possibly truncated):"
+ "%n---%n%1.1024s%n---%n", uri, Utils.toJsonHtml(body));
logger.finest(msg);
} else {
String msg = String.format("Sending POST to %s with large body", uri);
logger.finest(msg);
}
sendRequest(Service.Action.POST, uri, body, completionHandler, mode);
}
代码示例来源:origin: vmware/xenon
private void saveState(File sandboxDir) throws IOException, InterruptedException {
File hostStateFile = new File(sandboxDir, SERVICE_HOST_STATE_FILE);
this.state.documentUpdateTimeMicros = Utils.getNowMicrosUtc();
byte[] serializedState = Utils.toJsonHtml(this.state).getBytes(Utils.CHARSET);
Files.write(hostStateFile.toPath(), serializedState, StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING);
}
代码示例来源:origin: vmware/xenon
@Override
public String toString() {
SerializedOperation sop = SerializedOperation.create(this);
if (sop.jsonBody != null && sop.jsonBody.length() > TO_STRING_SERIALIZED_BODY_LIMIT) {
// Avoiding logging the entire body, which could be huge, and overwhelm the logs.
// Keep just an arbitrary prefix, serving as a hint
sop.jsonBody = sop.jsonBody.substring(0, TO_STRING_SERIALIZED_BODY_LIMIT);
}
return Utils.toJsonHtml(sop);
}
代码示例来源:origin: vmware/xenon
private static void handleQueryCompletion(ServiceHost host, Operation o, Throwable e) {
if (e != null) {
host.log(Level.SEVERE, "Query task failed: %s", Utils.toString(e));
return;
}
QueryTask queryTask = o.getBody(QueryTask.class);
if (queryTask.results.documentLinks.isEmpty()) {
host.log(Level.INFO, "Query returned no results");
return;
}
host.log(Level.INFO, "Returned query results: %s", Utils.toJsonHtml(queryTask.results));
}
代码示例来源:origin: vmware/xenon
public void logNodeProcessLogs(Set<URI> keySet, String logSuffix) {
List<URI> logServices = new ArrayList<>();
for (URI host : keySet) {
logServices.add(UriUtils.extendUri(host, logSuffix));
}
Map<URI, LogServiceState> states = this.getServiceState(null, LogServiceState.class,
logServices);
for (Entry<URI, LogServiceState> entry : states.entrySet()) {
log("Process log for node %s\n\n%s", entry.getKey(),
Utils.toJsonHtml(entry.getValue()));
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
public void logNodeManagementState(Set<URI> keySet) {
List<URI> services = new ArrayList<>();
for (URI host : keySet) {
services.add(UriUtils.extendUri(host, ServiceUriPaths.CORE_MANAGEMENT));
}
Map<URI, ServiceHostState> states = this.getServiceState(null, ServiceHostState.class,
services);
for (Entry<URI, ServiceHostState> entry : states.entrySet()) {
log("Management state for node %s\n\n%s", entry.getKey(),
Utils.toJsonHtml(entry.getValue()));
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void toJsonHtmlNull() {
String json = Utils.toJsonHtml(null);
assertEquals(json, "null");
}
代码示例来源:origin: vmware/xenon
@Test
public void toJsonHtmlNull() {
String json = Utils.toJsonHtml(null);
assertEquals(json, "null");
}
代码示例来源:origin: vmware/xenon
@Ignore("https://www.pivotaltracker.com/story/show/151532080 Fail on windows")
@Test
public void testPathJsonSerialization() {
Path p = Paths.get("test");
String jsonRepr = Utils.toJson(p);
assertEquals("\"" + p.toAbsolutePath().toAbsolutePath() + "\"", jsonRepr);
Arguments arguments = new Arguments();
Logger.getAnonymousLogger().info(Utils.toJsonHtml(arguments));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Ignore("https://www.pivotaltracker.com/story/show/151532080 Fail on windows")
@Test
public void testPathJsonSerialization() {
Path p = Paths.get("test");
String jsonRepr = Utils.toJson(p);
assertEquals("\"" + p.toAbsolutePath().toAbsolutePath() + "\"", jsonRepr);
Arguments arguments = new Arguments();
Logger.getAnonymousLogger().info(Utils.toJsonHtml(arguments));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void toJsonHtml() {
ServiceDocument doc = new ServiceDocument();
String json = Utils.toJsonHtml(doc);
assertTrue(json.contains(" "));
}
代码示例来源:origin: vmware/xenon
private void logQuerySingleStat() {
Map<String, ServiceStat> stats = this.host
.getServiceStats(this.host.getDocumentIndexServiceUri());
ServiceStat querySingleDurationStat = stats
.get(LuceneDocumentIndexService.STAT_NAME_QUERY_SINGLE_DURATION_MICROS);
if (querySingleDurationStat == null) {
return;
}
this.host.log("%s", Utils.toJsonHtml(querySingleDurationStat));
}
代码示例来源:origin: vmware/xenon
private void handleDocumentTemplateRequest(Operation op) {
if (op.getAction() != Action.GET) {
op.fail(new NotActiveException());
return;
}
ServiceDocument template = this.parent.getDocumentTemplate();
String serializedTemplate = Utils.toJsonHtml(template);
op.setBody(serializedTemplate).complete();
}
代码示例来源:origin: vmware/xenon
@Test
public void testNoHtmlEscping() throws Exception {
SomeComplexObject obj = new SomeComplexObject();
obj.a = "<script>alert('boom!');</script>";
String json = Utils.toJsonHtml(obj);
assertTrue(json.contains(obj.a));
json = Utils.toJson(obj);
assertTrue(json.contains(obj.a));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void testNoHtmlEscping() throws Exception {
SomeComplexObject obj = new SomeComplexObject();
obj.a = "<script>alert('boom!');</script>";
String json = Utils.toJsonHtml(obj);
assertTrue(json.contains(obj.a));
json = Utils.toJson(obj);
assertTrue(json.contains(obj.a));
}
代码示例来源:origin: vmware/xenon
@Override
public void handleStart(Operation startPost) {
if (startPost.hasBody()) {
DefaultHandlerState s = startPost.getBody(DefaultHandlerState.class);
logFine("Initial state is %s", Utils.toJsonHtml(s));
}
startPost.complete();
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Override
public void handleStart(Operation startPost) {
if (startPost.hasBody()) {
DefaultHandlerState s = startPost.getBody(DefaultHandlerState.class);
logFine("Initial state is %s", Utils.toJsonHtml(s));
}
startPost.complete();
}
}
代码示例来源:origin: vmware/xenon
@Test
public void testPrettyPrinting() {
SomeDocument1 doc = new SomeDocument1();
doc.value = new SomeComplexObject("fred", "barney");
String compact = Utils.toJson(doc);
String pretty = Utils.toJsonHtml(doc);
assertTrue(pretty.length() > compact.length());
JsonElement prettyParsed = readJson(pretty);
JsonElement compactParsed = readJson(compact);
assertEquals(compactParsed, prettyParsed);
}
内容来源于网络,如有侵权,请联系作者删除!