Author: julien(a)jboss.com
Date: 2007-02-01 11:42:11 -0500 (Thu, 01 Feb 2007)
New Revision: 6138
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSConstants.java
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java
Log:
JBPORTAL-538 : CMSPortlet displays only in default page when link is clicked on a
different page
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -209,7 +209,7 @@
//
addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
}
public HttpServletRequest getClientRequest() throws IllegalStateException
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-02-01
02:39:33 UTC (rev 6137)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -181,11 +181,23 @@
public void setProperty(String name, String value)
{
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ if (name.startsWith("content.") == false)
+ {
+ throw new IllegalArgumentException("Property name must be prefixed by
'content.'");
+ }
setDeclaredProperty(name, value);
}
public String getProperty(String name)
{
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
return getDeclaredProperty(name);
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -41,16 +41,18 @@
void setURI(String uri);
/**
+ * Set a content property, the property name must not be null and must start with the
litteral 'content.'.
*
- * @param name
- * @param value
+ * @param name the property name
+ * @param value the property value
*/
void setProperty(String name, String value);
/**
+ * Retrieve a content property
*
- * @param name
- * @return
+ * @param name the property name
+ * @return the property value or null if it does not exist
*/
String getProperty(String name);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -43,6 +43,7 @@
import org.jboss.portal.portlet.info.WindowStateInfo;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -89,6 +90,16 @@
return context.getController().getCustomizationManager().getInstance(window,
user);
}
+ protected void before(PortletInvocation invocation)
+ {
+
+ }
+
+ protected void after(PortletInvocation invocation)
+ {
+
+ }
+
public Object execute() throws ControllerException
{
//
@@ -142,6 +153,7 @@
PortletInvocationResponse response;
try
{
+ before(invocation);
response = instance.invoke(invocation);
}
catch (PortletInvokerException e)
@@ -155,6 +167,10 @@
throw new ControllerException(e);
}
}
+ finally
+ {
+ after(invocation);
+ }
//
if (response instanceof FragmentResponse)
Added: trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSConstants.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSConstants.java
(rev 0)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSConstants.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CMSConstants
+{
+ /**
+ * Property name for the server config which designates the value of the default
window reference for the
+ * CMS integration by the command mapper.
+ */
+ public static final String DEFAULT_CMS_WINDOW_REF_CONFIG_PROPERTY_NAME =
"cms.default_window_ref";
+}
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -33,8 +33,10 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.core.cms.command.StreamContentCommand;
+import org.jboss.portal.core.cms.ui.CMSPortlet;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.config.ServerConfig;
import java.util.Locale;
@@ -55,6 +57,9 @@
/** . */
protected PortalObjectId targetWindowId;
+ /** . */
+ protected ServerConfig serverConfig;
+
public CMS getCMSService()
{
return CMSService;
@@ -75,11 +80,23 @@
this.targetWindowRef = targetWindowRef;
}
+ public ServerConfig getServerConfig()
+ {
+ return serverConfig;
+ }
+ public void setServerConfig(ServerConfig serverConfig)
+ {
+ this.serverConfig = serverConfig;
+ }
+
protected void startService() throws Exception
{
targetWindowId = PortalObjectId.parse(targetWindowRef,
PortalObjectId.LEGACY_FORMAT);
+ // Update the config from the configuration
+ serverConfig.setProperty(CMSConstants.DEFAULT_CMS_WINDOW_REF_CONFIG_PROPERTY_NAME,
targetWindowRef);
+
//
super.startService();
}
@@ -93,18 +110,34 @@
targetWindowId = null;
}
+ private File getFile(String requestPath, Locale locale)
+ {
+ Command getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath,
locale);
+ File file = (File)CMSService.execute(getCMD);
+ if (file == null)
+ {
+ getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, new
Locale(CMSService.getDefaultLocale()));
+ file = (File)CMSService.execute(getCMD);
+ }
+ return file;
+ }
+
public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
try
{
- Command getCMD =
CMSService.getCommandFactory().createFileGetCommand(requestPath,
invocation.getRequest().getLocale());
- File file = (File)CMSService.execute(getCMD);
- if (file == null)
+ String path = requestPath;
+ Locale requestLocale = invocation.getRequest().getLocale();
+ File file = getFile(requestPath, requestLocale);
+
+ // Redirect to default content if nothing found (and WTF the content is prefixed
by /default ???)
+ if (file == null && "/default/index.html".equals(path) ==
false)
{
- getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, new
Locale(CMSService.getDefaultLocale()));
- file = (File)CMSService.execute(getCMD);
+ path = "/default/index.html";
+ file = getFile(path, requestLocale);
}
+ //
if (file != null)
{
Content content = file.getContent();
@@ -123,9 +156,10 @@
}
else
{
- //Set the content as a render parameter
+ // Set the content as a render parameter
PortletParametersStateString parameters = new
PortletParametersStateString();
- parameters.setValue("path", requestPath);
+ parameters.setValue(CMSPortlet.RENDER_PARAMETER_PATH, path);
+ parameters.setValue(CMSPortlet.REQUEST_PROPERTY_USE_GLOBAL_URLS,
"true");
// Perform a render URL on the target window
return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
@@ -146,6 +180,7 @@
log.error("CMS error", e);
}
}
+
return null; // TODO: 404?
}
}
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -28,8 +28,12 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.cms.ui.CMSPortlet;
+import org.jboss.portal.core.cms.CMSConstants;
import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.server.config.ServerConfig;
import java.util.Map;
import java.util.HashMap;
@@ -69,7 +73,25 @@
return container.getDefinition("CMSPortletInstance");
}
+ protected void before(PortletInvocation invocation)
+ {
+ // Find out if we are invoking the content portlet
+ ServerConfig cfg =
getControllerContext().getServerInvocation().getRequest().getServer().getConfig();
+ // Set the request property for it
+ String windowRef =
cfg.getProperty(CMSConstants.DEFAULT_CMS_WINDOW_REF_CONFIG_PROPERTY_NAME);
+ if (window.getId().toString(PortalObjectId.LEGACY_FORMAT).equals(windowRef))
+ {
+ invocation.setAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
CMSPortlet.REQUEST_PROPERTY_USE_GLOBAL_URLS, "true");
+ }
+ }
+
+ protected void after(PortletInvocation invocation)
+ {
+ // Cleanup request property
+ invocation.removeAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
CMSPortlet.REQUEST_PROPERTY_USE_GLOBAL_URLS);
+ }
+
public Object execute() throws ControllerException
{
Object o = super.execute();
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java 2007-02-01
02:39:33 UTC (rev 6137)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -83,6 +83,7 @@
{
String file = files[i];
CMSContent content = (CMSContent)ctx.createWindow(ContentType.CMS, file);
+
}
}
catch (Exception e)
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-02-01
02:39:33 UTC (rev 6137)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-02-01
16:42:11 UTC (rev 6138)
@@ -41,6 +41,7 @@
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
@@ -58,11 +59,9 @@
*/
public class CMSPortlet extends GenericPortlet
{
+ /** Logger. */
private static Logger log = Logger.getLogger(CMSPortlet.class);
- private CMS CMSService;
-
- private String indexpage;
/**
* It's easier and more robust to follow the standards. See
http://www.ietf.org/rfc/rfc2396.txt of which, Section
* 3.1 on the "Scheme Component" is partially excerpted here:
@@ -84,7 +83,6 @@
* sign (# = ASCII hex 23).
*/
private static final String URI_ignoreRegex = "" + URI_schemeRegex +
"|/|\\x23";
- //private static final String URI_ignoreRegex = "(" + URI_schemeRegex +
"|/|\\x23)";
private static final String
regex = "((?:href|src)\\s*=\\s*) # Capture preliminaries in $1.
\n"
@@ -98,29 +96,19 @@
+ " /?([^\\s>]+) # ...capture URL in $4
\n"
+ ")";
-/* private static final String regex =
-"((?:href|src)\\s*=\\s*) # Capture preliminaries in $1. \n" +
-"(?: # First look for URL in quotes. \n" +
-" ([\"\']) # Capture open quote in $2. \n" +
-" (?!http:) # If it isn't absolute... \n" +
-" /?(.+?) # ...capture URL in $3 \n" +
-" \\2 # Match the closing quote \n" +
-" | # Look for non-quoted URL. \n" +
-" (?![\"\']|http:) # If it isn't absolute... \n"
+
-" /?([^\\s>]+) # ...capture URL in $4 \n" +
-")";*/
-
- /** Removes header content, and leaves content between body tags */
+ /** Removes header content, and leaves content between body tags. */
private static final String HTMLStripperRegex =
"(.*<body[^>]*>(.+)</body>.*)";
- //private static final String HTMLStripperRegex =
"(.*<body[^>]*>(.+)</body>.*')";
+ /** . */
private static final Pattern RELATIVE_URI_PATTERN = Pattern.compile(regex,
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.COMMENTS);
+ /** . */
private static final Pattern STRIP_TAGS_PATTERN = Pattern.compile(HTMLStripperRegex,
Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
+ /** . */
static final URLFormat RELATIVE_SERVLET_ENCODED_URL_FORMAT =
URLFormat.newInstance(true, true);
- /** Our path to jsp pages */
+ /** Our path to jsp pages. */
static final String CMS_JSP_PATH = "/WEB-INF/jsp/cms";
/** Where we can find the default data in the resource bundle. */
@@ -129,6 +117,18 @@
/** Where we can find the default images in the resource bundle. */
static final String DEFAULT_IMAGES_PATH = "/images/cms";
+ /** The render parameter name of the path of the file the portlet will show. */
+ public static final String RENDER_PARAMETER_PATH = "path";
+
+ /** The request property which tells the portlet to use global URLs instead of portlet
URLs. */
+ public static final String REQUEST_PROPERTY_USE_GLOBAL_URLS =
"cms.use_global_urls";
+
+ /** . */
+ private CMS CMSService;
+
+ /** . */
+ private String indexpage;
+
public void init() throws PortletException
{
CMSService = (CMS)getPortletContext().getAttribute("CMS");
@@ -140,21 +140,35 @@
public void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
{
- String path = null;
+ String useGlobalURLs = req.getProperty(REQUEST_PROPERTY_USE_GLOBAL_URLS);
+ URLFactory textURLFactory = null;
+ if ("true".equals(useGlobalURLs))
+ {
+ textURLFactory = new
GlobalURLFactory(((JBossRenderRequest)req).getControllerContext());
+ }
+ if (textURLFactory == null)
+ {
+ textURLFactory = new LocalURLFactory(resp.createRenderURL());
+ }
+
+ URLFactory resourceURLFactory = new
GlobalURLFactory(((JBossRenderRequest)req).getControllerContext());
+
+ //
+ String path;
+ path = req.getParameter(RENDER_PARAMETER_PATH);
+ if (path == null)
+ {
+ PortletPreferences prefs = req.getPreferences();
+ indexpage = prefs.getValue("indexpage",
"/default/index.html");
+ }
+
+ //
try
{
- // String linkMode = req.getPreferences().getValue("linkMode",
LINK_MODE_PORTLET);
-// boolean useCMSLink = LINK_MODE_CMS.equals(linkMode);
- path = req.getParameter("path");
- if (path == null)
- {
- PortletPreferences prefs = req.getPreferences();
- indexpage = prefs.getValue("indexpage",
"/default/index.html");
- }
// Get the file from the CMS, localized.
Command fileGet;
- File file = null;
+ File file;
if (path == null)
{
fileGet = CMSService.getCommandFactory().createFileGetCommand(indexpage,
req.getLocale());
@@ -164,18 +178,6 @@
fileGet = CMSService.getCommandFactory().createFileGetCommand(indexpage,
new Locale(CMSService.getDefaultLocale()));
file = (File)CMSService.execute(fileGet);
}
-/*
- Command itemExistsCMD =
CMSService.getCommandFactory().createItemExistsCommand(indexpage + "/" +
req.getLocale().getLanguage());
- Boolean bExists = (Boolean) CMSService.execute(itemExistsCMD);
- if(bExists.booleanValue())
- {
- fileGet = CMSService.getCommandFactory().createFileGetCommand(indexpage,
req.getLocale());
- }
- else
- {
- fileGet = CMSService.getCommandFactory().createFileGetCommand(indexpage,
new Locale(CMSService.getDefaultLocale()));
- }
-*/
}
else
{
@@ -186,45 +188,31 @@
fileGet = CMSService.getCommandFactory().createFileGetCommand(path, new
Locale(CMSService.getDefaultLocale()));
file = (File)CMSService.execute(fileGet);
}
-/*
- Command itemExistsCMD =
CMSService.getCommandFactory().createItemExistsCommand(path + "/" +
req.getLocale().getLanguage());
- Boolean bExists = (Boolean) CMSService.execute(itemExistsCMD);
- if(bExists.booleanValue())
- {
- fileGet = CMSService.getCommandFactory().createFileGetCommand(path,
req.getLocale());
- }
- else
- {
- fileGet = CMSService.getCommandFactory().createFileGetCommand(path, new
Locale(CMSService.getDefaultLocale()));
- }
-*/
}
-// File file = (File) CMSService.execute(fileGet);
-
// Translate links to resources.
String sHTML = null;
resp.setContentType("text/html");
if (file != null)
{
sHTML = file.getContent().getContentAsString();
-
+
// clean html and body tags
sHTML = this.cleanupContent(sHTML);
-
+
// begin modifying links
StringBuffer buffer = new StringBuffer();
Matcher m = RELATIVE_URI_PATTERN.matcher(sHTML);
while (m.find())
{
String relURI = m.group(3) != null ? m.group(3) : m.group(4);
- String absoluteURI = this.buildURL((JBossRenderRequest)req, "/"
+ relURI);
+ URLFactory urlFactory = resourceURLFactory;
+ if (relURI.endsWith(".html"))
+ {
+ urlFactory = textURLFactory;
+ }
+ String absoluteURI = urlFactory.createURL("/" + relURI);
m.appendReplacement(buffer, "$1$2" +
FileUtil.cleanDoubleSlashes(absoluteURI) + "$2");
-// if(!relURI.startsWith("mailto") &&
!relURI.startsWith("http"))
-// {
-// String absoluteURI = this.buildURL(resp, "/" + relURI);
-// m.appendReplacement(buffer, "$1\"" +
FileUtil.cleanDoubleSlashes(absoluteURI) + "\"");
-// }
}
m.appendTail(buffer);
sHTML = buffer.toString();
@@ -246,40 +234,29 @@
}
catch (CMSException e)
{
- if(e.toString().indexOf("Access to this resource is denied")!=-1)
- {
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- String sHTML = "";
- if(path==null || path.trim().length()==0)
- {
- sHTML = "<h2>Access Denied</h2>You are not allowed to
access the following resource";
- }
- else
- {
- sHTML = "<h2>Access Denied</h2>You are not allowed to
access the following resource - "+path;
- }
- writer.write(sHTML);
- writer.close();
- }
- else
- {
- log.error("CMS error", e);
- }
+ if (e.toString().indexOf("Access to this resource is denied") != -1)
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ String sHTML = "";
+ if (path == null || path.trim().length() == 0)
+ {
+ sHTML = "<h2>Access Denied</h2>You are not allowed to
access the following resource";
+ }
+ else
+ {
+ sHTML = "<h2>Access Denied</h2>You are not allowed to
access the following resource - " + path;
+ }
+ writer.write(sHTML);
+ writer.close();
+ }
+ else
+ {
+ log.error("CMS error", e);
+ }
}
}
- /**
- * Rewrites urls. Typically, this is used for image src calls from the html, so they
route thru the
- * CMSObjectCommandMapper and invoke the StreamObjectCommand.
- */
- public String buildURL(JBossRenderRequest req, String path)
- {
- StreamContentCommand cmd = new StreamContentCommand(path);
- ControllerContext cc = req.getControllerContext();
- return cc.renderURL(cmd, URLContext.newInstance(false, false),
RELATIVE_SERVLET_ENCODED_URL_FORMAT);
- }
-
public void doHelp(RenderRequest req, RenderResponse resp) throws IOException,
PortletException
{
resp.setContentType("text/html");
@@ -296,25 +273,74 @@
PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMS_JSP_PATH + "/edit.jsp");
prd.include(req, resp);
}
-
+
/**
- *
- * @param originalContent
- * @return
+ *
*/
private String cleanupContent(String content)
- {
- //including content only between the <body> and </body>
- if(content.toLowerCase().indexOf("<body")!=-1)
- {
- Matcher h = STRIP_TAGS_PATTERN.matcher(content);
- while (h.find())
- {
- content = h.group(2);
- }
- }
-
-
- return content;
+ {
+ //including content only between the <body> and </body>
+ if (content.toLowerCase().indexOf("<body") != -1)
+ {
+ Matcher h = STRIP_TAGS_PATTERN.matcher(content);
+ while (h.find())
+ {
+ content = h.group(2);
+ }
+ }
+
+
+ return content;
}
+
+ /**
+ * Creates CMS urls which is used for image src calls from the html.
+ */
+ private abstract static class URLFactory
+ {
+ public abstract String createURL(String path);
+ }
+
+ /**
+ * Implementation that uses a PortletURL object.
+ */
+ private static class LocalURLFactory extends URLFactory
+ {
+
+ /** . */
+ private final PortletURL portletURL;
+
+ public LocalURLFactory(PortletURL portletURL)
+ {
+ this.portletURL = portletURL;
+ }
+
+ public String createURL(String path)
+ {
+ portletURL.setParameter(RENDER_PARAMETER_PATH, path);
+ return portletURL.toString();
+ }
+ }
+
+ /**
+ * Implementation that routes thru the CMSObjectCommandMapper.
+ */
+ private static class GlobalURLFactory extends URLFactory
+ {
+
+ /** . */
+ private final ControllerContext controllerContext;
+
+ public GlobalURLFactory(ControllerContext controllerContext)
+ {
+ this.controllerContext = controllerContext;
+ }
+
+ public String createURL(String path)
+ {
+ StreamContentCommand cmd = new StreamContentCommand(path);
+ return controllerContext.renderURL(cmd, URLContext.newInstance(false, false),
RELATIVE_SERVLET_ENCODED_URL_FORMAT);
+ }
+ }
+
}
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-02-01
02:39:33 UTC (rev 6137)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-02-01
16:42:11 UTC (rev 6138)
@@ -225,7 +225,12 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute
name="TargetWindowRef">default.default.CMSWindow</attribute>
- <depends optional-attribute-name="CMSService"
proxy-type="attribute">portal:service=CMS</depends>
+ <depends
+ optional-attribute-name="CMSService"
+ proxy-type="attribute">portal:service=CMS</depends>
+ <depends
+ optional-attribute-name="ServerConfig"
+ proxy-type="attribute">portal:service=ServerConfig</depends>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"