a little bit documentation
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / AgentController.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.cdm.remote.controller;
12
13 import java.io.IOException;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import javax.servlet.http.HttpServletRequest;
18 import javax.servlet.http.HttpServletResponse;
19
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;
25
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;
30
31 /**
32 * The AgentController class is a Spring MVC Controller.
33 * <p>
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.
39 * <p>
40 * Methods mapped at type level, inherited from super classes ({@link BaseController}):
41 * <blockquote>
42 * URI: <b>&#x002F;{datasource-name}&#x002F;agent&#x002F;name&#x002F;{agent-uuid}</b>
43 *
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}
47 * </blockquote>
48 * <blockquote>
49 * URI: <b>&#x002F;{datasource-name}&#x002F;agent&#x002F;name&#x002F;{agent-uuid}&#x002F;annotation</b>
50 *
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}
55 * </blockquote>
56 *
57 * @author a.kohlbecker
58 * @date 24.03.2009
59 */
60 @Controller
61 @RequestMapping(value = {"/agent/{uuid}"})
62 public class AgentController extends BaseController<AgentBase, IAgentService>
63 {
64
65
66 /* (non-Javadoc)
67 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
68 */
69 @Autowired
70 @Override
71 public void setService(IAgentService service) {
72 this.service = service;
73 }
74
75 /**
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.
79 *
80 * The method
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.
84 *
85 * @param uuid
86 * @param request
87 * @param response
88 * @return
89 * @throws IOException
90 */
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());
97 return mv;
98
99 }
100
101 }