/** * Copyright (c) 2010 portletfaces.org All rights reserved. * * 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.portletfaces.bridge.container.websphere; import javax.portlet.MimeResponse; import javax.portlet.PortletRequest; import javax.portlet.PortletResponse; import org.portletfaces.bridge.container.PortletContainerImpl; import org.portletfaces.bridge.context.map.ApplicationMap; public class PortletContainerWebSphereImpl extends PortletContainerImpl { //IW:TODO - WebSphere Really extends the Pluto Container // Private Constants private static final String CONTENT_TYPE_APPLICATION_XHTML_XML = "application/xhtml+xml"; private static final String CONTENT_TYPE_TEXT_HTML = "text/html"; public PortletContainerWebSphereImpl(PortletRequest portletRequest, PortletResponse portletResponse, String responseNamespace, ApplicationMap applicationMap) { super(portletRequest, portletResponse, responseNamespace, applicationMap); } @Override public boolean isAbleToSetResourceResponseBufferSize() { // The WebSphere javax.portlet.PortletResponse.setBufferSize(int) implementation throws an exception so return // false in order to indicate that this is not supported in WebSphere. return false; } @Override public void setMimeResponseContentType(MimeResponse mimeResponse, String contentType) { String contentTypeForPluto = null; // If the specified contentType is "application/xhtml+xml" use "text/html" instead. That's the only value that // Pluto's RenderResponseImpl.setContentType(String) will be happy with, even though Pluto's "ACCEPT" header // claims it can accept "application/xhtml+xml". if (CONTENT_TYPE_APPLICATION_XHTML_XML.equals(contentType)) { contentTypeForPluto = CONTENT_TYPE_TEXT_HTML; } // Otherwise, use the specified contentType. else { contentTypeForPluto = contentType; } mimeResponse.setContentType(contentTypeForPluto); } /** * Determines whether or not the portlet container supports the standard Portlet 2.0 mechanism for adding resources * to the ... section of the rendered portal page. Section PLT.12.5.4 of the Portlet 2.0 spec indicates * that this is an "optional" feature for vendors to implement. * * @return True if the portlet container supports the standard Portlet 2.0 mechanism for adding resources. */ @Override public boolean isAbleToAddScriptResourceToHead() { //WebSphere Portal v7 is able to add to the head using doHeaders in a two phased render approach //given that the bridge doesn't support this, we ignore the container value because we aren't able to //do this yet. return false; } }