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 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); } }