1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.net.URLEncoder ; 27 import java.util.List ; 28 29 import org.apache.log4j.Logger; 30 import org.infoglue.cms.applications.common.actions.TreeViewAbstractAction; 31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 32 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 33 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryLanguageController; 34 import org.infoglue.cms.entities.management.RepositoryVO; 35 import org.infoglue.cms.treeservice.ss.ContentNodeSupplier; 36 import org.infoglue.cms.treeservice.ss.ContentNodeVersionSupplier; 37 import org.infoglue.cms.util.CmsPropertyHandler; 38 39 import com.frovi.ss.Tree.BaseNode; 40 import com.frovi.ss.Tree.INodeSupplier; 41 42 public class ViewContentToolMenuHtmlAction extends TreeViewAbstractAction 43 { 44 private final static Logger logger = Logger.getLogger(ViewContentToolMenuHtmlAction.class.getName()); 45 46 private static final long serialVersionUID = 1L; 47 48 private Integer repositoryId; 49 private String showVersions; 50 private String showLeafs = "yes"; 51 private String treeMode = "classic"; 52 private Integer select; 53 private BaseNode rootNode = null; 54 private String [] allowedContentTypeIds = null; 55 private String bodyClass; 56 57 63 64 65 public String doBindingView() throws Exception 66 { 67 super.doExecute(); 68 69 return "bindingView"; 70 } 71 72 75 protected INodeSupplier getNodeSupplier() throws Exception , org.infoglue.cms.exception.SystemException 76 { 77 if (this.showVersions == null || this.showVersions.equals("")) 78 { 79 this.showVersions = (String )getRequest().getSession().getAttribute("htmlTreeShowVersions"); 80 } 81 else 82 { 83 getRequest().getSession().setAttribute("htmlTreeShowVersions", this.showVersions); 84 } 85 86 97 98 INodeSupplier sup = null; 99 if (this.showVersions != null && this.showVersions.equalsIgnoreCase("yes")) 100 { 101 sup = new ContentNodeVersionSupplier(getRepositoryId(), this.getInfoGluePrincipal().getName()); 102 } 103 else 104 { 105 ContentNodeSupplier contentNodeSupplier = new ContentNodeSupplier(getRepositoryId(), this.getInfoGluePrincipal()); 106 contentNodeSupplier.setShowLeafs(showLeafs.compareTo("yes")==0); 107 contentNodeSupplier.setAllowedContentTypeIds(allowedContentTypeIds); 108 sup = contentNodeSupplier; 109 } 110 111 String treeMode = CmsPropertyHandler.getTreeMode(); 112 if(treeMode != null) setTreeMode(treeMode); 113 114 115 rootNode = sup.getRootNode(); 116 return sup; 117 } 118 119 public List getAvailableLanguages() throws Exception 120 { 121 return RepositoryLanguageController.getController().getRepositoryLanguageVOListWithRepositoryId(this.repositoryId); 122 } 123 124 public List getContentTypeDefinitions() throws Exception 125 { 126 return ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(); 127 } 128 129 133 public Integer getRepositoryId() 134 { 135 if(this.repositoryId == null) 136 { 137 try 138 { 139 List repositoryVOList = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false); 140 if(repositoryVOList != null && repositoryVOList.size() > 0) 141 { 142 this.repositoryId = ((RepositoryVO)repositoryVOList.get(0)).getId(); 143 } 144 } 145 catch(Exception e) 146 { 147 logger.error("Could not fetch the master repository for the principal:" + e.getMessage(), e); 148 } 149 } 150 151 return repositoryId; 152 } 153 154 158 public void setRepositoryId(Integer repositoryId) 159 { 160 this.repositoryId = repositoryId; 161 } 162 163 167 public String getShowVersions() 168 { 169 return showVersions; 170 } 171 172 176 public void setShowVersions(String showVersions) 177 { 178 this.showVersions = showVersions; 179 } 180 181 185 public String getShowLeafs() 186 { 187 return showLeafs; 188 } 189 190 194 public void setShowLeafs(String showLeafs) 195 { 196 this.showLeafs = showLeafs; 197 } 198 199 203 public Integer getSelect() 204 { 205 return select; 206 } 207 208 212 public void setSelect(Integer select) 213 { 214 this.select = select; 215 } 216 217 public BaseNode getRootNode() 218 { 219 return rootNode; 220 } 221 222 public void setRootNode(BaseNode rootNode) 223 { 224 this.rootNode = rootNode; 225 } 226 227 public String getTreeMode() 228 { 229 return treeMode; 230 } 231 232 public void setTreeMode(String treeMode) 233 { 234 this.treeMode = treeMode; 235 } 236 237 public String [] getAllowedContentTypeIds() 238 { 239 return allowedContentTypeIds; 240 } 241 242 public void setAllowedContentTypeIds(String [] allowedContentTypeIds) 243 { 244 this.allowedContentTypeIds = allowedContentTypeIds; 245 } 246 247 public String getAllowedContentTypeIdsAsUrlEncodedString() throws Exception 248 { 249 StringBuffer sb = new StringBuffer (); 250 251 for(int i=0; i<allowedContentTypeIds.length; i++) 252 { 253 if(i > 0) 254 sb.append("&"); 255 256 sb.append("allowedContentTypeIds=" + URLEncoder.encode(allowedContentTypeIds[i], "UTF-8")); 257 } 258 259 return sb.toString(); 260 } 261 262 public String getBodyClass() 263 { 264 return bodyClass; 265 } 266 267 public void setBodyClass(String bodyClass) 268 { 269 this.bodyClass = bodyClass; 270 } 271 } 272 | Popular Tags |