Author: nextgens
Date: 2008-10-21 23:22:51 +0000 (Tue, 21 Oct 2008)
New Revision: 23023

Modified:
   trunk/freenet/src/freenet/client/ClientMetadata.java
   trunk/freenet/src/freenet/client/Metadata.java
   trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
   trunk/freenet/src/freenet/client/async/SingleFileInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileInserter.java
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
   trunk/freenet/src/freenet/frost/message/FrostMessage.java
   trunk/freenet/src/freenet/node/NodeARKInserter.java
   trunk/freenet/src/freenet/node/TextModeClientInterface.java
   trunk/freenet/src/freenet/node/fcp/ClientPut.java
   trunk/freenet/src/freenet/node/fcp/DirPutFile.java
   trunk/freenet/src/freenet/node/simulator/BootstrapPushPullTest.java
Log:
more work on bug #71: take toad's review into consideration: let 
ClientMetadatas alone.

I knew I didn't understand the API right ...

Modified: trunk/freenet/src/freenet/client/ClientMetadata.java
===================================================================
--- trunk/freenet/src/freenet/client/ClientMetadata.java        2008-10-21 
21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/client/ClientMetadata.java        2008-10-21 
23:22:51 UTC (rev 23023)
@@ -3,8 +3,6 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.client;

-import freenet.support.compress.Compressor.COMPRESSOR_TYPE;
-
 /**
  * Stores the metadata that the client might actually be interested in.
  */
@@ -12,16 +10,13 @@

        /** The document MIME type */
        private String mimeType;
-       private COMPRESSOR_TYPE compressor;

        public ClientMetadata(){
                mimeType = null;
-               compressor = null;
        }

