package org.osiam.addons.administration.controller;

import javax.inject.Inject;

import org.osiam.addons.administration.service.UserService;
import org.osiam.resources.scim.SCIMSearchResult;
import org.osiam.resources.scim.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * This controller is responsible for handling user list. 
 * This is the main page of the "userview".
 */
@Controller
@RequestMapping(UserViewController.CONTROLLER_PATH)
public class UserViewController {

    public static final String CONTROLLER_PATH = AdminController.CONTROLLER_PATH + "/user/list";
    
    /*
     * List of request parameters.
     */
    
    public static final String RP_QUERY = "query";
    public static final String RP_LIMIT = "limit";
    public static final String RP_OFFSET = "offset";
    public static final String RP_ORDER_BY = "orderBy";
    public static final String RP_ASCENDING = "asc";
    
    
    /*
     * List of model names.
     */
    public static final String MN_USER_LIST = "userlist";
    
    
    @Inject
    private UserService service;
    
    @RequestMapping
    public ModelAndView handleList(
            @RequestParam(value = RP_QUERY, required = false) 
            String query,
            @RequestParam(value = RP_LIMIT, required = false) 
            Integer limit,
            @RequestParam(value = RP_OFFSET, required = false) 
            Long offset,
            @RequestParam(value = RP_ORDER_BY, required = false) 
            String orderBy,
            @RequestParam(value = RP_ASCENDING, required = false) 
            Boolean ascending) {
        
        ModelAndView mav = new ModelAndView("user/list");

        SCIMSearchResult<User> userList = service.searchUser(query, limit, offset, orderBy, ascending);
        mav.addObject(MN_USER_LIST, userList);
        
        return mav;
    }
}

@@ -767,63 +767,8 @@
    %0A
-    /*%0A     * List of request parameters.%0A     */%0A    %0A
     
@@ -795,17 +795,32 @@
 String R
-P
+EQUEST_PARAMETER
 _QUERY =
@@ -861,17 +861,32 @@
 String R
-P
+EQUEST_PARAMETER
 _LIMIT =
@@ -927,17 +927,32 @@
 String R
-P
+EQUEST_PARAMETER
 _OFFSET 
@@ -995,17 +995,32 @@
 String R
-P
+EQUEST_PARAMETER
 _ORDER_B
@@ -1066,17 +1066,32 @@
 String R
-P
+EQUEST_PARAMETER
 _ASCENDI
@@ -1111,56 +1111,8 @@
    %0A
-    %0A    /*%0A     * List of model names.%0A     */%0A
     
@@ -1139,17 +1139,20 @@
 String M
-N
+ODEL
 _USER_LI
@@ -1173,21 +1173,16 @@
 %22;%0A    %0A
-    %0A
     @Inj
@@ -1314,17 +1314,32 @@
 alue = R
-P
+EQUEST_PARAMETER
 _QUERY, 
@@ -1418,17 +1418,32 @@
 alue = R
-P
+EQUEST_PARAMETER
 _LIMIT, 
@@ -1523,17 +1523,32 @@
 alue = R
-P
+EQUEST_PARAMETER
 _OFFSET,
@@ -1627,17 +1627,32 @@
 alue = R
-P
+EQUEST_PARAMETER
 _ORDER_B
@@ -1736,17 +1736,32 @@
 alue = R
-P
+EQUEST_PARAMETER
 _ASCENDI
@@ -2011,17 +2011,20 @@
 Object(M
-N
+ODEL
 _USER_LI

use full names instead of abbreviations