Project

General

Profile

Download (1.28 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2012 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.json;
10

    
11
import javax.servlet.http.HttpServletRequest;
12

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

    
22
    private String redirectURL = null;
23

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

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

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

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

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

    
47
}
(2-2/3)