001    package com.khubla.pragmatach.framework.controller.impl.redirect;
002    
003    import java.util.HashMap;
004    import java.util.Map;
005    
006    import javax.servlet.http.HttpServletResponse;
007    
008    import com.khubla.pragmatach.framework.api.PragmatachException;
009    import com.khubla.pragmatach.framework.controller.impl.AbstractResponse;
010    
011    /**
012     * @author tome
013     */
014    public class RedirectResponse extends AbstractResponse {
015       /**
016        * uri
017        */
018       private final String uri;
019    
020       /**
021        * ctor
022        */
023       public RedirectResponse(Map<String, String> cacheHeaders, String uri) {
024          super(cacheHeaders);
025          this.uri = uri;
026       }
027    
028       @Override
029       public String getContentType() throws PragmatachException {
030          return null;
031       }
032    
033       @Override
034       public Map<String, String> getHeaders() throws PragmatachException {
035          Map<String, String> map = getCacheHeaders();
036          if (null == map) {
037             map = new HashMap<String, String>();
038          }
039          map.put("Location", uri);
040          return map;
041       }
042    
043       @Override
044       public int getHTTPCode() {
045          return HttpServletResponse.SC_MOVED_TEMPORARILY;
046       }
047    
048       @Override
049       public void render(HttpServletResponse httpServletResponse) throws PragmatachException {
050          try {
051          } catch (final Exception e) {
052             throw new PragmatachException("Exception in render", e);
053          }
054       }
055    }