aboutsummaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex/src/main/java
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2020-08-10 18:42:48 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2020-08-10 18:08:46 +0000
commit7212e92fbe010ccf7a057153406d0633a293a8fd (patch)
tree057f942028af1093c6fd53714c616feb3c424cbd /gui-editors/gui-editor-apex/src/main/java
parent864811238d7d44933df2c4f59f31947a83310587 (diff)
Passing userId to upload policy
Issue-ID: POLICY-2751 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: Ifc91bba369161a63f2ad759dcdc014bb12837e88
Diffstat (limited to 'gui-editors/gui-editor-apex/src/main/java')
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java16
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyUploadHandler.java8
2 files changed, 13 insertions, 11 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 33aa04d..3083c4a 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
@@ -74,7 +74,6 @@ import org.slf4j.ext.XLoggerFactory;
public class ApexEditorRestResource implements RestCommandHandler {
// Get a reference to the logger
-
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEditorRestResource.class);
// Location of the periodi event template
@@ -262,13 +261,15 @@ public class ApexEditorRestResource implements RestCommandHandler {
@Path("Model/Upload")
@Consumes({MediaType.MULTIPART_FORM_DATA})
public ApexApiResult uploadModel(@FormDataParam("tosca-template-file") InputStream toscaTemplateFileStream,
- @FormDataParam("apex-config-file") InputStream apexConfigFileStream) {
+ @FormDataParam("apex-config-file") InputStream apexConfigFileStream,
+ @FormDataParam("userId") String userId) {
final ApexApiResult result = new ApexApiResult();
final RestSession session = SESSION_HANDLER.getSession(sessionId, result);
if (session == null) {
return result;
}
- return policyUploadHandler.doUpload(session.getApexModel(), toscaTemplateFileStream, apexConfigFileStream);
+ return policyUploadHandler.doUpload(session.getApexModel(), toscaTemplateFileStream,
+ apexConfigFileStream, userId);
}
/**
@@ -295,7 +296,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
@GET
@Path("KeyInformation/Get")
public ApexApiResult listKeyInformation(@QueryParam(NAME) final String name,
- @QueryParam(VERSION) final String version) {
+ @QueryParam(VERSION) final String version) {
return processRestCommand(RestCommandType.KEY_INFO, RestCommand.LIST, name, version);
}
@@ -587,7 +588,6 @@ public class ApexEditorRestResource implements RestCommandHandler {
return processRestCommand(RestCommandType.TASK, RestCommand.VALIDATE, name, version);
}
- // CHECKSTYLE:OFF: MethodLength
/**
* Creates a policy with the information in the JSON string passed.
*
@@ -741,7 +741,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
*/
@Override
public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
- final RestCommand command) {
+ final RestCommand command) {
switch (commandType) {
case MODEL:
return MODEL_HANDLER.executeRestCommand(session, commandType, command);
@@ -773,7 +773,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
*/
@Override
public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
- final RestCommand command, final String jsonString) {
+ final RestCommand command, final String jsonString) {
switch (commandType) {
case MODEL:
return MODEL_HANDLER.executeRestCommand(session, commandType, command, jsonString);
@@ -806,7 +806,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
*/
@Override
public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
- final RestCommand command, final String name, final String version) {
+ final RestCommand command, final String name, final String version) {
switch (commandType) {
case MODEL:
return MODEL_HANDLER.executeRestCommand(session, commandType, command, name, version);
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyUploadHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyUploadHandler.java
index af8d9dd..3540b2d 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyUploadHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyUploadHandler.java
@@ -83,7 +83,7 @@ public class PolicyUploadHandler {
* @return the result of the upload process
*/
public ApexApiResult doUpload(final ApexModel apexModel, final InputStream toscaTemplateInputStream,
- final InputStream apexConfigInputStream) {
+ final InputStream apexConfigInputStream, final String userId) {
final ProcessedTemplate processedToscaTemplate;
try {
processedToscaTemplate = toscaTemplateProcessor.process(toscaTemplateInputStream);
@@ -113,10 +113,11 @@ public class PolicyUploadHandler {
if (!processedApexConfig.isValid()) {
return buildResponse(processedApexConfig);
}
- return doUpload(apexModel, processedToscaTemplate.getContent(), processedApexConfig.getContent());
+ return doUpload(apexModel, processedToscaTemplate.getContent(), processedApexConfig.getContent(), userId);
}
- private ApexApiResult doUpload(final ApexModel apexModel, final String toscaTemplate, final String apexConfig) {
+ private ApexApiResult doUpload(final ApexModel apexModel, final String toscaTemplate, final String apexConfig,
+ final String userId) {
LOGGER.entry();
if (!isUploadPluginEnabled()) {
final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
@@ -128,6 +129,7 @@ public class PolicyUploadHandler {
final UploadPolicyRequestDto uploadPolicyRequestDto = new UploadPolicyRequestDto();
final AxArtifactKey policyKey = policyModel.getKeyInformation().getKey();
final java.util.UUID uuid = policyModel.getKeyInformation().get(policyKey).getUuid();
+ uploadPolicyRequestDto.setUserId(userId);
uploadPolicyRequestDto
.setFilename(String.format("%s.%s.%s", uuid, policyKey.getName(), policyKey.getVersion()));
final String apexPolicy = convert(result.getMessage(), toscaTemplate, apexConfig).orElse(null);