KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > admin > AdminImpl


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: AdminImpl.java,v 1.2 2002/06/08 00:49:39 mediumnet Exp $
8

9 package org.ozoneDB.core.admin;
10
11 import java.io.*;
12
13 import org.ozoneDB.core.*;
14 import org.ozoneDB.DxLib.*;
15
16
17 /**
18  * <p>This is the server side implementation of the ozone admin system. Some of
19  * the admin functions are directly provided by this class. For other functions
20  * this class serves as a facade for the actual implementation classes.</p>
21  *
22  * @version $Revision: 1.2 $ $Date: 2002/06/08 00:49:39 $
23  * @author <a HREF="http://www.smb-tec.com">SMB</a>
24  * @see Admin
25  */

26 public class AdminImpl
27         extends OzoneSupportObject
28         implements Admin, Externalizable {
29
30     protected final static long serialVersionUID = 1;
31
32     /**
33      * The object ID of the admin object in the database.
34      */

35     public final static long OBJECT_ID = 1;
36
37     /**
38      * The name of the admin object in the database.
39      */

40     public final static String JavaDoc OBJECT_NAME = "ozonedb.admin";
41
42     protected transient Env env;
43
44     protected transient BackupRestore backupRestore;
45
46
47     public AdminImpl() {
48         init();
49     }
50
51
52     protected void init() {
53         env = Env.currentEnv();
54         backupRestore = new BackupRestore(env);
55     }
56
57
58     public void writeExternal(ObjectOutput out) throws IOException {
59     }
60
61
62     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc {
63         init();
64     }
65
66
67     public void newUser(String JavaDoc _name, int _id) throws Exception JavaDoc {
68         if (_id < 100) {
69             throw new UserManagerException("IDs <100 are reserved by the system.");
70         }
71         env.userManager.newUser(_name, _id);
72     }
73
74
75     public void newUser(String JavaDoc _name, String JavaDoc _passwd, int _id) throws Exception JavaDoc {
76         if (_id < 100) {
77             throw new UserManagerException("IDs <100 are reserved by the system.");
78         }
79         env.userManager.newUser(_name, _passwd, _id);
80     }
81
82
83     public void removeUser(String JavaDoc _name) throws Exception JavaDoc {
84         env.userManager.removeUser(_name);
85     }
86
87
88     public void newGroup(String JavaDoc _name, int _id) throws Exception JavaDoc {
89         if (_id < 100) {
90             throw new UserManagerException("IDs <100 are reserved by the system.");
91         }
92         env.userManager.newGroup(_name, _id);
93     }
94
95
96     public void removeGroup(String JavaDoc _name) throws Exception JavaDoc {
97         env.userManager.removeGroup(_name);
98     }
99
100
101     public void addUser2Group(String JavaDoc _username, String JavaDoc _groupname) throws Exception JavaDoc {
102         env.userManager.addUserToGroup(_username, _groupname);
103     }
104
105
106     public void removeUserFromGroup(String JavaDoc _username, String JavaDoc _groupname) throws Exception JavaDoc {
107         env.userManager.removeUserFromGroup(_username, _groupname);
108     }
109
110
111     public DxCollection allUsers() throws Exception JavaDoc {
112         return env.userManager.allUsers();
113     }
114
115
116     public DxCollection allGroups() throws Exception JavaDoc {
117         return env.userManager.allGroups();
118     }
119
120
121     public User userForName(String JavaDoc _name) throws Exception JavaDoc {
122         return env.userManager.userForName(_name);
123     }
124
125
126     public Group groupForName(String JavaDoc _name) throws Exception JavaDoc {
127         return env.userManager.groupForName(_name);
128     }
129
130
131     public User userForId(int _id) throws Exception JavaDoc {
132         return env.userManager.userForID(_id);
133     }
134
135
136     public Group groupForId(int _id) throws Exception JavaDoc {
137         return env.userManager.groupForID(_id);
138     }
139
140
141     public void shutdown() throws Exception JavaDoc {
142         Server.stop = true;
143     }
144
145
146     public void beginRestore() throws Exception JavaDoc {
147         backupRestore.beginRestore();
148     }
149
150
151     public void processRestoreChunk(byte[] chunk) throws Exception JavaDoc {
152         backupRestore.processRestoreChunk(chunk);
153     }
154
155
156     public void beginBackup() throws Exception JavaDoc {
157         backupRestore.beginBackup();
158     }
159
160
161     public byte[] nextBackupChunk() throws Exception JavaDoc {
162         return backupRestore.nextBackupChunk();
163     }
164
165
166     public int numberOfTxs() throws Exception JavaDoc {
167         return Env.currentEnv().transactionManager.taTableCount();
168     }
169
170     public void startGarbageCollection() {
171         env.getGarbageCollector().start();
172     }
173 }
174
175
Popular Tags