Commit b2a70a0d authored by kpandey's avatar kpandey

Changes for landing page dashboard

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202589 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3ba17ad5
package ibase.dashboard.common.webService;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
......@@ -15,20 +18,17 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Context;
//import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
import ibase.dashboard.common.hibernate.dao.DashboardUtil;
import ibase.dashboard.common.hibernate.dao.UserHistoryDAO;
import ibase.ejb.UserEventLogEJB;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.utility.ITMException;
......@@ -127,6 +127,196 @@ public class DashboardService {
return dashboardMetadata.toString();
}
//Added by Kamal
@GET
@Path("/history/password")
@Produces(MediaType.APPLICATION_JSON)
public String getPasswordChgHistory() throws Exception
{
JSONObject passwrdChgHistoryObj = new JSONObject();
JSONArray paswrdChngData = new JSONArray();
try
{
UserInfoBean userInfo = getUserInfo();
if (userInfo != null)
{
String tranDb=userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
UserHistoryDAO userHistoryDAO = new UserHistoryDAO();
paswrdChngData = userHistoryDAO.getPassChgHistory(loginCode, tranDb);
System.out.println("paswrdChgData==>["+paswrdChngData+"]");
passwrdChgHistoryObj.put("passwrdHistory", paswrdChngData);
System.out.println("passwrdHistoryObj==>["+passwrdChgHistoryObj+"]");
}
else {
passwrdChgHistoryObj.put("status","failure" );
passwrdChgHistoryObj.put("message","Unauthorised access" );
}
}
catch (Exception e)
{
System.out.println("Inside getPasswordChgHistory :::" + e);
}
return passwrdChgHistoryObj.toString();
}
@GET
@Path("/history/device")
@Produces(MediaType.APPLICATION_JSON)
public String getDeviceHistory() throws Exception
{
JSONObject deviceHistoryObj = new JSONObject();
JSONArray deviceHistory = new JSONArray();
try
{
UserInfoBean userInfo = getUserInfo();
String tranDb="";
if (userInfo != null)
{
tranDb = userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
UserHistoryDAO userHistoryDAO = new UserHistoryDAO();
deviceHistory = userHistoryDAO.getDeviceHistory(loginCode, tranDb);
System.out.println("deviceHistory :::["+deviceHistory+"]");
deviceHistoryObj.put("deviceList", deviceHistory);
}
else {
deviceHistoryObj.put("status","failure" );
deviceHistoryObj.put("message","Unauthorised access" );
}
}
catch (Exception e)
{
System.out.println("Inside getAllQuestions :::" + e);
}
return deviceHistoryObj.toString();
}
@POST
@Path("/device/changeStatus/{deviceId}/{active}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deactivateDeviceHistory(@PathParam( "deviceID" ) String deviceId, @PathParam( "active" ) String active) throws Exception
{
UserInfoBean userInfo = getUserInfo();
JSONObject resultJson = new JSONObject();
if (userInfo != null)
{
BaseLogger.log("3",userInfo,null, " ***In updateInviteUser Method**** ");
try
{
if( userInfo != null )
{
String tranDb=userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
UserHistoryDAO userHistoryDAO = new UserHistoryDAO();
userHistoryDAO.changeDeviceStatus( loginCode, deviceId, active, tranDb );
resultJson.put("result", loginCode);
}
} catch (Exception e)
{
e.printStackTrace();
resultJson.put("result", "error" );
throw new Exception(e);
}
}
return Response.status(200).entity(resultJson.toString()).build();
}
@GET
@Path("/history/login")
@Produces(MediaType.APPLICATION_JSON)
public String getAllLoginHistory() throws Exception
{
JSONObject noOfContentsObj = new JSONObject();
JSONArray allLoginData = new JSONArray();;
try
{
UserInfoBean userInfo = getUserInfo();
if (userInfo != null)
{
String tranDb=userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
UserHistoryDAO userHistoryDAO = new UserHistoryDAO();
allLoginData = userHistoryDAO.getAllLoginHistory(loginCode, tranDb);
noOfContentsObj.put("lastLogin", allLoginData);
System.out.println("getAllLoginHostory==>["+noOfContentsObj+"]");
}
else {
noOfContentsObj.put("status","failure" );
noOfContentsObj.put("message","Unauthorised access" );
}
}
catch (Exception e)
{
System.out.println("Inside getAllLoginHistory :::" + e);
}
return noOfContentsObj.toString();
}
@GET
@Path("/userActSummary")
@Produces(MediaType.APPLICATION_JSON)
public String getUserActSummary() throws Exception
{
JSONObject userActivitySummObj = new JSONObject();
JSONObject userActSummObj = new JSONObject();
try
{
UserInfoBean userInfo = getUserInfo();
if (userInfo != null)
{
String tranDb=userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
String userName = userInfo.getUserName();
UserHistoryDAO userHistoryDAO = new UserHistoryDAO();
userActivitySummObj = userHistoryDAO.getUserActivitySummary(loginCode, userName, tranDb);
userActSummObj.put("userActSummary", userActivitySummObj);
System.out.println("getUserActSummary==>["+userActSummObj+"]");
}
else {
userActSummObj.put("status","failure" );
userActSummObj.put("message","Unauthorised access" );
}
}
catch (Exception e)
{
System.out.println("Inside getUserActSummary :::" + e);
}
return userActSummObj.toString();
}
private UserInfoBean getUserInfo()
{
UserInfoBean userInfo = null;
HttpSession session = request.getSession();
Object userObj = session.getAttribute( "USER_INFO" );
System.out.println(" CustomerInfoService getUserInfo userObj >>[" + userObj + "]" );
if(userObj != null)
{
try
{
userInfo = new UserInfoBean( userObj.toString() );
}
catch (BaseException e)
{
e.printStackTrace();
}
}
return userInfo;
}
}
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