1 13 14 package org.ejbca.ui.web.admin; 15 16 import java.io.Serializable ; 17 18 import javax.faces.application.FacesMessage; 19 import javax.faces.context.FacesContext; 20 21 import org.ejbca.core.model.authorization.AuthorizationDeniedException; 22 import org.ejbca.core.model.log.Admin; 23 import org.ejbca.ui.web.admin.configuration.EjbcaJSFHelper; 24 import org.ejbca.ui.web.admin.configuration.EjbcaWebBean; 25 26 32 public abstract class BaseManagedBean implements Serializable { 33 34 35 protected EjbcaWebBean getEjbcaWebBean(){ 36 return EjbcaJSFHelper.getBean().getEjbcaWebBean(); 37 } 38 39 protected void isAuthorizedNoLog(String resource) throws AuthorizationDeniedException{ 40 getEjbcaWebBean().isAuthorizedNoLog(resource); 41 } 42 43 protected void addErrorMessage(String messageResource){ 44 FacesContext ctx = FacesContext.getCurrentInstance(); 45 ctx.addMessage("error", new FacesMessage(FacesMessage.SEVERITY_ERROR,getEjbcaWebBean().getText(messageResource, true),getEjbcaWebBean().getText(messageResource, true))); 46 } 47 48 protected void addNonTranslatedErrorMessage(String messageResource){ 49 FacesContext ctx = FacesContext.getCurrentInstance(); 50 ctx.addMessage("error", new FacesMessage(FacesMessage.SEVERITY_ERROR,messageResource,messageResource)); 51 } 52 53 54 protected Admin getAdmin(){ 55 return EjbcaJSFHelper.getBean().getAdmin(); 56 } 57 58 59 60 } 61 | Popular Tags |