Hi,

Matthew Toseland a ?crit :
> On Wednesday 20 February 2008 01:22, dieppe at freenetproject.org wrote:
>   
>> Author: dieppe
>> Date: 2008-02-20 01:22:10 +0000 (Wed, 20 Feb 2008)
>> New Revision: 18079
>>
>> Modified:
>>    trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
>>    trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
>>    
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/WeblogPreviewer.java
>   
>>    
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
>   
>>    
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
>   
>>    
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
>   
>> Log:
>> Insert works (not deeply tested) now;
>> Few bugfixs;
>>
>> Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
>> ===================================================================
>> --- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java 
>>     
> 2008-02-19 20:28:19 UTC (rev 18078)
>   
>> +++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java 
>>     
> 2008-02-20 01:22:10 UTC (rev 18079)
>   
>> @@ -375,10 +375,13 @@
>>              }
>>              markWebFilesAsUpdated();
>>              File webFiles[] = getUpdatedWebFiles();
>> +            String webPaths[] = getWebFilesServerPaths(webFiles);
>>              long totalBytes = 0;                            
>>              //count the total bytes for this publish
>> -            for(int i = 0; i < webFiles.length; i++)
>> -            totalBytes += webFiles[i].length();
>> +            for(int i = 0; i < webFiles.length; i++){
>> +                totalBytes += webFiles[i].length();
>> +                ht.put(webFiles[i],webPaths[i]);
>> +            }
>>              for(Enumeration e = ht.keys() ; e.hasMoreElements() ;) 
>>              {
>>                      try
>> @@ -403,7 +406,7 @@
>>              boolean failed = false;
>>              //we are publishing a flog with fcp
>>              FCPTransport fcp = (FCPTransport) transport;
>> -            boolean result = fcp.publishFile(ht,progress);
>> +            boolean result = 
>>     
> fcp.publishFile(ht,progress,this.getFrontPageUrl().substring(("USK@" + 
> fcp.getInsertURI() + "/" + fcp.getTitle() + "/" + fcp.getEdition() 
> + "/").length()),getArchivePath());
>
> This is rather odd - what are you doing here? I mean, why do you construct 
> the 
> string, which presumably is identical to the first part of the other string, 
> and then use the first part of the other string anyway?
>
>   
Now, I'm doing this, is that better :
            int index = this.getFrontPageUrl().lastIndexOf("/");
            String defaultName = this.getFrontPageUrl().substring(index+1);
            boolean result =
fcp.publishFile(ht,progress,defaultName,getArchivePath(),this.getTitle());
?
>> Modified: 
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
>   
>> ===================================================================
>> --- 
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java   
> 2008-02-19 20:28:19 UTC (rev 18078)
>   
>> +++ 
>>     
> trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java   
> 2008-02-20 01:22:10 UTC (rev 18079)
>   
>> @@ -174,14 +170,16 @@
>>                  finished = success || "PutFailed".equals(messageName) || 
>>     
> messageName.endsWith("Error");
>   
>>              }            
>>          }
>> -        hasPublish=success;
>> +        // If the publish has been made, we update the edition number to 
>>     
> the current edition +1
>   
>> +        if(finalURI != null){
>> +            edition = 
>>     
> Integer.parseInt(finalURI.substring(finalURI.length()-1)) + 1;
>   
>> +        }
>>          return success;
>>      }
>>     
>
> And is this horrible hack necessary? Can't you keep the edition number as an 
> integer or something? For that matter, can't you keep the URI as a URI? (Feel 
> free to reuse code from Freenet itself e.g. FreenetURI).
>   
Yes, I know, I had to look a little closer on the code, because in fact,
I'm reusing the code of TBWeblog for the flog, adding a type field,
which leads me to not use URI. (I am creating a new TBFlog class, to use
URI instead of String, and to have more flexibility. But I have a little
technical issue with my IDE, so I have to change it, so it will take a
little more time I expected)
And, for the other point, I use String because the edition number is
stock in a xml file. Anyway, I prefer to look at the finalURI that the
node gives to know the edition number, because I'm sure it's the good
one (so, if there is a bug in another part of the application, I'm sure
the edition number is the right one). But perhaps it's not a good idea,
I don't know...
>>      
>> -    private FileEntry createFileEntry(File file, int edition){
>> +    private FileEntry createFileEntry(File file, int edition, String path){
>>          String content = DefaultMIMETypes.guessMIMEType(file.getName());
>> -        System.out.println(content);
>> -        FileEntry fileEntry = new DiskFileEntry(file.getName(), content, 
>>     
> file.getPath());
>   
>> +        FileEntry fileEntry = new DiskFileEntry(path + file.getName(), 
>>     
> content, file.getPath());
>   
>>          return fileEntry;
>>      }
>>     
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Devl mailing list
>> Devl at freenetproject.org
>> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl


Reply via email to