// Path: api/src/main/java/org/opennms/core/wsman/WSManConstants.java
// public class WSManConstants {
// 
//     public static final String XML_NS_DMTF_WSMAN_V1 = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd";
// 
//     public static final String XML_NS_DMTF_WSMAN_IDENTITY_V1 = "http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd";
// 
//     public static final String XML_NS_WS_2004_08_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
// 
//     public static final String XML_NS_WS_2004_09_ENUMERATION = "http://schemas.xmlsoap.org/ws/2004/09/enumeration";
// 
//     public static final String XML_NS_WS_2004_09_TRANSFER = "http://schemas.xmlsoap.org/ws/2004/09/transfer";
// 
//     public static final String XML_NS_WQL_DIALECT =  "http://schemas.microsoft.com/wbem/wsman/1/WQL";
// 
//     public static final String CIM_ALL_AVAILABLE_CLASSES = "http://schemas.dmtf.org/wbem/wscim/1/*";
// }
// 
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/WSManException.java
// public class WSManException extends RuntimeException {
//     private static final long serialVersionUID = -2894934806760355903L;
// 
//     public WSManException(String message) {
//         super(message);
//     }
// 
//     public WSManException(Throwable cause) {
//         super(cause);
//     }
// 
//     public WSManException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import java.net.URI;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMResult;
import org.opennms.core.wsman.WSManConstants;
import org.opennms.core.wsman.exceptions.WSManException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerateResponse;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerationContextType;
import org.xmlsoap.schemas.ws._2004._09.enumeration.PullResponse;
import org.xmlsoap.schemas.ws._2004._09.transfer.TransferElement;
import schemas.dmtf.org.wbem.wsman.v1.AnyListType;
import schemas.dmtf.org.wbem.wsman.v1.MixedDataType;
package org.opennms.core.wsman.cxf;





/**
 * Utility functions for manipulating WS-Man specific types.
 *
 * These functions should be very strict, and a {@link WSManException}
 * should be thrown if they encounter anything unexpected.
 *
 * @author jwhite
 */
public class TypeUtils {

    private final static QName WSEN_Items_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "Items");
    private final static QName WSEN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "EndOfSequence");
    private final static QName WSMAN_Items_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "Items");
    private final static QName WSMAN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "EndOfSequence");
    private final static QName WSMAN_XmlFragment_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "XmlFragment");

    private final static DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();

    protected static String getContextIdFrom(EnumerateResponse response) {
        // A valid response must always include the EnumerationContext element
        return getContextIdFrom(response.getEnumerationContext());
    }

    protected static String getContextIdFrom(PullResponse response) {
        if (response.getEnumerationContext() == null) {
            // The PullResponse will not contain an EnumerationContext if EndOfSequence is set
            return null;
        }
        return getContextIdFrom(response.getEnumerationContext());
    }

    protected static String getContextIdFrom(EnumerationContextType context) {
        // The content of the EnumerationContext should contain a single string, the context id
        if (context == null || context.getContent() == null) {
// Path: api/src/main/java/org/opennms/core/wsman/WSManConstants.java
// public class WSManConstants {
// 
//     public static final String XML_NS_DMTF_WSMAN_V1 = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd";
// 
//     public static final String XML_NS_DMTF_WSMAN_IDENTITY_V1 = "http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd";
// 
//     public static final String XML_NS_WS_2004_08_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
// 
//     public static final String XML_NS_WS_2004_09_ENUMERATION = "http://schemas.xmlsoap.org/ws/2004/09/enumeration";
// 
//     public static final String XML_NS_WS_2004_09_TRANSFER = "http://schemas.xmlsoap.org/ws/2004/09/transfer";
// 
//     public static final String XML_NS_WQL_DIALECT =  "http://schemas.microsoft.com/wbem/wsman/1/WQL";
// 
//     public static final String CIM_ALL_AVAILABLE_CLASSES = "http://schemas.dmtf.org/wbem/wscim/1/*";
// }
// 
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/WSManException.java
// public class WSManException extends RuntimeException {
//     private static final long serialVersionUID = -2894934806760355903L;
// 
//     public WSManException(String message) {
//         super(message);
//     }
// 
//     public WSManException(Throwable cause) {
//         super(cause);
//     }
// 
//     public WSManException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: cxf/src/main/java/org/opennms/core/wsman/cxf/TypeUtils.java
import java.net.URI;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMResult;
import org.opennms.core.wsman.WSManConstants;
import org.opennms.core.wsman.exceptions.WSManException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerateResponse;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerationContextType;
import org.xmlsoap.schemas.ws._2004._09.enumeration.PullResponse;
import org.xmlsoap.schemas.ws._2004._09.transfer.TransferElement;
import schemas.dmtf.org.wbem.wsman.v1.AnyListType;
import schemas.dmtf.org.wbem.wsman.v1.MixedDataType;

package org.opennms.core.wsman.cxf;





/**
 * Utility functions for manipulating WS-Man specific types.
 *
 * These functions should be very strict, and a {@link WSManException}
 * should be thrown if they encounter anything unexpected.
 *
 * @author jwhite
 */
public class TypeUtils {

    private final static QName WSEN_Items_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "Items");
    private final static QName WSEN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "EndOfSequence");
    private final static QName WSMAN_Items_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "Items");
    private final static QName WSMAN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "EndOfSequence");
    private final static QName WSMAN_XmlFragment_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "XmlFragment");

    private final static DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();

    protected static String getContextIdFrom(EnumerateResponse response) {
        // A valid response must always include the EnumerationContext element
        return getContextIdFrom(response.getEnumerationContext());
    }

    protected static String getContextIdFrom(PullResponse response) {
        if (response.getEnumerationContext() == null) {
            // The PullResponse will not contain an EnumerationContext if EndOfSequence is set
            return null;
        }
        return getContextIdFrom(response.getEnumerationContext());
    }

    protected static String getContextIdFrom(EnumerationContextType context) {
        // The content of the EnumerationContext should contain a single string, the context id
        if (context == null || context.getContent() == null) {
            throw new WSManException(String.format("EnumerationContext %s has no content.", context));