1 9 package org.ozoneDB.core.admin; 10 11 import org.ozoneDB.OzoneInterface; 12 import org.ozoneDB.core.*; 13 import org.ozoneDB.util.LogWriter; 14 15 16 24 public final class AdminManager extends ServerComponent { 25 26 public AdminManager( Env _env) { 27 super( _env ); 28 } 29 30 31 public void startup() throws Exception { 32 env.logWriter.newEntry( this, "startup...", LogWriter.INFO ); 33 34 User user = env.userManager.userForID( 0 ); 35 if (user == null) { 37 env.userManager.newUser( "root", 0 ); 38 user = env.userManager.userForID( 0 ); 39 if (user == null) { 40 throw new UserManagerException( "Unable to create root user account." ); 41 } 42 } 43 Transaction ta = env.transactionManager.newTransaction( user ); 44 45 ObjectContainer adminContainer = env.storeManager.containerForID( ta, new ObjectID( AdminImpl.OBJECT_ID )); 46 47 try { 48 if (adminContainer == null) { 49 env.logWriter.newEntry( this, "No admin object found. Initializing...", LogWriter.INFO ); 50 51 ObjectContainer container = ta.createObject( AdminImpl.class.getName(), OzoneInterface.GroupRead | OzoneInterface.GroupLock, AdminImpl.OBJECT_NAME, null, null, new ObjectID( AdminImpl.OBJECT_ID ) ); 52 53 try { 54 ta.prepareCommit(); 55 ta.commit(); 56 env.logWriter.newEntry( this, "Admin object created.", LogWriter.INFO ); 57 } finally { 58 container.unpin(); 59 } 60 } 61 } finally { 62 if (adminContainer!=null) { 63 adminContainer.unpin(); 64 } 65 } 66 env.transactionManager.deleteTransaction(); 67 } 68 69 70 public void shutdown() throws Exception { 71 env.logWriter.newEntry( this, "shutdown...", LogWriter.INFO ); 72 } 73 74 75 public void save() throws Exception { 76 } 77 78 } 79 80 | Popular Tags |