View Javadoc

1   /**
2    * @author SrinivasJasti
3    * 
4    */
5   package org.srinivas.siteworks.fecamelworks.webconfig;
6   
7   import org.apache.camel.ProducerTemplate;
8   import org.slf4j.Logger;
9   import org.slf4j.LoggerFactory;
10  import org.springframework.stereotype.Controller;
11  import org.springframework.ui.Model;
12  import org.springframework.web.bind.annotation.RequestMapping;
13  import org.springframework.web.bind.annotation.RequestMethod;
14  
15  /**
16   * The Class FECamelWorksController.
17   */
18  @Controller
19  public class FECamelWorksController {
20  	public static final String HTML_BREAK_TAG = "<br/>";
21  	private static final String NEWLINE_REGEX = "\\r\\n|\\n";
22  	private static final Logger log = LoggerFactory.getLogger(FECamelWorksController.class);
23  
24  	/**
25  	 * Camelworks page.
26  	 *
27  	 * @param model the model
28  	 * @return the string
29  	 * @throws Exception the exception
30  	 */
31  	@RequestMapping(value = "/camelworks.mvc", method = RequestMethod.GET)
32  	public String camelWorksPage(Model model) throws Exception {
33  		log.info("CamelWorksController");
34  		ProducerTemplate template = org.srinivas.siteworks.fecamelworks.webconfig.FECamelWorksCamelListener.getContext().createProducerTemplate();
35  		String result = template.requestBody("direct:process", "getAll&&Update:789{description:fountains colour}", String.class);
36  		result = result.replaceAll(NEWLINE_REGEX, HTML_BREAK_TAG);
37  		log.info("camelWorksPage Result is" + result);
38  		model.addAttribute("message", result);
39  		return "camelworks";
40  	}
41  }