001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.description;
021:
022: import org.apache.axis2.AxisFault;
023: import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
024: import org.apache.axis2.phaseresolver.PhaseResolver;
025: import org.apache.axis2.wsdl.SOAPHeaderMessage;
026: import org.apache.ws.commons.schema.XmlSchema;
027: import org.apache.ws.commons.schema.XmlSchemaElement;
028: import org.apache.ws.commons.schema.XmlSchemaImport;
029: import org.apache.ws.commons.schema.XmlSchemaInclude;
030: import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
031:
032: import javax.xml.namespace.QName;
033: import java.util.ArrayList;
034: import java.util.Iterator;
035: import java.util.List;
036:
037: /**
038: * This class represents the messages in WSDL. There can be message element in services.xml
039: * which are represented by this class.
040: */
041: public class AxisMessage extends AxisDescription {
042:
043: private ArrayList handlerChain;
044: private String name;
045: private ArrayList soapHeaders;
046:
047: //to keep data in WSDL message reference and to keep the Java2WSDL data
048: // such as SchemaElementName , direction etc.
049: private QName elementQname;
050: private String direction;
051: private String messagePartName;
052:
053: // To store deploy-time module refs
054: private ArrayList modulerefs;
055: private String partName = Java2WSDLConstants.PARAMETERS;
056:
057: // private PolicyInclude policyInclude;
058:
059: //To chcek whether the message is wrapped or unwrapped
060: private boolean wrapped = true;
061:
062: public String getMessagePartName() {
063: return messagePartName;
064: }
065:
066: public void setMessagePartName(String messagePartName) {
067: this .messagePartName = messagePartName;
068: }
069:
070: public AxisMessage() {
071: soapHeaders = new ArrayList();
072: handlerChain = new ArrayList();
073: modulerefs = new ArrayList();
074: }
075:
076: public ArrayList getMessageFlow() {
077: return handlerChain;
078: }
079:
080: public boolean isParameterLocked(String parameterName) {
081:
082: // checking the locked value of parent
083: boolean locked = false;
084:
085: if (getParent() != null) {
086: locked = getParent().isParameterLocked(parameterName);
087: }
088:
089: if (locked) {
090: return true;
091: } else {
092: Parameter parameter = getParameter(parameterName);
093:
094: return (parameter != null) && parameter.isLocked();
095: }
096: }
097:
098: public void setMessageFlow(ArrayList operationFlow) {
099: this .handlerChain = operationFlow;
100: }
101:
102: public String getDirection() {
103: return direction;
104: }
105:
106: public void setDirection(String direction) {
107: this .direction = direction;
108: }
109:
110: public QName getElementQName() {
111: return this .elementQname;
112: }
113:
114: public void setElementQName(QName element) {
115: this .elementQname = element;
116: }
117:
118: public Object getKey() {
119: return this .elementQname;
120: }
121:
122: public XmlSchemaElement getSchemaElement() {
123: XmlSchemaElement xmlSchemaElement = null;
124: AxisService service = getAxisOperation().getAxisService();
125: ArrayList schemas = service.getSchema();
126: for (Iterator schemaIter = schemas.iterator(); schemaIter
127: .hasNext();) {
128: xmlSchemaElement = getSchemaElement((XmlSchema) schemaIter
129: .next());
130: if (xmlSchemaElement != null) {
131: break;
132: }
133: }
134: return xmlSchemaElement;
135: }
136:
137: private XmlSchemaElement getSchemaElement(XmlSchema schema) {
138: XmlSchemaElement xmlSchemaElement = null;
139: if (schema != null) {
140: xmlSchemaElement = schema
141: .getElementByName(this .elementQname);
142: if (xmlSchemaElement == null) {
143: // try to find in an import or an include
144: XmlSchemaObjectCollection includes = schema
145: .getIncludes();
146: if (includes != null) {
147: Iterator includesIter = includes.getIterator();
148: Object object;
149: while (includesIter.hasNext()) {
150: object = includesIter.next();
151: if (object instanceof XmlSchemaImport) {
152: XmlSchema schema1 = ((XmlSchemaImport) object)
153: .getSchema();
154: xmlSchemaElement = getSchemaElement(schema1);
155: }
156: if (object instanceof XmlSchemaInclude) {
157: XmlSchema schema1 = ((XmlSchemaInclude) object)
158: .getSchema();
159: xmlSchemaElement = getSchemaElement(schema1);
160: }
161: if (xmlSchemaElement != null) {
162: break;
163: }
164: }
165: }
166: }
167: }
168: return xmlSchemaElement;
169: }
170:
171: public String getName() {
172: return name;
173: }
174:
175: public void setName(String name) {
176: this .name = name;
177: }
178:
179: /**
180: * This will return a list of WSDLExtensibilityAttribute
181: */
182: public List getExtensibilityAttributes() {
183: // TODO : Deepal implement this properly.
184:
185: // the list should contain list of WSDLExtensibilityAttribute
186: return new ArrayList(0);
187: }
188:
189: public void addSoapHeader(SOAPHeaderMessage soapHeaderMessage) {
190: soapHeaders.add(soapHeaderMessage);
191: }
192:
193: public ArrayList getSoapHeaders() {
194: return soapHeaders;
195: }
196:
197: /**
198: * We do not support adding module operations when engaging a module to an AxisMessage
199: *
200: * @param axisModule AxisModule to engage
201: * @param engager
202: * @throws AxisFault something went wrong
203: */
204: public void onEngage(AxisModule axisModule, AxisDescription engager)
205: throws AxisFault {
206: PhaseResolver phaseResolver = new PhaseResolver(
207: getAxisConfiguration());
208: phaseResolver.engageModuleToMessage(this , axisModule);
209: }
210:
211: public ArrayList getModulerefs() {
212: return modulerefs;
213: }
214:
215: public void addModuleRefs(String moduleName) {
216: modulerefs.add(moduleName);
217: }
218:
219: public AxisOperation getAxisOperation() {
220: return (AxisOperation) parent;
221: }
222:
223: public String getPartName() {
224: return partName;
225: }
226:
227: public void setPartName(String partName) {
228: this .partName = partName;
229: }
230:
231: public boolean isWrapped() {
232: return wrapped;
233: }
234:
235: public void setWrapped(boolean wrapped) {
236: this.wrapped = wrapped;
237: }
238: }
|