1 18 19 package org.apache.roller.ui.rendering.velocity.deprecated; 20 21 import java.util.HashSet ; 22 import java.util.Set ; 23 import javax.servlet.http.HttpServletRequest ; 24 import org.apache.commons.lang.StringUtils; 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.roller.RollerException; 28 import org.apache.roller.pojos.WeblogTemplate; 29 30 31 40 public class OldFeedRequest { 41 42 private static Log mLogger = LogFactory.getLog(OldFeedRequest.class); 43 44 private static Set feedServlets = new HashSet (); 45 46 private String context = null; 47 private String flavor = null; 48 private String weblogHandle = null; 49 private String weblogCategory = null; 50 private boolean excerpts = false; 51 52 53 static { 54 feedServlets.add("rss"); 56 feedServlets.add("flavor"); 57 feedServlets.add("atom"); 58 } 59 60 61 64 public OldFeedRequest(HttpServletRequest request) throws Exception { 65 66 mLogger.debug("parsing url "+request.getRequestURL()); 68 69 String servlet = request.getServletPath(); 70 String pathInfo = request.getPathInfo(); 71 72 if(servlet != null) { 74 servlet = servlet.substring(1); 76 77 if(feedServlets.contains(servlet)) { 78 this.context = "weblog"; 79 this.flavor = servlet; 80 } else { 81 throw new Exception ("not a weblog feed request, "+request.getRequestURL()); 83 } 84 } else { 85 throw new Exception ("not a weblog feed request, "+request.getRequestURL()); 86 } 87 88 if(pathInfo != null && pathInfo.trim().length() > 1) { 90 pathInfo = pathInfo.substring(1); 92 String [] pathElements = pathInfo.split("/"); 93 94 if(pathElements[0].length() > 0) { 95 this.weblogHandle = pathElements[0]; 96 } 97 98 } else { 99 100 106 this.context = "main"; 107 } 108 109 119 if(request.getParameter("flavor") != null) { 120 this.flavor = request.getParameter("flavor"); 121 } 122 123 if(request.getParameter("path") != null) { 124 this.weblogCategory = request.getParameter("path"); 125 } 126 127 if(request.getParameter("catname") != null) { 128 this.weblogCategory = request.getParameter("catname"); 129 } 130 131 if(request.getParameter("excerpts") != null) { 132 this.excerpts = Boolean.valueOf(request.getParameter("excerpts")).booleanValue(); 133 } 134 135 if(this.flavor.equals("flavor")) { 139 this.flavor = "rss"; 140 } 141 142 } 143 144 145 public String getContext() { 146 return context; 147 } 148 149 public String getFlavor() { 150 return flavor; 151 } 152 153 public String getWeblogHandle() { 154 return weblogHandle; 155 } 156 157 public String getWeblogCategory() { 158 return weblogCategory; 159 } 160 161 public boolean isExcerpts() { 162 return excerpts; 163 } 164 165 } 166 | Popular Tags |