001package org.andromda.cartridges.bpm4struts.metafacades; 002 003import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile; 004import org.andromda.metafacades.uml.StateVertexFacade; 005import org.andromda.metafacades.uml.UseCaseFacade; 006import org.andromda.utils.StringUtilsHelper; 007 008/** 009 * MetafacadeLogic implementation. 010 * 011 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler 012 */ 013public class StrutsExceptionHandlerLogicImpl 014 extends StrutsExceptionHandlerLogic 015{ 016 private static final long serialVersionUID = 34L; 017 /** 018 * @param metaObject 019 * @param context 020 */ 021 public StrutsExceptionHandlerLogicImpl( 022 Object metaObject, 023 String context) 024 { 025 super(metaObject, context); 026 } 027 028 /** 029 * @return hasStereotype(Bpm4StrutsProfile.STEREOTYPE_EXCEPTION) 030 */ 031 protected boolean handleIsFrontEndException() 032 { 033 return this.hasStereotype(Bpm4StrutsProfile.STEREOTYPE_EXCEPTION); 034 } 035 036 /** 037 * @return exceptionKey 038 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionKey() 039 */ 040 protected String handleGetExceptionKey() 041 { 042 final String type = getExceptionType(); 043 final int dotIndex = type.lastIndexOf('.'); 044 045 // the dot may not be the last character 046 return StringUtilsHelper.toResourceMessageKey((dotIndex < type.length() - 1) 047 ? type.substring(dotIndex + 1) : type); 048 } 049 050 /** 051 * @return exceptionType 052 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionType() 053 */ 054 protected String handleGetExceptionType() 055 { 056 final Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_TYPE); 057 String type = value == null ? null : value.toString(); 058 if (type == null) 059 { 060 type = Bpm4StrutsProfile.TAGGEDVALUE_EXCEPTION_DEFAULT_TYPE; 061 } 062 return type; 063 } 064 065 /** 066 * @return getTarget().getFullPath() + ".jsp" 067 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandler#getExceptionPath() 068 */ 069 protected String handleGetExceptionPath() 070 { 071 final StateVertexFacade target = getTarget(); 072 if (target instanceof StrutsJsp) 073 return ((StrutsJsp)target).getFullPath() + ".jsp"; 074 else if (target instanceof StrutsFinalState) 075 return ((StrutsFinalState)target).getFullPath(); 076 else 077 return ""; 078 } 079 080 /** 081 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsExceptionHandlerLogic#handleGetMessageKey() 082 */ 083 protected String handleGetMessageKey() 084 { 085 final UseCaseFacade useCase = this.getUseCase(); 086 return useCase != null ? StringUtilsHelper.toResourceMessageKey(useCase.getName()) : null; 087 } 088}