1 9 package org.jboss.portal.core.impl.invocation; 10 11 import java.util.Map ; 12 13 import javax.servlet.http.HttpServletRequest ; 14 import javax.servlet.http.HttpServletResponse ; 15 16 import org.jboss.portal.core.CorePortal; 17 import org.jboss.portal.core.CoreConstants; 18 import org.jboss.portal.core.invocation.CoreAttachmentKey; 19 import org.jboss.portal.core.plugins.page.Page; 20 import org.jboss.portal.core.plugins.page.PageRepository; 21 import org.jboss.portal.server.Portal; 22 import org.jboss.portal.server.PortalServer; 23 import org.jboss.portal.server.ServerObject; 24 import org.jboss.portal.server.ServerURL; 25 import org.jboss.portal.server.Window; 26 import org.jboss.portal.server.WindowURL; 27 import org.jboss.portal.server.impl.invocation.InvocationImpl; 28 import org.jboss.portal.server.util.Parameters; 29 30 34 public class CoreInvocation 35 extends InvocationImpl 36 implements MappingContext 37 { 38 39 public CoreInvocation( 40 PortalServer container, 41 HttpServletRequest req, 42 HttpServletResponse resp, 43 int nonSecurePort, 44 int securePort) 45 { 46 super(container, req, resp, nonSecurePort, securePort); 47 } 48 49 50 protected void decodeTarget() 51 { 52 super.decodeTarget(); 54 55 String portalPathInfo = null; 57 58 if (target != null) 60 { 61 portalPathInfo = null; 62 } 63 else 64 { 65 String pathInfo = req.getPathInfo(); 67 68 MappingResult result = new SimpleMapper().map(this, pathInfo); 70 71 target = (ServerObject)result.getTarget(); 73 portalPathInfo = result.getTargetPathInfo(); 74 } 75 76 if (target == null || target instanceof Portal) 78 { 79 CorePortal cp = null; 80 if (target == null) 81 { 82 cp = (CorePortal)container.getDefaultPortal(); 83 } 84 else 85 { 86 cp = (CorePortal)target; 87 } 88 89 Map props = cp.getProperties(); 91 String defaultWindowName = (String )props.get("org.jboss.portal.property.action"); 92 if (defaultWindowName != null) 93 { 94 target = cp.getWindow(defaultWindowName); 95 if (target != null) 96 { 97 WindowURL url = (WindowURL)target.createURL(); 99 url.setType(WindowURL.TYPE_ACTION); 100 url.setTargetParameter(CoreConstants.REQ_ACTION_PARAM_PATH, portalPathInfo); 101 targetParameters = url.getTargetParameters(); 102 controlParameters = url.getControlParameters(); 103 } 104 else 105 { 106 log.warn("Cannot find default window " + defaultWindowName + " in portal " + cp.getName()); 107 } 108 } 109 } 110 111 Page page = null; 113 if (target instanceof Window) 114 { 115 CorePortal portal = (CorePortal)((Window)target).getPortal(); 116 PageRepository repository = portal.getPageRepository(); 117 page = repository.getPageByWindow(target.getID()); 118 } 119 else if (target instanceof Portal) 120 { 121 PageRepository repository = ((CorePortal)target).getPageRepository(); 122 page = repository.getDefaultPage(); 123 } 124 else if (target instanceof Page) 125 { 126 page = (Page)target; 127 } 128 else 129 { 130 CorePortal portal = (CorePortal)container.getDefaultPortal(); 132 PageRepository repository = portal.getPageRepository(); 133 page = repository.getDefaultPage(); 134 } 135 136 if (target != null) 138 { 139 Map controlMap = controlParameters.getParameterMap(); 141 Map targetMap = targetParameters.getParameterMap(); 142 boolean secure = req.isSecure(); 143 144 ServerURL tmp = target.createURL(); 146 Parameters urlControlMap = tmp.getControlParameters(); 147 Parameters urlTargetMap = tmp.getTargetParameters(); 148 149 urlControlMap.setParameterMap(controlMap); 151 urlTargetMap.setParameterMap(targetMap); 152 tmp.setSecure(Boolean.valueOf(secure)); 153 this.url = tmp; 154 } 155 156 if (page != null) 158 { 159 setAttachment(CoreAttachmentKey.PAGE, page); 160 req.setAttribute(CoreConstants.REQ_ATT_SERVLET_PATH, req.getServletPath()); 161 req.setAttribute(CoreConstants.REQ_ATT_CONTEXT_PATH, req.getContextPath()); 162 } 163 else 164 { 165 throw new IllegalStateException ("No page found"); 167 } 168 } 169 170 172 public Object getRoot() 173 { 174 return container; 175 } 176 177 public Object getChild(Object parent, String name) 178 { 179 if (parent == container) 180 { 181 CorePortal portal = (CorePortal)container.getPortal(name); 182 if (portal != null) 183 { 184 return portal; 185 } 186 portal = (CorePortal)container.getDefaultPortal(); 187 Page page = portal.getPageRepository().getPageByName(name); 188 return page; 189 } 190 else if (parent instanceof Portal) 191 { 192 CorePortal portal = (CorePortal)parent; 193 Page page = portal.getPageRepository().getPageByName(name); 194 return page; 195 } 196 else 197 { 198 return null; 199 } 200 } 201 } 202 | Popular Tags |