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/TBWeblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
2008-02-19 20:28:19 UTC (rev 18078)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
2008-02-20 01:22:10 UTC (rev 18079)
@@ -150,6 +150,13 @@
super.publish(progress);
} else {
super.doFlogPublish(progress);
+ // Now we update the urls with the new edition number
+ String url = baseUrl;
+ if(!url.endsWith("/"))
+ url += "/";;
+ url = url.substring(0,url.length()-2);
+ url += ((FCPTransport) getPublishTransport()).getEdition() +
"/";
+ setBlogUrls(basePath,url,url,url);
}
}
@@ -159,6 +166,13 @@
super.publishAll(progress);
} else {
super.doFlogPublish(progress);
+ // Now we update the urls with the new edition number
+ String url = baseUrl;
+ if(!url.endsWith("/"))
+ url += "/";;
+ url = url.substring(0,url.length()-2);
+ url += ((FCPTransport) getPublishTransport()).getEdition() +
"/";
+ setBlogUrls(basePath,url,url,url);
}
}
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());
if(!result)
{
//progress.publishFailed(transport.getFailureReason());
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/WeblogPreviewer.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/WeblogPreviewer.java
2008-02-19 20:28:19 UTC (rev 18078)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/WeblogPreviewer.java
2008-02-20 01:22:10 UTC (rev 18079)
@@ -134,7 +134,7 @@
Desktop.browse(new URL(previewBlog.getFrontPageUrl()));
} else {
String nodeHostname = TBGlobals.getProperty("NODE_HOSTNAME");
- Desktop.browse(new URL("http://" + nodeHostname + ":8888" +
previewBlog.getFrontPageUrl()));
+ Desktop.browse(new URL("http://" + nodeHostname + ":8888/" +
previewBlog.getFrontPageUrl()));
}
}
catch(Exception ex)
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-02-19 20:28:19 UTC (rev 18078)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-02-20 01:22:10 UTC (rev 18079)
@@ -30,9 +30,12 @@
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.SortedMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@@ -52,6 +55,7 @@
import net.sf.thingamablog.transport.LocalTransport;
import net.sf.thingamablog.transport.PublishTransport;
import net.sf.thingamablog.transport.SFTPTransport;
+import net.sf.thingamablog.util.freenet.fcp.fcpManager;
/**
* @author Bob Tantlinger
@@ -85,6 +89,7 @@
private CardLayout tLayout;
private JTabbedPane ftpTabs = new JTabbedPane();
private ASCIIPanel asciiPanel = new ASCIIPanel();
+ private Logger logger =
Logger.getLogger("net.sf.thingamablog.gui.properties");
public TBPublishTransportPanel(TBWeblog wb, String InsertURI)
{
@@ -252,7 +257,29 @@
} else {
FCPTransport pt = new FCPTransport();
pt.setNode(fcpPanel.getMachineNameField(),fcpPanel.getPortField());
- pt.setInsertURI(InsertURI);
+ // If we are changing the publish transport after the
Dialog Wizard, we need to create a new key pair
+
+ if(InsertURI == null) {
+ logger.log(Level.INFO,"Creating a new SSK key
pair...");
+ fcpManager fcp = new fcpManager();
+ String keys[];
+
fcp.setNode(fcpPanel.getMachineNameField(),fcpPanel.getPortField());
+ try {
+ keys=fcp.generateKeyPair();
+ keys[0]=keys[0].substring("SSK".length());
+ keys[1]=keys[1].substring("SSK".length());
+ InsertURI="USK" + keys[0];
+
weblog.setBlogUrls(weblog.getBasePath(),"USK"+keys[1],weblog.getArchiveUrl(),weblog.getMediaUrl());
+ } catch (IOException ex) {
+
JOptionPane.showMessageDialog(TBPublishTransportPanel.this,
+ fcpPanel.getMachineNameField() + ":" +
fcpPanel.getPortField() + " : " + ex, i18n.str("key_generation_failure"),
//$NON-NLS-1$ //$NON-NLS-2$
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ logger.log(Level.INFO,"Done!");
+
+ }
+ pt.setInsertURI(InsertURI);
pt.setEdition("1");
pt.setTitle(fcpPanel.getTitle());
if(weblog.getPublishTransport() == null ||
weblog.getPublishTransport() instanceof LocalTransport){
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-19 20:28:19 UTC (rev 18078)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-20 01:22:10 UTC (rev 18079)
@@ -416,12 +416,6 @@
boolean valid = true;
valid = valid && isValidSSK(urlField.getText());
valid = valid && isValidSSK(insertUriField.getText());
- if (pathField.getText().contains("/")) {
- JOptionPane.showMessageDialog(TBWizardDialog.this,
- i18n.str("invalid_path_prompt"),
i18n.str("invalid_path"), //$NON-NLS-1$ //$NON-NLS-2$
- JOptionPane.WARNING_MESSAGE);
- valid = false;
- }
return valid;
} else {
insertUriField.setText("none");
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)
@@ -79,16 +79,11 @@
* @return true on success, false otherwise
*/
public boolean disconnect(){
- // We do the publish process during the disconnection (I hope it will
be temporary, time I get a solution)
if (client.isDisconnected())
return true;
logger.info("Disconnecting from the node...");
Manager.getConnection().disconnect();
logger.info("Disconnected!");
- if (hasPublish){
- hasPublish=false;
- edition++;
- }
return true;
}
@@ -115,7 +110,7 @@
return false;
}
- public boolean publishFile(Hashtable ht, PublishProgress tp){
+ 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
!");
@@ -126,16 +121,16 @@
String dirURI = "freenet:USK@" + insertURI + "/" + title + "/" +
edition + "/";
System.out.println("Insert URI : " + dirURI);
ClientPutComplexDir putDir = new ClientPutComplexDir("Thingamablog
insert", dirURI);
- putDir.setDefaultName("blog.html");
+ putDir.setDefaultName(frontPage);
putDir.setMaxRetries(-1);
int totalBytes = 0;
for(Enumeration e = ht.keys() ; e.hasMoreElements() ;) {
- File file = (File)e.nextElement();
- FileEntry fileEntry = createFileEntry(file, edition);
+ Object element = e.nextElement();
+ File file = (File)element;
+ String path = ((String)
ht.get(element)).substring(arcPath.length());
+ FileEntry fileEntry = createFileEntry(file, edition, path);
if (fileEntry != null) {
System.out.println("File to insert : " +
fileEntry.getFilename());
- System.out.println("Method : " + fileEntry.getName());
- System.out.println("Local path :" + ((DiskFileEntry)
fileEntry).getLocalFilename());
totalBytes += file.length();
putDir.addFileEntry(fileEntry);
}
@@ -145,6 +140,7 @@
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());
return false;
@@ -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;
}
- 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;
}