View Javadoc

1   /*
2    * Copyright  2004 The Apache Software Foundation.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package org.apache.kandula.wsat.completion;
18  
19  import org.apache.axiom.om.OMElement;
20  import org.apache.axis2.AxisFault;
21  import org.apache.axis2.context.OperationContext;
22  import org.apache.axis2.wsdl.WSDLConstants;
23  import org.apache.kandula.Constants;
24  import org.apache.kandula.Status;
25  import org.apache.kandula.context.AbstractContext;
26  import org.apache.kandula.storage.StorageFactory;
27  
28  /***
29   * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
30   */
31  
32  public class CompletionInitiatorPortTypeRawXMLSkeleton {
33  	private OperationContext opContext;
34  
35  	public void setOperationContext(OperationContext opContext) {
36  		this.opContext = opContext;
37  	}
38  
39  	public OMElement committedOperation(OMElement requestElement)
40  			throws AxisFault {
41  		StorageFactory.getInstance().setConfigurationContext(
42  				opContext.getServiceContext().getConfigurationContext());
43  		OMElement header = opContext.getMessageContext(
44  				WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope().getHeader();
45  		String requesterID = header.getFirstChildWithName(
46  				Constants.REQUESTER_ID_PARAMETER).getText();
47  		AbstractContext context = (AbstractContext) StorageFactory
48  				.getInstance().getInitiatorStore().get(requesterID);
49  		context.setStatus(Status.ParticipantStatus.STATUS_COMMITED);
50  		return null;
51  	}
52  
53  	public OMElement abortedOperation(OMElement requestElement)
54  			throws AxisFault {
55  		StorageFactory.getInstance().setConfigurationContext(
56  				opContext.getServiceContext().getConfigurationContext());
57  		OMElement header = opContext.getMessageContext(
58  				WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope().getHeader();
59  		String requesterID = header.getFirstChildWithName(
60  				Constants.REQUESTER_ID_PARAMETER).getText();
61  		AbstractContext context = (AbstractContext) StorageFactory
62  				.getInstance().getInitiatorStore().get(requesterID);
63  		context.setStatus(Status.ParticipantStatus.STATUS_ABORTED);
64  		return null;
65  	}
66  }