[jboss-svn-commits] JBL Code SVN: r15719 - in labs/jbosslabs/qa/portal-extensions: jbosswiki/src/application/META-INF and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 10 08:29:55 EDT 2007


Author: adamw
Date: 2007-10-10 08:29:55 -0400 (Wed, 10 Oct 2007)
New Revision: 15719

Modified:
   labs/jbosslabs/qa/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/MainCF.java
   labs/jbosslabs/qa/portal-extensions/jbosswiki/src/application/META-INF/application.xml
Log:
MERGE 15696:15718

Modified: labs/jbosslabs/qa/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/MainCF.java
===================================================================
--- labs/jbosslabs/qa/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/MainCF.java	2007-10-10 12:24:50 UTC (rev 15718)
+++ labs/jbosslabs/qa/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/MainCF.java	2007-10-10 12:29:55 UTC (rev 15719)
@@ -10,161 +10,172 @@
 import org.jboss.forge.common.Constants;
 
 /**
- * Main Labs command factory. Finds the most specific portal object
- * the request reffers to; then tries to delegate the mapping to
- * some registered delegate factory and if this is unsuccessfull,
- * default portal object mapping is invoked.
+ * Main Labs command factory. Finds the most specific portal object the request
+ * reffers to; then tries to delegate the mapping to some registered delegate
+ * factory and if this is unsuccessfull, default portal object mapping is
+ * invoked.
+ * 
  * @author Adam Warski (adamw at aster.pl)
  */
 public class MainCF extends AbstractBaseCF implements CommandFactory {
-    private PageDelegatingCF pageDelegatingCF;
-    private PortalObjectCF portalObjectCF;
+	private PageDelegatingCF pageDelegatingCF;
+	private PortalObjectCF portalObjectCF;
 
-    /*
-     * Getters and setters.
-     */
+	/*
+	 * Getters and setters.
+	 */
 
-    public PortalObjectCF getPortalObjectCF() {
-        return portalObjectCF;
-    }
+	public PortalObjectCF getPortalObjectCF() {
+		return portalObjectCF;
+	}
 
-    public void setPortalObjectCF(PortalObjectCF portalObjectCF) {
-        this.portalObjectCF = portalObjectCF;
-    }
+	public void setPortalObjectCF(PortalObjectCF portalObjectCF) {
+		this.portalObjectCF = portalObjectCF;
+	}
 
-    public PageDelegatingCF getPageDelegatingCF() {
-        return pageDelegatingCF;
-    }
+	public PageDelegatingCF getPageDelegatingCF() {
+		return pageDelegatingCF;
+	}
 
-    public void setPageDelegatingCF(PageDelegatingCF pageDelegatingCF) {
-        this.pageDelegatingCF = pageDelegatingCF;
-    }
+	public void setPageDelegatingCF(PageDelegatingCF pageDelegatingCF) {
+		this.pageDelegatingCF = pageDelegatingCF;
+	}
 
-    /**
-     * Portal id of the labs portal.
-     */
-    private PortalObjectId defaultPortalPath = PortalObjectId.parse(":/" + Constants.LABS_PORTAL,
-    		PortalObjectPath.CANONICAL_FORMAT);
+	/**
+	 * Portal id of the labs portal.
+	 */
+	private PortalObjectId defaultPortalPath = PortalObjectId.parse(":/"
+			+ Constants.LABS_PORTAL, PortalObjectPath.CANONICAL_FORMAT);
 
-    /**
-     *
-     * @return A portal object representing the Labs portal.
-     */
-    private Portal getLabsPortal() {
-    	Object o = getContainer().getObject(defaultPortalPath);
-        return (Portal) o;
-    }
+	/**
+	 * 
+	 * @return A portal object representing the Labs portal.
+	 */
+	private Portal getLabsPortal() {
+		Object o = getContainer().getObject(defaultPortalPath);
+		return (Portal) o;
+	}
 
-    /**
-     *
-     * @param parser Parser from which to read the data.
-     * @return The most specific portal object, corresponding to the data from
-     * the parser.
-     */
-    private PortalObject getPortalObject(PathParser parser) {
-        PortalObject o = getLabsPortal();
+	/**
+	 * 
+	 * @param parser
+	 *            Parser from which to read the data.
+	 * @return The most specific portal object, corresponding to the data from
+	 *         the parser.
+	 */
+	private PortalObject getPortalObject(PathParser parser) {
+		PortalObject o = getLabsPortal();
 
-        while (true) {
-            if (!parser.hasFirstToken()) {
-                return o;
-            }
-            
-            PortalObject child = o.getChild(parser.getFirstToken());
+		while (true) {
+			if (!parser.hasFirstToken()) {
+				return o;
+			}
 
-            if (child == null) {
-                return o;
-            }
+			PortalObject child = o.getChild(parser.getFirstToken());
 
-            o = child;
-            parser.proceed();
-        }
-    }
+			if (child == null) {
+				return o;
+			}
 
-    public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation,
-                                       String host, String contextPath, String requestPath) {
-        PathParser parser = new PathParser(requestPath);
+			o = child;
+			parser.proceed();
+		}
+	}
 
-        // Redirects.
-        if ("portal".equals(parser.getFirstToken())) {
-            String rest = parser.getRest();
+	public ControllerCommand doMapping(ControllerContext controllerContext,
+			ServerInvocation invocation, String host, String contextPath,
+			String requestPath) {
+		PathParser parser = new PathParser(requestPath);
 
-            if (parser.hasMoreTokens()) {
-                parser.proceed();
-                if ("community".equals(parser.getFirstToken())) {
-                    rest = parser.getRest();
+		// Redirects.
+		if ("portal".equals(parser.getFirstToken())) {
+			String rest = parser.getRest();
 
-                    if (rest == null) {
-                        rest = "";
-                    }
-                    
-                    sendRedirect(invocation, "/developers/" + rest);
-                    return null;
-                }
-            }
+			if (parser.hasMoreTokens()) {
+				parser.proceed();
+				if ("community".equals(parser.getFirstToken())) {
+					rest = parser.getRest();
 
-            if (rest == null) {
-                rest = "";
-            }
+					if (rest == null) {
+						rest = "";
+					}
 
-            sendRedirect(invocation, "/" + rest);
-            return null;
-        } else if ("jbossrules".equals(parser.getFirstToken())) {
-        	String rest = parser.getRest();
+					sendRedirect(invocation, "/developers/" + rest);
+					return null;
+				}
+			}
 
-            if (rest == null) {
-                rest = "";
-            }
-        	
-        	sendRedirect(invocation, "/drools/" + rest);
-        	return null;
-        }
-        // End of redirects.
-        
-        // Checking if the last token has a .; if no, redirecting to url with a / at the end.
-        // Doing this only with the GET method.
-        if ("GET".equals(invocation.getServerContext().getClientRequest().getMethod())) {
-        	String rest = requestPath;
-        	if (rest != null) {
-        		int lastSlash = rest.lastIndexOf('/');
-        		if (lastSlash != -1) {
-        			String lastToken = rest.substring(lastSlash + 1);
-        			if (!lastToken.contains(".") && !lastToken.equals("")) {
-        				sendRedirect(invocation, parser.getFullPath() + "/");
-        				return null;
-        			}
-        		}
-        	}
-        }
+			if (rest == null) {
+				rest = "";
+			}
 
-        // Getting the portal object referenced by the path.
-        PortalObject target = getPortalObject(parser);
+			sendRedirect(invocation, "/" + rest);
+			return null;
+		} else if ("jbossrules".equals(parser.getFirstToken())) {
+			String rest = parser.getRest();
 
-        // In case the portal object is a portal, the "real" target is this
-        // portal's default page.
-        if (target instanceof Portal) {
-            target = ((Portal) target).getDefaultPage();
-        }
+			if (rest == null) {
+				rest = "";
+			}
 
-        if (target instanceof Page) {
-            Page page = (Page) target;
+			sendRedirect(invocation, "/drools/" + rest);
+			return null;
+		}
+		// End of redirects.
 
-            // First trying to delegate the mapping to a prefix-based factory.
-            ControllerCommand cmd = pageDelegatingCF.doMapping(controllerContext, invocation, host, contextPath,
-                    parser, page);
+		// Checking if the last token has a .; if no, redirecting to url with a
+		// / at the end.
+		// Doing this only with the GET method. Ignore for wiki
 
-            if (cmd != null) {
-                return cmd;
-            }
+		if (!"wiki".equals(parser.getFirstToken())) {
+			if ("GET".equals(invocation.getServerContext().getClientRequest()
+					.getMethod())) {
+				String rest = requestPath;
+				if (rest != null) {
+					int lastSlash = rest.lastIndexOf('/');
+					if (lastSlash != -1) {
+						String lastToken = rest.substring(lastSlash + 1);
+						if (!lastToken.contains(".") && !lastToken.equals("")) {
+							sendRedirect(invocation, parser.getFullPath() + "/");
+							return null;
+						}
+					}
+				}
+			}
+		}
 
-            // If this is unsuccessful, doing the default page mapping.
-            return getPortalObjectCF().doMapping(controllerContext, invocation, parser, (Page) target);
-        } else if (target instanceof Window) {
-            // If the path referenced a window, then the mapping cannot be
-            // delegated; doing the default window mapping.
-            return getPortalObjectCF().doMapping(controllerContext, invocation, parser, (Window) target);
-        } else {
-            // Unknown portal object type.
-            return null;
-        }
-    }
+		// Getting the portal object referenced by the path.
+		PortalObject target = getPortalObject(parser);
+
+		// In case the portal object is a portal, the "real" target is this
+		// portal's default page.
+		if (target instanceof Portal) {
+			target = ((Portal) target).getDefaultPage();
+		}
+
+		if (target instanceof Page) {
+			Page page = (Page) target;
+
+			// First trying to delegate the mapping to a prefix-based factory.
+			ControllerCommand cmd = pageDelegatingCF.doMapping(
+					controllerContext, invocation, host, contextPath, parser,
+					page);
+
+			if (cmd != null) {
+				return cmd;
+			}
+
+			// If this is unsuccessful, doing the default page mapping.
+			return getPortalObjectCF().doMapping(controllerContext, invocation,
+					parser, (Page) target);
+		} else if (target instanceof Window) {
+			// If the path referenced a window, then the mapping cannot be
+			// delegated; doing the default window mapping.
+			return getPortalObjectCF().doMapping(controllerContext, invocation,
+					parser, (Window) target);
+		} else {
+			// Unknown portal object type.
+			return null;
+		}
+	}
 }

Modified: labs/jbosslabs/qa/portal-extensions/jbosswiki/src/application/META-INF/application.xml
===================================================================
--- labs/jbosslabs/qa/portal-extensions/jbosswiki/src/application/META-INF/application.xml	2007-10-10 12:24:50 UTC (rev 15718)
+++ labs/jbosslabs/qa/portal-extensions/jbosswiki/src/application/META-INF/application.xml	2007-10-10 12:29:55 UTC (rev 15719)
@@ -9,11 +9,11 @@
 			<context-root>wiki-files</context-root>
 		</web>
 	</module>
-	<module>
+	<!--<module>
 		<web>
 			<web-uri>wiki-test.war</web-uri>
 		</web>
-	</module>
+	</module>-->
 	<module>
 		<java>wiki-common.jar</java>
 	</module>




More information about the jboss-svn-commits mailing list