-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathServer.java
More file actions
53 lines (43 loc) · 1.68 KB
/
Copy pathServer.java
File metadata and controls
53 lines (43 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt
package com.google.appinventor.server;
import com.google.appengine.api.utils.SystemProperty;
import com.google.appinventor.shared.rpc.ServerLayout;
import javax.servlet.http.HttpServletRequest;
/**
* TODO(user);
* Useful server-related methods. Probably these should be moved elsewhere.
*
*/
public class Server {
// Start page for ODE/YA. This is where other servlets redirect to to get the main page
public static final String START_PAGE = getStartPage();
// System property name to obtain GWT UI module
private static final String START_PAGE_KEY = "StartPage";
public static String getStartPage() {
return System.getProperty(START_PAGE_KEY);
}
/**
* Indicates whether this server instance is running on app engine production
*
* @return true if this server instance is running on app engine production
*/
public static boolean isProductionServer() {
return SystemProperty.environment.value() == SystemProperty.Environment.Value.Production;
}
/**
* Returns URL built by appending path to the current server and the server
* port and base URL.
*
* @param req HTTP request
* @param path requested path
* @return build URL
*/
public static String urlFromPath(HttpServletRequest req, String path) {
// TODO(user): omit the port if it is the default port for a schema
return req.getScheme() + "://" + req.getServerName() + ':' + req.getServerPort()
+ ServerLayout.ODE_BASEURL + path;
}
}