Author: dieppe
Date: 2008-04-09 21:10:04 +0000 (Wed, 09 Apr 2008)
New Revision: 19121

Modified:
   trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
   
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:
Allow a user to change the path of the key



Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java    
2008-04-09 19:49:29 UTC (rev 19120)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java    
2008-04-09 21:10:04 UTC (rev 19121)
@@ -408,7 +408,7 @@
             FCPTransport fcp = (FCPTransport) transport;
             int index = this.getFrontPageUrl().lastIndexOf("/");
             String defaultName = this.getFrontPageUrl().substring(index+1);
-            boolean result = 
fcp.publishFile(ht,progress,defaultName,getArchivePath(),this.getTitle());
+            boolean result = 
fcp.publishFile(ht,progress,defaultName,getArchivePath());
             if(!result)
                                {
                                        
//progress.publishFailed(transport.getFailureReason());

Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
===================================================================
--- 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
 2008-04-09 19:49:29 UTC (rev 19120)
+++ 
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
 2008-04-09 21:10:04 UTC (rev 19121)
@@ -194,6 +194,7 @@
                             fcpPanel.setActiveLinkPath(t.getActiveLinkPath());
                         }
                         fcpPanel.setEditionNumber(t.getEdition());
+                        fcpPanel.setFlogSSKPath(t.getSSKPath());
                         transportTypeCombo.setSelectedItem(FCP);
                         tLayout.show(transportsPanel, FCP);
                 }
@@ -270,9 +271,10 @@
                         }
                         String url = fcpPanel.getRequestUri();                 
       
                         int firstSlash = url.indexOf('/');
-                        url = url.substring(0,firstSlash+1) + 
ASCIIconv.convertNonAscii(weblog.getTitle()) + "/" + 
fcpPanel.getEditionNumber() + "/";
+                        url = url.substring(0,firstSlash+1) + 
ASCIIconv.convertNonAscii(fcpPanel.getFlogSSKPath()) + "/" + 
fcpPanel.getEditionNumber() + "/";
                         weblog.setBlogUrls("none",url,url,url);
                         pt.setEdition(fcpPanel.getEditionNumber());
+                        pt.setSSKPath(fcpPanel.getFlogSSKPath());
                         transport = pt;
                 }

@@ -310,6 +312,7 @@

     private boolean validateOptions(FcpTransportPanel fcp)
     {
+        if(!fcp.getFlogSSKPath().equals("")){
             if (!fcp.getActiveLink() || 
DefaultMIMETypes.guessMIMEType(fcp.getActiveLinkPath()).equals("image/png")){
                 return true;
             } else {
@@ -317,6 +320,11 @@
                        JOptionPane.WARNING_MESSAGE);
                 return false;
             }            
+        } else {
+            JOptionPane.showMessageDialog(this, 
i18n.str("invalid_path_prompt"), i18n.str("invalid_path"),  //$NON-NLS-1$ 
//$NON-NLS-2$
+                       JOptionPane.WARNING_MESSAGE);
+            return false;
+        }
     }

     private class RemoteTransportPanel extends JPanel
@@ -478,6 +486,7 @@
                 private JTextField insertUriField;
                 private JTextField activeLinkPathField;
                 private JTextField editionNumberField;
+                private JTextField flogSSKPath;
                 private JCheckBox activeLinkCheckBox;
                 private JButton generateKeyButton;
                public FcpTransportPanel()
@@ -487,6 +496,7 @@
                         requestUriField = new JTextField();
                         insertUriField = new JTextField();
                         activeLinkPathField = new JTextField();
+                        flogSSKPath = new JTextField();
                         activeLinkCheckBox = new JCheckBox();
                         generateKeyButton = new JButton();
                         editionNumberField = new JTextField();
@@ -508,7 +518,7 @@
                         portField.setText(TBGlobals.getProperty("NODE_PORT"));
                         //Default machine name
                         
machineNameField.setText(TBGlobals.getProperty("NODE_HOSTNAME"));
-                        generateKeyButton.setText(i18n.str("generate_keys"));
+                        generateKeyButton.setText(i18n.str("generate_keys"));  
                      
                        LabelledItemPanel lip = new LabelledItemPanel();
                        JPanel p = new JPanel(new BorderLayout());
                        p.add(portField, BorderLayout.WEST);
@@ -519,8 +529,9 @@
                         
