aboutsummaryrefslogtreecommitdiffstats
path: root/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
diff options
context:
space:
mode:
Diffstat (limited to 'vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java')
-rw-r--r--vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java88
1 files changed, 32 insertions, 56 deletions
diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
index bfed60395..06c72cbd4 100644
--- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
+++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
@@ -1,40 +1,8 @@
package org.onap.simulator.controller;
-import static org.mockserver.integration.ClientAndServer.startClientAndServer;
-import static org.mockserver.matchers.Times.exactly;
-import static org.mockserver.model.JsonBody.json;
-
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Scanner;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.TypedQuery;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.matchers.MatchType;
import org.mockserver.matchers.Times;
@@ -52,23 +20,36 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
-import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.View;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.TypedQuery;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockserver.integration.ClientAndServer.startClientAndServer;
+import static org.mockserver.matchers.Times.exactly;
+import static org.mockserver.model.JsonBody.json;
+
@RestController
@Component
public class SimulatorController {
@@ -230,7 +211,7 @@ public class SimulatorController {
//*******portal role access simulator (added by ag137v)
- @RequestMapping(value = {"/ONAPPORTAL/auxapi//v3/user/*"}, method = RequestMethod.GET)
+ @RequestMapping(value = {"/ecompportal_att/auxapi//{ver}/user/*", "/ONAPPORTAL/auxapi//{ver}/user/*"}, method = RequestMethod.GET)
public @ResponseBody
ResponseEntity auxapiGetUser(HttpServletRequest request) {
if (!enableJPA) {
@@ -250,7 +231,7 @@ public class SimulatorController {
}
- @RequestMapping(value = {"/ONAPPORTAL/auxapi//v3/functions"}, method = RequestMethod.GET)
+ @RequestMapping(value = {"/ecompportal_att/auxapi//{ver}/functions", "/ONAPPORTAL/auxapi//{ver}/functions"}, method = RequestMethod.GET)
public @ResponseBody
ResponseEntity auxapiGetFunctions(HttpServletRequest request) {
if (!enableJPA) {
@@ -273,16 +254,11 @@ public class SimulatorController {
request.setAttribute(View.RESPONSE_STATUS_ATTRIBUTE, HttpStatus.TEMPORARY_REDIRECT);
//Building the redirect URL
- String restOfTheUrl = (String) request.getAttribute(
- HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
-
- //TODO encode only characters like spaces, not slashes
- /* try {
- restOfTheUrl = URLEncoder.encode(restOfTheUrl, "UTF-8");
- restOfTheUrl = restOfTheUrl.replaceAll("%2F", "/");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }*/
+// String restOfTheUrl = (String) request.getAttribute(
+// HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
+ String requestUri = URLEncoder.encode(request.getRequestURI(), "UTF-8");
+ requestUri = requestUri.replaceAll("%2F", "/");
+ String restOfTheUrl = requestUri.replaceFirst(request.getContextPath(), "");
StringBuilder sb = new StringBuilder();
sb.append(mockServerProtocol).append("://").append(mockServerHost).append(":").append(mockServerPort).append(restOfTheUrl);