3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.cdm
.remote
.controller
;
13 import java
.io
.IOException
;
15 import java
.util
.UUID
;
17 import javax
.servlet
.http
.HttpServletRequest
;
18 import javax
.servlet
.http
.HttpServletResponse
;
20 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
21 import org
.springframework
.stereotype
.Controller
;
22 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
23 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
24 import org
.springframework
.web
.servlet
.ModelAndView
;
26 import eu
.etaxonomy
.cdm
.api
.service
.IAgentService
;
27 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
29 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
32 * The AgentController class is a Spring MVC Controller.
34 * The syntax of the mapped service URIs contains the the {datasource-name} path element.
35 * The available {datasource-name}s are defined in a configuration file which
36 * is loaded by the {@link UpdatableRoutingDataSource}. If the
37 * UpdatableRoutingDataSource is not being used in the actual application
38 * context any arbitrary {datasource-name} may be used.
40 * Methods mapped at type level, inherited from super classes ({@link BaseController}):
42 * URI: <b>/{datasource-name}/agent/name/{agent-uuid}</b>
44 * Get the {@link AgentBase} instance identified by the <code>{agent-uuid}</code>.
45 * The returned AgentBase is initialized by
46 * the default initialization strategy: {@link #DEFAULT_INIT_STRATEGY}
49 * URI: <b>/{datasource-name}/agent/name/{agent-uuid}/annotation</b>
51 * Returns a {@link Pager} on the {@link Annotation}s for the {@link AgentBase} instance identified by the
52 * <code>{agent-uuid}</code>.
53 * The returned AgentBase instances are initialized by
54 * the following strategy: {@link #ANNOTATION_INIT_STRATEGY}
57 * @author a.kohlbecker
61 @RequestMapping(value
= {"/agent/{uuid}"})
62 public class AgentController
extends BaseController
<AgentBase
, IAgentService
>
67 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
71 public void setService(IAgentService service
) {
72 this.service
= service
;
76 * This method is only needed for
77 * {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase} or sub classes
78 * which are also handled by this controller.
81 * {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getTitleCache() } is
82 * annotated with @Transient and thus it is not automatically made available
83 * by the BaseController.
91 @RequestMapping(value
= {"titleCache"})
92 public ModelAndView
doGetTitleCache(@PathVariable("uuid") UUID uuid
,
93 HttpServletRequest request
, HttpServletResponse response
) throws IOException
{
94 ModelAndView mv
= new ModelAndView();
95 AgentBase
<?
> agentbase
= service
.load(uuid
);
96 mv
.addObject(agentbase
.getTitleCache());