summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service
diff options
context:
space:
mode:
authorrv871f <richard.vondadelszen@amdocs.com>2018-03-29 11:38:04 -0400
committerrv871f <richard.vondadelszen@amdocs.com>2018-03-29 11:38:30 -0400
commit439e16586f6a1b05a892cada09e7b48cb322878c (patch)
tree7a2caa507265c1471e2d1241e7591f177a8f8233 /sparkybe-onap-service
parentb505658d523507b2aa8eec564b599ce1e2b1956a (diff)
Portal Login Filter reintegration
Issue-ID: AAI-599 Change-Id: I119608a418a07546cd58d4fcbdf93f033c8fbd88 Signed-off-by: rv871f <richard.vondadelszen@amdocs.com>
Diffstat (limited to 'sparkybe-onap-service')
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java36
1 files changed, 19 insertions, 17 deletions
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
index 8d99221..6bb0c45 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
@@ -30,8 +30,8 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
public class SparkyResourceLoader implements ResourceLoaderAware {
-
-
+
+
private static final String FILE_URI = "file:";
private ResourceLoader resourceLoader;
private String configHomeEnvVar;
@@ -42,7 +42,7 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
-
+
public String getFullFileUri(String uriFilePath) {
return FILE_URI + System.getProperty(configHomeEnvVar) + uriFilePath;
}
@@ -50,38 +50,40 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public String getAbsolutePath(String uriFilePath) {
return System.getProperty(configHomeEnvVar) + uriFilePath;
}
-
+
protected Resource getResource(String uriFilePath, boolean isRelative) {
String fileUri = uriFilePath;
- if (!uriFilePath.startsWith("file:")) {
- fileUri = "file:" + uriFilePath;
- }
+ if (!uriFilePath.startsWith(FILE_URI)) {
+
+ if (isRelative) {
+ fileUri = getFullFileUri(fileUri);
+ } else {
+ fileUri = FILE_URI + uriFilePath;
+ }
- if (isRelative) {
- return resourceLoader.getResource(getFullFileUri(fileUri));
- } else {
- return resourceLoader.getResource(fileUri);
}
+ return resourceLoader.getResource(fileUri);
+
}
public File getResourceAsFile(String uriFilePath, boolean isRelativePath) throws IOException {
-
- Resource resource = getResource(uriFilePath, isRelativePath);
+
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return resource.getFile();
}
return null;
-
+
}
public byte[] getResourceAsBytes(String uriFilePath, boolean isRelativePath) throws IOException {
- Resource resource = getResource(uriFilePath, isRelativePath);
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return getResourceAsBytes(resource);
@@ -89,10 +91,10 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
return null;
}
-
+
public byte[] getResourceAsBytes(Resource resource) throws IOException {
- if ( resource != null && resource.exists()) {
+ if (resource != null && resource.exists()) {
return Files.readAllBytes(Paths.get(resource.getFile().getAbsolutePath()));
}