Shortest path to tests running with Spring Framework 5
Upgrade to Java 8+ Remove Portlet, Tiles2, and Hibernate 3 + 4 support Issue: SWF-1692
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.faces.webflow.context.portlet.JsfResourceRequestHandler;
|
||||
|
||||
/**
|
||||
* Extends {@link AbstractFacesFlowConfiguration} and registers a
|
||||
* {@link JsfResourceRequestHandler} bean for serving resources in a Portlet environment.
|
||||
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 2.4
|
||||
*/
|
||||
public class AbstractFacesPortletFlowConfiguration extends AbstractFacesFlowConfiguration {
|
||||
|
||||
@Bean
|
||||
public JsfResourceRequestHandler jsfPortletResourceRequestHandler() {
|
||||
return new JsfResourceRequestHandler();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.faces.webflow.application.portlet;
|
||||
|
||||
import javax.faces.application.ViewHandler;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.faces.webflow.context.portlet.PortletViewHandler;
|
||||
|
||||
/**
|
||||
* {@link ViewHandler} implementation for Portlets. This class is provided for compatibility with Web Flow v2.2.0, users
|
||||
* should replace references in their <tt>faces-confix.xml</tt> with
|
||||
* {@link org.springframework.faces.webflow.context.portlet.PortletViewHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
* @deprecated In favor of org.springframework.faces.webflow.context.portlet.PortletViewHandler
|
||||
*/
|
||||
@Deprecated
|
||||
public class PortletFaceletViewHandler extends PortletViewHandler {
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public PortletFaceletViewHandler(ViewHandler wrapped) {
|
||||
super(wrapped);
|
||||
this.logger.warn("*****");
|
||||
this.logger.warn("***** PLEASE UPDATE YOUR faces-confix.xml");
|
||||
this.logger.warn("*****");
|
||||
this.logger.warn("***** org.springframework.faces.webflow.application.portlet.PortletFaceletViewHandler has been deprecated");
|
||||
this.logger.warn("***** please update references to use org.springframework.faces.webflow.context.portlet.PortletViewHandler");
|
||||
this.logger.warn("*****");
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
|
||||
import org.springframework.binding.collection.StringKeyedMapAdapter;
|
||||
import org.springframework.webflow.core.collection.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Map backed by a PortletContext for accessing Portlet initialization parameters.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class InitParameterMap extends StringKeyedMapAdapter<String> {
|
||||
|
||||
final private PortletContext portletContext;
|
||||
|
||||
public InitParameterMap(PortletContext portletContext) {
|
||||
this.portletContext = portletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAttribute(String key) {
|
||||
return this.portletContext.getInitParameter(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAttribute(String key, String value) {
|
||||
throw new UnsupportedOperationException("Cannot set PortletContext InitParameter");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String key) {
|
||||
throw new UnsupportedOperationException("Cannot remove PortletContext InitParameter");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return CollectionUtils.toIterator(this.portletContext.getInitParameterNames());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.Resource;
|
||||
import javax.faces.application.ResourceHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.EventRequest;
|
||||
import javax.portlet.EventResponse;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.portlet.ResourceRequest;
|
||||
import javax.portlet.ResourceResponse;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.faces.webflow.FacesContextHelper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.portlet.HandlerAdapter;
|
||||
import org.springframework.web.portlet.HandlerExecutionChain;
|
||||
import org.springframework.web.portlet.HandlerMapping;
|
||||
import org.springframework.web.portlet.ModelAndView;
|
||||
import org.springframework.web.portlet.handler.PortletContentGenerator;
|
||||
|
||||
/**
|
||||
* Handles a request by delegating to the JSF ResourceHandler, which serves web application and classpath resources such
|
||||
* as images, CSS and JavaScript files from well-known locations.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @author Phillip Webb
|
||||
* @see ResourceHandler
|
||||
*/
|
||||
public class JsfResourceRequestHandler extends PortletContentGenerator implements HandlerAdapter, HandlerMapping, Ordered {
|
||||
|
||||
private static final String FACES_RESOURCE = "javax.faces.resource";
|
||||
|
||||
private static final String RESOURCE_EXCLUDES_DEFAULT = ".class .jsp .jspx .properties .xhtml .groovy";
|
||||
|
||||
private static final String RESOURCE_EXCLUDES_PARAM_NAME = "javax.faces.RESOURCE_EXCLUDES";
|
||||
|
||||
private int order = Ordered.HIGHEST_PRECEDENCE;
|
||||
|
||||
public HandlerExecutionChain getHandler(PortletRequest request) throws Exception {
|
||||
if (request instanceof ResourceRequest && request.getParameter(FACES_RESOURCE) != null) {
|
||||
return new HandlerExecutionChain(new JsfResourceRequest());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean supports(Object handler) {
|
||||
return handler instanceof JsfResourceRequest;
|
||||
}
|
||||
|
||||
public ModelAndView handleResource(ResourceRequest request, ResourceResponse response, Object handler) throws IOException {
|
||||
FacesContextHelper helper = new FacesContextHelper();
|
||||
try {
|
||||
FacesContext facesContext = helper.getFacesContext(getPortletContext(), request, response);
|
||||
handleResourceRequest(facesContext, request, response);
|
||||
} finally {
|
||||
helper.releaseIfNecessary();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleResourceRequest(FacesContext facesContext, ResourceRequest request, ResourceResponse response) throws IOException {
|
||||
ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
|
||||
String resourceName = request.getParameter(FACES_RESOURCE);
|
||||
String libraryName = request.getParameter("ln");
|
||||
int statusCodeNotFound = HttpStatus.NOT_FOUND.value();
|
||||
if (isResourceExcluded(facesContext, resourceName)) {
|
||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(statusCodeNotFound));
|
||||
PortletResponseUtils.setStatusCodeForPluto(response, statusCodeNotFound);
|
||||
return;
|
||||
}
|
||||
Resource resource = createResource(resourceHandler, resourceName, libraryName);
|
||||
if (resource == null) {
|
||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(statusCodeNotFound));
|
||||
PortletResponseUtils.setStatusCodeForPluto(response, statusCodeNotFound);
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<String, String> entry : resource.getResponseHeaders().entrySet()) {
|
||||
response.setProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
response.setContentType(resource.getContentType());
|
||||
FileCopyUtils.copy(resource.getInputStream(), response.getPortletOutputStream());
|
||||
}
|
||||
|
||||
private boolean isResourceExcluded(FacesContext context, String resourceName) {
|
||||
for (String resourceExclude : getResourceExcludes(context)) {
|
||||
if (StringUtils.endsWithIgnoreCase(resourceName, resourceExclude)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String[] getResourceExcludes(FacesContext context) {
|
||||
String resourceExcludes = context.getExternalContext().getInitParameter(RESOURCE_EXCLUDES_PARAM_NAME);
|
||||
if (resourceExcludes == null) {
|
||||
resourceExcludes = RESOURCE_EXCLUDES_DEFAULT;
|
||||
}
|
||||
return StringUtils.tokenizeToStringArray(resourceExcludes, " ");
|
||||
}
|
||||
|
||||
private Resource createResource(ResourceHandler resourceHandler, String resourceName, String libraryName) {
|
||||
if (libraryName != null) {
|
||||
return resourceHandler.createResource(resourceName, libraryName);
|
||||
}
|
||||
return resourceHandler.createResource(resourceName);
|
||||
}
|
||||
|
||||
public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception {
|
||||
}
|
||||
|
||||
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(EventRequest request, EventResponse response, Object handler) throws Exception {
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
private static class JsfResourceRequest {
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request parameters as a String array.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getParameterValues(String)
|
||||
*/
|
||||
public class MultiValueRequestParameterMap extends RequestParameterMap<String[]> {
|
||||
|
||||
public MultiValueRequestParameterMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String[] getAttribute(String key) {
|
||||
return getPortletRequest().getParameterValues(key);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request properties as a String array.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getProperties(String)
|
||||
*/
|
||||
public class MultiValueRequestPropertyMap extends RequestPropertyMap<String[]> {
|
||||
|
||||
public MultiValueRequestPropertyMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String[] getAttribute(String key) {
|
||||
List<String> list = Collections.list(getPortletRequest().getProperties(key));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
}
|
||||
@@ -1,599 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.Principal;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.Flash;
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.ClientDataRequest;
|
||||
import javax.portlet.MimeResponse;
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.PortletResponse;
|
||||
import javax.portlet.PortletSession;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.portlet.ResourceResponse;
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import org.apache.myfaces.shared.context.flash.FlashImpl;
|
||||
import org.springframework.binding.collection.MapAdaptable;
|
||||
import org.springframework.faces.webflow.JsfRuntimeInformation;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import org.springframework.webflow.context.portlet.PortletContextMap;
|
||||
import org.springframework.webflow.context.portlet.PortletRequestMap;
|
||||
import org.springframework.webflow.context.portlet.PortletSessionMap;
|
||||
import org.springframework.webflow.core.collection.CollectionUtils;
|
||||
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
||||
|
||||
import com.sun.faces.context.flash.ELFlash;
|
||||
|
||||
/**
|
||||
* An implementation of {@link ExternalContext} for use with Portlet requests.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class PortletExternalContextImpl extends ExternalContext {
|
||||
|
||||
private Map<String, Object> applicationMap;
|
||||
|
||||
private PortletContext portletContext;
|
||||
|
||||
private PortletRequest request;
|
||||
|
||||
private PortletResponse response;
|
||||
|
||||
private boolean isActionRequest;
|
||||
|
||||
private Map<String, String> initParameterMap;
|
||||
|
||||
private Map<String, String> requestHeaderMap;
|
||||
|
||||
private Map<String, String[]> requestHeaderValuesMap;
|
||||
|
||||
private Map<String, Object> requestMap;
|
||||
|
||||
private Map<String, String> requestParameterMap;
|
||||
|
||||
private Map<String, String[]> requestParameterValuesMap;
|
||||
|
||||
private MapAdaptable<String, Object> sessionMap;
|
||||
|
||||
private Flash flash;
|
||||
|
||||
public PortletExternalContextImpl(PortletContext portletContext, PortletRequest portletRequest,
|
||||
PortletResponse portletResponse) {
|
||||
this.portletContext = portletContext;
|
||||
this.request = portletRequest;
|
||||
this.response = portletResponse;
|
||||
if (portletRequest instanceof ActionRequest) {
|
||||
this.isActionRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
portletContext = null;
|
||||
request = null;
|
||||
response = null;
|
||||
applicationMap = null;
|
||||
sessionMap = null;
|
||||
requestMap = null;
|
||||
requestParameterMap = null;
|
||||
requestParameterValuesMap = null;
|
||||
requestHeaderMap = null;
|
||||
requestHeaderValuesMap = null;
|
||||
initParameterMap = null;
|
||||
}
|
||||
|
||||
public Flash getFlash() {
|
||||
if(this.flash == null) {
|
||||
this.flash = createFlash();
|
||||
}
|
||||
return this.flash;
|
||||
}
|
||||
|
||||
private Flash createFlash() {
|
||||
if (JsfRuntimeInformation.isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
|
||||
return new MojarraFlashFactory().newFlash(this);
|
||||
}
|
||||
else {
|
||||
return new MyFacesFlashFactory().newFlash(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatch(String path) throws IOException {
|
||||
Assert.isTrue(!isActionRequest);
|
||||
PortletRequestDispatcher requestDispatcher = portletContext.getRequestDispatcher(path);
|
||||
try {
|
||||
requestDispatcher.include((RenderRequest) request, (RenderResponse) response);
|
||||
} catch (PortletException exception) {
|
||||
if (exception.getMessage() != null) {
|
||||
throw new FacesException(exception.getMessage(), exception);
|
||||
}
|
||||
throw new FacesException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redirect(String url) throws IOException {
|
||||
Assert.isInstanceOf(ActionResponse.class, response);
|
||||
((ActionResponse) response).sendRedirect(url);
|
||||
}
|
||||
|
||||
public String encodeNamespace(String name) {
|
||||
Assert.isTrue(!isActionRequest);
|
||||
return name + ((RenderResponse) response).getNamespace();
|
||||
}
|
||||
|
||||
public String encodeActionURL(String url) {
|
||||
Assert.notNull(url);
|
||||
return response.encodeURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeResourceURL(String url) {
|
||||
Assert.notNull(url);
|
||||
return response.encodeURL(url);
|
||||
}
|
||||
|
||||
public String encodePartialActionURL(String url) {
|
||||
Assert.notNull(url);
|
||||
return response.encodeURL(url);
|
||||
}
|
||||
|
||||
public String encodeBookmarkableURL(String baseUrl, Map<String, List<String>> parameters) {
|
||||
return encodeUrl(baseUrl, parameters);
|
||||
}
|
||||
|
||||
public String encodeRedirectURL(String baseUrl, Map<String, List<String>> parameters) {
|
||||
return response.encodeURL(encodeUrl(baseUrl, parameters));
|
||||
}
|
||||
|
||||
private String encodeUrl(String baseUrl, Map<String, List<String>> parameters) {
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUrl);
|
||||
for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
|
||||
builder.queryParam(entry.getKey(), entry.getValue().toArray());
|
||||
}
|
||||
return builder.buildAndExpand().toUriString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return portletContext;
|
||||
}
|
||||
|
||||
public String getContextName() {
|
||||
return portletContext.getPortletContextName();
|
||||
}
|
||||
|
||||
public String getMimeType(String file) {
|
||||
return portletContext.getMimeType(file);
|
||||
}
|
||||
|
||||
public String getRealPath(String path) {
|
||||
return portletContext.getRealPath(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
Assert.notNull(message);
|
||||
portletContext.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message, Throwable exception) {
|
||||
Assert.notNull(message);
|
||||
Assert.notNull(exception);
|
||||
portletContext.log(message, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
if (applicationMap == null) {
|
||||
applicationMap = new PortletContextMap(portletContext);
|
||||
}
|
||||
return applicationMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
return portletContext.getInitParameter(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getInitParameterMap() {
|
||||
if (initParameterMap == null) {
|
||||
initParameterMap = new InitParameterMap(portletContext);
|
||||
}
|
||||
return initParameterMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
Assert.notNull(path);
|
||||
return portletContext.getResource(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
Assert.notNull(path);
|
||||
return portletContext.getResourceAsStream(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
Assert.notNull(path);
|
||||
return portletContext.getResourcePaths(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequest(Object request) {
|
||||
this.request = (PortletRequest) request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestContentType() {
|
||||
if (request instanceof ClientDataRequest) {
|
||||
ClientDataRequest clientDataRequest = (ClientDataRequest) request;
|
||||
return clientDataRequest.getContentType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestContextPath() {
|
||||
return request.getContextPath();
|
||||
}
|
||||
|
||||
public String getRequestScheme() {
|
||||
return request.getScheme();
|
||||
}
|
||||
|
||||
public String getRequestServerName() {
|
||||
return request.getServerName();
|
||||
}
|
||||
|
||||
public int getRequestServerPort() {
|
||||
return request.getServerPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getRequestLocale() {
|
||||
return request.getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Locale> getRequestLocales() {
|
||||
return CollectionUtils.toIterator(request.getLocales());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestCharacterEncoding() {
|
||||
if (request instanceof ClientDataRequest) {
|
||||
return ((ClientDataRequest) request).getCharacterEncoding();
|
||||
}
|
||||
else {
|
||||
Assert.state(response instanceof MimeResponse);
|
||||
return ((MimeResponse) response).getCharacterEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequestCharacterEncoding(String encoding) throws java.io.UnsupportedEncodingException {
|
||||
Assert.isInstanceOf(ClientDataRequest.class, request);
|
||||
((ClientDataRequest) request).setCharacterEncoding(encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRequestCookieMap() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getRequestHeaderMap() {
|
||||
if (requestHeaderMap == null) {
|
||||
requestHeaderMap = new SingleValueRequestPropertyMap(request);
|
||||
}
|
||||
return requestHeaderMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getRequestHeaderValuesMap() {
|
||||
if (requestHeaderValuesMap == null) {
|
||||
requestHeaderValuesMap = new MultiValueRequestPropertyMap(request);
|
||||
}
|
||||
return requestHeaderValuesMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRequestMap() {
|
||||
if (requestMap == null) {
|
||||
requestMap = new PortletRequestMap(request);
|
||||
}
|
||||
return requestMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getRequestParameterMap() {
|
||||
if (requestParameterMap == null) {
|
||||
requestParameterMap = new SingleValueRequestParameterMap(request);
|
||||
}
|
||||
return requestParameterMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getRequestParameterNames() {
|
||||
return CollectionUtils.toIterator(request.getParameterNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getRequestParameterValuesMap() {
|
||||
if (requestParameterValuesMap == null) {
|
||||
requestParameterValuesMap = new MultiValueRequestParameterMap(request);
|
||||
}
|
||||
return requestParameterValuesMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestServletPath() {
|
||||
// Return "" instead of null in order to prevent NullPointerException in Apache MyFaces 1.2 when it tries to
|
||||
// determine the servlet mappings in DefaultViewHandlerSupport.calculateFacesServletMapping(..).
|
||||
// Note that the FacesServlet mapping in Web Flow is not relevant so this should be ok.
|
||||
//
|
||||
// Alternatively this method could be implemented to provide an actual servlet path derived from the
|
||||
// viewId when that becomes available during rendering as the MyFaces Portlet Bridge does.
|
||||
//
|
||||
// return JsfRuntimeInformation.isMyFacesPresent() ? "" : null;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestPathInfo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getRequestContentLength() {
|
||||
Assert.isInstanceOf(ClientDataRequest.class, request);
|
||||
return ((ClientDataRequest) request).getContentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return request.getAuthType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return request.getRemoteUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return request.getUserPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
Assert.notNull(role);
|
||||
return request.isUserInRole(role);
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return request.isSecure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponse(Object response) {
|
||||
this.response = (PortletResponse) response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResponseContentType() {
|
||||
return getMimeResponse().getContentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResponseCharacterEncoding() {
|
||||
return getMimeResponse().getCharacterEncoding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponseCharacterEncoding(String encoding) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public OutputStream getResponseOutputStream() throws IOException {
|
||||
return getMimeResponse().getPortletOutputStream();
|
||||
}
|
||||
|
||||
public Writer getResponseOutputWriter() throws IOException {
|
||||
return getMimeResponse().getWriter();
|
||||
}
|
||||
|
||||
public void addResponseCookie(String name, String value, Map<String, Object> properties) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
setCookieProperties(cookie, properties);
|
||||
response.addProperty(cookie);
|
||||
}
|
||||
|
||||
private void setCookieProperties(Cookie cookie, Map<String, Object> properties) {
|
||||
if (properties != null) {
|
||||
for (Map.Entry<String, Object> entry : properties.entrySet()) {
|
||||
setCookieProperty(cookie, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setCookieProperty(Cookie cookie, String property, Object value) {
|
||||
if ("domain".equalsIgnoreCase(property)) {
|
||||
cookie.setDomain((String) value);
|
||||
return;
|
||||
}
|
||||
if ("maxAge".equalsIgnoreCase(property)) {
|
||||
cookie.setMaxAge((Integer) value);
|
||||
return;
|
||||
}
|
||||
if ("path".equalsIgnoreCase(property)) {
|
||||
cookie.setPath((String) value);
|
||||
return;
|
||||
}
|
||||
if ("secure".equalsIgnoreCase(property)) {
|
||||
cookie.setSecure((Boolean) value);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Unknown cookie property " + property);
|
||||
}
|
||||
|
||||
public void addResponseHeader(String name, String value) {
|
||||
response.addProperty(name, value);
|
||||
}
|
||||
|
||||
public void responseFlushBuffer() throws IOException {
|
||||
getMimeResponse().flushBuffer();
|
||||
}
|
||||
|
||||
public void responseReset() {
|
||||
MimeResponse mimeResponse = getMimeResponse(false);
|
||||
if (mimeResponse != null) {
|
||||
mimeResponse.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void responseSendError(int statusCode, String message) throws IOException {
|
||||
throw new IOException(statusCode + ": " + message);
|
||||
}
|
||||
|
||||
public void setResponseBufferSize(int size) {
|
||||
getMimeResponse().setBufferSize(size);
|
||||
}
|
||||
|
||||
public void setResponseContentLength(int length) {
|
||||
if (portletContext instanceof ResourceResponse) {
|
||||
((ResourceResponse) portletContext).setContentLength(length);
|
||||
}
|
||||
}
|
||||
|
||||
public void setResponseContentType(String contentType) {
|
||||
MimeResponse mimeResponse = getMimeResponse(false);
|
||||
if (mimeResponse != null) {
|
||||
mimeResponse.setContentType(contentType);
|
||||
}
|
||||
}
|
||||
|
||||
public void setResponseHeader(String name, String value) {
|
||||
response.setProperty(name, value);
|
||||
}
|
||||
|
||||
public void setResponseStatus(int statusCode) {
|
||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(statusCode));
|
||||
PortletResponseUtils.setStatusCodeForPluto(response, statusCode);
|
||||
}
|
||||
|
||||
public boolean isResponseCommitted() {
|
||||
MimeResponse mimeResponse = getMimeResponse(false);
|
||||
return ((mimeResponse != null) ? mimeResponse.isCommitted() : false);
|
||||
}
|
||||
|
||||
public int getResponseBufferSize() {
|
||||
return getMimeResponse().getBufferSize();
|
||||
|
||||
}
|
||||
|
||||
private MimeResponse getMimeResponse() {
|
||||
return getMimeResponse(true);
|
||||
}
|
||||
|
||||
private MimeResponse getMimeResponse(boolean required) {
|
||||
if (response instanceof MimeResponse) {
|
||||
return (MimeResponse) response;
|
||||
}
|
||||
if (!required) {
|
||||
return null;
|
||||
}
|
||||
throw new IllegalStateException("Portlet response is not a MimeResponse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSession(boolean create) {
|
||||
return request.getPortletSession(create);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSessionMap() {
|
||||
if (sessionMap == null) {
|
||||
sessionMap = new LocalAttributeMap<Object>(new PortletSessionMap(request));
|
||||
}
|
||||
return sessionMap.asMap();
|
||||
}
|
||||
|
||||
public int getSessionMaxInactiveInterval() {
|
||||
return request.getPortletSession().getMaxInactiveInterval();
|
||||
}
|
||||
|
||||
public void invalidateSession() {
|
||||
PortletSession portletSession = request.getPortletSession(false);
|
||||
if (portletSession != null) {
|
||||
portletSession.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSessionMaxInactiveInterval(int interval) {
|
||||
request.getPortletSession().setMaxInactiveInterval(interval);
|
||||
}
|
||||
|
||||
private static class MojarraFlashFactory {
|
||||
public Flash newFlash(ExternalContext context) {
|
||||
return (Flash) ELFlash.getFlash();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyFacesFlashFactory {
|
||||
public Flash newFlash(ExternalContext context) {
|
||||
return FlashImpl.getCurrentInstance(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletResponse;
|
||||
|
||||
import org.springframework.faces.webflow.JsfRuntimeInformation;
|
||||
|
||||
/**
|
||||
* {@link FacesContextFactory} to support portlet environments.
|
||||
* @author Phillip Webb
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class PortletFacesContextFactory extends FacesContextFactory {
|
||||
|
||||
private final FacesContextFactory factory;
|
||||
|
||||
public PortletFacesContextFactory(FacesContextFactory factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FacesContextFactory getWrapped() {
|
||||
return this.factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle)
|
||||
throws FacesException {
|
||||
if (JsfRuntimeInformation.isPortletContext(context)) {
|
||||
return new PortletFacesContextImpl((PortletContext) context, (PortletRequest) request,
|
||||
(PortletResponse) response);
|
||||
}
|
||||
return this.factory.getFacesContext(context, request, response, lifecycle);
|
||||
}
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELContextEvent;
|
||||
import javax.el.ELContextListener;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.VariableMapper;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.application.ProjectStage;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.ExceptionHandler;
|
||||
import javax.faces.context.ExceptionHandlerFactory;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.PartialViewContext;
|
||||
import javax.faces.context.PartialViewContextFactory;
|
||||
import javax.faces.context.ResponseStream;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.render.RenderKit;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletResponse;
|
||||
|
||||
import org.springframework.faces.webflow.JsfUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The default FacesContext implementation in Mojarra and in Apache MyFaces depends on the Servlet API. This
|
||||
* implementation provides an alternative that accepts Portlet request and response structures and creates a
|
||||
* {@link PortletExternalContextImpl} in its constructor. The rest of the method implementations mimic the equivalent
|
||||
* methods in the default FacesContext implementation.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class PortletFacesContextImpl extends FacesContext {
|
||||
|
||||
private static final List<FacesMessage> NO_MESSAGES = Collections.unmodifiableList(Collections
|
||||
.<FacesMessage> emptyList());
|
||||
|
||||
private static final Iterator<String> NO_CLIENT_IDS_WITH_MESSAGES = Collections.unmodifiableSet(
|
||||
Collections.<String> emptySet()).iterator();
|
||||
|
||||
private Application application;
|
||||
|
||||
private ELContext elContext;
|
||||
|
||||
private ExternalContext externalContext;
|
||||
|
||||
private List<Message> messages;
|
||||
|
||||
private FacesMessage.Severity maximumSeverity;
|
||||
|
||||
private boolean released = false;
|
||||
|
||||
private RenderKitFactory renderKitFactory;
|
||||
|
||||
private boolean renderResponse = false;
|
||||
|
||||
private boolean responseComplete = false;
|
||||
|
||||
private ResponseStream responseStream;
|
||||
|
||||
private ResponseWriter responseWriter;
|
||||
|
||||
private UIViewRoot viewRoot;
|
||||
|
||||
private Map<Object, Object> attributes;
|
||||
|
||||
private PhaseId currentPhaseId;
|
||||
|
||||
private ExceptionHandler exceptionHandler;
|
||||
|
||||
private boolean validationFailed;
|
||||
|
||||
private PartialViewContext partialViewContext;
|
||||
|
||||
private boolean processingEvents;
|
||||
|
||||
public PortletFacesContextImpl(ExternalContext externalContext) {
|
||||
this.externalContext = externalContext;
|
||||
}
|
||||
|
||||
public PortletFacesContextImpl(PortletContext portletContext, PortletRequest portletRequest,
|
||||
PortletResponse portletResponse) {
|
||||
application = JsfUtils.findFactory(ApplicationFactory.class).getApplication();
|
||||
renderKitFactory = JsfUtils.findFactory(RenderKitFactory.class);
|
||||
this.externalContext = new PortletExternalContextImpl(portletContext, portletRequest, portletResponse);
|
||||
FacesContext.setCurrentInstance(this);
|
||||
// This depends on the current FacesContext instance
|
||||
this.exceptionHandler = JsfUtils.findFactory(ExceptionHandlerFactory.class).getExceptionHandler();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
assertNotReleased();
|
||||
if (externalContext != null) {
|
||||
Method delegateMethod = ClassUtils.getMethodIfAvailable(externalContext.getClass(), "release");
|
||||
if (delegateMethod != null) {
|
||||
try {
|
||||
delegateMethod.invoke(externalContext);
|
||||
} catch (Exception e) {
|
||||
externalContext.log("Failed to release external context", e);
|
||||
}
|
||||
externalContext = null;
|
||||
}
|
||||
}
|
||||
messages = null;
|
||||
maximumSeverity = null;
|
||||
application = null;
|
||||
responseStream = null;
|
||||
responseWriter = null;
|
||||
viewRoot = null;
|
||||
exceptionHandler = null;
|
||||
attributes = null;
|
||||
|
||||
released = true;
|
||||
FacesContext.setCurrentInstance(null);
|
||||
}
|
||||
|
||||
public ExternalContext getExternalContext() {
|
||||
assertNotReleased();
|
||||
return externalContext;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
assertNotReleased();
|
||||
return application;
|
||||
}
|
||||
|
||||
public RenderKit getRenderKit() {
|
||||
if (getViewRoot() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String renderKitId = getViewRoot().getRenderKitId();
|
||||
|
||||
if (renderKitId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return renderKitFactory.getRenderKit(this, renderKitId);
|
||||
}
|
||||
|
||||
public boolean getRenderResponse() {
|
||||
assertNotReleased();
|
||||
return renderResponse;
|
||||
}
|
||||
|
||||
public boolean getResponseComplete() {
|
||||
assertNotReleased();
|
||||
return responseComplete;
|
||||
}
|
||||
|
||||
public ResponseStream getResponseStream() {
|
||||
assertNotReleased();
|
||||
return responseStream;
|
||||
}
|
||||
|
||||
public void setResponseStream(ResponseStream responseStream) {
|
||||
assertNotReleased();
|
||||
if (responseStream == null) {
|
||||
throw new NullPointerException("responseStream");
|
||||
}
|
||||
this.responseStream = responseStream;
|
||||
}
|
||||
|
||||
public ResponseWriter getResponseWriter() {
|
||||
assertNotReleased();
|
||||
return responseWriter;
|
||||
}
|
||||
|
||||
public void setResponseWriter(ResponseWriter responseWriter) {
|
||||
assertNotReleased();
|
||||
if (responseWriter == null) {
|
||||
throw new NullPointerException("responseWriter");
|
||||
}
|
||||
this.responseWriter = responseWriter;
|
||||
}
|
||||
|
||||
public UIViewRoot getViewRoot() {
|
||||
assertNotReleased();
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
public void setViewRoot(UIViewRoot viewRoot) {
|
||||
assertNotReleased();
|
||||
if (viewRoot == null) {
|
||||
throw new NullPointerException("viewRoot");
|
||||
}
|
||||
this.viewRoot = viewRoot;
|
||||
}
|
||||
|
||||
public void renderResponse() {
|
||||
assertNotReleased();
|
||||
renderResponse = true;
|
||||
}
|
||||
|
||||
public void responseComplete() {
|
||||
assertNotReleased();
|
||||
responseComplete = true;
|
||||
}
|
||||
|
||||
public ELContext getELContext() {
|
||||
if (elContext == null) {
|
||||
createELContext();
|
||||
}
|
||||
return elContext;
|
||||
}
|
||||
|
||||
private void createELContext() {
|
||||
elContext = new PortletELContextImpl(getApplication().getELResolver());
|
||||
elContext.putContext(FacesContext.class, FacesContext.getCurrentInstance());
|
||||
if (getViewRoot() != null) {
|
||||
elContext.setLocale(getViewRoot().getLocale());
|
||||
}
|
||||
fireContextCreated(getApplication().getELContextListeners());
|
||||
}
|
||||
|
||||
private void fireContextCreated(ELContextListener[] listeners) {
|
||||
if (listeners.length > 0) {
|
||||
ELContextEvent event = new ELContextEvent(elContext);
|
||||
for (ELContextListener listener : listeners) {
|
||||
listener.contextCreated(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMessage(String clientId, FacesMessage message) {
|
||||
assertNotReleased();
|
||||
if (message == null) {
|
||||
throw new NullPointerException("message");
|
||||
}
|
||||
|
||||
if (messages == null) {
|
||||
messages = new ArrayList<Message>();
|
||||
}
|
||||
messages.add(new Message(clientId, message));
|
||||
recalculateMaximumSeverity(message.getSeverity());
|
||||
}
|
||||
|
||||
private void recalculateMaximumSeverity(FacesMessage.Severity severity) {
|
||||
if (severity != null) {
|
||||
if (maximumSeverity == null || severity.compareTo(maximumSeverity) > 0) {
|
||||
maximumSeverity = severity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FacesMessage.Severity getMaximumSeverity() {
|
||||
assertNotReleased();
|
||||
return maximumSeverity;
|
||||
}
|
||||
|
||||
public Iterator<FacesMessage> getMessages() {
|
||||
return getMessageList().iterator();
|
||||
}
|
||||
|
||||
public List<FacesMessage> getMessageList() {
|
||||
assertNotReleased();
|
||||
if (messages == null || messages.isEmpty()) {
|
||||
return NO_MESSAGES;
|
||||
}
|
||||
List<FacesMessage> messageList = new ArrayList<FacesMessage>();
|
||||
for (Message message : messages) {
|
||||
messageList.add(message.getFacesMessage());
|
||||
}
|
||||
return Collections.unmodifiableList(messageList);
|
||||
}
|
||||
|
||||
public Iterator<FacesMessage> getMessages(String clientId) {
|
||||
return getMessageList(clientId).iterator();
|
||||
}
|
||||
|
||||
public List<FacesMessage> getMessageList(String clientId) {
|
||||
assertNotReleased();
|
||||
if (messages == null || messages.isEmpty()) {
|
||||
return NO_MESSAGES;
|
||||
}
|
||||
List<FacesMessage> messageList = new ArrayList<FacesMessage>();
|
||||
for (Message message : messages) {
|
||||
if (message.isForClientId(clientId)) {
|
||||
messageList.add(message.getFacesMessage());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(messageList);
|
||||
}
|
||||
|
||||
public Iterator<String> getClientIdsWithMessages() {
|
||||
assertNotReleased();
|
||||
if (messages == null || messages.isEmpty()) {
|
||||
return NO_CLIENT_IDS_WITH_MESSAGES;
|
||||
}
|
||||
Set<String> clientIdsWithMessags = new LinkedHashSet<String>();
|
||||
for (Message message : messages) {
|
||||
clientIdsWithMessags.add(message.getClientId());
|
||||
}
|
||||
return Collections.unmodifiableSet(clientIdsWithMessags).iterator();
|
||||
}
|
||||
|
||||
public Map<Object, Object> getAttributes() {
|
||||
assertNotReleased();
|
||||
if (attributes == null) {
|
||||
attributes = new HashMap<Object, Object>();
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public PhaseId getCurrentPhaseId() {
|
||||
assertNotReleased();
|
||||
return currentPhaseId;
|
||||
}
|
||||
|
||||
public ExceptionHandler getExceptionHandler() {
|
||||
return exceptionHandler;
|
||||
}
|
||||
|
||||
public boolean isPostback() {
|
||||
RenderKit renderKit = getRenderKit();
|
||||
if (renderKit == null) {
|
||||
String renderKitId = getApplication().getViewHandler().calculateRenderKitId(this);
|
||||
renderKit = JsfUtils.findFactory(RenderKitFactory.class).getRenderKit(this, renderKitId);
|
||||
}
|
||||
return renderKit.getResponseStateManager().isPostback(this);
|
||||
}
|
||||
|
||||
public boolean isReleased() {
|
||||
return released;
|
||||
}
|
||||
|
||||
public boolean isValidationFailed() {
|
||||
assertNotReleased();
|
||||
return validationFailed;
|
||||
}
|
||||
|
||||
public void setCurrentPhaseId(PhaseId currentPhaseId) {
|
||||
assertNotReleased();
|
||||
this.currentPhaseId = currentPhaseId;
|
||||
}
|
||||
|
||||
public void setExceptionHandler(ExceptionHandler exceptionHandler) {
|
||||
assertNotReleased();
|
||||
this.exceptionHandler = exceptionHandler;
|
||||
}
|
||||
|
||||
public void validationFailed() {
|
||||
assertNotReleased();
|
||||
validationFailed = true;
|
||||
}
|
||||
|
||||
public PartialViewContext getPartialViewContext() {
|
||||
assertNotReleased();
|
||||
if (partialViewContext == null) {
|
||||
partialViewContext = JsfUtils.findFactory(PartialViewContextFactory.class).getPartialViewContext(this);
|
||||
}
|
||||
return partialViewContext;
|
||||
}
|
||||
|
||||
public boolean isProcessingEvents() {
|
||||
assertNotReleased();
|
||||
return processingEvents;
|
||||
}
|
||||
|
||||
public void setProcessingEvents(boolean processingEvents) {
|
||||
assertNotReleased();
|
||||
this.processingEvents = processingEvents;
|
||||
}
|
||||
|
||||
public boolean isProjectStage(ProjectStage stage) {
|
||||
Assert.notNull(stage, "Stage must not be null");
|
||||
return (stage.equals(getApplication().getProjectStage()));
|
||||
}
|
||||
|
||||
private void assertNotReleased() {
|
||||
Assert.isTrue(!released, "FacesContext already released");
|
||||
}
|
||||
|
||||
private class PortletELContextImpl extends ELContext {
|
||||
|
||||
private FunctionMapper functionMapper;
|
||||
private VariableMapper variableMapper;
|
||||
private ELResolver resolver;
|
||||
|
||||
public PortletELContextImpl(ELResolver resolver) {
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionMapper getFunctionMapper() {
|
||||
return functionMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableMapper getVariableMapper() {
|
||||
return variableMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ELResolver getELResolver() {
|
||||
return resolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Message {
|
||||
|
||||
private String clientId;
|
||||
private FacesMessage facesMessage;
|
||||
|
||||
public Message(String clientId, FacesMessage facesMessage) {
|
||||
this.clientId = clientId;
|
||||
this.facesMessage = facesMessage;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public boolean isForClientId(String clientId) {
|
||||
return ObjectUtils.nullSafeEquals(this.clientId, clientId);
|
||||
}
|
||||
|
||||
public FacesMessage getFacesMessage() {
|
||||
return facesMessage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.portlet.PortletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Utilities when dealing with {@link PortletResponse}s.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class PortletResponseUtils {
|
||||
|
||||
// Work around for PLUTO-603
|
||||
|
||||
public static void setStatusCodeForPluto(PortletResponse response, int statusCode) {
|
||||
if (response.getClass().getName().startsWith("org.apache.pluto")) {
|
||||
Method servletResponseMethod = ReflectionUtils.findMethod(response.getClass(), "getServletResponse");
|
||||
if (servletResponseMethod != null) {
|
||||
try {
|
||||
ReflectionUtils.makeAccessible(servletResponseMethod);
|
||||
HttpServletResponse servletResponse = (HttpServletResponse) servletResponseMethod.invoke(response);
|
||||
servletResponse.setStatus(statusCode);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.application.ViewHandlerWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.portlet.MimeResponse;
|
||||
import javax.portlet.ResourceURL;
|
||||
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
/**
|
||||
* JSF {@link ViewHandler} that adds support for generating Portlet compatible resource URLs.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class PortletViewHandler extends ViewHandlerWrapper {
|
||||
|
||||
private static final String FACES_RESOURCE = "javax.faces.resource";
|
||||
|
||||
private ViewHandler wrapped;
|
||||
|
||||
public PortletViewHandler(ViewHandler wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
public ViewHandler getWrapped() {
|
||||
return this.wrapped;
|
||||
}
|
||||
|
||||
public String getResourceURL(FacesContext context, String path) {
|
||||
String uri = super.getResourceURL(context, path);
|
||||
int facesResourceIndex = (uri == null ? -1 : uri.indexOf(FACES_RESOURCE));
|
||||
if (facesResourceIndex == -1) {
|
||||
return uri;
|
||||
}
|
||||
UriComponents components = UriComponentsBuilder.fromUriString(uri.substring(facesResourceIndex + FACES_RESOURCE.length() + 1)).build();
|
||||
MimeResponse response = (MimeResponse) context.getExternalContext().getResponse();
|
||||
ResourceURL resourceURL = response.createResourceURL();
|
||||
for (Map.Entry<String, List<String>> entry : components.getQueryParams().entrySet()) {
|
||||
String name = entry.getKey();
|
||||
List<String> value = entry.getValue();
|
||||
resourceURL.setParameter(name, value.toArray(new String[value.size()]));
|
||||
}
|
||||
resourceURL.setParameter(FACES_RESOURCE, components.getPath());
|
||||
return resourceURL.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
import org.springframework.binding.collection.StringKeyedMapAdapter;
|
||||
import org.springframework.webflow.context.portlet.PortletRequestParameterMap;
|
||||
|
||||
/**
|
||||
* /** Base class for {@link Map}s allowing access to {@link PortletContext} request paramters.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @see SingleValueRequestParameterMap
|
||||
* @see MultiValueRequestParameterMap
|
||||
*/
|
||||
public abstract class RequestParameterMap<V> extends StringKeyedMapAdapter<V> {
|
||||
|
||||
private final PortletRequest portletRequest;
|
||||
|
||||
private final Delegate delegate;
|
||||
|
||||
public RequestParameterMap(PortletRequest portletRequest) {
|
||||
this.portletRequest = portletRequest;
|
||||
this.delegate = new Delegate(portletRequest);
|
||||
}
|
||||
|
||||
protected final PortletRequest getPortletRequest() {
|
||||
return this.portletRequest;
|
||||
}
|
||||
|
||||
protected void setAttribute(String key, V value) {
|
||||
this.delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
protected void removeAttribute(String key) {
|
||||
this.delegate.removeAttribute(key);
|
||||
}
|
||||
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return this.delegate.getAttributeNames();
|
||||
}
|
||||
|
||||
private static class Delegate extends PortletRequestParameterMap {
|
||||
|
||||
public Delegate(PortletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
public Object getAttribute(String key) {
|
||||
return super.getAttribute(key);
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object value) {
|
||||
super.setAttribute(key, value);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
super.removeAttribute(key);
|
||||
}
|
||||
|
||||
public Iterator<String> getAttributeNames() {
|
||||
return super.getAttributeNames();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
import org.springframework.binding.collection.StringKeyedMapAdapter;
|
||||
import org.springframework.webflow.core.collection.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Base class for {@link Map}s allowing access to {@link PortletContext} request properties.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @see SingleValueRequestPropertyMap
|
||||
* @see MultiValueRequestPropertyMap
|
||||
*/
|
||||
public abstract class RequestPropertyMap<V> extends StringKeyedMapAdapter<V> {
|
||||
|
||||
private final PortletRequest portletRequest;
|
||||
|
||||
public RequestPropertyMap(PortletRequest portletRequest) {
|
||||
this.portletRequest = portletRequest;
|
||||
}
|
||||
|
||||
protected final PortletRequest getPortletRequest() {
|
||||
return this.portletRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAttribute(String key, V value) {
|
||||
throw new UnsupportedOperationException("Cannot set PortletRequest property");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String key) {
|
||||
throw new UnsupportedOperationException("Cannot remove PortletRequest property");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return CollectionUtils.toIterator(this.portletRequest.getPropertyNames());
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request parameters containing single String values.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getParameterValues(String)
|
||||
*/
|
||||
public class SingleValueRequestParameterMap extends RequestParameterMap<String> {
|
||||
|
||||
public SingleValueRequestParameterMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String getAttribute(String key) {
|
||||
return getPortletRequest().getParameter(key);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request properties containing single String values.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getProperties(String)
|
||||
*/
|
||||
public class SingleValueRequestPropertyMap extends RequestPropertyMap<String> {
|
||||
|
||||
public SingleValueRequestPropertyMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String getAttribute(String key) {
|
||||
return getPortletRequest().getProperty(key);
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,4 @@ public abstract class AbstractResourcesConfigurationTests extends TestCase {
|
||||
assertEquals(0, handlerMapping.getOrder());
|
||||
}
|
||||
|
||||
public void testConfigurePortlet() {
|
||||
Object resourceHandler = this.context.getBean(ResourcesBeanDefinitionParser.PORTLET_RESOURCE_HANDLER_BEAN_NAME);
|
||||
assertNotNull(resourceHandler);
|
||||
assertTrue(resourceHandler instanceof org.springframework.faces.webflow.context.portlet.JsfResourceRequestHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
|
||||
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
|
||||
import org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser;
|
||||
import org.springframework.webflow.validation.BeanValidationHintResolver;
|
||||
|
||||
public class FacesFlowBuilderServicesJavaConfigTests extends AbstractFacesFlowBuilderServicesConfigurationTests {
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.springframework.faces.config;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
public class ResourcesJavaConfigTests extends AbstractResourcesConfigurationTests {
|
||||
|
||||
|
||||
@Override
|
||||
protected ApplicationContext initApplicationContext() {
|
||||
return new AnnotationConfigApplicationContext(FacesFlowConfig.class);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class FacesFlowConfig extends AbstractFacesPortletFlowConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class MultiValueRequestParameterMapTests extends TestCase {
|
||||
|
||||
private MultiValueRequestParameterMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.request = new MockPortletRequest();
|
||||
this.requestMap = new MultiValueRequestParameterMap(this.request);
|
||||
}
|
||||
|
||||
public void testMultiValueParameter() throws Exception {
|
||||
this.request.setParameter("key", "value");
|
||||
this.request.addParameter("key", "value2");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertTrue(actual.getClass().isArray());
|
||||
assertEquals(2, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
assertEquals("value2", ((String[]) actual)[1]);
|
||||
}
|
||||
|
||||
public void testSingleValueParameterAsArray() throws Exception {
|
||||
this.request.setParameter("key", "value");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertTrue(actual.getClass().isArray());
|
||||
assertEquals(1, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class MultiValueRequestPropertyMapTests extends TestCase {
|
||||
|
||||
private MultiValueRequestPropertyMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.request = new MockPortletRequest();
|
||||
this.requestMap = new MultiValueRequestPropertyMap(this.request);
|
||||
}
|
||||
|
||||
public void testMultiValueProperty() throws Exception {
|
||||
this.request.setProperty("key", "value");
|
||||
this.request.addProperty("key", "value2");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertEquals(2, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
assertEquals("value2", ((String[]) actual)[1]);
|
||||
}
|
||||
|
||||
public void testSingleValuePropertyAsArray() throws Exception {
|
||||
this.request.setProperty("key", "value");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertEquals(1, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class SingleValueRequestParameterMapTests extends TestCase {
|
||||
|
||||
private SingleValueRequestParameterMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.request = new MockPortletRequest();
|
||||
this.requestMap = new SingleValueRequestParameterMap(this.request);
|
||||
}
|
||||
|
||||
public void testSingleValueParameter() throws Exception {
|
||||
this.request.setParameter("key", "value");
|
||||
assertEquals("value", this.requestMap.getAttribute("key"));
|
||||
}
|
||||
|
||||
public void testMultiValueParameterAsString() throws Exception {
|
||||
this.request.setParameter("key", "value");
|
||||
this.request.addParameter("key", "value2");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class SingleValueRequestPropertyMapTests extends TestCase {
|
||||
|
||||
private SingleValueRequestPropertyMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.request = new MockPortletRequest();
|
||||
this.requestMap = new SingleValueRequestPropertyMap(this.request);
|
||||
}
|
||||
|
||||
public void testSingleValueProperty() throws Exception {
|
||||
this.request.setProperty("key", "value");
|
||||
assertEquals("value", this.requestMap.getAttribute("key"));
|
||||
}
|
||||
|
||||
public void testMultiValuePropertyAsString() throws Exception {
|
||||
this.request.setProperty("key", "value");
|
||||
this.request.addProperty("key", "value2");
|
||||
Object actual = this.requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user