a little bit documentation
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / AgentController.java
index 2855fba576a25e666afa150b0b25f21fa208b0da..0ce84283a115044450f254901dd223c8bb8f5a4b 100644 (file)
@@ -1,39 +1,68 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
-* \r
+*\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
 \r
 package eu.etaxonomy.cdm.remote.controller;\r
 \r
+import java.io.IOException;\r
+import java.util.Map;\r
+import java.util.UUID;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.annotation.PathVariable;\r
 import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.servlet.ModelAndView;\r
 \r
-import eu.etaxonomy.cdm.api.service.AnnotatableServiceBase;\r
 import eu.etaxonomy.cdm.api.service.IAgentService;\r
+import eu.etaxonomy.cdm.api.service.pager.Pager;\r
 import eu.etaxonomy.cdm.model.agent.AgentBase;\r
-import eu.etaxonomy.cdm.persistence.dao.common.IAnnotatableDao;\r
+import eu.etaxonomy.cdm.model.common.Annotation;\r
 \r
 /**\r
+ * The AgentController class is a Spring MVC Controller.\r
+ * <p>\r
+ * The syntax of the mapped service URIs contains the the {datasource-name} path element.\r
+ * The available {datasource-name}s are defined in a configuration file which\r
+ * is loaded by the {@link UpdatableRoutingDataSource}. If the\r
+ * UpdatableRoutingDataSource is not being used in the actual application\r
+ * context any arbitrary {datasource-name} may be used.\r
+ * <p>\r
+ * Methods mapped at type level, inherited from super classes ({@link BaseController}):\r
+ * <blockquote>\r
+ * URI: <b>&#x002F;{datasource-name}&#x002F;agent&#x002F;name&#x002F;{agent-uuid}</b>\r
+ *\r
+ * Get the {@link AgentBase} instance identified by the <code>{agent-uuid}</code>.\r
+ * The returned AgentBase is initialized by\r
+ * the default initialization strategy: {@link #DEFAULT_INIT_STRATEGY}\r
+ * </blockquote>\r
+ * <blockquote>\r
+ * URI: <b>&#x002F;{datasource-name}&#x002F;agent&#x002F;name&#x002F;{agent-uuid}&#x002F;annotation</b>\r
+ *\r
+ * Returns a {@link Pager} on the {@link Annotation}s for the {@link AgentBase} instance identified by the\r
+ * <code>{agent-uuid}</code>.\r
+ * The returned AgentBase instances are initialized by\r
+ * the following strategy: {@link #ANNOTATION_INIT_STRATEGY}\r
+ * </blockquote>\r
+ *\r
  * @author a.kohlbecker\r
  * @date 24.03.2009\r
  */\r
-\r
 @Controller\r
-@RequestMapping(value = {"/*/agent/*","/*/agent/*/annotation"})\r
-public class AgentController extends AnnotatableController<AgentBase, IAgentService>\r
+@RequestMapping(value = {"/agent/{uuid}"})\r
+public class AgentController extends BaseController<AgentBase, IAgentService>\r
 {\r
 \r
-       public AgentController(){\r
-               super();\r
-               setUuidParameterPattern("^/(?:[^/]+)/agent/([^/?#&\\.]+).*");\r
-       }\r
-       \r
+\r
        /* (non-Javadoc)\r
         * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)\r
         */\r
@@ -43,4 +72,30 @@ public class AgentController extends AnnotatableController<AgentBase, IAgentServ
                this.service = service;\r
        }\r
 \r
+       /**\r
+        * This method is only needed for\r
+        * {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase} or sub classes\r
+        * which are also handled by this controller.\r
+        *\r
+        * The method\r
+        * {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getTitleCache() } is\r
+        * annotated with @Transient and thus it is not automatically made available\r
+        * by the BaseController.\r
+        *\r
+        * @param uuid\r
+        * @param request\r
+        * @param response\r
+        * @return\r
+        * @throws IOException\r
+        */\r
+       @RequestMapping(value = {"titleCache"})\r
+       public ModelAndView doGetTitleCache(@PathVariable("uuid") UUID uuid,\r
+                       HttpServletRequest request, HttpServletResponse response) throws IOException {\r
+               ModelAndView mv = new ModelAndView();\r
+               AgentBase agentbase = service.load(uuid);\r
+               mv.addObject(agentbase.getTitleCache());\r
+               return mv;\r
+\r
+       }\r
+\r
 }\r