diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-07-08 18:35:07 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-07-09 13:05:29 +0300 |
commit | 97d9f66df456ef4573047a90baa3cc3ee4bfb0b7 (patch) | |
tree | b20f6304508e469fb5b48a70f17f02e713e66725 /vid-ext-services-simulator/src/main/java | |
parent | f4dff328c0386c8901b5841943b11f0c13b3169f (diff) |
Merge from ecomp 718fd196 - Ext. Services Simulator
Issue-ID: VID-378
Change-Id: Ib4430bf23d109e6fdfe38c55e55b7d3b96fff3af
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-ext-services-simulator/src/main/java')
9 files changed, 46 insertions, 77 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); diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/App.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/App.java index 222e753c4..56aafaa31 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/App.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/App.java @@ -1,9 +1,10 @@ package org.onap.simulator.db.entities; +import org.hibernate.annotations.Type; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; -import org.hibernate.annotations.Type; @Entity(name = "fn_app") public class App { diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/Role.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/Role.java index 8b09d1f57..85d7e2810 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/Role.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/Role.java @@ -1,13 +1,10 @@ package org.onap.simulator.db.entities; -import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToMany; import org.hibernate.annotations.Type; +import javax.persistence.*; +import java.util.Set; + @Entity(name = "fn_role") public class Role { @Id diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/RoleFunction.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/RoleFunction.java index addda5363..0765b69a4 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/RoleFunction.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/RoleFunction.java @@ -1,9 +1,9 @@ package org.onap.simulator.db.entities; -import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import java.io.Serializable; @Entity(name = "fn_role_function") public class RoleFunction implements Serializable { diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/User.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/User.java index 349845f36..6108f8c59 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/User.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/User.java @@ -1,13 +1,10 @@ package org.onap.simulator.db.entities; +import org.hibernate.annotations.Type; + +import javax.persistence.*; import java.math.BigDecimal; import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import org.hibernate.annotations.Type; @Entity(name = "fn_user") public class User { diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/UserApp.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/UserApp.java index e4eba7940..dfb6c056f 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/UserApp.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/db/entities/UserApp.java @@ -1,11 +1,7 @@ package org.onap.simulator.db.entities; +import javax.persistence.*; import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; @Entity(name = "fn_user_role") public class UserApp implements Serializable { diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorRequest.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorRequest.java index 713c318a2..bdb9ea738 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorRequest.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorRequest.java @@ -2,6 +2,7 @@ package org.onap.simulator.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.JsonNode; + import java.util.List; import java.util.Map; diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorResponse.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorResponse.java index 1ee185fdd..4836185f9 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorResponse.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/model/SimulatorResponse.java @@ -2,6 +2,7 @@ package org.onap.simulator.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.JsonNode; + import java.util.Map; public class SimulatorResponse { diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/service/TranslatorService.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/service/TranslatorService.java index 3894e90db..f675d39fe 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/service/TranslatorService.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/service/TranslatorService.java @@ -1,8 +1,8 @@ -//package org.onap.simulator.service; +//package org.openecomp.simulator.service; // //import org.mockserver.model.HttpRequest; //import org.mockserver.model.HttpResponse; -//import org.onap.simulator.model.ExpectationModel; +//import org.openecomp.simulator.model.ExpectationModel; //import org.springframework.stereotype.Component; // //import static org.mockserver.model.HttpRequest.request; |