1 package org.jahia.data.beans; 2 3 import java.util.ArrayList ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 import java.util.SortedSet ; 7 import java.util.Vector ; 8 9 import org.jahia.data.containers.JahiaContainerList; 10 import org.jahia.data.fields.LoadFlags; 11 import org.jahia.exceptions.JahiaException; 12 import org.jahia.params.ParamBean; 13 import org.jahia.registries.ServicesRegistry; 14 import org.jahia.services.acl.JahiaBaseACL; 15 import org.jahia.services.containers.ContainerFactory; 16 import org.jahia.services.pages.ContentPage; 17 import org.jahia.services.pages.JahiaPage; 18 import org.jahia.services.sites.JahiaSite; 19 20 28 29 public class SiteBean { 30 31 private static org.apache.log4j.Logger logger = 32 org.apache.log4j.Logger.getLogger(SiteBean.class); 33 34 private JahiaSite jahiaSite; 35 private ParamBean paramBean; 36 37 public SiteBean() { 38 } 39 40 public SiteBean(JahiaSite jahiaSite, ParamBean paramBean) { 41 this.jahiaSite = jahiaSite; 42 this.paramBean = paramBean; 43 } 44 45 public JahiaSite getJahiaSite() { 46 return jahiaSite; 47 } 48 49 public PageBean getPage(int pageID) { 50 try { 51 ContentPage contentPage = ContentPage.getPage(pageID); 52 JahiaPage jahiaPage = contentPage.getPage(paramBean.getEntryLoadRequest(), paramBean.getOperationMode(), paramBean.getUser()); 53 PageBean pageBean = new PageBean(jahiaPage, paramBean); 54 return pageBean; 55 } catch (JahiaException je) { 56 logger.error("Error while retrieving page " + pageID + " for site + " + getId() + " : ", je); 57 return null; 58 } 59 } 60 61 public PageBean getPageByStringID(String pageIDStr) { 62 return getPage(Integer.parseInt(pageIDStr)); 63 } 64 65 76 public List getLightContainerLists(String name) { 77 List containerLists = new ArrayList (); 78 try { 79 SortedSet containerListIDs = ServicesRegistry.getInstance(). 80 getJahiaContainersService(). 81 getSiteTopLevelContainerListsIDsByName( 82 getId(), name, paramBean.getEntryLoadRequest()); 83 ContainerFactory containerFactory = ContainerFactory.getInstance(); 84 Iterator containerListIDIter = containerListIDs.iterator(); 85 while (containerListIDIter.hasNext()) { 86 Integer curContainerListID = (Integer ) containerListIDIter.next(); 87 JahiaContainerList curContainerList = ServicesRegistry 88 .getInstance() 89 .getJahiaContainersService() 90 .loadContainerList ( 91 curContainerListID.intValue(), 92 LoadFlags.ALL, 93 paramBean, 94 paramBean.getEntryLoadRequest(), 95 null, 96 null, null); 97 98 ContainerListBean containerListBean = new ContainerListBean(curContainerList, paramBean); 99 containerLists.add(containerListBean); 100 } 101 return containerLists; 102 } catch (JahiaException je) { 103 logger.error("Error while retrieving site top level container lists with name " + name + ":", je); 104 return null; 105 } 106 } 107 108 public List getAllContainerLists(String name) { 109 List containerLists = new ArrayList (); 110 try { 111 SortedSet containerListIDs = ServicesRegistry.getInstance(). 112 getJahiaContainersService(). 113 getSiteTopLevelContainerListsIDsByName( 114 getId(), name, paramBean.getEntryLoadRequest()); 115 Iterator containerListIDIter = containerListIDs.iterator(); 116 while (containerListIDIter.hasNext()) { 117 Integer curContainerListID = (Integer ) containerListIDIter.next(); 118 JahiaContainerList curContainerList = ServicesRegistry.getInstance().getJahiaContainersService() 119 .loadContainerList(curContainerListID.intValue(), LoadFlags.ALL, paramBean, 120 paramBean.getEntryLoadRequest(), null, null, null); 121 ContainerListBean containerListBean = new ContainerListBean(curContainerList, paramBean); 122 containerLists.add(containerListBean); 123 } 124 return containerLists; 125 } catch (JahiaException je) { 126 logger.error("Error while retrieving site top level container lists with name " + name + ":", je); 127 return null; 128 } 129 } 130 131 public int getId() { 132 return jahiaSite.getID(); 133 } 134 135 public JahiaBaseACL getACL() { 136 return jahiaSite.getACL(); 137 } 138 139 public int getAclID() { 140 return jahiaSite.getAclID(); 141 } 142 143 public int getDefaultTemplateID() { 144 return jahiaSite.getDefaultTemplateID(); 145 } 146 147 public String getDescription() { 148 return jahiaSite.getDescr(); 149 } 150 151 public int getGroupDefaultHomepageDef() { 152 return jahiaSite.getGroupDefaultHomepageDef(); 153 } 154 155 public int getGroupDefaultHomepageDefActiveState() { 156 return jahiaSite.getGroupDefaultHomepageDefActiveState(); 157 } 158 159 public int getGroupDefaultHomepageDefAtCreationOnly() { 160 return jahiaSite.getGroupDefaultHomepageDefAtCreationOnly(); 161 } 162 163 public ContentPage getHomeContentPage() { 164 return jahiaSite.getHomeContentPage(); 165 } 166 167 public PageBean getHomePage() { 168 try { 169 JahiaPage homeJahiaPage = getHomeContentPage().getPage(paramBean. 170 getEntryLoadRequest(), paramBean.getOperationMode(), 171 paramBean.getUser()); 172 if (homeJahiaPage != null) { 173 return new PageBean(homeJahiaPage, paramBean); 174 } else { 175 return null; 176 } 177 } catch (JahiaException je) { 178 logger.error("Error while retrieving site home page :", je); 179 return null; 180 } 181 } 182 183 public int getHomepageID() { 184 return jahiaSite.getHomePageID(); 185 } 186 187 public Vector getLanguageMappings() { 188 try { 189 return jahiaSite.getLanguageMappings(); 190 } catch (JahiaException je) { 191 logger.error("Error while retrieving language mappings for site " + getId() + ":", je); 192 return null; 193 } 194 } 195 196 public Vector getLanguageSettings() { 197 try { 198 return jahiaSite.getLanguageSettings(); 199 } catch (JahiaException je) { 200 logger.error("Error while retrieving language settings for site " + getId() + ":", je); 201 return null; 202 } 203 } 204 205 public String getServerName() { 206 return jahiaSite.getServerName(); 207 } 208 209 public String getSiteKey() { 210 return jahiaSite.getSiteKey(); 211 } 212 213 public String getTemplateFolder() { 214 return jahiaSite.getTemplateFolder(); 215 } 216 217 public boolean isTemplatesAutoDeployMode() { 218 return jahiaSite.getTemplatesAutoDeployMode(); 219 } 220 221 public String getTitle() { 222 return jahiaSite.getTitle(); 223 } 224 225 public int getUserDefaultHomepageDef() { 226 return jahiaSite.getUserDefaultHomepageDef(); 227 } 228 229 public int getUserDefaultHomepageDefActiveState() { 230 return jahiaSite.getUserDefaultHomepageDefActiveState(); 231 } 232 233 public int getUserDefaultHomepageDefAtCreationOnly() { 234 return jahiaSite.getUserDefaultHomepageDefAtCreationOnly(); 235 } 236 237 public boolean isWebAppsAutoDeployMode() { 238 return jahiaSite.getWebAppsAutoDeployMode(); 239 } 240 241 public boolean isActive() { 242 return jahiaSite.isActive(); 243 } 244 245 public boolean isMixLanguagesActive() { 246 return jahiaSite.isMixLanguagesActive(); 247 } 248 249 public boolean isStagingEnabled() { 250 return jahiaSite.isStagingEnabled(); 251 } 252 253 public boolean isVersioningEnabled() { 254 return jahiaSite.isVersioningEnabled(); 255 } 256 } 257 | Popular Tags |