1 7 8 package org.jboss.portal.core.theme.impl; 9 10 import org.apache.log4j.Logger; 11 import org.jboss.portal.common.MediaType; 12 import org.jboss.portal.server.ServerRegistrationID; 13 import org.jboss.portal.server.deployment.PortalWebApp; 14 import org.jboss.portal.server.metadata.LayoutRegistrationMetaData; 15 import org.jboss.portal.server.theme.PortalLayout; 16 import org.jboss.portal.server.theme.PortalRenderSet; 17 import org.jboss.portal.server.theme.strategy.LayoutStrategy; 18 19 import javax.servlet.ServletContext ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 32 public class PortalLayoutImpl extends LayoutRegistrationMetaData 33 implements PortalLayout 34 { 35 private final String name; 36 private final String uri; 37 private final String appName; 38 private final Map stateURIs; 39 private final List renderSets; 41 private final Map strategies; 42 private final PortalWebApp pwa; 43 private static Logger log = Logger.getLogger(PortalLayoutImpl.class); 44 45 61 public PortalLayoutImpl(ServerRegistrationID id, PortalWebApp pwa, String appName, String name, 62 String uri, Map stateURIs, List renderSets, Map strategies) 63 { 64 super(id); 65 66 if (appName == null || "".equals(appName)) 67 { 68 throw new IllegalArgumentException ("appName cannot be null"); 69 } 70 if (name == null || "".equals(name)) 71 { 72 throw new IllegalArgumentException ("name cannot be null"); 73 } 74 if (pwa == null) 75 { 76 throw new IllegalArgumentException ("Portal WebApp cannot be null"); 77 } 78 if (uri == null || "".equals(uri)) 79 { 80 throw new IllegalArgumentException ("uri cannot be null"); 81 } 82 if (renderSets == null) 83 { 84 throw new IllegalArgumentException ("render set list cannot be null"); 85 } 86 if (strategies == null) 87 { 88 throw new IllegalArgumentException ("strategies map cannot be null"); 89 } 90 91 log.debug("creating new layout " + name + " + in " + appName); 92 this.pwa = pwa; 93 this.renderSets = renderSets; 94 this.name = name; 95 this.uri = uri; 96 this.appName = appName; 97 this.stateURIs = stateURIs; 98 this.strategies = strategies; 99 } 100 101 106 public String getAppName() 107 { 108 return appName; 109 } 110 111 116 public String getName() 117 { 118 return this.name; 119 } 120 121 126 public ServletContext getServletContext() 127 { 128 return pwa.getServletContext(); 129 } 130 131 140 public String getURI() 141 { 142 return uri; 143 } 144 145 155 public String getURI(String state) 156 { 157 if (state == null) 158 { 159 return getURI(); 160 } 161 if (stateURIs != null) 162 { 163 return (String )stateURIs.get(state); 164 } 165 return null; 166 } 167 168 173 public String getContextPath() 174 { 175 return pwa.getContextPath(); 176 } 177 178 187 public PortalRenderSet getRenderSet(MediaType mediaType) 188 { 189 for (Iterator i = renderSets.iterator(); i.hasNext();) 190 { 191 PortalRenderSet renderSet = (PortalRenderSet)i.next(); 192 if (renderSet.getMediaType().equals(mediaType)) 193 { 194 return renderSet; 195 } 196 } 197 return null; 198 } 199 200 205 public ClassLoader getLoader() 206 { 207 return pwa.getClassLoader(); 208 } 209 210 218 public LayoutStrategy getStrategy(MediaType mediaType) 219 { 220 return (LayoutStrategy)strategies.get(mediaType); 221 } 222 } 223 | Popular Tags |