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