1 23 24 package org.infoglue.cms.applications.cmstool.actions; 25 26 import java.util.List ; 27 28 import org.apache.log4j.Logger; 29 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 30 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 31 import org.infoglue.cms.entities.management.RepositoryVO; 32 33 38 39 public abstract class ViewCMSAbstractToolAction extends InfoGlueAbstractAction 40 { 41 private final static Logger logger = Logger.getLogger(ViewCMSAbstractToolAction.class.getName()); 42 43 private Integer repositoryId = null; 44 45 public void setRepositoryId(Integer repositoryId) 46 { 47 this.repositoryId = repositoryId; 48 } 49 50 54 55 public Integer getRepositoryId() 56 { 57 try 58 { 59 if(this.repositoryId == null) 60 { 61 logger.info("The repositoryId was null in ViewContentToolAction so we fetch it from the session"); 62 this.repositoryId = (Integer )getHttpSession().getAttribute("repositoryId"); 63 64 if(this.repositoryId == null) 65 { 66 List authorizedRepositoryVOList = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false); 67 if(authorizedRepositoryVOList.size() > 0) 68 { 69 RepositoryVO repositoryVO = (RepositoryVO)authorizedRepositoryVOList.get(0); 70 this.repositoryId = repositoryVO.getId(); 71 getHttpSession().setAttribute("repositoryId", this.repositoryId); 72 logger.info("We set the defaultRepositoryId in the users session to " + this.repositoryId); 73 } 74 else 75 { 76 this.repositoryId = new Integer (-1); 77 logger.info("We set the defaultRepositoryId in the users session to " + this.repositoryId); 79 } 80 } 81 } 82 } 83 catch(Exception e) 84 { 85 logger.error("The master repository could not be fetched due to an error:" + e.getMessage(), e); 86 } 87 88 return this.repositoryId; 89 } 90 91 92 } 93 | Popular Tags |