001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.core.tool;
034:
035: import org.libresource.so6.core.Workspace;
036: import org.libresource.so6.core.WsConnection;
037: import org.libresource.so6.core.client.DummyClient;
038: import org.libresource.so6.core.exec.CreateDummyWorkspace;
039:
040: import java.io.File;
041:
042: import java.util.logging.ConsoleHandler;
043: import java.util.logging.Formatter;
044: import java.util.logging.Handler;
045: import java.util.logging.Level;
046: import java.util.logging.LogRecord;
047: import java.util.logging.Logger;
048:
049: /**
050: * @author molli
051: */
052: public class Main {
053: private String clientPath;
054: private String[] dirs;
055:
056: private Main(String clientPath, String[] dirs) {
057: this .clientPath = clientPath;
058: this .dirs = dirs;
059: Logger.getLogger("fileparser.log").setLevel(Level.OFF);
060:
061: Handler[] handlers = Logger.getLogger("").getHandlers();
062:
063: for (int index = 0; index < handlers.length; index++) {
064: Logger.getLogger("").removeHandler(handlers[index]);
065: }
066:
067: handlers = Logger.getLogger("ui.log").getHandlers();
068:
069: for (int index = 0; index < handlers.length; index++) {
070: Logger.getLogger("ui.log").removeHandler(handlers[index]);
071: }
072:
073: Logger.getLogger("ui.log").setLevel(Level.SEVERE);
074:
075: Handler ca = new ConsoleHandler();
076: ca.setFormatter(new so6Formatter());
077: Logger.getLogger("ui.log").addHandler(ca);
078: }
079:
080: private void doit() throws Exception {
081: DummyClient dc = new DummyClient(clientPath);
082: CreateDummyWorkspace cdr;
083:
084: for (int i = 0; i < dirs.length; i++) {
085: File f = new File(dirs[i] + File.separator
086: + Workspace.SO6PREFIX + File.separator + "1"
087: + File.separator + WsConnection.SO6_WSC_FILE);
088:
089: if (!f.exists()) {
090: cdr = new CreateDummyWorkspace(dirs[i], clientPath,
091: dirs[i]);
092: cdr.execute();
093: }
094: }
095:
096: for (int i = 0; i < dirs.length; i++) {
097: Logger.getLogger("ui.log").info("Synchronizing:" + dirs[i]);
098:
099: WsConnection ws = new WsConnection(dirs[i] + File.separator
100: + Workspace.SO6PREFIX + File.separator + "1"
101: + File.separator + WsConnection.SO6_WSC_FILE);
102: ws.update();
103: ws.commit("sync " + dirs[i]);
104: }
105:
106: for (int i = 0; i < (dirs.length - 1); i++) {
107: Logger.getLogger("ui.log").info("Synchronizing:" + dirs[i]);
108:
109: WsConnection ws = new WsConnection(dirs[i] + File.separator
110: + Workspace.SO6PREFIX + File.separator + "1"
111: + File.separator + WsConnection.SO6_WSC_FILE);
112: ws.update();
113: ws.commit("sync " + dirs[i]);
114: }
115: }
116:
117: public static void main(String[] args) throws Exception {
118: if (args.length < 2) {
119: throw new Exception(
120: "Usage: <Op Queue dir> <dir1> <dir2>... <dirn>");
121: }
122:
123: String[] dirs = new String[args.length - 1];
124:
125: for (int i = 1; i < args.length; i++) {
126: dirs[i - 1] = new File(args[i]).getAbsolutePath();
127: }
128:
129: Main m = new Main(args[0], dirs);
130: m.doit();
131: }
132:
133: public class so6Formatter extends Formatter {
134: public String format(LogRecord record) {
135: return record.getMessage() + "\n";
136: }
137: }
138: }
|