Source Code Cross Referenced for WSRPXHelper.java in  » Portal » liferay-portal-4.4.2 » org » apache » wsrp4j » exception » 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 » Portal » liferay portal 4.4.2 » org.apache.wsrp4j.exception 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000-2001,2004 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.wsrp4j.exception;
018:
019:        import java.io.InputStream;
020:        import java.util.Enumeration;
021:        import java.util.HashMap;
022:        import java.util.Properties;
023:        import java.util.StringTokenizer;
024:
025:        import javax.xml.namespace.QName;
026:
027:        import oasis.names.tc.wsrp.v1.types.AccessDeniedFault;
028:        import oasis.names.tc.wsrp.v1.types.Fault;
029:        import oasis.names.tc.wsrp.v1.types.InconsistentParametersFault;
030:        import oasis.names.tc.wsrp.v1.types.InvalidCookieFault;
031:        import oasis.names.tc.wsrp.v1.types.InvalidHandleFault;
032:        import oasis.names.tc.wsrp.v1.types.InvalidRegistrationFault;
033:        import oasis.names.tc.wsrp.v1.types.InvalidSessionFault;
034:        import oasis.names.tc.wsrp.v1.types.InvalidUserCategoryFault;
035:        import oasis.names.tc.wsrp.v1.types.MissingParametersFault;
036:        import oasis.names.tc.wsrp.v1.types.OperationFailedFault;
037:        import oasis.names.tc.wsrp.v1.types.PortletStateChangeRequiredFault;
038:        import oasis.names.tc.wsrp.v1.types.UnsupportedLocaleFault;
039:        import oasis.names.tc.wsrp.v1.types.UnsupportedMimeTypeFault;
040:        import oasis.names.tc.wsrp.v1.types.UnsupportedModeFault;
041:        import oasis.names.tc.wsrp.v1.types.UnsupportedWindowStateFault;
042:
043:        import org.apache.axis.AxisFault;
044:        import org.apache.axis.utils.XMLUtils;
045:        import org.apache.wsrp4j.log.Logger;
046:        import org.apache.wsrp4j.util.Constants;
047:        import org.w3c.dom.Document;
048:        import org.w3c.dom.Element;
049:
050:        /**
051:         * Handles the throwing of exceptions. 
052:         * Instead of calling <code> throw(new WSRPException("exception text")) </code>
053:         * simply type <code>ExceptionHelper throwX(1234)</code>
054:         * So the appropriate messages can be handled in a central place.
055:         * Also the Exceptions will be logged
056:         */
057:        public class WSRPXHelper {
058:
059:            private static final String EMPTY_STRING = "";
060:
061:            // the name of the .properties file
062:            private static String EXCEPTION_MAPPING_FILE = "wsrp-exception-mapping.properties";
063:
064:            // the content of the .properties file
065:            private static HashMap exceptionMapping = null;
066:
067:            /**
068:             * Throws a new exception with a specific message 
069:             * identified by an error code without logging
070:             * 
071:             * @param errorCode integer specifying an error message
072:             * @exception WSRPException
073:             */
074:            public static void throwX(int errorCode) throws WSRPException {
075:                WSRPException e = getException(errorCode, null);
076:                throw e;
077:            }
078:
079:            /**
080:             * Throws a new exception with a specific message 
081:             * identified by an error code without logging
082:             * 
083:             * @param errorCode integer specifying an error message
084:             * @param t         the nested exception
085:             * @exception WSRPException
086:             */
087:            public static void throwX(int errorCode, Throwable t)
088:                    throws WSRPException {
089:                WSRPException e = getException(errorCode, t);
090:                throw e;
091:            }
092:
093:            /**
094:             * Throws a new exception with a specific message
095:             * identified by an error code and logs the exception
096:             * to a logger.
097:             * 
098:             * @param logger    an appropriate logger
099:             * @param logLevel  requested logging level (ERROR,WARN,INFO,
100:             *                  TRACE_LOW,
101:             *                  TRACE_MEDIUM,
102:             *                  TRACE_HIGH)
103:             * @param method    the method in that an Exception is thrown
104:             * @param errorCode integer specifying an error message
105:             * @exception WSRPException
106:             */
107:            public static void throwX(Logger logger, int logLevel,
108:                    String method, int errorCode) throws WSRPException {
109:                WSRPException e = getException(errorCode, null);
110:                //log stack trace
111:                if (logger != null) {
112:                    logger.text(logLevel, method, e, EMPTY_STRING);
113:                }
114:                throw e;
115:            }
116:
117:            /**
118:             * Throws a new exception with a specific message
119:             * identified by an error code and logs the exception
120:             * to a logger.
121:             * 
122:             * @param logger    an appropriate logger
123:             * @param logLevel  requested logging level (ERROR,WARN,INFO,
124:             *                  TRACE_LOW,
125:             *                  TRACE_MEDIUM,
126:             *                  TRACE_HIGH)
127:             * @param method    the method in that an Exception is thrown
128:             * @param errorCode integer specifying an error message
129:             * @param t         the nested exception
130:             * @exception WSRPException
131:             */
132:            public static void throwX(Logger logger, int logLevel,
133:                    String method, int errorCode, Throwable t)
134:                    throws WSRPException {
135:                WSRPException e = getException(errorCode, t);
136:                //log exception
137:                if (logger != null) {
138:                    if (t instanceof  WSRPException) {
139:                        //log NO trace
140:                        logger.text(logLevel, method, e.getMessage());
141:                    } else {
142:                        //log stack trace
143:                        logger.text(logLevel, method, e, EMPTY_STRING);
144:                    }
145:                }
146:                throw e;
147:            }
148:
149:            /**
150:             * This method translates a WSRP exception into an
151:             * apropriate WSRP fault according to the error code
152:             * 
153:             * @param exception the WSRPException to be translated
154:             * @exception java.rmi.RemoteException the translated fault
155:             */
156:            public static void handleWSRPException(WSRPException exception)
157:                    throws java.rmi.RemoteException {
158:
159:                if (exceptionMapping == null) {
160:                    loadExceptionMapping();
161:                }
162:
163:                AxisFault fault = null;
164:                int errorCode = ((Integer) exceptionMapping.get(String
165:                        .valueOf(exception.getErrorCode()))).intValue();
166:
167:                if (errorCode == ErrorCodes.ACCESS_DENIED) {
168:
169:                    fault = new AxisFault();
170:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
171:                            .getNamespaceURI(), Constants.ACCESS_DENIED_FAULT);
172:                    fault.setFaultCode(qname);
173:                    fault.setFaultString(exception.getMessage());
174:
175:                    try {
176:
177:                        Document doc = XMLUtils.newDocument();
178:                        Element element = doc.createElementNS(AccessDeniedFault
179:                                .getTypeDesc().getXmlType().getNamespaceURI(),
180:                                Constants.ACCESS_DENIED_FAULT);
181:                        fault.clearFaultDetails();
182:                        fault.setFaultDetail(new Element[] { element });
183:
184:                    } catch (Exception e) {
185:
186:                        // do nothing and keep the fault details as serialized by axis 
187:                    }
188:
189:                } else if (errorCode == ErrorCodes.INCONSISTENT_PARAMETERS) {
190:
191:                    fault = new AxisFault();
192:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
193:                            .getNamespaceURI(),
194:                            Constants.INCONSISTENT_PARAMETERS_FAULT);
195:                    fault.setFaultCode(qname);
196:                    fault.setFaultString(exception.getMessage());
197:
198:                    try {
199:
200:                        Document doc = XMLUtils.newDocument();
201:                        Element element = doc.createElementNS(
202:                                InconsistentParametersFault.getTypeDesc()
203:                                        .getXmlType().getNamespaceURI(),
204:                                Constants.INCONSISTENT_PARAMETERS_FAULT);
205:                        fault.clearFaultDetails();
206:                        fault.setFaultDetail(new Element[] { element });
207:
208:                    } catch (Exception e) {
209:
210:                        // do nothing and keep the fault details as serialized by axis 
211:                    }
212:
213:                } else if (errorCode == ErrorCodes.INVALID_REGISTRATION) {
214:
215:                    fault = new AxisFault();
216:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
217:                            .getNamespaceURI(),
218:                            Constants.INVALID_REGISTRATION_FAULT);
219:                    fault.setFaultCode(qname);
220:                    fault.setFaultString(exception.getMessage());
221:
222:                    try {
223:
224:                        Document doc = XMLUtils.newDocument();
225:                        Element element = doc.createElementNS(
226:                                InvalidRegistrationFault.getTypeDesc()
227:                                        .getXmlType().getNamespaceURI(),
228:                                Constants.INVALID_REGISTRATION_FAULT);
229:                        fault.clearFaultDetails();
230:                        fault.setFaultDetail(new Element[] { element });
231:
232:                    } catch (Exception e) {
233:
234:                        // do nothing and keep the fault details as serialized by axis 
235:                    }
236:
237:                } else if (errorCode == ErrorCodes.INVALID_COOKIE) {
238:
239:                    fault = new AxisFault();
240:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
241:                            .getNamespaceURI(), Constants.INVALID_COOKIE_FAULT);
242:                    fault.setFaultCode(qname);
243:                    fault.setFaultString(exception.getMessage());
244:
245:                    try {
246:
247:                        Document doc = XMLUtils.newDocument();
248:                        Element element = doc.createElementNS(
249:                                InvalidCookieFault.getTypeDesc().getXmlType()
250:                                        .getNamespaceURI(),
251:                                Constants.INVALID_COOKIE_FAULT);
252:                        fault.clearFaultDetails();
253:                        fault.setFaultDetail(new Element[] { element });
254:
255:                    } catch (Exception e) {
256:
257:                        // do nothing and keep the fault details as serialized by axis 
258:                    }
259:
260:                } else if (errorCode == ErrorCodes.INVALID_HANDLE) {
261:                    fault = new AxisFault();
262:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
263:                            .getNamespaceURI(), Constants.INVALID_HANDLE_FAULT);
264:                    fault.setFaultCode(qname);
265:                    fault.setFaultString(exception.getMessage());
266:
267:                    try {
268:
269:                        Document doc = XMLUtils.newDocument();
270:                        Element element = doc.createElementNS(
271:                                InvalidHandleFault.getTypeDesc().getXmlType()
272:                                        .getNamespaceURI(),
273:                                Constants.INVALID_HANDLE_FAULT);
274:                        fault.clearFaultDetails();
275:                        fault.setFaultDetail(new Element[] { element });
276:
277:                    } catch (Exception e) {
278:
279:                        // do nothing and keep the fault details as serialized by axis 
280:                    }
281:
282:                } else if (errorCode == ErrorCodes.INVALID_SESSION) {
283:                    fault = new AxisFault();
284:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
285:                            .getNamespaceURI(), Constants.INVALID_SESSION_FAULT);
286:                    fault.setFaultCode(qname);
287:                    fault.setFaultString(exception.getMessage());
288:
289:                    try {
290:
291:                        Document doc = XMLUtils.newDocument();
292:                        Element element = doc.createElementNS(
293:                                InvalidSessionFault.getTypeDesc().getXmlType()
294:                                        .getNamespaceURI(),
295:                                Constants.INVALID_SESSION_FAULT);
296:                        fault.clearFaultDetails();
297:                        fault.setFaultDetail(new Element[] { element });
298:
299:                    } catch (Exception e) {
300:
301:                        // do nothing and keep the fault details as serialized by axis 
302:                    }
303:
304:                } else if (errorCode == ErrorCodes.INVALID_USER_CATEGORY) {
305:                    fault = new AxisFault();
306:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
307:                            .getNamespaceURI(),
308:                            Constants.INVALID_USER_CATEGORY_FAULT);
309:                    fault.setFaultCode(qname);
310:                    fault.setFaultString(exception.getMessage());
311:
312:                    try {
313:
314:                        Document doc = XMLUtils.newDocument();
315:                        Element element = doc.createElementNS(
316:                                InvalidUserCategoryFault.getTypeDesc()
317:                                        .getXmlType().getNamespaceURI(),
318:                                Constants.INVALID_USER_CATEGORY_FAULT);
319:                        fault.clearFaultDetails();
320:                        fault.setFaultDetail(new Element[] { element });
321:
322:                    } catch (Exception e) {
323:
324:                        // do nothing and keep the fault details as serialized by axis 
325:                    }
326:
327:                } else if (errorCode == ErrorCodes.MISSING_PARAMETERS) {
328:
329:                    fault = new AxisFault();
330:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
331:                            .getNamespaceURI(),
332:                            Constants.MISSING_PARAMETERS_FAULT);
333:                    fault.setFaultCode(qname);
334:                    fault.setFaultString(exception.getMessage());
335:
336:                    try {
337:
338:                        Document doc = XMLUtils.newDocument();
339:                        Element element = doc.createElementNS(
340:                                MissingParametersFault.getTypeDesc()
341:                                        .getXmlType().getNamespaceURI(),
342:                                Constants.MISSING_PARAMETERS_FAULT);
343:                        fault.clearFaultDetails();
344:                        fault.setFaultDetail(new Element[] { element });
345:
346:                    } catch (Exception e) {
347:
348:                        // do nothing and keep the fault details as serialized by axis 
349:                    }
350:
351:                } else if (errorCode == ErrorCodes.OPERATION_FAILED) {
352:
353:                    fault = new AxisFault();
354:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
355:                            .getNamespaceURI(),
356:                            Constants.OPERATION_FAILED_FAULT);
357:                    fault.setFaultCode(qname);
358:                    fault.setFaultString(exception.getMessage());
359:
360:                    try {
361:
362:                        Document doc = XMLUtils.newDocument();
363:                        Element element = doc.createElementNS(
364:                                OperationFailedFault.getTypeDesc().getXmlType()
365:                                        .getNamespaceURI(),
366:                                Constants.OPERATION_FAILED_FAULT);
367:                        fault.clearFaultDetails();
368:                        fault.setFaultDetail(new Element[] { element });
369:
370:                    } catch (Exception e) {
371:
372:                        // do nothing and keep the fault details as serialized by axis 
373:                    }
374:
375:                } else if (errorCode == ErrorCodes.PORTLET_STATE_CHANGE_REQUIRED) {
376:                    fault = new AxisFault();
377:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
378:                            .getNamespaceURI(),
379:                            Constants.PORTLET_STATE_CHANGE_REQUIRED_FAULT);
380:                    fault.setFaultCode(qname);
381:                    fault.setFaultString(exception.getMessage());
382:
383:                    try {
384:
385:                        Document doc = XMLUtils.newDocument();
386:                        Element element = doc.createElementNS(
387:                                PortletStateChangeRequiredFault.getTypeDesc()
388:                                        .getXmlType().getNamespaceURI(),
389:                                Constants.PORTLET_STATE_CHANGE_REQUIRED_FAULT);
390:                        fault.clearFaultDetails();
391:                        fault.setFaultDetail(new Element[] { element });
392:
393:                    } catch (Exception e) {
394:
395:                        // do nothing and keep the fault details as serialized by axis 
396:                    }
397:
398:                } else if (errorCode == ErrorCodes.UNSUPPORTED_LOCALE) {
399:
400:                    fault = new AxisFault();
401:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
402:                            .getNamespaceURI(),
403:                            Constants.UNSUPPORTED_LOCALE_FAULT);
404:                    fault.setFaultCode(qname);
405:                    fault.setFaultString(exception.getMessage());
406:
407:                    try {
408:
409:                        Document doc = XMLUtils.newDocument();
410:                        Element element = doc.createElementNS(
411:                                UnsupportedLocaleFault.getTypeDesc()
412:                                        .getXmlType().getNamespaceURI(),
413:                                Constants.UNSUPPORTED_LOCALE_FAULT);
414:                        fault.clearFaultDetails();
415:                        fault.setFaultDetail(new Element[] { element });
416:
417:                    } catch (Exception e) {
418:
419:                        // do nothing and keep the fault details as serialized by axis 
420:                    }
421:
422:                } else if (errorCode == ErrorCodes.UNSUPPORTED_MIME_TYPE) {
423:
424:                    fault = new AxisFault();
425:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
426:                            .getNamespaceURI(),
427:                            Constants.UNSUPPORTED_MIME_TYPE_FAULT);
428:                    fault.setFaultCode(qname);
429:                    fault.setFaultString(exception.getMessage());
430:
431:                    try {
432:
433:                        Document doc = XMLUtils.newDocument();
434:                        Element element = doc.createElementNS(
435:                                UnsupportedMimeTypeFault.getTypeDesc()
436:                                        .getXmlType().getNamespaceURI(),
437:                                Constants.UNSUPPORTED_MIME_TYPE_FAULT);
438:                        fault.clearFaultDetails();
439:                        fault.setFaultDetail(new Element[] { element });
440:
441:                    } catch (Exception e) {
442:
443:                        // do nothing and keep the fault details as serialized by axis 
444:                    }
445:
446:                } else if (errorCode == ErrorCodes.UNSUPPORTED_MODE) {
447:
448:                    fault = new AxisFault();
449:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
450:                            .getNamespaceURI(),
451:                            Constants.UNSUPPORTED_MODE_FAULT);
452:                    fault.setFaultCode(qname);
453:                    fault.setFaultString(exception.getMessage());
454:
455:                    try {
456:
457:                        Document doc = XMLUtils.newDocument();
458:                        Element element = doc.createElementNS(
459:                                UnsupportedModeFault.getTypeDesc().getXmlType()
460:                                        .getNamespaceURI(),
461:                                Constants.UNSUPPORTED_MODE_FAULT);
462:                        fault.clearFaultDetails();
463:                        fault.setFaultDetail(new Element[] { element });
464:
465:                    } catch (Exception e) {
466:
467:                        // do nothing and keep the fault details as serialized by axis 
468:                    }
469:
470:                } else if (errorCode == ErrorCodes.UNSUPPORTED_WINDOW_STATE) {
471:
472:                    fault = new AxisFault();
473:                    QName qname = new QName(Fault.getTypeDesc().getXmlType()
474:                            .getNamespaceURI(),
475:                            Constants.UNSUPPORTED_WINDOW_STATE_FAULT);
476:                    fault.setFaultCode(qname);
477:                    fault.setFaultString(exception.getMessage());
478:
479:                    try {
480:
481:                        Document doc = XMLUtils.newDocument();
482:                        Element element = doc.createElementNS(
483:                                UnsupportedWindowStateFault.getTypeDesc()
484:                                        .getXmlType().getNamespaceURI(),
485:                                Constants.UNSUPPORTED_WINDOW_STATE_FAULT);
486:                        fault.clearFaultDetails();
487:                        fault.setFaultDetail(new Element[] { element });
488:
489:                    } catch (Exception e) {
490:
491:                        // do nothing and keep the fault details as serialized by axis 
492:                    }
493:
494:                } else {
495:
496:                    throw new java.rmi.RemoteException();
497:
498:                }
499:
500:                throw fault;
501:
502:            }
503:
504:            private static void loadExceptionMapping() {
505:                try {
506:                    exceptionMapping = new HashMap();
507:
508:                    // read in .properties-file
509:                    InputStream in = WSRPXHelper.class.getClassLoader()
510:                            .getResourceAsStream(EXCEPTION_MAPPING_FILE);
511:                    Properties props = new Properties();
512:                    props.load(in);
513:
514:                    // convert read Properties to a more useful representation
515:                    Enumeration keys = props.propertyNames();
516:                    StringTokenizer tokenizer = null;
517:
518:                    while (keys.hasMoreElements()) {
519:
520:                        String value = null;
521:                        String currentKey = (String) keys.nextElement();
522:                        exceptionMapping.put(currentKey,
523:                                new Integer(currentKey));
524:
525:                        value = props.getProperty(currentKey);
526:                        if (value != null && value.length() > 0) {
527:                            tokenizer = new StringTokenizer(value, ",");
528:                            String token = null;
529:
530:                            while (tokenizer.hasMoreTokens()) {
531:                                token = tokenizer.nextToken();
532:
533:                                if (token != null) {
534:                                    exceptionMapping.put(token, new Integer(
535:                                            currentKey));
536:                                }
537:
538:                            }
539:
540:                        }
541:                    }
542:
543:                } catch (Exception e) {
544:
545:                    // TODO
546:                    e.printStackTrace();
547:
548:                }
549:
550:            }
551:
552:            /**
553:             * This method translates a WSRP fault into a WSRP 
554:             * exception containing a corresponding error code
555:             * and logs the occurence of the exception
556:             * 
557:             * @param logger the logger to be used
558:             * @param wsrpFault the fault to be translated
559:             * @exception WSRPException this is the translated exception
560:             */
561:            public static void handleWSRPFault(Logger logger,
562:                    java.rmi.RemoteException wsrpFault) throws WSRPException {
563:
564:                if (wsrpFault instanceof  AccessDeniedFault) {
565:
566:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
567:                            1100, wsrpFault);
568:
569:                } else if (wsrpFault instanceof  InconsistentParametersFault) {
570:
571:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
572:                            1101, wsrpFault);
573:
574:                } else if (wsrpFault instanceof  InvalidRegistrationFault) {
575:
576:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
577:                            1102, wsrpFault);
578:
579:                } else if (wsrpFault instanceof  InvalidCookieFault) {
580:
581:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
582:                            1103, wsrpFault);
583:
584:                } else if (wsrpFault instanceof  InvalidHandleFault) {
585:
586:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
587:                            1104, wsrpFault);
588:
589:                } else if (wsrpFault instanceof  InvalidSessionFault) {
590:
591:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
592:                            1105, wsrpFault);
593:
594:                } else if (wsrpFault instanceof  InvalidUserCategoryFault) {
595:
596:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
597:                            1106, wsrpFault);
598:
599:                } else if (wsrpFault instanceof  MissingParametersFault) {
600:
601:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
602:                            1107, wsrpFault);
603:
604:                } else if (wsrpFault instanceof  OperationFailedFault) {
605:
606:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
607:                            1108, wsrpFault);
608:
609:                } else if (wsrpFault instanceof  PortletStateChangeRequiredFault) {
610:
611:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
612:                            1109, wsrpFault);
613:
614:                } else if (wsrpFault instanceof  UnsupportedLocaleFault) {
615:
616:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
617:                            1110, wsrpFault);
618:
619:                } else if (wsrpFault instanceof  UnsupportedMimeTypeFault) {
620:
621:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
622:                            1111, wsrpFault);
623:
624:                } else if (wsrpFault instanceof  UnsupportedModeFault) {
625:
626:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
627:                            1112, wsrpFault);
628:
629:                } else if (wsrpFault instanceof  UnsupportedWindowStateFault) {
630:
631:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
632:                            1113, wsrpFault);
633:
634:                } else {
635:
636:                    // its any other java.rmi.RemoteException
637:                    WSRPXHelper.throwX(logger, Logger.ERROR, EMPTY_STRING,
638:                            1116, wsrpFault);
639:
640:                }
641:
642:            }
643:
644:            /**
645:             Returns an Exception. The type of the Exception depends on the error code that is passed to the method.
646:             @param errorCode integer specifying an error message
647:             @return Exception. The type depends on the error code
648:             */
649:            protected static WSRPException getException(int errorCode,
650:                    Throwable t) {
651:                WSRPException e = null;
652:                if (errorCode >= Messages.PRODUCER_LOWER_BOUND
653:                        && errorCode <= Messages.PRODUCER_UPPER_BOUND) {
654:                    if (t == null) {
655:
656:                        e = new WSRPException(errorCode);
657:                    } else {
658:                        e = new WSRPException(errorCode, t);
659:                    }
660:                    e.setProducerExceptionRange();
661:                } else if (errorCode >= Messages.PROVIDER_LOWER_BOUND
662:                        && errorCode <= Messages.PROVIDER_UPPER_BOUND) {
663:                    if (t == null) {
664:
665:                        e = new WSRPException(errorCode);
666:                    } else {
667:                        e = new WSRPException(errorCode, t);
668:                    }
669:                    e.setProviderExceptionRange();
670:                } else if (errorCode >= Messages.CONSUMER_LOWER_BOUND
671:                        && errorCode <= Messages.CONSUMER_UPPER_BOUND) {
672:                    if (t == null) {
673:
674:                        e = new WSRPException(errorCode);
675:                    } else {
676:                        e = new WSRPException(errorCode, t);
677:                    }
678:                    e.setConsumerExceptionRange();
679:                } else if (errorCode >= Messages.COMMON_LOWER_BOUND
680:                        && errorCode <= Messages.COMMON_UPPER_BOUND) {
681:                    if (t == null) {
682:
683:                        e = new WSRPException(errorCode);
684:                    } else {
685:                        e = new WSRPException(errorCode, t);
686:                    }
687:                    e.setCommonExceptionRange();
688:                } else {
689:                    if (t == null) {
690:
691:                        e = new WSRPException(errorCode);
692:                    } else {
693:                        e = new WSRPException(errorCode, t);
694:                    }
695:                }
696:                return e;
697:            }
698:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.