Author: dieppe
Date: 2008-02-20 03:57:05 +0000 (Wed, 20 Feb 2008)
New Revision: 18080

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/transport/FCPTransport.java
Log:
Bug fix


Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java  
2008-02-20 01:22:10 UTC (rev 18079)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java  
2008-02-20 03:57:05 UTC (rev 18080)
@@ -998,7 +998,9 @@
                {
                        try
                        {
-                               File f = (File)e.nextElement();
+                            Object element = e.nextElement();
+                            File f = (File)element;
+                            
if(!f.getAbsolutePath().contains(webFilesDirectory.getAbsolutePath()))
                                f.delete();                             
                        }
                        catch(ClassCastException cce){}

Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java    
2008-02-20 01:22:10 UTC (rev 18079)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java    
2008-02-20 03:57:05 UTC (rev 18080)
@@ -374,7 +374,7 @@
                        return;
                }
             markWebFilesAsUpdated();
-            File webFiles[] = getUpdatedWebFiles();
+            File webFiles[] = getWebFiles();
             String webPaths[] = getWebFilesServerPaths(webFiles);
             long totalBytes = 0;                               
             //count the total bytes for this publish
@@ -406,7 +406,9 @@
             boolean failed = false;
             //we are publishing a flog with fcp
             FCPTransport fcp = (FCPTransport) transport;
-            boolean result = 
fcp.publishFile(ht,progress,this.getFrontPageUrl().substring(("USK@" + 
fcp.getInsertURI() + "/" + fcp.getTitle() + "/" + fcp.getEdition() + 
"/").length()),getArchivePath());
+            int index = this.getFrontPageUrl().lastIndexOf("/");
+            String defaultName = this.getFrontPageUrl().substring(index+1);
+            boolean result = 
fcp.publishFile(ht,progress,defaultName,getArchivePath());
             if(!result)
                                {
                                        
//progress.publishFailed(transport.getFailureReason());
@@ -431,6 +433,45 @@
             System.out.println("PUBLISH COMPLETE");    
         }

+        private File[] getWebFiles(){            
+            if(webFilesDirectory != null && webFilesDirectory.exists())
+            {                          
+                Vector v = scanDirWithoutDate(webFilesDirectory, new Vector());
+                File f[] = new File[v.size()];
+                for(int i = 0; i < f.length; i++){
+                    f[i] = (File)v.elementAt(i);
+                }
+                return f;
+            }
+            return null;
+        }
+        
+        private Vector scanDirWithoutDate(File dir, Vector updatedFiles)
+        {              
+               File files[] = dir.listFiles(new FileFilter()
+               {
+                       public boolean accept(File f)
+                       {
+                               return f.isFile();
+                       }
+               });
+
+               for(int i = 0; i < files.length; i++)
+                       updatedFiles.add(files[i]);                
+               
+               File dirs[] = dir.listFiles(new FileFilter()
+               {
+                       public boolean accept(File f)
+                       {
+                               return f.isDirectory();
+                       }       
+               });
+               for(int i = 0; i < dirs.length; i++)
+                       scanDirWithoutDate(dirs[i], updatedFiles);
+               
+               return updatedFiles;
+       }
+        
        private boolean publishWebFiles(File webFiles[], PublishProgress 
progress)
        {
                String webPaths[] = getWebFilesServerPaths(webFiles);

Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 
2008-02-20 01:22:10 UTC (rev 18079)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 
2008-02-20 03:57:05 UTC (rev 18080)
@@ -121,6 +121,7 @@
         String dirURI = "freenet:USK@" + insertURI + "/" + title + "/" + 
edition + "/";
         System.out.println("Insert URI : " + dirURI);
         ClientPutComplexDir putDir = new ClientPutComplexDir("Thingamablog 
insert", dirURI);
+        System.out.println("Default name : " + frontPage);
         putDir.setDefaultName(frontPage);
         putDir.setMaxRetries(-1);
         int totalBytes = 0;
@@ -136,10 +137,8 @@
             }
         }
         try {            
-            System.out.println("Executing the command...");
             tp.publishStarted(totalBytes);
             client.execute(putDir);
-            System.out.println("Command executed!");
             System.out.println("Publish in progress...");
         } catch (IOException ioe) {
             logger.log(Level.WARNING,"Publish process failed : " + 
ioe.getMessage());


Reply via email to