import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
*/
public class ProjectInserter implements FileScannerListener, Runnable {
+ /** The logger. */
+ private static final Logger logger = Logger.getLogger(ProjectInserter.class.getName());
+
/** Random number for FCP instances. */
private static final int random = (int) (Math.random() * Integer.MAX_VALUE);
/** Counter for FCP connection identifier. */
private static int counter = 0;
- /** Whether debug mode is set. */
- private boolean debug = false;
-
/** The list of insert listeners. */
private List<InsertListener> insertListeners = new ArrayList<InsertListener>();
}
/**
- * Sets the debug mode.
- *
- * @param debug
- * <code>true</code> to activate debug mode, <code>false</code>
- * to deactivate
- */
- public void setDebug(boolean debug) {
- this.debug = debug;
- }
-
- /**
* Sets the project to insert.
*
* @param project
while (!finished) {
Message message = client.readMessage();
finished = (message == null) || (disconnected = client.isDisconnected());
- if (debug) {
- System.out.println(message);
- }
if (firstMessage) {
fireProjectUploadFinished();
firstMessage = false;
}
+ logger.log(Level.FINE, "Received message: " + message);
if (!finished) {
@SuppressWarnings("null")
String messageName = message.getName();
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import de.todesbaum.jsite.main.Main;
import de.todesbaum.jsite.main.Version;
*/
public class UpdateChecker implements Runnable {
+ /** The logger. */
+ private static final Logger logger = Logger.getLogger(UpdateChecker.class.getName());
+
/** Counter for connection names. */
private static int counter = 0;
int currentEdition = lastUpdateEdition;
while (!shouldStop()) {
checkNow = false;
- System.out.println("Trying " + constructUpdateKey(currentEdition));
+ logger.log(Level.FINE, "Trying " + constructUpdateKey(currentEdition));
ClientGet clientGet = new ClientGet("get-update-key");
clientGet.setUri(constructUpdateKey(currentEdition));
clientGet.setPersistence(Persistence.CONNECTION);
boolean stop = false;
while (!stop) {
Message message = client.readMessage();
- System.out.println(message);
+ logger.log(Level.FINEST, "Received message: " + message);
if ("GetFailed".equals(message.getName())) {
if ("27".equals(message.get("code"))) {
String editionString = message.get("redirecturi").split("/")[2];
/* ignore. */
}
if (editionNumber != -1) {
- System.out.println("Found new edition " + editionNumber);
+ logger.log(Level.INFO, "Found new edition " + editionNumber);
currentEdition = editionNumber;
lastUpdateEdition = editionNumber;
checkNow = true;
}
}
if ("AllData".equals(message.getName())) {
- System.out.println("Update data found.");
+ logger.log(Level.FINE, "Update data found.");
InputStream dataInputStream = null;
Properties properties = new Properties();
try {
if (foundVersion != null) {
lastVersion = foundVersion;
String versionTimestampString = properties.getProperty("jSite.Date");
- System.out.println(versionTimestampString);
+ logger.log(Level.FINEST, "Version timestamp: " + versionTimestampString);
long versionTimestamp = -1;
try {
versionTimestamp = Long.parseLong(versionTimestampString);
}
}
} catch (IOException e) {
- System.out.println("Got IOException: " + e.getMessage());
+ logger.log(Level.INFO, "Got IOException: " + e.getMessage());
e.printStackTrace();
}
if (!checkNow && !shouldStop()) {
}
/**
- * Sets whether to activate the debug mode.
- *
- * @param debug
- * <code>true</code> to activate the debug mode,
- * <code>false</code> to deactivate.
- */
- public void setDebug(boolean debug) {
- projectInserter.setDebug(debug);
- }
-
- /**
* Sets the project to insert.
*
* @param project
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
*/
public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener, UpdateListener {
- /** Whether the debug mode is activated. */
- private static boolean debug = false;
-
/** The version. */
private static final Version VERSION = new Version(0, 7);
pages.put(PageType.PAGE_PROJECT_FILES, projectFilesPage);
ProjectInsertPage projectInsertPage = new ProjectInsertPage(wizard);
- projectInsertPage.setDebug(debug);
projectInsertPage.setName("page.project.insert");
projectInsertPage.setFreenetInterface(freenetInterface);
pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
* The command-line arguments
*/
public static void main(String[] args) {
+ /* initialize logger. */
+ Logger logger = Logger.getLogger("de.todesbaum");
+ Handler handler = new ConsoleHandler();
+ logger.addHandler(handler);
String configFilename = null;
boolean nextIsConfigFilename = false;
for (String argument : args) {
printHelp();
return;
} else if ("--debug".equals(argument)) {
- debug = true;
+ logger.setLevel(Level.ALL);
+ handler.setLevel(Level.ALL);
} else if ("--config-file".equals(argument)) {
nextIsConfigFilename = true;
}