⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseurlimpl.java.svn-base

📁 portal越来越流行了
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.apache.pluto.internal.impl;import java.io.IOException;import java.io.Writer;import java.util.Enumeration;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.portlet.BaseURL;import javax.portlet.PortalContext;import javax.portlet.PortletMode;import javax.portlet.PortletModeException;import javax.portlet.PortletSecurityException;import javax.portlet.ResourceURL;import javax.portlet.WindowState;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.pluto.PortletContainer;import org.apache.pluto.PortletContainerException;import org.apache.pluto.PortletWindow;import org.apache.pluto.om.portlet.PortletDefinition;import org.apache.pluto.om.portlet.PortletApplicationDefinition;import org.apache.pluto.om.portlet.Supports;import org.apache.pluto.spi.PortletURLListener;import org.apache.pluto.spi.PortletURLProvider;import org.apache.pluto.util.StringManager;import org.apache.pluto.util.StringUtils;/** * Implementation of JSR-286 <code>BaseURL</code>, which includes a refactoring * of <code>PortletURLImpl</code>. * * @since 2.0 */public class BaseURLImpl implements BaseURL {	private static final Log LOG = LogFactory.getLog(BaseURLImpl.class);	private static final StringManager EXCEPTIONS = StringManager.getManager(PortletURLImpl.class.getPackage().getName());	private boolean escapeXML;	protected Map parameters = new HashMap();	protected Map<String, String[]> publicRenderParameters = new HashMap<String, String[]>();	protected boolean secure;	protected PortletContainer container;	protected PortletMode mode = null;	protected PortletWindow portletWindow;	protected javax.servlet.http.HttpServletRequest servletRequest;	protected javax.servlet.http.HttpServletResponse servletResponse;	protected WindowState state;	protected boolean isAction;	protected boolean isResourceServing;	protected PortalContext context;		public BaseURLImpl(PortletContainer container,			PortletWindow portletWindow,			javax.servlet.http.HttpServletRequest servletRequest,			javax.servlet.http.HttpServletResponse servletResponse,			boolean isAction, boolean isResourceServing) {		this.container = container;		this.portletWindow = portletWindow;		this.servletRequest = servletRequest;		this.servletResponse = servletResponse;		secure = servletRequest.isSecure();		this.isAction = isAction;		this.isResourceServing = isResourceServing;		this.context = container.getRequiredContainerServices().getPortalContext();		if (!isResourceServing)			checkCacheLevel();	}	private String getCacheability() {		String cacheLevel[] = getRenderParameters("CACHABILITY");		if (cacheLevel == null)			return ResourceURL.PAGE;		else			return cacheLevel[0];	}		private void checkCacheLevel(){		if (getCacheability().equals(ResourceURL.FULL) || getCacheability().equals(ResourceURL.PORTLET))			throw new IllegalStateException("Action or RenderURLs have no FULL or PORTLET cache level.");	}		public void setParameter(String name, String value) {	    if (name == null || value == null) {	        throw new IllegalArgumentException(	            "name and value must not be null");	    }	    List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();	    if (publicRenderParameterNames == null){	    	parameters.put(name, new String[]{value});	    }	    else{	    	if (publicRenderParameterNames.contains(name) && !this.isAction && !this.isResourceServing){		    	publicRenderParameters.put(name,new String[] {value});		    }		    else{		    	parameters.put(name, new String[]{value});		    }		}	}	public void setParameter(String name, String[] values) {		if (name == null || values == null) {	        throw new IllegalArgumentException(	        	"name and values must not be null or values be an empty array");	    }		List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();	    		if (publicRenderParameterNames == null){			parameters.put(name, StringUtils.copy(values));	    }		else{			if (publicRenderParameterNames.contains(name)&& !this.isAction && !this.isResourceServing){		    	publicRenderParameters.put(name,StringUtils.copy(values));		    }		    else{		    	parameters.put(name, StringUtils.copy(values));		    }		}	}	public void setParameters(Map<String, String[]> parameters) {		        if (parameters == null) {            throw new IllegalArgumentException(                "Render parameters must not be null.");        }                for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {            Map.Entry entry = (Map.Entry) iter.next();            if (!(entry.getKey() instanceof String)) {                throw new IllegalArgumentException(                    "Key must not be null and of type java.lang.String.");            }            if (!(entry.getValue() instanceof String[])) {                throw new IllegalArgumentException(                    "Value must not be null and of type java.lang.String[].");            }        }                this.parameters.clear();        this.publicRenderParameters.clear();        List<String> publicPortletRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();        if (parameters.keySet()!= null){        	for (Object key : parameters.keySet()) {        		if (publicPortletRenderParameterNames == null)        			this.setParameter((String)key, (String[])parameters.get(key));        		else{        			//test if this is a public parameter        			if (publicPortletRenderParameterNames.contains(key)&& !this.isAction && !this.isResourceServing)        				publicRenderParameters.put((String)key, (String[])parameters.get(key));        			else        				this.setParameter((String)key, (String[])parameters.get(key));        		}    		}        }                	}	public void setSecure(boolean secure) throws PortletSecurityException {        PortletURLProvider urlProvider = container        		.getRequiredContainerServices()        		.getPortalCallbackService()        		.getPortletURLProvider(servletRequest, portletWindow);        if(urlProvider.isSecureSupported()) {            urlProvider.setSecure();        } else {            LOG.info("Secure URLs not supported.");        }	}	public String toString(){	    PortletURLProvider urlProvider = container	    		.getRequiredContainerServices()	    		.getPortalCallbackService()	    		.getPortletURLProvider(servletRequest, portletWindow);		    PortletURLListener portletURLFilterListener = container			.getRequiredContainerServices()			.getPortalCallbackService().getPortletURLListener();	    if (mode != null) {	        urlProvider.setPortletMode(mode);	    }	    if (state != null) {	        urlProvider.setWindowState(state);	    }	    if (isAction) {	        urlProvider.setAction(true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -