You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by st...@apache.org on 2005/11/18 16:59:39 UTC
svn commit: r345510 - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault: ./
AbstractFaultCode.java FaultCode.java FaultReason.java FaultReasonList.java
FaultSubcode.java SoapFaultSource.java
Author: stevel
Date: Fri Nov 18 07:59:32 2005
New Revision: 345510
URL: http://svn.apache.org/viewcvs?rev=345510&view=rev
Log:
The first step to improving faulting; a representation of all the fancy soap1.2 fault bits.
Added:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,63 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.axis2.fault;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+
+/**
+ * both FaultCodes and Subcodes implement this. They only really vary in how values are handled;
+ * subcodes must have qnames; faultcodes are simple strings.
+ * created 31-Oct-2005 14:20:40
+ */
+
+public abstract class AbstractFaultCode {
+ /**
+ * a subcode, may be null.
+ */
+ private FaultSubcode subcode;
+
+ protected AbstractFaultCode(FaultSubcode subcode) {
+ this.subcode = subcode;
+ }
+
+ protected AbstractFaultCode() {
+ }
+
+ /**
+ * Set the value of the fault code.
+ * <p/>
+ * Subclasses must provide their own specific semantics
+ *
+ * @param value
+ */
+ public abstract void setValue(QName value);
+
+ public FaultSubcode getSubcode() {
+ return subcode;
+ }
+
+ public void setSubcode(FaultSubcode subcode) {
+ this.subcode = subcode;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,86 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.axis2.fault;
+
+import org.apache.axis2.soap.SOAPFaultCode;
+import org.apache.axis2.soap.SOAPFaultValue;
+import org.apache.axis2.soap.SOAPFaultSubCode;
+
+import javax.xml.namespace.QName;
+
+/**
+ * created 31-Oct-2005 13:08:33
+ */
+
+public class FaultCode extends AbstractFaultCode {
+
+ String value;
+
+ /**
+ * simple constructor
+ */
+ public FaultCode() {
+ }
+
+ /**
+ * Constructor to fill in subcodes
+ *
+ * @param value fault value (may be null)
+ * @param subcode fault subcode (may be null)
+ */
+ public FaultCode(String value, FaultSubcode subcode) {
+ super(subcode);
+ setValueString(value);
+ }
+
+ /**
+ * Create a fault code (and all subcodes) from a SOAP Fault Code
+ *
+ * @param source SOAPFaultCode to parse
+ */
+ public FaultCode(SOAPFaultCode source) {
+
+ SOAPFaultValue value = source.getValue();
+ //what if it is a qname already?
+ setValueString(value.getText());
+ SOAPFaultSubCode subCode = source.getSubCode();
+ if (subCode != null) {
+ setSubcode(new FaultSubcode(subCode));
+ }
+ }
+
+ /**
+ * local names are stuck in as a string and turned into a local qname
+ *
+ * @param value
+ */
+ public void setValueString(String value) {
+ QName newName = new QName(value);
+ this.value = newName.toString();
+ }
+
+ public void setValue(QName value) {
+ setValueString(value.toString());
+ }
+
+ public String getValueString() {
+ return value;
+ }
+}
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,71 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.axis2.fault;
+
+/**
+ * Representation of a FaultReason; a language specific reason for a fault.
+ */
+
+public class FaultReason {
+
+ /**
+ * env:reasontext
+ */
+ private String text;
+
+ /**
+ * Language of the reason.
+ * xml:lang="en" "en-GB" or just ""
+ */
+ private String language = "";
+
+ public FaultReason(String text, String language) {
+ this.text = text;
+ this.language = language;
+ }
+
+ public FaultReason() {
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return the text value
+ */
+ public String toString() {
+ return text;
+ }
+}
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,93 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.axis2.fault;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.ListIterator;
+
+/**
+ * A list of fault reasons
+ */
+
+public class FaultReasonList {
+
+ private List reasons;
+
+ public FaultReasonList(int size) {
+ reasons = new ArrayList(size);
+ }
+
+ public FaultReasonList() {
+ this(1);
+ }
+
+ /**
+ * Add a new fault reason
+ *
+ * @param reason new reason
+ */
+ public void add(FaultReason reason) {
+ reasons.add(reason);
+ }
+
+ /**
+ * Add a new fault reason
+ *
+ * @param text text of message
+ * @param language language, can be ""
+ */
+ public void add(String text, String language) {
+ add(new FaultReason(text, language));
+ }
+
+ /**
+ * List iterator.
+ *
+ * @return iterator over elements of type FaultReason
+ */
+ public ListIterator iterator() {
+ return reasons.listIterator();
+ }
+
+ /**
+ * get the first reason text in the array. This is to downconvert to SOAP1.1
+ *
+ * @return the text of the first element in the array, or null for no
+ * reasons
+ */
+ public String getFirstReasonText() {
+ if (reasons.size() > 0) {
+ return reasons.get(0).toString();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * get at the underlying reasons. Useful for java1.5 iteration.
+ *
+ * @return the list of reasons
+ */
+ public List getReasons() {
+ return reasons;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,112 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.axis2.fault;
+
+import org.apache.axis2.soap.SOAPFaultSubCode;
+import org.apache.axis2.soap.SOAPFaultValue;
+import org.apache.axis2.om.OMException;
+
+import javax.xml.namespace.QName;
+
+/**
+ * OM-neutral representation of a SOAP1.2 fault code for use in AxisFaults
+ * created 28-Oct-2005 16:52:29
+ */
+
+public class FaultSubcode extends AbstractFaultCode {
+
+
+ /**
+ * in a subcode this can be an arbitrary qname.
+ * In a s12:Fault/s12:Code/s12:Value form, a limited set of values
+ * are permitted, as documented in
+ *
+ * @see <a href="http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#faultcodes">SOAP Spec</a>
+ */
+ private QName value;
+
+ /**
+ * simple constructor
+ */
+ public FaultSubcode() {
+ }
+
+ /**
+ * Constructor to fill in subcodes
+ *
+ * @param value fault value (may be null)
+ * @param subcode fault subcode (may be null)
+ */
+ public FaultSubcode(QName value, FaultSubcode subcode) {
+ super(subcode);
+ this.value = value;
+ }
+
+
+ /**
+ * Recursively construct from fault information
+ *
+ * @param source
+ */
+ public FaultSubcode(SOAPFaultSubCode source) {
+ SOAPFaultValue value = source.getValue();
+ String text = value.getText();
+ QName qname = source.resolveQName(text);
+ if (qname != null) {
+ setValue(qname);
+ } else {
+ //what to do here?
+ throw new OMException("No QName from " + text);
+ }
+ SOAPFaultSubCode subCode = source.getSubCode();
+ if (subCode != null) {
+ setSubcode(new FaultSubcode(subCode));
+ }
+ }
+
+ /**
+ * Get the current failt code value
+ *
+ * @return
+ */
+ public QName getValue() {
+ return value;
+ }
+
+ /**
+ * set the value of the fault code
+ *
+ * @param value new value
+ */
+ public void setValue(QName value) {
+ this.value = value;
+ }
+
+
+ /**
+ * Returns a string representation of the object.
+ * This only stringifies the base fault
+ *
+ * @return a string representation of the object.
+ */
+ public String toString() {
+ return value != null ? value.toString() : "[undefined fault]";
+ }
+}
Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java?rev=345510&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java Fri Nov 18 07:59:32 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.fault;
+
+import org.apache.axis2.soap.SOAPFault;
+
+import java.util.Iterator;
+
+/**
+ * This is an interface to be implemented by exceptions that can generate
+ * their own SOAPFault directly.
+ * Axis2 can extract the body and any headers and use them in the response.
+ */
+
+
+public interface SoapFaultSource {
+
+ /**
+ * The full SOAPFault to send back. This will become the body of a message.
+ *
+ * @return the SOAPFault to return as the body of a message.
+ */
+ SOAPFault getSOAPFault();
+
+ /**
+ * Get any Headers to include in the message.
+ * Most
+ *
+ * @return an iterator over headers, or null for no headers of interest.
+ */
+ Iterator getHeaders();
+}
Re: svn commit: r345510 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault: ./ AbstractFaultCode.java FaultCode.java FaultReason.java FaultReasonList.java FaultSubcode.java SoapFaultSource.java
Posted by Ruchith Fernando <ru...@gmail.com>.
Hi Steve,
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/AbstractFaultCode.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,63 @@
> +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> + For more information: www.smartfrog.org
> +
> + */
Shouldn't this be the Apache licence? :-)
> +package org.apache.axis2.fault;
> +
> +import org.apache.axis2.om.OMElement;
> +import org.apache.axis2.om.OMNamespace;
> +
> +import javax.xml.namespace.QName;
> +
> +/**
> + * both FaultCodes and Subcodes implement this. They only really vary in how values are handled;
> + * subcodes must have qnames; faultcodes are simple strings.
> + * created 31-Oct-2005 14:20:40
> + */
> +
> +public abstract class AbstractFaultCode {
> + /**
> + * a subcode, may be null.
> + */
> + private FaultSubcode subcode;
> +
> + protected AbstractFaultCode(FaultSubcode subcode) {
> + this.subcode = subcode;
> + }
> +
> + protected AbstractFaultCode() {
> + }
> +
> + /**
> + * Set the value of the fault code.
> + * <p/>
> + * Subclasses must provide their own specific semantics
> + *
> + * @param value
> + */
> + public abstract void setValue(QName value);
> +
> + public FaultSubcode getSubcode() {
> + return subcode;
> + }
> +
> + public void setSubcode(FaultSubcode subcode) {
> + this.subcode = subcode;
> + }
> +
> +}
>
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultCode.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,86 @@
> +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> + For more information: www.smartfrog.org
> +
> + */
> +package org.apache.axis2.fault;
> +
> +import org.apache.axis2.soap.SOAPFaultCode;
> +import org.apache.axis2.soap.SOAPFaultValue;
> +import org.apache.axis2.soap.SOAPFaultSubCode;
> +
> +import javax.xml.namespace.QName;
> +
> +/**
> + * created 31-Oct-2005 13:08:33
> + */
> +
> +public class FaultCode extends AbstractFaultCode {
> +
> + String value;
> +
> + /**
> + * simple constructor
> + */
> + public FaultCode() {
> + }
> +
> + /**
> + * Constructor to fill in subcodes
> + *
> + * @param value fault value (may be null)
> + * @param subcode fault subcode (may be null)
> + */
> + public FaultCode(String value, FaultSubcode subcode) {
> + super(subcode);
> + setValueString(value);
> + }
> +
> + /**
> + * Create a fault code (and all subcodes) from a SOAP Fault Code
> + *
> + * @param source SOAPFaultCode to parse
> + */
> + public FaultCode(SOAPFaultCode source) {
> +
> + SOAPFaultValue value = source.getValue();
> + //what if it is a qname already?
> + setValueString(value.getText());
> + SOAPFaultSubCode subCode = source.getSubCode();
> + if (subCode != null) {
> + setSubcode(new FaultSubcode(subCode));
> + }
> + }
> +
> + /**
> + * local names are stuck in as a string and turned into a local qname
> + *
> + * @param value
> + */
> + public void setValueString(String value) {
> + QName newName = new QName(value);
> + this.value = newName.toString();
> + }
> +
> + public void setValue(QName value) {
> + setValueString(value.toString());
> + }
> +
> + public String getValueString() {
> + return value;
> + }
> +}
>
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReason.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,71 @@
> +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> + For more information: www.smartfrog.org
> +
> + */
> +package org.apache.axis2.fault;
> +
> +/**
> + * Representation of a FaultReason; a language specific reason for a fault.
> + */
> +
> +public class FaultReason {
> +
> + /**
> + * env:reasontext
> + */
> + private String text;
> +
> + /**
> + * Language of the reason.
> + * xml:lang="en" "en-GB" or just ""
> + */
> + private String language = "";
> +
> + public FaultReason(String text, String language) {
> + this.text = text;
> + this.language = language;
> + }
> +
> + public FaultReason() {
> + }
> +
> + public String getText() {
> + return text;
> + }
> +
> + public void setText(String text) {
> + this.text = text;
> + }
> +
> + public String getLanguage() {
> + return language;
> + }
> +
> + public void setLanguage(String language) {
> + this.language = language;
> + }
> +
> + /**
> + * Returns a string representation of the object.
> + *
> + * @return the text value
> + */
> + public String toString() {
> + return text;
> + }
> +}
>
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultReasonList.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,93 @@
> +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> + For more information: www.smartfrog.org
> +
> + */
> +package org.apache.axis2.fault;
> +
> +import java.util.List;
> +import java.util.ArrayList;
> +import java.util.ListIterator;
> +
> +/**
> + * A list of fault reasons
> + */
> +
> +public class FaultReasonList {
> +
> + private List reasons;
> +
> + public FaultReasonList(int size) {
> + reasons = new ArrayList(size);
> + }
> +
> + public FaultReasonList() {
> + this(1);
> + }
> +
> + /**
> + * Add a new fault reason
> + *
> + * @param reason new reason
> + */
> + public void add(FaultReason reason) {
> + reasons.add(reason);
> + }
> +
> + /**
> + * Add a new fault reason
> + *
> + * @param text text of message
> + * @param language language, can be ""
> + */
> + public void add(String text, String language) {
> + add(new FaultReason(text, language));
> + }
> +
> + /**
> + * List iterator.
> + *
> + * @return iterator over elements of type FaultReason
> + */
> + public ListIterator iterator() {
> + return reasons.listIterator();
> + }
> +
> + /**
> + * get the first reason text in the array. This is to downconvert to SOAP1.1
> + *
> + * @return the text of the first element in the array, or null for no
> + * reasons
> + */
> + public String getFirstReasonText() {
> + if (reasons.size() > 0) {
> + return reasons.get(0).toString();
> + } else {
> + return null;
> + }
> + }
> +
> + /**
> + * get at the underlying reasons. Useful for java1.5 iteration.
> + *
> + * @return the list of reasons
> + */
> + public List getReasons() {
> + return reasons;
> + }
> +
> +}
>
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/FaultSubcode.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,112 @@
> +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> + For more information: www.smartfrog.org
> +
> + */
> +package org.apache.axis2.fault;
> +
> +import org.apache.axis2.soap.SOAPFaultSubCode;
> +import org.apache.axis2.soap.SOAPFaultValue;
> +import org.apache.axis2.om.OMException;
> +
> +import javax.xml.namespace.QName;
> +
> +/**
> + * OM-neutral representation of a SOAP1.2 fault code for use in AxisFaults
> + * created 28-Oct-2005 16:52:29
> + */
> +
> +public class FaultSubcode extends AbstractFaultCode {
> +
> +
> + /**
> + * in a subcode this can be an arbitrary qname.
> + * In a s12:Fault/s12:Code/s12:Value form, a limited set of values
> + * are permitted, as documented in
> + *
> + * @see <a href="http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#faultcodes">SOAP Spec</a>
> + */
> + private QName value;
> +
> + /**
> + * simple constructor
> + */
> + public FaultSubcode() {
> + }
> +
> + /**
> + * Constructor to fill in subcodes
> + *
> + * @param value fault value (may be null)
> + * @param subcode fault subcode (may be null)
> + */
> + public FaultSubcode(QName value, FaultSubcode subcode) {
> + super(subcode);
> + this.value = value;
> + }
> +
> +
> + /**
> + * Recursively construct from fault information
> + *
> + * @param source
> + */
> + public FaultSubcode(SOAPFaultSubCode source) {
> + SOAPFaultValue value = source.getValue();
> + String text = value.getText();
> + QName qname = source.resolveQName(text);
> + if (qname != null) {
> + setValue(qname);
> + } else {
> + //what to do here?
> + throw new OMException("No QName from " + text);
> + }
> + SOAPFaultSubCode subCode = source.getSubCode();
> + if (subCode != null) {
> + setSubcode(new FaultSubcode(subCode));
> + }
> + }
> +
> + /**
> + * Get the current failt code value
> + *
> + * @return
> + */
> + public QName getValue() {
> + return value;
> + }
> +
> + /**
> + * set the value of the fault code
> + *
> + * @param value new value
> + */
> + public void setValue(QName value) {
> + this.value = value;
> + }
> +
> +
> + /**
> + * Returns a string representation of the object.
> + * This only stringifies the base fault
> + *
> + * @return a string representation of the object.
> + */
> + public String toString() {
> + return value != null ? value.toString() : "[undefined fault]";
> + }
> +}
>
> Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java?rev=345510&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java (added)
> +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/fault/SoapFaultSource.java Fri Nov 18 07:59:32 2005
> @@ -0,0 +1,46 @@
> +/*
> + * Copyright 2005 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +package org.apache.axis2.fault;
> +
> +import org.apache.axis2.soap.SOAPFault;
> +
> +import java.util.Iterator;
> +
> +/**
> + * This is an interface to be implemented by exceptions that can generate
> + * their own SOAPFault directly.
> + * Axis2 can extract the body and any headers and use them in the response.
> + */
> +
> +
> +public interface SoapFaultSource {
> +
> + /**
> + * The full SOAPFault to send back. This will become the body of a message.
> + *
> + * @return the SOAPFault to return as the body of a message.
> + */
> + SOAPFault getSOAPFault();
> +
> + /**
> + * Get any Headers to include in the message.
> + * Most
> + *
> + * @return an iterator over headers, or null for no headers of interest.
> + */
> + Iterator getHeaders();
> +}
>
>
>
--
Ruchith