示例#1
0
 public Authority get(String value) {
   Connection conn = null;
   Authority auth = null;
   try {
     conn = ConnectionUtils.getConnection();
     auth = authDAO.get(conn, value);
   } catch (SQLException e) {
     logger.error(e.getMessage());
   } finally {
     DbUtils.closeQuietly(conn);
   }
   return auth;
 }
示例#2
0
 /**
  * {@inheritDoc}
  *
  * <p>此操作会清空 Cache 中 authorities 对应的 value 和 key = auth.getValue() 的数据,下次请求时装载。
  *
  * @see #getAll()
  */
 public void update(Authority auth) throws JibuException {
   Connection conn = null;
   try {
     conn = ConnectionUtils.getConnection();
     Authority old = authDAO.get(conn, auth.getId());
     authDAO.update(conn, auth);
     DbUtils.commitAndClose(conn);
     Cache cache = CacheUtils.getAuthCache();
     cache.remove("authorities");
     cache.remove(old.getValue());
   } catch (SQLException e) {
     DbUtils.rollbackAndCloseQuietly(conn);
     throw new JibuException(e.getMessage());
   }
 }
示例#3
0
 private List<String> findRoleNamesByValue(String value) {
   Connection conn = null;
   Cache cache = CacheUtils.getAuthCache();
   List<String> names = (List<String>) cache.get(value);
   if (null != names) return names;
   try {
     conn = ConnectionUtils.getConnection();
     Authority auth = authDAO.get(conn, value);
     if (null != auth) {
       names = roleDAO.findByAuthid(conn, auth.getId());
       cache.put(value, names);
     }
   } catch (SQLException e) {
     logger.error(e.getMessage());
   } finally {
     DbUtils.closeQuietly(conn);
   }
   return names;
 }