Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMException


  }

  public OMElement toOMElement(OMElement header) throws OMException {

    if (header == null || !(header instanceof SOAPHeader))
      throw new OMException();

    OMFactory factory = header.getOMFactory();
    if (factory==null)
      factory = defaultFactory;
   
    OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
   
    SOAPHeader SOAPHeader = (SOAPHeader) header;
    SOAPHeaderBlock sequenceAcknowledgementHeaderBlock = SOAPHeader.addHeaderBlock(
        Sandesha2Constants.WSRM_COMMON.USES_SEQUENCE_STR,rmNamespace);
   
    if (sequenceAcknowledgementHeaderBlock == null)
      throw new OMException("Cant set UsesSequenceSTR since the element is null");

    // This header _must_ always be understood
    sequenceAcknowledgementHeaderBlock.setMustUnderstand(true);

    SOAPHeader.addChild(sequenceAcknowledgementHeaderBlock);
View Full Code Here


            } else {
                String systemId = is.getSystemId();
                return StAXUtils.createXMLStreamReader(configuration, systemId, new URL(systemId).openConnection().getInputStream());
            }
        } catch (XMLStreamException ex) {
            throw new OMException(ex);
        } catch (IOException ex) {
            throw new OMException(ex);
        }
    }
View Full Code Here

            case XMLStreamReader.START_DOCUMENT:
                return originalReader;
            case XMLStreamReader.START_ELEMENT:
                return new XMLFragmentStreamReader(originalReader);
            default:
                throw new OMException("The supplied XMLStreamReader is in an unexpected state ("
                        + XMLEventUtils.getEventTypeString(eventType) + ")");
        }
    }
View Full Code Here

            return createOMBuilder(omFactory, ((DOMSource)source).getNode(), true);
        } else {
            try {
                return new StAXOMBuilder(omFactory, StAXUtils.getXMLInputFactory().createXMLStreamReader(source));
            } catch (XMLStreamException ex) {
                throw new OMException(ex);
            }
        }
    }
View Full Code Here

           
            // Add the new OMSourcedElement ot the parent
            parent.addChild(om);
            return om;
        } catch (XMLStreamException e) {
            throw new OMException(e);
        } catch (OMException e) {
            throw e;
        } catch (Throwable t) {
            throw new OMException(t);
        }
    }
View Full Code Here

    public SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns)
            throws OMException {
       
        if (ns == null || ns.getNamespaceURI().length() == 0) {
            throw new OMException(
                    "All the SOAP Header blocks should be namespace qualified");
        }
       
        OMNamespace namespace = findNamespace(ns.getNamespaceURI(), ns.getPrefix());
        if (namespace != null) {
            ns = namespace;
        }
       
        SOAPHeaderBlock soapHeaderBlock;
        try {
            soapHeaderBlock = ((SOAPFactory)factory).createSOAPHeaderBlock(localName, ns, this);
        } catch (SOAPProcessingException e) {
            throw new OMException(e);
        }
        ((OMNodeEx) soapHeaderBlock).setComplete(true);
        return soapHeaderBlock;
    }
View Full Code Here

        if (startNode instanceof OMDocument) {
            currentEvent = -1;
            try {
                next();
            } catch (XMLStreamException ex) {
                throw new OMException(ex);
            }
        } else {
            currentEvent = START_DOCUMENT;
        }
       
View Full Code Here

    public int next() throws OMException {
        try {
            // We need a loop here because we may decide to skip an event
            while (true) {
                if (done) {
                    throw new OMException();
                }
                createDocumentIfNecessary();
                int token = parserNext();
                if (!cache) {
                    return token;
                }
              
                // The current token should be the same as the
                // one just obtained.  This bit of code is used to
                // detect invalid parser state.
                if (doTrace) {
                    int currentParserToken = parser.getEventType();
                    if (currentParserToken != token) {
   
   
                        log.debug("WARNING: The current state of the parser is not equal to the " +
                                  "state just received from the parser. The current state in the paser is " +
                                  XMLEventUtils.getEventTypeString(currentParserToken) + " the state just received is " +
                                  XMLEventUtils.getEventTypeString(token));
   
                        /*
                          throw new OMException("The current token " + token +
                                         " does not match the current event " +
                                         "reported by the parser token.  The parser did not update its state correctly.  " +
                                         "The parser is " + parser);
                         */
                    }
                }
               
                // Now log the current state of the parser
                if (doTrace) {
                    logParserState();
                }
              
                switch (token) {
                    case XMLStreamConstants.START_ELEMENT: {
                        OMNode node = createNextOMElement();
                        // If the node was created by a custom builder, then it will be complete;
                        // in this case, the target doesn't change
                        if (!node.isComplete()) {
                            target = (OMContainerEx)node;
                        }
                        break;
                    }
                    case XMLStreamConstants.CHARACTERS:
                        createOMText(XMLStreamConstants.CHARACTERS);
                        break;
                    case XMLStreamConstants.CDATA:
                        createOMText(XMLStreamConstants.CDATA);
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        endElement();
                        break;
                    case XMLStreamConstants.END_DOCUMENT:
                        done = true;
                        ((OMContainerEx) this.document).setComplete(true);
                        target = null;
                        break;
                    case XMLStreamConstants.SPACE:
                        try {
                            OMNode node = createOMText(XMLStreamConstants.SPACE);
                            if (node == null) {
                                continue;
                            }
                        } catch (OMHierarchyException ex) {
                            // The OM implementation doesn't allow text nodes at the current
                            // position in the tree. Since it is only whitespace, we can safely
                            // skip this event.
                            continue;
                        }
                        break;
                    case XMLStreamConstants.COMMENT:
                        createComment();
                        break;
                    case XMLStreamConstants.DTD:
                        createDTD();
                        break;
                    case XMLStreamConstants.PROCESSING_INSTRUCTION:
                        createPI();
                        break;
                    case XMLStreamConstants.ENTITY_REFERENCE:
                        createEntityReference();
                        break;
                    default :
                        throw new OMException();
                }
                return token;
            }
        } catch (XMLStreamException e) {
            throw new OMException(e);
        }
    }
View Full Code Here

            dtdReader = (DTDReader)parser.getProperty(DTDReader.PROPERTY);
        } catch (IllegalArgumentException ex) {
            dtdReader = null;
        }
        if (dtdReader == null) {
            throw new OMException("Cannot create OMDocType because the XMLStreamReader doesn't support the DTDReader extension");
        }
        String internalSubset = getDTDText();
        // Woodstox returns an empty string if there is no internal subset
        if (internalSubset != null && internalSubset.length() == 0) {
            internalSubset = null;
View Full Code Here

                case XMLStreamConstants.END_ELEMENT:
                    elementLevel--;
                    break;
                case XMLStreamConstants.END_DOCUMENT:
                    if (elementLevel != 0) {
                        throw new OMException("Unexpected END_DOCUMENT event");
                    }
                    break;
            }
            return event;
        }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.