Author: orbiter
Date: 2008-02-15 14:12:25 +0100 (Fri, 15 Feb 2008)
New Revision: 4481
Modified:
trunk/htroot/htdocsdefault/dir.html
trunk/htroot/htdocsdefault/dir.java
trunk/htroot/htdocsdefault/dir.rss
trunk/htroot/htdocsdefault/dir.xml
trunk/source/de/anomic/plasma/plasmaCrawlBalancer.java
trunk/source/de/anomic/server/serverCodings.java
trunk/source/de/anomic/server/serverFileUtils.java
trunk/source/de/anomic/ymage/ymageOSM.java
Log:
modified dir servlet to cooperate with intranet indexing from the own HTDOCS
repository:
- removed md5 file generation (spoils the won repository)
- removed comments in file share (was never used)
- moved dir list comparator to other place (maybe solves problem, lets see)
Modified: trunk/htroot/htdocsdefault/dir.html
===================================================================
--- trunk/htroot/htdocsdefault/dir.html 2008-02-13 22:37:37 UTC (rev 4480)
+++ trunk/htroot/htdocsdefault/dir.html 2008-02-15 13:12:25 UTC (rev 4481)
@@ -107,7 +107,6 @@
Resource =
<input type="hidden"
name="action" value="upload">
<input type="file"
name="file" size="10" class="small"><br>
-
Description = <input type="text" name="description" size="30"
class="small"><br>
Indexing : <input
type="checkbox" name="indexing" checked><br>
<input type="submit"
value="Transfer" class="small">
</form>
Modified: trunk/htroot/htdocsdefault/dir.java
===================================================================
--- trunk/htroot/htdocsdefault/dir.java 2008-02-13 22:37:37 UTC (rev 4480)
+++ trunk/htroot/htdocsdefault/dir.java 2008-02-15 13:12:25 UTC (rev 4481)
@@ -31,7 +31,6 @@
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
@@ -53,6 +52,7 @@
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
+import de.anomic.server.serverFileUtils.dirlistComparator;
import de.anomic.tools.md5DirFileFilter;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
@@ -146,23 +146,20 @@
switchboard.setConfig("uploadAccountBase64MD5",
(post.get("password", "").length() == 0) ? "" :
serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString("upload:"
+ post.get("password", ""))));
} else if (action.equals("upload") && (uploadAuthorization ||
adminAuthorization)) {
String filename = new File(post.get("file", "dummy")).getName();
- String description = post.get("description", "");
pos = filename.lastIndexOf("\\");
if (pos >= 0) { filename = filename.substring(pos + 1); }
final File newfile = new File(dir, filename);
- final File newfilemd5 = new File(dir, filename + ".md5");
final byte[] binary = (byte[]) post.get("file$file", new byte[0]);
try {
serverFileUtils.write(binary, newfile);
byte[] md5 = serverCodings.encodeMD5Raw(newfile);
String md5s = serverCodings.encodeHex(md5);
- serverFileUtils.write((md5s + "\n" +
description).getBytes("UTF-8"), newfilemd5); // generate md5
-
+
// index file info
if (post.get("indexing", "").equals("on")) {
final String urlstring =
yacyhURL(yacyCore.seedDB.mySeed(), filename, md5s);
final String phrase = filename.replace('.', '
').replace('_', ' ').replace('-', ' ');
- indexPhrase(switchboard, urlstring, phrase, description,
md5);
+ indexPhrase(switchboard, urlstring, phrase, "", md5);
}
} catch (IOException e) {}
} else if (action.equals("newdir") && (uploadAuthorization ||
adminAuthorization)) {
@@ -175,18 +172,6 @@
String filename = post.get("file", "foo");
final File file = new File(dir, filename);
if (file.exists()) {
- final File filemd5 = new File(dir, post.get("file", "foo") +
".md5");
- // read md5 and phrase
- String md5s = "";
- String description = "";
- if (filemd5.exists()) try {
- md5s = new String(serverFileUtils.read(filemd5));
- pos = md5s.indexOf('\n');
- if (pos >= 0) {
- description = md5s.substring(pos + 1);
- md5s = md5s.substring(0, pos);
- }
- } catch (IOException e) {}
// delete file(s)
if (file.isDirectory()) {
final String[] content = file.list();
@@ -194,12 +179,11 @@
file.delete();
} else if (file.isFile()) {
file.delete();
- if (filemd5.exists()) filemd5.delete();
}
// delete index
- final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(),
filename, md5s);
+ final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(),
filename, "");
final String phrase = filename.replace('.', ' ').replace('_',
' ').replace('-', ' ');
- deletePhrase(switchboard, urlstring, phrase, description);
+ deletePhrase(switchboard, urlstring, phrase, "");
}
}
@@ -207,13 +191,13 @@
if ((adminAuthorization) || (uploadAuthorization) ||
(downloadAuthorization)) {
// generate dir listing
md5DirFileFilter fileFilter = new md5DirFileFilter();
- final File[] list = dir.listFiles(fileFilter);
+ File[] list = dir.listFiles(fileFilter);
+ if (list == null) list = new File[0];
// sorting the dir list
dirlistComparator comparator = new dirlistComparator();
Arrays.sort(list, comparator);
- String md5s, description;
// tree += "<span class=\"tt\">path = " + path +
"</span><br><br>";
if (list != null) {
int filecount = 0, fileIdx = 0;
@@ -231,31 +215,6 @@
dark = !dark;
- // reading the content of the md5 file that belongs
- // to the file
- File fmd5 = new File(dir, fileName + ".md5");
- try {
- if (fmd5.exists()) {
- md5s = new String(serverFileUtils.read(fmd5));
- pos = md5s.indexOf('\n');
- if (pos >= 0) {
- // the second line contains an optional
description
- description = md5s.substring(pos + 1);
- // the first line contains the md5 sum of the
file
- md5s = md5s.substring(0, pos);
- } else {
- description = "";
- }
- } else {
- // generate md5 on-the-fly
- md5s = serverCodings.encodeMD5Hex(f);
- description = "";
- serverFileUtils.write((md5s + "\n" +
description).getBytes("UTF-8"), fmd5);
- }
- } catch (IOException e) {
- md5s = "";
- description = "";
- }
// last modification date if the entry
prop.put("dirlist_" + fileIdx + "_dir_date" ,
dateString(new Date(f.lastModified())));
@@ -273,6 +232,8 @@
boolean showImage = /* (description.length() == 0) &&
*/ (fileName.endsWith(".jpg") || fileName.endsWith(".gif") ||
fileName.endsWith(".png") || fileName.endsWith(".ico") ||
fileName.endsWith(".bmp"));
// the entry is a file
+ String md5s = serverCodings.encodeMD5Hex(f);
+
prop.put("dirlist_" + fileIdx + "_dir" , "0");
// the file size
prop.put("dirlist_" + fileIdx + "_dir_size" ,
serverMemory.bytesToString(f.length()));
@@ -288,7 +249,7 @@
prop.putHTML("dirlist_" + fileIdx +
"_dir_descriptionMode_image",fileName);
}
// always set the description tag (needed by rss and
xml)
- prop.putHTML("dirlist_" + fileIdx +
"_dir_descriptionMode_text",description);
+ prop.putHTML("dirlist_" + fileIdx +
"_dir_descriptionMode_text", "");
}
prop.put("dirlist_" + fileIdx +
"_adminAuthorization",adminAuthorization ? "1" : "0");
@@ -389,17 +350,4 @@
}
}
- public static class dirlistComparator implements Comparator<File> {
-
- public int compare(File file1, File file2) {
- if (file1.isDirectory() && !file2.isDirectory()) {
- return -1;
- } else if (!file1.isDirectory() && file2.isDirectory()) {
- return 1;
- } else {
- return file1.getName().compareToIgnoreCase(file2.getName());
- }
- }
-
- }
}
Modified: trunk/htroot/htdocsdefault/dir.rss
===================================================================
--- trunk/htroot/htdocsdefault/dir.rss 2008-02-13 22:37:37 UTC (rev 4480)
+++ trunk/htroot/htdocsdefault/dir.rss 2008-02-15 13:12:25 UTC (rev 4481)
@@ -14,7 +14,6 @@
<link>#(dir)##[URL]#::#[URL]##(/dir)#</link>
<pubDate>#(dir)##[rfc822date]#::#[rfc822date]##(/dir)#</pubDate>
#(dir)#<guid>#[md5s]#</guid>::#(/dir)#
-
#(dir)#<description><![CDATA[#(descriptionMode)##[text]#::#[text]##(/descriptionMode)#]]></description>::#(/dir)#
<category><![CDATA[#(dir)#File::Directory#(/dir)#]]></category>
</item>#{/dirlist}#
</channel>
Modified: trunk/htroot/htdocsdefault/dir.xml
===================================================================
--- trunk/htroot/htdocsdefault/dir.xml 2008-02-13 22:37:37 UTC (rev 4480)
+++ trunk/htroot/htdocsdefault/dir.xml 2008-02-15 13:12:25 UTC (rev 4481)
@@ -7,7 +7,6 @@
<date timestamp="#[timestamp]#">#[date]#</date>
<size bytes="#[sizeBytes]#">#[size]#</size>
<md5>#[md5s]#</md5>
-
<comment>#(descriptionMode)##[text]#::#[text]##(/descriptionMode)#</comment>
<yacyURL>#[yacyhURL]#</yacyURL>
</file>
::
Modified: trunk/source/de/anomic/plasma/plasmaCrawlBalancer.java
===================================================================
--- trunk/source/de/anomic/plasma/plasmaCrawlBalancer.java 2008-02-13
22:37:37 UTC (rev 4480)
+++ trunk/source/de/anomic/plasma/plasmaCrawlBalancer.java 2008-02-15
13:12:25 UTC (rev 4481)
@@ -155,7 +155,8 @@
}
public synchronized plasmaCrawlEntry get(String urlhash) throws
IOException {
- kelondroRow.Entry entry = urlFileIndex.get(urlhash.getBytes());
+ assert urlhash != null;
+ kelondroRow.Entry entry = urlFileIndex.get(urlhash.getBytes());
if (entry == null) return null;
return new plasmaCrawlEntry(entry);
}
Modified: trunk/source/de/anomic/server/serverCodings.java
===================================================================
(Binary files differ)
Modified: trunk/source/de/anomic/server/serverFileUtils.java
===================================================================
--- trunk/source/de/anomic/server/serverFileUtils.java 2008-02-13 22:37:37 UTC
(rev 4480)
+++ trunk/source/de/anomic/server/serverFileUtils.java 2008-02-15 13:12:25 UTC
(rev 4481)
@@ -54,6 +54,7 @@
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -483,7 +484,21 @@
String[] list = from_dir.list();
for (int i = 0; i < list.length; i++) (new File(from_dir,
list[i])).renameTo(new File(to_dir, list[i]));
}
+
+ public static class dirlistComparator implements Comparator<File> {
+
+ public int compare(File file1, File file2) {
+ if (file1.isDirectory() && !file2.isDirectory()) {
+ return -1;
+ } else if (!file1.isDirectory() && file2.isDirectory()) {
+ return 1;
+ } else {
+ return file1.getName().compareToIgnoreCase(file2.getName());
+ }
+ }
+ }
+
public static void main(String[] args) {
try {
writeAndGZip("ein zwei drei, Zauberei".getBytes(), new
File("zauberei.txt.gz"));
Modified: trunk/source/de/anomic/ymage/ymageOSM.java
===================================================================
--- trunk/source/de/anomic/ymage/ymageOSM.java 2008-02-13 22:37:37 UTC (rev
4480)
+++ trunk/source/de/anomic/ymage/ymageOSM.java 2008-02-15 13:12:25 UTC (rev
4481)
@@ -28,6 +28,7 @@
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -83,6 +84,8 @@
}
try {
return ImageIO.read(tileStream);
+ } catch (EOFException e) {
+ return null;
} catch (IOException e) {
return null;
}
_______________________________________________
YaCy-svn mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/yacy-svn