Commit 065ff2c4 authored by manohar's avatar manohar

some additional SOP for debugging added


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92891 ce508802-f39f-4f6c-b175-0d175dae99d5
parent db86e37e
......@@ -881,78 +881,109 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
PreparedStatement pstmt = null;
ResultSet rs = null;
String alreadyExists = "N";
String sql = " SELECT RIGHTS FROM USER_RIGHTS "
+ " WHERE PROFILE_ID = ? "
+ " AND APPLICATION = ? "
+ " AND MENU_ROW = ? "
+ " AND MENU_COL = ? "
+ " AND MENU_SUBCOL = ? "
+ " AND LEVEL_4 = ? "
+ " AND LEVEL_5 = ? ";
pstmt = conn.prepareStatement(sql);
String foundRights = null;
int operation = -1;
pstmt.setString(1,profileId);
pstmt.setString(2,application);
pstmt.setInt(3,level1);
pstmt.setInt(4,level2);
pstmt.setInt(5,level3);
pstmt.setInt(6,level4);
pstmt.setInt(7,level5);
rs = pstmt.executeQuery();
if (rs.next())
String sql = " SELECT RIGHTS FROM USER_RIGHTS "
+ " WHERE PROFILE_ID = ? "
+ " AND APPLICATION = ? "
+ " AND MENU_ROW = ? "
+ " AND MENU_COL = ? "
+ " AND MENU_SUBCOL = ? "
+ " AND LEVEL_4 = ? "
+ " AND LEVEL_5 = ? ";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,profileId);
pstmt.setString(2,application);
pstmt.setInt(3,level1);
pstmt.setInt(4,level2);
pstmt.setInt(5,level3);
pstmt.setInt(6,level4);
pstmt.setInt(7,level5);
rs = pstmt.executeQuery();
if (rs.next())
{
foundRights = rs.getString(1);
alreadyExists = "Y";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//foundRights = (String) userRightsMap.get(searchKey);
System.out.println("Found rights in function ["+foundRights+"] rights [" + rights +"] alreadyExists [" + alreadyExists + "]");
if(foundRights == null && rights != null && "N".equals(alreadyExists))
operation = 1;
else if((foundRights != null && rights != null) || ("Y".equals(alreadyExists) && foundRights == null && rights != null) )
operation = 2;
else if(foundRights != null && rights == null && "Y".equals(alreadyExists))
operation = 3;
}
catch (Exception e)
{
foundRights = rs.getString(1);
alreadyExists = "Y";
e.printStackTrace();
throw new ITMException(e);// added by akhilesh on 31/oct/12
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//foundRights = (String) userRightsMap.get(searchKey);
System.out.println("Found rights in function ["+foundRights+"] rights [" + rights +"] alreadyExists [" + alreadyExists + "]");
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(foundRights == null && rights != null && "N".equals(alreadyExists))
operation = 1;
else if((foundRights != null && rights != null) || ("Y".equals(alreadyExists) && foundRights == null && rights != null) )
operation = 2;
else if(foundRights != null && rights == null && "Y".equals(alreadyExists))
operation = 3;
}
return operation;
}
// end 01/06/10 manoharan
int searchUserRight(String searchKey, String rights)
int searchUserRight(String searchKey, String rights) throws Exception
{
System.out.println("searchKey in function ["+searchKey+"]");
System.out.println("rights in function ["+rights+"]");
String foundRights = null;
int operation = -1;
try {
foundRights = (String) userRightsMap.get(searchKey);
System.out.println("Found rights in function ["+foundRights+"]");
System.out.println("searchKey in function ["+searchKey+"]");
System.out.println("rights in function ["+rights+"]");
foundRights = (String) userRightsMap.get(searchKey);
if(foundRights == null && rights != null)
operation = 1;
else if(foundRights != null && rights != null)
operation = 2;
else if(foundRights != null && rights == null)
operation = 3;
System.out.println("Found rights in function ["+foundRights+"]");
if(foundRights == null && rights != null)
operation = 1;
else if(foundRights != null && rights != null)
operation = 2;
else if(foundRights != null && rights == null)
operation = 3;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);// added by akhilesh on 31/oct/12
}
return operation;
}
private ArrayList getAllSubMenu(String application, int level1, int level2, int level3, int level4, int level5, Connection conn)
throws SQLException
{
private ArrayList getAllSubMenu(String application, int level1, int level2, int level3, int level4, int level5, Connection conn) throws Exception
{
String tApplication = null;
String tKey = null;
String tWinName = null;
ArrayList subMenuList = new ArrayList();
PreparedStatement pstmt = null;
ResultSet rs = null;
String parentKey = "";
int tLevel1 = 0;
int tLevel2 = 0;
int tLevel3 = 0;
......@@ -967,74 +998,87 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
" and ( level_1 = 0 or (level_1 <> 0 and (LEVEL_1 = " + level1 + " AND LEVEL_2 > 0))) " +
" and ( level_2 = 0 or (level_2 <> 0 and (LEVEL_2 = " + level2 + " AND LEVEL_3 > 0))) " +
" and ( level_3 = 0 or ( level_3 <> 0 and (LEVEL_3 = " + level3 + " AND LEVEL_4 > 0))) " +
" and ( level_4 = 0 or ( level_4 <> 0 and (LEVEL_4 = " + level4 + " AND LEVEL_5 > 0))) "; //+
//" and WIN_NAME <> '-' " ;
" and ( level_4 = 0 or ( level_4 <> 0 and (LEVEL_4 = " + level4 + " AND LEVEL_5 > 0))) " +
" and WIN_NAME <> '-' " ;
System.out.println("Get All Sub Menu SQL :: " + getSubMenuSql);
String parentKey = application + ":" + level1 + ":" + level2 + ":" + level3 + ":" + level4 + ":" + level5;
ArrayList subMenuList = new ArrayList();
parentKey = application + ":" + level1 + ":" + level2 + ":" + level3 + ":" + level4 + ":" + level5;
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = conn.prepareStatement(getSubMenuSql);
try
{
pstmt = conn.prepareStatement(getSubMenuSql);
rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while(rs.next())
{
tApplication = rs.getString(1);
tLevel1 = rs.getInt(2);
tLevel2 = rs.getInt(3);
tLevel3 = rs.getInt(4);
tLevel4 = rs.getInt(5);
tLevel5 = rs.getInt(6);
String tWinName = null;
tWinName = rs.getString(7);
String tKey = null;
tKey = tApplication + ":" + tLevel1 + ":" + tLevel2 + ":" + tLevel3 + ":" + tLevel4 + ":" + tLevel5;
System.out.println("tKey :: " + tKey);
subMenuList.add(tKey);
tMenuName = rs.getString(8);
if(!menuNameMap.containsKey(tKey))
menuNameMap.put(tKey, tMenuName);
winNameMap.put(tKey, tWinName.trim().substring(2, tWinName.trim().length()));
gotUserRights = (String) userRightsMap.get(tKey);
if(gotUserRights == null || gotUserRights.trim().length() == 0){
gotUserRights = getUserRights(profileId, tApplication, tLevel1, tLevel2, tLevel3, tLevel4, tLevel5, conn);
if(gotUserRights != null && gotUserRights.trim().length() > 0)
userRightsMap.put(tKey, gotUserRights);
while(rs.next())
{
tApplication = rs.getString(1);
tLevel1 = rs.getInt(2);
tLevel2 = rs.getInt(3);
tLevel3 = rs.getInt(4);
tLevel4 = rs.getInt(5);
tLevel5 = rs.getInt(6);
tWinName = rs.getString(7);
tKey = tApplication + ":" + tLevel1 + ":" + tLevel2 + ":" + tLevel3 + ":" + tLevel4 + ":" + tLevel5;
System.out.println("tKey [" + tKey + "] tWinName [" + tWinName + "]");
subMenuList.add(tKey);
tMenuName = rs.getString(8);
if(!menuNameMap.containsKey(tKey))
menuNameMap.put(tKey, tMenuName);
winNameMap.put(tKey, tWinName.trim().substring(2, tWinName.trim().length()));
gotUserRights = (String) userRightsMap.get(tKey);
if(gotUserRights == null || gotUserRights.trim().length() == 0){
gotUserRights = getUserRights(profileId, tApplication, tLevel1, tLevel2, tLevel3, tLevel4, tLevel5, conn);
if(gotUserRights != null && gotUserRights.trim().length() > 0)
userRightsMap.put(tKey, gotUserRights);
}
}
}
rs.close();
rs = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
pstmt.close();
pstmt = null;
if(subMenuList.size() == 0)
subMenuList.add(parentKey);
if(subMenuList.size() == 0)
subMenuList.add(parentKey);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);// added by akhilesh on 31/oct/12
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return subMenuList;
}
}
private String getUserRights(String profileId, String application, int level1, int level2, int level3, int level4, int level5, Connection conn)
throws SQLException
{
private String getUserRights(String profileId, String application, int level1, int level2, int level3, int level4, int level5, Connection conn) throws Exception
{
String userRightsSql = " select RIGHTS " +
" from user_rights " +
" where profile_id = '" + profileId + "' " +
" and APPLICATION = '" + application + "' " +
" and MENU_ROW = " + level1 +
" and MENU_COL = " + level2 +
" and MENU_SUBCOL = " +level3 +
" and LEVEL_4 = " + level4 +
" and LEVEL_5 = " + level5;
" from user_rights " +
" where profile_id = '" + profileId + "' " +
" and APPLICATION = '" + application + "' " +
" and MENU_ROW = " + level1 +
" and MENU_COL = " + level2 +
" and MENU_SUBCOL = " +level3 +
" and LEVEL_4 = " + level4 +
" and LEVEL_5 = " + level5;
String rights = null;
System.out.println("userRightsSql :: " + userRightsSql);
......@@ -1043,25 +1087,47 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = conn.prepareStatement(userRightsSql);
rs = pstmt.executeQuery();
pstmt = conn.prepareStatement(userRightsSql);
if(rs.next())
{
rights = rs.getString(1);
System.out.println("Key = " + key + " : Rights = " + rights);
}
rs = pstmt.executeQuery();
rs.close();
rs = null;
if(rs.next())
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
rights = rs.getString(1);
System.out.println("Key = " + key + " : Rights = " + rights);
e.printStackTrace();
throw new ITMException(e);// added by akhilesh on 31/oct/12
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
return rights;
}
}
}//class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment