From 304ca0b12a91ecaa3eac81bc65e308031c2456b8 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Jan 2012 20:39:15 +0100 Subject: [PATCH 01/17] add support for development in netbeans imported project from eclipse, now netbeans will automatically recognize project folder, link needed libraries, build scripts etc. Just do Open project... Signed-off-by: Marek Otahal --- .gitignore | 3 + nb-build.xml | 74 +++ nbproject/build-impl.xml | 1123 +++++++++++++++++++++++++++++++++ nbproject/genfiles.properties | 8 + nbproject/project.properties | 169 +++++ nbproject/project.xml | 22 + 6 files changed, 1399 insertions(+) create mode 100644 nb-build.xml create mode 100644 nbproject/build-impl.xml create mode 100644 nbproject/genfiles.properties create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml diff --git a/.gitignore b/.gitignore index 9fa982899..c21ca6b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ DATA/ classes/ RELEASE/ /yacy.pid +/nbproject/private/ +/build/ +/dist/ \ No newline at end of file diff --git a/nb-build.xml b/nb-build.xml new file mode 100644 index 000000000..e5c8d4252 --- /dev/null +++ b/nb-build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project yacy. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 000000000..81cced36a --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set htroot.dir + Must set api.dir + Must set env.dir + Must set yacy.dir + Must set bookmarks.dir + Must set ymarks.dir + Must set posts.dir + Must set tags.dir + Must set xbel.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 000000000..ae158eb93 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +nb-build.xml.data.CRC32=c1d508a7 +nb-build.xml.script.CRC32=812fb2fd +nb-build.xml.stylesheet.CRC32=28e38971@1.50.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=c1d508a7 +nbproject/build-impl.xml.script.CRC32=ec466945 +nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 000000000..5d3d8bbe5 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,169 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +api.dir=${file.reference.htroot-api} +auxiliary.org-netbeans-modules-projectimport-eclipse-core.key=src=source;src=htroot;src=htroot/api;src=htroot/env;src=htroot/yacy;src=htroot/api/bookmarks;src=htroot/api/ymarks;src=htroot/api/bookmarks/posts;src=htroot/api/bookmarks/tags;src=htroot/api/bookmarks/xbel;file=lib/commons-logging-1.1.1.jar;file=lib/servlet-api.jar;file=lib/bzip2.jar;file=lib/J7Zip-modified.jar;file=lib/webcat-0.1-swf.jar;file=lib/activation.jar;file=lib/commons-jxpath-1.3.jar;file=lib/poi-3.6-20091214.jar;file=lib/poi-scratchpad-3.6-20091214.jar;file=lib/bcmail-jdk15-145.jar;file=lib/bcprov-jdk15-145.jar;file=lib/jsch-0.1.42.jar;file=lib/jakarta-oro-2.0.8.jar;file=lib/commons-codec-1.4.jar;file=lib/mysql-connector-java-5.1.12-bin.jar;file=lib/jcifs-1.3.15.jar;file=lib/metadata-extractor-2.4.0-beta-1.jar;file=lib/httpclient-4.1.2.jar;file=lib/httpcore-4.1.3.jar;file=lib/httpmime-4.1.2.jar;file=lib/apache-mime4j-0.6.jar;file=lib/commons-fileupload-1.2.2.jar;file=lib/log4j-1.2.16.jar;file=lib/json-simple-1.1.jar;file=lib/fontbox-1.6.0.jar;file=lib/jempbox-1.6.0.jar;file=lib/pdfbox-1.6.0.jar;file=lib/commons-io-2.0.1.jar;file=lib/xercesImpl.jar;file=lib/xml-apis.jar;file=lib/slf4j-api-1.6.1.jar;file=lib/slf4j-jdk14-1.6.1.jar;file=lib/commons-httpclient-3.1.jar;file=lib/geronimo-stax-api_1.0_spec-1.0.1.jar;file=lib/jcl-over-slf4j-1.6.1.jar;file=lib/wstx-asl-3.2.7.jar;file=lib/apache-solr-solrj-3.4.0.jar;file=lib/icu4j-core.jar;output=gen; +auxiliary.org-netbeans-modules-projectimport-eclipse-core.project=. +auxiliary.org-netbeans-modules-projectimport-eclipse-core.timestamp=1325785600000 +bookmarks.dir=${file.reference.api-bookmarks} +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +buildfile=nb-build.xml +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/yacy.jar +dist.javadoc.dir=${dist.dir}/javadoc +env.dir=${file.reference.htroot-env} +excludes=api/,env/,processing/domaingraph/applet/,yacy/,api/bookmarks/,api/ymarks/,api/bookmarks/posts/,api/bookmarks/tags/,api/bookmarks/xbel/,bookmarks/,ymarks/,bookmarks/posts/,bookmarks/tags/,bookmarks/xbel/,posts/,tags/,xbel/ +file.reference.activation.jar=lib/activation.jar +file.reference.apache-mime4j-0.6.jar=lib/apache-mime4j-0.6.jar +file.reference.apache-solr-solrj-3.4.0.jar=lib/apache-solr-solrj-3.4.0.jar +file.reference.api-bookmarks=htroot/api/bookmarks +file.reference.api-ymarks=htroot/api/ymarks +file.reference.bcmail-jdk15-145.jar=lib/bcmail-jdk15-145.jar +file.reference.bcprov-jdk15-145.jar=lib/bcprov-jdk15-145.jar +file.reference.bookmarks-posts=htroot/api/bookmarks/posts +file.reference.bookmarks-tags=htroot/api/bookmarks/tags +file.reference.bookmarks-xbel=htroot/api/bookmarks/xbel +file.reference.bzip2.jar=lib/bzip2.jar +file.reference.commons-codec-1.4.jar=lib/commons-codec-1.4.jar +file.reference.commons-fileupload-1.2.2.jar=lib/commons-fileupload-1.2.2.jar +file.reference.commons-httpclient-3.1.jar=lib/commons-httpclient-3.1.jar +file.reference.commons-io-2.0.1.jar=lib/commons-io-2.0.1.jar +file.reference.commons-jxpath-1.3.jar=lib/commons-jxpath-1.3.jar +file.reference.commons-logging-1.1.1.jar=lib/commons-logging-1.1.1.jar +file.reference.fontbox-1.6.0.jar=lib/fontbox-1.6.0.jar +file.reference.geronimo-stax-api_1.0_spec-1.0.1.jar=lib/geronimo-stax-api_1.0_spec-1.0.1.jar +file.reference.htroot-api=htroot/api +file.reference.htroot-env=htroot/env +file.reference.htroot-yacy=htroot/yacy +file.reference.httpclient-4.1.2.jar=lib/httpclient-4.1.2.jar +file.reference.httpcore-4.1.3.jar=lib/httpcore-4.1.3.jar +file.reference.httpmime-4.1.2.jar=lib/httpmime-4.1.2.jar +file.reference.icu4j-core.jar=lib/icu4j-core.jar +file.reference.J7Zip-modified.jar=lib/J7Zip-modified.jar +file.reference.jakarta-oro-2.0.8.jar=lib/jakarta-oro-2.0.8.jar +file.reference.jcifs-1.3.15.jar=lib/jcifs-1.3.15.jar +file.reference.jcl-over-slf4j-1.6.1.jar=lib/jcl-over-slf4j-1.6.1.jar +file.reference.jempbox-1.6.0.jar=lib/jempbox-1.6.0.jar +file.reference.jsch-0.1.42.jar=lib/jsch-0.1.42.jar +file.reference.json-simple-1.1.jar=lib/json-simple-1.1.jar +file.reference.log4j-1.2.16.jar=lib/log4j-1.2.16.jar +file.reference.metadata-extractor-2.4.0-beta-1.jar=lib/metadata-extractor-2.4.0-beta-1.jar +file.reference.mysql-connector-java-5.1.12-bin.jar=lib/mysql-connector-java-5.1.12-bin.jar +file.reference.pdfbox-1.6.0.jar=lib/pdfbox-1.6.0.jar +file.reference.poi-3.6-20091214.jar=lib/poi-3.6-20091214.jar +file.reference.poi-scratchpad-3.6-20091214.jar=lib/poi-scratchpad-3.6-20091214.jar +file.reference.rc1-htroot=htroot +file.reference.rc1-source=source +file.reference.servlet-api.jar=lib/servlet-api.jar +file.reference.slf4j-api-1.6.1.jar=lib/slf4j-api-1.6.1.jar +file.reference.slf4j-jdk14-1.6.1.jar=lib/slf4j-jdk14-1.6.1.jar +file.reference.webcat-0.1-swf.jar=lib/webcat-0.1-swf.jar +file.reference.wstx-asl-3.2.7.jar=lib/wstx-asl-3.2.7.jar +file.reference.xercesImpl.jar=lib/xercesImpl.jar +file.reference.xml-apis.jar=lib/xml-apis.jar +htroot.dir=${file.reference.rc1-htroot} +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.commons-logging-1.1.1.jar}:\ + ${file.reference.servlet-api.jar}:\ + ${file.reference.bzip2.jar}:\ + ${file.reference.J7Zip-modified.jar}:\ + ${file.reference.webcat-0.1-swf.jar}:\ + ${file.reference.activation.jar}:\ + ${file.reference.commons-jxpath-1.3.jar}:\ + ${file.reference.poi-3.6-20091214.jar}:\ + ${file.reference.poi-scratchpad-3.6-20091214.jar}:\ + ${file.reference.bcmail-jdk15-145.jar}:\ + ${file.reference.bcprov-jdk15-145.jar}:\ + ${file.reference.jsch-0.1.42.jar}:\ + ${file.reference.jakarta-oro-2.0.8.jar}:\ + ${file.reference.commons-codec-1.4.jar}:\ + ${file.reference.mysql-connector-java-5.1.12-bin.jar}:\ + ${file.reference.jcifs-1.3.15.jar}:\ + ${file.reference.metadata-extractor-2.4.0-beta-1.jar}:\ + ${file.reference.httpclient-4.1.2.jar}:\ + ${file.reference.httpcore-4.1.3.jar}:\ + ${file.reference.httpmime-4.1.2.jar}:\ + ${file.reference.apache-mime4j-0.6.jar}:\ + ${file.reference.commons-fileupload-1.2.2.jar}:\ + ${file.reference.log4j-1.2.16.jar}:\ + ${file.reference.json-simple-1.1.jar}:\ + ${file.reference.fontbox-1.6.0.jar}:\ + ${file.reference.jempbox-1.6.0.jar}:\ + ${file.reference.pdfbox-1.6.0.jar}:\ + ${file.reference.commons-io-2.0.1.jar}:\ + ${file.reference.xercesImpl.jar}:\ + ${file.reference.xml-apis.jar}:\ + ${file.reference.slf4j-api-1.6.1.jar}:\ + ${file.reference.slf4j-jdk14-1.6.1.jar}:\ + ${file.reference.commons-httpclient-3.1.jar}:\ + ${file.reference.geronimo-stax-api_1.0_spec-1.0.1.jar}:\ + ${file.reference.jcl-over-slf4j-1.6.1.jar}:\ + ${file.reference.wstx-asl-3.2.7.jar}:\ + ${file.reference.apache-solr-solrj-3.4.0.jar}:\ + ${file.reference.icu4j-core.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +posts.dir=${file.reference.bookmarks-posts} +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +source.reference.commons-fileupload-1.2.2.jar=/Users/admin/.m2/repository/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2-sources.jar +source.reference.poi-3.6-20091214.jar=/Users/admin/.m2/repository/org/apache/poi/poi/3.6/poi-3.6-sources.jar +src.dir=${file.reference.rc1-source} +tags.dir=${file.reference.bookmarks-tags} +xbel.dir=${file.reference.bookmarks-xbel} +yacy.dir=${file.reference.htroot-yacy} +ymarks.dir=${file.reference.api-ymarks} diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 000000000..dd6c5fc1b --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,22 @@ + + + org.netbeans.modules.java.j2seproject + + + yacy + + + + + + + + + + + + + + + + From c11ed8a91946b79c829e5bb18be4cc25de24bdba Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Jan 2012 22:15:32 +0100 Subject: [PATCH 02/17] add *.*~ to .gitignore Signed-off-by: Marek Otahal --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c21ca6b2c..0572576b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.class +*.*~ lib/yacycore.jar libbuild/svnRevNr.jar libbuild/GitRevTask.jar @@ -9,4 +10,4 @@ RELEASE/ /yacy.pid /nbproject/private/ /build/ -/dist/ \ No newline at end of file +/dist/ From 8318103f253fa26b69f795fede6827595dd727d3 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Jan 2012 22:23:50 +0100 Subject: [PATCH 03/17] Blacklist addBlacklistEntry() - dont add an empty entry Signed-off-by: Marek Otahal --- htroot/Blacklist_p.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java index 361d1f2bc..b466fcc5e 100644 --- a/htroot/Blacklist_p.java +++ b/htroot/Blacklist_p.java @@ -624,7 +624,11 @@ public class Blacklist_p { String newEntry, final String[] supportedBlacklistTypes) { - // TODO: ignore empty entries + // ignore empty entries + if(newEntry == null || newEntry.isEmpty()) { + Log.logWarning("Blacklist", "skipped adding an empty entry"); + return; + } if (newEntry.startsWith("http://") ){ newEntry = newEntry.substring(7); From f727c357229db4006260788fb323090d111845c0 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Jan 2012 23:17:28 +0100 Subject: [PATCH 04/17] Blog dateString() print in localized date/time format Signed-off-by: Marek Otahal --- htroot/Blog.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htroot/Blog.java b/htroot/Blog.java index a09c7ce67..3af51689f 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -30,8 +30,8 @@ // javac -classpath .:../classes Blog.java // if the shell's current path is HTROOT -import java.text.SimpleDateFormat; import java.util.Date; +import java.text.DateFormat; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -52,9 +52,13 @@ public class Blog { private static final String DEFAULT_PAGE = "blog_default"; - private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); - // TODO: make userdefined date/time-strings (localisation) - + private static DateFormat SimpleFormatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault()); + + /** + * print localized date/time "yyyy/mm/dd HH:mm:ss" + * @param date + * @return + */ public static String dateString(final Date date) { return SimpleFormatter.format(date); } From 7189a70a627846767e8ea9ee782bf85b13e55c62 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Jan 2012 23:23:21 +0100 Subject: [PATCH 05/17] BlogComments dateString() - use localized date/time format use same method from Blog class, reduce code duplication Signed-off-by: Marek Otahal --- htroot/BlogComments.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java index 95d89c076..60808486c 100644 --- a/htroot/BlogComments.java +++ b/htroot/BlogComments.java @@ -32,10 +32,8 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; -import java.util.Locale; import net.yacy.cora.document.UTF8; import net.yacy.cora.protocol.HeaderFramework; @@ -54,11 +52,8 @@ import de.anomic.server.serverSwitch; public class BlogComments { - private final static SimpleDateFormat SIMPLE_FORMATTER = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); - // TODO: make userdefined date/time-strings (localisation) - public static String dateString(final Date date) { - return SIMPLE_FORMATTER.format(date); + return Blog.dateString(date); } public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) { From c1973c78a35e24179ecee927777c9edb8fcaac91 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 00:26:08 +0100 Subject: [PATCH 06/17] Blog + BlogComments method propose() make similar + fix anonymous poster's IP resolve in Blog this method share very much common code in both classes, would be nice to unify +fix some ugly code Signed-off-by: Marek Otahal --- htroot/Blog.java | 22 +++++++++------------- htroot/BlogComments.java | 31 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/htroot/Blog.java b/htroot/Blog.java index 3af51689f..b5570e20f 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -78,11 +78,7 @@ public class Blog { final boolean xml = (header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml"); final String address = sb.peers.mySeed().getPublicAddress(); - if(hasRights) { - prop.put("mode_admin", "1"); - } else { - prop.put("mode_admin", "0"); - } + prop.put("mode_admin", hasRights ? "1" : "0"); if (post == null) { prop.putHTML("peername", sb.peers.mySeed().getName()); @@ -106,22 +102,22 @@ public class Blog { String pagename = post.get("page", DEFAULT_PAGE); final String ip = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1"); - String StrAuthor = post.get("author", ""); + String strAuthor = post.get("author", "anonymous"); - if ("anonymous".equals(StrAuthor)) { - StrAuthor = sb.blogDB.guessAuthor(ip); + if ("anonymous".equals(strAuthor)) { + strAuthor = sb.blogDB.guessAuthor(ip); - if (StrAuthor == null || StrAuthor.length() == 0) { + if (strAuthor == null || strAuthor.length() == 0) { if (sb.peers.mySeed() == null) { - StrAuthor = "anonymous"; + strAuthor = "anonymous"; } else { - StrAuthor = sb.peers.mySeed().get("Name", "anonymous"); + strAuthor = sb.peers.mySeed().get("Name", "anonymous"); } } } byte[] author; - author = UTF8.getBytes(StrAuthor); + author = UTF8.getBytes(strAuthor); if (hasRights && post.containsKey("delete") && "sure".equals(post.get("delete"))) { page = sb.blogDB.readBlogEntry(pagename); @@ -165,7 +161,7 @@ public class Blog { final Map map = new HashMap(); map.put("page", pagename); map.put("subject", StrSubject.replace(',', ' ')); - map.put("author", StrAuthor.replace(',', ' ')); + map.put("author", strAuthor.replace(',', ' ')); sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_BLOG_ADD, map); } } diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java index 60808486c..53fe6eb6e 100644 --- a/htroot/BlogComments.java +++ b/htroot/BlogComments.java @@ -52,6 +52,8 @@ import de.anomic.server.serverSwitch; public class BlogComments { + private static final String DEFAULT_PAGE = "blog_default"; + public static String dateString(final Date date) { return Blog.dateString(date); } @@ -72,32 +74,31 @@ public class BlogComments { final UserDB.Entry userentry = sb.userDB.proxyAuth(header.get(RequestHeader.AUTHORIZATION, "xxxxxx")); if (userentry != null && userentry.hasRight(UserDB.AccessRight.BLOG_RIGHT)) { hasRights = true; - } - //opens login window if login link is clicked - else if (post.containsKey("login")) { + } else if (post.containsKey("login")) { + //opens login window if login link is clicked prop.put("AUTHENTICATE","admin log-in"); } } - final String pagename = post.get("page", "blog_default"); + String pagename = post.get("page", DEFAULT_PAGE); final String ip = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1"); - String StrAuthor = post.get("author", "anonymous"); + String strAuthor = post.get("author", "anonymous"); - if ("anonymous".equals(StrAuthor)) { - StrAuthor = sb.blogDB.guessAuthor(ip); + if ("anonymous".equals(strAuthor)) { + strAuthor = sb.blogDB.guessAuthor(ip); - if (StrAuthor == null || StrAuthor.length() == 0) { + if (strAuthor == null || strAuthor.length() == 0) { if (sb.peers.mySeed() == null) { - StrAuthor = "anonymous"; + strAuthor = "anonymous"; } else { - StrAuthor = sb.peers.mySeed().get("Name", "anonymous"); + strAuthor = sb.peers.mySeed().get("Name", "anonymous"); } } } byte[] author; - author = UTF8.getBytes(StrAuthor); + author = UTF8.getBytes(strAuthor); final BlogBoard.BlogEntry page = sb.blogDB.readBlogEntry(pagename); //maybe "if(page == null)" final boolean pageExists = sb.blogDB.contains(pagename); @@ -127,13 +128,13 @@ public class BlogComments { sb.blogCommentDB.write(sb.blogCommentDB.newEntry(commentID, subject, author, ip, date, content)); prop.putHTML("LOCATION","BlogComments.html?page=" + pagename); - MessageBoard.entry msgEntry = null; - sb.messageDB.write(msgEntry = sb.messageDB.newEntry( + MessageBoard.entry msgEntry = sb.messageDB.newEntry( "blogComment", - StrAuthor, + strAuthor, sb.peers.mySeed().hash, sb.peers.mySeed().getName(), sb.peers.mySeed().hash, - "new blog comment: " + UTF8.String(blogEntry.getSubject()), content)); + "new blog comment: " + UTF8.String(blogEntry.getSubject()), content); + sb.messageDB.write(msgEntry); messageForwardingViaEmail(sb, msgEntry); From 1dc5d9f0f3a7311363835b9db824e05c89039363 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 01:10:05 +0100 Subject: [PATCH 07/17] make ConnectionInfo comparable and sort list of connections in Connections_p ConnectionInfo compare by initTime Connections_p implement wish to sort connections, descending Signed-off-by: Marek Otahal --- htroot/Connections_p.java | 14 ++++++++++---- source/net/yacy/cora/protocol/ConnectionInfo.java | 9 ++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java index 74efaee55..047f54604 100644 --- a/htroot/Connections_p.java +++ b/htroot/Connections_p.java @@ -43,6 +43,9 @@ import de.anomic.server.serverCore; import de.anomic.server.serverCore.Session; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; public final class Connections_p { @@ -141,11 +144,14 @@ public final class Connections_p { // client sessions final Set allConnections = ConnectionInfo.getAllConnections(); - // TODO sorting -// Arrays.sort(a, httpc.connectionTimeComparatorInstance); + // sorting: sort by initTime, decending + List allConnectionsSorted = new LinkedList(allConnections); + Collections.sort(allConnectionsSorted); + Collections.reverse(allConnectionsSorted); // toggle ascending/descending + int c = 0; - synchronized (allConnections) { - for (final ConnectionInfo conInfo: allConnections) { + synchronized (allConnectionsSorted) { + for (final ConnectionInfo conInfo: allConnectionsSorted) { prop.put("clientList_" + c + "_clientProtocol", conInfo.getProtocol()); prop.putNum("clientList_" + c + "_clientLifetime", conInfo.getLifetime()); prop.putNum("clientList_" + c + "_clientUpbytes", conInfo.getUpbytes()); diff --git a/source/net/yacy/cora/protocol/ConnectionInfo.java b/source/net/yacy/cora/protocol/ConnectionInfo.java index c47acb21f..6091a9702 100644 --- a/source/net/yacy/cora/protocol/ConnectionInfo.java +++ b/source/net/yacy/cora/protocol/ConnectionInfo.java @@ -36,7 +36,7 @@ import java.util.Set; * @author daniel * @author sixcooler */ -public class ConnectionInfo { +public class ConnectionInfo implements Comparable { /** * a list of all current connections to be shown in Connections_p */ @@ -270,4 +270,11 @@ public class ConnectionInfo { final ConnectionInfo other = (ConnectionInfo) obj; return this.id == other.id; } + + public int compareTo(ConnectionInfo o) { + if(o==null) throw new NullPointerException("ConnectionInfo: compare() : passed argument is null \n"); + if(this.initTime>o.initTime) return 1; + else if(this.initTime Date: Fri, 6 Jan 2012 01:42:37 +0100 Subject: [PATCH 08/17] little fix in copy() Signed-off-by: Marek Otahal --- source/net/yacy/kelondro/util/FileUtils.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java index 7c7df2a39..29971c4bf 100644 --- a/source/net/yacy/kelondro/util/FileUtils.java +++ b/source/net/yacy/kelondro/util/FileUtils.java @@ -107,11 +107,8 @@ public final class FileUtils dest.flush(); total += c; - if ( count > 0 ) { - chunkSize = (int) Math.min(count - total, DEFAULT_BUFFER_SIZE); - if ( chunkSize == 0 ) { - break; - } + if ( count > 0 && count == total) { + break; } } @@ -130,7 +127,7 @@ public final class FileUtils if ( fis != null ) { try { fis.close(); - } catch ( final Exception e ) { + } catch (Exception e ) { } } } From f40efb39af852f40821290f7425aedf32527f878 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 02:01:20 +0100 Subject: [PATCH 09/17] Blacklist loadList() remove duplicates by using Set Signed-off-by: Marek Otahal --- source/net/yacy/repository/Blacklist.java | 10 ++++++++-- source/net/yacy/search/index/Segment.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java index 76098c2e6..32b4f30c2 100644 --- a/source/net/yacy/repository/Blacklist.java +++ b/source/net/yacy/repository/Blacklist.java @@ -181,6 +181,12 @@ public class Blacklist { } } + /** + * create a blacklist from file, entries separated by 'sep' + * duplicit entries are removed + * @param blFile + * @param sep + */ private void loadList(final BlacklistFile blFile, final String sep) { final Map> blacklistMapMatch = getBlacklistMap(blFile.getType(), true); final Map> blacklistMapNotMatch = getBlacklistMap(blFile.getType(), false); @@ -213,8 +219,8 @@ public class Blacklist { blacklistMapNotMatch.put(loadedEntry.getKey(), loadedPaths); } } else { - // TODO check for duplicates? (refactor List -> Set) - paths.addAll(loadedPaths); + // check for duplicates? (refactor List -> Set) + paths.addAll(new HashSet(loadedPaths)); } } } diff --git a/source/net/yacy/search/index/Segment.java b/source/net/yacy/search/index/Segment.java index e63119cad..20627524e 100644 --- a/source/net/yacy/search/index/Segment.java +++ b/source/net/yacy/search/index/Segment.java @@ -77,9 +77,9 @@ public class Segment { public static final int writeBufferSize = 4 * 1024 * 1024; // the reference factory - public static final ReferenceFactory wordReferenceFactory = new WordReferenceFactory(); + public static final ReferenceFactory wordReferenceFactory = new WordReferenceFactory(); public static final ReferenceFactory navigationReferenceFactory = new NavigationReferenceFactory(); - public static final ByteOrder wordOrder = Base64Order.enhancedCoder; + public static final ByteOrder wordOrder = Base64Order.enhancedCoder; private final Log log; protected final IndexCell termIndex; From ed253b7affa21dd79d5dca62fa892dea2390bd72 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 05:30:04 +0100 Subject: [PATCH 10/17] update javadoc, does not throw IOException Signed-off-by: Marek Otahal --- source/de/anomic/http/client/Cache.java | 1 - 1 file changed, 1 deletion(-) diff --git a/source/de/anomic/http/client/Cache.java b/source/de/anomic/http/client/Cache.java index 8eba2c6c1..b886d1924 100644 --- a/source/de/anomic/http/client/Cache.java +++ b/source/de/anomic/http/client/Cache.java @@ -222,7 +222,6 @@ public final class Cache { * @return the resource content as byte[]. If no data * is available or the cached file is not readable, null * is returned. - * @throws IOException */ public static byte[] getContent(final byte[] hash) { // load the url as resource from the cache From 6d8faa80667ba5d936e260b27974b42d5a08fca5 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 05:41:54 +0100 Subject: [PATCH 11/17] small fix Signed-off-by: Marek Otahal --- htroot/CacheResource_p.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htroot/CacheResource_p.java b/htroot/CacheResource_p.java index 1007cd4e9..e468b144e 100644 --- a/htroot/CacheResource_p.java +++ b/htroot/CacheResource_p.java @@ -53,8 +53,7 @@ public class CacheResource_p { return prop; } - byte[] resource = null; - resource = Cache.getContent(url.hash()); + byte[] resource = Cache.getContent(url.hash()); if (resource == null) return prop; // check request type From 371fbb4deb456788192b3583561ca6633033925c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 20:23:38 +0100 Subject: [PATCH 12/17] just comment + shorter code in serverSwitch Signed-off-by: Marek Otahal --- source/de/anomic/server/serverSwitch.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java index 864fbc489..8adf78ce2 100644 --- a/source/de/anomic/server/serverSwitch.java +++ b/source/de/anomic/server/serverSwitch.java @@ -165,18 +165,18 @@ public class serverSwitch (int) getConfigLong("server.maxTrackingHostCount", 100)); } + /** + * get my public IP, either set statically or figure out dynamic + * @return + */ public String myPublicIP() { // if a static IP was configured, we have to return it here ... final String staticIP = getConfig("staticIP", ""); - if ( staticIP.length() > 0 ) { - return staticIP; - } + if ( !"".equals(staticIP) ) return staticIP; // otherwise we return the real IP address of this host final InetAddress pLIP = Domains.myPublicLocalIP(); - if ( pLIP != null ) { - return pLIP.getHostAddress(); - } + if ( pLIP != null ) return pLIP.getHostAddress(); return null; } @@ -189,6 +189,10 @@ public class serverSwitch return this.log; } + /** + * add whole map of key-value pairs to config + * @param otherConfigs + */ public void setConfig(final Map otherConfigs) { final Iterator> i = otherConfigs.entrySet().iterator(); Map.Entry entry; @@ -326,6 +330,9 @@ public class serverSwitch return this.configProps.keySet().iterator(); } + /** + * write the changes to permanent storage (File) + */ private void saveConfig() { ConcurrentMap configPropsCopy = new ConcurrentHashMap(); configPropsCopy.putAll(this.configProps); // avoid concurrency problems From 64e4bcee823c22eb38250dd52744c26c8f0d2a6c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 20:41:30 +0100 Subject: [PATCH 13/17] serverSwitch get(App/Data)Path() use common helper method Signed-off-by: Marek Otahal --- source/de/anomic/server/serverSwitch.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java index 8adf78ce2..122d8730a 100644 --- a/source/de/anomic/server/serverSwitch.java +++ b/source/de/anomic/server/serverSwitch.java @@ -311,19 +311,23 @@ public class serverSwitch * the relative path setting. */ public File getDataPath(final String key, final String dflt) { - File ret; - final String path = getConfig(key, dflt).replace('\\', '/'); - final File f = new File(path); - ret = (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(this.dataPath, path)); - return ret; + return getFileByPath(key, dflt, dataPath); } + /** + * return file at path from config entry "key", or fallback to default dflt + * @param key + * @param dflt + * @return + */ public File getAppPath(final String key, final String dflt) { - File ret; + return getFileByPath(key, dflt, appPath); + } + + private File getFileByPath(String key, String dflt, File prefix) { final String path = getConfig(key, dflt).replace('\\', '/'); final File f = new File(path); - ret = (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(this.appPath, path)); - return ret; + return (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(prefix, path)); } public Iterator configKeys() { From c1af123ddd3f4ff837e5be2e4810663c1a7ed086 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 21:36:45 +0100 Subject: [PATCH 14/17] just a little faster toString Signed-off-by: Marek Otahal --- source/de/anomic/server/serverObjects.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java index 9cf1f1fd2..579ac5c52 100644 --- a/source/de/anomic/server/serverObjects.java +++ b/source/de/anomic/server/serverObjects.java @@ -418,10 +418,10 @@ public class serverObjects extends HashMap implements Cloneable if (isEmpty()) return ""; final StringBuilder param = new StringBuilder(size() * 40); for (final Map.Entry entry: entrySet()) { - param.append(MultiProtocolURI.escape(entry.getKey())); - param.append('='); - param.append(MultiProtocolURI.escape(entry.getValue())); - param.append('&'); + param.append(MultiProtocolURI.escape(entry.getKey())) + .append('=') + .append(MultiProtocolURI.escape(entry.getValue())) + .append('&'); } param.setLength(param.length() - 1); return param.toString(); From 72adbeae90120840ec67fd1ddd963f4ca270c73f Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 7 Jan 2012 00:38:42 +0100 Subject: [PATCH 15/17] !Important: move from Hashtable to HashMap Hashtable is an obsolete collection v1, now since v2 offers HashMap with same or better functionality. Please review, almost all code was already moved, so only a few changes. That is not the issue, but I found notices that some (ugly big) helper classes had to be created in past to compensate missing Hashtable's functionality. I'd like input if we can remove some of them. look for //FIX: if these commits Signed-off-by: Marek Otahal --- source/de/anomic/data/Translator.java | 2 +- source/de/anomic/http/server/TemplateEngine.java | 6 +++--- source/de/anomic/server/serverObjects.java | 1 + source/de/anomic/tools/loaderThreads.java | 10 ++++++---- source/net/yacy/document/importer/OAIPMHImporter.java | 1 + source/net/yacy/kelondro/util/ByteArray.java | 2 ++ source/net/yacy/kelondro/util/OS.java | 6 +++--- source/net/yacy/peers/SeedDB.java | 10 +++++----- source/net/yacy/search/Switchboard.java | 3 +-- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/source/de/anomic/data/Translator.java b/source/de/anomic/data/Translator.java index 15c16052d..17a4cb68e 100644 --- a/source/de/anomic/data/Translator.java +++ b/source/de/anomic/data/Translator.java @@ -80,7 +80,7 @@ public class Translator { /** * Load multiple translationLists from one File. Each List starts with #File: relative/path/to/file * @param translationFile the File, which contains the Lists - * @return a Hashtable, which contains for each File a Hashtable with translations. + * @return a HashMap, which contains for each File a HashMap with translations. */ public static Map> loadTranslationsLists(final File translationFile){ final Map> lists = new HashMap>(); //list of translationLists for different files. diff --git a/source/de/anomic/http/server/TemplateEngine.java b/source/de/anomic/http/server/TemplateEngine.java index 499ed5e0a..a047689f7 100644 --- a/source/de/anomic/http/server/TemplateEngine.java +++ b/source/de/anomic/http/server/TemplateEngine.java @@ -87,10 +87,10 @@ import net.yacy.kelondro.util.FileUtils; * </body></html> * *

- * The corresponding Hashtable to use this Template:
+ * The corresponding HashMap to use this Template:
* Java Example
*

- * Hashtable pattern;
+ * HashMap pattern;
  * pattern.put("times", 10); //10 greetings
  * for(int i=0;i<=9;i++){
  * 	pattern.put("times_"+i+"_daytime", 1); //index: 1, second Entry, evening
@@ -112,7 +112,7 @@ import net.yacy.kelondro.util.FileUtils;
  * 
  • Multi templates: multitemplatename_index_
  • *
  • Alterantives: alternativename_
  • * - * So the Names in the Hashtable are: + * So the Names in the HashMap are: *
      *
    • Multi templates: multitemplatename_index_templatename
    • *
    • Alterantives: alternativename_templatename
    • diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java index 579ac5c52..46d25502f 100644 --- a/source/de/anomic/server/serverObjects.java +++ b/source/de/anomic/server/serverObjects.java @@ -33,6 +33,7 @@ Properties - setProperty would be needed, but only available in 1.2 HashMap, TreeMap - only in 1.2 Hashtable - available in 1.0, but 'put' does not accept null values +//FIXME: it's 2012, do we still need support for Java 1.0?! So this class was created as a convenience. It will also contain special methods that read data from internet-resources diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.java index 7a061b4e2..176525bda 100644 --- a/source/de/anomic/tools/loaderThreads.java +++ b/source/de/anomic/tools/loaderThreads.java @@ -24,7 +24,9 @@ package de.anomic.tools; -import java.util.Hashtable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.http.ProxySettings; @@ -39,8 +41,8 @@ public class loaderThreads { protected ProxySettings remoteProxyConfig; // management objects for collection of threads - Hashtable threads; - int completed, failed; + private Map threads; + private int completed, failed; public loaderThreads() { this(10000, null, null); @@ -54,7 +56,7 @@ public class loaderThreads { this.timeout = timeout; this.user = user; this.password = password; - this.threads = new Hashtable(); + this.threads = new HashMap(); this.completed = 0; this.failed = 0; } diff --git a/source/net/yacy/document/importer/OAIPMHImporter.java b/source/net/yacy/document/importer/OAIPMHImporter.java index a97c0b06a..8985f6686 100644 --- a/source/net/yacy/document/importer/OAIPMHImporter.java +++ b/source/net/yacy/document/importer/OAIPMHImporter.java @@ -118,6 +118,7 @@ public class OAIPMHImporter extends Thread implements Importer, Comparable 50) { try {Thread.sleep(10000 + 3000 * (System.currentTimeMillis() % 6));} catch (InterruptedException e) {} diff --git a/source/net/yacy/kelondro/util/ByteArray.java b/source/net/yacy/kelondro/util/ByteArray.java index eb4810818..0ac0b633a 100644 --- a/source/net/yacy/kelondro/util/ByteArray.java +++ b/source/net/yacy/kelondro/util/ByteArray.java @@ -37,6 +37,8 @@ import net.yacy.cora.order.ByteOrder; * a byte[] in a Hashtable does not work because the hash computation does not * work for byte[]. This class extends byte[] with a cached hashing function, * so it can be used in hashtables. + * //FIXME: so does storing byte[] in HashMap help? as I'm moving use of Hashtable to + * //FIXME: HashMap, if so, please remove this class- or notify me */ public class ByteArray { diff --git a/source/net/yacy/kelondro/util/OS.java b/source/net/yacy/kelondro/util/OS.java index 6c38396f8..72378dc91 100644 --- a/source/net/yacy/kelondro/util/OS.java +++ b/source/net/yacy/kelondro/util/OS.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.lang.management.ManagementFactory; import java.util.ArrayList; -import java.util.Hashtable; import java.util.List; import java.util.Properties; import java.util.Vector; @@ -35,6 +34,7 @@ import java.util.Vector; import net.yacy.cora.document.UTF8; import net.yacy.kelondro.logging.Log; import de.anomic.server.serverCore; +import java.util.*; public final class OS { @@ -63,8 +63,8 @@ public final class OS { public static int maxPathLength = 65535; // Macintosh-specific statics - public static final Hashtable macFSTypeCache = new Hashtable(); - public static final Hashtable macFSCreatorCache = new Hashtable(); + public static final Map macFSTypeCache = new HashMap(); + public static final Map macFSCreatorCache = new HashMap(); // static initialization static { diff --git a/source/net/yacy/peers/SeedDB.java b/source/net/yacy/peers/SeedDB.java index cb631d1f2..f5a11642d 100644 --- a/source/net/yacy/peers/SeedDB.java +++ b/source/net/yacy/peers/SeedDB.java @@ -33,7 +33,7 @@ import java.lang.ref.SoftReference; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashSet; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -98,8 +98,8 @@ public final class SeedDB implements AlternativeDomainNames { private Seed mySeed; // my own seed private final Set myBotIDs; // list of id's that this bot accepts as robots.txt identification - private final Hashtable nameLookupCache; // a name-to-hash relation - private final Hashtable> ipLookupCache; + private final Map nameLookupCache; // a name-to-hash relation + private final Map> ipLookupCache; public SeedDB( final File networkRoot, @@ -129,10 +129,10 @@ public final class SeedDB implements AlternativeDomainNames { this.seedPotentialDB = openSeedTable(this.seedPotentialDBFile); // start our virtual DNS service for yacy peers with empty cache - this.nameLookupCache = new Hashtable(); + this.nameLookupCache = new HashMap(); // cache for reverse name lookup - this.ipLookupCache = new Hashtable>(); + this.ipLookupCache = new HashMap>(); // check if we are in the seedCaches: this can happen if someone else published our seed removeMySeed(); diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index cd72ffb02..16c75c348 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -56,7 +56,6 @@ import java.security.spec.InvalidKeySpecException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -260,7 +259,7 @@ public final class Switchboard extends serverSwitch //private Object crawlingPausedSync = new Object(); //private boolean crawlingIsPaused = false; - public Hashtable crawlJobsStatus = new Hashtable(); + public HashMap crawlJobsStatus = new HashMap(); private static Switchboard sb = null; From a9f0843e75270d6b8a3fe8cf0d7bdcc245dc721d Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sun, 8 Jan 2012 16:06:26 +0100 Subject: [PATCH 16/17] netbeans: build script: make compressed jar w/ all libraries + other improvements FIXME: run ant clean all on each clean/rebuild --- nbproject/project.properties | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 5d3d8bbe5..0b2c89444 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,10 +1,11 @@ annotation.processing.enabled=true annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output api.dir=${file.reference.htroot-api} +application.title=yacy +application.vendor=marek auxiliary.org-netbeans-modules-projectimport-eclipse-core.key=src=source;src=htroot;src=htroot/api;src=htroot/env;src=htroot/yacy;src=htroot/api/bookmarks;src=htroot/api/ymarks;src=htroot/api/bookmarks/posts;src=htroot/api/bookmarks/tags;src=htroot/api/bookmarks/xbel;file=lib/commons-logging-1.1.1.jar;file=lib/servlet-api.jar;file=lib/bzip2.jar;file=lib/J7Zip-modified.jar;file=lib/webcat-0.1-swf.jar;file=lib/activation.jar;file=lib/commons-jxpath-1.3.jar;file=lib/poi-3.6-20091214.jar;file=lib/poi-scratchpad-3.6-20091214.jar;file=lib/bcmail-jdk15-145.jar;file=lib/bcprov-jdk15-145.jar;file=lib/jsch-0.1.42.jar;file=lib/jakarta-oro-2.0.8.jar;file=lib/commons-codec-1.4.jar;file=lib/mysql-connector-java-5.1.12-bin.jar;file=lib/jcifs-1.3.15.jar;file=lib/metadata-extractor-2.4.0-beta-1.jar;file=lib/httpclient-4.1.2.jar;file=lib/httpcore-4.1.3.jar;file=lib/httpmime-4.1.2.jar;file=lib/apache-mime4j-0.6.jar;file=lib/commons-fileupload-1.2.2.jar;file=lib/log4j-1.2.16.jar;file=lib/json-simple-1.1.jar;file=lib/fontbox-1.6.0.jar;file=lib/jempbox-1.6.0.jar;file=lib/pdfbox-1.6.0.jar;file=lib/commons-io-2.0.1.jar;file=lib/xercesImpl.jar;file=lib/xml-apis.jar;file=lib/slf4j-api-1.6.1.jar;file=lib/slf4j-jdk14-1.6.1.jar;file=lib/commons-httpclient-3.1.jar;file=lib/geronimo-stax-api_1.0_spec-1.0.1.jar;file=lib/jcl-over-slf4j-1.6.1.jar;file=lib/wstx-asl-3.2.7.jar;file=lib/apache-solr-solrj-3.4.0.jar;file=lib/icu4j-core.jar;output=gen; auxiliary.org-netbeans-modules-projectimport-eclipse-core.project=. auxiliary.org-netbeans-modules-projectimport-eclipse-core.timestamp=1325785600000 @@ -30,6 +31,7 @@ debug.test.classpath=\ dist.dir=dist dist.jar=${dist.dir}/yacy.jar dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= env.dir=${file.reference.htroot-env} excludes=api/,env/,processing/domaingraph/applet/,yacy/,api/bookmarks/,api/ymarks/,api/bookmarks/posts/,api/bookmarks/tags/,api/bookmarks/xbel/,bookmarks/,ymarks/,bookmarks/posts/,bookmarks/tags/,bookmarks/xbel/,posts/,tags/,xbel/ file.reference.activation.jar=lib/activation.jar @@ -82,7 +84,9 @@ file.reference.xercesImpl.jar=lib/xercesImpl.jar file.reference.xml-apis.jar=lib/xml-apis.jar htroot.dir=${file.reference.rc1-htroot} includes=** -jar.compress=false +jar.archive.disabled=${jnlp.enabled} +jar.compress=true +jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.commons-logging-1.1.1.jar}:\ ${file.reference.servlet-api.jar}:\ @@ -124,7 +128,7 @@ javac.classpath=\ ${file.reference.icu4j-core.jar} # Space-separated list of extra javac options javac.compilerargs= -javac.deprecation=false +javac.deprecation=true javac.processorpath=\ ${javac.classpath} javac.source=1.5 @@ -140,13 +144,25 @@ javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false -javadoc.private=false +javadoc.private=true javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= +jnlp.applet.class=net.yacy.visualization.DemoApplet +jnlp.applet.height=300 +jnlp.applet.width=300 +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=true +mkdist.disabled=false platform.active=default_platform posts.dir=${file.reference.bookmarks-posts} run.classpath=\ From a231d0eeb9ab07de85cbc68a3bdc3c2c91c97cca Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 9 Jan 2012 01:49:37 +0100 Subject: [PATCH 17/17] Run from Java the whole app YACY start for java webStart allow for better integration with IDE Conflicts: source/net/yacy/gui/framework/Browser.java --- build.xml | 8 ++-- source/net/yacy/utils/StartFromJava.java | 55 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 source/net/yacy/utils/StartFromJava.java diff --git a/build.xml b/build.xml index 099bd77f7..e05e27721 100644 --- a/build.xml +++ b/build.xml @@ -79,7 +79,7 @@ - + @@ -199,7 +199,7 @@ @@ -209,7 +209,7 @@ @@ -251,7 +251,7 @@ + debug="true" debuglevel="lines,vars,source" includeantruntime="false"> diff --git a/source/net/yacy/utils/StartFromJava.java b/source/net/yacy/utils/StartFromJava.java new file mode 100644 index 000000000..b272b0797 --- /dev/null +++ b/source/net/yacy/utils/StartFromJava.java @@ -0,0 +1,55 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package net.yacy.utils; + +import java.util.Scanner; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.yacy.gui.framework.Browser; + +/** + * Allow running the aplication yacy from java, useful from running from IDE etc + * + * @author marek + */ +public class StartFromJava { + + private String cmdStart = "./startYACY.sh"; + private String cmdStop = "./stopYACY.sh"; + + public StartFromJava() { + //FIXME: rewrite browser to general use utility UtilExecuteFile + if(Browser.systemOS != Browser.systemUnix) { + throw new UnsupportedOperationException("RUN for other os than Linux not done yet."); + } + } + + public void start() throws Exception { + Browser.openBrowser(cmdStart); + } + + public void stop() throws Exception { + Browser.openBrowser(cmdStop); + } + + public static void main(String[] args) { + try { + StartFromJava run = new StartFromJava(); + run.start(); + System.out.println("run ./stopYACY.sh to stop it or type STOP here"); + Scanner sc = new Scanner(System.in); + String s = "aaa"; + do { + System.out.println("type STOP to stop YACY"); + s = sc.nextLine(); + } while(!"STOP".equals(s)); + + run.stop(); + + } catch(Exception ex) { + Logger.getLogger(StartFromJava.class.getName()).log(Level.SEVERE, null, ex); + } + } +}