This method initiates a new connection with the thrift client and returns a profile object
private TResume fetchProfileObj(int userId) { try{ TTransport transport = new TSocket("172.XX.X.XXX”, 9311); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); Map<String, String> ids = new HashMap<String, String>(); ids.put("requestId", "settingsService"); TResumeService.Client resumeServiceClient = new TResumeService.Client(protocol); TResume profileObj = resumeServiceClient.getFullActiveProfileFromUserId(ids, 105, userId, "resman5_1"); transport.close(); return profileObj; } catch(Exception e) { e.printStackTrace(); return null; } }
This method updates the profile object recieved from the fetchProfile method
private void updateProfileFlags(TResume profile,int recruiterJobAlert) { try{ TTransport transport = new TSocket("172.XX.X.XXX", 9321); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); Map<String, String> ids = new HashMap<String, String>(); ids.put("requestId", "settingsService"); TUpdateResume.Client updateResumeClient = new TUpdateResume.Client(protocol); profile.getUser().setResdexVisibility(recruiterJobAlert>0?"a":"c"); updateResumeClient.saveProfile(ids, 105, profile.getProfile(), "now", "resman5_1", null); transport.close(); } catch(Exception e) { e.printStackTrace(); } }
Now calling the above methods
public void myTestMethod(){ updateProfileFlags(fetchProfileObj(userId),settings.getRecruiterJobAlert()); }