summaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST/src
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2019-03-26 21:51:56 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-26 21:51:56 +0000
commit3b0becfbca1fb48889f2b82361dae2abe1583c1f (patch)
tree35bee846548b22d69b649fb3829b7e11c1bef05c /ONAP-PDP-REST/src
parenta956a490499cf5c3f4ed2bff1921aec9a2b5a200 (diff)
parentf2b8028cc05cce994c855a8574d4d89e5a27be62 (diff)
Merge "Added changes to save original model file"
Diffstat (limited to 'ONAP-PDP-REST/src')
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java9
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportService.java22
2 files changed, 29 insertions, 2 deletions
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
index fcf319c8e..c227d9d2a 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PDP-REST
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -276,6 +276,13 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e);
throw new ServletException(e);
}
+
+ try {
+ System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home"));
+ } catch (Exception e) {
+ logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration");
+ }
+
startThreads(baseLoggingContext, new Thread(this));
}
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportService.java
index f7c1cc578..f8cba5123 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PDP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
package org.onap.policy.pdp.rest.api.services;
import java.io.BufferedInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;
@@ -77,6 +78,25 @@ public class PolicyEngineImportService {
importResponse = XACMLErrorConstants.ERROR_DATA_ISSUE + e;
status = HttpStatus.BAD_REQUEST;
}
+
+ // Save the imported file
+ if (!file.isEmpty() && status.equals(HttpStatus.OK) ) {
+ String filePath = null;
+ try {
+ String uploadsDir = System.getProperty("msToscaModel.home");
+ if(uploadsDir != null) {
+ if(! new File(uploadsDir).exists()){
+ new File(uploadsDir).mkdir();
+ }
+ String orgName = file.getOriginalFilename();
+ filePath = uploadsDir + orgName;
+ File dest = new File(filePath);
+ file.transferTo(dest);
+ }
+ }catch(Exception e){
+ LOGGER.error("Operation: policyEngineImport : " + e.getMessage() + ". " + filePath + " is not a valid file path.");
+ }
+ }
}
private void specialCheck() {