On Monday 01 September 2008 21:43, saces at freenetproject.org wrote:
> 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

@Override is a *good* thing. Everything can use 1.5 now.

> 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());

Don't forget to close it.
>               
> +             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;
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080906/76fae3bd/attachment.pgp>

Reply via email to