You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by si...@apache.org on 2006/12/01 22:38:36 UTC
svn commit: r481407 - in /lucene/nutch/trunk/contrib/web2/src/main:
java/org/apache/nutch/webapp/common/ java/org/apache/nutch/webapp/controller/
java/org/apache/nutch/webapp/extension/
java/org/apache/nutch/webapp/servlet/ java/org/apache/nutch/webapp...
Author: siren
Date: Fri Dec 1 13:38:33 2006
New Revision: 481407
URL: http://svn.apache.org/viewvc?view=rev&rev=481407
Log:
Fix formatting
Modified:
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/BaseSearch.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/PluginResourceLoader.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Preferences.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchForm.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchResultBean.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServiceLocator.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServletContextServiceLocator.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Startable.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebAppModule.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebappInstanceServiceLocator.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/CachedController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/I18NPageController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/SearchController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PostSearchExtensionPoint.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PreSearchExtensionPoint.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/SearchExtensionPoint.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/UIExtensionPoint.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/CachedServlet.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/JspDispatcherServlet.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/NutchHttpServlet.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/OpenSearchServlet.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/ResourceServlet.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/ExtendableDefinitionsFactory.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/NutchRequestProcessor.java
lucene/nutch/trunk/contrib/web2/src/main/test/org/apache/nutch/webapp/servlet/TestNutchHttpServlet.java
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/BaseSearch.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/BaseSearch.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/BaseSearch.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/BaseSearch.java Fri Dec 1 13:38:33 2006
@@ -111,7 +111,7 @@
}
/**
- * Call plugins participating PreSearch activities
+ * Call plugins participating PreSearch activities.
*/
void callPreSearch(ServiceLocator locator) {
LOG.info("presearch");
@@ -121,7 +121,7 @@
}
/**
- * Call plugins participating Search activities
+ * Call plugins participating Search activities.
*/
void callSearch() {
for (int i = 0; i < search.length; i++) {
@@ -130,7 +130,7 @@
}
/**
- * Call plugins participating postSearch activities
+ * Call plugins participating postSearch activities.
*/
void callPostSearch(ServiceLocator locator) {
LOG.info("postsearch");
@@ -140,7 +140,7 @@
}
/**
- * Entry point to execute the search
+ * Entry point to execute the search.
*/
public void doSearch() {
// create context
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java Fri Dec 1 13:38:33 2006
@@ -17,9 +17,7 @@
package org.apache.nutch.webapp.common;
/**
- * Helper class to aid when forming search result navigation
- *
- *
+ * Helper class to aid when forming search result navigation.
*/
public class NavigationHelper {
@@ -50,8 +48,8 @@
}
/**
- * Is there a previous page available
- *
+ * Is there a previous page available.
+ *
* @return
*/
protected boolean hasPrev() {
@@ -66,16 +64,16 @@
return end < totalHits && (!getShowAllHits());
}
- /**
- * Proceed to next page
+ /**
+ * Proceed to next page.
*/
protected void nextPage() {
start += hitsPerPage;
}
/**
- * Returns offset to next page
- *
+ * Returns offset to next page.
+ *
* @return
*/
public long getNextPageStart() {
@@ -83,14 +81,14 @@
}
/**
- * Proceed to previous page
+ * Proceed to previous page.
*/
public void prev() {
start -= hitsPerPage;
}
/**
- * Get a page number
+ * Get a page number.
* @return
*/
public int getPageNumber() {
@@ -98,7 +96,6 @@
}
/**
- *
* @return
*/
protected boolean getShowAllHits() {
@@ -106,7 +103,7 @@
}
/**
- * Returns the numer of last hit on page
+ * Returns the number of last hit on page.
* @return
*/
public long getEnd() {
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/PluginResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/PluginResourceLoader.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/PluginResourceLoader.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/PluginResourceLoader.java Fri Dec 1 13:38:33 2006
@@ -141,8 +141,9 @@
ArrayList paths = new ArrayList();
- if(LOG.isDebugEnabled()){
- LOG.debug("PluginResourceLoader : dynamically setting jars based on plugins implementing UIExtensionPoint.");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("PluginResourceLoader : dynamically setting jars based "
+ + "on plugins implementing UIExtensionPoint.");
}
ExtensionPoint point = locator.getPluginRepository().getExtensionPoint(
@@ -164,15 +165,13 @@
// classloaders.add(loader);
- URL urls[] = loader.getURLs();
+ URL[] urls = loader.getURLs();
for (int k = 0; k < urls.length; k++) {
URL url = urls[k];
if (!seen.contains(url)) {
paths.add(url);
- if(LOG.isDebugEnabled()){
- LOG.debug("Adding to classpath:" + url);
- }
+ LOG.debug("Adding to classpath:" + url);
}
seen.add(url);
}
@@ -183,11 +182,6 @@
}
- /*
- * s (non-Javadoc)
- *
- * @see java.lang.ClassLoader#getResource(java.lang.String)
- */
public URL getResource(String name) {
Iterator i = classloaders.iterator();
@@ -201,11 +195,6 @@
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String)
- */
public InputStream getResourceAsStream(String name) {
Iterator i = classloaders.iterator();
@@ -219,11 +208,6 @@
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.ClassLoader#getResources(java.lang.String)
- */
public Enumeration getResources(String name) throws IOException {
Iterator i = classloaders.iterator();
@@ -237,11 +221,6 @@
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.ClassLoader#loadClass(java.lang.String)
- */
public Class loadClass(String name) throws ClassNotFoundException {
try {
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Preferences.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Preferences.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Preferences.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Preferences.java Fri Dec 1 13:38:33 2006
@@ -28,9 +28,9 @@
/**
* Preferences represents (extendable) configuration object that is persistable
- * into user browser (as cookie)
- *
- * cookie is in format key-1<KEYVALSEPARATOR>value-1<VALVALSEPARATOR>key-2<KEYVALSEPARATOR>value-2<VALVALSEPARATOR>key-n<KEYVALSEPARATOR>value-n
+ * into user browser (as cookie).
+ *
+ * Cookie is in format key-1<KEYVALSEPARATOR>value-1<VALVALSEPARATOR>key-2<KEYVALSEPARATOR>value-2<VALVALSEPARATOR>key-n<KEYVALSEPARATOR>value-n
*/
public class Preferences extends HashMap {
@@ -43,44 +43,49 @@
public static final String KEY_HITS_PER_DUP = "S";
public static final String KEY_DUP_FIELD = "D";
-
- static final String DEFAULTKEYVALSEPARATOR="_";
- static final String DEFAULTVALVALSEPARATOR="-";
- // Name of web ui cookie that stores users cutomized user preferences
- public static String COOKIE_NAME = "NUTCH";
+ static final String DEFAULTKEYVALSEPARATOR = "_";
- // default preferences, used for all who have not customized
- static Preferences defaults = new Preferences();
+ static final String DEFAULTVALVALSEPARATOR = "-";
+
+ /**
+ * Name of web ui cookie that stores users cutomized user preferences.
+ */
+ public static final String COOKIE_NAME = "NUTCH";
+
+ /**
+ * Default preferences, used for all who have not customized.
+ */
+ static final Preferences DEFAULTS = new Preferences();
static {
// results per page
- defaults.put(KEY_RESULTS_PER_PAGE, "10");
+ DEFAULTS.put(KEY_RESULTS_PER_PAGE, "10");
// dup field
- defaults.put(KEY_DUP_FIELD, "site");
+ DEFAULTS.put(KEY_DUP_FIELD, "site");
}
/**
- *
* @return locale of user (from preferences if set, or from request)
*/
public Locale getLocale(HttpServletRequest request) {
- if (containsKey(KEY_LOCALE))
+ if (containsKey(KEY_LOCALE)) {
return new Locale((String) get(KEY_LOCALE));
- else
+ } else {
return request.getLocale();
+ }
}
/**
* Persist Preferences as cookie.
- * @param request
+ * @param request
* @param response
* @param prefs preferences object to persist
- */
+ */
public static void setPreferencesCookie(HttpServletRequest request,
HttpServletResponse response, Preferences prefs) {
- if (defaults.equals(prefs)) {
+ if (DEFAULTS.equals(prefs)) {
removeCookie(response);
} else {
setPreferencesCookie(response, prefs);
@@ -96,7 +101,7 @@
/**
* Remove cookie from browser
- *
+ *
* @param response
*/
public static void removeCookie(HttpServletResponse response) {
@@ -106,13 +111,13 @@
}
/**
- * Parse Preferences from cookie
- *
+ * Parse Preferences from cookie.
+ *
* @param request
*/
public static Preferences parseCookie(HttpServletRequest request) {
// find right cookie
- Cookie c[] = request.getCookies();
+ Cookie[] c = request.getCookies();
if (c != null) {
for (int i = 0; i < c.length; i++) {
@@ -121,7 +126,7 @@
}
}
}
- return defaults;
+ return DEFAULTS;
}
/**
@@ -138,17 +143,17 @@
* @param data String to parse
* @param valueValueSeparator delimiter between keyValue pairs
* @param keyValueSeparator delimiter between key & value
- * @return parsed Preferences
+ * @return parsed Preferences
*/
public static Preferences parse(String data, String valueValueSeparator, String keyValueSeparator) {
Preferences p = new Preferences();
- p.putAll(defaults);
+ p.putAll(DEFAULTS);
String[] dataitems = data.split(valueValueSeparator);
for (int i = 0; i < dataitems.length; i++) {
String keyvalue[] = dataitems[i].split(keyValueSeparator);
if (keyvalue.length == 2) {
try {
- p.put(keyvalue[0], URLDecoder.decode((String)keyvalue[1],"UTF-8"));
+ p.put(keyvalue[0], URLDecoder.decode((String) keyvalue[1], "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
@@ -156,9 +161,9 @@
}
return p;
}
-
+
/**
- * Return int value or default if non existing
+ * Return int value or default if non existing.
* @param name
* @param defaultVal
* @return
@@ -173,7 +178,7 @@
}
/**
- * Return String value or default if non existing
+ * Return String value or default if non existing.
* @param name
* @param defaultVal
* @return
@@ -188,12 +193,14 @@
for (int i = 0; i < keys.length; i++) {
try {
- txt.append(keys[i].toString()).append(DEFAULTKEYVALSEPARATOR).append(URLEncoder.encode((String)get(keys[i]),"UTF-8"));
+ txt.append(keys[i].toString()).append(DEFAULTKEYVALSEPARATOR).append(
+ URLEncoder.encode((String) get(keys[i]), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
- if (i < keys.length - 1)
+ if (i < keys.length - 1) {
txt.append(DEFAULTVALVALSEPARATOR);
+ }
}
return txt.toString();
@@ -201,12 +208,12 @@
/**
* Get (cached) Preferences instance from request (first from request
- * attribute then from cookie)
- *
+ * attribute then from cookie).
+ *
* @param request
- * @return Preferences object from request or null if not
+ * @return Preferences object from request or null if not available
*/
- public static Preferences getPreferences(HttpServletRequest request) {
+ public static Preferences getPreferences(final HttpServletRequest request) {
Preferences prefs = (Preferences) request.getAttribute(Preferences.class
.getName());
// processing locale
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java Fri Dec 1 13:38:33 2006
@@ -34,15 +34,15 @@
/**
* Search is a bean that represents an ongoing search.
- *
+ *
* After search searchBean that represents the search user doing (also the
* results) might be a good candidate for caching ?
- *
+ *
*/
public class Search implements Writable {
private static final long serialVersionUID = 1L;
-
+
public static final String REQ_ATTR_SEARCH="nutchSearch";
public static final Log LOG = LogFactory.getLog(Search.class);
@@ -58,11 +58,11 @@
// Number of results per page
int hitsPerPage;
-
+
// Number of hits required, for example clustering plugin might require more
// than hitsPerPage hits
int hitsRequired=0;
-
+
String sortColumn;
boolean sortDesc;
@@ -87,13 +87,13 @@
/**
* Perform search described by this bean
- *
+ *
* @param bean
*/
public void performSearch() {
LOG.info("performing search, requiring:" + getHitsRequired());
-
+
try {
LOG.info("query:" + getQuery());
LOG.info("endOffset:" + getStartOffset() + getHitsRequired());
@@ -101,9 +101,10 @@
LOG.info("dupField:" + getDupField());
LOG.info("sortField:" + getSortColumn());
LOG.info("descending:" + isSortDesc());
-
- hits = locator.getNutchBean().search(getQuery(), getStartOffset() + getHitsRequired(),
- getHitsPerDup(), getDupField(), getSortColumn(), isSortDesc());
+
+ hits = locator.getNutchBean().search(getQuery(),
+ getStartOffset() + getHitsRequired(), getHitsPerDup(), getDupField(),
+ getSortColumn(), isSortDesc());
} catch (IOException e) {
hits = new Hits(0, new Hit[0]);
}
@@ -125,7 +126,7 @@
public void init(){
int endOffset=hits.getLength();
-
+
navigationHelper = new NavigationHelper(startOffset, endOffset, hitsPerPage, hits
.getTotal(), hits.totalIsExact());
@@ -135,17 +136,16 @@
.getNextPageStart()));
}
}
-
-
+
/**
- * gets the results of search to display
- *
+ * Gets the results of search to display.
+ *
* @return
*/
public List getResults() {
-
+
int len=Math.min(details.length,getHitsPerPage());
-
+
if (results == null) {
results = new ArrayList(len);
for (int i = 0; i < len; i++) {
@@ -167,9 +167,9 @@
}
return ret;
}
-
+
public Search(){
-
+
}
public Search(ServiceLocator locator) {
@@ -178,14 +178,16 @@
form = locator.getSearchForm();
queryString = form.getValueString(SearchForm.NAME_QUERYSTRING);
- if (queryString == null)
+ if (queryString == null) {
queryString = "";
+ }
htmlQueryString = Entities.encode(queryString);
startOffset = parseInt(form.getValueString(SearchForm.NAME_START), 0);
hitsPerPage = parseInt(form.getValueString(SearchForm.NAME_HITSPERPAGE),
prefs.getInt(Preferences.KEY_RESULTS_PER_PAGE, 10));
- hitsPerDup = parseInt(form.getValueString(SearchForm.NAME_HITSPERDUP), prefs.getInt(
+ hitsPerDup = parseInt(form.getValueString(SearchForm.NAME_HITSPERDUP),
+ prefs.getInt(
Preferences.KEY_HITS_PER_DUP, 2));
sortColumn = form.getValueString(SearchForm.NAME_SORTCOLUMN);
@@ -194,8 +196,9 @@
.getValueString(SearchForm.NAME_SORTREVERSE)));
dupField = form.getValueString(SearchForm.NAME_DUPCOLUMN);
- if (dupField == null)
+ if (dupField == null) {
dupField = "site";
+ }
try {
query = Query.parse(queryString, locator.getConfiguration());
@@ -235,7 +238,7 @@
protected void setHitsPerSite(int hitsPerSite) {
this.hitsPerDup = hitsPerSite;
}
-
+
/**
* @return Returns the query.
*/
@@ -267,8 +270,8 @@
}
/**
- * Returns true if sort is descending
- *
+ * Returns true if sort is descending.
+ *
* @return Returns sort order
*/
public boolean isSortDesc() {
@@ -276,8 +279,8 @@
}
/**
- * Set sort order
- *
+ * Set sort order.
+ *
* @param sortAsc
* The sortAsc to set.
*/
@@ -392,7 +395,7 @@
/**
* returns start, end, total, used for printing message on search page, this
- * is why offset is +1'd
+ * is why offset is +1'd.
*/
public String[] getResultInfo() {
return new String[] { Long.toString(startOffset + 1),
@@ -423,7 +426,6 @@
}
/**
- *
* @return
*/
public List getFormProperties() {
@@ -441,8 +443,8 @@
}
/**
- * return boolean if there are results
- *
+ * Return true if there are results.
+ *
* @return
*/
public boolean getHasResults() {
@@ -454,79 +456,76 @@
}
/**
- * Return number of hits required, if not specified defaults to HitsPerPage
+ * Return number of hits required, if not specified defaults to HitsPerPage.
* @return
*/
public int getHitsRequired() {
- if(hitsRequired!=0) {
- return hitsRequired;
- }
+ if (hitsRequired != 0) {
+ return hitsRequired;
+ }
return getHitsPerPage();
}
/**
- * Set number of hits required
+ * Set number of hits required.
* @param hitsRequired
*/
public void setHitsRequired(int hitsRequired) {
this.hitsRequired = hitsRequired;
}
- /**
- * Launch search
+ /**
+ * Launch search.
*/
public void launchSearch() {
- BaseSearch bs=new BaseSearch(locator);
+ BaseSearch bs = new BaseSearch(locator);
bs.doSearch();
}
public void write(DataOutput out) throws IOException {
LOG.info("writing hits");
hits.write(out);
-
-
out.writeInt(show.length);
- for(int i=0;i<show.length;i++){
+ for (int i = 0; i < show.length; i++) {
show[i].write(out);
}
out.writeInt(details.length);
- for(int i=0;i<details.length;i++){
+ for (int i = 0; i < details.length; i++) {
details[i].write(out);
}
out.writeInt(summaries.length);
- for(int i=0;i<summaries.length;i++){
+ for (int i = 0; i < summaries.length; i++) {
summaries[i].write(out);
}
}
public void readFields(DataInput in) throws IOException {
- hits=new Hits();
+ hits = new Hits();
hits.readFields(in);
- int showlength=in.readInt();
- show=new Hit[showlength];
- for(int i=0;i<showlength;i++){
- show[i]=new Hit();
+ int showlength = in.readInt();
+ show = new Hit[showlength];
+ for (int i = 0; i < showlength; i++) {
+ show[i] = new Hit();
show[i].readFields(in);
}
- int detailsLength=in.readInt();
- details=new HitDetails[detailsLength];
- for(int i=0;i<detailsLength;i++){
- details[i]=new HitDetails();
+ int detailsLength = in.readInt();
+ details = new HitDetails[detailsLength];
+ for (int i = 0; i < detailsLength; i++) {
+ details[i] = new HitDetails();
details[i].readFields(in);
}
- int summariesLength=in.readInt();
- summaries=new Summary[summariesLength];
- for(int i=0;i<summariesLength;i++){
- summaries[i]=new Summary();
+ int summariesLength = in.readInt();
+ summaries = new Summary[summariesLength];
+ for (int i = 0; i < summariesLength; i++) {
+ summaries[i] = new Summary();
summaries[i].readFields(in);
}
-
-
}
+
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchForm.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchForm.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchForm.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchForm.java Fri Dec 1 13:38:33 2006
@@ -28,17 +28,17 @@
* SearchForm is a representation of query parameters submitted as part of
* search form. It provides functionality to preserve all required parameters
* for example when creating link to "next page"
- *
+ *
* Plugins participating in search
- *
+ *
* @see org.apache.nutch.webapp.extension.PreSearch,
* @see org.apache.nutch.webapp.extension.Search,
* @see org.apache.nutch.webapp.extension.PostSearch
- *
+ *
* can by reading (existing) or setting values to/from this map make sure that
* those parameters are persisted to forms/links requiring them without any
* special tricks.
- *
+ *
*/
public class SearchForm {
@@ -46,9 +46,9 @@
* General HTTP parameter name wich contains hits per page value
*/
public static final String NAME_HITSPERPAGE = "hitsPerPage";
-
- public static final String NAME_HITSPERDUP ="hitsPerDup";
-
+
+ public static final String NAME_HITSPERDUP = "hitsPerDup";
+
public static final String NAME_START = "start";
public static final String NAME_QUERYSTRING = "query";
@@ -68,8 +68,8 @@
ArrayList active;
/**
- * KeyValue presents a class that holds key value pair
- *
+ * KeyValue presents a class that holds key value pair.
+ *
*/
public static class KeyValue {
@@ -140,8 +140,8 @@
}
/**
- * Sets value for provided key
- *
+ * Sets value for provided key.
+ *
* @param key
* the key to set the value on
* @param value
@@ -158,8 +158,8 @@
}
/**
- * Gets the real value contained in keyed KeyValue
- *
+ * Gets the real value contained in keyed KeyValue.
+ *
* @param key
* @return
*/
@@ -167,13 +167,14 @@
if (n_values.containsKey(key) && !active.contains(n_values.get(key))) {
active.add(n_values.get(key));
return (String) ((KeyValue) n_values.get(key)).getValue();
- } else
+ } else {
return null;
+ }
}
/**
- * Gets the String value contained in keyed KeyValue
- *
+ * Gets the String value contained in keyed KeyValue.
+ *
* @param key
* @return Object.toString()
*/
@@ -184,8 +185,9 @@
// get only the 1st parameter
n_values.put(key, new KeyValue(key, ((String[]) o_values.get(key))[0]));
active.add(n_values.get(key));
- } else
+ } else {
return null;
+ }
try {
return (String) ((KeyValue) n_values.get(key)).getValue();
@@ -195,8 +197,8 @@
}
/**
- * Remove named key (and the KeyValue)
- *
+ * Remove named key (and the KeyValue).
+ *
* @param key
* @return
*/
@@ -204,12 +206,13 @@
if (n_values.containsKey(key)) {
active.remove(n_values.get(key));
return (KeyValue) n_values.remove(key);
- } else
+ } else {
return null;
+ }
}
/**
- * Get named KeyValue object
+ * Get named KeyValue object.
*
* @param key
* @return named object or null if not existing
@@ -222,19 +225,14 @@
}
/**
- * returns list of KeyValue objects that have been read or set
- *
+ * Returns list of KeyValue objects that have been read or set.
+ *
* @return List containing KeyValue objects
*/
public List getActive() {
return active;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -268,7 +266,7 @@
* Returns a string usable in urls that contains all active parameters and
* their values, if submitted encoding does not work values are encoded with
* utf-8 encoding.
- *
+ *
* @param encoding
* @return
*/
@@ -293,7 +291,7 @@
sb.append(URLEncoder.encode(kv.getKey(), encoding)).append("=").append(
URLEncoder.encode(kv.getValue(), encoding));
} else {
- sb.append(URLEncoder.encode(kv.getKey(),"utf-8")).append("=").append(
+ sb.append(URLEncoder.encode(kv.getKey(), "utf-8")).append("=").append(
URLEncoder.encode(kv.getValue(), "utf-8"));
}
if (i.hasNext()) {
@@ -302,7 +300,7 @@
}
return sb.toString();
}
-
+
public Object clone(){
SearchForm newForm=new SearchForm(new HashMap());
newForm.active.addAll(active);
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchResultBean.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchResultBean.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchResultBean.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/SearchResultBean.java Fri Dec 1 13:38:33 2006
@@ -47,8 +47,8 @@
}
/**
- * Url of search result
- *
+ * Url of search result.
+ *
* @return
*/
public String getUrl() {
@@ -56,8 +56,8 @@
}
/**
- * Title of search result
- *
+ * Title of search result.
+ *
* @return
*/
public String getTitle() {
@@ -66,8 +66,8 @@
}
/**
- * Id of search result
- *
+ * Id of search result.
+ *
* @return
*/
public String getId() {
@@ -75,8 +75,8 @@
}
/**
- * Summary of search result
- *
+ * Summary of search result.
+ *
* @return
*/
public String getSummary() {
@@ -84,8 +84,8 @@
}
/**
- * Url of search result in encoded form
- *
+ * Url of search result in encoded form.
+ *
* @return
*/
public String getEncodedUrl() {
@@ -93,8 +93,8 @@
}
/**
- * Title of search result in encoded form
- *
+ * Title of search result in encoded form.
+ *
* @return
*/
public String getEncodedTitle() {
@@ -102,10 +102,10 @@
}
/**
- * "more" url this should be replaced with help of SearchForm
- *
+ * "more" url this should be replaced with help of SearchForm.
+ *
* @return
- *
+ *
*/
public String getMoreUrl() throws UnsupportedEncodingException {
String more = "";
@@ -119,8 +119,8 @@
}
/**
- * Dedup field name
- *
+ * Dedup field name.
+ *
* @return
*/
public String getDedupValue() {
@@ -128,14 +128,15 @@
}
/**
- * QueryString in encoded form
- *
+ * QueryString in encoded form.
+ *
* @return
*/
public String getUrlEncodedQuery() {
try {
- if (search.getQueryString() != null)
+ if (search.getQueryString() != null) {
return URLEncoder.encode(search.getQueryString(), "UTF-8");
+ }
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -144,8 +145,8 @@
}
/**
- * HitDetails of search result
- *
+ * HitDetails of search result.
+ *
* @return
*/
public HitDetails getDetails() {
@@ -153,8 +154,8 @@
}
/**
- * Hit of search result
- *
+ * Hit of search result.
+ *
* @return
*/
public Hit getHit() {
@@ -163,10 +164,10 @@
/**
* Boolean indicating that there are other, lower-scoring hits with the same
- * dedup value
- *
+ * dedup value.
+ *
* @see Hit#moreFromDupExcluded()
- *
+ *
* @return true if more dups available
*/
public boolean getHasMore() {
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServiceLocator.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServiceLocator.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServiceLocator.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServiceLocator.java Fri Dec 1 13:38:33 2006
@@ -30,54 +30,58 @@
public interface ServiceLocator {
/**
- * Return active Configuration instance (application context)
- *
+ * Return active Configuration instance (application context).
+ *
* @return
*/
public Configuration getConfiguration();
/**
- * Return active PluginRepsository instance (application instance)
- *
+ * Return active PluginRepsository instance (application instance).
+ *
* @return
*/
public PluginRepository getPluginRepository();
/**
- * Return active SearchForm (request instance)
- *
+ * Return active SearchForm (request instance).
+ *
* @return
*/
public SearchForm getSearchForm();
/**
- * Return active Preferences (request context)
- *
+ * Return active Preferences (request context).
+ *
* @return
*/
public Preferences getPreferences();
/**
- * Return active NutchBean (application context)
- *
+ * Return active NutchBean (application context).
+ *
* @return
*/
public NutchBean getNutchBean();
/**
- * Return active PluginResourceLoader (application context)
- *
+ * Return active PluginResourceLoader (application context).
+ *
* @return
*/
public PluginResourceLoader getPluginResourceLoader(ClassLoader loader);
/**
- * Return active Search (request context)
- *
+ * Return active Search (request context).
+ *
* @return
*/
public Search getSearch();
+ /**
+ * Return active locale
+ * @return
+ */
public Locale getLocale();
-
+
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServletContextServiceLocator.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServletContextServiceLocator.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServletContextServiceLocator.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/ServletContextServiceLocator.java Fri Dec 1 13:38:33 2006
@@ -37,33 +37,34 @@
.getName();
/**
- * Logger
+ * Logger.
*/
- public static final Log LOG = LogFactory.getLog(ServletContextServiceLocator.class);
+ public static final Log LOG = LogFactory
+ .getLog(ServletContextServiceLocator.class);
/**
- * ServletContext this ServiceLocator is bound to
+ * ServletContext this ServiceLocator is bound to.
*/
protected ServletContext servletContext;
/**
- * Active configuration
+ * Active configuration.
*/
protected Configuration config;
/**
- * Active PluginRepository
+ * Active PluginRepository.
*/
private PluginRepository repository;
/**
- * Active NutchBean
+ * Active NutchBean.
*/
private NutchBean bean;
/**
- * Private Constructor used to create new ServiceLocator when needed
- *
+ * Private Constructor used to create new ServiceLocator when needed.
+ *
* @param servletContext
*/
private ServletContextServiceLocator(ServletContext servletContext) {
@@ -80,7 +81,7 @@
/**
* Factory method to get handle to ServiceLocator, or if none exists in
* ServletContext then one is created.
- *
+ *
* @param context
* @return ServiceLocator instance bound to ServletContext
*/
@@ -110,37 +111,18 @@
return locator;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.nutch.webapp.common.ServiceLocator#getConfiguration()
- */
public Configuration getConfiguration() {
return config;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.nutch.webapp.common.ServiceLocator#getPluginRepository()
- */public PluginRepository getPluginRepository() {
+ public PluginRepository getPluginRepository() {
return repository;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.nutch.webapp.common.ServiceLocator#getNutchBean()
- */
public NutchBean getNutchBean() {
return bean;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.nutch.webapp.common.ServiceLocator#getPluginResourceLoader(java.lang.ClassLoader)
- */
public PluginResourceLoader getPluginResourceLoader(ClassLoader loader) {
return PluginResourceLoader.getInstance(this, loader);
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Startable.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Startable.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Startable.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Startable.java Fri Dec 1 13:38:33 2006
@@ -18,9 +18,15 @@
import javax.servlet.ServletContext;
-/** Controllers wishing to be initialized must extend this interface
- *
+/**
+ * Controllers wishing to be initialized must extend this interface.
*/
public interface Startable {
- public void start(ServletContext servletContext);
+
+ /**
+ * This method gets called when plugin initializes.
+ *
+ * @param servletContext
+ */
+ void start(ServletContext servletContext);
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebAppModule.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebAppModule.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebAppModule.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebAppModule.java Fri Dec 1 13:38:33 2006
@@ -42,7 +42,7 @@
/**
* This class is responsible for parsing web.xml definitions from plugins (put
* there by jspc when precompiling jsp files).
- *
+ *
* Extracted information is used at runtime when dispatching requests targetted
* to jsp resources to the precompiled servlet classes.
*/
@@ -120,7 +120,7 @@
public WebAppModule(ClassLoader loader, ServletConfig config) {
servletConfig = config;
- this.loader=loader;
+ this.loader = loader;
init(loader.getResourceAsStream("META-INF/jsp-servlet-mappings.xml"));
}
@@ -175,7 +175,7 @@
*/
public void dispatch(String relPath, HttpServletRequest request,
HttpServletResponse response) {
-
+
HttpServlet servletObject;
if (servletObjects.containsKey(relPath)) {
servletObject = (HttpServlet) servletObjects.get(relPath);
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebappInstanceServiceLocator.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebappInstanceServiceLocator.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebappInstanceServiceLocator.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/WebappInstanceServiceLocator.java Fri Dec 1 13:38:33 2006
@@ -72,7 +72,6 @@
}
/**
- *
* @param request
* @return
*/
@@ -82,7 +81,6 @@
}
/**
- *
* @param request
* @param locator
*/
@@ -96,42 +94,22 @@
}
}
- /*
- * (non-Javadoc)
- * @see org.apache.nutch.webapp.common.ServiceLocator#getConfiguration()
- */
public Configuration getConfiguration() {
return contextLocator.getConfiguration();
}
- /*
- * (non-Javadoc)
- * @see org.apache.nutch.webapp.common.ServiceLocator#getPluginRepository()
- */
public PluginRepository getPluginRepository() {
return contextLocator.getPluginRepository();
}
- /*
- * (non-Javadoc)
- * @see org.apache.nutch.webapp.common.ServiceLocator#getNutchBean()
- */
public NutchBean getNutchBean() {
return contextLocator.getNutchBean();
}
- /*
- * (non-Javadoc)
- * @see org.apache.nutch.webapp.common.ServiceLocator#getPluginResourceLoader(java.lang.ClassLoader)
- */
public PluginResourceLoader getPluginResourceLoader(ClassLoader loader) {
return contextLocator.getPluginResourceLoader(loader);
}
- /*
- * (non-Javadoc)
- * @see org.apache.nutch.webapp.common.ServiceLocator#getLocale()
- */
public Locale getLocale() {
return getPreferences().getLocale(request);
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/CachedController.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/CachedController.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/CachedController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/CachedController.java Fri Dec 1 13:38:33 2006
@@ -36,16 +36,15 @@
public void nutchPerform(ComponentContext tileContext,
HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException {
-
-
+
ServiceLocator locator = getServiceLocator(request);
NutchBean bean = locator.getNutchBean();
LOG.info("Cache request from " + request.getRemoteAddr());
-
+
Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")),
Integer.parseInt(request.getParameter("id")));
-
+
HitDetails details = bean.getDetails(hit);
String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo();
@@ -54,24 +53,23 @@
String content = null;
String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);
-
+
if (contentType.startsWith("text/html")) {
- // FIXME : it's better to emit the original 'byte' sequence
+ // FIXME : it's better to emit the original 'byte' sequence
// with 'charset' set to the value of 'CharEncoding',
// but I don't know how to emit 'byte sequence' in JSP.
- // out.getOutputStream().write(bean.getContent(details)) may work,
+ // out.getOutputStream().write(bean.getContent(details)) may work,
// but I'm not sure.
- String encoding = (String) metaData.get("CharEncodingForConversion");
+ String encoding = (String) metaData.get("CharEncodingForConversion");
if (encoding != null) {
try {
content = new String(bean.getContent(details), encoding);
- }
- catch (UnsupportedEncodingException e) {
+ } catch (UnsupportedEncodingException e) {
//fallback to configured charset
- content = new String(bean.getContent(details), locator.getConfiguration().get("parser.character.encoding.default"));
+ content = new String(bean.getContent(details), locator
+ .getConfiguration().get("parser.character.encoding.default"));
}
- }
- else {
+ } else {
//construct String with system default encoding
content = new String(bean.getContent(details));
}
@@ -86,6 +84,7 @@
// page id
request.setAttribute("id", id);
// page content if html
- request.setAttribute("isHtml", new Boolean(contentType.startsWith("text/html")));
+ request.setAttribute("isHtml", new Boolean(contentType
+ .startsWith("text/html")));
}
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/I18NPageController.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/I18NPageController.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/I18NPageController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/I18NPageController.java Fri Dec 1 13:38:33 2006
@@ -56,8 +56,9 @@
String attrName = (String) tileContext.getAttribute("attrName");
// if not available use default
- if (attrName == null)
+ if (attrName == null) {
attrName = "content";
+ }
// get users preferred locale
Locale locale = locator.getLocale();
@@ -70,13 +71,15 @@
if (content == null) {
content = new StringBuffer();
List suffixes = calculateSuffixes(locale);
-
- if(!suffixes.contains(servletContext.getInitParameter("javax.servlet.jsp.jstl.fmt.fallbackLocale"))){
- suffixes.add(servletContext.getInitParameter("javax.servlet.jsp.jstl.fmt.fallbackLocale"));
+
+ if (!suffixes.contains(servletContext
+ .getInitParameter("javax.servlet.jsp.jstl.fmt.fallbackLocale"))) {
+ suffixes.add(servletContext
+ .getInitParameter("javax.servlet.jsp.jstl.fmt.fallbackLocale"));
}
Iterator iterator = suffixes.iterator();
-
+
while (iterator.hasNext()) {
String postfix = (String) iterator.next();
String name = concatPostfix(baseName, postfix);
@@ -145,13 +148,13 @@
* Concat postfix to the name. Take care of existing filename extension.
* Transform the given name "name.ext" to have "name" + "postfix" + "ext". If
* there is no ext, return "name" + "postfix".
- *
+ *
* @param name
* Filename.
* @param postfix
* Postfix to add.
* @return Concatenated filename.
- *
+ *
* This method is borrowed from I18NFactorySet.java wich is part of tiles
* (struts)
*/
@@ -161,5 +164,5 @@
}
return "/" + postfix + name;
}
-
+
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java Fri Dec 1 13:38:33 2006
@@ -40,11 +40,11 @@
public abstract class NutchController implements Controller {
public static final Log LOG = LogFactory.getLog(NutchController.class);
-
+
public final void execute(ComponentContext tileContext,
HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException {
-
+
request.setCharacterEncoding("UTF-8");
try {
@@ -54,9 +54,9 @@
e.printStackTrace(LogUtil.getInfoStream(LOG));
}
}
-
+
/**
- * Nutch controllers overwrite this method
+ * Nutch controllers overwrite this method.
*
* @param tileContext
* @param request
@@ -70,8 +70,8 @@
ServletContext servletContext) throws ServletException, IOException;
/**
- * Get Active service locator from request or create on if not exiting
- *
+ * Get Active service locator from request or create on if none exists.
+ *
* @param request
* @return
*/
@@ -107,13 +107,6 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.Controller#perform(org.apache.struts.tiles.ComponentContext,
- * javax.servlet.http.HttpServletRequest,
- * javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext)
- */
public void perform(ComponentContext tileContext, HttpServletRequest request,
HttpServletResponse response, ServletContext servletContext)
throws ServletException, IOException {
@@ -123,7 +116,7 @@
/**
* Get servlet context service locator, this one cannot access request
* specific information as preferences etc.
- *
+ *
* @param servletContext
* @return
*/
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java Fri Dec 1 13:38:33 2006
@@ -28,7 +28,7 @@
import org.apache.struts.tiles.ComponentContext;
/**
- * Simple controller for preferences page
+ * Simple controller for preferences page.
*/
public class PreferencesController extends NutchController {
@@ -40,9 +40,9 @@
if (tileContext.getAttribute("action").equals("save")) {
LOG.info("save");
- Preferences p=Preferences.parse(request.getQueryString(),"&", "=");
+ Preferences p = Preferences.parse(request.getQueryString(), "&", "=");
LOG.info("setting cookie");
- Preferences.setPreferencesCookie(request,response,p);
+ Preferences.setPreferencesCookie(request, response, p);
LOG.info("setting attribute");
request.setAttribute("preferences", p);
} else {
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/SearchController.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/SearchController.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/SearchController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/SearchController.java Fri Dec 1 13:38:33 2006
@@ -27,17 +27,19 @@
import org.apache.nutch.webapp.common.ServiceLocator;
import org.apache.struts.tiles.ComponentContext;
-/* This is the main controller of nutch search application
+/**
+ * This is the main controller of nutch search application.
*/
public class SearchController extends NutchController {
-
- public void nutchPerform(ComponentContext tileContext, HttpServletRequest request,
- HttpServletResponse response, ServletContext servletContext)
+
+ public void nutchPerform(ComponentContext tileContext,
+ HttpServletRequest request, HttpServletResponse response,
+ ServletContext servletContext)
throws ServletException, IOException {
-
- ServiceLocator locator=getServiceLocator(request);
-
- Search search=locator.getSearch();
+
+ ServiceLocator locator = getServiceLocator(request);
+
+ Search search = locator.getSearch();
search.launchSearch();
}
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PostSearchExtensionPoint.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PostSearchExtensionPoint.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PostSearchExtensionPoint.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PostSearchExtensionPoint.java Fri Dec 1 13:38:33 2006
@@ -20,12 +20,12 @@
/**
* Plugins extending this extension point are run after the actual
- * search
+ * search.
*/
public interface PostSearchExtensionPoint {
public static final String X_POINT_ID=PostSearchExtensionPoint.class.getName();
-
+
void doPostSearch(ServiceLocator locator);
-
+
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PreSearchExtensionPoint.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PreSearchExtensionPoint.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PreSearchExtensionPoint.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/PreSearchExtensionPoint.java Fri Dec 1 13:38:33 2006
@@ -20,10 +20,10 @@
/**
* Plugins extending this extension point are run before the actual
- * search
+ * search.
*/
public interface PreSearchExtensionPoint {
-
+
public static final String X_POINT_ID=PreSearchExtensionPoint.class.getName();
void doPreSearch(ServiceLocator locator);
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/SearchExtensionPoint.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/SearchExtensionPoint.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/SearchExtensionPoint.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/SearchExtensionPoint.java Fri Dec 1 13:38:33 2006
@@ -20,11 +20,10 @@
/**
* Plugins extending this interface can provide logic that
- * is run in parallel with the nutch search.
- *
+ * is run in parallel with the nutch search.
*/
public interface SearchExtensionPoint {
-
+
public static final String X_POINT_ID=SearchExtensionPoint.class.getName();
void doSearch(ServiceLocator locator);
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/UIExtensionPoint.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/UIExtensionPoint.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/UIExtensionPoint.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/extension/UIExtensionPoint.java Fri Dec 1 13:38:33 2006
@@ -19,7 +19,7 @@
/**
* Plugins implementing UIExtensionPoint can provide
* extensions web ui in form of layout components
- * or ui logic
+ * or ui logic.
*/
public interface UIExtensionPoint {
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/CachedServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/CachedServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/CachedServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/CachedServlet.java Fri Dec 1 13:38:33 2006
@@ -33,13 +33,12 @@
/**
* A servlet that serves raw Content of any mime type.
- *
+ *
* If it fails with java.lang.OutOfMemoryError, you may have to increase heap
* size when starting container, such as -Xms1024M -Xmx1024M
- *
+ *
* @author John Xing
*/
-
public class CachedServlet extends NutchHttpServlet {
private static final long serialVersionUID = 1L;
@@ -66,7 +65,8 @@
byte[] bytes = getServiceLocator().getNutchBean().getContent(details);
// pass all original headers? only these for now.
- Metadata metadata = getServiceLocator().getNutchBean().getParseData(details).getContentMeta();
+ Metadata metadata = getServiceLocator().getNutchBean()
+ .getParseData(details).getContentMeta();
String contentType = metadata.get(Response.CONTENT_TYPE);
// String lastModified = metadata.get(Metadata.LAST_MODIFIED);
// String contentLength = metadata.get(Metadata.CONTENT_LENGTH);
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/JspDispatcherServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/JspDispatcherServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/JspDispatcherServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/JspDispatcherServlet.java Fri Dec 1 13:38:33 2006
@@ -74,7 +74,7 @@
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
-
+
//get jsp include path_info from request object
String relPath=(String)request.getAttribute("javax.servlet.include.path_info");
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/NutchHttpServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/NutchHttpServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/NutchHttpServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/NutchHttpServlet.java Fri Dec 1 13:38:33 2006
@@ -25,50 +25,54 @@
import org.apache.nutch.webapp.common.ServletContextServiceLocator;
/**
- * Abstract base Servlet for nutch
+ * Abstract base Servlet for nutch.
*/
-public abstract class NutchHttpServlet extends HttpServlet{
+public abstract class NutchHttpServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private ServiceLocator locator;
-
+
public void init(final ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
- locator = ServletContextServiceLocator.getInstance(getServletContext());
+ locator = ServletContextServiceLocator.getInstance(getServletContext());
}
-
+
/**
- * Return context relative path
- *
+ * Return context relative path.
+ *
* @return
*/
public String getContextRelativePath(final HttpServletRequest request) {
return request.getRequestURI().substring(request.getContextPath().length());
}
-
+
/**
- * Removes the first part of path String and returns new String
- * if there is no path available return null
- * @param path original path
+ * Removes the first part of path String and returns new String if there is no
+ * path available return null.
+ *
+ * @param path
+ * original path
* @return
*/
- public String getMappingRelativePath(final String path){
-
- String relPath=null;
-
- if(path.indexOf("/",(path.startsWith("/")?1:0))!=-1){
- relPath=path.substring(path.indexOf('/',(path.startsWith("/")?1:0)));
- }
-
+ public String getMappingRelativePath(final String path) {
+
+ String relPath = null;
+
+ if (path.indexOf("/", (path.startsWith("/") ? 1 : 0)) != -1) {
+ relPath = path.substring(path
+ .indexOf('/', (path.startsWith("/") ? 1 : 0)));
+ }
+
return relPath;
}
/**
* Get ServiceLocator instance
+ *
* @return
*/
- public ServiceLocator getServiceLocator(){
+ public ServiceLocator getServiceLocator() {
return locator;
}
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/OpenSearchServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/OpenSearchServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/OpenSearchServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/OpenSearchServlet.java Fri Dec 1 13:38:33 2006
@@ -19,17 +19,20 @@
import java.io.IOException;
import java.net.URLEncoder;
-import java.util.Map;
import java.util.HashMap;
-import java.util.Set;
import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
-import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import javax.xml.parsers.*;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
import org.apache.nutch.searcher.Hit;
import org.apache.nutch.searcher.HitDetails;
@@ -37,17 +40,18 @@
import org.apache.nutch.searcher.NutchBean;
import org.apache.nutch.searcher.Query;
import org.apache.nutch.searcher.Summary;
-import org.w3c.dom.*;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* Present search results using A9's OpenSearch extensions to RSS, plus a few
* Nutch-specific extensions.
*/
public class OpenSearchServlet extends NutchHttpServlet {
+ private static final int DEFAULT_NUMBER_OF_HITS = 10;
+
private static final long serialVersionUID = 1L;
private static final Map NS_MAP = new HashMap();
@@ -75,19 +79,22 @@
// get parameters from request
request.setCharacterEncoding("UTF-8");
String queryString = request.getParameter("query");
- if (queryString == null)
+ if (queryString == null) {
queryString = "";
+ }
String urlQuery = URLEncoder.encode(queryString, "UTF-8");
int start = 0; // first hit to display
String startString = request.getParameter("start");
- if (startString != null)
+ if (startString != null) {
start = Integer.parseInt(startString);
+ }
- int hitsPerPage = 10; // number of hits to display
+ int hitsPerPage = DEFAULT_NUMBER_OF_HITS; // number of hits to display
String hitsString = request.getParameter("hitsPerPage");
- if (hitsString != null)
+ if (hitsString != null) {
hitsPerPage = Integer.parseInt(hitsString);
+ }
String sort = request.getParameter("sort");
boolean reverse = sort != null
@@ -119,14 +126,15 @@
+ (reverse ? "&reverse=true" : "")
+ (dedupField == null ? "" : "&dedupField=" + dedupField));
- Query query = Query.parse(queryString, getServiceLocator().getConfiguration());
+ Query query = Query.parse(queryString, getServiceLocator()
+ .getConfiguration());
NutchBean.LOG.info("query: " + queryString);
// execute the query
Hits hits;
try {
- hits = getServiceLocator().getNutchBean().search(query, start + hitsPerPage, hitsPerDup, dedupField,
- sort, reverse);
+ hits = getServiceLocator().getNutchBean().search(query,
+ start + hitsPerPage, hitsPerDup, dedupField, sort, reverse);
} catch (IOException e) {
NutchBean.LOG.warn("Search Error", e);
hits = new Hits(0, new Hit[0]);
@@ -140,7 +148,8 @@
Hit[] show = hits.getHits(start, end - start);
HitDetails[] details = getServiceLocator().getNutchBean().getDetails(show);
- Summary[] summaries = getServiceLocator().getNutchBean().getSummary(details, query);
+ Summary[] summaries = getServiceLocator().getNutchBean().getSummary(
+ details, query);
String requestUrl = request.getRequestURL().toString();
String base = requestUrl.substring(0, requestUrl.lastIndexOf('/'));
@@ -188,8 +197,10 @@
String url = detail.getValue("url");
String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo();
- if (title == null || title.equals("")) // use url for docs w/o title
+ if (title == null || title.equals("")) {
+ // use url for docs w/o title
title = url;
+ }
Element item = addNode(doc, channel, "item");
@@ -212,8 +223,9 @@
for (int j = 0; j < detail.getLength(); j++) { // add all from detail
String field = detail.getField(j);
- if (!SKIP_DETAILS.contains(field))
+ if (!SKIP_DETAILS.contains(field)) {
addNode(doc, item, "nutch", field, detail.getValue(j));
+ }
}
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/ResourceServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/ResourceServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/ResourceServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/servlet/ResourceServlet.java Fri Dec 1 13:38:33 2006
@@ -28,11 +28,11 @@
/**
* Simple Servlet that serves resources from plugins.
- *
+ *
* Plugin must put resources to be exposed into path /resources/ for example
* resource /resources/possible/sub/folder/resource.jpg will then be available
* in location <contextPath>/resources/<plugin_id>/possible/sub/folder/resource.jpg
- *
+ *
*/
public class ResourceServlet extends NutchHttpServlet {
@@ -41,8 +41,8 @@
private static final long serialVersionUID = 1L;
/**
- * Extract plugin id from path
- *
+ * Extract plugin id from path.
+ *
* @param path
* @return
*/
@@ -59,8 +59,8 @@
}
/**
- * Extract plugin relative path from path
- *
+ * Extract plugin relative path from path.
+ *
* @param path
* @return
*/
@@ -96,7 +96,8 @@
byte[] buffer = new byte[response.getBufferSize()];
int len;
- String contentType = getServletContext().getMimeType(path).toString();
+ String contentType = getServletContext().getMimeType(path)
+ .toString();
response.setContentType(contentType);
while ((len = is.read(buffer)) != -1) {
@@ -110,7 +111,7 @@
}
}
}
-
+
//of no resource was found dispay error
response.setContentType("text/plain");
PrintWriter pw = response.getWriter();
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/ExtendableDefinitionsFactory.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/ExtendableDefinitionsFactory.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/ExtendableDefinitionsFactory.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/ExtendableDefinitionsFactory.java Fri Dec 1 13:38:33 2006
@@ -48,13 +48,14 @@
import org.xml.sax.SAXException;
/**
- * Tiles DefinitionsFactory that can be extended by activated plugins
+ * Tiles DefinitionsFactory that can be extended by activated plugins.
*/
public class ExtendableDefinitionsFactory implements DefinitionsFactory {
private static final long serialVersionUID = 1L;
- public static final Log LOG = LogFactory.getLog(ExtendableDefinitionsFactory.class);
+ public static final Log LOG = LogFactory
+ .getLog(ExtendableDefinitionsFactory.class);
DefinitionsFactoryConfig config;
@@ -66,23 +67,12 @@
HashMap locales = new HashMap();
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.DefinitionsFactory#getDefinition(java.lang.String,
- * javax.servlet.ServletRequest, javax.servlet.ServletContext)
- */
public ComponentDefinition getDefinition(String name, ServletRequest request,
ServletContext servletContext) throws NoSuchDefinitionException,
DefinitionsFactoryException {
return (ComponentDefinition) definitions.get(name);
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.xmlDefinition.DefinitionsFactory#putDefinition(org.apache.struts.tiles.ComponentDefinition)
- */
public void putDefinition(ComponentDefinition definition) {
LOG.info("putting definition:" + definition.getName());
definitions.put(definition.getName(), definition);
@@ -96,7 +86,7 @@
protected XmlDefinitionsSet getDefinitions() {
LOG.debug("getDefinitions()");
-
+
XmlDefinitionsSet definitions = new XmlDefinitionsSet();
//
// core definitions
@@ -109,9 +99,9 @@
InputStream input = servletContext.getResourceAsStream(files[i]);
LOG.info("Stream: " + input);
-
+
if (input != null) {
- parseXMLDefinitionSet(input, definitions, files[i], "nutch-core");
+ parseXMLDefinitionSet(input, definitions, files[i], "nutch-core");
} else {
LOG.info("Cannot find static " + files[i]);
}
@@ -138,7 +128,8 @@
addToSet(definitions, extension);
}
} else {
- LOG.info("Cannot find extension point '" + UIExtensionPoint.X_POINT_ID + "'");
+ LOG.info("Cannot find extension point '" + UIExtensionPoint.X_POINT_ID
+ + "'");
}
try {
@@ -169,8 +160,8 @@
protected void parseXMLDefinitionSet(InputStream input,
XmlDefinitionsSet definitions, String info, String pluginid) {
- XmlDefinitionsSet newSet=new XmlDefinitionsSet();
-
+ XmlDefinitionsSet newSet = new XmlDefinitionsSet();
+
try {
xmlParser.parse(input, newSet);
} catch (IOException e) {
@@ -183,31 +174,25 @@
e.printStackTrace();
}
-// LOG.info("Definitions:" + definitions.getDefinitions().size() + " : "
-// + definitions.toString());
-
- copySet(definitions,newSet);
-
+ // LOG.info("Definitions:" + definitions.getDefinitions().size() + " : "
+ // + definitions.toString());
+
+ copySet(definitions, newSet);
+
}
private void copySet(XmlDefinitionsSet definitions2, XmlDefinitionsSet newSet) {
-
- Iterator iterator=newSet.getDefinitions().keySet().iterator();
-
- while(iterator.hasNext()){
- String key=(String)iterator.next();
+
+ Iterator iterator = newSet.getDefinitions().keySet().iterator();
+
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
LOG.info("adding: " + key);
- XmlDefinition value=newSet.getDefinition(key);
+ XmlDefinition value = newSet.getDefinition(key);
definitions2.putDefinition(value);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.DefinitionsFactory#init(org.apache.struts.tiles.DefinitionsFactoryConfig,
- * javax.servlet.ServletContext)
- */
public void init(DefinitionsFactoryConfig config,
ServletContext servletContext) throws DefinitionsFactoryException {
this.config = config;
@@ -227,22 +212,23 @@
this.definitions = definitions.getDefinitions();
}
-
+
private void initDefinitions(XmlDefinitionsSet definitions) {
Iterator i = definitions.getDefinitions().keySet().iterator();
while (i.hasNext()) {
String key = (String) i.next();
- if(LOG.isDebugEnabled()){
+ if (LOG.isDebugEnabled()) {
LOG.debug("Initializing controller: " + key);
}
XmlDefinition d = definitions.getDefinition(key);
try {
- Controller controller=d.getOrCreateController();
- if(controller!=null){
- //check if it is implementing Startable, if so execute lifecycle method
- if(controller instanceof Startable) {
- ((Startable)controller).start(servletContext);
+ Controller controller = d.getOrCreateController();
+ if (controller != null) {
+ // check if it is implementing Startable, if so execute lifecycle
+ // method
+ if (controller instanceof Startable) {
+ ((Startable) controller).start(servletContext);
}
}
} catch (Exception e) {
@@ -251,21 +237,10 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.DefinitionsFactory#destroy()
- */
public void destroy() {
LOG.info("destroy()");
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.struts.tiles.DefinitionsFactory#setConfig(org.apache.struts.tiles.DefinitionsFactoryConfig,
- * javax.servlet.ServletContext)
- */
public void setConfig(DefinitionsFactoryConfig config,
ServletContext servletContext) throws DefinitionsFactoryException {
this.config = config;
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/NutchRequestProcessor.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/NutchRequestProcessor.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/NutchRequestProcessor.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/tiles/NutchRequestProcessor.java Fri Dec 1 13:38:33 2006
@@ -26,7 +26,7 @@
public class NutchRequestProcessor extends TilesRequestProcessor {
-
+
/**
* Process locale, override the default functionality and prevent
* session from being created.
@@ -34,12 +34,13 @@
protected void processLocale(HttpServletRequest request,
HttpServletResponse response) {
- ServiceLocator locator=WebappInstanceServiceLocator.getFrom(request);
+ ServiceLocator locator = WebappInstanceServiceLocator.getFrom(request);
- if(locator==null) {
- locator=new WebappInstanceServiceLocator(request, getServletContext());
- WebappInstanceServiceLocator.register(request, (WebappInstanceServiceLocator)locator);
- }
+ if (locator == null) {
+ locator = new WebappInstanceServiceLocator(request, getServletContext());
+ WebappInstanceServiceLocator.register(request,
+ (WebappInstanceServiceLocator) locator);
+ }
Config.set(request, Config.FMT_LOCALE, locator.getLocale());
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/test/org/apache/nutch/webapp/servlet/TestNutchHttpServlet.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/src/main/test/org/apache/nutch/webapp/servlet/TestNutchHttpServlet.java?view=diff&rev=481407&r1=481406&r2=481407
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/test/org/apache/nutch/webapp/servlet/TestNutchHttpServlet.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/test/org/apache/nutch/webapp/servlet/TestNutchHttpServlet.java Fri Dec 1 13:38:33 2006
@@ -20,15 +20,15 @@
public class TestNutchHttpServlet extends TestCase {
- /*
- * Test method for 'org.apache.nutch.webapp.servlet.NutchHttpServlet.getMappingRelativePath(String)'
- */
public void testGetMappingRelativePath() {
-
- NutchHttpServlet servlet=new NutchHttpServlet(){};
- assertEquals(null,servlet.getMappingRelativePath("test.jsp"));
- assertEquals("/kissa.jsp",servlet.getMappingRelativePath("/somepath/kissa.jsp"));
- assertEquals("/kissa.jsp",servlet.getMappingRelativePath("somepath/kissa.jsp"));
+ NutchHttpServlet servlet = new NutchHttpServlet() {
+ };
+
+ assertEquals(null, servlet.getMappingRelativePath("test.jsp"));
+ assertEquals("/kissa.jsp", servlet
+ .getMappingRelativePath("/somepath/kissa.jsp"));
+ assertEquals("/kissa.jsp", servlet
+ .getMappingRelativePath("somepath/kissa.jsp"));
}
}