aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv
diff options
context:
space:
mode:
authorrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-01 10:42:06 +0000
committerrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-01 10:42:06 +0000
commit55e33b147723d68223f31994125b6364cb808bb1 (patch)
treec6fed8a675de993eaf17dafc2166c68251056ab4 /common/src/at/gv
parent1bfa47c942022dbf4b294cdd494b728deb84298b (diff)
downloadmoa-id-spss-55e33b147723d68223f31994125b6364cb808bb1.tar.gz
moa-id-spss-55e33b147723d68223f31994125b6364cb808bb1.tar.bz2
moa-id-spss-55e33b147723d68223f31994125b6364cb808bb1.zip
added makeAbsoluteURI (RSCH)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@66 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/at/gv')
-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;
+ }
+ }
+
}