|
From: <fg...@us...> - 2007-07-30 10:16:00
|
Revision: 371
http://openutils.svn.sourceforge.net/openutils/?rev=371&view=rev
Author: fgiust
Date: 2007-07-30 03:16:00 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
new module: magnolia/stripes integration
Modified Paths:
--------------
trunk/pom.xml
Added Paths:
-----------
trunk/openutils-mgnlstripes/
trunk/openutils-mgnlstripes/pom.xml
trunk/openutils-mgnlstripes/src/
trunk/openutils-mgnlstripes/src/main/
trunk/openutils-mgnlstripes/src/main/java/
trunk/openutils-mgnlstripes/src/main/java/it/
trunk/openutils-mgnlstripes/src/main/java/it/openutils/
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/MgnlActionResolver.java
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesModule.java
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRenderer.java
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRequestWrapper.java
trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphResponseWrapper.java
trunk/openutils-mgnlstripes/src/main/resources/
trunk/openutils-mgnlstripes/src/main/resources/META-INF/
trunk/openutils-mgnlstripes/src/main/resources/META-INF/magnolia/
trunk/openutils-mgnlstripes/src/main/resources/META-INF/magnolia/stripes.xml
trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/
trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/
trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.modules.stripes.paragraph-renderers.stripes.xml
trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.server.MIMEMapping.action.xml
Property Changed:
----------------
trunk/openutils-parent/
trunk/openutils-testing-testng-dwr/
Property changes on: trunk/openutils-mgnlstripes
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/openutils-mgnlstripes/pom.xml
===================================================================
--- trunk/openutils-mgnlstripes/pom.xml (rev 0)
+++ trunk/openutils-mgnlstripes/pom.xml 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils</artifactId>
+ <version>3</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+ <artifactId>openutils-mgnlstripes</artifactId>
+ <name>openutils-mgnlstripes</name>
+ <version>0.1-SNAPSHOT</version>
+ <licenses>
+ <license>
+ <name>GPL v3</name>
+ <url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
+ </license>
+ </licenses>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+ <dependency>
+ <groupId>info.magnolia</groupId>
+ <artifactId>magnolia-core</artifactId>
+ <version>3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>info.magnolia</groupId>
+ <artifactId>magnolia-module-admininterface</artifactId>
+ <version>3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <classifier>jdk15</classifier>
+ <version>5.1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
Property changes on: trunk/openutils-mgnlstripes/pom.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/MgnlActionResolver.java
===================================================================
--- trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/MgnlActionResolver.java (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/MgnlActionResolver.java 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,79 @@
+package it.openutils.magnoliastripes;
+
+import info.magnolia.cms.beans.config.Paragraph;
+import info.magnolia.cms.beans.config.ParagraphManager;
+import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.controller.NameBasedActionResolver;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * ActionResolver that extends <code>NameBasedActionResolver</code>, registering any found Stripe action as a
+ * Magnolia paragraph.
+ * @author fgiust
+ * @version $Id: $
+ */
+public class MgnlActionResolver extends NameBasedActionResolver
+{
+
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(MgnlActionResolver.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addActionBean(Class< ? extends ActionBean> clazz)
+ {
+ String binding = getUrlBinding(clazz);
+
+ // Only process the class if it's properly annotated
+ if (binding != null)
+ {
+ registerSpringParagraph(binding);
+ super.addActionBean(clazz);
+ }
+ }
+
+ /**
+ * Registers a Magnolia paragraph which will delegate to a Stripe action.
+ * @param binding Stripes action binding
+ */
+ @SuppressWarnings("unchecked")
+ private void registerSpringParagraph(String binding)
+ {
+ Paragraph paragraph = new Paragraph();
+
+ String dialogName = actionNameToParagraphName(binding);
+
+ paragraph.setName(dialogName);
+ paragraph.setTitle("paragraph." + dialogName + ".title");
+ paragraph.setDescription("paragraph." + dialogName + ".description");
+ paragraph.setDialog(dialogName);
+ paragraph.setTemplatePath(binding);
+ paragraph.setType("stripes");
+
+ log.info("Registering stripes paragraph {}", paragraph.getName()); //$NON-NLS-1$
+ ParagraphManager.getInstance().getParagraphs().put(paragraph.getName(), paragraph);
+ }
+
+ /**
+ * Generate a paragraph name from a Stripes binding. This method will take the last token after "/", strip any
+ * extension and convert everything to lowercase.
+ * @param binding Stripe action binding
+ * @return paragraph name
+ */
+ protected String actionNameToParagraphName(String binding)
+ {
+ String dialogName = StringUtils.lowerCase(StringUtils.substringBeforeLast(StringUtils.substringAfterLast(
+ binding,
+ "/"), "."));
+ return dialogName;
+ }
+
+}
Added: trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesModule.java
===================================================================
--- trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesModule.java (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesModule.java 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,31 @@
+package it.openutils.magnoliastripes;
+
+import info.magnolia.cms.module.RegisterException;
+import info.magnolia.module.admininterface.AbstractAdminModule;
+
+
+/**
+ * Stripes module. Extends AbstractAdminModule which will take care of registering the Stripes paragraph renderer.
+ * @author fgiust
+ * @version $Id: $
+ */
+public class StripesModule extends AbstractAdminModule
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onInit()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onRegister(int registerState) throws RegisterException
+ {
+ // nothing to do
+ }
+}
\ No newline at end of file
Added: trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRenderer.java
===================================================================
--- trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRenderer.java (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRenderer.java 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,333 @@
+package it.openutils.magnoliastripes;
+
+import info.magnolia.cms.beans.config.Paragraph;
+import info.magnolia.cms.beans.runtime.ParagraphRenderer;
+import info.magnolia.cms.core.Content;
+import info.magnolia.cms.core.NodeData;
+import info.magnolia.context.MgnlContext;
+import info.magnolia.context.WebContext;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.PageContext;
+
+import net.sourceforge.stripes.action.ActionBeanContext;
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.config.Configuration;
+import net.sourceforge.stripes.controller.DispatcherHelper;
+import net.sourceforge.stripes.controller.DispatcherServlet;
+import net.sourceforge.stripes.controller.ExecutionContext;
+import net.sourceforge.stripes.controller.LifecycleStage;
+import net.sourceforge.stripes.controller.StripesConstants;
+import net.sourceforge.stripes.controller.StripesFilter;
+import net.sourceforge.stripes.exception.StripesServletException;
+import net.sourceforge.stripes.validation.BooleanTypeConverter;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * <p>
+ * A Magnolia paragraph renderer that delegates to Stripes actions. Most of the code is just a cut and paste from
+ * Stripes' {@link DispatcherServlet}, adapted to work withing magnolia by:
+ * </p>
+ * <ul>
+ * <li>wrap the request in order to modify the request path and provide a custom requestDispatcher</li>
+ * <li>wrap the response in order to provide a custom Writer</li>
+ * <li>use a fake servlet instance/context to setup a Stripe context (there is no servlet here)</li>
+ * <li>injiect any paragraph property as a parameter</li>
+ * </ul>
+ * <p>
+ * <strong>Todo:</strong>
+ * </p>
+ * <ul>
+ * <li>Handle multipart forms in request wrapper (should be easy to do)</li>
+ * <li>A better way of handling multivalued properties in paragraph</li>
+ * <li>Handle binary properties in paragraph</li>
+ * </ul>
+ * @author fgiust
+ * @version $Id: $
+ */
+public class StripesParagraphRenderer implements ParagraphRenderer
+{
+
+ private Boolean alwaysInvokeValidate;
+
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(StripesParagraphRenderer.class);
+
+ /**
+ * <p>
+ * Invokes the following instance level methods in order to coordinate the processing of requests:
+ * </p>
+ * <ul>
+ * <li>{@link #resolveActionBean(ExecutionContext)}</li>
+ * <li>{@link #resolveHandler(ExecutionContext)}</li>
+ * <li>{@link #doBindingAndValidation(ExecutionContext)}</li>
+ * <li>{@link #doCustomValidation(ExecutionContext)}</li>
+ * <li>{@link #handleValidationErrors(ExecutionContext)}</li>
+ * <li>{@link #invokeEventHandler(ExecutionContext)}</li>
+ * </ul>
+ * <p>
+ * If any of the above methods return a {@link Resolution} the rest of the request processing is aborted and the
+ * resolution is executed.
+ * </p>
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void render(Content content, Paragraph paragraph, Writer out) throws IOException
+ {
+ // @fgiust start custom magnolia setup
+
+ WebContext webContext = (WebContext) MgnlContext.getInstance();
+ HttpServletResponse response = new StripesParagraphResponseWrapper(webContext.getResponse(), out);
+
+ final String templatePath = paragraph.getTemplatePath();
+ Map<String, String[]> nodeDataMap = contentToMap(content);
+
+ HttpServletRequest request;
+ try
+ {
+ request = new StripesParagraphRequestWrapper(
+ ((WebContext) MgnlContext.getInstance()).getRequest(),
+ templatePath,
+ nodeDataMap);
+
+ ((StripesParagraphRequestWrapper) request).setLocale(MgnlContext.getLocale());
+ }
+ catch (StripesServletException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ // @todo fgiust force include instead of forwarding. Not needed anymore since we are wrapping requestDispatcher?
+ request.setAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH, templatePath);
+
+ PageContext pageContext = webContext.getPageContext();
+ ServletContext servletContext = null;
+
+ if (pageContext != null)
+ {
+ pageContext.getServletContext();
+ }
+ // @fgiust end custom magnolia setup
+
+ // It sucks that we have to do this here (in the request cycle), but there doesn't
+ // seem to be a good way to get at the Configuration from the Filter in init()
+ doOneTimeConfiguration();
+
+ log.debug("Dispatching request to URL: ", request.getRequestURI());
+
+ try
+ {
+ final Configuration config = StripesFilter.getConfiguration();
+
+ // First manufacture an ActionBeanContext
+ final ActionBeanContext context = config
+ .getActionBeanContextFactory()
+ .getContextInstance(request, response);
+ context.setServletContext(servletContext);
+
+ // Then setup the ExecutionContext that we'll use to process this request
+ final ExecutionContext ctx = new ExecutionContext();
+ ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));
+ ctx.setLifecycleStage(LifecycleStage.ActionBeanResolution);
+ ctx.setActionBeanContext(context);
+
+ ActionBeanContext abc = ctx.getActionBeanContext();
+ if (pageContext != null)
+ {
+ DispatcherHelper.setPageContext(pageContext);
+ }
+
+ // Resolve the ActionBean, and if an interceptor returns a resolution, bail now
+ saveActionBean(request);
+ Resolution resolution = DispatcherHelper.resolveActionBean(ctx);
+
+ if (resolution == null)
+ {
+ resolution = DispatcherHelper.resolveHandler(ctx);
+
+ if (resolution == null)
+ {
+ // Then run binding and validation
+ resolution = DispatcherHelper.doBindingAndValidation(ctx, true);
+
+ if (resolution == null)
+ {
+ // Then continue on to custom validation
+ resolution = DispatcherHelper.doCustomValidation(ctx, alwaysInvokeValidate);
+
+ if (resolution == null)
+ {
+ // And then validation error handling
+ resolution = DispatcherHelper.handleValidationErrors(ctx);
+
+ if (resolution == null)
+ {
+ // And finally(ish) invoking of the event handler
+ resolution = DispatcherHelper.invokeEventHandler(ctx);
+
+ // If the event produced errors, fill them in
+ DispatcherHelper.fillInValidationErrors(ctx);
+ }
+ }
+ }
+ }
+ }
+
+ // Whatever stage it came from, execute the resolution
+ if (resolution != null)
+ {
+ DispatcherHelper.executeResolution(ctx, resolution);
+ }
+ }
+ catch (RuntimeException re)
+ {
+ throw re;
+ }
+ catch (InvocationTargetException ite)
+ {
+ if (ite.getTargetException() instanceof RuntimeException)
+ {
+ throw (RuntimeException) ite.getTargetException();
+ }
+ else
+ {
+ throw new RuntimeException("ActionBean execution threw an exception.", ite.getTargetException());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Exception encountered processing request.", e);
+ }
+ finally
+ {
+
+ if (pageContext != null)
+ {
+ // *Don't* release the page context, if set it will be closed by the main magnolia template
+ // JspFactory.getDefaultFactory().releasePageContext(pageContext);
+ DispatcherHelper.setPageContext(null);
+ }
+ restoreActionBean(request);
+ }
+ }
+
+ /**
+ * @param content paragraph node
+ * @return a map of Strings (converted nodedata)
+ */
+ @SuppressWarnings("unchecked")
+ protected Map<String, String[]> contentToMap(Content content)
+ {
+ Collection<NodeData> paragraphsData = content.getNodeDataCollection();
+ Map<String, String[]> nodeDataMap = new HashMap<String, String[]>();
+ for (NodeData nodeData : paragraphsData)
+ {
+ String name = nodeData.getName();
+ String value = nodeData.getString();
+ if (name.startsWith("multiple"))
+ {
+ nodeDataMap.put(name, StringUtils.split(value, "\n"));
+ }
+ else
+ {
+ nodeDataMap.put(name, new String[]{value });
+ }
+ }
+ return nodeDataMap;
+ }
+
+ /**
+ * Performs a simple piece of one time configuration that requires access to the Configuration object delivered
+ * through the Stripes Filter.
+ */
+ private void doOneTimeConfiguration()
+ {
+ if (alwaysInvokeValidate == null)
+ {
+ // Check to see if, in this application, validate() methods should always be run
+ // even when validation errors already exist
+ String callValidateWhenErrorsExist = StripesFilter
+ .getConfiguration()
+ .getBootstrapPropertyResolver()
+ .getProperty(DispatcherServlet.RUN_CUSTOM_VALIDATION_WHEN_ERRORS);
+
+ if (callValidateWhenErrorsExist != null)
+ {
+ BooleanTypeConverter c = new BooleanTypeConverter();
+ this.alwaysInvokeValidate = c.convert(callValidateWhenErrorsExist, Boolean.class, null);
+ }
+ else
+ {
+ this.alwaysInvokeValidate = false; // Default behaviour
+ }
+ }
+ }
+
+ /**
+ * Fetches, and lazily creates if required, a Stack in the request to store ActionBeans should the current request
+ * involve forwards or includes to other ActionBeans.
+ * @param request the current HttpServletRequest
+ * @param create create a Stack if not already set
+ * @return the Stack if present, or if creation is requested
+ */
+ @SuppressWarnings("unchecked")
+ protected Stack getActionBeanStack(HttpServletRequest request, boolean create)
+ {
+ Stack stack = (Stack) request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN_STACK);
+ if (stack == null && create)
+ {
+ stack = new Stack();
+ request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN_STACK, stack);
+ }
+
+ return stack;
+ }
+
+ /**
+ * Saves the current value of the 'actionBean' attribute in the request so that it can be restored at a later date
+ * by calling {@link #restoreActionBean(HttpServletRequest)}. If no ActionBean is currently stored in the request,
+ * nothing is changed.
+ * @param request the current HttpServletRequest
+ */
+ @SuppressWarnings("unchecked")
+ protected void saveActionBean(HttpServletRequest request)
+ {
+ if (request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN) != null)
+ {
+ Stack stack = getActionBeanStack(request, true);
+ stack.push(request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN));
+ }
+ }
+
+ /**
+ * Restores the previous value of the 'actionBean' attribute in the request. If no ActionBeans have been saved using
+ * {@link #saveActionBean(HttpServletRequest)} then this method has no effect.
+ * @param request the current HttpServletRequest
+ */
+ @SuppressWarnings("unchecked")
+ protected void restoreActionBean(HttpServletRequest request)
+ {
+ Stack stack = getActionBeanStack(request, false);
+ if (stack != null && !stack.empty())
+ {
+ request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN, stack.pop());
+ }
+ }
+
+}
Added: trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRequestWrapper.java
===================================================================
--- trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRequestWrapper.java (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphRequestWrapper.java 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,174 @@
+package it.openutils.magnoliastripes;
+
+import info.magnolia.context.MgnlContext;
+import info.magnolia.context.WebContext;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import net.sourceforge.stripes.controller.StripesRequestWrapper;
+import net.sourceforge.stripes.exception.StripesServletException;
+
+
+/**
+ * Magnolia request wrapper for Stripes actions.
+ * @author fgiust
+ * @version $Id: $
+ */
+class StripesParagraphRequestWrapper extends StripesRequestWrapper
+{
+
+ /**
+ * Hacked servlet path.
+ */
+ private String servletPath;
+
+ /**
+ * Parameter map.
+ */
+ private Map<String, String[]> parameterMap;
+
+ /**
+ * Instantiate a new request wrapper.
+ * @param request original HttpServletRequest
+ * @param servletPath modified servlet path (matches Stripes binding)
+ * @param paragraphsData map containing paragraph attributes
+ * @throws StripesServletException if any other error occurs constructing the wrapper
+ */
+ @SuppressWarnings("unchecked")
+ public StripesParagraphRequestWrapper(
+ HttpServletRequest request,
+ String servletPath,
+ Map<String, String[]> paragraphsData) throws StripesServletException
+ {
+ super(request);
+ this.servletPath = servletPath;
+
+ parameterMap = new Hashtable<String, String[]>();
+ parameterMap.putAll(request.getParameterMap());
+ parameterMap.putAll(paragraphsData);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getServletPath()
+ {
+ return servletPath;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setLocale(Locale locale)
+ {
+ super.setLocale(locale);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Enumeration<String> getParameterNames()
+ {
+ return ((Hashtable) parameterMap).keys();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String[] getParameterValues(String name)
+ {
+ return parameterMap.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String[]> getParameterMap()
+ {
+
+ return parameterMap;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getParameter(String name)
+ {
+ String[] values = getParameterValues(name);
+ if (values != null && values.length > 0)
+ {
+ return values[0];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RequestDispatcher getRequestDispatcher(String path)
+ {
+ return new MagnoliaRequestDispatcher(path);
+ }
+
+ /**
+ * A {@link RequestDispatcher} that uses {@link WebContext} for including a resource.
+ * @author fgiust
+ * @version $Id: $
+ */
+ private static class MagnoliaRequestDispatcher implements RequestDispatcher
+ {
+
+ /**
+ * The url this RequestDispatcher is bound to.
+ */
+ private String url;
+
+ /**
+ * Created a new MagnoliaRequestDispatcher for the given url.
+ * @param url url passed to {@link HttpServletRequest#getRequestDispatcher()}
+ */
+ public MagnoliaRequestDispatcher(String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException
+ {
+ ((WebContext) MgnlContext.getInstance()).include(url, response.getWriter());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException
+ {
+ ((WebContext) MgnlContext.getInstance()).include(url, response.getWriter());
+ }
+ }
+}
\ No newline at end of file
Added: trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphResponseWrapper.java
===================================================================
--- trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphResponseWrapper.java (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/java/it/openutils/magnoliastripes/StripesParagraphResponseWrapper.java 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,43 @@
+package it.openutils.magnoliastripes;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+
+/**
+ * A response wrapper for the Stripes paragraph (replace the standard writer with the Magnolia one).
+ * @author fgiust
+ * @version $Id: $
+ */
+class StripesParagraphResponseWrapper extends HttpServletResponseWrapper
+{
+
+ /**
+ * Writer that should be used for output.
+ */
+ private PrintWriter out;
+
+ /**
+ * @param response HttpServletResponse
+ * @param out writer guven by Magnolia.
+ */
+ public StripesParagraphResponseWrapper(HttpServletResponse response, Writer out)
+ {
+ super(response);
+ this.out = new PrintWriter(out);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PrintWriter getWriter() throws IOException
+ {
+ return out;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-mgnlstripes/src/main/resources/META-INF/magnolia/stripes.xml
===================================================================
--- trunk/openutils-mgnlstripes/src/main/resources/META-INF/magnolia/stripes.xml (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/resources/META-INF/magnolia/stripes.xml 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module SYSTEM "module.dtd">
+<module>
+ <name>stripes</name>
+ <displayName>stripes</displayName>
+ <description>Stripes integration module</description>
+ <class>it.openutils.magnoliastripes.StripesModule</class>
+ <version>0.1</version>
+</module>
Added: trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.modules.stripes.paragraph-renderers.stripes.xml
===================================================================
--- trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.modules.stripes.paragraph-renderers.stripes.xml (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.modules.stripes.paragraph-renderers.stripes.xml 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sv:node sv:name="stripes" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mgnl="http://www.magnolia.info/jcr/mgnl"
+ xmlns:rep="internal" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:jcrfn="http://www.jcp.org/jcr/xpath-functions/1.0">
+ <sv:property sv:name="jcr:primaryType" sv:type="Name">
+ <sv:value>mgnl:contentNode</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
+ <sv:value>mix:versionable</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:uuid" sv:type="String">
+ <sv:value>42369a0d-1d6c-469b-b17d-dc5171435db9</sv:value>
+ </sv:property>
+ <sv:property sv:name="name" sv:type="String">
+ <sv:value>stripes</sv:value>
+ </sv:property>
+ <sv:property sv:name="class" sv:type="String">
+ <sv:value>it.openutils.magnoliastripes.StripesParagraphRenderer</sv:value>
+ </sv:property>
+ <sv:node sv:name="MetaData">
+ <sv:property sv:name="jcr:primaryType" sv:type="Name">
+ <sv:value>mgnl:metaData</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:uuid" sv:type="String">
+ <sv:value>fd0eff1b-ba74-4c6e-ab93-b8a344175495</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:authorid" sv:type="String">
+ <sv:value>superuser</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:creationdate" sv:type="Date">
+ <sv:value>2007-04-12T03:58:33.504+02:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:lastaction" sv:type="Date">
+ <sv:value>2007-07-23T22:39:14.178+01:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:lastmodified" sv:type="Date">
+ <sv:value>2007-07-23T22:39:40.986+01:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:activatorid" sv:type="String">
+ <sv:value>superuser</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:activated" sv:type="Boolean">
+ <sv:value>false</sv:value>
+ </sv:property>
+ </sv:node>
+</sv:node>
Added: trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.server.MIMEMapping.action.xml
===================================================================
--- trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.server.MIMEMapping.action.xml (rev 0)
+++ trunk/openutils-mgnlstripes/src/main/resources/mgnl-bootstrap/stripes/config.server.MIMEMapping.action.xml 2007-07-30 10:16:00 UTC (rev 371)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sv:node sv:name="action" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mgnl="http://www.magnolia.info/jcr/mgnl"
+ xmlns:rep="internal" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:jcrfn="http://www.jcp.org/jcr/xpath-functions/1.0">
+ <sv:property sv:name="jcr:primaryType" sv:type="Name">
+ <sv:value>mgnl:contentNode</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
+ <sv:value>mix:versionable</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:uuid" sv:type="String">
+ <sv:value>c0a3cfb0-2f94-4924-8da2-0f152c825891</sv:value>
+ </sv:property>
+ <sv:property sv:name="icon" sv:type="String">
+ <sv:value>/.resources/file-icons/htm.png</sv:value>
+ </sv:property>
+ <sv:property sv:name="mime-type" sv:type="String">
+ <sv:value>text/html</sv:value>
+ </sv:property>
+ <sv:node sv:name="MetaData">
+ <sv:property sv:name="jcr:primaryType" sv:type="Name">
+ <sv:value>mgnl:metaData</sv:value>
+ </sv:property>
+ <sv:property sv:name="jcr:uuid" sv:type="String">
+ <sv:value>11cf3c7b-3a09-4983-8761-867a1a8cdd14</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:authorid" sv:type="String">
+ <sv:value>superuser</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:lastaction" sv:type="Date">
+ <sv:value>2007-07-29T20:52:47.861+01:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:creationdate" sv:type="String">
+ <sv:value>2004-11-02T15:34:17.212+01:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:lastmodified" sv:type="Date">
+ <sv:value>2007-07-29T20:52:47.928+01:00</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:activatorid" sv:type="String">
+ <sv:value>superuser</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:Data" sv:type="String">
+ <sv:value>MetaData</sv:value>
+ </sv:property>
+ <sv:property sv:name="mgnl:activated" sv:type="Boolean">
+ <sv:value>false</sv:value>
+ </sv:property>
+ </sv:node>
+</sv:node>
Property changes on: trunk/openutils-parent
___________________________________________________________________
Name: svn:ignore
- target
.project
+ target
.project
.settings
Property changes on: trunk/openutils-testing-testng-dwr
___________________________________________________________________
Name: svn:ignore
+ .settings
target
.checkstyle
.classpath
.project
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2007-07-24 10:17:23 UTC (rev 370)
+++ trunk/pom.xml 2007-07-30 10:16:00 UTC (rev 371)
@@ -170,5 +170,7 @@
<module>openutils-backup</module>
<module>openutils-configuration-dataobjects</module>
<module>openutils-configuration-services</module>
+ <module>openutils-mgnlspring</module>
+ <module>openutils-mgnlstripes</module>
</modules>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|