Project

General

Profile

Download (1.14 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2021 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.vaadin.util;
10

    
11
import java.net.MalformedURLException;
12
import java.net.URI;
13
import java.net.URL;
14

    
15
import com.vaadin.server.VaadinServlet;
16
import com.vaadin.ui.UI;
17

    
18
/**
19
 * @author a.kohlbecker
20
 * @since Nov 10, 2021
21
 */
22
public class VaadinServletUtilities {
23

    
24
    public static URL getServletBaseUrl() throws MalformedURLException {
25
        URI baseURI = UI.getCurrent().getPage().getLocation();
26

    
27
        // int port = baseURI.getPort(); // ((baseURI.getPort() != 80 && baseURI.getScheme().equals("http")) || (baseURI.getPort() != 334 && baseURI.getScheme().equals("https")) ? ":" + baseURI.getPort() : ""), null);
28

    
29
        URL baseURL  = new URL(
30
                baseURI.getScheme(),
31
                baseURI.getHost(),
32
                baseURI.getPort(),
33
                VaadinServlet.getCurrent().getServletContext().getContextPath()
34
                );
35
        return baseURL;
36
    }
37

    
38
}
(17-17/17)