Example #1
0
 @Override
 public void init(ServletConfig config) throws ServletException {
   try {
     ParameterContext c = new ServletContextParameterContext(config.getServletContext());
     String gridId = c.getValue("langrid.node.gridId");
     if (gridId == null) {
       logger.info("langrid.node.gridId is not set. ignore initializing domain.");
       return;
     }
     DaoFactory f = DaoFactory.createInstance();
     DaoContext dc = f.getDaoContext();
     jp.go.nict.langrid.dao.initializer.DomainInitializer.init(
         f,
         dc,
         gridId,
         c.getBoolean("dropAndCreate", false),
         config.getServletContext().getRealPath("/WEB-INF/init"));
     ProtocolDao dao = f.createProtocolDao();
     Set<String> protos =
         new HashSet<String>(
             CollectionUtil.collect(
                 dao.listAllProtocols(),
                 new Transformer<Protocol, String>() {
                   @Override
                   public String transform(Protocol value) throws TransformationException {
                     return value.getProtocolId();
                   }
                 }));
     if (!protos.contains(Protocols.SOAP_RPCENCODED)) {
       dao.addProtocol(new Protocol(Protocols.SOAP_RPCENCODED));
     }
     if (!protos.contains(Protocols.PROTOBUF_RPC)) {
       dao.addProtocol(new Protocol(Protocols.PROTOBUF_RPC));
     }
     if (!protos.contains(Protocols.JSON_RPC)) {
       dao.addProtocol(new Protocol(Protocols.JSON_RPC));
     }
   } catch (DaoException e) {
     throw new ServletException(e);
   } catch (IOException e) {
     throw new ServletException(e);
   } catch (SQLException e) {
     throw new ServletException(e);
   }
 }
Example #2
0
 public static void main(String[] args) throws Exception {
   System.setProperty(
       "jp.go.nict.langrid.dao.hibernate.LangridSessionFactory.hibernate.cfg",
       "hibernate.cfg.xml");
   File baseDir = new File("contents_grids");
   DaoFactory f = DaoFactory.createInstance();
   DaoContext c = f.getDaoContext();
   c.beginTransaction();
   try {
     clearAll(f);
     List<String> gridIds = setupGrids(f, baseDir);
     for (String gid : gridIds) {
       setupUsers(f, gid, baseDir);
       setupResources(f, gid, baseDir);
       setupExternalServices(f, gid, baseDir);
     }
   } finally {
     c.commitTransaction();
   }
 }