aboutsummaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-09-30 15:56:24 +0100
committerLiam Fallon <liam.fallon@est.tech>2020-09-30 15:22:25 +0000
commit33c9f2c07083f2f94f909a27f406da2744c4158f (patch)
tree1f8010eb7def66b9b6f055a9f32dae0d070463db /gui-editors/gui-editor-apex
parent8254698572dd9475c7dd6070ffe7b68361fb6834 (diff)
Pick up userId from apex editor URL
The userId must be picked up from the URL passed to the policy editor and then passed to the server. Issue-ID: POLICY-2850 Change-Id: I98948f2e0a2bf8090926751ee98c26c46d272fcf Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'gui-editors/gui-editor-apex')
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java8
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java2
-rw-r--r--gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js2
3 files changed, 9 insertions, 3 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
index ba3d5e7..dc27d49 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
@@ -32,9 +32,11 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.gui.editors.apex.rest.ApexEditorMain;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -229,11 +231,15 @@ public class ApexEditorRestResource implements RestCommandHandler {
/**
* Uploads a TOSCA Policy Model to a configured endpoint.
*
+ * @param userid the userid to use for upload
* @return an ApexAPIResult that contains the operation status and success/error messages
*/
@GET
@Path("Model/Upload")
- public ApexApiResult uploadModel() {
+ public ApexApiResult uploadModel(@QueryParam("userId") final String userid) {
+ if (!StringUtils.isBlank(userid)) {
+ ApexEditorMain.getParameters().setUploadUserid(userid);
+ }
return processRestCommand(RestCommandType.MODEL, RestCommand.UPLOAD);
}
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
index 5e3cf56..6d8b803 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
@@ -56,7 +56,7 @@ public class PolicyUploadHandler {
if (StringUtils.isBlank(ApexEditorMain.getParameters().getUploadUrl())) {
final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
- apexApiResult.addMessage("Model download is disabled, parameter upload-url is not set on server");
+ apexApiResult.addMessage("Model upload is disabled, parameter upload-url is not set on server");
LOGGER.exit(MODEL_UPLOAD_NOT_OK);
return apexApiResult;
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js
index a8726e7..93b1183 100644
--- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js
+++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js
@@ -51,7 +51,7 @@ function files_fileDownload() {
}
function files_fileUpload() {
- var requestURL = restRootURL + "/Model/Upload";
+ var requestURL = restRootURL + "/Model/Upload?userId=" + new URLSearchParams(window.location.search).get('userId');
ajax_getOKOrFail(requestURL, function(data) {
var uploadResultString = "";