Commit a549de44 authored by Mohammed Dohadwala's avatar Mohammed Dohadwala

Modified the endpoint to take in json input and produce json response.

parent 07331f60
/**
*
*/
package ibase.webService;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.json.JSONException;
import org.json.JSONObject;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.CryptographyUtil;
import ibase.utility.UserInfoBean;
import ibase.webitm.angular.BuildAngularLayout;
import ibase.webitm.ejb.AuditTrailExtEJB;
import ibase.webitm.reports.utility.ResourceConstants;
import ibase.webitm.utility.E12ExtServiceUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.RestAPIServiceUtility;
import ibase.webitm.utility.ViewReport;
/**
* @author Prasad Raut Changed the structure of class by Gagan B. To seperate
* logic from service file into a new utility file named
* E12ExtServiceUtility.
*/
@Path("/E12ExtService")
//Changed by Prasad on 20/12/2020 [Create a common class RestAPIService, for authentication related process]
public class E12ExtService extends RestAPIService {
/**
* Get External Service Data
*
* @param dataFor
* @param userCode
* @param password
* @param isPwdEncrypt
* @param serviceParam1
* @param serviceParam2
* @param serviceParam3
* @param serviceParam4
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getExtServiceData")
@Produces(MediaType.APPLICATION_JSON)
public Response getExtServiceData(@QueryParam("dataFor") String dataFor, @QueryParam("userCode") String userCode,
@QueryParam("password") String password, @QueryParam("isPwdEncrypt") String isPwdEncrypt,
@QueryParam("serviceParam1") String serviceParam1, @QueryParam("serviceParam2") String serviceParam2,
@QueryParam("serviceParam3") String serviceParam3, @QueryParam("serviceParam4") String serviceParam4,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getExtServiceData(dataFor, userCode, password, isPwdEncrypt, serviceParam1,
serviceParam2, serviceParam3, serviceParam4, request);
return Response.status(200).entity(result).build();
}
/**
*
* @param dataFor
* @param userCode
* @param password
* @param isPwdEncrypt
* @param serviceParam1
* @param serviceParam2
* @param serviceParam3
* @param serviceParam4
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getExtServiceClient")
@Produces(MediaType.APPLICATION_JSON)
public Response getExtnServiceData(@FormParam("dataFor") String dataFor, @FormParam("userCode") String userCode,
@FormParam("password") String password, @FormParam("isPwdEncrypt") String isPwdEncrypt,
@FormParam("serviceParam1") String serviceParam1, @FormParam("serviceParam2") String serviceParam2,
@FormParam("serviceParam3") String serviceParam3, @FormParam("serviceParam4") String serviceParam4,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getExtnServiceData(dataFor, userCode, password, isPwdEncrypt,
serviceParam1, serviceParam2, serviceParam3, serviceParam4, request);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 07/03/16 [E-travel related services - T15JSUN001] START
/**
* Used for authenticate user
*
* @param userCode
* @param password
* @param isPwdEncrypt
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/login")
@Produces(MediaType.APPLICATION_JSON)
public Response authenticateUser(@QueryParam("USER_CODE") String userCode, @QueryParam("PASSWORD") String password,
@QueryParam("IS_PWD_ENCRYPT") String isPwdEncrypt, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("IS_DESTROY_SESSION") boolean isDestroySession, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.authenticateUser(userCode, password, isPwdEncrypt, dataFormat,
isDestroySession, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Used for authenticate user
*
* @param userCode
* @param password
* @param isPwdEncrypt
* @param inputString
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/login")
@Produces(MediaType.APPLICATION_JSON)
public Response authenticateUserClient(@FormParam("USER_CODE") String userCode,
@FormParam("PASSWORD") String password, @FormParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@FormParam("INPUT_STR") String inputString, @FormParam("DATA_FORMAT") String dataFormat,
@Context HttpServletRequest request, @FormParam("IS_DESTROY_SESSION") boolean isDestroySession,
@FormParam("APP_ID") String appId) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.authenticateUserClient(userCode, password, isPwdEncrypt, inputString,
dataFormat, request, isDestroySession, appId);
return Response.status(200).entity(result).build();
}
/**
* Forgot Password
*
* @param userCode
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/forgot_password")
@Produces(MediaType.APPLICATION_JSON)
public Response forgotPassword(@QueryParam("USER_CODE") String userCode,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_HASH") String applicationHashCode, //// Added
//// by
//// Pravin
//// k
//// on
//// 28-FEB-19
//// [For
//// appHash]
//// START
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.forgotPassword(userCode, dataFormat, applicationHashCode, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Forgot Password
*
* @param userCode
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/forgot_password")
@Produces(MediaType.APPLICATION_JSON)
public Response forgotPasswordClient(@FormParam("USER_CODE") String userCode,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.forgotPasswordClient(userCode, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
// Added By Ankush S on 04-DEC-2023[to get the Application list]START
@GET
@Path("/appllist")
@Produces(MediaType.APPLICATION_JSON)
public Response getApplList(@Context HttpServletRequest request,@Context HttpHeaders header) {
BaseLogger.log("3", null, null, "calling API for getting Application List==>");
//return Response.status(200).entity(new E12ExtServiceUtility().getApplList(request)).build();
return new E12ExtServiceUtility().getApplList(request,header);
}
// Added By Ankush S on 04-DEC-2023[to get the Application list]END
// Added By Ankush S on 23-NOV-23 [to get response in JSON]START
@POST
@Path("/loginApp")
@Produces(MediaType.APPLICATION_JSON)
public Response authenticateUserClientLoginApp(
@FormParam("USER_CODE") String userCode,
@FormParam("PASSWORD") String password,
@FormParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@FormParam("INPUT_STR") String inputString,
@FormParam("DATA_FORMAT") String dataFormat,
@Context HttpServletRequest request,
@FormParam("IS_DESTROY_SESSION") boolean isDestroySession,
@FormParam("APP_ID") String appId,
@FormParam("DEVICE_INFO") String deviceInfo) throws BaseException, Exception {
BaseLogger.log("3", null, null, "Calling new API for login");
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.authenticateUserClientJSON(userCode, password, isPwdEncrypt, inputString,
dataFormat, request, isDestroySession, appId,deviceInfo);
return Response.status(200).entity(result).build();
}
// Added By Ankush S on 23-NOV-23 [to get response in JSON]START
// Added By Pankaj T on 13-APR-2026 [loginApp API with bypass GRACE_LOGIN_COUNT logic] START
@POST
@Path("/loginAppDirect")
@Produces(MediaType.APPLICATION_JSON)
public Response authenticateUserClientLoginAppDirect(
@FormParam("USER_CODE") String userCode,
@FormParam("PASSWORD") String password,
@FormParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@FormParam("INPUT_STR") String inputString,
@FormParam("DATA_FORMAT") String dataFormat,
@Context HttpServletRequest request,
@FormParam("IS_DESTROY_SESSION") boolean isDestroySession,
@FormParam("APP_ID") String appId,
@FormParam("DEVICE_INFO") String deviceInfo) throws BaseException, Exception {
BaseLogger.log("3", null, null, "Calling API for login (bypass grace login count)");
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.authenticateUserClientJSONBypassGrace(userCode, password, isPwdEncrypt, inputString,
dataFormat, request, isDestroySession, appId, deviceInfo);
return Response.status(200).entity(result).build();
}
// Added By Pankaj T on 13-APR-2026 [loginApp API with bypass GRACE_LOGIN_COUNT logic] END
// Added By Pankaj T on 29-MAY-2026 [getToken API - generate token from active session and return token_id and session_id] START
@POST
@Path("/getToken")
@Produces(MediaType.APPLICATION_JSON)
public Response getToken(
@FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
BaseLogger.log("3", null, null, "E12ExtService.getToken() appId : [" + appId + "]");
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getTokenOnly(appId, request);
return Response.status(200).entity(result).build();
}
// Added By Pankaj T on 29-MAY-2026 [getToken API - generate token from active session and return token_id and session_id] END
/**
* Change Password
*
* @param userCode
* @param oldPassword
* @param newPassword
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/change_password")
@Produces(MediaType.APPLICATION_JSON)
public Response changePassword(@QueryParam("USER_CODE") String userCode, @QueryParam("OLD_PASS") String oldPassword,
@QueryParam("NEW_PASS") String newPassword, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.changePassword(userCode, oldPassword, newPassword, tokenId, dataFormat,
appId, request);
return Response.status(200).entity(result).build();
}
/**
* Change Password
*
* @param userCode
* @param oldPassword
* @param newPassword
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/change_password")
@Produces(MediaType.APPLICATION_JSON)
public Response changePasswordClient(@FormParam("USER_CODE") String userCode,
@FormParam("OLD_PASS") String oldPassword, @FormParam("NEW_PASS") String newPassword,
@FormParam("TOKEN_ID") String tokenId, @FormParam("DATA_FORMAT") String dataFormat,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request,@Context HttpHeaders header) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
//Added by Ankush S on 07-JUNE-2024 [to get TOKEN_ID from header]START
String headerToken = E12ExtServiceUtility.getTokenFromHeaders(header);
if(tokenId==null&& headerToken!=null && headerToken.length()>0) {
BaseLogger.log("3", null, null, "Change Password POST setting token from header - ");
tokenId = headerToken;
}
if (tokenId == null) {
BaseLogger.log("3", null, null, "Token id is null from all");
// Return a response indicating that the token is missing
String errorMessage = "{\"error\":\"TOKEN_ID is required\"}";
return Response.status(200).entity(errorMessage).build();
}
//Added by Ankush S on 07-JUNE-2024 [to get TOKEN_ID from header]END
String result = E12ExtServiceUtility.changePasswordClient(userCode, oldPassword, newPassword, tokenId,
dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Logout user session
*
* @param userCode
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/logout")
@Produces(MediaType.APPLICATION_JSON)
public Response logout(@QueryParam("USER_CODE") String userCode, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.logout(userCode, tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Logout user session
*
* @param userCode
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/logout")
@Produces(MediaType.APPLICATION_JSON)
public Response logoutClient(@FormParam("USER_CODE") String userCode, @FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.logoutClient(userCode, tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Used for calling system actions for provided object
*
* @param objName - object Name
* @param action - actions to perform ('Add', 'Edit',...)
* @param xmlString - input Data
* @param tokenId -
* @param dataFormat
* @param request
* @return responseStr - respective response in provided data_format
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/callSystemAction")
@Produces(MediaType.APPLICATION_JSON)
public Response callSystemAction(@QueryParam("ACTION") String action, @QueryParam("OBJ_NAME") String objName,
@QueryParam("INPUT_STR") String inputString, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request, @Context ServletContext context) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.callSystemAction(action, objName, inputString, tokenId, dataFormat, appId,
request, context);
return Response.status(200).entity(result).build();
}
/**
* Used for calling system actions for provided object
*
* @param objName - object Name
* @param action - actions to perform ('Add', 'Edit',...)
* @param xmlString - input Data
* @param tokenId -
* @param dataFormat
* @param request
* @return responseStr - respective response in provided data_format
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/callSystemAction")
@Produces(MediaType.APPLICATION_JSON)
public Response callSystemActionClient(@FormParam("ACTION") String action, @FormParam("OBJ_NAME") String objName,
@FormParam("INPUT_STR") String inputString, @FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request, @Context ServletContext context) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.callSystemActionClient(action, objName, inputString, tokenId, dataFormat,
appId, request, context);
return Response.status(200).entity(result).build();
}
/**
* Used for calling user defined events for provided object
*
* @param objName - object Name
* @param eventCode - events to perform ('Confirm a transaction', ...)
* @param xmlString - input data
* @param tokenId
* @param dataFormat
* @param request
* @return responseStr - respective response in provided data_format
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/callSystemEvent")
@Produces(MediaType.APPLICATION_JSON)
public Response callSystemEvent(@QueryParam("OBJ_NAME") String objName, @QueryParam("EVENT_CODE") String eventCode,
@QueryParam("INPUT_STR") String inputString, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.callSystemEvent(objName, eventCode, inputString, tokenId, dataFormat,
appId, request);
return Response.status(200).entity(result).build();
}
/**
* Used for calling user defined events for provided object
*
* @param objName - object Name
* @param eventCode - events to perform ('Confirm a transaction', ...)
* @param xmlString - input data
* @param tokenId
* @param dataFormat
* @param request
* @return responseStr - respective response in provided data_format
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/callSystemEvent")
@Produces(MediaType.APPLICATION_JSON)
public Response callSystemEventClient(@FormParam("OBJ_NAME") String objName,
@FormParam("EVENT_CODE") String eventCode, @FormParam("INPUT_STR") String inputString,
@FormParam("TOKEN_ID") String tokenId, @FormParam("DATA_FORMAT") String dataFormat,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.callSystemEventClient(objName, eventCode, inputString, tokenId, dataFormat,
appId, request);
return Response.status(200).entity(result).build();
}
/**
* to get required data for provided object
*
* @param objName - Object Name
* @param refId - transaction Id
* @param tokenId - provided at login time
* @param dataFormat
* @param request
* @return responseStr - respective data in provided data_format
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getData")
@Produces(MediaType.APPLICATION_JSON)
public Response getData(@QueryParam("OBJ_NAME") String objName, @QueryParam("REF_ID") String refId,
@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getData(objName, refId, tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* to get required data for provided object
*
* @param objName - Object Name
* @param refId - transaction Id
* @param tokenId - provided at login time
* @param enterprise //Added By Gagan B. on 21-FEB-23
* @param dataFormat
* @param request
* @return responseStr - respective data in provided data_format
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getData")
@Produces(MediaType.APPLICATION_JSON)
public Response getDataClient(@FormParam("OBJ_NAME") String objName, @FormParam("REF_ID") String refId,
@FormParam("TOKEN_ID") String tokenId, @FormParam("ENTERPRISE") String enterprise,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request, @Context HttpHeaders header) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
// Added By Ankush S. on 05-APR-2024 [to get token_id from Header if not in
// param]START
String headerToken = E12ExtServiceUtility.getTokenFromHeaders(header);
if (headerToken != null && !headerToken.equals("") && tokenId == null)
tokenId = headerToken;
// Added By Ankush S. on 05-APR-2024 [to get token_id from Header if not in
// param]END
String result = E12ExtServiceUtility.getDataClient(objName, refId, tokenId, enterprise, dataFormat, appId,
request);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 07/03/16 [E-travel related services - T15JSUN001] END
// Added by Prasad on 26/05/16 [Adding PopHelp, ItemChange, BrowData options-
// T15JSUN001] START
/**
* Get Pophelp data
*
* @param objName
* @param fieldName
* @param inputString
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/fieldPophelp")
@Produces(MediaType.APPLICATION_JSON)
public Response getPopHelpData(@QueryParam("OBJ_NAME") String objName, @QueryParam("FIELDNAME") String fieldName,
@QueryParam("INPUT_STR") String inputString, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("INPUT_STR_ALL") String inputStringAllXml,
@QueryParam("FORM_NO") String formNo, @QueryParam("REQ_PARAMS") String reqParams,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request,@Context HttpHeaders header) throws BaseException, Exception// Modified
// by
// Ahmed
// on
// 29-08-2020
// to
// add
// input
// arguments
// as
// per
// required
// to
// fetch
// PopUp
// data
{
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
//Added by Ankush S on 19-JULY-2024 [to get TOKEN from header]START
if(tokenId==null) {
tokenId = E12ExtServiceUtility.getTokenFromHeaders(header);
BaseLogger.log("3", null, null,"getPopHelpData() get=Token getting null");
}
//Added by Ankush S on 19-JULY-2024 [to get TOKEN from header]END
String result = E12ExtServiceUtility.getPopHelpData(objName, fieldName, inputString, tokenId, dataFormat,
inputStringAllXml, formNo, reqParams, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Pophelp data
*
* @param objName
* @param fieldName
* @param inputString
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/fieldPophelp")
@Produces(MediaType.APPLICATION_JSON)
public Response getPopHelpDataClient(@FormParam("OBJ_NAME") String objName,
@FormParam("FIELDNAME") String fieldName, @FormParam("INPUT_STR") String inputString,
@FormParam("TOKEN_ID") String tokenId, @FormParam("DATA_FORMAT") String dataFormat,
@FormParam("INPUT_STR_ALL") String inputStringAllXml, @FormParam("FORM_NO") String formNo,
@FormParam("REQ_PARAMS") String reqParams, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception// Modified by Ahmed on 29-08-2020 to
// add input arguments as per required
// to fetch PopUp data
{
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getPopHelpDataClient(objName, fieldName, inputString, tokenId, dataFormat,
inputStringAllXml, formNo, reqParams, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Brow data
*
* @param objName
* @param argNames
* @param argValues
* @param argTypes
* @param advQuery
* @param searchParam
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/objectBrowse")
@Produces(MediaType.APPLICATION_JSON)
public Response getBrowData(@QueryParam("OBJ_NAME") String objName, @QueryParam("ARG_NAMES") String argNames,
@QueryParam("ARG_VALUES") String argValues, @QueryParam("ARG_TYPES") String argTypes,
@QueryParam("ADV_QRY") String advQuery, @QueryParam("SEARCH_PARAM") String searchParam,
@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getBrowData(objName, argNames, argValues, argTypes, advQuery, searchParam,
tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* get brow data
*
* @param objName
* @param argNames
* @param argValues
* @param argTypes
* @param advQuery
* @param searchParam
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/objectBrowse")
@Produces(MediaType.APPLICATION_JSON)
public Response getBrowDataClient(@FormParam("OBJ_NAME") String objName, @FormParam("ARG_NAMES") String argNames,
@FormParam("ARG_VALUES") String argValues, @FormParam("ARG_TYPES") String argTypes,
@FormParam("ADV_QRY") String advQuery, @FormParam("SEARCH_PARAM") String searchParam,
@FormParam("TOKEN_ID") String tokenId, @FormParam("DATA_FORMAT") String dataFormat,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getBrowDataClient(objName, argNames, argValues, argTypes, advQuery,
searchParam, tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get itemchange data
*
* @param objName
* @param transDomStr
* @param detailDomStr
* @param domId
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/performItemChange")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemChange(@QueryParam("OBJ_NAME") String objName, @QueryParam("TRANS_DOM") String transDomStr,
@QueryParam("DETAIL_DOM") String detailDomStr, @QueryParam("DOM_ID") String domId,
@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getItemChange(objName, transDomStr, detailDomStr, domId, tokenId,
dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* get Itemchange data
*
* @param objName
* @param transDomStr
* @param detailDomStr
* @param domId
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/performItemChange")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemChangeClient(@FormParam("OBJ_NAME") String objName,
@FormParam("TRANS_DOM") String transDomStr, @FormParam("DETAIL_DOM") String detailDomStr,
@FormParam("DOM_ID") String domId, @FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getItemChangeClient(objName, transDomStr, detailDomStr, domId, tokenId,
dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 26/05/16 [Adding PopHelp, ItemChange, BrowData options-
// T15JSUN001] END
// Added by Prasad on 26/05/16 [Adding Workflow related options- T16CSUN001]
// START
/**
* Get Inbox data of Workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getInbox")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwInbox(@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwInbox(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Inbox data of workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getInbox")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwInboxClient(@FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwInboxClient(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Approved data of workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getApproved")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwApproved(@QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwApproved(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Approved data of workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getApproved")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwApprovedClient(@FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwApprovedClient(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Rejected data of workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getRejected")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwRejected(@QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwRejected(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Rejected data of workflow
*
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getRejected")
@Produces(MediaType.APPLICATION_JSON)
public Response getWrkFlwRejectedClient(@FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getWrkFlwRejectedClient(tokenId, dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Sign transaction details
*
* @param refSer
* @param refId
* @param lineNo
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getSignTransDet")
@Produces(MediaType.APPLICATION_JSON)
public Response getSignTransDet(@QueryParam("REF_SER") String refSer, @QueryParam("REF_ID") String refId,
@QueryParam("LINE_NO") String lineNo, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getSignTransDet(refSer, refId, lineNo, tokenId, dataFormat, appId,
request);
return Response.status(200).entity(result).build();
}
/**
* Get Sign transaction details
*
* @param refSer
* @param refId
* @param lineNo
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getSignTransDet")
@Produces(MediaType.APPLICATION_JSON)
public Response getSignTransDetClient(@FormParam("REF_SER") String refSer, @FormParam("REF_ID") String refId,
@FormParam("LINE_NO") String lineNo, @FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getSignTransDetClient(refSer, refId, lineNo, tokenId, dataFormat, appId,
request);
return Response.status(200).entity(result).build();
}
/**
* Update Sign status (Approve/Reject)
*
* @param actionCode
* @param xmlString
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/updateSignStatus")
@Produces(MediaType.APPLICATION_JSON)
public Response updateSignStatus(@QueryParam("ACTION_CODE") String actionCode,
@QueryParam("XML_STRING") String xmlString, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("UUID") String uuid,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request, @Context ServletContext context)
throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.updateSignStatus(actionCode, xmlString, tokenId, dataFormat, uuid, appId,
request, context);
return Response.status(200).entity(result).build();
}
/**
* Update Sign status (Approve/Reject)
*
* @param actionCode
* @param xmlString
* @param tokenId
* @param dataFormat
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/updateSignStatus")
@Produces(MediaType.APPLICATION_JSON)
public Response updateSignStatusClient(@FormParam("ACTION_CODE") String actionCode,
@FormParam("XML_STRING") String xmlString, @FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("UUID") String uuid,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request, @Context ServletContext context,@Context HttpHeaders header)
throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
BaseLogger.log("3", null, null, "updateSignStatus API Token is null - " + (tokenId==null));
if(tokenId==null) {
String headerToken = E12ExtServiceUtility.getTokenFromHeaders(header);
BaseLogger.log("3", null, null, "updateSignStatus API headerToken - " + headerToken);
if (!headerToken.equals("") && tokenId == null)
tokenId = headerToken;
}
BaseLogger.log("3", null, null, "updateSignStatus API Token is null after - " + (tokenId==null));
String result = E12ExtServiceUtility.updateSignStatusClient(actionCode, xmlString, tokenId, dataFormat, uuid,
appId, request, context);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 26/05/16 [Adding Workflow related options- T16CSUN001] END
// Added by Prasad on 26/05/16 [Adding User Image and Attachment related
// options- T16DSUN001] START
/**
* Get User Image
*
* @param tokenId
* @param dataFormat
* @param request
* @param response
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getUserImage")
public Response getUserImage(@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request,
@Context HttpServletResponse response, @Context HttpHeaders header) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
// Added By Ankush S on 28-Feb-2024 [to use tokenId from header if not in
// argument ]
BaseLogger.log("3", null, null, "getUserImage API Token is null - " + (tokenId==null));
if(tokenId==null) {
String headerToken = E12ExtServiceUtility.getTokenFromHeaders(header);
BaseLogger.log("3", null, null, "getUserImage API headerToken - " + headerToken);
if (!headerToken.equals("") && tokenId == null)
tokenId = headerToken;
}
BaseLogger.log("3", null, null, "getUserImage API Token is null after - " + (tokenId==null));
String result = E12ExtServiceUtility.getUserImage(tokenId, dataFormat, appId, request, response);
return Response.status(200).entity(result).build();
}
/**
* Get User Image
*
* @param tokenId
* @param dataFormat
* @param request
* @param response
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getUserImage")
public Response getUserImageClient(@FormParam("TOKEN_ID") String tokenId,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request, @Context HttpServletResponse response)
throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getUserImageClient(tokenId, dataFormat, appId, request, response);
return Response.status(200).entity(result).build();
}
/**
* Get Attachment of provided object name and refId
*
* @param objName
* @param refSer
* @param refId
* @param docType
* @param tokenId
* @param dataFormat
* @param request
* @param response
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getAttachDocument")
public Response getAttachDocument(@QueryParam("OBJ_NAME") String objName, @QueryParam("REF_SER") String refSer,
@QueryParam("REF_ID") String refId, @QueryParam("DOC_TYPE") String docType,
@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getAttachDocument(objName, refSer, refId, docType, tokenId, dataFormat,
appId, request, response);
return Response.status(200).entity(result).build();
}
/**
* Get Attachment of provided object name and refId
*
* @param objName
* @param refSer
* @param refId
* @param docType
* @param tokenId
* @param dataFormat
* @param request
* @param response
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getAttachDocument")
public Response getAttachDocumentClient(@FormParam("OBJ_NAME") String objName, @FormParam("REF_SER") String refSer,
@FormParam("REF_ID") String refId, @FormParam("DOC_TYPE") String docType,
@FormParam("TOKEN_ID") String tokenId, @FormParam("DATA_FORMAT") String dataFormat,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getAttachDocumentClient(objName, refSer, refId, docType, tokenId,
dataFormat, appId, request, response);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 26/05/16 [Adding User Image and Attachment related
// options- T16DSUN001] END
// Added by Prasad on 26/05/16 [For keep alive session] START
/**
* Keep session alive
*
* @param tokenId
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/keepAlive")
public Response keepSessionAlive(@QueryParam("TOKEN_ID") String tokenId, @QueryParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.keepSessionAlive(tokenId, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Keep session alive
*
* @param tokenId
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/keepAlive")
public Response keepSessionAliveClient(@FormParam("TOKEN_ID") String tokenId, @FormParam("APP_ID") String appId,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.keepSessionAliveClient(tokenId, appId, request);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 26/05/16 [For keep alive session] END
// Added by Prasad on 25/05/18 [enterprise implementation in attachment] START
/**
* Upload document
*
* @param tokenId
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/uploadDocument")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response upload(@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.upload(request);
return Response.status(200).entity(result).build();
}
/**
* Get document from docId
*
* @param docId
* @param request
* @return byteArray of document
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getDocument")
public Response getDocument(@FormParam("DOC_ID") String docId, @FormParam("USER_INFO") String userInfoStr,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
byte[] result = E12ExtServiceUtility.getDocument(docId, userInfoStr, request);
return Response.status(200).entity( result ).type( "text/xml" ).build();
}
// Added by Gagan B. on 14-MAY-24 [Add new endpoint which returns document stream from docID and authentication is done based on header Token ID] -- Start
/**
* Get document from docId
*
* @param docId
* @param request
* @return byteArray of document
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getDocumentStream")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public byte[] getDocumentStream(@FormParam("DOC_ID") String docId, @FormParam("USER_INFO") String userInfoStr,
@HeaderParam("TOKEN_ID") String tokenIDfromHeader,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
byte[] result = E12ExtServiceUtility.getDocument(docId, null, tokenIDfromHeader, request);
return result;
}
// Added by Gagan B. on 14-MAY-24 [Add new endpoint which returns document stream from docID and authentication is done based on header Token ID] -- END
/**
* Delete document from docId
*
* @param docId
* @param request
* @return byteArray of document
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/deleteDocument")
public Response deleteDocument(@FormParam("DOC_ID") String docId, @FormParam("REF_ID") String refId,
@FormParam("REF_SER") String refSer, @FormParam("REF_COL") String refCol,
@FormParam("OBJ_NAME") String objName, @FormParam("USER_INFO") String userInfoStr,
@Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.deleteDocument(docId, refId, refSer, refCol, objName, userInfoStr,
request);
return Response.status(200).entity(result).build();
}
// Added by Prasad on 25/05/18 [enterprise implementation in attachment] END
// Added by sunny soni on 07-May-18 for getting app survey information [start]
/**
* getting App survey information from users
*
* @param USER_ID
* @param EASE_USE
* @param FUNC_COVERED
* @param PERFRMNCE
* @param FEEDBACK
* @param request
* @return
* @throws JSONException
* @throws BaseException
* @throws Exception
*/
@SuppressWarnings("unchecked")
@GET
@Path("/getAppSurvey")
public Response getAppsurveyInfo(@QueryParam("USER_ID") String userId, @QueryParam("APP_ID") String appId,
@QueryParam("EASE_USE") String easeUse, @QueryParam("FUNC_COVERED") String funcCovered,
@QueryParam("PERFORMANCE") String performance, @QueryParam("FEEDBACK") String feedback)
throws JSONException {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
JSONObject result = E12ExtServiceUtility.getAppsurveyInfo(userId, appId, easeUse, funcCovered, performance,
feedback);
return Response.status(200).entity(result).build();
}
/**
* getting App survey information from users
*
* @param USER_ID
* @param EASE_USE
* @param FUNC_COVERED
* @param PERFRMNCE
* @param FEEDBACK
* @param request
* @return
* @throws JSONException
* @throws BaseException
* @throws Exception
*/
@SuppressWarnings("unchecked")
@POST
@Path("/getAppSurvey")
public Response getAppsurveyInformation(@FormParam("USER_ID") String userId, @FormParam("APP_ID") String appId,
@FormParam("EASE_USE") String easeUse, @FormParam("FUNC_COVERED") String funcCovered,
@FormParam("PERFORMANCE") String performance, @FormParam("FEEDBACK") String feedback) throws JSONException {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
JSONObject result = E12ExtServiceUtility.getAppsurveyInformation(userId, appId, easeUse, funcCovered,
performance, feedback);
return Response.status(200).entity(result).build();
}
// Added by sunny soni on 07-May-18 for getting app survey information [end]
// Added by sunny soni for getting annotation data and saved annotation
// data[Start]
@POST
@Path("/saveAnnotationData")
public Response saveAnnoataionData(@FormParam("USER_ID") String userId, @FormParam("DOC_ID") String docId,
@FormParam("ANNOT_DATA") String annotationData, @Context HttpServletRequest request) {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
JSONObject result = E12ExtServiceUtility.saveAnnoataionData(userId, docId, annotationData, request);
return Response.status(200).entity(result).build();
}
// Added by sunny soni for getting annoatation data and saved annotation
// data[End]
// Added by sunny soni on 03-Oct-19 for uploading CaptureImage from browser
// notification sent in attachments and return websocket message [Start]
@POST
@Path("/uploadCaptureImage")
public Response uploadCaptureImage(@Context HttpServletRequest request) {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
JSONObject result = E12ExtServiceUtility.uploadCaptureImage(request);
return Response.status(200).entity(result).build();
}
// Added by Umakanta Das on 05/MAY/2017 [ A16LSUN004 ] [ Receive request from
// third party mobile app and return Pay slip data with json format ]Start
/**
* This method return Pay slip data with json format.
*
* @param userCode
* @param password
* @param isPwdEncrypt
* @param dataFormat
* @param apiUrl
* @param token
* @param guid
* @param apIPwd
* @param imei
* @param appId
* @param projectName
* @return return Pay slip data with json format
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getPaySlipData")
@Produces(MediaType.APPLICATION_JSON)
public Response getPaySlipDataClient(@FormParam("USERCODE") String userCode, @FormParam("PASSWORD") String password,
@FormParam("ISPWDENCRYPT") String isPwdEncrypt, @FormParam("DATAFORMAT") String dataFormat,
@FormParam("URL") String apiUrl, @FormParam("TOKEN") String token, @FormParam("GUID") String guid,
@FormParam("APIPwd") String apIPwd, @FormParam("IMEI") String imei, @FormParam("AppID") String appId,
@FormParam("ProjectName") String projectName, @Context HttpServletRequest request)
throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getPaySlipDataClient(userCode, password, isPwdEncrypt, dataFormat, apiUrl,
token, guid, apIPwd, imei, appId, projectName, request);
return Response.status(200).entity(result).build();
}
// Added by Umakanta Das on 05/MAY/2017 [ A16LSUN004 ] [ Receive request from
// third party mobile app and return Pay slip data with json format ]End
// added by vishal pathare on 1.8.18 for[users licence related security]Start
@GET
@Path("/getHashCode")
public Response getHashCode(@QueryParam("tranId") String tranId, @QueryParam("enterprise") String enterprise,
@QueryParam("activeUsrCnt") String activeUsrCnt, @QueryParam("usrLicType") String usrLicType,
@QueryParam("transDb") String transDb, @QueryParam("tokenId") String tokenId,
@QueryParam("appId") String appId, @QueryParam("endPoint") String endPoint,
@QueryParam("name") String name, @QueryParam("emailId") String emailId,
@Context HttpServletRequest request) throws JSONException, ITMException {
String result = "";
boolean response = false;
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
// Added by Vaishali Patil 10/07/23 [provision to add validation to validate
// appId][start]
response = E12ExtServiceUtility.validateLLT(tokenId, appId, endPoint);
if (response) {
result = E12ExtServiceUtility.getHashCode(tranId, enterprise, activeUsrCnt, usrLicType, transDb, request, name, emailId);
}
return Response.status(200).entity(result).build();
// Added by Vaishali Patil 10/07/23 [provision to add validation to validate
// appId][end]
}
// added by vishal pathare on 1.8.18 for[users licence related security]End
// START: Added by Arti: 09-Feb-23: For activate/deactivate the users
@GET
@Path("/setToggleUserLock")
public Response setToggleUserLock(@QueryParam("tranId") String tranId, @QueryParam("enterprise") String enterprise,
@QueryParam("acctLock") String acctLock, @QueryParam("transDb") String transDb,
@Context HttpServletRequest request) throws JSONException, ITMException {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.setToggleUserLock(tranId, enterprise, acctLock, transDb, request);
return Response.status(200).entity(result).build();
}
// END: Added by Arti: 09-Feb-23: For activate/deactivate the users
// START: Added by Arti: 06-Mar-23: For getting Enterprise from
// proteusvision.com
@GET
@Path("/getEnterpriseCode")
public Response getEnterpriseCode(@QueryParam("userId") String userId, @QueryParam("entpDescr") String entpDescr, @QueryParam("usrLicType") String usrLicType,
@QueryParam("tokenId") String tokenId, @QueryParam("appId") String appId,
@QueryParam("endPoint") String endPoint, @Context HttpServletRequest request)
throws JSONException, ITMException {
String result = "";
boolean response = false;
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
// Added by Vaishali Patil 10/07/23 [provision to add validation to validate
// appId][start]
response = E12ExtServiceUtility.validateLLT(tokenId, appId, endPoint);
if (response) {
result = E12ExtServiceUtility.getEnterpriseCode(userId, entpDescr, usrLicType, request);
}
// Added by Vaishali Patil 10/07/23 [provision to add validation to validate
// appId][end]
return Response.status(200).entity(result).build();
}
// END: Added by Arti: 06-Mar-23: For getting Enterprise from proteusvision.com
@GET
@Path("/LicUserCount")
public Response getLicUserCount(@QueryParam("enterprise") String enterprise,
@QueryParam("usrLicType") String usrLicType) throws JSONException, ITMException {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getLicUserCount(enterprise, usrLicType);
return Response.status(200).entity(result).build();
}
// Added by Gagan B. on 08-JUN-2022 for getReport (GET) - [START]
@GET
@Path("/getReport")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getReportGET(@QueryParam("USER_CODE") String userCode, @QueryParam("OBJ_NAME") String objName,
@QueryParam("REPORT_SAVE_TYPE") String docType, @QueryParam("ARGUMENT") String reportArgument,
@QueryParam("TOKEN_ID") String tokenId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
UserInfoBean userInfo = null;
RestAPIServiceUtility restapiserviceutility = new RestAPIServiceUtility();
String key = "a3edd11a09ea4e0ccd09c6cd2828021b";
HashMap<String, String> jwtData = CryptographyUtil.parseBase64EncodedJWTToken(tokenId, key);
userInfo = restapiserviceutility.createUserInfo(jwtData);
BaseLogger.log("3", userInfo, null, "Inside getReportGET method GSB from E12ExtService...");
File file = null;
String filePath = null;
// setting the values of variable here because they are essential for POJO and
// are not required from the user.
String backgrndProcess = "false";
String deviceType = ""; // to check whether device is mobile.
String fromSqlTimeOut = ""; // if sqlTimeOut error comes then it is set true in getReportErrorResponse
// method.
String fromBackgrounServer = "false"; // to check whether file is to be downloaded in background or not.
String browserType = null; // to check from where it is accessed, IE browser etc.
String notifyBy = null; // used in various places like notifyUsers method to determine mode of notifying
// like email, sms etc.
String remoteAddress = request.getRemoteAddr(); // for getting the remote address.
String isExplore = ""; // to check the isExplore condition, if it is yes directly report is viewed by
// writing bytes there itself.
boolean isConfirmReprint = false;
try {
BaseLogger.log("3", userInfo, null, "Inside VIEW_REPORT GSB from E12ExtService 09082022...");
ViewReport viewReport = new ViewReport();
viewReport.getReport(docType, objName, backgrndProcess, deviceType, reportArgument, fromSqlTimeOut,
fromBackgrounServer, userCode, isExplore, isConfirmReprint, browserType, notifyBy, remoteAddress);
BaseLogger.log("3", userInfo, null, "Executed POJO from E12ExtService...");
filePath = viewReport.getFilePath();
file = new File(filePath);
BaseLogger.log("3", userInfo, null, "filePath:::[" + viewReport.getFilePath() + "]");
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception: E12ExtService: getReportGET:==>\n" + e.getMessage());
}
if (filePath.length() < 0 || filePath.equals("") || filePath.equals(null) || file == null) {
JSONObject resultJson = new JSONObject();
resultJson.put("status", "No data found!");
return Response.ok(resultJson, MediaType.APPLICATION_JSON).header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD").build();
}
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
E12ExtServiceUtility.writeAPICallLog("getReportGET ( /getReport )", null, null, null, request, userInfo);
return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM).header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD")
.header("Content-disposition", "attachment; filename = \"" + file.getName().trim() + "\"").build();
}
// Added by Gagan B. on 08-JUN-2022 for getReport (GET) - [END]
// Added by Gagan B. on 28-JUN-2022 for getReport (POST) - [START]
@POST
@Path("/getReport")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getReportPOST(@FormParam("USER_CODE") String userCode, @FormParam("OBJ_NAME") String objName,
@FormParam("REPORT_SAVE_TYPE") String docType, @FormParam("ARGUMENT") String reportArgument,
@FormParam("TOKEN_ID") String tokenId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
UserInfoBean userInfo = null;
RestAPIServiceUtility restapiserviceutility = new RestAPIServiceUtility();
String key = "a3edd11a09ea4e0ccd09c6cd2828021b";
HashMap<String, String> jwtData = CryptographyUtil.parseBase64EncodedJWTToken(tokenId, key);
userInfo = restapiserviceutility.createUserInfo(jwtData);
BaseLogger.log("3", userInfo, null, "Inside getReportPOST method GSB from E12ExtService...");
File file = null;
String filePath = null;
// setting the values of variable here because they are essential for POJO and
// are not required from the user.
String backgrndProcess = "false";
String deviceType = ""; // to check whether device is mobile.
String fromSqlTimeOut = ""; // if sqlTimeOut error comes then it is set true in getReportErrorResponse
// method.
String fromBackgrounServer = "false"; // to check whether file is to be downloaded in background or not.
String browserType = null; // to check from where it is accessed, IE browser etc.
String notifyBy = null; // used in various places like notifyUsers method to determine mode of notifying
// like email, sms etc.
String remoteAddress = request.getRemoteAddr(); // for getting the remote address.
String isExplore = ""; // to check the isExplore condition, if it is yes directly report is viewed by
// writing bytes there itself.
boolean isConfirmReprint = false;
try {
BaseLogger.log("3", userInfo, null, "Inside VIEW_REPORT GSB from E12ExtService 09082022...");
ViewReport viewReport = new ViewReport();
viewReport.getReport(docType, objName, backgrndProcess, deviceType, reportArgument, fromSqlTimeOut,
fromBackgrounServer, userCode, isExplore, isConfirmReprint, browserType, notifyBy, remoteAddress);
BaseLogger.log("3", userInfo, null, "Executed POJO from E12ExtService...");
filePath = viewReport.getFilePath();
file = new File(filePath);
BaseLogger.log("3", userInfo, null, "filePath:::[" + viewReport.getFilePath() + "]");
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception: E12ExtService: getReportGET:==>\n" + e.getMessage());
}
if (filePath.length() < 0 || filePath.equals("") || filePath.equals(null) || file == null) {
JSONObject resultJson = new JSONObject();
resultJson.put("status", "No data found!");
return Response.ok(resultJson, MediaType.APPLICATION_JSON).header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD").build();
}
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
E12ExtServiceUtility.writeAPICallLog("getReportGET ( /getReport )", null, null, null, request, userInfo);
return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM).header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD")
.header("Content-disposition", "attachment; filename = \"" + file.getName().trim() + "\"").build();
}
// Added by Gagan B. on 28-JUN-2022 for getReport (POST) - [END]
// Added by Sainath T. on 01-NOV-2019[Jasper report related implementation]
// -Start
/**
* Get Report Arguments
*
* @param obJName
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/getReportArg")
public Response getReportArg(@QueryParam("OBJ_NAME") String objName, @QueryParam("USER_CODE") String userCode,
@QueryParam("PASSWORD") String password, @QueryParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@QueryParam("TOKEN_ID") String tokenId, @QueryParam("DATA_FORMAT") String dataFormat,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.getReportArg(objName, userCode, password, isPwdEncrypt, tokenId,
dataFormat, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Report Arguments
*
* @param obJName
* @param request
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/getReportArg")
public Response getReportArgClient(@FormParam("OBJ_NAME") String objName, @FormParam("USER_CODE") String userCode,
@FormParam("PASSWORD") String password, @FormParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("TOKEN_ID") String tokenId,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request,@Context HttpHeaders header) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
//Addeed by Ankush S. on 15-APR-2024[to get token_id from header]
String headerToken = E12ExtServiceUtility.getTokenFromHeaders(header);
if(headerToken!=null && !headerToken.equals("") && headerToken.length()>0) {
tokenId = headerToken;
}
String result = E12ExtServiceUtility.getReportArgClient(objName, userCode, password, isPwdEncrypt, dataFormat,
tokenId, appId, request);
return Response.status(200).entity(result).build();
}
/**
* Get Report Arguments
*
* @param obJName
* @param reportArgStr
* @return
* @throws BaseException
* @throws Exception
*/
@GET
@Path("/executeReport")
public Response executeReport(@QueryParam("OBJ_NAME") String objName,
@QueryParam("REPORT_ARG_STR") String reportArgStr, @QueryParam("USER_CODE") String userCode,
@QueryParam("PASSWORD") String password, @QueryParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@QueryParam("DATA_FORMAT") String dataFormat, @QueryParam("TOKEN_ID") String tokenId,
@QueryParam("APP_ID") String appId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.executeReport(objName, reportArgStr, userCode, password, isPwdEncrypt,
dataFormat, tokenId, appId, request, response);
return Response.status(200).entity(result).build();
}
/**
* Get Report Arguments
*
* @param obJName
* @param reportArgStr
* @return
* @throws BaseException
* @throws Exception
*/
@POST
@Path("/executeReport")
public Response executeReportClient(@FormParam("OBJ_NAME") String objName,
@FormParam("REPORT_ARG_STR") String reportArgStr, @FormParam("USER_CODE") String userCode,
@FormParam("PASSWORD") String password, @FormParam("IS_PWD_ENCRYPT") String isPwdEncrypt,
@FormParam("DATA_FORMAT") String dataFormat, @FormParam("TOKEN_ID") String tokenId,
@FormParam("APP_ID") String appId, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.executeReportClient(objName, reportArgStr, userCode, password,
isPwdEncrypt, dataFormat, tokenId, appId, request, response);
return Response.status(200).entity(result).build();
}
// Added by Saiprasad G on 16-MAR-2020[Mail Jasper Report] START
@POST
@Path("/executeReportSendMail")
@Produces({ "application/json" })
@Consumes({ "application/json" })
public Response executeReportAndSendMail(String data, @Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
String result = E12ExtServiceUtility.executeReportAndSendMail(data, request, response);
return Response.status(200).entity(result).build();
}
// Added by Saiprasad G on 16-MAR-2020[Mail Jasper Report] END
@GET
@Path("/buildAngComponent")
@Produces(MediaType.APPLICATION_JSON)
public Response buildAngComponent(@QueryParam("objName") String objName, @Context HttpServletRequest request)
throws BaseException, Exception {
JSONObject resultJson = new JSONObject();
try {
HashMap<String, String> propEditorInfoMap = new HashMap<String, String>();
HttpSession session = request.getSession();
BaseLogger.log("3", null, null, "23012023 session : [" + session + "]");
if (session != null) {
UserInfoBean userInfoBean = (UserInfoBean) session.getAttribute("USER_INFO");
BaseLogger.log("3", userInfoBean, null, "23012023 userInfoBean : [" + userInfoBean + "]");
if (userInfoBean != null) {
propEditorInfoMap.put("PROFILE_ID_RES", userInfoBean.getProfileIdRes());
propEditorInfoMap.put("ENTERPRISE_ID_RES", userInfoBean.getEnterprise());
propEditorInfoMap.put("USER_ID", userInfoBean.getLoginCode());
BaseLogger.log("3", userInfoBean, null, "23012023 propEditorInfoMap : [" + propEditorInfoMap + "]");
}
BuildAngularLayout angLayout = new BuildAngularLayout();
angLayout.buildANGComponent(objName, propEditorInfoMap, userInfoBean);
resultJson.put("result", "success");
}
} catch (Exception e) {
resultJson.put("result", "failure");
BaseLogger.log("3", null, null, "23012023 Exception buildANgComponent : [" + e.getMessage() + "]");
throw new BaseException(e);
}
return Response.status(200).entity(resultJson.toString()).build();
}
@POST
@Path("/uploadJrxml")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadJrxml(
@FormDataParam("file") InputStream fileInputStream,
@HeaderParam("TOKEN_ID") String tokenId,
@Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception {
String auditTranId = "";
AuditTrailExtEJB auditTrailExt = new AuditTrailExtEJB();
UserInfoBean userInfo = null;
E12ExtServiceUtility E12ExtServiceUtility = new E12ExtServiceUtility();
Response apiResponse = null;
try
{
RestAPIServiceUtility restapiserviceutility = new RestAPIServiceUtility();
String key = "a3edd11a09ea4e0ccd09c6cd2828021b";
HashMap<String, String> jwtData = CryptographyUtil.parseBase64EncodedJWTToken(tokenId, key);
userInfo = restapiserviceutility.createUserInfo(jwtData);
BaseLogger.log("3", null, null, "Inside E12ExtService.uploadJrxml() userInfo : ["+ userInfo + "]");
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart)
{
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"Not multipart request\"}")
.build();
}
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> items = upload.parseRequest(request);
String objName = null;
FileItem fileItem = null;
String reportName = null;
for (FileItem item : items)
{
if (item.isFormField())
{
if ("OBJ_NAME".equals(item.getFieldName()))
{
objName = item.getString("UTF-8");
}
else if ("REPORT_NAME".equals(item.getFieldName()))
{
reportName = item.getString("UTF-8");
}
}
else
{
if ("file".equals(item.getFieldName()))
{
fileItem = item;
}
}
}
String chgTerm = userInfo.getRemoteHostName();
if( chgTerm != null && chgTerm.length() > 15 )
{
chgTerm = chgTerm.substring(0, 15);
}
else if( chgTerm == null || chgTerm.length() == 0 )
{
chgTerm = userInfo.getRemoteHost();
}
auditTranId = auditTrailExt.saveActionPerformedInAudit( reportName, "X", "Action", "UPLOAD_JRXML", userInfo.getLoginCode(), chgTerm, userInfo );
BaseLogger.log("3",userInfo,null,"Inside E12ExtService.uploadJrxml() auditTranId ["+ auditTranId +"]");
if (objName == null || fileItem == null || reportName == null)
{
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"ERROR: Missing OBJ_NAME, REPORT_NAME or file\"}")
.build();
}
String designSourcePath = ResourceConstants.DESIGNSOURCEPATH;
String enterprise = userInfo.getEnterprise();
if (enterprise == null || enterprise.trim().isEmpty())
{
if(!"".equalsIgnoreCase(auditTranId))
{
auditTrailExt.updateAuditResponse( auditTranId, "ERROR", "Enterprise not available" ,userInfo);
}
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"ERROR: Enterprise not available\"}")
.build();
}
File targetDir = new File(designSourcePath + File.separator + enterprise.trim());
if (!targetDir.exists())
{
targetDir.mkdirs();
}
String originalFileName = new File(fileItem.getName()).getName();
BaseLogger.log("3", null, null, "Inside E12ExtService.uploadJrxml() originalFileName : [" + originalFileName + "]");
// checked file extension
if (!originalFileName.toLowerCase().endsWith(".jrxml"))
{
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"ERROR: Only .jrxml files are allowed\"}")
.build();
}
// Extract filename without extension
String uploadedNameWithoutExt = originalFileName.substring(0, originalFileName.lastIndexOf('.'));
Set<String> allReports = new LinkedHashSet<>();
String standardPath = designSourcePath + File.separator + reportName + ".jrxml";
E12ExtServiceUtility.collectJrxmlSubReports( reportName, true, standardPath, "", allReports );
String uploadedName = uploadedNameWithoutExt.toLowerCase();
if (!allReports.contains(uploadedName))
{
if(!"".equalsIgnoreCase(auditTranId))
{
auditTrailExt.updateAuditResponse( auditTranId, "ERROR", "File name does not match report name" ,userInfo);
}
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"ERROR: File name does not match report name\"}")
.build();
return apiResponse;
}
// Create target file using original name
File targetFile = new File(targetDir, originalFileName);
fileItem.write(targetFile);
if(!"".equalsIgnoreCase(auditTranId))
{
auditTrailExt.updateAuditResponse( auditTranId, "SUCCESS", "Upload Successfully" ,userInfo);
}
apiResponse = Response.ok()
.entity("{\"message\":\"SUCCESS\"}")
.build();
return apiResponse;
}
catch(Exception e)
{
e.printStackTrace();
String exceptionMsg = e.getMessage();
if(!"".equalsIgnoreCase(auditTranId))
{
String currentResp = "";
if( exceptionMsg.length() > 1000 )
{
currentResp = exceptionMsg.substring(0, 1000);
}
else
{
currentResp = exceptionMsg;
}
auditTrailExt.updateAuditResponse( auditTranId, "Exception", currentResp ,userInfo);
apiResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("{\"message\":\"Internal server error\"}")
.build();
return apiResponse;
}
}
return apiResponse;
}
@POST
@Path("/downloadJrxml")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadJrxml(
@FormParam("OBJ_NAME") String objName,
@FormParam("REPORT_NAME") String reportName,
@FormParam("isStandardLayoutOpen") boolean isStandardLayoutOpen,
@HeaderParam("TOKEN_ID") String tokenId,
@Context HttpServletRequest request,
@Context HttpServletResponse response) throws BaseException, Exception
{
String auditTranId = "";
AuditTrailExtEJB auditTrailExt = new AuditTrailExtEJB();
UserInfoBean userInfo = null;
Response apiResponse = null;
try
{
RestAPIServiceUtility restapiserviceutility = new RestAPIServiceUtility();
String key = "a3edd11a09ea4e0ccd09c6cd2828021b";
HashMap<String, String> jwtData = CryptographyUtil.parseBase64EncodedJWTToken(tokenId, key);
userInfo = restapiserviceutility.createUserInfo(jwtData);
BaseLogger.log("3", null, null, "Inside E12ExtService.downloadJrxml() userInfo : ["+ userInfo + "]");
BaseLogger.log("3", null, null, "Inside E12ExtService.downloadJrxml() reportName : ["+ reportName + "]");
String designSourcePath = ResourceConstants.DESIGNSOURCEPATH;
String enterprise = userInfo.getEnterprise();
String jrxmlFilePath = "";
String chgTerm = userInfo.getRemoteHostName();
if( chgTerm != null && chgTerm.length() > 15 )
{
chgTerm = chgTerm.substring(0, 15);
}
else if( chgTerm == null || chgTerm.length() == 0 )
{
chgTerm = userInfo.getRemoteHost();
}
auditTranId = auditTrailExt.saveActionPerformedInAudit( reportName, "X", "Action", "DOWNLOAD_JRXML", userInfo.getLoginCode(), chgTerm, userInfo );
BaseLogger.log("3",userInfo,null,"Inside E12ExtService.downloadJrxml() auditTranId ["+ auditTranId +"]");
if(isStandardLayoutOpen == true)
{
jrxmlFilePath = designSourcePath + File.separator + reportName + ".jrxml";
}
else if(isStandardLayoutOpen == false)
{
jrxmlFilePath = designSourcePath + File.separator + enterprise.trim() + File.separator + reportName + ".jrxml";
}
BaseLogger.log("3", null, null, "Inside E12ExtService.downloadJrxml() jrxmlFilePath : ["+ jrxmlFilePath + "]");
File downloadFile = new File(jrxmlFilePath);
BaseLogger.log("3", null, null, "Inside E12ExtService.downloadJrxml() downloadFile : ["+ downloadFile + "]");
if (downloadFile == null || !downloadFile.exists())
{
apiResponse = Response.status(Response.Status.BAD_REQUEST)
.entity("{\"message\":\"ERROR: File not found\"}")
.build();
}
if (enterprise != null && enterprise.trim().length() > 0)
{
File enterpriseDir = new File(designSourcePath + File.separator + enterprise.trim());
if (!enterpriseDir.exists())
{
enterpriseDir.mkdirs();
}
File targetEnterpriseFile = new File(enterpriseDir, downloadFile.getName());
// Avoid copying file onto itself
if (!downloadFile.getAbsolutePath().equals(targetEnterpriseFile.getAbsolutePath()) && !targetEnterpriseFile.exists())
{
try
{
java.nio.file.Files.copy(downloadFile.toPath(), targetEnterpriseFile.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
BaseLogger.log("3", null, null, "Inside E12ExtService.downloadJrxml() - JRXML copied to enterprise path : ["+ targetEnterpriseFile.getAbsolutePath() + "]");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// Set response headers
apiResponse = Response.ok(downloadFile).header("Content-Disposition", "attachment; filename=\"" + downloadFile.getName() + "\"").build();
InputStream in = null;
OutputStream out = null;
boolean downloadSuccess = false;
try
{
in = new FileInputStream(downloadFile);
out = response.getOutputStream();
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, bytesRead);
}
out.flush();
downloadSuccess = true;
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
if(downloadSuccess)
{
if(!"".equalsIgnoreCase(auditTranId))
{
auditTrailExt.updateAuditResponse( auditTranId, "SUCCESS", "Download Successfully" ,userInfo);
}
}
apiResponse = Response.ok()
.entity("{\"message\":\"SUCCESS\"}")
.build();
}
catch (Exception e)
{
e.printStackTrace();
String exceptionMsg = e.getMessage();
if(!"".equalsIgnoreCase(auditTranId))
{
String currentResp = "";
if( exceptionMsg.length() > 1000 )
{
currentResp = exceptionMsg.substring(0, 1000);
}
else
{
currentResp = exceptionMsg;
}
auditTrailExt.updateAuditResponse( auditTranId, "Exception", currentResp ,userInfo);
apiResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("{\"message\":\"Internal server error\"}")
.build();
}
}
return apiResponse;
}
}
......@@ -69,6 +69,7 @@ import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
......@@ -3937,31 +3938,42 @@ public class E12ExtServiceUtility extends RestAPIServiceUtility {
}
public String upload(HttpServletRequest request) {
public String upload(HttpServletRequest request)
{
String result = "";
String params = "";
String status = "error";
try {
try
{
params = request.getQueryString();
if (checkNull(params).length() == 0) {
if (checkNull(params).length() == 0)
{
StringBuffer paramString = new StringBuffer();
params = paramString.toString();
}
BaseLogger.log("3", null, null, "params - " + params);
result = uploadDocument(request);
status = "success";
} catch (Exception e) {
}
catch (Exception e)
{
BaseLogger.log("0", null, null, "Exception : uploadDocument : " + e.getMessage());
status = "exception";
// Changed By Ravindra C on 25-05-21 to write a exception in input Data format
// result = getStackTrace(e);
result = getStackTrace(e, "JSON");
} finally {
}
finally
{
result = generateResponse(request, "uploadDocument", params, "", "JSON", status, result);
}
writeAPICallLog("upload ( /uploadDocument )", status, result, null, request, userInfo);
return result;
return result;
}
public byte[] getDocument(String docId, String userInfoStr, HttpServletRequest request) {
......@@ -8555,11 +8567,16 @@ public class E12ExtServiceUtility extends RestAPIServiceUtility {
// Added by Mohammed on 20-AUG-26 to support TOKEN_ID authentication for document upload
// Replaced USER_INFO with UserInfoBean created from the token
private String uploadDocument(HttpServletRequest request) throws ITMException {
// Added by Mohammed on 01-SEP-26 to support JSON input for document upload
// XML is generated internally and passed to DocumentHandlerEJB
private String uploadDocument(HttpServletRequest request) throws ITMException
{
String retString = "";
try {
String retXMLStr = "";
String tokenId = "";
try
{
String inputJson = "";
String tokenId = request.getHeader("TOKEN_ID");
byte[] byteArray = { 0 };
byte[] videoFrameBytes = { 0 };
......@@ -8572,63 +8589,269 @@ public class E12ExtServiceUtility extends RestAPIServiceUtility {
factory.setRepository(new File(System.getProperty("java.io.tmpdir")));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setFileSizeMax(MAX_FILE_SIZE);
upload.setSizeMax(MAX_REQUEST_SIZE);
List<FileItem> formItems = upload.parseRequest(request);
if (formItems != null && formItems.size() > 0) {
if (formItems != null && formItems.size() > 0)
{
String fieldName = "";
for (FileItem item : formItems) {
for (FileItem item : formItems)
{
fieldName = item.getFieldName();
BaseLogger.log("3", null, null, "fieldName : [" + fieldName + "]");
if (item.isFormField()) {
if (item.isFormField())
{
String fieldValue = item.getString();
BaseLogger.log("3", null, null, "fieldValue : [" + fieldValue + "]");
if ("UPLOAD_XML_STR".equalsIgnoreCase(fieldName)) {
retXMLStr = fieldValue;
} else if ("TOKEN_ID".equalsIgnoreCase(fieldName)) {
tokenId = fieldValue;
if ("INPUT_JSON".equalsIgnoreCase(fieldName))
{
inputJson = fieldValue;
}
} else if (!item.isFormField()) {
}
else
{
String fileName = new File(item.getName()).getName();
BaseLogger.log("3", null, null, "fileName : [" + fileName + "]");
if ("fileBytes".equalsIgnoreCase(fieldName)) {
if ("fileBytes".equalsIgnoreCase(fieldName))
{
byteArray = item.get();
BaseLogger.log("3", null, null, "byteArray : [" + byteArray + "]");
} else if ("videoFrameBytes".equalsIgnoreCase(fieldName)) {
}
else if ("videoFrameBytes".equalsIgnoreCase(fieldName))
{
videoFrameBytes = item.get();
BaseLogger.log("3", null, null, "videoFrameBytes : [" + videoFrameBytes + "]");
}
}
}
}
if (tokenId != null && tokenId.trim().length() > 0) {
userInfo = apiUtility.createUserInfoFromJWTToken(tokenId);
if (checkNull(inputJson).length() == 0)
{
throw new Exception("Request JSON cannot be empty.");
}
if (userInfo == null) {
userInfo = apiUtility.createUserInfoFromJWTToken(checkNull(tokenId));
if (userInfo == null)
{
throw new Exception("Invalid TOKEN_ID or user information could not be created.");
}
// DocumentHandlerWrapperRemote docHandler = (DocumentHandlerWrapperRemote)
// getInitialContext().lookup( "ibase/DocumentHandlerWrapperEJB/remote" );
// DocumentHandlerWrapperEJB docHandler = new DocumentHandlerWrapperEJB();
JSONObject requestJson = new JSONObject(inputJson);
JSONObject docInfo = requestJson.optJSONObject("doc_info");
if (docInfo == null)
{
throw new Exception("doc_info is mandatory in request JSON.");
}
String refId = checkNull(docInfo.optString("ref_id"));
String objName = checkNull(docInfo.optString("obj_name"));
String docName = checkNull(docInfo.optString("doc_name"));
String docType = checkNull(docInfo.optString("doc_type"));
String refCol = checkNull(docInfo.optString("ref_col"));
String documentType = checkNull(docInfo.optString("document_type"));
if (objName.length() == 0)
{
throw new Exception("obj_name is mandatory.");
}
if (docName.length() == 0)
{
throw new Exception("doc_name is mandatory.");
}
if (docType.length() == 0)
{
int lastDot = docName.lastIndexOf(".");
if (lastDot >= 0 && lastDot < docName.length() - 1)
{
docType = docName.substring(lastDot + 1);
}
}
if (docType.length() == 0)
{
throw new Exception("doc_type could not be determined for DOC_NAME : [" + docName + "]");
}
String refSer = "";
String docLinkOpt = "";
String cacheOpt = "0";
if (objName.equalsIgnoreCase("content_library"))
{
refSer = "COPLST";
refId = "TRD";
documentType = "Others";
docLinkOpt = "DOC_CONTENT";
}
else
{
DBAccessEJB dbAccessEJB = new DBAccessEJB();
try
{
refSer = checkNull(dbAccessEJB.getDBColumnValue(
"TRANSETUP",
"REF_SER",
(" TRAN_WINDOW = 'w_" + objName + "'"),
"Driver"));
}
catch (RemoteException e)
{
throw e;
}
catch (ITMException e)
{
throw e;
}
finally
{
dbAccessEJB = null;
}
}
if (refSer.length() == 0)
{
throw new Exception("REF_SER could not be determined for OBJ_NAME : [" + objName + "]");
}
if (refId.length() == 0)
{
throw new Exception("ref_id is mandatory.");
}
String createdBy = checkNull(userInfo.getLoginCode());
StringBuilder xmlBuilder = new StringBuilder();
xmlBuilder.append("<?xml version=\"1.0\" encoding=\"")
.append(CommonConstants.ENCODING)
.append("\"?>");
xmlBuilder.append("<DocumentRoot>");
xmlBuilder.append("<description>Datawindow Root</description>");
xmlBuilder.append("<group0>");
xmlBuilder.append("<description>Group0 description</description>");
xmlBuilder.append("<Header0>");
xmlBuilder.append("<description>Header0 members</description>");
xmlBuilder.append("<header>");
xmlBuilder.append("<ref_id><![CDATA[")
.append(refId)
.append("]]></ref_id>");
xmlBuilder.append("<ref_col><![CDATA[")
.append(refCol.length() > 0 ? refCol : " ")
.append("]]></ref_col>");
xmlBuilder.append("<obj_name><![CDATA[")
.append(objName)
.append("]]></obj_name>");
xmlBuilder.append("<ref_ser><![CDATA[")
.append(refSer)
.append("]]></ref_ser>");
xmlBuilder.append("<doc_name><![CDATA[")
.append(docName)
.append("]]></doc_name>");
xmlBuilder.append("<doc_type><![CDATA[")
.append(docType)
.append("]]></doc_type>");
xmlBuilder.append("<created_by><![CDATA[")
.append(createdBy)
.append("]]></created_by>");
xmlBuilder.append("<document_type><![CDATA[")
.append(documentType)
.append("]]></document_type>");
xmlBuilder.append("<doc_link_optn><![CDATA[")
.append(docLinkOpt)
.append("]]></doc_link_optn>");
xmlBuilder.append("<cache_opt><![CDATA[")
.append(cacheOpt)
.append("]]></cache_opt>");
xmlBuilder.append("</header>");
xmlBuilder.append("</Header0>");
xmlBuilder.append("</group0>");
xmlBuilder.append("</DocumentRoot>");
String retXMLStr = xmlBuilder.toString();
BaseLogger.log("3", userInfo, null, "Generated XML : [" + retXMLStr + "]");
DocumentHandlerEJB docHandler = new DocumentHandlerEJB();
retString = docHandler.addDocument(retXMLStr, byteArray, videoFrameBytes, getUserInfo());
retString = docHandler.addDocument
(
retXMLStr,
byteArray,
videoFrameBytes,
getUserInfo()
);
if (checkNull(retString).length() > 0)
{
JSONObject responseJson = XML.toJSONObject(retString);
JSONObject documentJson = responseJson.optJSONObject("Document");
JSONObject idJson = null;
if (documentJson != null)
{
idJson = documentJson.optJSONObject("ID");
}
if (idJson != null)
{
JSONObject filteredJson = new JSONObject();
filteredJson.put("Name", idJson.optString("Name"));
filteredJson.put("Document_Id", idJson.optString("Document_Id"));
filteredJson.put("Type", idJson.optString("Type"));
filteredJson.put("Created_By", idJson.optString("Created_By"));
filteredJson.put("Created_Date", idJson.optString("Created_Date"));
retString = filteredJson.toString();
}
else
{
retString = responseJson.toString();
}
}
docHandler = null;
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception :: uploadDocument : [" + e.getMessage() + "]");
}
catch (Exception e)
{
BaseLogger.log("0", null, null,
"Exception :: uploadDocument : [" + e.getMessage() + "]");
throw new ITMException(e);
}
return retString;
}
// Added by sunny soni on 03-OCT-19 for uploading CaptureImage from browser
// notification sent in attachments and return websocket message[Start]
private String getAttachmentDetailStr(String objName, String refSer, String refId, String filePath, File file,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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