public String updatedUser() { try { if (validateForm(!true) && validateLoginForm(!updateLogin)) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "mod"); IclubPersonModel model = IclubPersonTrans.fromUItoWS(bean); model.setIclubPerson(getSessionUserId()); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { return updateLogin(); } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } else { IclubWebHelper.addMessage("Fail :: ", FacesMessage.SEVERITY_ERROR); } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } return null; }
public String doIclubLogin() { LOGGER.info("Class :: " + this.getClass() + " :: Method :: doIclubLogin"); if (!validateLogin()) { try { WebClient client = IclubWebHelper.createCustomClient( BASE_URL + "person/login/" + bean.getLName() + "/" + Base64.encodeBase64URLSafeString(DigestUtils.md5(bean.getLPasswd()))); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).get(ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { setTheme(); IclubWebHelper.addMessage("Person Logged-In successfully", FacesMessage.SEVERITY_INFO); WebClient loginClient = IclubWebHelper.createCustomClient(BASE_URL + "person/" + bean.getLName()); IclubLoginModel model = loginClient.accept(MediaType.APPLICATION_JSON).get(IclubLoginModel.class); loginClient.close(); if (model != null && model.getLId() != null) { IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.id"), model.getIclubPersonBByLPersonId()); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.scname"), bean.getLName()); WebClient personClient = IclubWebHelper.createCustomClient( U_BASE_URL + "get/" + model.getIclubPersonBByLPersonId()); IclubPersonModel personModel = personClient.accept(MediaType.APPLICATION_JSON).get(IclubPersonModel.class); personClient.close(); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.name"), personModel.getPFName() + (personModel.getPLName() == null ? "" : personModel.getPLName() + " ")); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.role.id"), model.getIclubRoleType()); return "/pages/dashboard/user/main.xhtml?faces-redirect=true"; } else { IclubWebHelper.addMessage( "Person Profile Fetch Error - Contact Admin", FacesMessage.SEVERITY_ERROR); return ""; } } else { IclubWebHelper.addMessage( "Login error :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); return ""; } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage("Login error :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); return ""; } } else { return ""; } }
public void handleFileUpload(FileUploadEvent fue) { String docId = UUID.randomUUID().toString(); getDocIds().add(docId); try { IclubDocumentModel model = new IclubDocumentModel(); model.setIclubPerson(getSessionUserId()); model.setDCrtdDt(new Date(System.currentTimeMillis())); model.setDId(docId); model.setDName(fue.getFile().getFileName()); model.setDContent(fue.getFile().getContentType()); model.setDSize(fue.getFile().getSize()); WebClient client = IclubWebHelper.createCustomClient(D_BASE_URL + "add"); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { ContentDisposition cd = new ContentDisposition( "attachment;filename=" + fue.getFile().getFileName() + ";filetype=" + fue.getFile().getContentType()); List<Attachment> attachments = new ArrayList<Attachment>(); Attachment attachment = new Attachment(docId, fue.getFile().getInputstream(), cd); attachments.add(attachment); WebClient uploadClient = WebClient.create(D_BASE_URL + "upload"); Response res = uploadClient.type("multipart/form-data").post(new MultipartBody(attachments)); uploadClient.close(); if (res.getStatus() == 200) { IclubWebHelper.addMessage( getLabelBundle().getString("doucmentuploadedsuccessfully"), FacesMessage.SEVERITY_INFO); } else { IclubWebHelper.addMessage( getLabelBundle().getString("doucmentuploadingfailed") + " :: " + (res.getHeaderString("status") != null ? res.getHeaderString("status") : res.getStatusInfo()), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage( getLabelBundle().getString("doucmentuploadingerror") + " :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }
@GET @Path("/validate/sd/{val}/{id}") @Consumes({"application/json"}) @Produces({"application/json"}) @Transactional(propagation = Propagation.REQUIRED) public ResponseModel validateSd(@PathParam("val") String val, @PathParam("id") Long id) { try { List data = iclubNamedQueryDAO.getBySD(val, id, IclubEntityType.class.getSimpleName()); ResponseModel message = new ResponseModel(); if ((data != null) && (data.size() > 0)) { message.setStatusCode(Integer.valueOf(1)); message.setStatusDesc("Duplicate Value"); } else { message.setStatusCode(Integer.valueOf(0)); message.setStatusDesc("Success"); } return message; } catch (Exception e) { LOGGER.error(e, e); ResponseModel message = new ResponseModel(); message.setStatusCode(Integer.valueOf(2)); message.setStatusDesc(e.getMessage()); return message; } }
public String updateLogin() { try { if (validateLoginForm(!updateLogin)) { IclubLoginModel model = new IclubLoginModel(); WebClient client = null; if (loginBean.getLId() != null) { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "mod"); model.setLId(loginBean.getLId()); } else { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "add"); model.setLId(UUID.randomUUID().toString()); } model.setLCrtdDt(new Date(System.currentTimeMillis())); model = IclubLoginTrans.fromUItoWS(loginBean); model.setLPasswd(Base64.encodeBase64URLSafeString(DigestUtils.md5(loginBean.getLPasswd()))); model.setIclubPersonAByLCrtdBy(bean.getPId()); model.setIclubPersonBByLPersonId(getSessionUserId()); model.setIclubRoleType(2l); ResponseModel response = null; if (updateLogin) { response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); } else { response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); } if (response.getStatusCode() == 0) { IclubWebHelper.addObjectIntoSession("social_update_profile", null); IclubWebHelper.addMessage( "Personal Details Updated Successfully", FacesMessage.SEVERITY_INFO); loadBean = false; return "userDashboard"; } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } return null; }
public void updatePassword() { try { if (validateLoginForm(!updateLogin)) { IclubLoginModel model = new IclubLoginModel(); WebClient client = null; if (loginBean.getLId() != null) { client = IclubWebHelper.createCustomClient(BASE_URL + "mod"); model.setLId(loginBean.getLId()); } else { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "add"); model.setLId(UUID.randomUUID().toString()); } model.setLCrtdDt(new Date(System.currentTimeMillis())); model.setLLastDate(loginBean.getLLastDate()); model.setLName(loginBean.getLName()); model.setLPasswd(Base64.encodeBase64URLSafeString(DigestUtils.md5(loginBean.getLPasswd()))); model.setLSecAns(loginBean.getLSecAns()); model.setIclubPersonAByLCrtdBy(bean.getPId()); model.setIclubPersonBByLPersonId(getSessionUserId()); model.setIclubRoleType(2l); model.setIclubSecurityQuestion(loginBean.getIclubSecurityQuestion()); ResponseModel response = null; if (updateLogin) { response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); } else { response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); } if (response.getStatusCode() == 0) { IclubWebHelper.addMessage( "Personal Details Updated Successfully", FacesMessage.SEVERITY_INFO); } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }
public String updatedPerson() { try { if (validateForm(!true)) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "mod"); IclubPersonModel model = IclubPersonTrans.fromUItoWS(bean); model.setIclubPerson(getSessionUserId()); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { for (String doc : getDocIds()) { IclubDocumentModel docModel = new IclubDocumentModel(); docModel.setDId(doc); docModel.setDEntityId(model.getPId().toString()); docModel.setIclubEntityType(1l); WebClient docClient = IclubWebHelper.createCustomClient(D_BASE_URL + "mod"); ResponseModel res = docClient.accept(MediaType.APPLICATION_JSON).put(docModel, ResponseModel.class); if (res.getStatusCode() == 0) LOGGER.info("Doc Merge Successful :: " + doc); } docIds = null; IclubWebHelper.addMessage("Updated Successfully", FacesMessage.SEVERITY_INFO); return "userDashboard"; } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } else { IclubWebHelper.addMessage("Fail :: ", FacesMessage.SEVERITY_ERROR); } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } return ""; }
public void addIclubVehicleMaster() { LOGGER.info("Class :: " + this.getClass() + " :: Method :: addIclubVehicleMaster"); try { if (validateForm(true)) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "add"); IclubVehicleMasterModel model = IclubVehicleMasterTrans.fromUItoWS(bean); model.setVmCrtdDt(new Date(System.currentTimeMillis())); model.setIclubPerson(getSessionUserId()); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { IclubWebHelper.addMessage( getLabelBundle().getString("vehiclemaster") + " " + getLabelBundle().getString("add.success"), FacesMessage.SEVERITY_INFO); viewParam = 1l; showView(); } else { IclubWebHelper.addMessage( getLabelBundle().getString("vehiclemaster") + " " + getLabelBundle().getString("add.error") + " :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage( getLabelBundle().getString("vehiclemaster") + " " + getLabelBundle().getString("add.error") + " :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }
public void modIclubAssessmentType() { LOGGER.info("Class :: " + this.getClass() + " :: Method :: modIclubAssessmentType"); try { if (validateForm(false)) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "mod"); IclubAssessmentTypeModel model = new IclubAssessmentTypeModel(); model.setAtId(bean.getAtId()); model.setAtLongDesc(bean.getAtLongDesc()); model.setAtShortDesc(bean.getAtShortDesc()); model.setAtStatus(bean.getAtStatus()); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { IclubWebHelper.addMessage( getLabelBundle().getString("assessmentType") + " " + getLabelBundle().getString("mod.success"), FacesMessage.SEVERITY_INFO); clearForm(); } else { IclubWebHelper.addMessage( getLabelBundle().getString("assessmentType") + " " + getLabelBundle().getString("mod.error") + " :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage( getLabelBundle().getString("assessmentType") + " " + getLabelBundle().getString("mod.error") + " :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }
@PUT @Path("/mod") @Consumes("application/json") @Produces("application/json") @Transactional(propagation = Propagation.REQUIRED) public ResponseModel mod(IclubEntityTypeModel model) { try { IclubEntityType iCEt = IclubEntityTypeTrans.fromWStoORM(model); iclubEntityTypeDAO.merge(iCEt); LOGGER.info("Merge Success with ID :: " + model.getEtId()); ResponseModel message = new ResponseModel(); message.setStatusCode(0); message.setStatusDesc("Success"); return message; } catch (Exception e) { LOGGER.error(e, e); ResponseModel message = new ResponseModel(); message.setStatusCode(1); message.setStatusDesc(e.getMessage()); return message; } }
@POST @Path("/add") @Consumes("application/json") @Produces("application/json") @Transactional(propagation = Propagation.REQUIRED) public ResponseModel add(IclubQuoteStatusModel model) { try { IclubQuoteStatus iQs = IclubQuoteStatusTrans.fromWStoORM(model); iQs.setQsId(iclubCommonDAO.getNextId(IclubQuoteStatus.class)); iclubQuoteStatusDAO.save(iQs); LOGGER.info("Save Success with ID :: " + iQs.getQsId()); ResponseModel message = new ResponseModel(); message.setStatusCode(0); message.setStatusDesc("Success"); return message; } catch (Exception e) { LOGGER.error(e, e); ResponseModel message = new ResponseModel(); message.setStatusCode(1); message.setStatusDesc(e.getMessage()); return message; } }
public void addIclubBuildingState() { LOGGER.info("Class :: " + this.getClass() + " :: Method :: addIclubBuildingState"); try { if (validateForm(true)) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "add"); IclubBuildingStateModel model = IclubBuildingStateTrans.fromUItoWS(bean); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { IclubWebHelper.addMessage( getLabelBundle().getString("buildingstate") + " " + getLabelBundle().getString("add.success"), FacesMessage.SEVERITY_INFO); clearForm(); } else { IclubWebHelper.addMessage( getLabelBundle().getString("buildingstate") + " " + getLabelBundle().getString("add.error") + " :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage( getLabelBundle().getString("buildingstate") + " " + getLabelBundle().getString("add.error") + " :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }
public boolean validateForm(boolean flag) { boolean ret = true; if (bean.getBsShortDesc() != null && !bean.getBsShortDesc().trim().equalsIgnoreCase("")) { WebClient client = IclubWebHelper.createCustomClient( BASE_URL + "validate/sd/" + bean.getBsShortDesc().trim() + "/" + ((bean.getBsId() == null) ? -999l : bean.getBsId())); ResponseModel message = client.accept(MediaType.APPLICATION_JSON).get(ResponseModel.class); client.close(); if (message.getStatusCode() != 0) { IclubWebHelper.addMessage(message.getStatusDesc(), FacesMessage.SEVERITY_ERROR); ret = ret && false; } } else { IclubWebHelper.addMessage( getLabelBundle().getString("val.shortdesc.empty"), FacesMessage.SEVERITY_ERROR); ret = ret && false; } if (bean.getBsLongDesc() == null || bean.getBsLongDesc().trim().equalsIgnoreCase("")) { IclubWebHelper.addMessage( getLabelBundle().getString("val.longdesc.empty"), FacesMessage.SEVERITY_ERROR); ret = ret && false; } if (bean.getBsStatus() == null || bean.getBsStatus().trim().equalsIgnoreCase("")) { IclubWebHelper.addMessage( getLabelBundle().getString("val.select.valid"), FacesMessage.SEVERITY_ERROR); ret = ret && false; } return ret; }