Author: dieppe
Date: 2008-03-24 16:34:57 +0000 (Mon, 24 Mar 2008)
New Revision: 18739

Modified:
   
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
   trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
   trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
Log:
Fix the following problem : the edition number was only include in [0-9]
-> add a edition number field in fcpPanel (the edition number was reset 
before...)
-> don't use the finalURI to get the edition number, just increment it
-> edition number is a int everywhere now



Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
===================================================================
--- 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
 2008-03-24 16:34:34 UTC (rev 18738)
+++ 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
 2008-03-24 16:34:57 UTC (rev 18739)
@@ -52,6 +52,7 @@
 import net.sf.thingamablog.TBGlobals;
 import net.sf.thingamablog.blog.TBWeblog;
 import net.sf.thingamablog.gui.LabelledItemPanel;
+import net.sf.thingamablog.transport.DefaultMIMETypes;
 import net.sf.thingamablog.transport.FCPTransport;
 import net.sf.thingamablog.transport.FTPTransport;
 import net.sf.thingamablog.transport.LocalTransport;
@@ -192,6 +193,7 @@
                         if (t.getActiveLink()){                            
                             fcpPanel.setActiveLinkPath(t.getActiveLinkPath());
                         }
+                        fcpPanel.setEditionNumber(t.getEdition());
                         transportTypeCombo.setSelectedItem(FCP);
                         tLayout.show(transportsPanel, FCP);
                 }
@@ -268,9 +270,9 @@
                         }
                         String url = fcpPanel.getRequestUri();                 
       
                         int firstSlash = url.indexOf('/');
-                        url = url.substring(0,firstSlash+1) + 
ASCIIconv.convertNonAscii(weblog.getTitle()) + "/1/";
+                        url = url.substring(0,firstSlash+1) + 
ASCIIconv.convertNonAscii(weblog.getTitle()) + "/" + 
fcpPanel.getEditionNumber() + "/";
                         weblog.setBlogUrls("none",url,url,url);
-                        pt.setEdition("1");
+                        pt.setEdition(fcpPanel.getEditionNumber());
                         transport = pt;
                 }

@@ -288,6 +290,8 @@
                return validateOptions(ftpPanel);
         if(o == SFTP)
                return validateOptions(sftpPanel);
+        if(o == FCP)
+                return validateOptions(fcpPanel);

         return true;
     }
@@ -304,6 +308,17 @@
                return true;
     }    

+    private boolean validateOptions(FcpTransportPanel fcp)
+    {
+            if (!fcp.getActiveLink() || 
DefaultMIMETypes.guessMIMEType(fcp.getActiveLinkPath()).equals("image/png")){
+                return true;
+            } else {
+                JOptionPane.showMessageDialog(this, i18n.str("png_needed"), 
i18n.str("wrong_type"),  //$NON-NLS-1$ //$NON-NLS-2$
+                       JOptionPane.WARNING_MESSAGE);
+                return false;
+            }            
+    }
+    
     private class RemoteTransportPanel extends JPanel
     {
        /**
@@ -464,6 +479,7 @@
                 private JTextField activeLinkPathField;
                 private JCheckBox activeLinkCheckBox;
                 private JButton generateKeyButton;
+                private int EditionNumber = 0;
                public FcpTransportPanel()
                {
                         portField = new JTextField();
@@ -480,7 +496,7 @@
                         TypeListener listener = new TypeListener();
                         generateKeyButton.addActionListener(listener);

-                        activeLinkPathField.setEditable(false);
+                        
activeLinkPathField.setEditable(activeLinkCheckBox.isSelected());
                         activeLinkCheckBox.addActionListener(new 
ActionListener() {
                             public void actionPerformed(ActionEvent e) {       
                         
                                 
activeLinkPathField.setEditable(activeLinkCheckBox.isSelected());
@@ -546,6 +562,7 @@

         public void setActiveLink(boolean b){
             this.activeLinkCheckBox.setSelected(b);
+            this.activeLinkPathField.setEditable(b);
         }

         public boolean getActiveLink(){
@@ -560,6 +577,14 @@
             return this.activeLinkPathField.getText();
         }

+        public void setEditionNumber(int ed){
+            this.EditionNumber = ed;
+        }
+        
+        public int getEditionNumber(){
+            return this.EditionNumber;
+        }
+        
         private class TypeListener implements ActionListener {
             public void actionPerformed(ActionEvent e) {
                 if (e.getSource() instanceof JButton){

Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 
2008-03-24 16:34:34 UTC (rev 18738)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 
2008-03-24 16:34:57 UTC (rev 18739)
@@ -119,8 +119,8 @@
             return false;
         }
         System.out.println("Beginning of the publish process...");
-        edition++;
-        String dirURI = "freenet:USK@" + insertURI + "/" + 
ASCIIconv.convertNonAscii(title) + "/" + edition + "/";
+        int current_edition = edition + 1;
+        String dirURI = "freenet:USK@" + insertURI + "/" + 
ASCIIconv.convertNonAscii(title) + "/" + current_edition + "/";
         System.out.println("Insert URI : " + dirURI);
         ClientPutComplexDir putDir = new ClientPutComplexDir("Thingamablog 
insert", dirURI);
         System.out.println("Default name : " + frontPage);
@@ -183,11 +183,9 @@
                 finished = success || "PutFailed".equals(messageName) || 
messageName.endsWith("Error");
             }            
         }
-        // If the publish has been made, we update the edition number to the 
current edition, otherwise, we revert it
+        // If the publish has been made, we update the edition number to the 
current edition
         if(finalURI != null){
-            edition = 
Integer.parseInt(finalURI.substring(finalURI.length()-1));
-        } else {
-            edition--;
+            edition++;
         }
         return success;
     }
@@ -220,8 +218,8 @@
         this.insertURI=shortenURI(insertURI);
     }

-    public void setEdition(String edition){
-        this.edition=Integer.parseInt(edition);
+    public void setEdition(int edition){
+        this.edition=edition;
     }

     public int getEdition(){

Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java   
2008-03-24 16:34:34 UTC (rev 18738)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java   
2008-03-24 16:34:57 UTC (rev 18739)
@@ -876,7 +876,7 @@
                 {
                     FCPTransport fcp = new FCPTransport();
                     fcp.setNode(transport.getAttributeValue("hostname"), 
Integer.parseInt(transport.getAttributeValue("port")));
-                    fcp.setEdition(transport.getAttributeValue("edition"));
+                    
fcp.setEdition(Integer.parseInt(transport.getAttributeValue("edition")));
                     fcp.setInsertURI(transport.getAttributeValue("insertURI"));
                     
fcp.setActiveLink(Boolean.valueOf(transport.getAttributeValue("activeLink")).booleanValue());
                     if (fcp.getActiveLink()){


Reply via email to