You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2005/12/16 06:51:33 UTC

svn commit: r357128 - /incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java

Author: agilliland
Date: Thu Dec 15 21:51:28 2005
New Revision: 357128

URL: http://svn.apache.org/viewcvs?rev=357128&view=rev
Log:
simple weblog request object.


Added:
    incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java

Added: incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java?rev=357128&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/WeblogRequest.java Thu Dec 15 21:51:28 2005
@@ -0,0 +1,56 @@
+/*
+ * WeblogRequest.java
+ *
+ * Created on December 14, 2005, 6:14 PM
+ */
+
+package org.roller.presentation;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * Represents a request to single weblog.
+ *
+ * This is a fairly generic parsed request which is only trying to figure out
+ * the weblog handle that this request is destined for.
+ *
+ * @author Allen Gilliland
+ */
+public class WeblogRequest extends ParsedRequest {
+    
+    private String weblogHandle = null;
+    
+    
+    public WeblogRequest(HttpServletRequest request) throws InvalidRequestException {
+        
+        // let our parent take care of their business first
+        super(request);
+        
+        String pathInfo = request.getPathInfo();
+        
+        // we expect a path info of /<handle/*
+        if(pathInfo != null && pathInfo.trim().length() > 1) {
+            // strip off the leading slash
+            pathInfo = pathInfo.substring(1);
+            String[] pathElements = pathInfo.split("/");
+            
+            if(pathElements[0] != null && pathElements[0].trim().length() > 1) {
+                this.weblogHandle = pathElements[0];
+            } else {
+                // no handle in path info
+                throw new InvalidRequestException("not a weblog request, "+request.getRequestURL());
+            }
+            
+        } else {
+            // invalid request ... path info is empty
+            throw new InvalidRequestException("not a weblog request, "+request.getRequestURL());
+        }
+    }
+
+    
+    public String getWeblogHandle() {
+        return weblogHandle;
+    }
+    
+}