@Override public String toString() { return "Access rules for " + (this.patient != null ? this.patient.getDocument() : "<unknown patient>"); } }
@Override public boolean isAdministrator(Patient patient, DocumentReference user) { if (patient == null || patient.getDocument() == null) { return false; } return this.rights.hasAccess(Right.ADMIN, user, patient.getDocument()); }
@Override public DocumentReference getDocument() { return this.access.isOpenAccess() ? this.match.getDocument() : null; }
@Override public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (Patient.class.isInstance(value)) { st.setString(index, ((Patient) value).getDocument().toString()); } else { st.setNull(index, Types.VARCHAR); } }
@Override public boolean isAdministrator(Patient patient) { if (patient == null || patient.getDocument() == null) { return false; } return this.rights.hasAccess(Right.ADMIN, getCurrentUser(), patient.getDocument()); }
@Override public Serializable disassemble(Object value) throws HibernateException { if (Patient.class.isInstance(value)) { return ((Patient) value).getDocument().toString(); } return null; }
protected XWikiDocument getPatientDocument(Patient patient) throws Exception { return (XWikiDocument) this.bridge.getDocument(patient.getDocument()); }
private void findNextPatient() { this.nextPatient = null; if (this.patientIterator == null) { return; } while (this.patientIterator.hasNext() && this.nextPatient == null) { Patient potentialNextPatient = this.patientIterator.next(); if (this.access.hasAccess(this.currentUser, Right.VIEW, potentialNextPatient.getDocument())) { this.nextPatient = potentialNextPatient; } } } }
@Override public Owner getOwner(Patient patient) { if (patient == null || patient.getDocument() == null) { return null; } DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, patient.getDocument()); String owner = String.valueOf(this.bridge.getProperty(patient.getDocument(), classReference, "owner")); if (StringUtils.isNotBlank(owner) && !"null".equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, patient.getDocument()), this); } return new DefaultOwner(null, this); }
@Override public Visibility getVisibility(Patient patient) { DocumentReference classReference = this.partialEntityResolver.resolve(Visibility.CLASS_REFERENCE, patient.getDocument()); String visibility = (String) this.bridge.getProperty(patient.getDocument(), classReference, "visibility"); if (StringUtils.isNotBlank(visibility)) { return this.manager.resolveVisibility(visibility); } return null; }
@Override public boolean matches(Object otherEvent) { if (otherEvent instanceof PatientEvent) { PatientEvent otherPatientEvent = (PatientEvent) otherEvent; if (!StringUtils.equals(otherPatientEvent.getEventType(), this.eventType)) { return false; } return this.patient == null || this.patient.getDocument() == null || (otherPatientEvent.getPatient() != null && this.patient.getDocument().equals( otherPatientEvent.getPatient().getDocument())); } return false; }
private Patient checkAccess(Right right, Patient patient, User user) { if (patient != null && this.access.hasAccess(user, right, patient.getDocument())) { return patient; } else if (patient != null) { this.logger.warn("Illegal access requested for patient [{}] by user [{}]", patient.getId(), user); throw new SecurityException("Unauthorized access"); } return null; }
@Override public boolean setVisibility(Patient patient, Visibility visibility) { DocumentReference classReference = this.partialEntityResolver.resolve(Visibility.CLASS_REFERENCE, patient.getDocument()); try { this.bridge.setProperty(patient.getDocument(), classReference, "visibility", visibility != null ? visibility.getName() : ""); return true; } catch (Exception e) { return false; } }
@Override public boolean isMember(Patient patient) { List<String> members = getMembersIds(); if (members == null) { return false; } String patientId = patient.getDocument().getName(); return members.contains(patientId); }
private XWikiDocument getPatientDocument(Patient patient) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); DocumentReference patientDocumentReference = patient.getDocument(); try { return xwiki.getDocument(patientDocumentReference, context); } catch (XWikiException e) { return null; } }
private XWikiDocument getDocument(Patient patient) { try { DocumentReference document = patient.getDocument(); XWikiDocument patientDocument = getDocument(document); return patientDocument; } catch (XWikiException ex) { this.logger.error("Can't get patient document for patient [{}]: []", patient.getId(), ex); return null; } }
private SaveablePatientConsentHolder getPatientConsentHolder(Patient patient) throws Exception { XWikiDocument patientDoc = (XWikiDocument) this.bridge.getDocument(patient.getDocument()); return new SaveablePatientConsentHolder(getXWikiConsentHolder(patientDoc), patientDoc, this.contextProvider.get()); }
@Override public PatientData<String> load(Patient patient) { Map<String, String> versions = new LinkedHashMap<>(); try { XWikiDocument doc = (XWikiDocument) this.documentAccessBridge.getDocument(patient.getDocument()); addOntologyVersions(doc, versions); addPhenoTipsVersion(versions); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen" + " error has occurred during controller loading ", e.getMessage()); } return new DictionaryPatientData<>(getName(), versions); }
private void checkIfPatientCanBeRemovedFromFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocument())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } }
private void checkIfPatientCanBeAddedToFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocument())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } // check for logical problems: patient in another family Family familyForLinkedPatient = this.getFamilyForPatient(patient); if (familyForLinkedPatient != null && !familyForLinkedPatient.getId().equals(family.getId())) { throw new PTPatientAlreadyInAnotherFamilyException(patient.getId(), familyForLinkedPatient.getId()); } }