private void getAppDsNames(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    Collection dsNames = DBPower.getDsNames();
    ArrayList appDsNames = new ArrayList(dsNames.size());

    for (Iterator iterator = dsNames.iterator(); iterator.hasNext(); ) {
      String name = (String) iterator.next();
      if (!name.equals("ralasafe")) {
        appDsNames.add(name);
      }
    }

    Gson gson = new Gson();
    String json = gson.toJson(appDsNames);

    if (log.isDebugEnabled()) {
      log.debug("The json is:" + json);
    }

    resp.setContentType("application/json;charset=UTF-8");
    resp.setCharacterEncoding("UTF-8");
    PrintWriter pw = resp.getWriter();
    // pw.write( "\"appDsNames\":" );
    pw.write(json);
    pw.flush();
  }
Exemple #2
0
  public Collection batchSave(Connection conn, Collection coll) throws DBLevelException {
    if (coll == null) return null;

    PreparedStatement pstmt = null;
    try {
      pstmt = conn.prepareStatement(insertSql);
      Column[] columns = table.getColumns();

      CollectionPageBatch cpb = new CollectionPageBatch();
      cpb.setPageSize(DBPower.getMaxBatchSize());
      cpb.setColumns(columns);
      cpb.setPreparedStatement(pstmt);
      cpb.doBatch(coll);

      return cpb.getResult();
    } catch (SQLException e) {
      logger.error("", e);
      throw new DBLevelException(e);
    } catch (Exception e) {
      logger.error("", e);
      throw new RalasafeException(e);
    } finally {
      DBUtil.close(pstmt);
    }
  }
Exemple #3
0
 public Collection batchSave(Collection coll) throws DBLevelException {
   Connection conn = null;
   try {
     conn = DBPower.getConnection(table.getId());
     return batchSave(conn, coll);
   } finally {
     DBUtil.close(conn);
   }
 }
Exemple #4
0
 public int[] batchSave(Object[] os) throws DBLevelException {
   Connection conn = null;
   try {
     conn = DBPower.getConnection(table.getId());
     return batchSave(conn, os);
   } finally {
     DBUtil.close(conn);
   }
 }
Exemple #5
0
 public void save(Object o) throws EntityExistException, DBLevelException {
   Connection conn = null;
   try {
     conn = DBPower.getConnection(table.getId());
     save(conn, o);
   } finally {
     DBUtil.close(conn);
   }
 }
 public void delete(WhereElement emt, Object o) {
   Connection conn = null;
   try {
     conn = DBPower.getConnection(table.getId());
     delete(conn, emt, o);
   } finally {
     DBUtil.close(conn);
   }
 }
 public void deleteByIdColumns(Object o) {
   Connection conn = null;
   try {
     conn = DBPower.getConnection(table.getId());
     deleteByIdColumns(conn, o);
   } finally {
     DBUtil.close(conn);
   }
 }
  public PrivilegeManagerImpl(String appName) {
    this.appName = appName;
    this.tableName = appName + "_privilege";
    TableNewer newer = new TableNewer();
    newer.setTableName(tableName);
    newer.setColumnNames(
        new String[] {
          "id",
          "pid",
          "name",
          "description",
          "isleaf",
          "display",
          "decisionPolicyCombAlg",
          "queryPolicyCombAlg",
          "type",
          "constantName",
          "url",
          "target",
          "orderNum"
        });
    newer.setIdColumnNames(new String[] {"id"});
    newer.setUniqueColumnNames(new String[] {"name"});
    newer.setMappingClass(Privilege.class.getName());
    newer.put("id", new JavaBeanColumnAdapter("id", "int"));
    newer.put("pid", new JavaBeanColumnAdapter("pid", "int"));
    newer.put("name", new JavaBeanColumnAdapter("name", "java.lang.String"));
    newer.put("description", new JavaBeanColumnAdapter("description", "java.lang.String"));
    newer.put("isleaf", new JavaBeanColumnAdapter("isLeaf", "boolean"));
    newer.put("display", new JavaBeanColumnAdapter("display", "boolean"));
    newer.put("decisionPolicyCombAlg", new JavaBeanColumnAdapter("decisionPolicyCombAlg", "int"));
    newer.put("queryPolicyCombAlg", new JavaBeanColumnAdapter("queryPolicyCombAlg", "int"));
    newer.put("type", new JavaBeanColumnAdapter("type", "int"));
    newer.put("constantName", new JavaBeanColumnAdapter("constantName", "java.lang.String"));
    newer.put("url", new JavaBeanColumnAdapter("url", "java.lang.String"));
    newer.put("target", new JavaBeanColumnAdapter("target", "java.lang.String"));
    newer.put("orderNum", new JavaBeanColumnAdapter("orderNum", "int"));

    newer.setId(DBPower.getTableId(null, newer.getTableName()));
    table = newer.getTable();
    selector = new TableSelectorImpl();
    selector.setObjectNewer(new JavaBeanObjectNewer(newer.getMappingClass()));
    saver = new TableSaverImpl();
    updator = new TableUpdatorImpl();
    deletor = new TableDeletorImpl();
    selector.setTable(table);
    saver.setTable(table);
    updator.setTable(table);
    deletor.setTable(table);
  }