lip.addItem(i18n.str("activeLinkPath"),activeLinkPathField);
                         lip.addItem(i18n.str("requestUri"),requestUriField);
                         lip.addItem(i18n.str("insertUri"),insertUriField);     
                   
+                        lip.addItem("",generateKeyButton);
                         
lip.addItem(i18n.str("currentEdition"),editionNumberField);
-                        lip.addItem("",generateKeyButton);
+                        lip.addItem(i18n.str("flogSSKPath"),flogSSKPath);
                        setLayout(new BorderLayout());
                        add(lip, BorderLayout.CENTER);  
                }
@@ -587,6 +598,14 @@
             return Integer.parseInt(this.editionNumberField.getText());
         }

+        public String getFlogSSKPath(){
+            return flogSSKPath.getText();
+        }
+        
+        public void setFlogSSKPath(String path){
+            this.flogSSKPath.setText(path);
+        }
+        
         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-04-09 19:49:29 UTC (rev 19120)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 
2008-04-09 21:10:04 UTC (rev 19121)
@@ -48,6 +48,7 @@
     private int port;
     private boolean activeLink;
     private String activeLinkPath;
+    private String SSKPath;

     /**
      * Connects the transport
@@ -111,7 +112,7 @@
         return false;
     }

-    public boolean publishFile(Hashtable ht, PublishProgress tp, String 
frontPage, String arcPath, String title){
+    public boolean publishFile(Hashtable ht, PublishProgress tp, String 
frontPage, String arcPath){
         //We do the publish job for an entire directory
         if(!Manager.isConnected()){
             logger.log(Level.WARNING,"The connection to the node is not open 
!");
@@ -120,7 +121,7 @@
         }
         System.out.println("Beginning of the publish process...");
         int current_edition = edition + 1;
-        String dirURI = "freenet:USK@" + insertURI + "/" + 
ASCIIconv.convertNonAscii(title) + "/" + current_edition + "/";
+        String dirURI = "freenet:USK@" + insertURI + "/" + 
ASCIIconv.convertNonAscii(this.SSKPath) + "/" + current_edition + "/";
         System.out.println("Insert URI : " + dirURI);
         ClientPutComplexDir putDir = new ClientPutComplexDir("Thingamablog 
insert", dirURI);
         System.out.println("Default name : " + frontPage);
@@ -242,6 +243,14 @@
         return this.activeLinkPath;
     }

+    public String getSSKPath(){
+        return this.SSKPath;
+    }
+    
+    public void setSSKPath(String path){
+        this.SSKPath = path;
+    }
+    
     private String shortenURI(String uri) {
         if (uri.startsWith("freenet:")) {
             uri = uri.substring("freenet:".length());

Modified: 
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java   
2008-04-09 19:49:29 UTC (rev 19120)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java   
2008-04-09 21:10:04 UTC (rev 19121)
@@ -485,6 +485,7 @@
                     if (fpt.getActiveLink()){
                         
transport.setAttribute("activeLinkPath",fpt.getActiveLinkPath());
                     }
+                    transport.setAttribute("SSKPath",fpt.getSSKPath());
                 }
                else
                {
@@ -549,11 +550,11 @@

                if(weblog == null)
                        return null;
-               
-               
weblog.setPublishTransport(loadPublishTransportFromXML(blogEle));
+               String title = blogEle.getAttributeValue("title", "Untitled");
+               weblog.setPublishTransport(loadPublishTransportFromXML(blogEle, 
title));
                loadPingServicesFromXML(blogEle, weblog);
         loadEmailSettingsFromXML(blogEle, weblog);
-               weblog.setTitle(blogEle.getAttributeValue("title", "Untitled"));
+               weblog.setTitle(title);
                String description = "";
                Element desc = blogEle.getChild("Description");
                if(desc != null)
@@ -826,7 +827,7 @@
                return loc;             
        }

-       private static PublishTransport loadPublishTransportFromXML(Element 
parent)
+       private static PublishTransport loadPublishTransportFromXML(Element 
parent, String title)
        {
                Element transport = parent.getChild("Transport");
                if(transport == null)
@@ -882,6 +883,9 @@
                     if (fcp.getActiveLink()){
                         
fcp.setActiveLinkPath(transport.getAttributeValue("activeLinkPath"));
                     }
+                    fcp.setSSKPath(transport.getAttributeValue("SSKPath"));
+                    if(fcp.getSSKPath() == null)
+                        fcp.setSSKPath(title);                    
                     pubTransport = fcp;
                 }
                else            


Reply via email to