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.exec;
034:
035: import org.libresource.so6.core.StateMonitoring;
036: import org.libresource.so6.core.WsConnection;
037: import org.libresource.so6.core.client.WorkspaceListener;
038: import org.libresource.so6.core.engine.log.LogUtils;
039: import org.libresource.so6.core.engine.log.StandardOutputWriter;
040: import org.libresource.so6.core.engine.log.monitoring.XMLMonitoringThread;
041: import org.libresource.so6.core.exec.tools.CheckWscParameters;
042:
043: import java.util.Properties;
044: import java.util.logging.Logger;
045:
046: /**
047: * The <code>Commit</code> class is used to commit local changes
048: *
049: * @author Smack
050: * @version 1.0, 26/05/04
051: * @see org.libresource.so6.core.WsConnection
052: * @since JDK1.4
053: */
054: public class Update {
055: private WsConnection ws;
056: private XMLMonitoringThread monitoringThread;
057:
058: /**
059: * Instantiate the update process
060: *
061: * @param wsPath
062: * @throws Exception
063: */
064: public Update(String wsPath) throws Exception {
065: this .ws = new WsConnection(wsPath);
066:
067: if (this .ws.getProperty("so6.clienti.name").equals(
068: "org.libresource.so6.core.client.ClientIServletImpl")) {
069: CheckWscParameters checkWscParameters = new CheckWscParameters(
070: wsPath);
071: checkWscParameters.editProperties();
072:
073: Properties newProps = checkWscParameters.getWscProps();
074: this .ws.updateProp(newProps);
075: }
076:
077: // init output
078: LogUtils.removeAllHandlers(Logger.getLogger("ui.log"));
079: LogUtils.removeAllHandlers(StateMonitoring.getInstance()
080: .getXMLMonitoringLogger());
081: monitoringThread = new XMLMonitoringThread();
082:
083: StandardOutputWriter outWriter = new StandardOutputWriter(
084: monitoringThread.getTreeContext());
085: monitoringThread.attachMessageWriter(outWriter);
086: }
087:
088: /**
089: * Execute the update process
090: *
091: * @throws Exception
092: */
093: public void execute() throws Exception {
094: monitoringThread.setDaemon(true);
095: monitoringThread.start();
096: ws.update();
097:
098: // monitoringThread.join();
099: if (ws.getClient() instanceof WorkspaceListener) {
100: ((WorkspaceListener) ws.getClient())
101: .notifyQueue(ws.getNs());
102: }
103:
104: System.out.println("\n*** Report ***\n");
105: System.out.println(ws.getReport());
106: }
107:
108: /**
109: * Simulate the update process
110: *
111: * @param outputDir
112: * @throws Exception
113: */
114: public void simulate(String outputDir) throws Exception {
115: ws.setSimulationMode(true, outputDir);
116:
117: //
118: monitoringThread.start();
119: ws.update();
120: monitoringThread.join();
121: }
122:
123: /**
124: * Instantiate and execute the update process
125: *
126: * @param args
127: * path of the connection property file
128: * @throws Exception
129: */
130: public static void main(String[] args) throws Exception {
131: if (args.length != 1) {
132: System.err.println("Usage: wscPath");
133: System.err.println(" (1) wscPath: path of the file "
134: + WsConnection.SO6_WSC_FILE);
135: } else {
136: Update update = new Update(args[0]);
137: update.execute();
138: System.out.println("\007");
139: System.exit(0);
140: }
141: }
142: }
|