BrightSide Workbench Full Report + Source Code
org.turro.http.URLUtil Class Reference

Static Public Member Functions

static String checkAppServer (String server, boolean secured)
 
static String[] splitPath (String path)
 
static String absolute (String appServer, String path) throws URISyntaxException, MalformedURLException
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 35 of file URLUtil.java.

Member Function Documentation

◆ absolute()

static String org.turro.http.URLUtil.absolute ( String  appServer,
String  path 
) throws URISyntaxException, MalformedURLException
static

Definition at line 77 of file URLUtil.java.

77  {
78  URI url = new URI(path);
79  if(url.isAbsolute()) {
80  return path;
81  } else {
82  return new URL(new URL(appServer), path).toString();
83  }
84  }
Here is the caller graph for this function:

◆ checkAppServer()

static String org.turro.http.URLUtil.checkAppServer ( String  server,
boolean  secured 
)
static

Definition at line 37 of file URLUtil.java.

37  {
38  try {
39  URIBuilder url = new URIBuilder(server);
40  if(url.getScheme() == null) {
41  if(secured) url.setScheme("https"); else url.setScheme("http");
42  }
43  if(url.getHost() == null) {
44  String[] path = splitPath(url.getPath());
45  url.setHost(path[0]);
46  if(path.length > 1) {
47  url.setPath("/" + path[1]);
48  } else {
49  url.setPath(null);
50  }
51  } else {
52  String[] path = splitPath(url.getPath());
53  if(path != null && path.length > 0) {
54  url.setPath("/" + path[0]);
55  } else {
56  url.setPath(null);
57  }
58  }
59  url.removeQuery();
60  return url.build().toString();
61  } catch (URISyntaxException ex) {
62  Logger.getLogger(URLUtil.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
63  return null;
64  }
65  }
static String[] splitPath(String path)
Definition: URLUtil.java:67
Here is the call graph for this function:
Here is the caller graph for this function:

◆ splitPath()

static String [] org.turro.http.URLUtil.splitPath ( String  path)
static

Definition at line 67 of file URLUtil.java.

67  {
68  if(!Strings.isBlank(path)) {
69  path = path.replaceFirst("^[\\/ ]+", "");
70  path = path.replaceFirst("[\\/ ]+$", "");
71  return path.split("\\/");
72  } else {
73  return null;
74  }
75  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: