Package org.atomojo.app.db

Examples of org.atomojo.app.db.DBInfo


            if (service==null) {
               getLogger().severe("Cannot find auth service "+databaseConf.getAuthName()+" for database "+adminDB.getName());
               continue;
            }
         }
         DBInfo dbinfo = new DBInfo(adminDB.getName(),adminDB,service,databaseConf==null ? null : databaseConf.getGroup(),databaseConf==null ? null : databaseConf.getGroupAlias());
         dbConfList.put(dbinfo.getName(),dbinfo);
         UserGuard adminGuard = new UserGuard(childContext,ChallengeScheme.HTTP_BASIC,"Atom Administrator",service);
         adminGuard.getRequiredGroups().add(AuthService.ADMIN_GROUP);

         try {
            adminGuard.setNext(new AdminApplication(childContext,adminDB,storageFactory.getStorage(adminDB),AtomApplication.RESOURCE_BASE));
View Full Code Here


   }
  
   protected void configure(VirtualHost vhost,ServerConfiguration.Host host)
      throws Exception
   {
      DBInfo atomDB = dbConfList.get(host.getDatabaseName());
      if (atomDB==null) {
         atomDB = autodbList.get(host.getDatabaseName());
      }
      if (atomDB==null) {
         throw new RuntimeException("Database "+host.getDatabaseName()+" does not exist.");
      }
      AuthService auth = atomDB.getAuthService();
      if (auth==null) {
         throw new RuntimeException("The auth service for database "+host.getDatabaseName()+" does not exist.");
      }
     
      Storage storage = storageFactory.getStorage(atomDB.getDB());


      Restlet adminApp = admins.get(atomDB.getName());
      if (adminApp==null) {
         getLogger().warning("There is no admin restlet for "+atomDB.getName());
      }
     
      AtomApplication app = new AtomApplication(childContext,auth,atomDB.getDB(),storage,host.allowQueries());

      Router router = new Router(childContext);
      router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
      router.attachDefault(app);
      router.attach("/admin",adminApp).getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
View Full Code Here

               }
               if (auth==null) {
                  getLogger().warning("Cannot configure db entry for "+dbName+" as auth service "+authName+" does not exist.");
                  return;
               }
               DBInfo dbinfo = autodbList.get(dbName);
               Storage storage = null;
               if (dbinfo==null) {
                  getLogger().info("Creating DB "+dbName);
                  DB db = new DB(getLogger(),new File(dbDir,dbName));
                  dbinfo = new DBInfo(dbName,db,auth,groupT!=null ?  groupT.getFirstValue() : null, aliasT!=null ? aliasT.getFirstValue() : null);
                  storage = storageFactory.getStorage(db);
                  try {
                     getLogger().info("Connecting to DB "+dbName);
                     db.connect();
                     getLogger().info("Connected to DB "+dbName);
                     autodbList.put(dbName,dbinfo);
                     storage.start();
                  } catch (SQLException ex) {
                     getLogger().log(Level.SEVERE,"Cannot connect to database "+dbName,ex);
                  }
               } else {
                  storage = storageFactory.getStorage(dbinfo.getDB());
               }
               currentDBList.put(dbName,Boolean.TRUE);
               UserGuard adminGuard = new UserGuard(childContext,ChallengeScheme.HTTP_BASIC,"Atom Administrator",auth);
               adminGuard.getRequiredGroups().add(AuthService.ADMIN_GROUP);

               adminGuard.setNext(new AdminApplication(childContext,dbinfo.getDB(),storage,AtomApplication.RESOURCE_BASE));
               admins.put(dbName,adminGuard);
               for (Router router : adminRouters) {
                  router.attach("/admin/database/"+dbName,adminGuard).getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
               }
            }
           
            // Remove databases that have been removed from feed
            for (String name : autodbList.keySet()) {
               if (currentDBList.get(name)==null) {
                  // the database was removed
                  DBInfo dbinfo = autodbList.remove(name);
                  dbinfo.getDB().stop();
                  Storage storage = storageFactory.getStorage(dbinfo.getDB());
                  storage.stop();
                  Restlet admin = admins.remove(name);
                  if (admin!=null) {
                     for (Router router : adminRouters) {
                        router.detach(admin);
View Full Code Here

TOP

Related Classes of org.atomojo.app.db.DBInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.