using System; using System.IO; using System.Web; using System.Web.Services.Protocols; namespace Repository { /// ///

Deploys and undeploys archives.
/// Calls Deploy proxy.
/// Implements only static methods.
/// Base class of RepSubs and RepoArchs.

///

Copyright (c) 2002 Alexis Grandemange
/// Mail: alexis.grandemange@pagebox.net

///
This program is free software; you can redistribute it and/or
	/// modify it under the terms of the GNU Lesser General Public
	/// License as published by the Free Software Foundation; version
	/// 2.1 of the License.
	/// This library is distributed in the hope that it will be useful,
	/// but WITHOUT ANY WARRANTY; without even the implied warranty of
	/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	/// GNU Lesser General Public License for more details.
	/// A copy of the GNU Lesser General Public License lesser.txt should be
	/// included in the distribution.
///
public class Deployer { /// Deploy on a PageBox. /// status /// user who issued the command /// host which issued the command /// PageBox URL /// archive /// owner /// documentation URL /// download URL protected static string deploy(string user, string host, string pu, string a, string o, string dou, string du) { if (!File.Exists(Global.archRep.downloadPath + a)) return a + " doesn't exist"; DateTime date = File.GetLastWriteTime(Global.archRep.downloadPath + a); FileStream fs = File.Open(Global.archRep.downloadPath + a, FileMode.Open, FileAccess.Read); int size = (int)fs.Length; fs.Close(); String pageboxURL = pu; if (pu.IndexOf("://") == -1) pageboxURL = "http://" + pu; Deploy d = new Deploy(pageboxURL); try { d.Discover(); } catch(Exception e) { Log.write(user, host, "deploy(" + pu + ", " + a + ", " + o + ") returned pending deploy"); return a + " pending deploy"; } try { string rc = d.add(a, du, o, size, date, dou, user); Log.write(user, host, "deploy(" + pu + ", " + a + ", " + o + ") returned " + rc); if (rc.Equals(a + " installed")) return rc; else return null; } catch(System.Net.WebException we) { Log.write(user, host, "deploy(" + pu + ", " + a + ", " + o + ") returned pending deploy"); return a + " pending deploy"; } catch(System.Web.HttpException he) { Log.write(user, host, "deploy(" + pu + ", " + a + ", " + o + ") returned pending deploy"); return a + " pending deploy"; } catch(SoapException se) { Log.write(user, host, "deploy(" + pu + ", " + a + ", " + o + ") returned pending deploy"); return a + " pending deploy"; } } /// Undeploy from a PageBox. /// true in case of success /// user who issued the command /// host which issued the command /// PageBox URL /// archive /// owner /// download URL protected static bool undeploy(string user, string host, string pu, string a, string o, string du) { String pageboxURL = pu; if (pu.IndexOf("://") == -1) pageboxURL = "http://" + pu; Deploy d = new Deploy(pageboxURL); try { d.Discover(); } catch(Exception e) { Log.write(user, host, "undeploy(" + pu + ", " + a + ", " + o + ") returned pending undeploy"); return false; } string rc = ""; try { rc = d.delete(a, du, o, user); } catch(System.Net.WebException we) { Log.write(user, host, "undeploy(" + pu + ", " + a + ", " + o + ") returned pending undeploy"); return false; } catch(System.Web.HttpException he) { Log.write(user, host, "undeploy(" + pu + ", " + a + ", " + o + ") returned pending undeploy"); return false; } catch(SoapException se) { Log.write(user, host, "undeploy(" + pu + ", " + a + ", " + o + ") returned pending undeploy"); return false; } Log.write(user, host, "undeploy(" + pu + ", " + a + ", " + o + ") returned " + rc); if (rc.Equals(a + " uninstalled")) return true; else return false; } } }