-       public ClientMetadata(String mime, COMPRESSOR_TYPE comp) {
+       public ClientMetadata(String mime) {
                mimeType = (mime == null) ? null : mime.intern();
-               compressor = comp;
        }

        /** Get the document MIME type. Will always be a valid MIME type, 
unless there
@@ -72,12 +67,4 @@
                }
                return s;
        }
-       
-       public COMPRESSOR_TYPE getCompressorType() {
-               return compressor;
 }
-       
-       public void setCompressorType(COMPRESSOR_TYPE compressor) {
-               this.compressor = compressor;
-       }
-}

Modified: trunk/freenet/src/freenet/client/Metadata.java
===================================================================
--- trunk/freenet/src/freenet/client/Metadata.java      2008-10-21 21:30:22 UTC 
(rev 23022)
+++ trunk/freenet/src/freenet/client/Metadata.java      2008-10-21 23:22:51 UTC 
(rev 23023)
@@ -267,7 +267,7 @@
                        extraMetadata = false; // can't parse, can't write
                }

-               clientMetadata = new ClientMetadata(mimeType, compressionCodec);
+               clientMetadata = new ClientMetadata(mimeType);

                if((!splitfile) && ((documentType == SIMPLE_REDIRECT) || 
(documentType == ARCHIVE_MANIFEST))) {
                        simpleRedirectKey = readKey(dis);
@@ -461,7 +461,7 @@
                documentType = SIMPLE_MANIFEST;
                noMIME = true;
                mimeType = null;
-               clientMetadata = new ClientMetadata(null,null);
+               clientMetadata = new ClientMetadata();
                manifestEntries = new HashMap();
                int count = 0;
                for(Iterator i = dir.keySet().iterator();i.hasNext();) {
@@ -472,7 +472,7 @@
                        if(o instanceof String) {
                                // Zip internal redirect
                                target = new 
Metadata(ARCHIVE_INTERNAL_REDIRECT, null, null, prefix+key,
-                                       new 
ClientMetadata(DefaultMIMETypes.guessMIMEType(key, false),null));
+                                       new 
ClientMetadata(DefaultMIMETypes.guessMIMEType(key, false)));
                        } else if(o instanceof HashMap) {
                                target = new Metadata((HashMap)o, 
prefix+key+"/");
                        } else throw new IllegalArgumentException("Not String 
nor HashMap: "+o);
@@ -922,7 +922,7 @@
        public void setArchiveManifest() {
                ARCHIVE_TYPE type = 
ARCHIVE_TYPE.getArchiveType(clientMetadata.getMIMEType());
                archiveType = type;
-               compressionCodec = clientMetadata.getCompressorType();
+               compressionCodec = null;
                clientMetadata.clear();
                documentType = ARCHIVE_MANIFEST;
        }

Modified: trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2008-10-21 21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2008-10-21 23:22:51 UTC (rev 23023)
@@ -310,7 +310,7 @@
                                if(mimeType == null || 
mimeType.equals(DefaultMIMETypes.DEFAULT_MIME_TYPE))
                                        cm = null;
                                else
-                                       cm = new ClientMetadata(mimeType, null);
+                                       cm = new ClientMetadata(mimeType);
                                PutHandler ph;
                                Bucket data = element.data;
                                if(element.targetURI != null) {
@@ -438,7 +438,7 @@
                                // Can we just insert it, and not bother with a 
redirect to it?
                                // Thereby exploiting implicit manifest 
support, which will pick up on .metadata??
                                // We ought to be able to !!
-                               block = new InsertBlock(outputBucket, new 
ClientMetadata(mimeType, null), targetURI);
+                               block = new InsertBlock(outputBucket, new 
ClientMetadata(mimeType), targetURI);
                                isMetadata = false;
                                insertAsArchiveManifest = true;
                        } catch (IOException e) {

Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2008-10-21 21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2008-10-21 23:22:51 UTC (rev 23023)
@@ -206,7 +206,6 @@
                        if(logMINOR) Logger.minor(this, "The best compression 
algorithm is "+bestCodec+ " we have a "+origSize/compressedSize+" ratio! 
("+origSize+'/'+compressedSize+')');
                        data = bestCompressedData;
                        shouldFreeData = true;
-                       block.clientMetadata.setCompressorType(bestCodec);
                        compressorUsed = bestCodec;
                }

@@ -371,7 +370,7 @@
                        if(sfiFS == null)
                                throw new ResumeException("No 
SplitFileInserter");
                        ClientPutState newSFI, newMetaPutter = null;
-                       newSFI = new SplitFileInserter(parent, this, 
forceMetadata ? null : block.clientMetadata, ctx, getCHKOnly, meta, token, 
archiveType, compressorUsed, sfiFS);
+                       newSFI = new SplitFileInserter(parent, this, 
forceMetadata ? null : block.clientMetadata, ctx, getCHKOnly, meta, token, 
archiveType, sfiFS);
                        if(logMINOR) Logger.minor(this, "Starting "+newSFI+" 
for "+this);
                        fs.removeSubset("SplitFileInserter");
                        SimpleFieldSet metaFS = fs.subset("MetadataPutter");
@@ -381,7 +380,7 @@
                                        if(type.equals("SplitFileInserter")) {
                                                // FIXME 
insertAsArchiveManifest ?!?!?!
                                                newMetaPutter = 
-                                                       new 
SplitFileInserter(parent, this, null, ctx, getCHKOnly, true, token, 
archiveType, compressorUsed, metaFS);
+                                                       new 
SplitFileInserter(parent, this, null, ctx, getCHKOnly, true, token, 
archiveType, metaFS);
                                        } else if(type.equals("SplitHandler")) {
                                                newMetaPutter = new 
SplitHandler();
                                                
((SplitHandler)newMetaPutter).start(metaFS, true);

Modified: trunk/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserter.java       
2008-10-21 21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserter.java       
2008-10-21 23:22:51 UTC (rev 23023)
@@ -103,7 +103,7 @@
                parent.onMajorProgress();
        }

-       public SplitFileInserter(BaseClientPutter parent, PutCompletionCallback 
cb, ClientMetadata clientMetadata, InsertContext ctx, boolean getCHKOnly, 
boolean metadata, Object token, ARCHIVE_TYPE archiveType, COMPRESSOR_TYPE 
bestCodec, SimpleFieldSet fs) throws ResumeException {
+       public SplitFileInserter(BaseClientPutter parent, PutCompletionCallback 
cb, ClientMetadata clientMetadata, InsertContext ctx, boolean getCHKOnly, 
boolean metadata, Object token, ARCHIVE_TYPE archiveType, SimpleFieldSet fs) 
throws ResumeException {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                this.parent = parent;
                this.archiveType = archiveType;
@@ -146,14 +146,10 @@
                } catch (NumberFormatException e) {
                        throw new ResumeException("Corrupt CheckSegmentSize: 
"+e+" : "+length);
                }
-               if(bestCodec != null) {
-                       compressionCodec = bestCodec;
-               } else {
                String ccodec = fs.get("CompressionCodec");
-                       if(ccodec == null)
-                               throw new ResumeException("No compression 
codec");
-                       compressionCodec = COMPRESSOR_TYPE.valueOf(ccodec);
-               }
+               if(ccodec == null)
+                       throw new ResumeException("No compression codec");
+               compressionCodec = COMPRESSOR_TYPE.valueOf(ccodec);
                String scodec = fs.get("SplitfileCodec");
                if(scodec == null) throw new ResumeException("No splitfile 
codec");
                try {

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2008-10-21 
21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2008-10-21 
23:22:51 UTC (rev 23023)
@@ -305,7 +305,7 @@
             if (type == null) {
                 type = "text/plain";
             }
-            ClientMetadata contentType = new ClientMetadata(type, null);
+            ClientMetadata contentType = new ClientMetadata(type);

             Bucket bucket = request.getPart("filename");


Modified: trunk/freenet/src/freenet/frost/message/FrostMessage.java
===================================================================
--- trunk/freenet/src/freenet/frost/message/FrostMessage.java   2008-10-21 
21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/frost/message/FrostMessage.java   2008-10-21 
23:22:51 UTC (rev 23023)
@@ -293,7 +293,7 @@
                key = this.composeUploadKey(innitialIndex);
                keepgoing = false;

-            block = new InsertBlock(new ArrayBucket(data), new 
ClientMetadata(type, null), key);
+            block = new InsertBlock(new ArrayBucket(data), new 
ClientMetadata(type), key);

                // try inserting the message with the key
             try {

Modified: trunk/freenet/src/freenet/node/NodeARKInserter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeARKInserter.java 2008-10-21 21:30:22 UTC 
(rev 23022)
+++ trunk/freenet/src/freenet/node/NodeARKInserter.java 2008-10-21 23:22:51 UTC 
(rev 23023)
@@ -156,7 +156,7 @@


                inserter = new ClientPutter(this, b, uri,
-                                       new ClientMetadata("text/plain", null) 
/* it won't quite fit in an SSK anyway */, 
+                                       new ClientMetadata("text/plain") /* it 
won't quite fit in an SSK anyway */, 
                                        node.clientCore.makeClient((short)0, 
true).getInsertContext(true),
                                        
node.clientCore.requestStarters.chkPutScheduler, 
node.clientCore.requestStarters.sskPutScheduler, 
                                        
RequestStarter.INTERACTIVE_PRIORITY_CLASS, false, false, this, null, null, 
false);

Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2008-10-21 
21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2008-10-21 
23:22:51 UTC (rev 23023)
@@ -582,7 +582,7 @@
                        mimeType = ""; // don't need to override it

                FileBucket fb = new FileBucket(f, true, false, false, false, 
false);
-               InsertBlock block = new InsertBlock(fb, new 
ClientMetadata(mimeType, null), FreenetURI.EMPTY_CHK_URI);
+               InsertBlock block = new InsertBlock(fb, new 
ClientMetadata(mimeType), FreenetURI.EMPTY_CHK_URI);

                startTime = System.currentTimeMillis();
                FreenetURI uri = client.insert(block, getCHKOnly, f.getName());

