/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forResource(getClass(), this.uriInfo) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forResource(getClass(), this.uriInfo) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
@Override public org.phenotips.vocabularies.rest.model.Vocabulary getVocabulary(String vocabularyId) { Vocabulary vocabulary = this.vm.getVocabulary(vocabularyId); if (vocabulary == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } org.phenotips.vocabularies.rest.model.Vocabulary rep = this.objectFactory.createVocabularyRepresentation(vocabulary); rep.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW).build()); return rep; }
@Override public CollaboratorsRepresentation getCollaborators(String patientId) { this.logger.debug("Retrieving collaborators of patient record [{}] via REST", patientId); // Besides getting the patient, checks that the user has view access PatientAccessContext patientAccessContext = this.secureContextFactory.getReadContext(patientId); CollaboratorsRepresentation result = this.factory.createCollaboratorsRepresentation(patientAccessContext.getPatient(), this.uriInfo); result.withLinks(this.autolinker.get().forResource(this.getClass(), this.uriInfo) .withGrantedRight(patientAccessContext.getPatientAccess().getAccessLevel().getGrantedRight()) .build()); return result; }
@Override public OwnerRepresentation getOwner(String entityId, String entityType) { this.logger.debug("Retrieving entity record's owner [{}] via REST", entityId); // besides getting the entity, checks that the user has view access EntityAccessContext entityAccessContext = this.secureContextFactory.getReadContext(entityId, entityType); OwnerRepresentation result = this.factory.createOwnerRepresentation(entityAccessContext.getEntity()); // adding links relative to this context result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo) .withGrantedRight(entityAccessContext.getEntityAccess().getAccessLevel().getGrantedRight()) .build()); return result; }
@Override public VisibilityRepresentation getVisibility(String patientId) { this.logger.debug("Retrieving patient record's visibility [{}] via REST", patientId); // besides getting the patient, checks that the user has view access PatientAccessContext patientAccessContext = this.secureContextFactory.getReadContext(patientId); VisibilityRepresentation result = this.factory.createVisibilityRepresentation(patientAccessContext.getPatient()); AccessLevel accessLevel = patientAccessContext.getPatientAccess().getAccessLevel(); result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo) .withGrantedRight(accessLevel.getGrantedRight()) .build()); return result; }
@Override public OwnerRepresentation getOwner(String patientId) { this.logger.debug("Retrieving patient record's owner [{}] via REST", patientId); // besides getting the patient, checks that the user has view access PatientAccessContext patientAccessContext = this.secureContextFactory.getReadContext(patientId); OwnerRepresentation result = this.factory.createOwnerRepresentation(patientAccessContext.getPatient()); // adding links relative to this context result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo) .withGrantedRight(patientAccessContext.getPatientAccess().getAccessLevel().getGrantedRight()) .build()); return result; }
@Override public PrincipalsRepresentation getPrincipals(String entityType, String entityId) { this.logger.debug("Retrieving principals with access to entity record [{}] via REST", entityId); // Besides getting the entity, checks that the user has view access EntityAccessContext patientAccessContext = this.secureContextFactory.getReadContext(entityId, entityType); PrincipalsRepresentation result = this.factory.createPrincipalsRepresentation(patientAccessContext.getEntity(), entityType, this.uriInfo); result.withLinks(this.autolinker.get().forResource(this.getClass(), this.uriInfo) .withGrantedRight(patientAccessContext.getEntityAccess().getAccessLevel().getGrantedRight()) .build()); return result; } }
@Override public CollaboratorsRepresentation getCollaborators(String entityId, String entityType) { this.logger.debug("Retrieving collaborators of entity record [{}] via REST", entityId); // Besides getting the entity, checks that the user has view access EntityAccessContext entityAccessContext = this.secureContextFactory.getReadContext(entityId, entityType); CollaboratorsRepresentation result = this.factory.createCollaboratorsRepresentation(entityAccessContext.getEntity(), this.uriInfo); result.withLinks(this.autolinker.get().forResource(this.getClass(), this.uriInfo) .withGrantedRight(entityAccessContext.getEntityAccess().getAccessLevel().getGrantedRight()) .build()); return result; }
@Override public CollaboratorRepresentation getCollaborator(String patientId, String collaboratorId) { this.logger.debug("Retrieving collaborator with id [{}] of patient record [{}] via REST", collaboratorId, patientId); // Besides getting the patient, checks that the user has view access PatientAccessContext patientAccessContext = this.secureContextFactory.getReadContext(patientId); CollaboratorRepresentation result; try { result = this.createCollaboratorRepresentation(patientAccessContext.getPatient(), collaboratorId.trim(), patientAccessContext.getPatientAccess()); } catch (WebApplicationException ex) { this.logger.debug("Collaborator of patient record [{}] with id [{}] was not found", patientId, collaboratorId); throw ex; } // adding links relative to this context result.withLinks(this.autolinker.get().forResource(this.getClass(), this.uriInfo) .withGrantedRight(patientAccessContext.getPatientAccess().getAccessLevel().getGrantedRight()) .build()); return result; }
@Override public VisibilityRepresentation getVisibility(String entityId, String entityType) { this.logger.debug("Retrieving entity record's visibility [{}] via REST", entityId); // besides getting the entity, checks that the user has view access EntityAccessContext entityAccessContext = this.secureContextFactory.getReadContext(entityId, entityType); VisibilityRepresentation result = this.factory.createVisibilityRepresentation(entityAccessContext.getEntity()); AccessLevel accessLevel = entityAccessContext.getEntityAccess().getAccessLevel(); result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo) .withGrantedRight(accessLevel.getGrantedRight()) .build()); return result; }
@Override public Vocabularies getAllVocabularies() { Vocabularies result = new Vocabularies(); List<String> vocabularyIDs = this.vm.getAvailableVocabularies(); List<org.phenotips.vocabularies.rest.model.Vocabulary> availableVocabs = new ArrayList<>(); for (String vocabularyID : vocabularyIDs) { Vocabulary vocab = this.vm.getVocabulary(vocabularyID); org.phenotips.vocabularies.rest.model.Vocabulary rep = this.objectFactory.createVocabularyRepresentation(vocab); rep.withLinks(this.autolinker.get().forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withExtraParameters("vocabulary-id", vocabularyID) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW) .build()); availableVocabs.add(rep); } result.withVocabularies(availableVocabs); result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return result; }
@Override public CollaboratorsRepresentation createCollaboratorsRepresentation(Patient patient, UriInfo uriInfo) { PatientAccess patientAccess = this.manager.getPatientAccess(patient); Collection<Collaborator> collaborators = patientAccess.getCollaborators(); CollaboratorsRepresentation result = new CollaboratorsRepresentation(); for (Collaborator collaborator : collaborators) { CollaboratorRepresentation collaboratorObject = this.createCollaboratorRepresentation(patientAccess, collaborator); collaboratorObject.withLinks(this.autolinker.get().forSecondaryResource(CollaboratorResource.class, uriInfo) .withExtraParameters("collaborator-id", this.entitySerializer.serialize(collaborator.getUser())) .withGrantedRight(patientAccess.getAccessLevel().getGrantedRight()) .build()); result.withCollaborators(collaboratorObject); } return result; }
@Override public CollaboratorsRepresentation createCollaboratorsRepresentation(PrimaryEntity entity, UriInfo uriInfo) { EntityAccess entityAccess = this.manager.getEntityAccess(entity); Collection<Collaborator> collaborators = entityAccess.getCollaborators(); CollaboratorsRepresentation result = new CollaboratorsRepresentation(); for (Collaborator collaborator : collaborators) { CollaboratorRepresentation collaboratorObject = this.createCollaboratorRepresentation(collaborator); collaboratorObject.withLinks(this.autolinker.get() .forSecondaryResource(CollaboratorResource.class, uriInfo) .withExtraParameters("collaborator-id", this.entitySerializer.serialize(collaborator.getUser())) .withGrantedRight(entityAccess.getAccessLevel().getGrantedRight()) .build()); result.withCollaborators(collaboratorObject); } return result; }