本文整理汇总了Java中org.apache.axiom.om.OMException类的典型用法代码示例。如果您正苦于以下问题:Java OMException类的具体用法?Java OMException怎么用?Java OMException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OMException类属于org.apache.axiom.om包,在下文中一共展示了OMException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBuilder
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Creates an OMBuilder for a plain XML message.
*
* @param inStream InputStream for a XML message
* @param charSetEnc Character set encoding to be used
* @return Handler to a OMBuilder implementation instance
* @throws javax.xml.stream.XMLStreamException
*/
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:24,代码来源:XMLUtil.java
示例2: getSOAPBuilder
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Creates an OMBuilder for a SOAP message. Default character set encording is used.
*
* @param inStream InputStream for a SOAP message
* @return Handler to a OMBuilder implementation instance
* @throws javax.xml.stream.XMLStreamException
*/
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream) , "UTF-8") + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:23,代码来源:XMLUtil.java
示例3: readElement
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Reads the information from the <code>eb:MessageInfo</code> element and stores it in the given implementation of
* {@link MessageUnit}.
* <p>Because the information read from the <code>eb:MessageInfo</code> is not stored in the message unit objects
* themselves this method does not return an object with the info read from the header element but directly stores
* the information in the provided message unit object.
*
* @param miElement The {@link OMElement} object representing the <code>MessageInfo</code> element to read the
* information from
* @param msgUnit The {@link MessageUnit} where information should be stored in
*/
public static void readElement(final OMElement miElement, final MessageUnit msgUnit) {
if (miElement == null)
return;
try {
msgUnit.setTimestamp(Utils.fromXMLDateTime(miElement.getFirstChildWithName(Q_TIMESTAMP).getText()));
} catch (final OMException | ParseException e) {
msgUnit.setTimestamp(null);
}
final OMElement messageId = miElement.getFirstChildWithName(Q_MESSAGEID);
if (messageId != null && !Utils.isNullOrEmpty(messageId.getText()))
msgUnit.setMessageId(messageId.getText());
else
msgUnit.setMessageId(null);
final OMElement refToMsgId = miElement.getFirstChildWithName(Q_REFTO_MESSAGEID);
if (refToMsgId != null && !Utils.isNullOrEmpty(refToMsgId.getText()))
msgUnit.setRefToMessageId(refToMsgId.getText());
}
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:32,代码来源:MessageInfoElement.java
示例4: getJSONString
import org.apache.axiom.om.OMException; //导入依赖的package包/类
protected String getJSONString() {
if (isRead) {
return jsonString;
} else {
try {
BufferedReader br = new BufferedReader(jsonReader);
StringBuilder sb = new StringBuilder(512);
char[] tempBuf = new char[512];
int readLen;
while((readLen = br.read(tempBuf)) != -1) {
sb.append(tempBuf, 0, readLen);
}
jsonString = sb.toString();
} catch (IOException e) {
throw new OMException();
}
isRead = true;
return jsonString;
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:AbstractJSONDataSource.java
示例5: getXMLBytes
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Exposes getOutputStream, which allows faster writes.
XMLStreamWriterWithOS writer = new XMLStreamWriterWithOS(baos, encoding);
// Write the business object to the writer
serialize(writer);
// Flush the writer
writer.flush();
writer.close();
return baos.toByteArray();
} catch (XMLStreamException e) {
throw new OMException(e);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:JAXBDataSource.java
示例6: getAttachmentAsByteArray
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public final byte[] getAttachmentAsByteArray(String cid) {
if (log.isDebugEnabled()) {
log.debug("Attempting to retrieve attachment [" + cid + "] as a byte[]");
}
DataHandler dh = getAttachmentAsDataHandler(cid);
if (dh != null) {
try {
return convert(dh);
} catch (IOException ioe) {
if (log.isDebugEnabled()) {
log.debug("Exception occurred while getting the byte[] " + ioe);
}
throw new OMException(ioe);
}
}
if (log.isDebugEnabled()) {
log.debug("returning null byte[]");
}
return null;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:AbstractJAXBAttachmentUnmarshaller.java
示例7: getAttachmentAsDataHandler
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public final DataHandler getAttachmentAsDataHandler(String cid) {
if (log.isDebugEnabled()) {
log.debug("Attempting to retrieve attachment [" + cid + "] as a DataHandler");
}
DataHandler dh = getDataHandler(cid);
if (dh != null) {
return dh;
} else {
String cid2 = getNewCID(cid);
if (log.isDebugEnabled()) {
log.debug("A dataHandler was not found for [" + cid + "] trying [" + cid2 + "]");
}
dh = getDataHandler(cid2);
if (dh != null) {
return dh;
}
}
// No Data Handler found
throw new OMException(Messages.getMessage("noDataHandler", cid));
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:AbstractJAXBAttachmentUnmarshaller.java
示例8: getBuilder
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Creates an OMBuilder for a plain XML message.
*
* @param inStream InputStream for a XML message
* @param charSetEnc Character set encoding to be used
* @return Handler to a OMBuilder implementation instance
* @throws XMLStreamException
*/
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc)
throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:BuilderUtil.java
示例9: getSOAPBuilder
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Creates an OMBuilder for a SOAP message. Default character set encording is used.
*
* @param inStream InputStream for a SOAP message
* @return Handler to a OMBuilder implementation instance
* @throws XMLStreamException
*/
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream)) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:BuilderUtil.java
示例10: getRootCause
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* This method searches the causes of the specified throwable until it finds one that is
* acceptable as a "root" cause.
* <p/>
* Example: If t is an AxisFault, the code traverses to the next cause.
*
* @param t Throwable
* @return Throwable root cause
*/
private static Throwable getRootCause(Throwable t) {
while (t != null) {
Throwable nextCause = null;
if (t instanceof InvocationTargetException ||
t instanceof OMException ||
t instanceof AxisFault) {
// Skip over this cause
nextCause = getCause(t);
if (nextCause == null) {
logRootCause(t);
return t;
}
t = nextCause;
} else {
// This is the root cause
logRootCause(t);
return t;
}
}
logRootCause(t);
return t;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:ExceptionFactory.java
示例11: getXMLBytes
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Returns a byte[] representing the xml data
* @param encoding String encoding of InputStream
* @return byte[]
* @see getXMLInputStream
*/
public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(encoding);
try {
serialize(baos, format);
} catch (XMLStreamException e) {
new OMException(e);
}
return baos.toByteArray();
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:ADBDataSource.java
示例12: marshalByElement
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Preferred way to marshal objects.
*
* @param b Object that can be rendered as an element and the element name is known by the
* Marshaller
* @param m Marshaller
* @param writer XMLStreamWriter
*/
private static void marshalByElement(final Object b, final Marshaller m,
final XMLStreamWriter writer,
final boolean optimize) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// Marshalling directly to the output stream is faster than marshalling through the
// XMLStreamWriter.
// Take advantage of this optimization if there is an output stream.
try {
OutputStream os = (optimize) ? getOutputStream(writer,m) : null;
if (os != null) {
if (DEBUG_ENABLED) {
log.debug("Invoking marshalByElement. " +
"Marshaling to an OutputStream. " +
"Object is "
+ getDebugName(b));
}
writer.flush();
m.marshal(b, os);
} else {
if (DEBUG_ENABLED) {
log.debug("Invoking marshalByElement. " +
"Marshaling to an XMLStreamWriter. " +
"Object is "
+ getDebugName(b));
}
m.marshal(b, writer);
}
} catch (OMException e) {
throw e;
}
catch (Throwable t) {
throw new OMException(t);
}
return null;
}});
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:46,代码来源:JAXBDSContext.java
示例13: copy
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public OMDataSourceExt copy() throws OMException {
if (DEBUG_ENABLED) {
log.debug("Making a copy of the JAXB object");
}
return new JAXBDataSource(this.getObject(),
(JAXBDSContext) this.getBusinessContext());
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:JAXBBlockImpl.java
示例14: copy
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public OMDataSourceExt copy() throws OMException {
// TODO: This is a default implementation. Much
// more refactoring needs to occur to account for attachments.
try {
String encoding = "utf-8"; // Choose a common encoding
byte[] bytes = this.getXMLBytes(encoding);
return new ByteArrayDataSource(bytes, encoding);
} catch (UnsupportedEncodingException e) {
throw new OMException(e);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:BlockImpl.java
示例15: convertToOMElement
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Convert servicexmlStream to OMElement
*
* @param servicexmlStream InputStream contain xml content
* @return OMElement format of the xml content
* @throws XMLStreamException
*/
public static OMElement convertToOMElement(InputStream servicexmlStream)
throws XMLStreamException, OMException{
OMElement element = null;
element = OMXMLBuilderFactory.createOMBuilder(servicexmlStream).getDocumentElement();
element.build();
return element;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:DataRetrievalUtil.java
示例16: getAttachmentsBuilder
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
InputStream inStream, String contentTypeString,
boolean isSOAP)
throws OMException, XMLStreamException, FactoryConfigurationError {
StAXBuilder builder = null;
XMLStreamReader streamReader;
Attachments attachments = createAttachmentsMap(msgContext, inStream, contentTypeString);
String charSetEncoding = getCharSetEncoding(attachments.getSOAPPartContentType());
if ((charSetEncoding == null)
|| "null".equalsIgnoreCase(charSetEncoding)) {
charSetEncoding = MessageContext.UTF_8;
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
charSetEncoding);
try {
PushbackInputStream pis = getPushbackInputStream(attachments.getSOAPPartInputStream());
String actualCharSetEncoding = getCharSetEncoding(pis, charSetEncoding);
streamReader = StAXUtils.createXMLStreamReader(pis, actualCharSetEncoding);
} catch (IOException e) {
throw new XMLStreamException(e);
}
// Put a reference to Attachments Map in to the message context For
// backword compatibility with Axis2 1.0
msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
// Setting the Attachments map to new SwA API
msgContext.setAttachmentMap(attachments);
String soapEnvelopeNamespaceURI = getEnvelopeNamespace(contentTypeString);
return MessageProcessorSelector.getAttachmentBuilder(msgContext, attachments, streamReader, soapEnvelopeNamespaceURI, isSOAP);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:BuilderUtil.java
示例17: addArtifact
import org.apache.axiom.om.OMException; //导入依赖的package包/类
public String addArtifact(String key, String info, String lifecycleAttribute) throws
RegistryException {
RegistryUtils.recordStatistics(key, info, lifecycleAttribute);
Registry registry = getGovernanceUserRegistry();
if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
return null;
}
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_COALESCING, true);
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(info));
GenericArtifactManager manager = new GenericArtifactManager(registry, key);
GenericArtifact artifact = manager.newGovernanceArtifact(new StAXOMBuilder(reader).getDocumentElement());
// want to save original content, so set content here
artifact.setContent(info.getBytes());
artifact.setAttribute("resource.source", "AdminConsole");
manager.addGenericArtifact(artifact);
if (lifecycleAttribute != null) {
String lifecycle = artifact.getAttribute(lifecycleAttribute);
if (lifecycle != null) {
artifact.attachLifecycle(lifecycle);
}
}
return RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + artifact.getPath();
} catch (Exception e) {
String msg = "Unable to add artifact. ";
if (e instanceof RegistryException) {
throw (RegistryException) e;
} else if (e instanceof OMException) {
msg += "Unexpected character found in input-field name.";
log.error(msg, e);
throw new RegistryException(msg, e);
}
throw new RegistryException(
msg + (e.getCause() instanceof SQLException ? "" : e.getCause().getMessage()),
e);
}
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:41,代码来源:ManageGenericArtifactService.java
示例18: testWithNoEntityBodyPropertTest
import org.apache.axiom.om.OMException; //导入依赖的package包/类
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", expectedExceptions = OMException.class,
description = "Test-With NO_ENTITY_BODY")
public void testWithNoEntityBodyPropertTest() throws Exception {
client.get(getProxyServiceURLHttp("Axis2ProxyService2") + "/echoString?in=IBM");
}
开发者ID:wso2,项目名称:product-ei,代码行数:7,代码来源:PropertyIntegrationNO_ENTITY_BODY_PropertyTest.java
示例19: serialize
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Writes XML through the XMLStreamWriter. As the input data source is JSON, this method needs
* to get a StAX reader from that JSON String. Therefore this uses the getReader() method to get
* the StAX reader writes the events into the XMLStreamWriter.
*
* @param xmlStreamWriter StAX writer to be written into
* @throws javax.xml.stream.XMLStreamException
* if there is an error while writing the message through the StAX writer.
*/
public void serialize(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
XMLStreamReader reader = getReader();
xmlStreamWriter.writeStartDocument();
while (reader.hasNext()) {
int x = reader.next();
switch (x) {
case XMLStreamConstants.START_ELEMENT:
xmlStreamWriter.writeStartElement(reader.getPrefix(), reader.getLocalName(),
reader.getNamespaceURI());
int namespaceCount = reader.getNamespaceCount();
for (int i = namespaceCount - 1; i >= 0; i--) {
xmlStreamWriter.writeNamespace(reader.getNamespacePrefix(i),
reader.getNamespaceURI(i));
}
int attributeCount = reader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
xmlStreamWriter.writeAttribute(reader.getAttributePrefix(i),
reader.getAttributeNamespace(i),
reader.getAttributeLocalName(i),
reader.getAttributeValue(i));
}
break;
case XMLStreamConstants.START_DOCUMENT:
break;
case XMLStreamConstants.CHARACTERS:
xmlStreamWriter.writeCharacters(reader.getText());
break;
case XMLStreamConstants.CDATA:
xmlStreamWriter.writeCData(reader.getText());
break;
case XMLStreamConstants.END_ELEMENT:
xmlStreamWriter.writeEndElement();
break;
case XMLStreamConstants.END_DOCUMENT:
xmlStreamWriter.writeEndDocument();
break;
case XMLStreamConstants.SPACE:
break;
case XMLStreamConstants.COMMENT:
xmlStreamWriter.writeComment(reader.getText());
break;
case XMLStreamConstants.DTD:
xmlStreamWriter.writeDTD(reader.getText());
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
xmlStreamWriter
.writeProcessingInstruction(reader.getPITarget(), reader.getPIData());
break;
case XMLStreamConstants.ENTITY_REFERENCE:
xmlStreamWriter.writeEntityRef(reader.getLocalName());
break;
default :
throw new OMException();
}
}
xmlStreamWriter.writeEndDocument();
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:67,代码来源:AbstractJSONDataSource.java
示例20: marshalOccurrenceArray
import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
* Marshal array objects by type
*
* Invoke marshalByType for each element in the array
*
* @param jaxb_in JAXBElement containing a value that is a List or array
* @param m_in Marshaller
* @param writer_in XMLStreamWriter
*/
private void marshalOccurrenceArray(
final JAXBElement jbe_in,
final Marshaller m_in,
final XMLStreamWriter writer_in) {
if (log.isDebugEnabled()) {
log.debug("Enter marshalOccurrenceArray");
log.debug(" Marshaller = " + JavaUtils.getObjectIdentity(m_in));
}
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
Marshaller m = m_in;
JAXBContext newJBC = null;
if (getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY_PLUS_ARRAYS) {
// Rebuild JAXBContext
// There may be a preferred classloader that should be used
if (log.isDebugEnabled()) {
log.debug("Building a JAXBContext with array capability");
}
ClassLoader cl = getClassLoader();
newJBC = getJAXBContext(cl, true);
m = JAXBUtils.getJAXBMarshaller(newJBC);
if (log.isDebugEnabled()) {
log.debug("The new JAXBContext was constructed with " + getConstructionType());
}
}
OccurrenceArray occurArray = (OccurrenceArray) jbe_in.getValue();
// Create a new JAXBElement.
// The name is the name of the individual occurence elements
// Type type is Object[]
// The value is the array of Object[] representing each element
JAXBElement jbe = new JAXBElement(jbe_in.getName(),
Object[].class,
occurArray.getAsArray());
// The jaxb marshal command cannot write out a list/array
// of occurence elements. So we marshal it as a single
// element containing items...and then put a filter on the
// writer to transform it into a stream of occurence elements
XMLStreamWriterArrayFilter writer = new XMLStreamWriterArrayFilter(writer_in);
m.marshal(jbe, writer);
if (newJBC != null) {
JAXBUtils.releaseJAXBMarshaller(newJBC, m);
}
return null;
} catch (OMException e) {
throw e;
} catch (Throwable t) {
throw new OMException(t);
}
}
});
if (log.isDebugEnabled()) {
log.debug("Exit marshalOccurrenceArray");
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:79,代码来源:JAXBDSContext.java
注:本文中的org.apache.axiom.om.OMException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论