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: package org.apache.axis2.description;
020:
021: import org.apache.axiom.om.util.UUIDGenerator;
022: import org.apache.axis2.AxisFault;
023: import org.apache.axis2.context.MessageContext;
024: import org.apache.axis2.context.OperationContext;
025: import org.apache.axis2.i18n.Messages;
026: import org.apache.axis2.wsdl.WSDLConstants;
027:
028: import javax.xml.namespace.QName;
029: import java.util.ArrayList;
030: import java.util.HashMap;
031:
032: public class InOnlyAxisOperation extends AxisOperation {
033:
034: private AxisMessage inFaultMessage;
035: // private AxisMessage inMessage;
036: private AxisMessage outFaultMessage;
037:
038: // this is just to store the chain , we don't use it
039: private ArrayList outPhase;
040:
041: public InOnlyAxisOperation() {
042: super ();
043: //setup a temporary name
044: QName tmpName = new QName(this .getClass().getName() + "_"
045: + UUIDGenerator.getUUID());
046: this .setName(tmpName);
047: createMessage();
048: setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
049: }
050:
051: public InOnlyAxisOperation(QName name) {
052: super (name);
053: createMessage();
054: setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
055: }
056:
057: public void addMessage(AxisMessage message, String label) {
058: if (WSDLConstants.MESSAGE_LABEL_IN_VALUE.equals(label)) {
059: // inMessage = message;
060: addChild("inMessage", message);
061: } else {
062: throw new UnsupportedOperationException(
063: "Not yet implemented");
064: }
065: }
066:
067: public void addMessageContext(MessageContext msgContext,
068: OperationContext opContext) throws AxisFault {
069: if (!opContext.isComplete()) {
070: opContext.getMessageContexts().put(MESSAGE_LABEL_IN_VALUE,
071: msgContext);
072: opContext.setComplete(true);
073: } else {
074: throw new AxisFault(Messages.getMessage("mepcompleted"));
075: }
076: }
077:
078: public void addFaultMessageContext(MessageContext msgContext,
079: OperationContext opContext) throws AxisFault {
080: HashMap mep = opContext.getMessageContexts();
081: MessageContext faultMessageCtxt = (MessageContext) mep
082: .get(MESSAGE_LABEL_FAULT_VALUE);
083: if (faultMessageCtxt != null) {
084: throw new AxisFault(Messages.getMessage("mepcompleted"));
085: } else {
086: mep.put(MESSAGE_LABEL_FAULT_VALUE, msgContext);
087: opContext.setComplete(true);
088: opContext.cleanup();
089: }
090: }
091:
092: private void createMessage() {
093: AxisMessage inMessage = new AxisMessage();
094: inMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
095: inMessage.setParent(this );
096:
097: inFaultMessage = new AxisMessage();
098: inFaultMessage.setParent(this );
099:
100: outFaultMessage = new AxisMessage();
101: outFaultMessage.setParent(this );
102:
103: outPhase = new ArrayList();
104:
105: addChild("inMessage", inMessage);
106: }
107:
108: public AxisMessage getMessage(String label) {
109: if (WSDLConstants.MESSAGE_LABEL_IN_VALUE.equals(label)) {
110: return (AxisMessage) getChild("inMessage");
111: } else {
112: throw new UnsupportedOperationException(Messages
113: .getMessage("invalidacess"));
114: }
115: }
116:
117: public ArrayList getPhasesInFaultFlow() {
118: return inFaultMessage.getMessageFlow();
119: }
120:
121: public ArrayList getPhasesOutFaultFlow() {
122: return outFaultMessage.getMessageFlow();
123: }
124:
125: public ArrayList getPhasesOutFlow() {
126: return outPhase;
127: }
128:
129: public ArrayList getRemainingPhasesInFlow() {
130: return ((AxisMessage) getChild("inMessage")).getMessageFlow();
131: }
132:
133: public void setPhasesInFaultFlow(ArrayList list) {
134: inFaultMessage.setMessageFlow(list);
135: }
136:
137: public void setPhasesOutFaultFlow(ArrayList list) {
138: outFaultMessage.setMessageFlow(list);
139: }
140:
141: public void setPhasesOutFlow(ArrayList list) {
142: outPhase = list;
143: }
144:
145: public void setRemainingPhasesInFlow(ArrayList list) {
146: ((AxisMessage) getChild("inMessage")).setMessageFlow(list);
147: }
148: }
|