001// license-header java merge-point 002// 003// Generated by: MetafacadeLogicImpl.vsl in andromda-meta-cartridge. 004package org.andromda.cartridges.jsf.metafacades; 005 006import org.andromda.cartridges.jsf.JSFProfile; 007import org.andromda.metafacades.uml.StateVertexFacade; 008import org.andromda.metafacades.uml.UseCaseFacade; 009import org.andromda.utils.StringUtilsHelper; 010 011/** 012 * 013 * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler. 014 * 015 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler 016 */ 017public class JSFExceptionHandlerLogicImpl 018 extends JSFExceptionHandlerLogic 019{ 020 private static final long serialVersionUID = 34L; 021 /** 022 * Public constructor for JSFExceptionHandlerLogicImpl 023 * @param metaObject 024 * @param context 025 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler 026 */ 027 public JSFExceptionHandlerLogicImpl(Object metaObject, String context) 028 { 029 super(metaObject, context); 030 } 031 032 /** 033 * <p> 034 * The key to use with this handler's message resource bundle that 035 * will retrieve the error message template for this exception. 036 * </p> 037 * @return exceptionKey 038 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#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 * <p> 052 * The module-relative URI to the resource that will complete the 053 * request/response if this exception occurs. 054 * </p> 055 * @return exceptionPath 056 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getExceptionPath() 057 */ 058 protected String handleGetExceptionPath() 059 { 060 final StateVertexFacade target = getTarget(); 061 if (target instanceof JSFForward) 062 { 063 return (target).getFullyQualifiedNamePath() + ".jsf"; 064 } 065 else if (target instanceof JSFFinalState) 066 { 067 return ((JSFFinalState)target).getFullyQualifiedNamePath(); 068 } 069 else 070 { 071 return ""; 072 } 073 } 074 075 /** 076 * <p> 077 * Fully qualified Java class name of the exception type to 078 * register with this handler. 079 * </p> 080 * @return exceptionType 081 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getExceptionType() 082 */ 083 protected String handleGetExceptionType() 084 { 085 final Object value = this.findTaggedValue(JSFProfile.TAGGEDVALUE_EXCEPTION_TYPE); 086 return value == null ? "" : value.toString(); 087 } 088 089 /** 090 * 091 * @return messageKey 092 * @see org.andromda.cartridges.jsf.metafacades.JSFExceptionHandler#getMessageKey() 093 */ 094 protected String handleGetMessageKey() 095 { 096 final UseCaseFacade useCase = this.getUseCase(); 097 return useCase != null ? StringUtilsHelper.toResourceMessageKey(useCase.getName()) : null; 098 } 099}