/[dgee]/dgee/adminWS/DGEE.Admin/DGEEAdmin.cs
ViewVC logotype

Diff of /dgee/adminWS/DGEE.Admin/DGEEAdmin.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by npg, Sat Jun 21 18:20:42 2003 UTC revision 1.2 by csmith, Sun Sep 21 11:07:15 2003 UTC
# Line 0  Line 1 
1    /* Hey Emacs! read this in -*- csharp -*- mode please!!!
2     *
3     * DotGNU DGEE Administrator Web Service
4     *
5     * Copyright (C) 2003 Nicolai P Guba <nicolai@btinternet.com>
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20     *
21     * $Revision$  $Date$
22     *
23     * --------------------------------------------------------------------------
24     */
25    
26    namespace DGEE.Admin
27    {
28      using System;
29      using DotGNU.XmlRpc;
30      using System.Collections;
31      
32      /**
33       * Session
34       */
35      [WebService(Description="DGEE administration session interface", Namespace="http://nfluid.com")]
36      public sealed class Session
37      {
38        private String id = "";
39        private bool isValid = false;
40        
41        // Note: This class should probably be moved so that generic
42        // logons for webservices are handled.  In this case support for
43        // non-authenticated sessions needs to be implemneted and the
44        // namespace adjusted of course.
45        public Session( String senderId, String pwd ) : base()
46        {
47          // TODO:  GWService lookup for credentials
48          
49          // TODO:  GWService retrieval of SessionId
50          
51          
52          // set the session id to the approprate value
53          id = senderId + "-1jk3o-3ak992-666";
54          isValid = true;
55        }
56        
57        public String Id
58        {
59          get {
60            return id;
61          }
62        }
63    
64        public bool Valid
65        {
66          get {
67            return isValid;
68          }
69        }
70        
71        [WebMethod("session.Validate", Description="Determines whether session timed out")]
72        internal bool Validate()
73        {
74          // TODO: Determine whether Session hasnt timed out, has been
75          // invalidated by GW (ie logout) or other nasty little things
76          // that a superadin can do to his users
77          isValid = true;
78          
79          return isValid;
80        }    
81    
82        [WebMethod("session.Timeout", Description="Force the session to time out")]
83        internal void Timeout()
84        {
85          isValid = false;
86        }
87      }
88    
89      [WebService(Description="DGEE administration WebService", Namespace="http://nfluid.com")]
90      public sealed class WebService
91      {
92        private String name;
93        
94        public WebService( String name ) : base()
95        {
96          this.name = name;
97        }
98        
99        public String Name
100        {
101          get {
102            return name;
103          }
104        }
105    
106        public ArrayList GetMethods()
107        {
108          return new ArrayList();
109        }
110        
111        internal bool IsEnabled()
112        {
113          // FIXME:  Call GW to see whether the WS is enabled or not
114          return true;
115        }
116      }
117      
118      public sealed class ByteCode
119      {
120        String mimeType;
121        String code;
122        
123        public ByteCode( String mimeType, String code )
124        {
125          this.mimeType = mimeType;
126          this.code = code;
127        }
128    
129        public String MimeType
130        {
131          get {
132            return mimeType;
133          }
134        }
135        
136        public String Code
137        {
138          get {
139            return code;
140          }
141        }    
142      }
143      
144      /**
145       * WebService
146       */
147      [WebService(Description="These methods implement the installation and removal of webservices from the DGEE.")]
148      public sealed class WebServiceManager
149      {
150        private Session session;
151        
152        public WebServiceManager( Session session ) : base()
153        {
154          this.session = session;
155        }
156    
157        [WebMethod("manager.Install", Description="Install a webservice in the DGEE")]
158        public String Install( WebService ws, ByteCode byteCode, String fileName )
159        {
160          if (session.Valid) {
161            Console.WriteLine( "{1} >>> {0} WebService '{2}'", "Installing", session.Id, ws.Name );
162          }
163          
164          return "";
165        }
166    
167        [WebMethod("manager.Uninstall", Description="Uninstall a webservice in the DGEE")]
168        public String Remove( WebService ws )
169        {
170          if( session.Valid ) {
171            this.Disable( ws );
172            Console.WriteLine( "{1} >>> {0} WebService '{2}'", "Removing", session.Id, ws.Name );
173          }
174          
175          return "";
176        }
177    
178        [WebMethod("manager.Disable", Description="Disable a webservice in the DGEE")]
179        public String Disable( WebService ws )
180        {
181          if( session.Valid && ws.IsEnabled() ) {
182            Console.WriteLine( "{1} >>> {0} WebService '{2}'", "Disabling", session.Id, ws.Name );
183          }
184          return "";
185        }
186    
187        [WebMethod("manager.Enable", Description="Enable a webservice in the DGEE")]
188        public String Enable( WebService ws )
189        {
190          if (session.Valid) {
191    
192            if( ws.IsEnabled() == false ) {
193              Console.WriteLine( "{1} >>> {0} WebService '{2}'", "Already Enabled", session.Id, ws.Name );
194            }
195            else {
196              Console.WriteLine( "{1} >>> {0} WebService '{2}'", "Enabling", session.Id, ws.Name );
197            }
198          }
199          return "";
200        }    
201      };
202    
203      public class Test
204      {
205        static void Main()
206        {
207          Session s = new Session ( "npg", "letmein" );
208          WebServiceManager w1 = new WebServiceManager( s );
209    
210          ByteCode bc   = new ByteCode( "bc/mime", "%$£$^&^&&*" );
211          WebService ws = new WebService( "/DGEE/WS/FooBar" );
212          
213          w1.Install( ws, bc, "/home/npg/FoobarWS.dgmx");
214          w1.Enable(  ws );
215          w1.Remove(  ws );
216        }
217      }
218    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26