Class WikiUserPermissionRest

java.lang.Object
fr.paris.lutece.plugins.wiki.rs.WikiUserPermissionRest

@ApplicationScoped @Path("wiki/permission") public class WikiUserPermissionRest extends Object
REST endpoints backing the user permission panel of the item modification page: searching the user directory and granting a permission to several users at once, without leaving the page. Both endpoints require an authenticated user holding edit rights on the target item, and a valid security token. The item, the permission type and the token travel in the query string, because the platform token service reads the token from the request parameters and JAX-RS has already consumed the request body by then. The payload itself travels in a form encoded body, so a bulk grant is not bound by the length of a URL. A token may only be validated once, so every response carries a fresh one for the next call.
  • Constructor Details

    • WikiUserPermissionRest

      public WikiUserPermissionRest()
  • Method Details

    • attributeValues

      @GET @Path("attribute-values") @Produces("application/json") public jakarta.ws.rs.core.Response attributeValues(@QueryParam("code") String strCode, @QueryParam("attribute") String strAttribute, @QueryParam("q") String strQuery, @Context jakarta.ws.rs.core.UriInfo uriInfo)
      Suggests the values an attribute takes in the user directory, among those still possible given what the other search fields already hold. The directory holds thousands of combinations once every organisation level is mapped, so they stay on the server and only the matching values travel. Read only, so no security token is required: an authenticated user holding edit rights on the target item is enough.
      Parameters:
      strCode - the code of the target item
      strAttribute - the provider attribute
      strQuery - what the user typed so far
      uriInfo - the request URI, holding the values of the other search fields
      Returns:
      the matching values
    • populationCount

      @GET @Path("population-count") @Produces("application/json") public jakarta.ws.rs.core.Response populationCount(@QueryParam("code") String strCode, @QueryParam("attribute") String strAttribute, @QueryParam("value") String strValue)
      Resolves an attribute value to its directory spelling and says how many agents carry it right now, so the caller can show what a population rule would cover before granting it. The count runs on the settled value only, never on half-typed text: a number that does not match what the rule would grant is worse than none. Read only, so no security token is required, for the same reason as the suggestions.
      Parameters:
      strCode - the code of the target item
      strAttribute - the provider attribute
      strValue - the attribute value
      Returns:
      the directory spelling and the matching agent count, the spelling null when unknown
    • search

      @POST @Path("search") @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public jakarta.ws.rs.core.Response search(jakarta.ws.rs.core.MultivaluedMap<String,String> form)
      Searches the user directory for candidates to grant a permission to.
      Returns:
      the matching users, each flagged when they already hold the permission
    • grant

      @POST @Path("grant") @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public jakarta.ws.rs.core.Response grant(jakarta.ws.rs.core.MultivaluedMap<String,String> form)
      Grants a permission to every user of the request, ignoring those already holding it.
      Returns:
      how many users were granted, and how many were rejected
    • grantAttribute

      @POST @Path("grant-attribute") @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public jakarta.ws.rs.core.Response grantAttribute(jakarta.ws.rs.core.MultivaluedMap<String,String> form)
      Grants a permission to everyone carrying an attribute value, rather than to the users listed on screen. Habilitating a whole direction one name at a time would freeze the day someone joins it.
      Returns:
      the rule applied, or a refusal when the directory holds no such value
    • revokeAttribute

      @POST @Path("revoke-attribute") @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public jakarta.ws.rs.core.Response revokeAttribute(jakarta.ws.rs.core.MultivaluedMap<String,String> form)
      Revokes a permission granted to the holders of an attribute value.
      Returns:
      the outcome