import java.io.IOException;\r
import java.util.Arrays;\r
import java.util.HashSet;\r
+import java.util.List;\r
import java.util.Set;\r
+import java.util.UUID;\r
\r
import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
import org.apache.log4j.Logger;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.WebDataBinder;\r
+import org.springframework.web.bind.annotation.InitBinder;\r
+import org.springframework.web.bind.annotation.PathVariable;\r
import org.springframework.web.bind.annotation.RequestMapping;\r
import org.springframework.web.bind.annotation.RequestMethod;\r
\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;\r
\r
/**\r
* TODO write controller documentation\r
*\r
*/\r
@Controller\r
-@RequestMapping(value = {"/*/taxon/*","/*/taxon/*/*", "/*/taxon/*/annotation"})\r
+@RequestMapping(value = {"/taxon/*", "/taxon/{uuid}"})\r
public class TaxonController extends AnnotatableController<TaxonBase, ITaxonService>\r
{\r
public static final Logger logger = Logger.getLogger(TaxonController.class);\r
\r
+ protected static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "taxonNodes"\r
+ });\r
+ \r
public TaxonController(){\r
super();\r
- setUuidParameterPattern("^/(?:[^/]+)/taxon/([^/?#&\\.]+).*");\r
+ setUuidParameterPattern("^/taxon/([^/?#&\\.]+).*");\r
setInitializationStrategy(Arrays.asList(new String[]{"$","name.nomenclaturalReference"}));\r
}\r
\r
* {@link #DEFAULT_INIT_STRATEGY}\r
* @throws IOException\r
*/\r
- @RequestMapping(value = "/*/taxon/*/accepted", method = RequestMethod.GET)\r
- public Set<TaxonBase> getAccepted(HttpServletRequest request, HttpServletResponse response) throws IOException {\r
+ @RequestMapping(value = "{uuid}/accepted", method = RequestMethod.GET)\r
+ public Set<TaxonBase> doGetAccepted(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response) throws IOException {\r
logger.info("getAccepted() " + request.getServletPath());\r
- TaxonBase tb = doGet(request, response);\r
+ TaxonBase tb = service.load(uuid);\r
HashSet<TaxonBase> resultset = new HashSet<TaxonBase>();\r
if(tb instanceof Taxon){\r
//the taxon already is accepted\r
}\r
return resultset;\r
}\r
+ \r
+ @RequestMapping(value = "{uuid}/taxonNodes", method = RequestMethod.GET)\r
+ public Set<TaxonNode> doGetTaxonNodes(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response) throws IOException {\r
+ TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);\r
+ if(tb instanceof Taxon){\r
+ return ((Taxon)tb).getTaxonNodes();\r
+ } else {\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ return null;\r
+ }\r
+ }\r
\r
\r
- \r
-}\r
+}
\ No newline at end of file