1 23 24 package org.infoglue.cms.applications.contenttool.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 ViewContentToolHeaderAction extends InfoGlueAbstractAction 43 { 44 private static final long serialVersionUID = 1L; 45 46 private String tree; 47 private String showVersions; 48 private String exp=""; 50 private Integer repositoryId; 51 52 private List repositories; 53 54 public String doExecute() throws Exception  55 { 56 if (this.showVersions == null || this.showVersions.equals("")) 57 this.showVersions = (String )getRequest().getSession().getAttribute("htmlTreeShowVersions"); 58 else 59 getRequest().getSession().setAttribute("htmlTreeShowVersions", this.showVersions); 60 61 if (showVersions != null) 62 { 63 Cookie t = new Cookie ("showversions", showVersions); 64 getResponse().addCookie(t); 65 } 66 67 if (tree != null) 69 { 70 Cookie t = new Cookie ("tree", tree); 73 getResponse().addCookie(t); 74 } 75 else 76 { 77 Cookie [] cookies = getRequest().getCookies(); 79 if(cookies != null) 80 for (int i=0; i < cookies.length; i++) 81 { 82 if (cookies[i].getName().compareTo("tree") == 0) 83 setTree(cookies[i].getValue()); 84 85 if (cookies[i].getName().compareTo("showversions") == 0) 86 setShowVersions(cookies[i].getValue()); 87 } 88 } 89 90 if (tree == null) 92 setTree(CmsPropertyHandler.getTree()); 93 94 if (tree == null) 96 setTree("applet"); 97 98 if (showVersions == null) 99 setShowVersions("no"); 100 101 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false); 102 103 return "success"; 104 } 105 106 public List getRepositories() 107 { 108 return this.repositories; 109 } 110 111 public Integer getTopRepositoryId() 112 { 113 Integer topRepositoryId = null; 114 115 if (repositoryId != null) 116 topRepositoryId = repositoryId; 117 118 if(this.repositories.size() > 0) 119 { 120 topRepositoryId = ((RepositoryVO)this.repositories.get(0)).getRepositoryId(); 121 } 122 123 return topRepositoryId; 124 } 125 126 130 public String getTree() { 131 return tree; 132 } 133 134 138 public void setTree(String tree) { 139 this.tree = tree; 140 } 141 142 146 public Integer getRepositoryId() 147 { 148 try 149 { 150 if(this.repositoryId == null) 151 { 152 this.repositoryId = (Integer )getHttpSession().getAttribute("repositoryId"); 153 154 if(this.repositoryId == null) 155 { 156 this.repositoryId = getTopRepositoryId(); 157 getHttpSession().setAttribute("repositoryId", this.repositoryId); 158 } 159 } 160 } 161 catch(Exception e) 162 { 163 } 164 165 return repositoryId; 166 } 167 168 172 public String getRepositoryName() 173 { 174 String repositoryName = ""; 175 try 176 { 177 Integer repositoryId = this.getRepositoryId(); 178 repositoryName = RepositoryController.getController().getRepositoryVOWithId(repositoryId).getName(); 179 } 180 catch(Exception e) 181 { 182 } 183 184 return repositoryName; 185 } 186 187 191 public void setRepositoryId(Integer repositoryId) 192 { 193 this.repositoryId = repositoryId; 194 } 195 196 200 public String getShowVersions() 201 { 202 return showVersions; 203 } 204 205 209 public void setShowVersions(String showVersions) 210 { 211 this.showVersions = showVersions; 212 } 213 214 218 public String getExp() 219 { 220 return exp; 221 } 222 223 227 public void setExp(String exp) 228 { 229 this.exp = exp; 230 } 231 232 } 233 | Popular Tags |