use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project docker-client by spotify.
the class DefaultDockerClient method copyContainer.
@Override
@Deprecated
public InputStream copyContainer(String containerId, String path) throws DockerException, InterruptedException {
final String apiVersion = version().apiVersion();
final int versionComparison = compareVersion(apiVersion, "1.24");
// Version above 1.24
if (versionComparison >= 0) {
throw new UnsupportedApiVersionException(apiVersion);
}
final WebTarget resource = resource().path("containers").path(containerId).path("copy");
// Internal JSON object; not worth it to create class for this
final JsonNodeFactory nf = JsonNodeFactory.instance;
final JsonNode params = nf.objectNode().set("Resource", nf.textNode(path));
try {
return request(POST, InputStream.class, resource, resource.request(APPLICATION_OCTET_STREAM_TYPE), Entity.json(params));
} catch (DockerRequestException e) {
switch(e.status()) {
case 404:
throw new ContainerNotFoundException(containerId, e);
default:
throw e;
}
}
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project snow-owl by b2ihealthcare.
the class CisClient method logout.
public void logout() {
final String tokenBeforeLogout = token.getAndSet(BAD_TOKEN);
// If this is already set to BAD_TOKEN, we are no longer logged in
if (BAD_TOKEN.equals(tokenBeforeLogout)) {
return;
}
LogUtils.logUserAccess(LOGGER, username, "Logging out from Component Identifier service.");
HttpPost request = null;
try {
final JsonNodeFactory factory = JsonNodeFactory.instance;
final JsonNode node = factory.objectNode().set("token", factory.textNode(tokenBeforeLogout));
request = httpPost("logout", node);
client.execute(request);
} catch (IOException e) {
throw new SnowowlRuntimeException("Exception while logging out.", e);
} finally {
if (null != request)
release(request);
}
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class InfoArchiveRestClient method getValidJsonRequestForExport.
private String getValidJsonRequestForExport(String exportConfigurationUri, Collection<SearchResult> searchResults) {
JsonNodeFactory jsonNodeFactory = new ObjectMapper().getNodeFactory();
ObjectNode root = jsonNodeFactory.objectNode();
root.set("exportConfiguration", jsonNodeFactory.textNode(exportConfigurationUri));
root.set("includedRows", getIncludedRows(searchResults, jsonNodeFactory));
return root.toString();
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project rskj by rsksmart.
the class NetworkStateExporter method exportStatus.
public boolean exportStatus(String outputFile) {
Repository frozenRepository = this.repository.getSnapshotTo(this.repository.getRoot());
File dumpFile = new File(outputFile);
try (FileWriter fw = new FileWriter(dumpFile.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw)) {
JsonNodeFactory jsonFactory = new JsonNodeFactory(false);
ObjectNode mainNode = jsonFactory.objectNode();
for (RskAddress addr : frozenRepository.getAccountsKeys()) {
if (!addr.equals(RskAddress.nullAddress())) {
mainNode.set(addr.toString(), createAccountNode(mainNode, addr, frozenRepository));
}
}
ObjectMapper mapper = new ObjectMapper();
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
bw.write(writer.writeValueAsString(mainNode));
return true;
} catch (IOException e) {
logger.error(e.getMessage(), e);
panicProcessor.panic("dumpstate", e.getMessage());
return false;
}
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testKnoxWithKerberosAndEachGwHasKnox.
@Test
public void testKnoxWithKerberosAndEachGwHasKnox() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = new HashSet<>();
instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = jsonNodeFactory.objectNode();
ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, KNOX);
addHostGroup(hostGroupsNode, "gateway2", KNOX, MA_MIN1_MAX3);
addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, MA_MIN1_MAX5);
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
Cluster cluster = new Cluster();
cluster.setSecure(true);
Gateway gateway = new Gateway();
gateway.setEnableGateway(true);
cluster.setGateway(gateway);
// WHEN
underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN no exception thrown
}
Aggregations