Author: saces
Date: 2008-09-01 20:43:39 +0000 (Mon, 01 Sep 2008)
New Revision: 22316
Modified:
trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java
trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
fix 1.5 style @Overwrite
use TempBuckets instead "raw" files
Modified: trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-09-01 20:27:50 UTC
(rev 22315)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-09-01 20:43:39 UTC
(rev 22316)
@@ -74,7 +74,6 @@
Logger.debug(this, "Stopped all current requests");
}
- @Override
public void onFailure(FetchException e, ClientGetter state) {
if ((e.mode == FetchException.PERMANENT_REDIRECT) || (e.mode ==
FetchException.TOO_MANY_PATH_COMPONENTS )) {
@@ -92,27 +91,22 @@
requests.remove(state);
}
- @Override
public void onFailure(InsertException e, BaseClientPutter state) {
}
- @Override
public void onFetchable(BaseClientPutter state) {
}
- @Override
public void onGeneratedURI(FreenetURI uri, BaseClientPutter state) {
}
- @Override
public void onMajorProgress() {
}
- @Override
public void onSuccess(FetchResult result, ClientGetter state) {
Logger.debug(this, "Fetched key (ClientGetter) : " +
state.getURI());
@@ -127,7 +121,6 @@
}
}
- @Override
public void onSuccess(BaseClientPutter state) {
Logger.debug(this, "Fetched key (BaseClientPutter) : " +
state.getURI());
Modified: trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java 2008-09-01
20:27:50 UTC (rev 22315)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java 2008-09-01
20:43:39 UTC (rev 22316)
@@ -6,7 +6,6 @@
package plugins.WoT;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
@@ -31,7 +30,8 @@
import freenet.client.async.ClientGetter;
import freenet.keys.FreenetURI;
import freenet.support.Logger;
-import freenet.support.io.FileBucket;
+import freenet.support.api.Bucket;
+import freenet.support.io.TempBucketFactory;
/**
* @author Julien Cornuwel (batosai at freenetproject.org)
@@ -42,19 +42,18 @@
WoT wot;
ObjectContainer db;
HighLevelSimpleClient client;
- String TEMP_DIR = ".";
+ final TempBucketFactory tBF;
boolean isRunning;
- public IdentityInserter(WoT wot, ObjectContainer db,
HighLevelSimpleClient client) {
-
+ public IdentityInserter(WoT wot, ObjectContainer db,
HighLevelSimpleClient client, TempBucketFactory tbf) {
this.wot = wot;
this.db = db;
this.client = client;
isRunning = true;
+ tBF = tbf;
}
- @Override
public void run() {
try{
Thread.sleep(30 * 1000); // Let the node start up (30
seconds)
@@ -87,13 +86,15 @@
public void insert(OwnIdentity identity) throws
TransformerConfigurationException, FileNotFoundException,
ParserConfigurationException, TransformerException, IOException,
InsertException, Db4oIOException, DatabaseClosedException,
InvalidParameterException {
+ Bucket tempB = tBF.makeBucket(1);
// Create XML file to insert
- File outputFile= identity.exportToXML(db, new File(TEMP_DIR));
+ identity.exportToXML(db, tempB.getOutputStream());
+ tempB.setReadOnly();
+
// Prepare the insert
- FileBucket fb = new FileBucket(outputFile, false, false, true,
true, true); // We always delete the file after insert
ClientMetadata cmd = new ClientMetadata("text/xml");
- InsertBlock ib = new
InsertBlock(fb,cmd,identity.getInsertURI());
+ InsertBlock ib = new
InsertBlock(tempB,cmd,identity.getInsertURI());
client.getInsertContext(false);
// Insert
@@ -105,37 +106,30 @@
db.store(identity);
}
- @Override
public void onFailure(FetchException e, ClientGetter state) {
}
- @Override
public void onFailure(InsertException e, BaseClientPutter state) {
}
- @Override
public void onFetchable(BaseClientPutter state) {
}
- @Override
public void onGeneratedURI(FreenetURI uri, BaseClientPutter state) {
}
- @Override
public void onMajorProgress() {
}
- @Override
public void onSuccess(FetchResult result, ClientGetter state) {
}
- @Override
public void onSuccess(BaseClientPutter state) {
OwnIdentity identity;
Modified: trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java 2008-09-01 20:27:50 UTC
(rev 22315)
+++ trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java 2008-09-01 20:43:39 UTC
(rev 22316)
@@ -10,6 +10,7 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.Date;
import java.util.Iterator;
@@ -91,12 +92,10 @@
* @throws DatabaseClosedException
* @throws Db4oIOException
*/
- public File exportToXML(ObjectContainer db, File dir ) throws
ParserConfigurationException, TransformerConfigurationException,
TransformerException, FileNotFoundException, IOException, Db4oIOException,
DatabaseClosedException, InvalidParameterException {
+ public void exportToXML(ObjectContainer db, OutputStream os) throws
ParserConfigurationException, TransformerConfigurationException,
TransformerException, FileNotFoundException, IOException, Db4oIOException,
DatabaseClosedException, InvalidParameterException {
// Create the output file
- File outputFile = new File(dir, getNickName());
- BufferedOutputStream fos = new BufferedOutputStream(new
FileOutputStream(outputFile));
- StreamResult resultStream = new StreamResult(fos);
+ StreamResult resultStream = new StreamResult(os);
// Create the XML document
DocumentBuilderFactory xmlFactory =
DocumentBuilderFactory.newInstance();
@@ -152,11 +151,6 @@
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
serializer.transform(domSource, resultStream);
-
- fos.close();
-
- return outputFile.getAbsoluteFile();
-
}
/**
Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-09-01 20:27:50 UTC
(rev 22315)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-09-01 20:43:39 UTC
(rev 22316)
@@ -100,7 +100,7 @@
}
// Start the inserter thread
- inserter = new IdentityInserter(wot, db, client);
+ inserter = new IdentityInserter(wot, db, client,
pr.getNode().clientCore.tempBucketFactory);
pr.getNode().executor.execute(inserter, "WoTinserter");
// Create the fetcher
@@ -120,7 +120,6 @@
db.close();
}
- @Override
public String handleHTTPGet(HTTPRequest request) throws
PluginHTTPException {
String page = request.getPath().substring(SELF_URI.length());
@@ -144,7 +143,6 @@
}
}
- @Override
public String handleHTTPPost(HTTPRequest request) throws
PluginHTTPException {
String pass = request.getPartAsString("formPassword", 32);
@@ -380,7 +378,6 @@
Logger.debug(this, "Removed property '" + property + "' from
identity '" + id.getNickName() + "'");
}
- @Override
public String handleHTTPPut(HTTPRequest request) throws
PluginHTTPException {
return null;
}
@@ -389,7 +386,6 @@
return "0.3.0 r"+Version.getSvnRevision();
}
- @Override
public void handle(PluginReplySender replysender, SimpleFieldSet
params, Bucket data, int accesstype) {
try {
@@ -648,13 +644,11 @@
return sfs;
}
- @Override
public String getString(String key) {
// TODO Auto-generated method stub
return key;
}
- @Override
public void setLanguage(LANGUAGE newLanguage) {
// TODO Auto-generated method stub
}