public Set<RoleAssignment> rolesAssignments(DvObject dv) {
    Set<RoleAssignment> ras = new HashSet<>();
    while (!dv.isEffectivelyPermissionRoot()) {
      ras.addAll(
          em.createNamedQuery("RoleAssignment.listByDefinitionPointId", RoleAssignment.class)
              .setParameter("definitionPointId", dv.getId())
              .getResultList());
      dv = dv.getOwner();
    }

    ras.addAll(
        em.createNamedQuery("RoleAssignment.listByDefinitionPointId", RoleAssignment.class)
            .setParameter("definitionPointId", dv.getId())
            .getResultList());

    return ras;
  }
 /**
  * Retrieves the roles assignments for {@code user}, directly on {@code dv}. No traversal on the
  * containment hierarchy is done.
  *
  * @param roas the user whose roles are given
  * @param dvo the object where the roles are defined.
  * @return Set of roles defined for the user in the given dataverse.
  * @see #roleAssignments(edu.harvard.iq.dataverse.DataverseUser,
  *     edu.harvard.iq.dataverse.Dataverse)
  */
 public List<RoleAssignment> directRoleAssignments(RoleAssignee roas, DvObject dvo) {
   if (roas == null) throw new IllegalArgumentException("RoleAssignee cannot be null");
   TypedQuery<RoleAssignment> query =
       em.createNamedQuery(
           "RoleAssignment.listByAssigneeIdentifier_DefinitionPointId", RoleAssignment.class);
   query.setParameter("assigneeIdentifier", roas.getIdentifier());
   query.setParameter("definitionPointId", dvo.getId());
   return query.getResultList();
 }
Пример #3
0
 /** @todo DRY! Perhaps we should merge this with the older updateContentIndexTime method. */
 public DvObject updatePermissionIndexTime(DvObject dvObject) {
   /**
    * @todo to avoid a possible OptimisticLockException, should we merge dvObject before we try to
    *     set this timestamp? See
    *     https://github.com/IQSS/dataverse/commit/6ad0ebb272c8cb46368cb76784b55dbf33eea947
    */
   DvObject dvObjectToModify = findDvObject(dvObject.getId());
   dvObjectToModify.setPermissionIndexTime(new Timestamp(new Date().getTime()));
   DvObject savedDvObject = em.merge(dvObjectToModify);
   return savedDvObject;
 }
 public void revoke(Set<DataverseRole> roles, RoleAssignee assignee, DvObject defPoint) {
   for (DataverseRole role : roles) {
     em.createNamedQuery("RoleAssignment.deleteByAssigneeIdentifier_RoleIdDefinition_PointId")
         .setParameter("assigneeIdentifier", assignee.getIdentifier())
         .setParameter("roleId", role.getId())
         .setParameter("definitionPointId", defPoint.getId())
         .executeUpdate();
     em.refresh(role);
   }
   em.refresh(assignee);
 }
 /**
  * Retrieves the roles assignments for {@code user}, directly on {@code dv}. No traversal on the
  * containment hierarchy is done.
  *
  * @param dvo the object where the roles are defined.
  * @return Set of roles defined for the user in the given dataverse.
  * @see #roleAssignments(edu.harvard.iq.dataverse.DataverseUser,
  *     edu.harvard.iq.dataverse.Dataverse)
  */
 public List<RoleAssignment> directRoleAssignments(DvObject dvo) {
   TypedQuery<RoleAssignment> query =
       em.createNamedQuery("RoleAssignment.listByDefinitionPointId", RoleAssignment.class);
   query.setParameter("definitionPointId", dvo.getId());
   return query.getResultList();
 }