Search in sources :

Example 6 with MissingNode

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;
}
Also used : MissingNode(com.fasterxml.jackson.databind.node.MissingNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 7 with MissingNode

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) MissingNode(com.fasterxml.jackson.databind.node.MissingNode)

Example 8 with MissingNode

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;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) MissingNode(com.fasterxml.jackson.databind.node.MissingNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 9 with MissingNode

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;
}
Also used : IntNode(com.fasterxml.jackson.databind.node.IntNode) DoubleNode(com.fasterxml.jackson.databind.node.DoubleNode) MissingNode(com.fasterxml.jackson.databind.node.MissingNode)

Example 10 with MissingNode

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);
                }
            }
        }
    }
}
Also used : NativeVideo(com.xrtb.nativeads.creative.NativeVideo) Img(com.xrtb.nativeads.creative.Img) Title(com.xrtb.nativeads.creative.Title) JsonNode(com.fasterxml.jackson.databind.JsonNode) MissingNode(com.fasterxml.jackson.databind.node.MissingNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) Data(com.xrtb.nativeads.creative.Data) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

MissingNode (com.fasterxml.jackson.databind.node.MissingNode)12 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)7 TextNode (com.fasterxml.jackson.databind.node.TextNode)4 IntNode (com.fasterxml.jackson.databind.node.IntNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)2 NativeVideo (com.xrtb.nativeads.creative.NativeVideo)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SecurityQuestionsAuthenticationContext (com.evolveum.midpoint.model.api.context.SecurityQuestionsAuthenticationContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 SecurityQuestionAnswerType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType)1 SecurityQuestionDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionDefinitionType)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 BloomFilter (com.google.common.hash.BloomFilter)1 NavMap (com.xrtb.blocks.NavMap)1