Source Code Cross Referenced for AddressingHelper.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » addressing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services AXIS2 » kernal » org.apache.axis2.addressing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.addressing;
020:
021:        import org.apache.axis2.AxisFault;
022:        import org.apache.axis2.Constants;
023:        import org.apache.axis2.context.MessageContext;
024:        import org.apache.axis2.description.AxisOperation;
025:        import org.apache.axis2.description.Parameter;
026:        import org.apache.axis2.util.LoggingControl;
027:        import org.apache.axis2.util.Utils;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:
031:        import java.util.Map;
032:
033:        public class AddressingHelper {
034:
035:            private static final Log log = LogFactory
036:                    .getLog(AddressingHelper.class);
037:
038:            /**
039:             * Returns true if the ReplyTo address does not match one of the supported
040:             * anonymous urls. If the ReplyTo is not set, anonymous is assumed, per the Final
041:             * spec. The AddressingInHandler should have set the ReplyTo to non-null in the
042:             * 2004/08 case to ensure the different semantics. (per AXIS2-885)
043:             *
044:             * @param messageContext
045:             */
046:            public static boolean isReplyRedirected(
047:                    MessageContext messageContext) {
048:                EndpointReference replyTo = messageContext.getReplyTo();
049:                if (replyTo == null) {
050:                    if (LoggingControl.debugLoggingAllowed
051:                            && log.isDebugEnabled()) {
052:                        log
053:                                .debug(messageContext.getLogIDString()
054:                                        + " isReplyRedirected: ReplyTo is null. Returning false");
055:                    }
056:                    return false;
057:                } else {
058:                    return !replyTo.hasAnonymousAddress();
059:                }
060:            }
061:
062:            /**
063:             * Returns true if the FaultTo address does not match one of the supported
064:             * anonymous urls. If the FaultTo is not set, the ReplyTo is checked per the
065:             * spec.
066:             *
067:             * @param messageContext
068:             * @see #isReplyRedirected(org.apache.axis2.context.MessageContext)
069:             */
070:            public static boolean isFaultRedirected(
071:                    MessageContext messageContext) {
072:                EndpointReference faultTo = messageContext.getFaultTo();
073:                if (faultTo == null) {
074:                    if (LoggingControl.debugLoggingAllowed
075:                            && log.isDebugEnabled()) {
076:                        log
077:                                .debug(messageContext.getLogIDString()
078:                                        + " isReplyRedirected: FaultTo is null. Returning isReplyRedirected");
079:                    }
080:                    return isReplyRedirected(messageContext);
081:                } else {
082:                    return !faultTo.hasAnonymousAddress();
083:                }
084:            }
085:
086:            /**
087:             * If the inbound FaultTo header was invalid and caused a fault, the fault should not be
088:             * sent to it.
089:             *
090:             * @return true if the fault should be sent to the FaultTo
091:             */
092:            public static boolean shouldSendFaultToFaultTo(
093:                    MessageContext messageContext) {
094:                // there are some information  that the fault thrower wants to pass to the fault path.
095:                // Means that the fault is a ws-addressing one hence use the ws-addressing fault action.
096:                Object faultInfoForHeaders = messageContext
097:                        .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
098:                // if the exception is due to a problem in the faultTo header itself, we can not use those
099:                // fault informatio to send the error. Try to send using replyTo, leave it to transport
100:                boolean doNotSendFaultUsingFaultTo = false;
101:                if (faultInfoForHeaders != null) {
102:                    // TODO: This should probably store a QName instead of a String.. currently we rely on prefix string matching!!
103:                    String problemHeaderName = (String) ((Map) faultInfoForHeaders)
104:                            .get(AddressingConstants.Final.FAULT_HEADER_PROB_HEADER_QNAME);
105:                    doNotSendFaultUsingFaultTo = (problemHeaderName != null && (AddressingConstants.WSA_DEFAULT_PREFIX
106:                            + ":" + AddressingConstants.WSA_FAULT_TO)
107:                            .equals(problemHeaderName));
108:                }
109:                return !doNotSendFaultUsingFaultTo;
110:            }
111:
112:            /**
113:             * Extract the parameter representing the Anonymous flag from the AxisOperation
114:             * and return the String value. Return the default of "optional" if not specified.
115:             *
116:             * @param axisOperation
117:             */
118:            public static String getAnonymousParameterValue(
119:                    AxisOperation axisOperation) {
120:                String value = "";
121:                if (axisOperation != null) {
122:                    value = Utils
123:                            .getParameterValue(axisOperation
124:                                    .getParameter(AddressingConstants.WSAW_ANONYMOUS_PARAMETER_NAME));
125:                    if (LoggingControl.debugLoggingAllowed
126:                            && log.isDebugEnabled()) {
127:                        log.debug("getAnonymousParameterValue: value: '"
128:                                + value + "'");
129:                    }
130:                }
131:
132:                if (value == null || "".equals(value.trim())) {
133:                    value = "optional";
134:                }
135:                return value.trim();
136:            }
137:
138:            /**
139:             * Set the value of an existing unlocked Parameter representing Anonymous or add a new one if one
140:             * does not exist. If a locked Parameter of the same name already exists the method will trace and
141:             * return.
142:             *
143:             * @param axisOperation
144:             * @param value
145:             */
146:            public static void setAnonymousParameterValue(
147:                    AxisOperation axisOperation, String value) {
148:                if (value == null) {
149:                    if (LoggingControl.debugLoggingAllowed
150:                            && log.isDebugEnabled()) {
151:                        log
152:                                .debug("setAnonymousParameterValue: value passed in is null. return");
153:                    }
154:                    return;
155:                }
156:
157:                Parameter param = axisOperation
158:                        .getParameter(AddressingConstants.WSAW_ANONYMOUS_PARAMETER_NAME);
159:                // If an existing parameter exists
160:                if (param != null) {
161:                    if (LoggingControl.debugLoggingAllowed
162:                            && log.isDebugEnabled()) {
163:                        log
164:                                .debug("setAnonymousParameterValue: Parameter already exists");
165:                    }
166:                    // and is not locked
167:                    if (!param.isLocked()) {
168:                        if (LoggingControl.debugLoggingAllowed
169:                                && log.isDebugEnabled()) {
170:                            log
171:                                    .debug("setAnonymousParameterValue: Parameter not locked. Setting value: "
172:                                            + value);
173:                        }
174:                        // set the value
175:                        param.setValue(value);
176:                    }
177:                } else {
178:                    // otherwise, if no Parameter exists
179:                    if (LoggingControl.debugLoggingAllowed
180:                            && log.isDebugEnabled()) {
181:                        log
182:                                .debug("setAnonymousParameterValue: Parameter does not exist");
183:                    }
184:                    // Create new Parameter with correct name/value
185:                    param = new Parameter();
186:                    param
187:                            .setName(AddressingConstants.WSAW_ANONYMOUS_PARAMETER_NAME);
188:                    param.setValue(value);
189:                    try {
190:                        if (LoggingControl.debugLoggingAllowed
191:                                && log.isDebugEnabled()) {
192:                            log
193:                                    .debug("setAnonymousParameterValue: Adding parameter with value: "
194:                                            + value);
195:                        }
196:                        // and add it to the AxisOperation object
197:                        axisOperation.addParameter(param);
198:                    } catch (AxisFault af) {
199:                        // This should not happen. AxisFault is only ever thrown when a locked Parameter
200:                        // of the same name already exists and this should be dealt with by the outer
201:                        // if statement.
202:                        if (LoggingControl.debugLoggingAllowed
203:                                && log.isDebugEnabled()) {
204:                            log
205:                                    .debug("setAnonymousParameterValue: addParameter failed: "
206:                                            + af.getMessage());
207:                        }
208:                    }
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.