Project

General

Profile

« Previous | Next » 

Revision b79b18bd

Added by Andreas Kohlbecker almost 11 years ago

BaseListController: paging as default with full support for all parameters

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/BaseListController.java
12 12
package eu.etaxonomy.cdm.remote.controller;
13 13

  
14 14
import java.io.IOException;
15
import static java.net.HttpURLConnection.*;
16 15
import java.util.List;
17 16
import java.util.UUID;
18 17

  
19 18
import javax.servlet.http.HttpServletRequest;
20 19
import javax.servlet.http.HttpServletResponse;
21 20

  
22
import org.apache.http.protocol.HTTP;
23 21
import org.springframework.web.bind.WebDataBinder;
24 22
import org.springframework.web.bind.annotation.InitBinder;
25 23
import org.springframework.web.bind.annotation.RequestMapping;
......
67 65
     * @return
68 66
     * @throws IOException
69 67
     */
70
    @RequestMapping(method = RequestMethod.GET, params = "pageNumber")
68
    @RequestMapping(method = RequestMethod.GET)
71 69
    public Pager<T> doPage(
72
            @RequestParam(value = "pageNumber") Integer pageIndex,
70
            @RequestParam(value = "pageNumber", required = false) Integer pageIndex,
73 71
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
74
            @RequestParam(value = "class", required = false) Class<T> type,
72
            @RequestParam(value = "class", required = false) Class type,
75 73
            HttpServletRequest request,
76 74
            HttpServletResponse response) throws IOException
77 75
            {
78 76

  
79
        logger.info("doGet() " + request.getServletPath());
77
        logger.info("doPage() " + requestPathAndQuery(request));
80 78
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageIndex);
81 79
        pagerParameters.normalizeAndValidate(response);
82 80

  
83 81
        return service.page(type, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null, DEFAULT_INIT_STRATEGY);
84 82
    }
85 83

  
86
    /**
87
     * Parameter less method to be used as default when request without parameter are made. Otherwise
88
     * the nameless methods {@link #doPage(Integer, Integer, Class)} and {@link #doList(Integer, Integer, Class)}
89
     * are ambigous.
90
     * @return
91
     * @throws IOException
92
     */
93
    @RequestMapping(method = RequestMethod.GET)
94
    public Pager<T> doPage(HttpServletRequest request, HttpServletResponse response) throws IOException{
95
        return doPage(null, null, null, request, response);
96
    }
84
//    /**
85
//     * Parameter less method to be used as default when request without parameter are made. Otherwise
86
//     * the nameless methods {@link #doPage(Integer, Integer, Class)} and {@link #doList(Integer, Integer, Class)}
87
//     * are ambigous.
88
//     * @return
89
//     * @throws IOException
90
//     */
91
//    @RequestMapping(method = RequestMethod.GET)
92
//    public Pager<T> doPage(HttpServletRequest request, HttpServletResponse response) throws IOException{
93
//        return doPage(null, null, null, request, response);
94
//    }
97 95

  
98 96
    /**
99 97
     * @param start
......
114 112
            @RequestParam(value = "class", required = false) Class<T> type,
115 113
            HttpServletRequest request,
116 114
            HttpServletResponse response) {
117
        
115

  
118 116
        if (request != null)
119 117
        {
120
            logger.info("doGet() " + request.getServletPath());
118
            logger.info("doList() " + requestPathAndQuery(request));
121 119
        }
122 120

  
123 121
        //if(start == null){ start = 0;}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/CdmTypePropertyEditor.java
15 15
import org.apache.log4j.Logger;
16 16
import org.springframework.stereotype.Component;
17 17

  
18
import eu.etaxonomy.cdm.model.location.TdwgArea;
19

  
20 18
/**
21 19
 * @author a.kohlbecker
22 20
 * @date 30.06.2009
23
 * TODO only TDWG areas supported for now
24 21
 */
25 22
@Component
26 23
public class CdmTypePropertyEditor extends PropertyEditorSupport  {
27 24

  
28 25
    public static final Logger logger = Logger.getLogger(CdmTypePropertyEditor.class);
29 26

  
27
    @Override
30 28
    public void setAsText(String text) {
31 29

  
32
            Class clazz = null;
30
            Class<?> clazz = null;
33 31
            try {
34 32
                clazz = Class.forName(text);
35 33
            } catch (ClassNotFoundException e) { /* IGNORE */ }

Also available in: Unified diff