aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv/egovernment/moa
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/at/gv/egovernment/moa')
-rw-r--r--common/src/at/gv/egovernment/moa/util/FileUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
index f8941568d..bb21f4ca0 100644
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/FileUtils.java
@@ -4,6 +4,8 @@ import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -84,4 +86,26 @@ public class FileUtils {
byte[] content = readResource(name);
return new String(content, encoding);
}
+
+ /**
+ * Returns the absolute URL of a given url which is relative to the parameter root
+ * @param url
+ * @param root
+ * @return String
+ */
+ public static String makeAbsoluteURL(String url, String root) {
+ //if url is relative to rootConfigFileDirName make it absolute
+ try {
+ if(null == url) return null;
+ URI uri = new URI(url);
+ if (!uri.isAbsolute()) { // make it absolute to the config file
+ uri = new URI(root + url);
+ }
+ return uri.toString();
+ } catch (URISyntaxException e) {
+ //if url string could not be converted to absolute URL return source url
+ return url;
+ }
+ }
+
}