01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: AdminManager.java,v 1.2 2002/06/08 00:49:39 mediumnet Exp $
08:
09: package org.ozoneDB.core.admin;
10:
11: import java.io.*;
12:
13: import org.xml.sax.*;
14: import org.xml.sax.helpers.*;
15:
16: import org.apache.xml.serialize.*;
17:
18: import org.ozoneDB.*;
19: import org.ozoneDB.util.*;
20: import org.ozoneDB.core.*;
21: import org.ozoneDB.core.xml.*;
22: import org.ozoneDB.xml.util.*;
23: import org.ozoneDB.DxLib.*;
24:
25: /**
26: * This class does nothing than handling the initialization of the admin
27: * system.
28: *
29: * @version $Revision: 1.2 $ $Date: 2002/06/08 00:49:39 $
30: * @author <a href="http://www.smb-tec.com">SMB</a>
31: * @see Admin
32: */
33: public final class AdminManager extends ServerComponent {
34:
35: public AdminManager(Env _env) {
36: super (_env);
37: }
38:
39: public void startup() throws Exception {
40: env.logWriter.newEntry(this , "startup...", LogWriter.INFO);
41:
42: User user = env.userManager.userForID(0);
43: // happens if db was not initialized by proper version of install tool
44: if (user == null) {
45: env.userManager.newUser("root", 0);
46: user = env.userManager.userForID(0);
47: if (user == null) {
48: throw new UserManagerExc(
49: "Unable to create root user account.");
50: }
51: }
52: Transaction ta = env.transactionManager.newTransaction(user);
53:
54: ObjectContainer adminContainer = env.storeManager
55: .containerForIDAndPin(ta, new ObjectID(
56: AdminImpl.OBJECT_ID));
57:
58: try {
59: if (adminContainer == null) {
60: env.logWriter.newEntry(this ,
61: "No admin object found. Initializing...",
62: LogWriter.INFO);
63:
64: ObjectContainer container = ta.createObjectAndPin(
65: AdminImpl.class.getName(),
66: OzoneInterface.GroupRead
67: | OzoneInterface.GroupLock,
68: AdminImpl.OBJECT_NAME, null, null,
69: new ObjectID(AdminImpl.OBJECT_ID));
70:
71: try {
72: ta.prepareCommit();
73: ta.commit();
74: env.logWriter.newEntry(this ,
75: "Admin object created.", LogWriter.INFO);
76: } finally {
77: container.unpin();
78: }
79: }
80: } finally {
81: if (adminContainer != null) {
82: adminContainer.unpin();
83: }
84: }
85: env.transactionManager.deleteTransaction();
86: }
87:
88: public void shutdown() throws Exception {
89: env.logWriter.newEntry(this , "shutdown...", LogWriter.INFO);
90: }
91:
92: public void save() throws Exception {
93: }
94:
95: }
|