~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/webservices/.svn/text-base/iFolderCommonLocal.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
|
3
 
| Copyright (c) 2007 Novell, Inc.
4
 
| All Rights Reserved.
5
 
|
6
 
| This program is free software; you can redistribute it and/or
7
 
| modify it under the terms of version 2 of the GNU General Public License as
8
 
| published by the Free Software Foundation.
9
 
|
10
 
| This program is distributed in the hope that it will be useful,
11
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
| GNU General Public License for more details.
14
 
|
15
 
| You should have received a copy of the GNU General Public License
16
 
| along with this program; if not, contact Novell, Inc.
17
 
|
18
 
| To contact Novell about this file by physical or electronic mail,
19
 
| you may find current contact information at www.novell.com 
20
 
|
21
 
| Author: Rob 
22
 
|***************************************************************************/
23
 
 
24
 
using System;
25
 
using System.Web;
26
 
using System.Web.Services;
27
 
using System.Web.Services.Protocols;
28
 
using System.Collections;
29
 
 
30
 
using Simias.Storage;
31
 
using Simias.Server;
32
 
 
33
 
namespace iFolder.WebService
34
 
{
35
 
        /// <summary>
36
 
        /// iFolder Common Local Web Service
37
 
        /// </summary>
38
 
        public abstract class iFolderCommonLocal : System.Web.Services.WebService
39
 
        {
40
 
                #region Constructors
41
 
                
42
 
                /// <summary>
43
 
                /// Constructor
44
 
                /// </summary>
45
 
                public iFolderCommonLocal()
46
 
                {
47
 
                }
48
 
                
49
 
                #endregion
50
 
 
51
 
                #region System
52
 
 
53
 
                /// <summary>
54
 
                /// Get information about the iFolder system.
55
 
                /// </summary>
56
 
                /// <returns>An iFolderSystem object describing the system.</returns>
57
 
                [WebMethod(
58
 
                         Description="Get information about the iFolder system.",
59
 
                         EnableSession=true)]
60
 
                public virtual iFolderSystem GetSystem()
61
 
                {
62
 
                        iFolderSystem result = null;
63
 
 
64
 
                        try
65
 
                        {
66
 
                                Authorize();
67
 
 
68
 
                                result = iFolderSystem.GetSystem();
69
 
                        }
70
 
                        catch(Exception e)
71
 
                        {
72
 
                                SmartException.Throw(e);
73
 
                        }
74
 
 
75
 
                        return result;
76
 
                }
77
 
 
78
 
                /// <summary>
79
 
                /// Get information about the authenticated user's home iFolder server.
80
 
                /// </summary>
81
 
                /// <returns>An iFolderServer object describing the user's home iFolder server.</returns>
82
 
                [WebMethod(
83
 
                         Description="Get information about the authenticated user's home iFolder server.",
84
 
                         EnableSession=true)]
85
 
                public virtual iFolderServer GetHomeServer()
86
 
                {
87
 
                        iFolderServer result = null;
88
 
 
89
 
                        try
90
 
                        {
91
 
                                Authorize();
92
 
 
93
 
                                result = iFolderServer.GetHomeServer();
94
 
                        }
95
 
                        catch(Exception e)
96
 
                        {
97
 
                                SmartException.Throw(e);
98
 
                        }
99
 
 
100
 
                        return result;
101
 
                }
102
 
 
103
 
                /// <summary>
104
 
                /// Get the location of the iFolder
105
 
                /// </summary>
106
 
                /// <returns>The PrivateUrl of the iFolder's HomeServer.</returns>
107
 
                [WebMethod(
108
 
                         Description="Get information about the authenticated user's home iFolder server.",
109
 
                         EnableSession=true)]
110
 
                public virtual string GetiFolderLocation ( string ifolderID )
111
 
                {
112
 
                        string result = null;
113
 
 
114
 
                        try
115
 
                        {
116
 
                                Authorize();
117
 
 
118
 
                                result = iFolder.GetiFolderLocation ( ifolderID );
119
 
                        }
120
 
                        catch(Exception e)
121
 
                        {
122
 
                                SmartException.Throw(e);
123
 
                        }
124
 
 
125
 
                        return result;
126
 
                }
127
 
 
128
 
                /// <summary>
129
 
                /// Get all the searched orphaned ifolders 
130
 
                /// </summary>
131
 
                /// <returns>a list of orphaned ifolders. </returns>
132
 
                
133
 
                [WebMethod(
134
 
                         Description="Get Orphaned iFolders",
135
 
                         EnableSession=true)]
136
 
                public virtual iFolderSet GetOrphanediFolders(SearchOperation operation, string pattern, int index, int max  )
137
 
                {
138
 
                        iFolderSet OrphiFolderList = new iFolderSet();
139
 
                        try
140
 
                        {
141
 
                                Authorize();
142
 
 
143
 
                                OrphiFolderList = iFolder.GetOrphanediFolders ( operation, pattern, index, max, GetAccessID() );
144
 
                        }
145
 
                        catch(Exception e)
146
 
                        {
147
 
                                SmartException.Throw(e);
148
 
                        }
149
 
 
150
 
                        return OrphiFolderList;
151
 
                }
152
 
 
153
 
                /// <summary>
154
 
                /// Checks whether an ifolder is orphaned or not 
155
 
                /// </summary>
156
 
                /// <returns>. string 'false' if the ifolder is not orphaned otherwise returns userID of prev owner</returns>
157
 
 
158
 
                [WebMethod(
159
 
                         Description="check orphaned property",
160
 
                         EnableSession=true)]
161
 
                public virtual string IsOrphanediFolder(string iFolderID)
162
 
                {
163
 
                        string isorphaned = "";
164
 
                        
165
 
                        try
166
 
                        {
167
 
                                Authorize();
168
 
 
169
 
                                isorphaned = iFolder.IsOrphanediFolder (iFolderID, GetAccessID() );
170
 
                        }
171
 
                        catch(Exception e)
172
 
                        {
173
 
                                SmartException.Throw(e);
174
 
                        }
175
 
                        return isorphaned;
176
 
                }       
177
 
 
178
 
                
179
 
        
180
 
                /// <summary>
181
 
                /// Get the list of recovery agents
182
 
                /// </summary>
183
 
                /// <returns>The list containing recovery agents name</returns>
184
 
                [WebMethod(
185
 
                         Description="Get the list of recovery agents",
186
 
                         EnableSession=true)]
187
 
                public virtual string[] GetRAList ()
188
 
                {
189
 
                        string[] result = null;
190
 
 
191
 
                        try
192
 
                        {
193
 
                                Authorize();
194
 
 
195
 
                                result = iFolder.GetRAList ();
196
 
                        }
197
 
                        catch(Exception e)
198
 
                        {
199
 
                                SmartException.Throw(e);
200
 
                        }
201
 
 
202
 
                        return result;
203
 
                }
204
 
                
205
 
                /// <summary>
206
 
                /// Get the RA Certificate
207
 
                /// </summary>
208
 
                /// <returns>The byte array containing the certificate</returns>
209
 
                [WebMethod(
210
 
                         Description="Get the RA Certificate",
211
 
                         EnableSession=true)]
212
 
                public virtual byte[] GetRACertificate(string rAgent)
213
 
                {
214
 
                        byte [] result = null;
215
 
 
216
 
                        try
217
 
                        {
218
 
                                Authorize();
219
 
 
220
 
                                result = iFolder.GetRACertificate (rAgent);
221
 
                        }
222
 
                        catch(Exception e)
223
 
                        {
224
 
                                SmartException.Throw(e);
225
 
                        }
226
 
 
227
 
                        return result;
228
 
                }
229
 
        
230
 
                /// <summary>
231
 
                /// Get the PassPhrase Status 
232
 
                /// </summary>
233
 
                /// <returns>The Status of pass-phrase</returns>
234
 
                [WebMethod(
235
 
                         Description="Get the pass-phrase status",
236
 
                         EnableSession=true)]
237
 
                public virtual bool IsPassPhraseSet ()
238
 
                {
239
 
                        Store store = Store.GetStore();
240
 
                        Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
241
 
                   // Simias.Authentication.Status result = new Simias.Authentication.Status( Simias.Authentication.StatusCodes.UnknownDomain );
242
 
                        bool result = false;
243
 
 
244
 
                        try
245
 
                        {
246
 
                                Authorize();
247
 
 
248
 
                                result = iFolderUser.IsPassPhraseSet(domain.ID, GetAccessID());
249
 
                        }
250
 
                        catch(Exception e)
251
 
                        {
252
 
                                SmartException.Throw(e);
253
 
                        }
254
 
 
255
 
                        return result;
256
 
                }
257
 
                
258
 
                ///<summary>
259
 
                ///Validate the passphrase for the correctness
260
 
                ///</summary>
261
 
                ///<returns>passPhrase.</returns>
262
 
                [WebMethod(EnableSession=true, Description="Validate the passphrase for the correctness.")]
263
 
                [SoapDocumentMethod]    
264
 
                public virtual Simias.Authentication.Status ValidatePassPhrase(string passPhrase)
265
 
                {
266
 
                        Store store = Store.GetStore();
267
 
                        Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
268
 
                    Simias.Authentication.Status result = new Simias.Authentication.Status( Simias.Authentication.StatusCodes.UnknownDomain );
269
 
                    try
270
 
                        {
271
 
                                Authorize();
272
 
 
273
 
                                result = iFolderUser.ValidatePassPhrase(domain.ID, passPhrase, GetAccessID());
274
 
                        }
275
 
                        catch(Exception e)
276
 
                        {
277
 
                                SmartException.Throw(e);
278
 
                        }
279
 
 
280
 
                        return result;
281
 
        
282
 
                }
283
 
                
284
 
                ///<summary>
285
 
                ///Set the passphrase and recovery agent
286
 
                ///</summary>
287
 
                ///<returns>passPhrase.</returns>
288
 
                [WebMethod(EnableSession=true, Description="Set the passphrase and recovery agent.")]
289
 
                [SoapDocumentMethod]
290
 
                public virtual void SetPassPhrase(string passPhrase, string recoveryAgentName, string publicKey)
291
 
                {
292
 
                        Store store = Store.GetStore();
293
 
                        Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
294
 
                    try
295
 
                        {
296
 
                                Authorize();
297
 
 
298
 
                                iFolderUser.SetPassPhrase(domain.ID, passPhrase, recoveryAgentName, publicKey, GetAccessID() );
299
 
                        }
300
 
                        catch(Exception e)
301
 
                        {
302
 
                                SmartException.Throw(e);
303
 
                        }
304
 
 
305
 
                }
306
 
                
307
 
 
308
 
                /// <summary>
309
 
                /// Get information about an iFolder Server.
310
 
                /// </summary>
311
 
                /// <param name="serverID">The id of the iFolder Server.</param>
312
 
                /// <returns>An iFolderServer object describing the iFolder Server.</returns>
313
 
                [WebMethod(
314
 
                         Description="Get information about an iFolder Server.",
315
 
                         EnableSession=true)]
316
 
                public virtual iFolderServer GetServer(string serverID)
317
 
                {
318
 
                        iFolderServer result = null;
319
 
 
320
 
                        try
321
 
                        {
322
 
                                Authorize();
323
 
 
324
 
                                result = iFolderServer.GetServer(serverID);
325
 
                        }
326
 
                        catch(Exception e)
327
 
                        {
328
 
                                SmartException.Throw(e);
329
 
                        }
330
 
 
331
 
                        return result;
332
 
                }
333
 
                
334
 
                /// <summary>
335
 
                /// Get information about all the iFolder servers.
336
 
                /// </summary>
337
 
                /// <returns>An array of iFolderServer objects.</returns>
338
 
                [WebMethod(
339
 
                         Description="Get information about all the iFolder servers.",
340
 
                         EnableSession=true)]
341
 
                public virtual iFolderServer[] GetServers()
342
 
                {
343
 
                        iFolderServer[] result = null;
344
 
 
345
 
                        try
346
 
                        {
347
 
                                Authorize();
348
 
 
349
 
                                result = iFolderServer.GetServers();
350
 
                        }
351
 
                        catch(Exception e)
352
 
                        {
353
 
                                SmartException.Throw(e);
354
 
                        }
355
 
 
356
 
                        return result;
357
 
                }
358
 
 
359
 
 
360
 
                /// <summary>
361
 
                /// Get the home server for the user
362
 
                /// </summary>
363
 
                /// <returns>Publiv url of the home server.</returns>
364
 
                [WebMethod(
365
 
                         Description="Get the home server for the user.",
366
 
                         EnableSession=true)]
367
 
                public virtual string GetHomeServerForUser( string username , string password)
368
 
                {
369
 
                        string result;
370
 
 
371
 
                        result = iFolderServer.GetHomeServerForUser ( username, password );
372
 
 
373
 
                        return result;
374
 
                }
375
 
 
376
 
                /// <summary>
377
 
                /// 
378
 
                /// </summary>
379
 
                /// <returns>An array of iFolderServer objects.</returns>
380
 
                [WebMethod(
381
 
                         Description="Get information about the reports.",
382
 
                         EnableSession=true)]
383
 
                public virtual string[] GetReports()
384
 
                {
385
 
                        string[] result = null;
386
 
 
387
 
                        try
388
 
                        {
389
 
                                Authorize();
390
 
 
391
 
                                result = iFolderServer.GetReports ();
392
 
                        }
393
 
                        catch(Exception e)
394
 
                        {
395
 
                                SmartException.Throw(e);
396
 
                        }
397
 
 
398
 
                        return result;
399
 
                }
400
 
 
401
 
                /// <summary>
402
 
                /// Get information about iFolder Servers identified by a search on name.
403
 
                /// </summary>
404
 
                /// <param name="operation">The operation to compare the name and pattern.</param>
405
 
                /// <param name="pattern">The pattern to search.</param>
406
 
                /// <param name="index">The starting index for the search results.</param>
407
 
                /// <param name="count">The max number of search results to be returned.</param>
408
 
                /// <returns>A set of iFolder Server objects.</returns>
409
 
                [WebMethod(
410
 
                         Description="Get information about iFolder Servers identified by a search on name.",
411
 
                         EnableSession=true)]
412
 
                public virtual iFolderServerSet GetServersByName(SearchOperation operation, string pattern,
413
 
                        int index, int count)
414
 
                {
415
 
                        iFolderServerSet result = null;
416
 
 
417
 
                        try
418
 
                        {
419
 
                                Authorize();
420
 
 
421
 
                                result = iFolderServer.GetServersByName(iFolderServerType.All, operation, pattern, index, count);
422
 
                        }
423
 
                        catch(Exception e)
424
 
                        {
425
 
                                SmartException.Throw(e);
426
 
                        }
427
 
 
428
 
                        return result;
429
 
                }
430
 
 
431
 
                #endregion
432
 
 
433
 
                #region iFolders
434
 
 
435
 
                /// <summary>
436
 
                /// Delete an iFolder
437
 
                /// </summary>
438
 
                /// <param name="ifolderID">The id of the iFolder to be deleted.</param>
439
 
                /// <remarks>This API will accept multiple iFolder ids in a comma delimited list.</remarks>
440
 
                [WebMethod(
441
 
                         Description="Delete an iFolder",
442
 
                         EnableSession=true)]
443
 
                public virtual void DeleteiFolder(string ifolderID)
444
 
                {
445
 
                        Hashtable exceptions = new Hashtable();
446
 
 
447
 
                        try
448
 
                        {
449
 
                                Authorize();
450
 
 
451
 
                                string accessID = GetAccessID();
452
 
 
453
 
                                string[] ids = ifolderID.Split(new char[] {',', ' '});
454
 
 
455
 
                                foreach(string id in ids)
456
 
                                {
457
 
                                        if (id.Length > 0)
458
 
                                        {
459
 
                                                try
460
 
                                                {
461
 
                                                        iFolder.DeleteiFolder(id, accessID);
462
 
                                                }
463
 
                                                catch(Exception e)
464
 
                                                {
465
 
                                                        exceptions.Add(id, e);
466
 
                                                }
467
 
                                        }
468
 
                                }
469
 
                        }
470
 
                        catch(Exception e)
471
 
                        {
472
 
                                SmartException.Throw(e);
473
 
                        }
474
 
 
475
 
                        SmartException.Throw(exceptions);
476
 
                }
477
 
 
478
 
                /// <summary>
479
 
                /// Get information about an iFolder.
480
 
                /// </summary>
481
 
                /// <param name="ifolderID">The id of the iFolder.</param>
482
 
                /// <returns>An iFolder object describing the iFolder.</returns>
483
 
                [WebMethod(
484
 
                         Description="Get information about an iFolder.",
485
 
                         EnableSession=true)]
486
 
                public virtual iFolder GetiFolder(string ifolderID)
487
 
                {
488
 
                        iFolder result = null;
489
 
                        try
490
 
                        {
491
 
                                Authorize();
492
 
                                result = iFolder.GetiFolder(ifolderID, GetAccessID());
493
 
                        }
494
 
                        catch(Exception e)
495
 
                        {
496
 
                                SmartException.Throw(e);
497
 
                        }
498
 
 
499
 
                        return result;
500
 
                }
501
 
                
502
 
                /// <summary>
503
 
                /// Get detailed information about an iFolder.
504
 
                /// </summary>
505
 
                /// <param name="ifolderID">The id of the iFolder</param>
506
 
                /// <returns>An iFolderDetails object describing the iFolder</returns>
507
 
                /// <remarks>It is more expensive to call GetiFolderDetails than GetiFolder.</remarks>
508
 
                [WebMethod(
509
 
                         Description="Get detailed information about an iFolder.",
510
 
                         EnableSession=true)]
511
 
                public virtual iFolderDetails GetiFolderDetails(string ifolderID)
512
 
                {
513
 
                        iFolderDetails result = null;
514
 
 
515
 
                        try
516
 
                        {
517
 
                                Authorize();
518
 
 
519
 
                                result = iFolderDetails.GetiFolderDetails(ifolderID, GetAccessID());
520
 
                        }
521
 
                        catch(Exception e)
522
 
                        {
523
 
                                SmartException.Throw(e);
524
 
                        }
525
 
 
526
 
                        return result;
527
 
                }
528
 
                
529
 
                /// <summary>
530
 
                /// Set the description of an iFolder.
531
 
                /// </summary>
532
 
                /// <param name="ifolderID">The id of the iFolder.</param>
533
 
                /// <param name="description">The new description for the iFolder.</param>
534
 
                [WebMethod(
535
 
                         Description="Set the description of an iFolder.",
536
 
                         EnableSession=true)]
537
 
                public virtual void SetiFolderDescription(string ifolderID, string description)
538
 
                {
539
 
                        try
540
 
                        {
541
 
                                Authorize();
542
 
 
543
 
                                iFolder.SetDescription(ifolderID, description, GetAccessID());
544
 
                        }
545
 
                        catch(Exception e)
546
 
                        {
547
 
                                SmartException.Throw(e);
548
 
                        }
549
 
                }
550
 
 
551
 
                /// <summary>
552
 
                /// Publish an iFolder.
553
 
                /// </summary>
554
 
                /// <param name="ifolderID">The id of the iFolder.</param>
555
 
                /// <param name="publish">The published state of the iFolder</param>
556
 
                [WebMethod(
557
 
                         Description="Publish an iFolder.",
558
 
                         EnableSession=true)]
559
 
                public virtual void PublishiFolder(string ifolderID, bool publish)
560
 
                {
561
 
                        try
562
 
                        {
563
 
                                Authorize();
564
 
 
565
 
                                iFolder.PublishiFolder(ifolderID, publish, GetAccessID());
566
 
                        }
567
 
                        catch(Exception e)
568
 
                        {
569
 
                                SmartException.Throw(e);
570
 
                        }
571
 
                }
572
 
 
573
 
                #endregion
574
 
 
575
 
                #region Changes
576
 
                
577
 
                /// <summary>
578
 
                /// Get a history of changes to an iFolder.
579
 
                /// </summary>
580
 
                /// <param name="ifolderID">The id of the iFolder.</param>
581
 
                /// <param name="itemID">The id of item to filter the results (can be null for no filtering).</param>
582
 
                /// <param name="index">The starting index for the search results.</param>
583
 
                /// <param name="max">The max number of search results to be returned.</param>
584
 
                /// <returns>A set of ChangeEntry objects.</returns>
585
 
                [WebMethod(
586
 
                         Description="Get a history of changes to an iFolder.",
587
 
                         EnableSession=true)]
588
 
                public virtual ChangeEntrySet GetChanges(string ifolderID, string itemID, int index, int max)
589
 
                {
590
 
                        ChangeEntrySet result = null;
591
 
 
592
 
                        try
593
 
                        {
594
 
                                Authorize();
595
 
 
596
 
                                result = ChangeEntry.GetChanges(ifolderID, itemID, index, max, GetAccessID());
597
 
                        }
598
 
                        catch(Exception e)
599
 
                        {
600
 
                                SmartException.Throw(e);
601
 
                        }
602
 
 
603
 
                        return result;
604
 
                }
605
 
 
606
 
                /// <summary>
607
 
                /// To extract the aspx page from header
608
 
                /// </summary>
609
 
                /// <param name="sender"></param>
610
 
                /// <param name="e"></param>
611
 
                [WebMethod(
612
 
                         Description="Get a trimmed url from full url",
613
 
                         EnableSession=true)]
614
 
                public virtual string TrimUrl(string FullUrl)
615
 
                {
616
 
                        string TrimmedUrl = "iFolders.aspx";
617
 
                        try
618
 
                        {
619
 
                                if(FullUrl != "")
620
 
                                {
621
 
                                         TrimmedUrl = FullUrl.Substring(FullUrl.LastIndexOf('/') + 1);
622
 
                                         
623
 
                                }
624
 
                        }
625
 
                        catch(Exception e)
626
 
                        {
627
 
                                SmartException.Throw(e);
628
 
                        }
629
 
                        return TrimmedUrl;
630
 
                }
631
 
                
632
 
                #endregion
633
 
 
634
 
                #region User
635
 
 
636
 
                /// <summary>
637
 
                /// Get information about the authenticated user.
638
 
                /// </summary>
639
 
                /// <returns>An iFolderUser object describing the authenticated user.</returns>
640
 
                [WebMethod(
641
 
                         Description="Get information about the authenticated user.",
642
 
                         EnableSession=true)]
643
 
                public virtual iFolderUser GetAuthenticatedUser()
644
 
                {
645
 
                        iFolderUser result = null;
646
 
 
647
 
                        try
648
 
                        {
649
 
                                Authorize();
650
 
 
651
 
                                result = iFolderUser.GetUser(null, GetUserID(), GetAccessID());
652
 
                        }
653
 
                        catch(Exception e)
654
 
                        {
655
 
                                SmartException.Throw(e);
656
 
                        }
657
 
 
658
 
                        return result;
659
 
                }
660
 
 
661
 
                /// <summary>
662
 
                /// Set the rights of a member on an iFolder.
663
 
                /// </summary>
664
 
                /// <param name="ifolderID">The id of the iFolder.</param>
665
 
                /// <param name="userID">The user id of the member.</param>
666
 
                /// <param name="rights">The rights to be set.</param>
667
 
                /// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
668
 
                [WebMethod(
669
 
                         Description="Set the rights of a member on an iFolder.",
670
 
                         EnableSession=true)]
671
 
                public virtual void SetMemberRights(string ifolderID, string userID, Rights rights)
672
 
                {
673
 
                        Hashtable exceptions = new Hashtable();
674
 
 
675
 
                        try
676
 
                        {
677
 
                                Authorize();
678
 
 
679
 
                                string[] ids = userID.Split(new char[] {',', ' '});
680
 
 
681
 
                                foreach(string id in ids)
682
 
                                {
683
 
                                        if (id.Length > 0)
684
 
                                        {
685
 
                                                try
686
 
                                                {
687
 
                                                        iFolderUser.SetMemberRights(ifolderID, id, rights, GetAccessID());
688
 
                                                }
689
 
                                                catch(Exception e)
690
 
                                                {
691
 
                                                        exceptions.Add(id, e);
692
 
                                                }
693
 
                                        }
694
 
                                }
695
 
                        }
696
 
                        catch(Exception e)
697
 
                        {
698
 
                                SmartException.Throw(e);
699
 
                        }
700
 
 
701
 
                        SmartException.Throw(exceptions);
702
 
                }
703
 
 
704
 
                /// <summary>
705
 
                /// Add a member to an iFolder.
706
 
                /// </summary>
707
 
                /// <param name="ifolderID">The id of iFolder.</param>
708
 
                /// <param name="userID">The user id of the new member.</param>
709
 
                /// <param name="rights">The rights of the new member on the iFolder.</param>
710
 
                /// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
711
 
                [WebMethod(
712
 
                         Description="Add a member to an iFolder.",
713
 
                         EnableSession=true)]
714
 
                public virtual void AddMember(string ifolderID, string userID, Rights rights)
715
 
                {   
716
 
                        Hashtable exceptions = new Hashtable();
717
 
                        
718
 
                        try
719
 
                        {
720
 
                                Authorize();
721
 
 
722
 
                                string[] ids = userID.Split(new char[] {',', ' '});
723
 
 
724
 
                                foreach(string id in ids)
725
 
                                {
726
 
                                        if (id.Length > 0)
727
 
                                        {
728
 
                                                try
729
 
                                                {
730
 
                                                        iFolderUser.AddMember(ifolderID, id, rights, GetAccessID());
731
 
                                                }
732
 
                                                catch(Exception e)
733
 
                                                {
734
 
                                                        // save any exceptions
735
 
                                                        exceptions.Add(id, e);
736
 
                                                }
737
 
                                        }
738
 
                                }
739
 
                        }
740
 
                        catch(Exception e)
741
 
                        {
742
 
                                SmartException.Throw(e);
743
 
                        }
744
 
 
745
 
                        SmartException.Throw(exceptions);
746
 
                }
747
 
 
748
 
                /// <summary>
749
 
                /// Remove a member from an iFolder.
750
 
                /// </summary>
751
 
                /// <param name="ifolderID">The id of the iFolder.</param>
752
 
                /// <param name="userID">The user id of the member.</param>
753
 
                /// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
754
 
                [WebMethod(
755
 
                         Description="Remove a member from an iFolder.",
756
 
                         EnableSession=true)]
757
 
                public virtual void RemoveMember(string ifolderID, string userID)
758
 
                {
759
 
                        Hashtable exceptions = new Hashtable();
760
 
 
761
 
                        try
762
 
                        {
763
 
                                Authorize();
764
 
 
765
 
                                string[] ids = userID.Split(new char[] {',', ' '});
766
 
 
767
 
                                foreach(string id in ids)
768
 
                                {
769
 
                                        if (id.Length > 0)
770
 
                                        {
771
 
                                                try
772
 
                                                {
773
 
                                                        iFolderUser.RemoveMember(ifolderID, id, GetAccessID());
774
 
                                                }
775
 
                                                catch(Exception e)
776
 
                                                {
777
 
                                                        exceptions.Add(id, e);
778
 
                                                }
779
 
                                        }
780
 
                                }
781
 
 
782
 
                        }
783
 
                        catch(Exception e)
784
 
                        {
785
 
                                SmartException.Throw(e);
786
 
                        }
787
 
        
788
 
                        SmartException.Throw(exceptions);
789
 
                }
790
 
 
791
 
                /// <summary>
792
 
                /// Set the owner of an iFolder.
793
 
                /// </summary>
794
 
                /// <param name="ifolderID">The id of the iFolder.</param>
795
 
                /// <param name="userID">The user id of the new owner.</param>
796
 
                [WebMethod(
797
 
                         Description="Set the owner of an iFolder.",
798
 
                         EnableSession=true)]
799
 
                public virtual void SetiFolderOwner(string ifolderID, string userID, bool OrphanAdopt)
800
 
                {
801
 
                        try
802
 
                        {
803
 
                                Authorize();
804
 
 
805
 
                                iFolderUser.SetOwner(ifolderID, userID, GetAccessID(), OrphanAdopt);
806
 
                        }
807
 
                        catch(Exception e)
808
 
                        {
809
 
                                SmartException.Throw(e);
810
 
                        }
811
 
                }
812
 
 
813
 
                /// <summary>
814
 
                /// Get information about the members of an iFolder.
815
 
                /// </summary>
816
 
                /// <param name="ifolderID">The id of the iFolder.</param>
817
 
                /// <param name="index">The starting index for the search results.</param>
818
 
                /// <param name="max">The max number of search results to be returned.</param>
819
 
                /// <returns>A set of iFolderUser objects describing the members.</returns>
820
 
                [WebMethod(
821
 
                         Description="Get information about the members of an iFolder.",
822
 
                         EnableSession=true)]
823
 
                public virtual iFolderUserSet GetMembers(string ifolderID, int index, int max)
824
 
                {
825
 
                        iFolderUserSet result = null;
826
 
 
827
 
                        try
828
 
                        {
829
 
                                Authorize();
830
 
 
831
 
                                result = iFolderUser.GetUsers(ifolderID, index, max, GetAccessID());
832
 
                        }
833
 
                        catch(Exception e)
834
 
                        {
835
 
                                SmartException.Throw(e);
836
 
                        }
837
 
 
838
 
                        return result;
839
 
                }
840
 
 
841
 
                /// <summary>
842
 
                /// Get information about all of the iFolder users.
843
 
                /// </summary>
844
 
                /// <param name="index">The starting index for the search results.</param>
845
 
                /// <param name="max">The max number of search results to be returned.</param>
846
 
                /// <returns>A set of iFolderUser objects.</returns>
847
 
                [WebMethod(
848
 
                         Description="Get information about all of the iFolder users.",
849
 
                         EnableSession=true)]
850
 
                public virtual iFolderUserSet GetUsers(int index, int max)
851
 
                {
852
 
                        iFolderUserSet result = null;
853
 
 
854
 
                        try
855
 
                        {
856
 
                                Authorize();
857
 
 
858
 
                                result = iFolderUser.GetUsers(null, index, max, GetAccessID());
859
 
                        }
860
 
                        catch(Exception e)
861
 
                        {
862
 
                                SmartException.Throw(e);
863
 
                        }
864
 
 
865
 
                        return result;
866
 
                }
867
 
 
868
 
                /// <summary>
869
 
                /// Get information about a user using an id or username.
870
 
                /// </summary>
871
 
                /// <param name="userID">The id or username of the user.</param>
872
 
                /// <returns>A iFolderUser object.</returns>
873
 
                [WebMethod(
874
 
                         Description="Get information about a user using an id or username.",
875
 
                         EnableSession=true)]
876
 
                public virtual iFolderUser GetUser(string userID)
877
 
                {
878
 
                        iFolderUser result = null;
879
 
 
880
 
                        try
881
 
                        {
882
 
                                Authorize();
883
 
 
884
 
                                result = iFolderUser.GetUser(userID, GetAccessID());
885
 
                        }
886
 
                        catch(Exception e)
887
 
                        {
888
 
                                SmartException.Throw(e);
889
 
                        }
890
 
 
891
 
                        return result;
892
 
                }
893
 
 
894
 
                /// <summary>
895
 
                /// Get detailed information about a user.
896
 
                /// </summary>
897
 
                /// <param name="userID">The id of the user.</param>
898
 
                /// <returns>A iFolderUserDetails object.</returns>
899
 
                /// <remarks>It is more expensive to call GetUserDetails than GetUser.</remarks>
900
 
                [WebMethod(
901
 
                         Description="Get User Details",
902
 
                         EnableSession=true)]
903
 
                public virtual iFolderUserDetails GetUserDetails(string userID)
904
 
                {
905
 
                        iFolderUserDetails result = null;
906
 
 
907
 
                        try
908
 
                        {
909
 
                                Authorize();
910
 
 
911
 
                                result = iFolderUserDetails.GetDetails(userID);
912
 
                        }
913
 
                        catch(Exception e)
914
 
                        {
915
 
                                SmartException.Throw(e);
916
 
                        }
917
 
 
918
 
                        return result;
919
 
                }
920
 
 
921
 
                /// <summary>
922
 
                /// Get information about all of the iFolder users identified by the search property, operation, and pattern.
923
 
                /// </summary>
924
 
                /// <param name="property">The property to search.</param>
925
 
                /// <param name="operation">The operation to compare the property and pattern.</param>
926
 
                /// <param name="pattern">The pattern to search</param>
927
 
                /// <param name="index">The starting index for the search results.</param>
928
 
                /// <param name="max">The max number of search results to be returned.</param>
929
 
                /// <returns>A set of iFolderUser objects.</returns>
930
 
                [WebMethod(
931
 
                         Description="Get information about all of the iFolder users identified by the search property, operation, and pattern.",
932
 
                         EnableSession=true)]
933
 
                public virtual iFolderUserSet GetUsersBySearch(SearchProperty property, SearchOperation operation, string pattern, int index, int max)
934
 
                {
935
 
                        iFolderUserSet result = null;
936
 
 
937
 
                        try
938
 
                        {
939
 
                                Authorize();
940
 
 
941
 
                                result = iFolderUser.GetUsers(property, operation, pattern, index, max, GetAccessID());
942
 
                        }
943
 
                        catch(Exception e)
944
 
                        {
945
 
                                SmartException.Throw(e);
946
 
                        }
947
 
 
948
 
                        return result;
949
 
                }
950
 
 
951
 
                #endregion
952
 
 
953
 
                #region Utility
954
 
 
955
 
                /// <summary>
956
 
                /// Get the access user's id.
957
 
                /// </summary>
958
 
                protected abstract string GetAccessID();
959
 
 
960
 
                /// <summary>
961
 
                /// Get the authenticated user's id.
962
 
                /// </summary>
963
 
                protected abstract string GetUserID();
964
 
 
965
 
                /// <summary>
966
 
                /// Authorize the authenticated user.
967
 
                /// </summary>
968
 
                protected abstract void Authorize();
969
 
 
970
 
                #endregion
971
 
        }
972
 
}