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 com.artenum.so6.dataflow.util;
034:
035: import org.libresource.so6.adapter.ls.exec.ui.CreateLibresourceReplica;
036: import org.libresource.so6.adapter.ls.tools.IndeterminateProgressView;
037: import org.libresource.so6.core.client.AuthenticationException;
038: import org.libresource.so6.core.client.LocalException;
039: import org.libresource.so6.core.client.ServerException;
040: import org.libresource.so6.core.client.UnableToContactServerException;
041: import org.libresource.so6.core.exec.CreateGenericWsConnection;
042:
043: import java.io.IOException;
044:
045: import java.util.Hashtable;
046:
047: import javax.swing.JOptionPane;
048:
049: /**
050: * @author Sebastien
051: */
052: public class CreateWorkspace extends LsClassicPropertiesEditor {
053: private String basePath;
054: private String wsName;
055: private String queueId;
056: private String login;
057: private String password;
058: private IndeterminateProgressView view;
059:
060: public CreateWorkspace(String queueId, String clientName)
061: throws IOException {
062: super ("Create Workspace");
063: addTextPropertie("wsName", "Workspace Name :", "");
064: addPathPropertie("basePath", "Base Path :", "");
065: addTextPropertie("synchronizerURI", "Synchronizer URI :",
066: queueId);
067: addTextPropertie("login", "Login :", "");
068: addPasswordPropertie("password", "Password :", "");
069:
070: Hashtable props = editProperties();
071:
072: if (props != null) {
073: view = new IndeterminateProgressView("Workspace creation",
074: "Please wait during the local workspace creation...");
075:
076: basePath = (String) props.get("basePath");
077: wsName = (String) props.get("wsName");
078: queueId = (String) props.get("synchronizerURI");
079: login = (String) props.get("login");
080: password = (String) props.get("password");
081:
082: //
083: try {
084: new CreateGenericWsConnection(basePath, wsName,
085: clientName, login, password, queueId, null)
086: .execute();
087: } catch (AuthenticationException e) {
088: e.printStackTrace();
089: JOptionPane
090: .showMessageDialog(null,
091: "<html><b>Invalide user name or password</b><br></html>");
092: view.dispose();
093: } catch (ServerException e) {
094: e.printStackTrace();
095: JOptionPane.showMessageDialog(null,
096: "<html><b>Server error</b><br>"
097: + e.getMessage() + "</html>");
098: view.dispose();
099: } catch (IOException e) {
100: e.printStackTrace();
101: JOptionPane.showMessageDialog(null,
102: "<html><b>Local error (IO error)</b><br>"
103: + e.getMessage() + "</html>");
104: view.dispose();
105: } catch (UnableToContactServerException e) {
106: e.printStackTrace();
107: JOptionPane.showMessageDialog(null,
108: "<html><b>Unable to contact server</b><br>"
109: + e.getMessage() + "</html>");
110: view.dispose();
111: } catch (LocalException e) {
112: e.printStackTrace();
113: JOptionPane.showMessageDialog(null,
114: "<html><b>Local error</b><br>" + e.getMessage()
115: + "</html>");
116: view.dispose();
117: } catch (Exception e) {
118: e.printStackTrace();
119: JOptionPane.showMessageDialog(null,
120: "<html><b>Error</b><br>" + e.getMessage()
121: + "</html>");
122: view.dispose();
123: }
124: } else {
125: view.dispose();
126: }
127:
128: view.dispose();
129: }
130:
131: public static void main(String[] args) throws Exception {
132: if (args.length > 1) {
133: System.err
134: .println("The only parameter required is the client class name");
135: System.err
136: .println("To set default value please use System properties");
137: System.err
138: .println(" (1) createLibresourceReplica.basePath = workspace base path");
139: System.err
140: .println(" (2) createLibresourceReplica.wsName = name of the workspace");
141: System.err
142: .println(" (3) createLibresourceReplica.queueId = the synchronizer URI");
143: System.err
144: .println(" (4) createLibresourceReplica.login = user login");
145: System.err
146: .println(" (5) createLibresourceReplica.password = user password");
147: } else if (args.length == 1) {
148: String queueId = System.getProperties().getProperty(
149: "createLibresourceReplica.queueId", "");
150: String basePath = System.getProperties().getProperty(
151: "createLibresourceReplica.basePath", "");
152: String login = System.getProperties().getProperty(
153: "createLibresourceReplica.login", "");
154: String password = System.getProperties().getProperty(
155: "createLibresourceReplica.password", "");
156: String wsName = System.getProperties().getProperty(
157: "createLibresourceReplica.wsName", "");
158: String clientName = args[0];
159:
160: new CreateLibresourceReplica(queueId, basePath, login,
161: password, wsName, clientName, null);
162: JOptionPane
163: .showMessageDialog(
164: null,
165: "<html>Your replica has been created localy.<br>(Refresh your browser to see it...)</html>");
166: }
167: }
168: }
|