Modified: trunk/freenet/src/freenet/node/fcp/ClientPut.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPut.java   2008-10-21 21:30:22 UTC 
(rev 23022)
+++ trunk/freenet/src/freenet/node/fcp/ClientPut.java   2008-10-21 23:22:51 UTC 
(rev 23023)
@@ -117,7 +117,7 @@
                if(persistenceType != PERSIST_CONNECTION)
                        client.register(this, false);
                Bucket tempData = data;
-               ClientMetadata cm = new ClientMetadata(mimeType, null);
+               ClientMetadata cm = new ClientMetadata(mimeType);
                boolean isMetadata = false;
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR) Logger.minor(this, "data = "+tempData+", 
uploadFrom = "+ClientPutMessage.uploadFromString(uploadFrom));
@@ -200,7 +200,7 @@
                if(persistenceType != PERSIST_CONNECTION)
                        client.register(this, false);
                Bucket tempData = message.bucket;
-               ClientMetadata cm = new ClientMetadata(mimeType, null);
+               ClientMetadata cm = new ClientMetadata(mimeType);
                boolean isMetadata = false;
                if(logMINOR) Logger.minor(this, "data = "+tempData+", 
uploadFrom = "+ClientPutMessage.uploadFromString(uploadFrom));
                if(uploadFrom == ClientPutMessage.UPLOAD_FROM_REDIRECT) {
@@ -292,7 +292,7 @@
                                throw new PersistenceParseException("Unknown 
UploadFrom: "+from);
                }

-               ClientMetadata cm = new ClientMetadata(mimeType, null);
+               ClientMetadata cm = new ClientMetadata(mimeType);

                boolean isMetadata = false;


Modified: trunk/freenet/src/freenet/node/fcp/DirPutFile.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/DirPutFile.java  2008-10-21 21:30:22 UTC 
(rev 23022)
+++ trunk/freenet/src/freenet/node/fcp/DirPutFile.java  2008-10-21 23:22:51 UTC 
(rev 23023)
@@ -26,9 +26,9 @@
                        throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing field 
Name", identifier, global);
                String contentTypeOverride = subset.get("Metadata.ContentType");
                if(contentTypeOverride != null) {
-                       meta = new ClientMetadata(contentTypeOverride, null);
+                       meta = new ClientMetadata(contentTypeOverride);
                } else {
-                       meta = new ClientMetadata(guessMIME(), null);
+                       meta = new ClientMetadata(guessMIME());
                }
        }


Modified: trunk/freenet/src/freenet/node/simulator/BootstrapPushPullTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/BootstrapPushPullTest.java 
2008-10-21 21:30:22 UTC (rev 23022)
+++ trunk/freenet/src/freenet/node/simulator/BootstrapPushPullTest.java 
2008-10-21 23:22:51 UTC (rev 23023)
@@ -76,7 +76,7 @@
         os.close();
         System.out.println("Inserting test data.");
         HighLevelSimpleClient client = node.clientCore.makeClient((short)0);
-        InsertBlock block = new InsertBlock(data, new ClientMetadata(null, 
null), FreenetURI.EMPTY_CHK_URI);
+        InsertBlock block = new InsertBlock(data, new ClientMetadata(), 
FreenetURI.EMPTY_CHK_URI);
         long startInsertTime = System.currentTimeMillis();
         FreenetURI uri;
         try {


Reply via email to