|                                                                                                              1
 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
 26  public class AdminImpl
 27          extends OzoneSupportObject
 28          implements Admin, Externalizable {
 29
 30      protected final static long serialVersionUID = 1;
 31
 32
 35      public final static long OBJECT_ID = 1;
 36
 37
 40      public final static String
  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
  { 63          init();
 64      }
 65
 66
 67      public void newUser(String
  _name, int _id) throws Exception  { 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
  _name, String  _passwd, int _id) throws Exception  { 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
  _name) throws Exception  { 84          env.userManager.removeUser(_name);
 85      }
 86
 87
 88      public void newGroup(String
  _name, int _id) throws Exception  { 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
  _name) throws Exception  { 97          env.userManager.removeGroup(_name);
 98      }
 99
 100
 101     public void addUser2Group(String
  _username, String  _groupname) throws Exception  { 102         env.userManager.addUserToGroup(_username, _groupname);
 103     }
 104
 105
 106     public void removeUserFromGroup(String
  _username, String  _groupname) throws Exception  { 107         env.userManager.removeUserFromGroup(_username, _groupname);
 108     }
 109
 110
 111     public DxCollection allUsers() throws Exception
  { 112         return env.userManager.allUsers();
 113     }
 114
 115
 116     public DxCollection allGroups() throws Exception
  { 117         return env.userManager.allGroups();
 118     }
 119
 120
 121     public User userForName(String
  _name) throws Exception  { 122         return env.userManager.userForName(_name);
 123     }
 124
 125
 126     public Group groupForName(String
  _name) throws Exception  { 127         return env.userManager.groupForName(_name);
 128     }
 129
 130
 131     public User userForId(int _id) throws Exception
  { 132         return env.userManager.userForID(_id);
 133     }
 134
 135
 136     public Group groupForId(int _id) throws Exception
  { 137         return env.userManager.groupForID(_id);
 138     }
 139
 140
 141     public void shutdown() throws Exception
  { 142         Server.stop = true;
 143     }
 144
 145
 146     public void beginRestore() throws Exception
  { 147         backupRestore.beginRestore();
 148     }
 149
 150
 151     public void processRestoreChunk(byte[] chunk) throws Exception
  { 152         backupRestore.processRestoreChunk(chunk);
 153     }
 154
 155
 156     public void beginBackup() throws Exception
  { 157         backupRestore.beginBackup();
 158     }
 159
 160
 161     public byte[] nextBackupChunk() throws Exception
  { 162         return backupRestore.nextBackupChunk();
 163     }
 164
 165
 166     public int numberOfTxs() throws Exception
  { 167         return Env.currentEnv().transactionManager.taTableCount();
 168     }
 169
 170     public void startGarbageCollection() {
 171         env.getGarbageCollector().start();
 172     }
 173 }
 174
 175
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |