1 23 24 package org.infoglue.cms.applications.structuretool.actions; 25 26 import java.util.List ; 27 28 import javax.servlet.http.Cookie ; 29 30 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 31 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 32 import org.infoglue.cms.entities.management.RepositoryVO; 33 import org.infoglue.cms.util.CmsPropertyHandler; 34 35 36 41 42 public class ViewStructureToolHeaderAction extends InfoGlueAbstractAction 43 { 44 private static final long serialVersionUID = 1L; 45 46 private List repositories; 47 private String tree; 48 private Integer repositoryId; 49 50 public String doExecute() throws Exception  51 { 52 if (tree != null) 54 { 55 Cookie t = new Cookie ("tree", tree); 58 getResponse().addCookie(t); 59 } 60 else 61 { 62 Cookie [] cookies = getRequest().getCookies(); 64 if(cookies != null) 65 for (int i=0; i < cookies.length; i++) 66 if (cookies[i].getName().compareTo("tree") == 0) 67 setTree(cookies[i].getValue()); 68 } 69 70 if (tree == null) 72 setTree(CmsPropertyHandler.getTree()); 73 74 if (tree == null) 76 setTree("applet"); 77 78 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false); 79 80 return "success"; 81 } 82 83 public List getRepositories() 84 { 85 return this.repositories; 86 } 87 88 public Integer getTopRepositoryId() 89 { 90 if (repositoryId != null) 91 return repositoryId; 92 93 if(this.repositories.size() > 0) 94 { 95 return ((RepositoryVO)this.repositories.get(0)).getRepositoryId(); 96 } 97 98 return null; 99 } 100 104 public Integer getRepositoryId() 105 { 106 try 107 { 108 if(this.repositoryId == null) 109 { 110 this.repositoryId = (Integer )getHttpSession().getAttribute("repositoryId"); 111 112 if(this.repositoryId == null) 113 { 114 this.repositoryId = getTopRepositoryId(); 115 getHttpSession().setAttribute("repositoryId", this.repositoryId); 116 } 117 } 118 } 119 catch(Exception e) 120 { 121 } 122 123 return repositoryId; 124 } 125 126 130 public String getRepositoryName() 131 { 132 String repositoryName = ""; 133 try 134 { 135 Integer repositoryId = this.getRepositoryId(); 136 repositoryName = RepositoryController.getController().getRepositoryVOWithId(repositoryId).getName(); 137 } 138 catch(Exception e) 139 { 140 } 141 142 return repositoryName; 143 } 144 145 149 public String getTree() { 150 return tree; 151 } 152 153 157 public void setRepositoryId(Integer repositoryId) { 158 this.repositoryId = repositoryId; 159 } 160 161 165 public void setTree(String tree) { 166 this.tree = tree; 167 } 168 169 } 170 | Popular Tags |