page but list
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / json / JsonpRedirect.java
1 // $Id$
2 /**
3 * Copyright (C) 2012 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.remote.json;
11
12 import java.net.URL;
13
14 import javax.servlet.http.HttpServletRequest;
15
16 /**
17 * The JsonpRedirect is used to mimic redirects when using json ajax requests.
18 *
19 * @author andreas
20 * @date Jul 20, 2012
21 *
22 */
23 public class JsonpRedirect {
24
25 private String redirectURL = null;
26
27 public JsonpRedirect(String redirectURL) {
28 this.redirectURL = redirectURL;
29 }
30
31 public JsonpRedirect(HttpServletRequest request, String path){
32 this.redirectURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/" + request.getContextPath() + path;
33 }
34
35 public JsonpRedirect(String frontendBaseUrl, String path){
36 if(frontendBaseUrl.endsWith("/")){
37 frontendBaseUrl = frontendBaseUrl.substring(0, frontendBaseUrl.length() -1);
38 }
39 this.redirectURL = frontendBaseUrl + path;
40 }
41
42 public String getRedirectURL() {
43 return redirectURL;
44 }
45
46 public void setRedirectURL(String redirectURL) {
47 this.redirectURL = redirectURL;
48 }
49
50 }