01: // PropertyFeeder.java
02: // $Id: RealmUsersFeeder.java,v 1.3 2000/08/16 21:37:27 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigadm.editors;
07:
08: import org.w3c.jigadm.RemoteResourceWrapper;
09:
10: import org.w3c.jigsaw.admin.RemoteAccessException;
11: import org.w3c.jigsaw.admin.RemoteResource;
12:
13: import java.util.Properties;
14:
15: /**
16: * RealmUsersFeeder :
17: * @author Benoit Mahe <bmahe@sophia.inria.fr>
18: */
19: public class RealmUsersFeeder implements EditorFeeder {
20:
21: RemoteResourceWrapper rrw;
22: Properties p;
23:
24: public String[] getDefaultItems() {
25: return getStringArray(rrw, p);
26: }
27:
28: protected String[] getStringArray(RemoteResourceWrapper rrw,
29: Properties p) {
30: RemoteResourceWrapper w = rrw;
31: RemoteResource rm = w.getResource();
32: RemoteResource target = null;
33: String realm = null;
34: try {
35: realm = (String) rm.getValue("realm");
36: } catch (RemoteAccessException ex) {
37: ex.printStackTrace();
38: }
39: if (realm == null)
40: return new String[0];
41:
42: do {
43: w = w.getFatherWrapper();
44: if (w != null) {
45: rm = w.getResource();
46: try {
47: if ((rm.getClassHierarchy())[0]
48: .equals("org.w3c.jigsaw.http.ConfigResource"))
49: target = rm.loadResource("realms");
50: } catch (RemoteAccessException ex) {
51: ex.printStackTrace();
52: }
53: } else
54: return new String[0];
55: } while (target == null);
56:
57: try {
58: target = target.loadResource(realm);
59: } catch (RemoteAccessException ex) {
60: target = null;
61: }
62: if (target == null)
63: return new String[0];
64: try {
65: return target.enumerateResourceIdentifiers();
66: } catch (RemoteAccessException ex) {
67: ex.printStackTrace();
68: return new String[0];
69: }
70: }
71:
72: public void initialize(RemoteResourceWrapper rrw, Properties p) {
73: this.rrw = rrw;
74: this.p = p;
75: }
76:
77: }
|