3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.controller
;
12 import java
.util
.Arrays
;
13 import java
.util
.List
;
15 import javax
.servlet
.http
.HttpServletRequest
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IService
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.remote
.controller
.util
.PagerParameters
;
24 * @author a.kohlbecker
30 public abstract class AbstractController
<T
extends CdmBase
, SERVICE
extends IService
<T
>> {
32 private static final List
<String
> DEFAULT_INIT_STRATEGY
= Arrays
.asList(new String
[]{
36 public static final Logger logger
= Logger
.getLogger(AbstractController
.class);
38 protected SERVICE service
;
40 public abstract void setService(SERVICE service
);
42 protected static final Integer DEFAULT_PAGE_SIZE
= PagerParameters
.DEFAULT_PAGESIZE
;
45 * Default thread priority for long term processes which are running in
46 * separate threads. These batch processes are usually monitored with the
47 * {@link ProgressMonitorController}. This value must be lower than
48 * {@link Thread#NORM_PRIORITY}
50 public static final int DEFAULT_BATCH_THREAD_PRIORITY
= 3;
52 protected List
<String
> initializationStrategy
= DEFAULT_INIT_STRATEGY
;
55 * Set the default initialization strategy for this controller.
57 * @param initializationStrategy
59 public final void setInitializationStrategy(List
<String
> initializationStrategy
) {
60 this.initializationStrategy
= initializationStrategy
;
64 * Provides access to the default initialization strategy.
65 * The default initialization strategy is predefined for all controllers in
66 * {@link #DEFAULT_INIT_STRATEGY} but can be altered by
67 * concrete implementations by utilizing {@link #setInitializationStrategy(List)}
68 * in the constructor of the specific controller.
70 * @return the default initialization strategy
72 public final List
<String
> getInitializationStrategy() {
73 return this.initializationStrategy
;
77 * Returns the HTTP request path and query parameters as string
80 * @return request path and query parameters as string.
82 protected String
requestPathAndQuery(HttpServletRequest request
) {
86 StringBuilder b
= new StringBuilder();
87 b
.append(request
.getMethod()).append(": ");
88 b
.append(request
.getRequestURI());
89 String query
= request
.getQueryString();
91 b
.append("?").append(query
);