use of com.fasterxml.jackson.databind.node.MissingNode in project XRTB by benmfaul.
the class Appnexus method checkNonStandard.
/**
* Makes sure the Appnexus keys are available on the creative
* @param creat Creative. The creative in question.
* @param errorString StringBuilder. The error handling string. Add your error here if not null.
* @returns boolean. Returns true if the Exchange and creative are compatible.
*/
@Override
public boolean checkNonStandard(Creative c, StringBuilder sb) {
if (c.extensions == null || c.extensions.get("appnexus_crid") == null) {
if (sb != null)
sb.append("Creative is not Appnexus compatible");
return false;
}
///////////////////////////
//
// Check for seat id
//
Object obj = interrogate("wseat");
if (obj instanceof MissingNode) {
if (sb != null) {
sb.append("appnexus seat missing");
return false;
}
}
ArrayNode list = (ArrayNode) obj;
boolean hasSeat = false;
for (int i = 0; i < list.size(); i++) {
JsonNode nx = list.get(i);
if (nx.asText().equals(Appnexus.seatId)) {
return true;
}
}
if (sb != null)
sb.append("Not our seat");
return false;
}
use of com.fasterxml.jackson.databind.node.MissingNode in project azure-sdk-for-java by Azure.
the class LinuxDiskVolumeEncryptionMonitorImpl method dataDiskStatus.
@Override
public EncryptionStatus dataDiskStatus() {
if (!hasEncryptionExtension()) {
return EncryptionStatus.NOT_ENCRYPTED;
}
final JsonNode subStatusNode = instanceViewFirstSubStatus();
if (subStatusNode == null) {
return EncryptionStatus.UNKNOWN;
}
JsonNode diskNode = subStatusNode.path("data");
if (diskNode instanceof MissingNode) {
return EncryptionStatus.UNKNOWN;
}
return EncryptionStatus.fromString(diskNode.asText());
}
use of com.fasterxml.jackson.databind.node.MissingNode in project azure-sdk-for-java by Azure.
the class CreateVirtualMachinesUsingCustomImageOrSpecializedVHD method extractCapturedImageUri.
private static String extractCapturedImageUri(String capturedResultJson) {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode;
try {
rootNode = mapper.readTree(capturedResultJson);
} catch (IOException exception) {
throw new RuntimeException("Parsing JSON failed -" + capturedResultJson, exception);
}
JsonNode resourcesNode = rootNode.path("resources");
if (resourcesNode instanceof MissingNode) {
throw new IllegalArgumentException("Expected 'resources' node not found in the capture result -" + capturedResultJson);
}
String imageUri = null;
for (JsonNode resourceNode : resourcesNode) {
JsonNode propertiesNodes = resourceNode.path("properties");
if (!(propertiesNodes instanceof MissingNode)) {
JsonNode storageProfileNode = propertiesNodes.path("storageProfile");
if (!(storageProfileNode instanceof MissingNode)) {
JsonNode osDiskNode = storageProfileNode.path("osDisk");
if (!(osDiskNode instanceof MissingNode)) {
JsonNode imageNode = osDiskNode.path("image");
if (!(imageNode instanceof MissingNode)) {
JsonNode uriNode = imageNode.path("uri");
if (!(uriNode instanceof MissingNode)) {
imageUri = uriNode.asText();
}
}
}
}
}
}
if (imageUri == null) {
throw new IllegalArgumentException("Could not locate image uri under expected section in the capture result -" + capturedResultJson);
}
return imageUri;
}
use of com.fasterxml.jackson.databind.node.MissingNode in project XRTB by benmfaul.
the class BidRequest method getDoubleFrom.
/**
* Return a double, whether it's integer or not.
*
* @param o
* Obhect. The json object.
* @return double. Returns the value as a double.
* @throws Exception
* if the object is not a number.
*/
public static double getDoubleFrom(Object o) throws Exception {
double x = 0;
if (o instanceof DoubleNode) {
DoubleNode dn = (DoubleNode) o;
x = dn.doubleValue();
} else if (o instanceof MissingNode) {
throw new Exception("Missing value from: " + o.toString());
} else {
IntNode dn = (IntNode) o;
x = dn.doubleValue();
}
return x;
}
use of com.fasterxml.jackson.databind.node.MissingNode in project XRTB by benmfaul.
the class Impression method doNative.
/**
* Handle the native impression
*/
void doNative() {
JsonNode node = rnode.get("native");
if (node != null) {
JsonNode child = null;
nativead = true;
nativePart = new NativePart();
child = node.path("layout");
if (child != null) {
nativePart.layout = child.intValue();
}
if (node.path("assets") instanceof MissingNode == false) {
ArrayNode array = (ArrayNode) node.path("assets");
for (JsonNode x : array) {
child = x.path("title");
if (child instanceof MissingNode == false) {
nativePart.title = new Title();
nativePart.title.len = child.path("len").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.title.required = x.path("required").intValue();
}
}
child = x.path("img");
if (child instanceof MissingNode == false) {
nativePart.img = new Img();
nativePart.img.w = child.path("w").intValue();
nativePart.img.h = child.path("h").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.img.required = x.path("required").intValue();
}
if (child.path("mimes") instanceof MissingNode == false) {
if (child.path("mimes") instanceof TextNode) {
nativePart.img.mimes.add(child.get("mimes").asText());
} else {
array = (ArrayNode) child.path("mimes");
for (JsonNode nx : array) {
nativePart.img.mimes.add(nx.textValue());
}
}
}
}
child = x.path("video");
if (child instanceof MissingNode == false) {
nativePart.video = new NativeVideo();
nativePart.video.linearity = child.path("linearity").intValue();
nativePart.video.minduration = child.path("minduration").intValue();
nativePart.video.maxduration = child.path("maxduration").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.video.required = x.path("required").intValue();
}
if (child.path("mimes") instanceof MissingNode == false) {
array = (ArrayNode) child.path("protocols");
for (JsonNode nx : array) {
nativePart.video.protocols.add(nx.textValue());
}
}
}
child = x.path("data");
if (child instanceof MissingNode == false) {
Data data = new Data();
if (x.path("required") instanceof MissingNode == false) {
data.required = x.path("required").intValue();
}
if (child.path("len") instanceof MissingNode == false) {
data.len = child.path("len").intValue();
}
data.type = child.path("type").intValue();
nativePart.data.add(data);
}
}
}
}
}
Aggregations