001    package com.khubla.pragmatach.plugin.yaml;
002    
003    import java.util.Map;
004    
005    import com.khubla.pragmatach.framework.api.PragmatachException;
006    import com.khubla.pragmatach.framework.api.Response;
007    import com.khubla.pragmatach.framework.controller.BeanBoundController;
008    import com.khubla.pragmatach.framework.controller.ControllerBeanUtil;
009    import com.khubla.pragmatach.framework.controller.impl.AbstractController;
010    
011    /**
012     * @author tome
013     */
014    public class YAMLController extends AbstractController implements BeanBoundController {
015       /**
016        * ctor
017        */
018       public YAMLController() {
019       }
020    
021       private Map<String, String> getPostFieldValues() throws PragmatachException {
022          try {
023             return PragmatachYAML.parseYAML(getRequest().getInputStream());
024          } catch (final Exception e) {
025             throw new PragmatachException("Exception in getPostFieldValues", e);
026          }
027       }
028    
029       /**
030        * render
031        */
032       public Response render() throws PragmatachException {
033          try {
034             return new YAMLResponse(getCacheHeaders(), this);
035          } catch (final Exception e) {
036             throw new PragmatachException("Exception in render", e);
037          }
038       }
039    
040       @Override
041       public void populateController() throws PragmatachException {
042          ControllerBeanUtil.populateController(this, this.getPostFieldValues());
043       }
044    }