001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.cms.content;
023:
024: import org.jboss.portal.Mode;
025: import org.jboss.portal.core.cms.CMSObjectCommandFactory;
026: import org.jboss.portal.core.impl.model.content.generic.InternalGenericContentProvider;
027: import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
028: import org.jboss.portal.core.model.portal.PortalObjectId;
029: import org.jboss.portal.core.model.portal.content.WindowRendition;
030: import org.jboss.portal.core.model.portal.content.ContentRendererContext;
031:
032: /**
033: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
034: * @version $Revision: 9006 $
035: */
036: public class InternalCMSContentProvider extends
037: InternalGenericContentProvider {
038:
039: /** . */
040: private static final ThreadLocal useGlobalURLLocal = new ThreadLocal();
041:
042: public static boolean useGlobalURL() {
043: return Boolean.TRUE.equals(useGlobalURLLocal.get());
044: }
045:
046: /** . */
047: private PortalObjectId targetWindowId;
048:
049: /** . */
050: private CMSObjectCommandFactory commandFactory;
051:
052: /** . */
053: private String portletInstanceName;
054:
055: public String getPortletInstanceName() {
056: return portletInstanceName;
057: }
058:
059: public void setPortletInstanceName(String portletInstanceName) {
060: this .portletInstanceName = portletInstanceName;
061: }
062:
063: public CMSObjectCommandFactory getCommandFactory() {
064: return commandFactory;
065: }
066:
067: public void setCommandFactory(CMSObjectCommandFactory commandFactory) {
068: this .commandFactory = commandFactory;
069: }
070:
071: public void start() throws Exception {
072: targetWindowId = commandFactory.getTargetWindowId();
073: contentPortlet = new ContentPortlet() {
074: public String getPortletName(Mode mode) {
075: return portletInstanceName;
076: }
077: };
078:
079: //
080: super .start();
081: }
082:
083: public WindowRendition renderWindow(
084: ContentRendererContext rendererContext) {
085: try {
086: PortalObjectId windowId = rendererContext.getWindow()
087: .getId();
088:
089: //
090: if (windowId.equals(targetWindowId)) {
091: useGlobalURLLocal.set(Boolean.TRUE);
092: }
093:
094: //
095: return super.renderWindow(rendererContext);
096: } finally {
097: useGlobalURLLocal.set(null);
098: }
099: }
100: }
|