package org.gluu.oxtrust.ws.rs.scim2;

import org.gluu.oxtrust.model.scim2.user.UserResource;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import static org.gluu.oxtrust.model.scim2.Constants.*;

/**
 * Created by jgomer on 2017-09-01.
 *
 * Shared (rest-easy) interface of the SCIM service.
 * Besides SCIM server code, this class is also used by SCIM java client, edit carefully.
 * The class org.gluu.oxtrust.service.scim2.interceptor.UserServiceDecorator uses this interface as well
 */
public interface UserService {

    @Path("/scim/v2/Users")
    @POST
    @Consumes({MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON})
    @Produces({MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT})
    @HeaderParam("Accept") @DefaultValue(MEDIA_TYPE_SCIM_JSON)
    Response createUser(
            UserResource user,
            @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList,
            @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList,
            @HeaderParam("Authorization") String authorization) throws Exception;

    @Path("/scim/v2/Users/{id}")
    @GET
    @Produces({MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT})
    @HeaderParam("Accept") @DefaultValue(MEDIA_TYPE_SCIM_JSON)
    Response getUserById(
            @PathParam("id") String id,
            @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList,
            @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList,
            @HeaderParam("Authorization") String authorization) throws Exception;

    @Path("/scim/v2/Users/{id}")
    @PUT
    @Consumes({MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON})
    @Produces({MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT})
    @HeaderParam("Accept") @DefaultValue(MEDIA_TYPE_SCIM_JSON)
    Response updateUser(
            UserResource user,
            @PathParam("id") String id,
            @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList,
            @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList,
            @HeaderParam("Authorization") String authorization) throws Exception;

    @Path("/scim/v2/Users/{id}")
    @DELETE
    @Produces({MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT})
    @HeaderParam("Accept") @DefaultValue(MEDIA_TYPE_SCIM_JSON)
    Response deleteUser(
            @PathParam("id") String id,
            @HeaderParam("Authorization") String authorization) throws Exception;

    /*
    Response patchUser(String authorization, String id, ScimPatchUser user,final String attributesArray) throws Exception;
    Response getUserById(String authorization, String id, final String attributesArray) throws Exception;
    Response searchUsers(String authorization, final String filterString, final int startIndex, Integer count, final String sortBy, final String sortOrder, final String attributesArray) throws Exception;
    */
}
@@ -32,16 +32,67 @@
 scim2;%0A%0A
+import org.gluu.oxtrust.model.scim2.SearchRequest;%0A
 import o
@@ -1159,33 +1159,16 @@
 ization)
- throws Exception
 ;%0A%0A    @
@@ -1654,33 +1654,16 @@
 ization)
- throws Exception
 ;%0A%0A    @
@@ -2245,33 +2245,16 @@
 ization)
- throws Exception
 ;%0A%0A    @
@@ -2602,34 +2602,224 @@
 ion)
- throws Exception;%0A%0A    /*
+;%0A%0A    @Path(%22/scim/v2/Users%22)%0A    @GET%0A    @Produces(%7BMEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT%7D)%0A    @HeaderParam(%22Accept%22) @DefaultValue(MEDIA_TYPE_SCIM_JSON)
 %0A   
@@ -2832,151 +2832,504 @@
 nse 
-pat
+sear
 chUser
-(String authorization, String id, ScimPatchUser user,final String attributesArray) throws Exception;%0A    Response getUserById(String a
+s(%0A            @QueryParam(QUERY_PARAM_FILTER) String filter,%0A            @QueryParam(QUERY_PARAM_SORT_BY) String sortBy,%0A            @QueryParam(QUERY_PARAM_SORT_ORDER) String sortOrder,%0A            @QueryParam(QUERY_PARAM_START_INDEX) Integer startIndex,%0A            @QueryParam(QUERY_PARAM_COUNT) Integer count,%0A            @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList,%0A            @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList,%0A            @HeaderParam(%22A
 utho
@@ -3340,17 +3340,18 @@
 tion
-,
+%22)
  String 
 id, 
@@ -3350,93 +3350,412 @@
 ing 
-id, final String attributesArray) throws Exception;%0A    Response searchUsers(String a
+authorization);%0A%0A    @Path(%22/scim/v2/Users/.search%22)%0A    @POST%0A    @Consumes(%7BMEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON%7D)%0A    @Produces(%7BMEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT%7D)%0A    @HeaderParam(%22Accept%22) @DefaultValue(MEDIA_TYPE_SCIM_JSON)%0A    Response searchUsersPost(%0A            SearchRequest searchRequest,%0A            @HeaderParam(%22A
 utho
@@ -3762,31 +3762,26 @@
 rization
-, final
+%22)
  String 
 filterSt
@@ -3776,104 +3776,107 @@
 ing 
-filterString, final int startIndex, Integer count, final String sortBy, final String sortOrd
+authorization);%0A%0A    /*%0A    Response patchUser(String authorization, String id, ScimPatchUser us
 er,
- 
 fina
@@ -3904,25 +3904,8 @@
 ray)
- throws Exception
 ;%0A  

Add operations for search