1 package org.andromda.cartridges.bpm4struts.metafacades;
2
3 import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
4 import org.andromda.utils.StringUtilsHelper;
5 import org.andromda.metafacades.uml.StateVertexFacade;
6 import org.andromda.metafacades.uml.UseCaseFacade;
7
8
9 /**
10 * MetafacadeLogic implementation.
11 *
12 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler
13 */
14 public class StrutsExceptionHandlerLogicImpl
15 extends StrutsExceptionHandlerLogic
16 {
17 public StrutsExceptionHandlerLogicImpl(
18 Object metaObject,
19 String context)
20 {
21 super(metaObject, context);
22 }
23
24 protected boolean handleIsFrontEndException()
25 {
26 return this.hasStereotype(Bpm4StrutsProfile.STEREOTYPE_EXCEPTION);
27 }
28
29 /**
30 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionKey()()
31 */
32 protected java.lang.String handleGetExceptionKey()
33 {
34 final String type = getExceptionType();
35 final int dotIndex = type.lastIndexOf('.');
36
37
38 return StringUtilsHelper.toResourceMessageKey((dotIndex < type.length() - 1)
39 ? type.substring(dotIndex + 1) : type);
40 }
41
42 /**
43 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionType()()
44 */
45 protected java.lang.String handleGetExceptionType()
46 {
47 final Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_TYPE);
48 String type = value == null ? null : value.toString();
49 if (type == null)
50 {
51 type = Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_DEFAULT_TYPE;
52 }
53 return type;
54 }
55
56 /**
57 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionPath()()
58 */
59 protected java.lang.String handleGetExceptionPath()
60 {
61 final StateVertexFacade target = getTarget();
62 if (target instanceof StrutsJsp)
63 return ((StrutsJsp)target).getFullPath() + ".jsp";
64 else if (target instanceof StrutsFinalState)
65 return ((StrutsFinalState)target).getFullPath();
66 else
67 return "";
68 }
69
70 protected String handleGetMessageKey()
71 {
72 final UseCaseFacade useCase = this.getUseCase();
73 return useCase != null ? StringUtilsHelper.toResourceMessageKey(useCase.getName()) : null;
74 }
75 }