1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.remote.controller;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.List;
|
14
|
|
15
|
import javax.servlet.http.HttpServletRequest;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.service.IService;
|
20
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
21
|
|
22
|
/**
|
23
|
* @author a.kohlbecker
|
24
|
* @date 23.06.2009
|
25
|
*
|
26
|
* @param <T>
|
27
|
* @param <SERVICE>
|
28
|
*/
|
29
|
public abstract class AbstractController<T extends CdmBase, SERVICE extends IService<T>> {
|
30
|
|
31
|
protected static final List<String> DEFAULT_INIT_STRATEGY = Arrays.asList(new String []{
|
32
|
"$"
|
33
|
});
|
34
|
|
35
|
public static final Logger logger = Logger.getLogger(AbstractController.class);
|
36
|
|
37
|
protected SERVICE service;
|
38
|
|
39
|
public abstract void setService(SERVICE service);
|
40
|
|
41
|
protected static final Integer DEFAULT_PAGE_SIZE = 30;
|
42
|
|
43
|
/**
|
44
|
* Default thread priority for long term processes which are running in
|
45
|
* separate threads. These batch processes are usually monitored with the
|
46
|
* {@link ProgressMonitorController}. This value must be lower than
|
47
|
* {@link Thread#NORM_PRIORITY}
|
48
|
*/
|
49
|
public static final int DEFAULT_BATCH_THREAD_PRIORITY = 3;
|
50
|
|
51
|
protected List<String> initializationStrategy = DEFAULT_INIT_STRATEGY;
|
52
|
|
53
|
/**
|
54
|
* Set the default initialization strategy for this controller.
|
55
|
*
|
56
|
* @param initializationStrategy
|
57
|
*/
|
58
|
public void setInitializationStrategy(List<String> initializationStrategy) {
|
59
|
this.initializationStrategy = initializationStrategy;
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* Returns the HTTP request path and query parameters as string
|
64
|
*
|
65
|
* @param request
|
66
|
* @return request path and query parameters as string.
|
67
|
*/
|
68
|
protected String requestPathAndQuery(HttpServletRequest request) {
|
69
|
if(request == null) {
|
70
|
return "";
|
71
|
}
|
72
|
StringBuilder b = new StringBuilder();
|
73
|
b.append(request.getRequestURI());
|
74
|
String query = request.getQueryString();
|
75
|
if(query != null) {
|
76
|
b.append("?").append(query);
|
77
|
}
|
78
|
return b.toString();
|
79
|
}
|
80
|
|
81
|
}
|