Project

General

Profile

Download (1.28 KB) Statistics
| Branch: | Tag: | Revision:
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 javax.servlet.http.HttpServletRequest;
13

    
14
/**
15
 * The JsonpRedirect is used to mimic redirects when using json ajax requests.
16
 *
17
 * @author andreas
18
 * @date Jul 20, 2012
19
 *
20
 */
21
public class JsonpRedirect {
22

    
23
    private String redirectURL = null;
24

    
25
    public JsonpRedirect(String redirectURL) {
26
        this.redirectURL = redirectURL;
27
    }
28

    
29
    public JsonpRedirect(HttpServletRequest request, String path){
30
        this.redirectURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + path;
31
    }
32

    
33
    public JsonpRedirect(String frontendBaseUrl, String path){
34
        if(frontendBaseUrl.endsWith("/")){
35
            frontendBaseUrl = frontendBaseUrl.substring(0, frontendBaseUrl.length() -1);
36
        }
37
        this.redirectURL = frontendBaseUrl + path;
38
    }
39

    
40
    public String getRedirectURL() {
41
        return redirectURL;
42
    }
43

    
44
    public void setRedirectURL(String redirectURL) {
45
        this.redirectURL = redirectURL;
46
    }
47

    
48
}
(2-2/2)