1 // license-header java merge-point
2 //
3 // Generated by: MetafacadeLogicImpl.vsl in andromda-meta-cartridge.
4 package org.andromda.cartridges.jsf.metafacades;
5
6 import org.andromda.cartridges.jsf.JSFProfile;
7 import org.andromda.metafacades.uml.StateVertexFacade;
8 import org.andromda.metafacades.uml.UseCaseFacade;
9 import org.andromda.utils.StringUtilsHelper;
10
11 /**
12 *
13 * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler.
14 *
15 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler
16 */
17 public class JSFExceptionHandlerLogicImpl
18 extends JSFExceptionHandlerLogic
19 {
20 private static final long serialVersionUID = 34L;
21 /**
22 * Public constructor for JSFExceptionHandlerLogicImpl
23 * @param metaObject
24 * @param context
25 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler
26 */
27 public JSFExceptionHandlerLogicImpl(Object metaObject, String context)
28 {
29 super(metaObject, context);
30 }
31
32 /**
33 * <p>
34 * The key to use with this handler's message resource bundle that
35 * will retrieve the error message template for this exception.
36 * </p>
37 * @return exceptionKey
38 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getExceptionKey()
39 */
40 protected String handleGetExceptionKey()
41 {
42 final String type = getExceptionType();
43 final int dotIndex = type.lastIndexOf('.');
44
45 // the dot may not be the last character
46 return StringUtilsHelper.toResourceMessageKey((dotIndex < type.length() - 1)
47 ? type.substring(dotIndex + 1) : type);
48 }
49
50 /**
51 * <p>
52 * The module-relative URI to the resource that will complete the
53 * request/response if this exception occurs.
54 * </p>
55 * @return exceptionPath
56 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getExceptionPath()
57 */
58 protected String handleGetExceptionPath()
59 {
60 final StateVertexFacade target = getTarget();
61 if (target instanceof JSFForward)
62 {
63 return (target).getFullyQualifiedNamePath() + ".jsf";
64 }
65 else if (target instanceof JSFFinalState)
66 {
67 return ((JSFFinalState)target).getFullyQualifiedNamePath();
68 }
69 else
70 {
71 return "";
72 }
73 }
74
75 /**
76 * <p>
77 * Fully qualified Java class name of the exception type to
78 * register with this handler.
79 * </p>
80 * @return exceptionType
81 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getExceptionType()
82 */
83 protected String handleGetExceptionType()
84 {
85 final Object value = this.findTaggedValue(JSFProfile.TAGGEDVALUE_EXCEPTION_TYPE);
86 return value == null ? "" : value.toString();
87 }
88
89 /**
90 *
91 * @return messageKey
92 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getMessageKey()
93 */
94 protected String handleGetMessageKey()
95 {
96 final UseCaseFacade useCase = this.getUseCase();
97 return useCase != null ? StringUtilsHelper.toResourceMessageKey(useCase.getName()) : null;
98 }
99 }