Class ReplacementResource

    • Constructor Detail

      • ReplacementResource

        public ReplacementResource()
    • Method Detail

      • getAllReplacements

        @GET
        @Produces("application/json")
        public <T extends Replacement<T>> Collection<ReplacementEntity> getAllReplacements​(@QueryParam("incumbent")
                                                                                           String incumbentId,
                                                                                           @QueryParam("substitute")
                                                                                           String substituteId)
        Gets all the replacements that were created in the requested workflow. The replacements can be filtered by one incumbent or by one substitute taking part in the replacements to returns. If both are specified, then only the replacements in which both of them take part are returned.

        For security reason, when one incumbent or one substitute is specified, only the replacements in which the requester is concerned (either as incumbent or as substitute) are returned. Unless the requester is a supervisor in the requested workflow, if he is neither an incumbent nor a substitute in any replacements, then nothing is returned.

        Only the supervisor of the given requested workflow have the rights to asks for all of the replacements in the workflow or to request any replacements in which a given user takes part (either as an incumbent or as a substitute).

        Returns:
        a list of all replacements that are defined in the requested workflow.
      • getReplacement

        @GET
        @Produces("application/json")
        @Path("{id}")
        public ReplacementEntity getReplacement​(@PathParam("id")
                                                String replacementId)
        Gets the replacement with the specified unique identifier in the requested workflow. If no such replacement exists in the given workflow, then an HTTP error Response.Status.NOT_FOUND is sent back.

        For security reason, unless the requester is a supervisor in the requested workflow, only the users concerned by the asked replacement (either as incumbent or as substitute) can ask for the targeted replacement.

        Parameters:
        replacementId - the unique identifier of a replacement in the requested workflow.
        Returns:
        ReplacementEntity representation of the replacement.
      • createNewReplacement

        @POST
        @Consumes("application/json")
        @Produces("application/json")
        public javax.ws.rs.core.Response createNewReplacement​(ReplacementEntity entity)
        Creates a new replacement in the given requested workflow from the specified entity embodied in the incoming request. Be caution: the workflow identifier in the entity must match the requested workflow instance otherwise an HTTP error Response.Status.BAD_REQUEST is sent back.

        For security reason, unless the requester plays the role of supervisor in the requested workflow, he must be the incumbent of the tasks he asks for replacement. Otherwise an HTTP error Response.Status.FORBIDDEN is sent back. Only the supervisor can create a replacement between two others users in a workflow instance or for himself.

        Parameters:
        entity - the entity providing the information about the replacement to create.
        Returns:
        the response with the status Response.Status.CREATED and with the entity representing the newly created replacement.
      • updateReplacement

        @PUT
        @Path("{id}")
        @Consumes("application/json")
        @Produces("application/json")
        public ReplacementEntity updateReplacement​(@PathParam("id")
                                                   String id,
                                                   ReplacementEntity entity)
        Updates the replacement identified by the specified unique identifier with the given replacement entity. If no such replacement exists in the requested workflow, then an HTTP error Response.Status.NOT_FOUND is sent back.

        Only the period over which the replacement will occur and the substitute can be updated. If any other properties (the incumbent) are modified, an HTTP error Response.Status.BAD_REQUEST is sent back.

        For security reason, unless the requester plays the role of supervisor in the requested workflow, only the incumbent of the tasks concerned by the replacement can update a replacement. Otherwise, an HTTP error Response.Status.FORBIDDEN is sent back.

        Parameters:
        id - the unique identifier of the a replacement in the requested workflow.
        entity - the new state of the replacement.
        Returns:
        the updated replacement.
      • deleteReplacement

        @DELETE
        @Path("{id}")
        public void deleteReplacement​(@PathParam("id")
                                      String replacementId)
        Deletes the replacement identified by the specified unique identifier. If no such replacement exists in the requested workflow, then an HTTP error Response.Status.NOT_FOUND is sent back.

        For security reason, unless the requester plays the role of supervisor in the requested workflow, only the incumbent of the tasks concerned by the replacement or the substitute can delete a replacement. Otherwise, an HTTP error Response.Status.FORBIDDEN is sent back.

        Parameters:
        replacementId - the unique identifier of a replacement in the requested workflow.
      • getComponentId

        public String getComponentId()
        Description copied from interface: SilverpeasWebResource
        Gets the identifier of the component instance to which the requested resource belongs to.
        Returns:
        the identifier of the Silverpeas component instance.