List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuth(String who, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;/* w w w .j a v a2 s .co m*/ ; Statement ps = null; boolean success = false; who = who.toLowerCase(); Privilege priv = privMap.get(privIndex); try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); try { ps = con.createStatement(); String sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (userSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (userSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (userSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DBA_PRIV", ts.toString()); } } break; } break; } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "'" + " and tdwrole.role_name=tdwuserrole.role_name"; ResultSet roleSet = ps.executeQuery(sql); String roleName = null; while (roleSet.next()) { roleName = roleSet.getString(12); ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (roleSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (roleSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (roleSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DBA_PRIV", ts.toString()); } } break; } } roleSet.close(); success = true; } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public Table getTable(String dbName, String tableName) throws MetaException, NoSuchObjectException { boolean success = false; Connection con;//from w ww . j a v a 2 s .c o m Statement ps = null; Table tbl = new Table(); dbName = dbName.toLowerCase(); tableName = tableName.toLowerCase(); try { con = getSegmentConnectionForRead(dbName); } catch (MetaStoreConnectException e1) { LOG.error("get table error, db=" + dbName + ", tbl=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("get table error, db=" + dbName + ", tbl=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { con.setAutoCommit(false); con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); ps = con.createStatement(); String sql = "SELECT tbl_id, create_time" + ", is_compressed, retention, tbl_type, db_name, tbl_name, tbl_owner " + ", tbl_format, pri_part_type, sub_part_type, pri_part_key, sub_part_key " + ", input_format, output_format, serde_name, serde_lib, tbl_location, tbl_comment " + " from TBLS where db_name='" + dbName + "' and tbl_name='" + tableName + "'"; ResultSet tblSet = ps.executeQuery(sql); boolean isTblFind = false; StorageDescriptor sd = null; SerDeInfo sdInfo = null; String priPartKey = null; String subPartKey = null; Partition priPart = null; Partition subPart = null; long tblID = 0; String comment = null; String format = null; Timestamp createTime = null; String tblType = null; boolean hasPriPart = false; boolean hasSubPart = false; while (tblSet.next()) { isTblFind = true; tblID = tblSet.getLong(1); createTime = tblSet.getTimestamp(2); if (createTime != null) { tbl.setCreateTime((int) (createTime.getTime() / 1000)); } sd = new StorageDescriptor(); sdInfo = new SerDeInfo(); sd.setCompressed(tblSet.getBoolean(3)); tbl.setRetention((int) tblSet.getLong(4)); tblType = tblSet.getString(5); tbl.setTableType(tblType); tbl.setDbName(tblSet.getString(6)); tbl.setTableName(tblSet.getString(7)); tbl.setOwner(tblSet.getString(8)); format = tblSet.getString(9); priPartKey = tblSet.getString(12); subPartKey = tblSet.getString(13); if (priPartKey != null && !priPartKey.isEmpty()) { hasPriPart = true; priPart = new Partition(); priPart.setLevel(0); priPart.setDbName(tblSet.getString(6)); priPart.setTableName(tblSet.getString(7)); priPart.setParType(tblSet.getString(10)); } if (subPartKey != null && !subPartKey.isEmpty()) { hasSubPart = true; subPart = new Partition(); subPart.setLevel(1); subPart.setDbName(tblSet.getString(6)); subPart.setTableName(tblSet.getString(7)); subPart.setParType(tblSet.getString(11)); } sd.setInputFormat(tblSet.getString(14)); sd.setOutputFormat(tblSet.getString(15)); sdInfo.setName(tblSet.getString(16)); sdInfo.setSerializationLib(tblSet.getString(17)); sd.setLocation(tblSet.getString(18)); comment = tblSet.getString(19); break; } tblSet.close(); if (!isTblFind) { LOG.error(dbName + "." + tableName + " table not found"); throw new NoSuchObjectException(dbName + "." + tableName + " table not found"); } List<FieldSchema> fieldList = new ArrayList<FieldSchema>(); Map<String, FieldSchema> fieldMap = new LinkedHashMap<String, FieldSchema>(); sql = "SELECT column_name, type_name, comment from columns where tbl_id=" + tblID + " order by column_index asc"; ResultSet colSet = ps.executeQuery(sql); while (colSet.next()) { FieldSchema field = new FieldSchema(); field.setName(colSet.getString(1)); field.setType(colSet.getString(2)); field.setComment(colSet.getString(3)); fieldList.add(field); fieldMap.put(colSet.getString(1), field); } colSet.close(); sd.setCols(fieldList); sql = "SELECT param_type, param_key, param_value from table_params where tbl_id=" + tblID; ResultSet paramSet = ps.executeQuery(sql); Map<String, String> tblParamMap = new HashMap<String, String>(); Map<String, String> sdParamMap = new HashMap<String, String>(); Map<String, String> serdeParam = new HashMap<String, String>(); while (paramSet.next()) { String type = paramSet.getString(1); if (type == null) continue; if (type.equalsIgnoreCase("sd")) { sdParamMap.put(paramSet.getString(2), paramSet.getString(3)); } else if (type.equalsIgnoreCase("serde")) { serdeParam.put(paramSet.getString(2), paramSet.getString(3)); } else if (type.equalsIgnoreCase("tbl")) { tblParamMap.put(paramSet.getString(2), paramSet.getString(3)); } else { tblParamMap.put(paramSet.getString(2), paramSet.getString(3)); } } paramSet.close(); if (comment != null && !comment.isEmpty()) { tblParamMap.put("comment", comment); } if (format != null && !format.isEmpty()) { tblParamMap.put("type", format); } tbl.setParameters(tblParamMap); sd.setParameters(sdParamMap); sdInfo.setParameters(serdeParam); List<String> bucketCols = new ArrayList<String>(); sql = "select bucket_col_name from bucket_cols where tbl_id=" + tblID + " order by col_index asc"; ResultSet bucketSet = ps.executeQuery(sql); while (bucketSet.next()) { bucketCols.add(bucketSet.getString(1)); } bucketSet.close(); if (bucketCols.size() > 0) { sd.setBucketCols(bucketCols); String numBucketStr = sd.getParameters().get("NUM_BUCKETS"); if (numBucketStr == null) { sd.setNumBuckets(-1); } else { sd.setNumBuckets(Integer.valueOf(numBucketStr)); } } else { sd.setBucketCols(bucketCols); sd.setNumBuckets(-1); } sd.getParameters().remove("NUM_BUCKETS"); List<Order> sortCols = new ArrayList<Order>(); sql = "select sort_column_name, sort_order from sort_cols where tbl_id=" + tblID + " order by col_index asc"; ResultSet sortSet = ps.executeQuery(sql); while (sortSet.next()) { Order o = new Order(); o.setCol(sortSet.getString(1)); o.setOrder(sortSet.getInt(2)); sortCols.add(o); } sortSet.close(); sd.setSortCols(sortCols); sd.setSerdeInfo(sdInfo); tbl.setSd(sd); if (hasPriPart) { sql = "SELECT level, part_name, part_values from PARTITIONS where tbl_id=" + tblID; ResultSet partSet = ps.executeQuery(sql); Map<String, List<String>> priPartSpace = new LinkedHashMap<String, List<String>>(); Map<String, List<String>> subPartSpace = new LinkedHashMap<String, List<String>>(); while (partSet.next()) { int level = partSet.getInt(1); switch (level) { case 0: String priName = partSet.getString(2); List<String> priValueList = new ArrayList<String>(); Array priSpaceArray = partSet.getArray(3); if (priSpaceArray != null) { ResultSet priValueSet = priSpaceArray.getResultSet(); while (priValueSet.next()) { priValueList.add(priValueSet.getString(2)); } } priPartSpace.put(priName, priValueList); break; case 1: String subName = partSet.getString(2); List<String> subValueList = new ArrayList<String>(); Array subSpaceArray = partSet.getArray(3); if (subSpaceArray != null) { ResultSet subValueSet = subSpaceArray.getResultSet(); while (subValueSet.next()) { subValueList.add(subValueSet.getString(2)); } } subPartSpace.put(subName, subValueList); break; default: break; } } partSet.close(); priPart.setParSpaces(priPartSpace); priPart.setParKey(fieldMap.get(priPartKey.toLowerCase())); if (hasSubPart) { subPart.setParSpaces(subPartSpace); subPart.setParKey(fieldMap.get(subPartKey.toLowerCase())); } } tbl.setPriPartition(priPart); tbl.setSubPartition(subPart); if (tblType.equalsIgnoreCase("VIRTUAL_VIEW")) { sql = "select view_original_text, view_expanded_text, vtables from " + " tdwview where tbl_id=" + tblID; ResultSet viewSet = ps.executeQuery(sql); while (viewSet.next()) { tbl.setViewOriginalText(viewSet.getString(1)); tbl.setViewExpandedText(viewSet.getString(2)); tbl.setVtables(viewSet.getString(3)); break; } } con.commit(); success = true; } catch (SQLException sqlex) { sqlex.printStackTrace(); LOG.error("get table error, db=" + dbName + ", tbl=" + tableName + ", msg=" + sqlex.getMessage()); throw new MetaException(sqlex.getMessage()); } finally { if (!success) { try { con.rollback(); } catch (SQLException e) { } } closeStatement(ps); closeConnection(con); } if (success) return tbl; else return null; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuthWithRole(String who, String role, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;/*from w ww. j a va 2 s . com*/ ; Statement ps = null; boolean success = false; who = who.toLowerCase(); role = role.toLowerCase(); Privilege priv = privMap.get(privIndex); try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); try { ps = con.createStatement(); Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; String sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "' and tdwrole.role_name='" + role + "' " + " and tdwrole.role_name=tdwuserrole.role_name"; ResultSet roleSet = ps.executeQuery(sql); String roleName = null; boolean isRoleFind = false; while (roleSet.next()) { isRoleFind = true; roleName = roleSet.getString(12); ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (roleSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (roleSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (roleSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DBA_PRIV", ts.toString()); } } break; } break; } roleSet.close(); if (!isRoleFind) { LOG.error("user/role does not exist or user does not play this role:" + who + "/" + role); throw new MetaException("user/role does not exist or user does not play this role:" + who + "/" + role + ", you shoule check it"); } sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (userSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (userSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (userSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DBA_PRIV", ts.toString()); } } break; } break; } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } success = true; } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuthOnDb(String who, String db, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;// ww w .j a v a 2s. com ; Statement ps = null; Privilege priv = privMap.get(privIndex); who = who.toLowerCase(); db = db.toLowerCase(); long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { ps = con.createStatement(); String sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (userSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (userSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SHOW_VIEW_PRIV", ts.toString()); } } break; } } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; ResultSet dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SHOW_VIEW_PRIV", ts.toString()); } } break; } } sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "'" + " and tdwrole.role_name=tdwuserrole.role_name"; ResultSet roleSet = ps.executeQuery(sql); String roleName = null; List<String> roleList = new ArrayList<String>(); while (roleSet.next()) { roleName = roleSet.getString(12); ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (roleSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (roleSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (roleSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " DBA_PRIV", ts.toString()); } } break; } roleList.add(roleSet.getString(12)); } roleSet.close(); for (String r : roleList) { sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + r.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + r + " on db:" + db + " SHOW_VIEW_PRIV", ts.toString()); } } break; } } } } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuthOnTbl(String who, String db, String table, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;//from w ww . j a v a 2 s .c o m ; Statement ps = null; Privilege priv = privMap.get(privIndex); who = who.toLowerCase(); db = db.toLowerCase(); table = table.toLowerCase(); long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { ps = con.createStatement(); String sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; } } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; ResultSet dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; } } dbPrivSet.close(); sql = "select alter_priv, create_priv, delete_priv " + ",drop_priv, index_priv, insert_priv, select_priv, update_priv, out_of_date_time" + " from tblpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "' and tbl_name='" + table.toLowerCase() + "'"; ResultSet tblSet = ps.executeQuery(sql); while (tblSet.next()) { ts = tblSet.getTimestamp(9); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (tblSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (tblSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (tblSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (tblSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (tblSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (tblSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (tblSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (tblSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " UPDATE_PRIV", ts.toString()); } } break; } break; } tblSet.close(); sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "'" + " and tdwrole.role_name=tdwuserrole.role_name"; ResultSet roleSet = ps.executeQuery(sql); String rName = null; List<String> roleList = new ArrayList<String>(); while (roleSet.next()) { rName = roleSet.getString(12); ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + rName + " UPDATE_PRIV", ts.toString()); } } break; } roleList.add(roleSet.getString(12)); } roleSet.close(); for (String roleName : roleList) { sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + roleName.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + roleName + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; } } dbPrivSet.close(); sql = "select alter_priv, create_priv, delete_priv " + ",drop_priv, index_priv, insert_priv, select_priv, update_priv, out_of_date_time " + " from tblpriv where user_name='" + roleName.toLowerCase() + "' and db_name='" + db.toLowerCase() + "' and tbl_name='" + table.toLowerCase() + "'"; tblSet = ps.executeQuery(sql); while (tblSet.next()) { ts = tblSet.getTimestamp(9); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (tblSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (tblSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (tblSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (tblSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (tblSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (tblSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (tblSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (tblSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put( "role " + roleName + " on tbl:" + db + "/" + table + " UPDATE_PRIV", ts.toString()); } } break; } break; } tblSet.close(); } } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuthOnDbWithRole(String who, String role, String db, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;//from w ww.j a v a 2 s .co m ; Statement ps = null; Privilege priv = privMap.get(privIndex); who = who.toLowerCase(); db = db.toLowerCase(); role = role.toLowerCase(); long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { ps = con.createStatement(); String sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "' and tdwrole.role_name='" + role + "' " + " and tdwrole.role_name=tdwuserrole.role_name"; ResultSet roleSet = ps.executeQuery(sql); boolean isRoleFind = false; while (roleSet.next()) { isRoleFind = true; ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (roleSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (roleSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " SHOW_VIEW_PRIV", ts.toString()); } } break; case DBA_PRIV: if (roleSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " DBA_PRIV", ts.toString()); } } break; } break; } roleSet.close(); if (!isRoleFind) { LOG.error("user/role does not exist or user does not play this role:" + who + "/" + role); throw new MetaException("user/role does not exist or user does not play this role:" + who + "/" + role + ", you shoule check it"); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + role + "' and db_name='" + db.toLowerCase() + "'"; ResultSet dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " SHOW_VIEW_PRIV", ts.toString()); } } break; } break; } sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (userSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (userSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SHOW_VIEW_PRIV", ts.toString()); } } break; } break; } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SHOW_VIEW_PRIV", ts.toString()); } } break; } break; } } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:com.ibm.ioes.dao.ReportsDao_Usage.java
public ArrayList<StartChargeNotPushedInFXDTO> viewStartChargeNotPushedInFx(StartChargeNotPushedInFXDTO objDto) { //Nagarjuna//w w w. j av a2 s . co m String methodName = "viewStartChargeNotPushedInFx", className = this.getClass().getName(), msg = ""; boolean logToFile = true, logToConsole = true; //end Nagarjuna Connection connection = null; CallableStatement proc = null; ResultSet rs = null; ArrayList<StartChargeNotPushedInFXDTO> listSearchDetails = new ArrayList<StartChargeNotPushedInFXDTO>(); StartChargeNotPushedInFXDTO objReportsDto = null; int recordCount = 0; Utility utility = new Utility(); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date tempDate = null; Timestamp ts = null; try { connection = DbConnection.getReportsConnectionObject(); proc = connection.prepareCall(sqlGetStartChargeNotPushedInFx); if (objDto.getOrderType() != null && !"".equals(objDto.getOrderType())) { proc.setString(1, objDto.getOrderType().trim()); } else { proc.setNull(1, java.sql.Types.VARCHAR); } if (objDto.getFromDate() != null && !"".equals(objDto.getFromDate())) { proc.setString(2, objDto.getFromDate().trim()); } else { proc.setNull(2, java.sql.Types.VARCHAR); } if (objDto.getToDate() != null && !"".equals(objDto.getToDate())) { proc.setString(3, objDto.getToDate().trim()); } else { proc.setNull(3, java.sql.Types.VARCHAR); } if (objDto.getFromOrderNo() != 0 && !"".equals(objDto.getFromOrderNo())) { proc.setInt(4, objDto.getFromOrderNo()); } else { proc.setNull(4, java.sql.Types.BIGINT); } if (objDto.getToOrderNo() != 0 && !"".equals(objDto.getToOrderNo())) { proc.setInt(5, objDto.getToOrderNo()); } else { proc.setNull(5, java.sql.Types.BIGINT); } if (objDto.getVerticalDetails() != null && !"".equals(objDto.getVerticalDetails())) { proc.setString(6, objDto.getVerticalDetails().trim()); } else { proc.setNull(6, java.sql.Types.VARCHAR); } PagingSorting pagingSorting = objDto.getPagingSorting(); pagingSorting.sync();// To calculate start index and Enc Index proc.setString(7, pagingSorting.getSortByColumn());// columnName proc.setString(8, PagingSorting.DB_Asc_Desc(pagingSorting.getSortByOrder()));// sort order proc.setInt(9, pagingSorting.getStartRecordId());// start index proc.setInt(10, pagingSorting.getEndRecordId());// end index proc.setInt(11, (pagingSorting.isPagingToBeDone() ? 1 : 0)); // index proc.setInt(12, objDto.getIsUsage()); rs = proc.executeQuery(); while (rs.next()) { objReportsDto = new StartChargeNotPushedInFXDTO(); objReportsDto.setLogicalSINumber(rs.getInt("LOGICAL_SI_NO")); objReportsDto.setCustomer_logicalSINumber(rs.getInt("CUSTOMER_LOGICAL_SI_NO")); objReportsDto.setServiceName(rs.getString("SERVICENAME")); objReportsDto.setServiceDetDescription(rs.getString("SERVICEDETDESCRIPTION")); //objReportsDto.setContractStartDate(rs.getString("CONTRACTSTARTDATE")); tempDate = rs.getDate("CONTRACTSTARTDATE"); objReportsDto.setContractStartDate(rs.getString("CONTRACTSTARTDATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setContractStartDate((utility.showDate_Report(tempDate)).toUpperCase()); } //objReportsDto.setContractEndDate(rs.getString("CONTRACTENDDATE")); tempDate = rs.getDate("CONTRACTENDDATE"); objReportsDto.setContractEndDate(rs.getString("CONTRACTENDDATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setContractEndDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setCrmAccountNoString(rs.getString("CRMACCOUNTNO")); objReportsDto.setCreditPeriodName(rs.getString("CREDITPERIOD")); objReportsDto.setCurrencyName(rs.getString("CURRENCYNAME")); objReportsDto.setEntity(rs.getString("ENTITYNAME")); objReportsDto.setBillingMode(rs.getString("BILLINGMODE")); objReportsDto.setBillingTypeName(rs.getString("BILLING_TYPENAME")); objReportsDto.setBillingFormatName(rs.getString("BILLING_FORMATNAME")); objReportsDto.setLcompanyname(rs.getString("LCOMPANYNAME")); objReportsDto.setTaxation(rs.getString("TAXATIONVALUE")); objReportsDto.setPenaltyClause(rs.getString("PENALTYCLAUSE")); objReportsDto.setBillingLevel(rs.getString("BILLINGLEVEL")); objReportsDto.setBillingLevelNo(rs.getLong("BILLING_LEVEL_NO")); objReportsDto.setBillingLevelName(rs.getString("BILLING_LEVELNAME")); //objReportsDto.setPrimaryLocation(rs.getString("PRIMARYLOCATION")); //objReportsDto.setSecondaryLocation(rs.getString("SECONDARYLOCATION")); setBlank(); replaceSeperator("PRIMARYLOCATION", rs.getString("PRIMARYLOCATION")); objReportsDto.setPrimaryLocation(VAR_PRIMARYLOCATION); replaceSeperator("SECONDARYLOCATION", rs.getString("SECONDARYLOCATION")); objReportsDto.setSecondaryLocation(VAR_SECONDARYLOCATION); objReportsDto.setPonum(rs.getLong("PONUMBER")); /*objReportsDto.setPoDate(rs.getString("PODATE")); if (rs.getString("PODATE") != null && !"".equals(rs.getString("PODATE"))) { Date date=df.parse(objReportsDto.getPoDate()); objReportsDto.setPoDate((Utility.showDate_Report(date)).toUpperCase()); }*/ tempDate = rs.getDate("PODATE"); objReportsDto.setPoDate(rs.getString("PODATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setPoDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setParty_no(rs.getInt("Party_NO")); objReportsDto.setPartyName(rs.getString("PARTYNAME")); objReportsDto.setBilling_Trigger_Flag(rs.getString("Billing_Trigger_Flag")); objReportsDto.setLOC_Date(rs.getString("Pm_Prov_Date")); if (rs.getString("Pm_Prov_Date") != null && !"".equals(rs.getString("Pm_Prov_Date"))) { String s1 = rs.getString("Pm_Prov_Date"); String s3 = s1.substring(0, 7); String s4 = s1.substring(9, 11); String s5 = s3.concat(s4); objReportsDto.setPmApproveDate(s5); } objReportsDto.setLocDate(rs.getString("LOCDATE")); if (rs.getString("LOCDATE") != null && !"".equals(rs.getString("LOCDATE"))) { Date date = df.parse(objReportsDto.getLocDate()); objReportsDto.setLocDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setBillingTriggerDate(rs.getString("BILLINGTRIGGERDATE")); if (rs.getString("BILLINGTRIGGERDATE") != null && !"".equals(rs.getString("BILLINGTRIGGERDATE"))) { Date date = df.parse(objReportsDto.getBillingTriggerDate()); objReportsDto.setBillingTriggerDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setChallenno(rs.getString("CHALLEN_NO")); objReportsDto.setChallendate(rs.getString("CHALLEN_DATE")); if (rs.getString("CHALLEN_DATE") != null && !"".equals(rs.getString("CHALLEN_DATE"))) { //Date date=df.parse(objReportsDto.getChallendate()); objReportsDto.setChallendate(rs.getString("CHALLEN_DATE")); } objReportsDto.setFx_external_acc_id(rs.getString("Child_Account_Number")); objReportsDto.setChildAccountFXSataus(rs.getString("Child_Account_FX_Sataus")); /*objReportsDto.setOrderDate(rs.getString("ORDERDATE")); if (rs.getString("ORDERDATE") != null && !"".equals(rs.getString("ORDERDATE"))) { Date date=df.parse(objReportsDto.getOrderDate()); objReportsDto.setOrderDate((Utility.showDate_Report(date)).toUpperCase()); }*/ tempDate = rs.getDate("ORDERDATE"); objReportsDto.setOrderDate(rs.getString("ORDERDATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setOrderDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setOrderApproveDate(rs.getString("ORDER_APPROVED_DATE"));//Copc date tempDate = rs.getDate("ORDER_APPROVED_DATE"); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setOrderApproveDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setCopcApproveDate(rs.getString("COPC_APPROVED_DATE")); ts = rs.getTimestamp("COPC_APPROVED_DATE"); if (ts != null) { tempDate = new Date(ts.getTime()); objReportsDto.setCopcApproveDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setOrderType(rs.getString("ORDERTYPE")); // --Order Type Id // --Service Order Type // ''SERVICE ORDER TYPE DESC'' AS SERVICE_ORDER_TYPE_DESC, // "TST3"."TASK_END_DATE" as "COPC_APPROVED_DATE", // --TPOSERVICEDETAILS.BILLINGTRIGGERDATE as BILLINGTRIGGER_CREATE_DATE, // --Cust Logical Si ( Duplicate column) // --Charge Type Id objReportsDto.setServiceStage(rs.getString("SERVICE_STAGE")); objReportsDto.setAccountManager(rs.getString("ACCOUNTMANAGER")); objReportsDto.setProjectManager(rs.getString("PROJECTMANAGER")); // --"TPOMASTER"."ORDERDATE" ORDERCREATION DATE /*objReportsDto.setRfsDate(rs.getString("SERVICE_RFS_DATE")); if (rs.getString("SERVICE_RFS_DATE") != null && !"".equals(rs.getString("SERVICE_RFS_DATE"))) { Date date=df.parse(objReportsDto.getRfsDate()); objReportsDto.setRfsDate((Utility.showDate_Report(date)).toUpperCase()); }*/ tempDate = rs.getDate("SERVICE_RFS_DATE"); objReportsDto.setRfsDate(rs.getString("SERVICE_RFS_DATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setRfsDate((utility.showDate_Report(tempDate)).toUpperCase()); } /*objReportsDto.setPoRecieveDate(rs.getString("PORECEIVEDATE")); if (rs.getString("PORECEIVEDATE") != null && !"".equals(rs.getString("PORECEIVEDATE"))) { Date date=df.parse(objReportsDto.getPoRecieveDate()); objReportsDto.setPoRecieveDate((Utility.showDate_Report(date)).toUpperCase()); }*/ tempDate = rs.getDate("PORECEIVEDATE"); objReportsDto.setPoRecieveDate(rs.getString("PORECEIVEDATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setPoRecieveDate((utility.showDate_Report(tempDate)).toUpperCase()); } //--Fx Status Ed objReportsDto.setCustPoDetailNo(rs.getString("CUSTPONUMBER")); /*objReportsDto.setCustPoDate(rs.getString("CUSTPODATE")); if (rs.getString("CUSTPODATE") != null && !"".equals(rs.getString("CUSTPODATE"))) { Date date=df.parse(objReportsDto.getCustPoDate()); objReportsDto.setCustPoDate((Utility.showDate_Report(date)).toUpperCase()); }*/ tempDate = rs.getDate("CUSTPODATE"); objReportsDto.setCustPoDate(rs.getString("CUSTPODATE")); if (tempDate != null && !"".equals(tempDate)) { objReportsDto.setCustPoDate((utility.showDate_Report(tempDate)).toUpperCase()); } objReportsDto.setLOC_No(rs.getString("LOCNO")); //objReportsDto.setBillingAddress(rs.getString("BILLING_ADDRESS")); replaceSeperator("BILLING_LOCATION", rs.getString("BILLING_ADDRESS")); objReportsDto.setBillingAddress(VAR_BILLING_ADDRESS); objReportsDto.setFxSiId(rs.getString("FX_SI_ID")); objReportsDto.setCancelBy(rs.getString("CANCEL_BY")); objReportsDto.setCanceldate(rs.getString("CANCEL_DATE")); objReportsDto.setCancelReason(rs.getString("CANCEL_RESION")); objReportsDto.setOpms_Account_Id(rs.getString("Opms_Account_Id")); objReportsDto.setRegionName(rs.getString("REGION")); objReportsDto.setBandwaidth(rs.getString("BANDWIDTH")); objReportsDto.setVerticalDetails(rs.getString("VERTICAL_DETAILS")); objReportsDto.setToLocation(rs.getString("FROM_ADDRESS")); objReportsDto.setFromLocation(rs.getString("TO_ADDRESS")); objReportsDto.setColl_Manager(rs.getString("COLL_MANAGER")); objReportsDto.setColl_Manager_Mail(rs.getString("COLL_MANAGER_MAIL")); objReportsDto.setColl_Manager_Phone(rs.getString("COLL_MANAGER_PHONE")); objReportsDto.setBilling_bandwidth(rs.getString("BILLING_BANDWIDTH")); objReportsDto.setOrder_type(rs.getString("DEMO_TYPE")); objReportsDto.setTotalPoAmt(rs.getString("TOTALPOAMOUNT")); //--CRM ORDER ID objReportsDto.setOrderNumber(rs.getInt("ORDERNO")); //--Charge Hdr Id objReportsDto.setOrderLineNumber(rs.getInt("Order_Line_Id")); objReportsDto.setServiceId(rs.getInt("SERVICE_NO")); // --Installment Rate //--Trai Rate //--Discount objReportsDto.setContractPeriod(rs.getInt("CONTRACTPERIOD")); objReportsDto.setCommitmentPeriod(rs.getInt("COMMITMENTPERIOD")); objReportsDto.setNoticePeriod(rs.getInt("NOTICEPERIOD")); //--Principal Amt // --Intrest Rate // --Period In Month objReportsDto.setPoAmount(rs.getString("CUST_TOT_PO_AMT")); // --party Id // --Cust Account id // --M6 Product Id // --M6 Order Id // --Ib Order Line Id // --Ib Service List Id // --Ib Pk Charges Id // --Fx Sno // --Fx Sno Ed // --Cust Tot Po Amt // --M6 Order No // --Business Serial No // --Bus Serial // --Advance // Meenakshi : Changes for Usage if (objDto.getIsUsage() == 1) { objReportsDto.setComponentInfoID(rs.getInt("COMPONENTINFOID")); objReportsDto.setComponentID(rs.getInt("COMPONENT_ID")); objReportsDto.setComponentName(rs.getString("COMPONENT_NAME")); objReportsDto.setPackageID(rs.getInt("PACKAGE_ID")); objReportsDto.setPackageName(rs.getString("PACKAGE_NAME")); objReportsDto.setCreditPeriodName(rs.getString("CREDIT_PERIODNAME")); objReportsDto.setServiceOrderType(rs.getString("SERVICE_ORDER_TYPE_DESC")); objReportsDto.setM6OrderNo(rs.getInt("M6ORDERNO")); objReportsDto.setCancelServiceReason(rs.getString("CANCEL_SERVICE_REASON")); objReportsDto.setCancelBy(rs.getString("CANCELBY")); objReportsDto.setCanceldate(rs.getString("CANCELDATE")); objReportsDto.setOrderStage(rs.getString("ORDERSTAGE")); ComponentsDto dto = new ComponentsDto(); dto.setComponentStatus(rs.getString("COMPONENT_STATUS")); dto.setStartLogic(rs.getString("COMPONENT_START_LOGIC")); dto.setStartDate(rs.getString("SYSTEM_START_DATE")); if (rs.getString("SYSTEM_START_DATE") != null && !"".equals(rs.getString("SYSTEM_START_DATE"))) { Date date = df.parse(dto.getStartDate()); dto.setStartDate((Utility.showDate_Report(date)).toUpperCase()); } dto.setEndLogic(rs.getString("COMPONENT_END_LOGIC")); dto.setEnd_date(rs.getString("SYSTEM_END_DATE")); if (rs.getString("SYSTEM_END_DATE") != null && !"".equals(rs.getString("SYSTEM_END_DATE"))) { Date date = df.parse(dto.getEnd_date()); dto.setEnd_date((Utility.showDate_Report(date)).toUpperCase()); } dto.setFxTokenNo(rs.getString("START_COMPONENT_TOKEN_NO")); dto.setFxStartStatus(rs.getString("SYSTEM_START_STATUS")); dto.setEndFxStatus(rs.getString("SYSTEM_END_STATUS")); dto.setEndTokenNo(rs.getString("END_COMPONENT_TOKEN_NO")); //dto.setComponentFXStatus(rs.getString("FX_STATUS")); objReportsDto.setStartDateDays(rs.getInt("COMP_START_DAYS")); objReportsDto.setStartDateMonth(rs.getInt("COMP_START_MONTHS")); objReportsDto.setEndDateDays(rs.getInt("COMP_END_DAYS")); objReportsDto.setEndDateMonth(rs.getInt("COMP_END_MONTHS")); objReportsDto.setSourcePartyID(rs.getLong("PARTY_ID")); objReportsDto.setAccountID(rs.getInt("CUSTACCOUNTID")); objReportsDto.setFx_internal_acc_id(rs.getLong("INTERNAL_ID")); dto.setComponentInstanceID(rs.getString("COMPONENT_INST_ID")); dto.setComponentType(rs.getString("COMPONENT_TYPE")); dto.setComponentAmount(rs.getDouble("COMP_AMOUNT")); ///dto.setEndTokenNo(rs.getString("")); //END_COMPONENT_TOKEN_NO objReportsDto.setComponentDto(dto); } else { objReportsDto.setOrderStage(rs.getString("STAGE")); objReportsDto.setTokenNoEd(rs.getString("CSTATE_END_DETAILS_FX_TOKEN_NO"));//--Token No Ed objReportsDto.setHardwareFlag(rs.getString("HARDWARE_FLAG")); objReportsDto.setWarrantyStartDate(rs.getString("WARRENTY_START_DATE")); if (rs.getString("WARRENTY_START_DATE") != null && !"".equals(rs.getString("WARRENTY_START_DATE"))) { Date date = df.parse(objReportsDto.getWarrantyStartDate()); objReportsDto.setWarrantyStartDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setWarrantyEndDate(rs.getString("WARRENTY_END_DATE")); if (rs.getString("WARRENTY_END_DATE") != null && !"".equals(rs.getString("WARRENTY_END_DATE"))) { Date date = df.parse(objReportsDto.getWarrantyEndDate()); objReportsDto.setWarrantyEndDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setExtSuportEndDate(rs.getString("EXT_SUPPORT_END_DATE")); if (rs.getString("EXT_SUPPORT_END_DATE") != null && !"".equals(rs.getString("EXT_SUPPORT_END_DATE"))) { Date date = df.parse(objReportsDto.getExtSuportEndDate()); objReportsDto.setExtSuportEndDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setFxStatus(rs.getString("CSTATE_START_DETAILS_FX_STATUS"));//FX_STATUS objReportsDto.setTokenNO(rs.getString("CSTATE_START_DETAILS_FX_TOKEN_NO"));//Token_No objReportsDto.setHardwaretypeName(rs.getString("HARDWARETYPENAME")); objReportsDto.setFormAvailable(rs.getString("FORM_C_AVAILABLE")); objReportsDto.setSaleNature(rs.getString("SALENATURE")); objReportsDto.setSaleType(rs.getString("SALETYPE")); objReportsDto.setDispatchAddressName(rs.getString("DISPATCHADDNAME")); objReportsDto.setChargeTypeName(rs.getString("CHARGE_TYPE")); objReportsDto.setFrequencyName(rs.getString("FREQUENCY")); objReportsDto.setChargeName(rs.getString("CHARGE_NAME")); objReportsDto.setBillPeriod(rs.getString("BILL_PERIOD")); objReportsDto.setDnd_Dispatch_But_Not_Delivered(rs.getString("Dnd_Dispatch_But_Not_Delivered")); objReportsDto.setDnd_Dispatch_And_Delivered(rs.getString("Dnd_Dispatch_And_Delivered")); objReportsDto.setDnd_Disp_Del_Not_Installed(rs.getString("Ddni_Disp_Del_Not_Installed")); objReportsDto.setDnd_Disp_Delivered_Installed(rs.getString("Ddni_Disp_Delivered_Installed")); objReportsDto.setStartDateLogic(rs.getString("STARTDATELOGIC")); objReportsDto.setEndDateLogic(rs.getString("ENDDATELOGIC")); objReportsDto.setStartDate(rs.getString("START_DATE")); if (rs.getString("START_DATE") != null && !"".equals(rs.getString("START_DATE"))) { Date date = df.parse(objReportsDto.getStartDate()); objReportsDto.setStartDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setEndDate(rs.getString("END_DATE")); if (rs.getString("END_DATE") != null && !"".equals(rs.getString("END_DATE"))) { Date date = df.parse(objReportsDto.getEndDate()); objReportsDto.setEndDate((Utility.showDate_Report(date)).toUpperCase()); } objReportsDto.setChargeAnnotation(rs.getString("ANNOTATION")); objReportsDto.setFx_St_Chg_Status(rs.getString("CSTATE_FX_CHARGE_START_STATUS"));//Fx_St_Chg_Status objReportsDto.setFx_Ed_Chg_Status(rs.getString("CSTATE_FX_CHARGE_END_STATUS"));//Fx_Ed_Chg_Status objReportsDto.setCharge_status(rs.getString("CHARGES_STATUS")); objReportsDto.setChargeAmount_String(rs.getString("INV_AMT")); objReportsDto.setLineItemAmount(rs.getString("LINEITEMAMOUNT")); objReportsDto.setStartDateDays(rs.getInt("START_DATE_DAYS")); objReportsDto.setStartDateMonth(rs.getInt("START_DATE_MONTH")); objReportsDto.setEndDateDays(rs.getInt("END_DATE_DAYS")); objReportsDto.setEndDateMonth(rs.getInt("END_DATE_MONTH")); objReportsDto.setAnnual_rate(rs.getDouble("ANNUAL_RATE")); } /// End if (pagingSorting.isPagingToBeDone()) { recordCount = rs.getInt("FULL_REC_COUNT"); } listSearchDetails.add(objReportsDto); } pagingSorting.setRecordCount(recordCount); } catch (Exception ex) { //ex.printStackTrace(); Utility.onEx_LOG_RET_NEW_EX(ex, methodName, className, msg, logToFile, logToConsole);//nagarjuna } finally { try { DbConnection.closeResultset(rs); DbConnection.closeCallableStatement(proc); DbConnection.freeConnection(connection); } catch (Exception e) { // TODO Auto-generated catch block //e.printStackTrace(); Utility.onEx_LOG_RET_NEW_EX(e, methodName, className, msg, logToFile, logToConsole);//nagarjuna } } return listSearchDetails; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean hasAuthOnTblWithRole(String who, String role, String db, String table, int privIndex) throws NoSuchObjectException, MetaException { Connection con = null;/*w w w. j ava 2 s. c o m*/ ; Statement ps = null; Privilege priv = privMap.get(privIndex); who = who.toLowerCase(); db = db.toLowerCase(); table = table.toLowerCase(); role = role.toLowerCase(); long nowtime = (new Date()).getTime(); Map<String, String> outofdataInfoMap = new HashMap<String, String>(); Timestamp ts = null; long outofdateTime = 0; boolean isOutofdate = false; try { con = getGlobalConnection(); } catch (MetaStoreConnectException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("audit error, user=" + user + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { ps = con.createStatement(); String sql = "select tdwrole.alter_priv, tdwrole.create_priv, tdwrole.createview_priv, tdwrole.dba_priv, " + "tdwrole.delete_priv, tdwrole.drop_priv, tdwrole.index_priv, tdwrole.insert_priv, tdwrole.select_priv, tdwrole.showview_priv, " + "tdwrole.update_priv, tdwrole.role_name, tdwrole.out_of_date_time from tdwrole, tdwuserrole where tdwuserrole.user_name='" + who.toLowerCase() + "' and tdwrole.role_name='" + role + "' and tdwuserrole.role_name=tdwrole.role_name"; System.out.println(sql); ResultSet roleSet = ps.executeQuery(sql); boolean isRoleFind = false; while (roleSet.next()) { isRoleFind = true; ts = roleSet.getTimestamp(13); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = roleSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (roleSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (roleSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (roleSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (roleSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (roleSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (roleSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (roleSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (roleSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " UPDATE_PRIV", ts.toString()); } } break; } break; } roleSet.close(); if (!isRoleFind) { LOG.error("user/role does not exist or user does not play this role:" + who + "/" + role); throw new MetaException("user/role does not exist or user does not play this role:" + who + "/" + role + ", you shoule check it"); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + role + "' and db_name='" + db.toLowerCase() + "'"; System.out.println(sql); ResultSet dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; case CREATE_VIEW_PRIV: if (dbPrivSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; case SHOW_VIEW_PRIV: if (dbPrivSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on db:" + db + " CREATE_VIEW_PRIV", ts.toString()); } } break; } break; } dbPrivSet.close(); sql = "select alter_priv, create_priv, delete_priv " + ",drop_priv, index_priv, insert_priv, select_priv, update_priv, out_of_date_time " + " from tblpriv where user_name='" + role + "' and db_name='" + db.toLowerCase() + "' and tbl_name='" + table.toLowerCase() + "'"; System.out.println(sql); ResultSet tblSet = ps.executeQuery(sql); while (tblSet.next()) { ts = tblSet.getTimestamp(9); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (tblSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (tblSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (tblSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (tblSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (tblSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (tblSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (tblSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (tblSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("role " + role + " on tbl:" + db + "/" + table + " UPDATE_PRIV", ts.toString()); } } break; } break; } tblSet.close(); sql = "select alter_priv, create_priv, createview_priv, dba_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, showview_priv, " + "update_priv, user_name, group_name, out_of_date_time from tdwuser where tdwuser.user_name='" + who.toLowerCase() + "'"; ResultSet userSet = ps.executeQuery(sql); boolean isUserFind = false; while (userSet.next()) { isUserFind = true; ts = userSet.getTimestamp(14); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } boolean isDBA = userSet.getBoolean(4); if (isDBA) { return true; } switch (priv) { case SELECT_PRIV: if (userSet.getBoolean(9)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (userSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (userSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (userSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (userSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (userSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (userSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (userSet.getBoolean(11)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " UPDATE_PRIV", ts.toString()); } } break; } break; } userSet.close(); if (!isUserFind) { throw new NoSuchObjectException("can not find user:" + who); } sql = "select alter_priv, create_priv, createview_priv, " + "delete_priv, drop_priv, index_priv, insert_priv, select_priv, " + "showview_priv, update_priv, out_of_date_time from dbpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "'"; dbPrivSet = ps.executeQuery(sql); while (dbPrivSet.next()) { ts = dbPrivSet.getTimestamp(11); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (dbPrivSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (dbPrivSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (dbPrivSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (dbPrivSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (dbPrivSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (dbPrivSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (dbPrivSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (dbPrivSet.getBoolean(10)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on db:" + db + " UPDATE_PRIV", ts.toString()); } } break; } break; } dbPrivSet.close(); sql = "select alter_priv, create_priv, delete_priv " + ",drop_priv, index_priv, insert_priv, select_priv, update_priv, out_of_date_time" + " from tblpriv where user_name='" + who.toLowerCase() + "' and db_name='" + db.toLowerCase() + "' and tbl_name='" + table.toLowerCase() + "'"; LOG.error(sql); tblSet = ps.executeQuery(sql); while (tblSet.next()) { ts = tblSet.getTimestamp(9); if (ts != null) { outofdateTime = ts.getTime(); } else { outofdateTime = Long.MAX_VALUE; } if (nowtime > outofdateTime) { isOutofdate = true; } else { isOutofdate = false; } switch (priv) { case SELECT_PRIV: if (tblSet.getBoolean(7)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " SELECT_PRIV", ts.toString()); } } break; case ALTER_PRIV: if (tblSet.getBoolean(1)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " ALTER_PRIV", ts.toString()); } } break; case INSERT_PRIV: if (tblSet.getBoolean(6)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " INSERT_PRIV", ts.toString()); } } break; case INDEX_PRIV: if (tblSet.getBoolean(5)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " INDEX_PRIV", ts.toString()); } } break; case CREATE_PRIV: if (tblSet.getBoolean(2)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " CREATE_PRIV", ts.toString()); } } break; case DROP_PRIV: if (tblSet.getBoolean(4)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " DROP_PRIV", ts.toString()); } } break; case DELETE_PRIV: if (tblSet.getBoolean(3)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " DELETE_PRIV", ts.toString()); } } break; case UPDATE_PRIV: if (tblSet.getBoolean(8)) { if (!isOutofdate) { return true; } else { outofdataInfoMap.put("user " + who + " on tbl:" + db + "/" + table + " UPDATE_PRIV", ts.toString()); } } break; } break; } tblSet.close(); } catch (SQLException sqlex) { LOG.error("get user error, user=" + user + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { closeStatement(ps); closeConnection(con); } if (!outofdataInfoMap.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("priv out of date, you should renewal you privlage; the detail information is "); sb.append("\n"); for (Entry<String, String> e : outofdataInfoMap.entrySet()) { sb.append("priv:" + e.getKey() + ","); sb.append("out of date:" + e.getValue()); sb.append("\n"); } throw new MetaException(sb.toString()); } return false; }
From source file:com.ibm.ioes.dao.ReportsDao_Usage.java
/** * * @param objDto// w w w. j a v a 2 s . c o m * @return * @throws Exception */ public ArrayList<ActiveLineItemReportsDTO> viewActiveLineItemsList(ActiveLineItemReportsDTO objDto) throws Exception { //Nagarjuna String methodName = "viewActiveLineItemsList", className = this.getClass().getName(), msg = ""; boolean logToFile = true, logToConsole = true; //end Nagarjuna ArrayList<ActiveLineItemReportsDTO> objUserList = new ArrayList<ActiveLineItemReportsDTO>(); Connection conn = null; CallableStatement proc = null; ResultSet rs = null; int recordCount = 0; Utility utility = new Utility(); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date tempDate = null; Timestamp ts = null; try { conn = DbConnection.getReportsConnectionObject(); proc = conn.prepareCall(sqlActiveLineItemsForUsage); proc.setInt(1, java.sql.Types.BIGINT); if (objDto.getOrderType() != null && !"".equals(objDto.getOrderType())) { proc.setString(2, objDto.getOrderType().trim()); } else { proc.setNull(2, java.sql.Types.VARCHAR); } if (objDto.getFromDate() != null && !"".equals(objDto.getFromDate())) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); Date dateStr = formatter.parse(objDto.getFromDate()); String formattedDate = formatter.format(dateStr); Date date1 = formatter.parse(formattedDate); formatter = new SimpleDateFormat("MM-dd-yyyy"); formattedDate = formatter.format(date1); proc.setString(3, formattedDate); //proc.setString(2, objDto.getFromDate().trim()); } else { proc.setNull(3, java.sql.Types.VARCHAR); } if (objDto.getToDate() != null && !"".equals(objDto.getToDate())) { SimpleDateFormat formatter1 = new SimpleDateFormat("dd/MM/yyyy"); Date dateStr1 = formatter1.parse(objDto.getToDate()); String formattedDate1 = formatter1.format(dateStr1); Date date2 = formatter1.parse(formattedDate1); formatter1 = new SimpleDateFormat("MM-dd-yyyy"); formattedDate1 = formatter1.format(date2); proc.setString(4, formattedDate1); } else { proc.setNull(4, java.sql.Types.VARCHAR); } if (objDto.getFromOrderNo() != 0 && !"".equals(objDto.getFromOrderNo())) { proc.setInt(5, objDto.getFromOrderNo()); } else { proc.setNull(5, java.sql.Types.BIGINT); } if (objDto.getToOrderNo() != 0 && !"".equals(objDto.getToOrderNo())) { proc.setInt(6, objDto.getToOrderNo()); } else { proc.setNull(6, java.sql.Types.BIGINT); } PagingSorting pagingSorting = objDto.getPagingSorting(); pagingSorting.sync();// To calculate start index and Enc Index proc.setString(7, pagingSorting.getSortByColumn());// columnName proc.setString(8, PagingSorting.DB_Asc_Desc(pagingSorting.getSortByOrder()));// sort order proc.setInt(9, pagingSorting.getStartRecordId());// start index proc.setInt(10, pagingSorting.getEndRecordId());// end index proc.setInt(11, (pagingSorting.isPagingToBeDone() ? 1 : 0));// end // index proc.setInt(12, (objDto.getIsUsage()));// end if (objDto.getFromCopcApprovedDate() != null && !"".equals(objDto.getFromCopcApprovedDate())) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); Date dateStr = formatter.parse(objDto.getFromCopcApprovedDate()); String formattedDate = formatter.format(dateStr); Date date1 = formatter.parse(formattedDate); formatter = new SimpleDateFormat("MM-dd-yyyy"); formattedDate = formatter.format(date1); proc.setString(13, formattedDate); //proc.setString(2, objDto.getFromDate().trim()); } else { proc.setNull(13, java.sql.Types.VARCHAR); } if (objDto.getToCopcApprovedDate() != null && !"".equals(objDto.getToCopcApprovedDate())) { SimpleDateFormat formatter1 = new SimpleDateFormat("dd/MM/yyyy"); Date dateStr1 = formatter1.parse(objDto.getToCopcApprovedDate()); String formattedDate1 = formatter1.format(dateStr1); Date date2 = formatter1.parse(formattedDate1); formatter1 = new SimpleDateFormat("MM-dd-yyyy"); formattedDate1 = formatter1.format(date2); proc.setString(14, formattedDate1); } else { proc.setNull(14, java.sql.Types.VARCHAR); } if (objDto.getPartyNo() != 0 && !"".equals(objDto.getPartyNo())) { proc.setInt(15, objDto.getPartyNo()); } else { proc.setNull(15, java.sql.Types.BIGINT); } System.out.println("Dao" + objDto.getPartyNo()); if (objDto.getCustomerSegment() != null && !"".equals(objDto.getCustomerSegment()) && !objDto.getCustomerSegment().equals("0")) { proc.setString(16, objDto.getCustomerSegment()); } else { proc.setNull(16, java.sql.Types.VARCHAR); } System.out.println("Dao cust " + objDto.getCustomerSegment()); if (objDto.getProductName() != null && !"".equals(objDto.getProductName()) && !objDto.getProductName().equals("0")) { proc.setString(17, objDto.getProductName()); } else { proc.setNull(17, java.sql.Types.VARCHAR); } rs = proc.executeQuery(); int countFlag = 0; ActiveLineItemReportsDTO objdto; while (rs.next() != false) { countFlag++; //Added by Ashutosh for Billing Address //[270513]Start setBlank(); //replaceSeperator("BILLING_LOCATION",rs.getString("BILLING_ADDRESS")); replaceSeperator("PRIMARYLOCATION", rs.getString("PRIMARYLOCATION")); replaceSeperator("SECONDARYLOCATION", rs.getString("SECONDARYLOCATION")); objdto = new ActiveLineItemReportsDTO(); objdto.setLogicalSINo(rs.getString("LOGICAL_SI_NO")); objdto.setCustSINo(rs.getString("CUSTOMER_LOGICAL_SI_NO")); objdto.setServiceName(rs.getString("SERVICENAME")); //objdto.setLinename(rs.getString("LINENAME"));//PARENT_NAME //objdto.setAccountID(rs.getInt("ACCOUNTID"));//CUSTACCOUNTID objdto.setCreditPeriodName(rs.getString("CREDIT_PERIODNAME")); //objdto.setCurrencyName(rs.getString("CURNAME"));//CURRENCYNAME objdto.setEntity(rs.getString("ENTITYNAME")); objdto.setBillingMode(rs.getString("BILLINGMODE")); objdto.setBillingTypeName(rs.getString("BILLING_TYPENAME")); objdto.setBillingformat(rs.getString("BILLING_FORMATNAME")); objdto.setLicCompanyName(rs.getString("LCOMPANYNAME")); objdto.setTaxation(rs.getString("TAXATIONVALUE")); objdto.setBillingLevelName(rs.getString("BILLING_LEVELNAME")); objdto.setBillingLevelNo(rs.getLong("BILLING_LEVEL_NO")); //objdto.setPoNumber(rs.getInt("PODETAILNUMBER"));//PONUMBER Date temDate = rs.getDate("PODATE"); if (temDate != null) { objdto.setPoDate((Utility.showDate_Report(temDate)).toUpperCase()); } objdto.setParty_num(rs.getString("PARTY_NO")); objdto.setBillingTriggerFlag(rs.getString("BILLING_TRIGGER_FLAG")); /*objdto.setPm_pro_date(rs.getString("PM_PROVISIONING_DATE"));//Pm_Prov_Date if (rs.getString("PM_PROVISIONING_DATE") != null && !"".equals(rs.getString("PM_PROVISIONING_DATE"))) { String s1=rs.getString("PM_PROVISIONING_DATE"); String s3=s1.substring(0,7).toUpperCase(); String s4=s1.substring(9,11); String s5=s3.concat(s4); objdto.setPm_pro_date(s5); }*/ objdto.setLocDate(rs.getString("LOCDATE")); if (rs.getString("LOCDATE") != null && !"".equals(rs.getString("LOCDATE"))) { Date date = df.parse(objdto.getLocDate()); objdto.setLocDate((utility.showDate_Report(date)).toUpperCase()); } objdto.setBilling_trigger_date(rs.getString("BILLINGTRIGGERDATE")); if (rs.getString("BILLINGTRIGGERDATE") != null && !"".equals(rs.getString("BILLINGTRIGGERDATE"))) { Date date = df.parse(objdto.getBilling_trigger_date()); objdto.setBilling_trigger_date((utility.showDate_Report(date)).toUpperCase()); } //objdto.setFx_external_acc_id(rs.getString("FX_ACCOUNT_EXTERNAL_ID"));//Child_Account_Number objdto.setChild_account_creation_status(rs.getString("Child_account_FX_sataus")); tempDate = rs.getDate("ORDERDATE"); if (tempDate != null) { objdto.setOrderDate((Utility.showDate_Report(tempDate)).toUpperCase()); } /*objdto.setCopcapprovaldate(rs.getString("APPROVAL_DATE"));//ORDER_APPROVED_DATE if (rs.getString("APPROVAL_DATE") != null && !"".equals(rs.getString("APPROVAL_DATE"))) { objdto.setCopcapprovaldate((utility.showDate_Report(new Date(rs.getTimestamp("APPROVAL_DATE").getTime()))).toUpperCase()); }*/ objdto.setOrderType(rs.getString("ORDERTYPE")); ts = rs.getTimestamp("BILLING_TRIGGER_CREATEDATE"); if (ts != null) { tempDate = new Date(ts.getTime()); objdto.setBillingtrigger_createdate(Utility.showDate_Report(tempDate).toUpperCase()); } objdto.setProductName(rs.getString("PRODUCTNAME")); objdto.setSubProductName(rs.getString("SUBPRODUCTNAME")); objdto.setServiceStage(rs.getString("SERVICE_STAGE")); objdto.setOrderStage(rs.getString("STAGE")); /*objdto.setRfsDate(rs.getString("RFS_DATE"));//SERVICE_RFS_DATE if (rs.getString("RFS_DATE") != null && !"".equals(rs.getString("RFS_DATE"))) { objdto.setRfsDate((utility.showDate_Report(new Date(rs.getTimestamp("RFS_DATE").getTime()))).toUpperCase()); }*/ tempDate = rs.getDate("PORECEIVEDATE"); if (rs.getString("PORECEIVEDATE") != null && !"".equals(rs.getString("PORECEIVEDATE"))) { objdto.setPoReceiveDate((Utility.showDate_Report(tempDate)).toUpperCase()); } objdto.setCustPoDetailNo(rs.getString("CUSTPONUMBER")); //objdto.setCustPoDate(rs.getString("CUST_PODATE"));//PORECEIVEDATE /*if (rs.getString("CUST_PODATE") != null && !"".equals(rs.getString("CUST_PODATE"))) { Date date=df.parse(objdto.getCustPoDate()); objdto.setCustPoDate((utility.showDate_Report(date)).toUpperCase()); }*/ objdto.setM6cktid(rs.getString("CKTID")); objdto.setOrdersubtype(rs.getString("ORDERSUBTYPE")); objdto.setRegion(rs.getString("REGIONNAME"));//Added in View Componet :AKS objdto.setBandwaidth(rs.getString("BANDWIDTH")); objdto.setVertical(rs.getString("VERTICAL_DETAILS")); objdto.setAccountManager(rs.getString("ACCOUNTMANAGER")); objdto.setProjectManager(rs.getString("PROJECTMANAGER")); objdto.setPartyName(rs.getString("PARTYNAME")); //objdto.setBilling_location_from(rs.getString("BILLING_LOCATION"));//BILLING_ADDRESS //objdto.setDemo(rs.getString("DEMO_ORDER"));//Demo_Type //objdto.setToLocation(rs.getString("FROM_LOCATION"));//FROM_ADDRESS //objdto.setFromLocation(rs.getString("TO_LOCATION"));//TO_ADDRESS objdto.setBilling_bandwidth(rs.getString("BILLING_BANDWIDTH")); objdto.setBilling_uom(rs.getString("BILLING_BANDWIDTH_UOM")); objdto.setServiceproductid(rs.getInt("ORDER_LINE_ID")); objdto.setOrderNumber(rs.getInt("ORDERNO")); objdto.setContractPeriod(rs.getInt("CONTRACTPERIOD")); //objdto.setTotalPoAmt(""+rs.getDouble("TOTAL_POAMOUNT"));//ORDERTOTAL objdto.setParty_id(rs.getInt("PARTY_ID")); objdto.setCrmAccountNoString(rs.getString("CRMACCOUNTNO")); //objdto.setServiceId(rs.getInt("SERVICEID"));//SERVICE_NO //[111] START objdto.setMainSpid(rs.getLong("MAIN_SERVICEPRODUCTID")); objdto.setTaxExemptReasonName(rs.getString("REASONNAME")); //[111] end //[003] Start objdto.setServiceSegment(rs.getString("ACCOUNTCATEGORY_DETAILS")); //[003] end //[004] rahul Start objdto.setChargeRedirectionLSI(rs.getString("FX_REDIRECTION_LSI")); //[004] rahul end //[005] Start objdto.setInstallationFromCity(rs.getString("INSTALLATION_FROM_CITY")); objdto.setInstallationToCity(rs.getString("INSTALLATION_TO_CITY")); objdto.setInstallationFromState(rs.getString("INSTALLATION_FROM_STATE")); objdto.setInstallationToState(rs.getString("INSTALLATION_TO_STATE")); objdto.setBillingContactName(rs.getString("BILLING_CONTACT_NAME")); objdto.setBillingContactNumber(rs.getString("BILLING_CONTACT_NUMBER")); objdto.setBillingEmailId(rs.getString("BILLING_EMAIL_ID")); //[005] End //[006] Start objdto.setStandardReason(rs.getString("STANDARDREASON")); objdto.setLdClause(rs.getString("LDCLAUSE")); //[006] End //Saurabh : Changes for Usage for storing charge data if (objDto.getIsUsage() == 0) { objdto.setChargeTypeName(rs.getString("CHARGETYPE")); objdto.setChargeTypeID(rs.getInt("CHARGETYPEID")); objdto.setChargeName(rs.getString("CHARGE_NAME")); objdto.setChargeFrequency(rs.getString("FREQUENCYNAME")); objdto.setBillPeriod(rs.getString("BILL_PERIOD")); objdto.setStartDate(rs.getString("START_DATE")); if (rs.getString("START_DATE") != null && !"".equals(rs.getString("START_DATE"))) { Date date = df.parse(objdto.getStartDate()); objdto.setStartDate((utility.showDate_Report(date)).toUpperCase()); } objdto.setStore(rs.getString("STORENAME")); objdto.setHardwaretypeName(rs.getString("HARDWARETYPENAME")); objdto.setFormAvailable(rs.getString("FORM_C_AVAILABLE")); objdto.setSaleNature(rs.getString("SALENATURENAME")); objdto.setSaleTypeName(rs.getString("SALETYPENAME")); objdto.setPrimaryLocation(rs.getString("PRIMARYLOCATION")); objdto.setSeclocation(rs.getString("SECONDARYLOCATION")); objdto.setChargeAnnotation(rs.getString("ANNOTATION")); objdto.setFx_sd_charge_status(rs.getString("FX_SD_CHG_SATATUS")); objdto.setFx_charge_status(rs.getString("FX_STATUS")); objdto.setFx_Ed_Chg_Status(rs.getString("FX_ED_CHARGE_STATUS")); objdto.setTokenID(rs.getInt("TOKEN_ID")); objdto.setModifiedDate(rs.getString("LAST_UPDATE_DATE")); if (rs.getString("LAST_UPDATE_DATE") != null && !"".equals(rs.getString("LAST_UPDATE_DATE"))) { objdto.setModifiedDate( (utility.showDate_Report(new Date(rs.getTimestamp("LAST_UPDATE_DATE").getTime()))) .toUpperCase()); } objdto.setChallenno(rs.getString("CHALLEN_NO")); objdto.setChallendate(rs.getString("CHALLEN_DATE")); if (rs.getString("CHALLEN_DATE") != null && !"".equals(rs.getString("CHALLEN_DATE"))) { String s1 = rs.getString("CHALLEN_DATE"); String s3 = s1.substring(0, 7).toUpperCase(); String s4 = s1.substring(9, 11); String s5 = s3.concat(s4); objdto.setChallendate(s5); } objdto.setRatio(rs.getString("RATIO")); objdto.setHardwareType(rs.getString("HARDWARE_FLAG")); objdto.setCharge_status(rs.getString("CHARGES_STATUS")); objdto.setLOC_No(rs.getString("LOCNO")); objdto.setAddress1(rs.getString("ADDRESS")); objdto.setRate_code(rs.getString("RATECODE")); objdto.setDistance(rs.getString("CHARGEABLE_DISTANCE")); objdto.setDispatchAddress1(rs.getString("DISPATCH_DETAILS")); objdto.setIndicative_value(rs.getString("INDICATIVE_VALUE")); objdto.setCrm_productname(rs.getString("CRM_PRODUCTNAME")); objdto.setBlSource(rs.getString("BL_SOURCE")); objdto.setChargeAmount(rs.getDouble("INV_AMT")); objdto.setLineamt(rs.getDouble("LINEITEMAMOUNT")); objdto.setChargesSumOfLineitem(rs.getDouble("TOTAL_CHARGE_AMT")); objdto.setM6OrderNo(rs.getInt("M6ORDERID")); objdto.setCust_total_poamt(rs.getDouble("CUST_TOT_PO_AMT")); objdto.setPk_charge_id(rs.getString("PK_CHARGE_ID"));//Added by Ashutosh as on 26-Jun-12 objdto.setContractPeriod(rs.getInt("CONTRACTPERIOD")); objdto.setAnnual_rate(rs.getDouble("ANNUAL_RATE")); //Start: Adding Changes objdto.setLinename(rs.getString("LINENAME"));//PARENT_NAME objdto.setAccountID(rs.getInt("ACCOUNTID"));//CUSTACCOUNTID objdto.setCurrencyName(rs.getString("CURNAME"));//CURRENCYNAME objdto.setPoNumber(rs.getInt("PODETAILNUMBER"));//PONUMBER objdto.setPm_pro_date(rs.getString("PM_PROVISIONING_DATE"));//Pm_Prov_Date if (rs.getString("PM_PROVISIONING_DATE") != null && !"".equals(rs.getString("PM_PROVISIONING_DATE"))) { String s1 = rs.getString("PM_PROVISIONING_DATE"); String s3 = s1.substring(0, 7).toUpperCase(); String s4 = s1.substring(9, 11); String s5 = s3.concat(s4); objdto.setPm_pro_date(s5); } objdto.setFx_external_acc_id(rs.getString("FX_ACCOUNT_EXTERNAL_ID"));//Child_Account_Number objdto.setCopcapprovaldate(rs.getString("APPROVAL_DATE"));//ORDER_APPROVED_DATE if (rs.getString("APPROVAL_DATE") != null && !"".equals(rs.getString("APPROVAL_DATE"))) { objdto.setCopcapprovaldate( (utility.showDate_Report(new Date(rs.getTimestamp("APPROVAL_DATE").getTime()))) .toUpperCase()); } tempDate = rs.getDate("RFS_DATE"); if (tempDate != null) { objdto.setRfsDate((Utility.showDate_Report(tempDate)).toUpperCase()); } objdto.setCustPoDate(rs.getString("CUST_PODATE"));//PORECEIVEDATE if (rs.getString("CUST_PODATE") != null && !"".equals(rs.getString("CUST_PODATE"))) { Date date = df.parse(objdto.getCustPoDate()); objdto.setCustPoDate((utility.showDate_Report(date)).toUpperCase()); } objdto.setBilling_location_from(rs.getString("BILLING_LOCATION"));//BILLING_ADDRESS objdto.setDemo(rs.getString("DEMO_ORDER"));//Demo_Type objdto.setToLocation(rs.getString("FROM_LOCATION"));//FROM_ADDRESS objdto.setFromLocation(rs.getString("TO_LOCATION"));//TO_ADDRESS objdto.setTotalPoAmt("" + rs.getDouble("TOTAL_POAMOUNT"));//ORDERTOTAL objdto.setServiceId(rs.getInt("SERVICEID"));//SERVICE_NO objdto.setPoExpiryDate(rs.getString("PO_EXPIRY_DATE")); if (rs.getString("PO_EXPIRY_DATE") != null && !"".equals(rs.getString("PO_EXPIRY_DATE"))) { //Date date=df.parse(objdto.getPoExpiryDate()); //objdto.setPoExpiryDate((utility.showDate_Report(date)).toUpperCase()); objdto.setPoExpiryDate( (utility.showDate_Report(new Date(rs.getTimestamp("PO_EXPIRY_DATE").getTime()))) .toUpperCase()); } //END } // Meenakshi : Changes for Usage for storing component data else if (objDto.getIsUsage() == 1) { objdto.setFxInternalId(rs.getInt("INTERNAL_ID")); objdto.setMinimum_bandwidth(rs.getString("MINIMUM_BANDWIDTH"));//Need to add in View : AKS(Added) objdto.setMinimum_bandwidth_UOM(rs.getString("MINIMUM_BANDWIDTH_UOM"));//Need to add in View : AKS(Added) objdto.setComponentInfoID(rs.getInt("COMPONENTINFOID")); objdto.setComponentID(rs.getInt("COMPONENT_ID")); objdto.setComponentName(rs.getString("COMPONENT_NAME")); objdto.setPackageID(rs.getInt("PACKAGE_ID")); objdto.setPackageName(rs.getString("PACKAGE_NAME")); ComponentsDto dto = new ComponentsDto(); dto.setComponentType(rs.getString("COMPONENT_TYPE")); dto.setComponentAmount(rs.getDouble("COMP_AMOUNT"));//RC_NRC_COMP_AMOUNT : AKS dto.setComponentStatus(rs.getString("COMPONENT_STATUS")); dto.setStartLogic(rs.getString("COMPONENT_START_LOGIC")); dto.setStartDate(rs.getString("COMPONENT_START_DATE")); if (rs.getString("COMPONENT_START_DATE") != null && !"".equals(rs.getString("COMPONENT_START_DATE"))) { Date date = df.parse(dto.getStartDate()); dto.setStartDate((utility.showDate_Report(date)).toUpperCase()); } dto.setEndLogic(rs.getString("COMPONENT_END_LOGIC")); dto.setEnd_date(rs.getString("COMPONENT_END_DATE")); if (rs.getString("COMPONENT_END_DATE") != null && !"".equals(rs.getString("COMPONENT_END_DATE"))) { Date date = df.parse(dto.getEnd_date()); dto.setEnd_date((utility.showDate_Report(date)).toUpperCase()); } dto.setFxTokenNo(rs.getString("START_COMPONENT_TOKEN_NO")); dto.setFxStartStatus(rs.getString("SYSTEM_START_STATUS")); //dto.setChargesSumOfLineitem(rs.getString("FX_START_COMPONENT_STATUS")); dto.setComponentInstanceID(rs.getString("COMPONENT_INST_ID"));//COMP_FX_INSTANCE_ID : AKS dto.setEndFxStatus(rs.getString("SYSTEM_END_STATUS"));//FX_END_COMPONENT_STATUS :AKS //dto.setStartStatus(rs.getString("FX_ST_COMPONENT_STATUS")); objdto.setExternalId(rs.getString("FX_SI_ID")); //Start: Adding Changes objdto.setM6OrderNo(rs.getInt("M6ORDERNO")); objdto.setLinename(rs.getString("PARENT_NAME")); objdto.setAccountID(rs.getInt("CUSTACCOUNTID")); objdto.setCurrencyName(rs.getString("CURRENCYNAME")); objdto.setPoNumber(rs.getInt("PONUMBER")); objdto.setPm_pro_date(rs.getString("Pm_Prov_Date")); if (rs.getString("Pm_Prov_Date") != null && !"".equals(rs.getString("Pm_Prov_Date"))) { String s1 = rs.getString("Pm_Prov_Date"); String s3 = s1.substring(0, 7).toUpperCase(); String s4 = s1.substring(9, 11); String s5 = s3.concat(s4); objdto.setPm_pro_date(s5); } objdto.setFx_external_acc_id(rs.getString("Child_Account_Number")); /* objdto.setCopcapprovaldate(rs.getString("ORDER_APPROVED_DATE")); if (rs.getString("ORDER_APPROVED_DATE") != null && !"".equals(rs.getString("ORDER_APPROVED_DATE"))) { objdto.setCopcapprovaldate((utility.showDate_Report(new Date(rs.getTimestamp("ORDER_APPROVED_DATE").getTime()))).toUpperCase()); }*/ objdto.setOrderApproveDate(rs.getString("ORDER_APPROVED_DATE"));//Copc date tempDate = rs.getDate("ORDER_APPROVED_DATE"); if (tempDate != null && !"".equals(tempDate)) { objdto.setOrderApproveDate((utility.showDate_Report(tempDate)).toUpperCase()); } objdto.setCopcapprovaldate(rs.getString("COPC_APPROVED_DATE")); ts = rs.getTimestamp("COPC_APPROVED_DATE"); if (ts != null) { tempDate = new Date(ts.getTime()); objdto.setCopcapprovaldate((utility.showDate_Report(tempDate)).toUpperCase()); } tempDate = rs.getDate("SERVICE_RFS_DATE"); if (tempDate != null) { objdto.setRfsDate(Utility.showDate_Report(tempDate).toUpperCase()); } tempDate = rs.getDate("PORECEIVEDATE"); if (tempDate != null) { objdto.setCustPoDate((Utility.showDate_Report(tempDate)).toUpperCase()); } objdto.setBilling_location_from(VAR_PRIMARYLOCATION); objdto.setBilling_location_to(VAR_SECONDARYLOCATION); objdto.setDemo(rs.getString("Demo_Type")); objdto.setToLocation(rs.getString("TO_ADDRESS")); objdto.setFromLocation(rs.getString("FROM_ADDRESS")); objdto.setTotalPoAmt("" + rs.getDouble("ORDERTOTAL")); objdto.setServiceId(rs.getInt("SERVICE_NO")); //nagarjuna PoExpiryDate Modified objdto.setPoExpiryDate(rs.getString("PO_EXPIRY_DATE")); if (rs.getString("PO_EXPIRY_DATE") != null && !"".equals(rs.getString("PO_EXPIRY_DATE"))) { //Date date=df.parse(objdto.getPoExpiryDate()); //objdto.setPoExpiryDate((utility.showDate_Report(date)).toUpperCase()); objdto.setPoExpiryDate( (utility.showDate_Report(new Date(rs.getTimestamp("PO_EXPIRY_DATE").getTime()))) .toUpperCase()); } //nagarjuna PoExpiryDate Modified End //END //satyapan OSP/ISP objdto.setIsOspRequired(rs.getString("IS_OSP")); if (rs.getString("OSP_REG_NO") != null && !"".equals(rs.getString("OSP_REG_NO"))) { objdto.setOspRegistrationNo(rs.getString("OSP_REG_NO")); } else { objdto.setOspRegistrationNo(""); } objdto.setOspRegistrationDate(rs.getString("OSP_REG_DATE")); if (rs.getString("OSP_REG_DATE") != null && !"".equals(rs.getString("OSP_REG_DATE"))) { objdto.setOspRegistrationDate( (Utility.showDate_Report(new Date(rs.getTimestamp("OSP_REG_DATE").getTime()))) .toUpperCase()); } objdto.setIsIspRequired(rs.getString("ISP_TAGGING")); if (rs.getString("ISP_LIC_CTGRY") != null && !"".equals(rs.getString("ISP_LIC_CTGRY")) && !"0".equals(rs.getString("ISP_LIC_CTGRY"))) { objdto.setIspCatageory(rs.getString("ISP_LIC_CTGRY")); } else { objdto.setIspCatageory(""); } if (rs.getString("ISP_LIC_NO") != null && !"".equals(rs.getString("ISP_LIC_NO"))) { objdto.setIspLicenseNo(rs.getString("ISP_LIC_NO")); } else { objdto.setIspLicenseNo(""); } objdto.setIspLicenseDate(rs.getString("ISP_LIC_DATE")); if (rs.getString("ISP_LIC_DATE") != null && !"".equals(rs.getString("ISP_LIC_DATE"))) { objdto.setIspLicenseDate( (Utility.showDate_Report(new Date(rs.getTimestamp("ISP_LIC_DATE").getTime()))) .toUpperCase()); } //End of satyapan OSP/ISP objdto.setComponentDto(dto); } /// End //[007] start objdto.setSalesForceOpportunityNumber(rs.getString("SF_OPP_ID")); objdto.setChannelPartner(rs.getString("PARTNER_NAME")); objdto.setNetworkType(rs.getString("NETWORK_SERVICE_TYPE")); objdto.setPartnerId(rs.getString("PARTNER_ID")); //[007] End //[008] start objdto.setPartnerCode(rs.getString("PARTNER_CODE")); objdto.setFieldEngineer(rs.getString("FIELD_ENGINEER")); //NANCY objdto.setePCNNo(rs.getString("EPCN_NO")); //NANCY //[008] end if (pagingSorting.isPagingToBeDone()) { recordCount = rs.getInt("FULL_REC_COUNT"); //recordCount = countFlag; } objUserList.add(objdto); } pagingSorting.setRecordCount(recordCount); } catch (Exception ex) { Utility.onEx_LOG_RET_NEW_EX(ex, methodName, className, msg, logToFile, logToConsole);//nagarjuna //ex.printStackTrace(); //throw new Exception("SQL Exception : " + ex.getMessage(), ex); } finally { try { DbConnection.closeResultset(rs); DbConnection.closeCallableStatement(proc); DbConnection.freeConnection(conn); } catch (Exception e) { //e.printStackTrace(); //throw new Exception("Exception : " + e.getMessage(), e); Utility.onEx_LOG_RET_NEW_EX(e, methodName, className, msg, logToFile, logToConsole);//nagarjuna } } return objUserList; }