示例#1
0
 private static void setupUsers(DaoFactory factory, String gridId, File baseDir) throws Exception {
   baseDir = new File(new File(new File(baseDir, "grids"), gridId), "users");
   UserDao dao = factory.createUserDao();
   for (File f : baseDir.listFiles(new RegexFileNameFilter(".*\\.json$"))) {
     User u =
         new LangridJSON(baseDir, FilenameUtil.getIdFromFileName(f))
             .parse(new FileInputStream(f), User.class);
     u.setPassword(MessageDigestUtil.digestBySHA512(u.getPassword()));
     dao.addUser(u);
   }
 }
示例#2
0
 private static void setupResources(DaoFactory factory, String gridId, File baseDir)
     throws Exception {
   baseDir = new File(new File(new File(baseDir, "grids"), gridId), "resources");
   ResourceDao dao = factory.createResourceDao();
   for (File f : baseDir.listFiles(new RegexFileNameFilter(".*\\.json$"))) {
     Resource r =
         new LangridJSON(baseDir, FilenameUtil.getIdFromFileName(f))
             .parse(new FileInputStream(f), Resource.class);
     for (ResourceAttribute a : r.getAttributes()) {
       a.setGridId(r.getGridId());
       a.setResourceId(r.getResourceId());
     }
     dao.addResource(r);
   }
 }
示例#3
0
 private static List<String> setupGrids(DaoFactory factory, File baseDir) throws Exception {
   baseDir = new File(baseDir, "grids");
   GridDao gdao = factory.createGridDao();
   DomainDao ddao = factory.createDomainDao();
   List<String> gridIds = new ArrayList<String>();
   for (File f : baseDir.listFiles(new RegexFileNameFilter(".*\\.json$"))) {
     Grid g =
         new LangridJSON(baseDir, FilenameUtil.getIdFromFileName(f))
             .parse(new FileInputStream(f), Grid.class);
     List<Domain> domains = new ArrayList<Domain>();
     for (Domain d : g.getSupportedDomains()) {
       domains.add(ddao.getDomain(d.getDomainId()));
     }
     g.getSupportedDomains().clear();
     g.getSupportedDomains().addAll(domains);
     gdao.addGrid(g);
     gridIds.add(g.getGridId());
   }
   return gridIds;
 }
示例#4
0
 private static void setupExternalServices(DaoFactory factory, String gridId, File baseDir)
     throws Exception {
   baseDir = new File(new File(new File(baseDir, "grids"), gridId), "services");
   ServiceDao dao = factory.createServiceDao();
   for (File f : baseDir.listFiles(new RegexFileNameFilter("es_.*\\.json$"))) {
     ExternalService s =
         new LangridJSON(baseDir, FilenameUtil.getIdFromServiceFileName(f))
             .parse(new FileInputStream(f), ExternalService.class);
     for (ServiceAttribute a : s.getAttributes()) {
       a.setGridId(gridId);
       a.setServiceId(s.getServiceId());
     }
     for (ServiceEndpoint a : s.getServiceEndpoints()) {
       a.setGridId(gridId);
       a.setServiceId(s.getServiceId());
     }
     s.setGridId(gridId);
     dao.addService(s);
   }
 }