@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; String patientId = doc.getDocumentReference().getName(); this.pushStorageManager.deletePatientPushInfo(patientId); } }
protected TokenStatus checkUserToken(String userName, String serverName, String token, long tokenLifeTimeInDays) { if (token == null) { return TokenStatus.INVALID; } LocalLoginToken storedToken = this.storageManager.getLocalLoginToken(userName, serverName); if (storedToken == null) { return TokenStatus.INVALID; } // this.logger.debug("Expected token for user [{}]: [{}] aged [{}] out of [{}]", // userName, storedToken.getLoginToken(), storedToken.getTokenAgeInDays(), tokenLifeTimeInDays); if (!token.equals(storedToken.getLoginToken())) { this.logger.warn("Stored token does not match provided token"); return TokenStatus.INVALID; } if (tokenLifeTimeInDays != 0 && (storedToken.getTokenAgeInDays() > tokenLifeTimeInDays)) { this.logger.warn("Stored token has expired"); return TokenStatus.EXPIRED; } return TokenStatus.VALID; }
@Override public PatientPushHistory getPatientPushHistory(String localPatientID, String remoteServerIdentifier) { PatientPushedToInfo pushInfo = this.storageManager.getPatientPushInfo(localPatientID, remoteServerIdentifier); PatientPushHistory history = (pushInfo == null) ? null : new DefaultPatientPushHistory(pushInfo); return history; }
@Override public PushServerSendPatientResponse sendPatient(String patientID, String exportFieldListJSON, String patientState, String groupName, String remoteGUID, String remoteServerIdentifier, String remoteUserName, String password) { Patient patient = getPatientByID(patientID, "push"); if (patient == null) { return new DefaultPushServerSendPatientResponse(DefaultPushServerResponse.generateActionFailedJSON()); } Set<String> exportFields = parseJSONArrayIntoSet(exportFieldListJSON); JSONObject patientStateJSON = this.parsePatientStateToJSON(patientState); PushServerSendPatientResponse response = this.internalService.sendPatient(patient, exportFields, patientStateJSON, groupName, remoteGUID, remoteServerIdentifier, remoteUserName, password, null); if (response != null && response.isSuccessful()) { this.storageManager.storePatientPushInfo(patient.getId(), remoteServerIdentifier, response.getRemotePatientGUID(), response.getRemotePatientID(), response.getRemotePatientURL()); } return response; }
protected void storeUserData(String remoteServerIdentifier, String remoteUser, String loginToken) { String localUserName = getLocalUserName(); this.storageManager.storeRemoteLoginData(localUserName, remoteServerIdentifier, remoteUser, loginToken); }
protected RemoteLoginData getStoredData(String remoteServerIdentifier) { String localUserName = getLocalUserName(); return this.storageManager.getRemoteLoginData(localUserName, remoteServerIdentifier); }
protected void removeUserData(String remoteServerIdentifier) { String localUserName = getLocalUserName(); this.storageManager.removeRemoteLoginData(localUserName, remoteServerIdentifier); }
this.logger.debug("Remote server name: [{}]", serverName); this.storageManager.storeLocalLoginToken(userName, serverName, token);
String sourceServerName = getRemoteServerName(serverConfig, request); String patientGUID = getPatientGUID(affectedPatient); this.storageManager.storePatientSourceServerInfo(patientGUID, sourceServerName);
@Override public PushServerSendPatientResponse sendPatient(String patientID, String exportFieldListJSON, String patientState, String groupName, String remoteGUID, String remoteServerIdentifier, String remoteUserName, String password) { Patient patient = getPatientByID(patientID, "push"); if (patient == null) { return new DefaultPushServerSendPatientResponse(DefaultPushServerResponse.generateActionFailedJSON()); } Set<String> exportFields = parseJSONArrayIntoSet(exportFieldListJSON); JSONObject patientStateJSON = this.parsePatientStateToJSON(patientState); PushServerSendPatientResponse response = this.internalService.sendPatient(patient, exportFields, patientStateJSON, groupName, remoteGUID, remoteServerIdentifier, remoteUserName, password, null); if (response != null && response.isSuccessful()) { this.storageManager.storePatientPushInfo(patient.getDocument().getName(), remoteServerIdentifier, response.getRemotePatientGUID(), response.getRemotePatientID(), response.getRemotePatientURL()); } return response; }
protected void storeUserData(String remoteServerIdentifier, String remoteUser, String loginToken) { String localUserName = getLocalUserName(); this.storageManager.storeRemoteLoginData(localUserName, remoteServerIdentifier, remoteUser, loginToken); }
protected RemoteLoginData getStoredData(String remoteServerIdentifier) { String localUserName = getLocalUserName(); return this.storageManager.getRemoteLoginData(localUserName, remoteServerIdentifier); }
protected void removeUserData(String remoteServerIdentifier) { String localUserName = getLocalUserName(); this.storageManager.removeRemoteLoginData(localUserName, remoteServerIdentifier); }
this.logger.debug("Remote server name: [{}]", serverName); this.storageManager.storeLocalLoginToken(userName, serverName, token);
String sourceServerName = getRemoteServerName(serverConfig, request); String patientGUID = getPatientGUID(affectedPatient); this.storageManager.storePatientSourceServerInfo(patientGUID, sourceServerName);
@Override public PushServerSendPatientResponse sendPatient(String patientID, String exportFieldListJSON, String patientState, String groupName, String remoteGUID, String remoteServerIdentifier) { Patient patient = getPatientByID(patientID, "push"); if (patient == null) { return new DefaultPushServerSendPatientResponse(DefaultPushServerResponse.generateActionFailedJSON()); } RemoteLoginData storedData = getStoredData(remoteServerIdentifier); if (storedData == null || storedData.getRemoteUserName() == null || storedData.getLoginToken() == null) { return new DefaultPushServerSendPatientResponse( DefaultPushServerResponse.generateIncorrectCredentialsJSON()); } Set<String> exportFields = parseJSONArrayIntoSet(exportFieldListJSON); JSONObject patientStateJSON = this.parsePatientStateToJSON(patientState); PushServerSendPatientResponse response = this.internalService.sendPatient(patient, exportFields, patientStateJSON, groupName, remoteGUID, remoteServerIdentifier, storedData.getRemoteUserName(), null, storedData.getLoginToken()); if (response != null && response.isSuccessful()) { this.storageManager.storePatientPushInfo(patient.getId(), remoteServerIdentifier, response.getRemotePatientGUID(), response.getRemotePatientID(), response.getRemotePatientURL()); } return response; }
@Override public PatientPushHistory getPatientPushHistory(String localPatientID, String remoteServerIdentifier) { PatientPushedToInfo pushInfo = this.storageManager.getPatientPushInfo(localPatientID, remoteServerIdentifier); PatientPushHistory history = (pushInfo == null) ? null : new DefaultPatientPushHistory(pushInfo); return history; }
protected TokenStatus checkUserToken(String userName, String serverName, String token, long tokenLifeTimeInDays) { if (token == null) { return TokenStatus.INVALID; } LocalLoginToken storedToken = this.storageManager.getLocalLoginToken(userName, serverName); if (storedToken == null) { return TokenStatus.INVALID; } // this.logger.debug("Expected token for user [{}]: [{}] aged [{}] out of [{}]", // userName, storedToken.getLoginToken(), storedToken.getTokenAgeInDays(), tokenLifeTimeInDays); if (!token.equals(storedToken.getLoginToken())) { this.logger.warn("Stored token does not match provided token"); return TokenStatus.INVALID; } if (tokenLifeTimeInDays != 0 && (storedToken.getTokenAgeInDays() > tokenLifeTimeInDays)) { this.logger.warn("Stored token has expired"); return TokenStatus.EXPIRED; } return TokenStatus.VALID; }
@Override public PushServerSendPatientResponse sendPatient(String patientID, String exportFieldListJSON, String patientState, String groupName, String remoteGUID, String remoteServerIdentifier) { Patient patient = getPatientByID(patientID, "push"); if (patient == null) { return new DefaultPushServerSendPatientResponse(DefaultPushServerResponse.generateActionFailedJSON()); } RemoteLoginData storedData = getStoredData(remoteServerIdentifier); if (storedData == null || storedData.getRemoteUserName() == null || storedData.getLoginToken() == null) { return new DefaultPushServerSendPatientResponse( DefaultPushServerResponse.generateIncorrectCredentialsJSON()); } Set<String> exportFields = parseJSONArrayIntoSet(exportFieldListJSON); JSONObject patientStateJSON = this.parsePatientStateToJSON(patientState); PushServerSendPatientResponse response = this.internalService.sendPatient(patient, exportFields, patientStateJSON, groupName, remoteGUID, remoteServerIdentifier, storedData.getRemoteUserName(), null, storedData.getLoginToken()); if (response != null && response.isSuccessful()) { this.storageManager.storePatientPushInfo(patient.getDocument().getName(), remoteServerIdentifier, response.getRemotePatientGUID(), response.getRemotePatientID(), response.getRemotePatientURL()); } return response; }