View Javadoc
1   package org.andromda.cartridges.bpm4struts.metafacades;
2   
3   import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
4   import org.andromda.metafacades.uml.StateVertexFacade;
5   import org.andromda.metafacades.uml.UseCaseFacade;
6   import org.andromda.utils.StringUtilsHelper;
7   
8   /**
9    * MetafacadeLogic implementation.
10   *
11   * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler
12   */
13  public class StrutsExceptionHandlerLogicImpl
14      extends StrutsExceptionHandlerLogic
15  {
16      private static final long serialVersionUID = 34L;
17      /**
18       * @param metaObject
19       * @param context
20       */
21      public StrutsExceptionHandlerLogicImpl(
22          Object metaObject,
23          String context)
24      {
25          super(metaObject, context);
26      }
27  
28      /**
29       * @return hasStereotype(Bpm4StrutsProfile.STEREOTYPE_EXCEPTION)
30       */
31      protected boolean handleIsFrontEndException()
32      {
33          return this.hasStereotype(Bpm4StrutsProfile.STEREOTYPE_EXCEPTION);
34      }
35  
36      /**
37       * @return exceptionKey
38       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#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       * @return exceptionType
52       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionType()
53       */
54      protected String handleGetExceptionType()
55      {
56          final Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_TYPE);
57          String type = value == null ? null : value.toString();
58          if (type == null)
59          {
60              type = Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_DEFAULT_TYPE;
61          }
62          return type;
63      }
64  
65      /**
66       * @return getTarget().getFullPath() + ".jsp"
67       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionPath()
68       */
69      protected String handleGetExceptionPath()
70      {
71          final StateVertexFacade target = getTarget();
72          if (target instanceof StrutsJsp)
73              return ((StrutsJsp)target).getFullPath() + ".jsp";
74          else if (target instanceof StrutsFinalState)
75              return ((StrutsFinalState)target).getFullPath();
76          else
77              return "";
78      }
79  
80      /**
81       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandlerLogic#handleGetMessageKey()
82       */
83      protected String handleGetMessageKey()
84      {
85          final UseCaseFacade useCase = this.getUseCase();
86          return useCase != null ? StringUtilsHelper.toResourceMessageKey(useCase.getName()) : null;
87      }
88  }