X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPolicyEngineImportService.java;fp=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPolicyEngineImportService.java;h=f8cba5123e9ca7773783cfedb5613788792b3ddb;hb=f2b8028cc05cce994c855a8574d4d89e5a27be62;hp=f7c1cc5784018ecfcc0f8899afda47749d1168d4;hpb=97ce3b94390c10a1af43ed5614ca976095c0097d;p=policy%2Fengine.git 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() {