Przeglądaj źródła

Merge remote-tracking branch 'origin/dev' into dev

mxd 4 lat temu
rodzic
commit
986a0348e6

+ 55 - 15
src/main/java/org/ssssssss/magicapi/model/RequestEntity.java

@@ -6,31 +6,24 @@ import org.ssssssss.script.MagicScriptContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Map;
-
 public class RequestEntity {
 
-	private final ApiInfo apiInfo;
+	private  ApiInfo apiInfo;
 
-	private final HttpServletRequest request;
+	private  HttpServletRequest request;
 
-	private final HttpServletResponse response;
+	private  HttpServletResponse response;
 
-	private final boolean requestedFromTest;
+	private  boolean requestedFromTest;
 
-	private final Map<String, Object> parameters;
+	private  Map<String, Object> parameters;
 
-	private final Map<String, Object> pathVariables;
-	private final Long requestTime = System.currentTimeMillis();
+	private  Map<String, Object> pathVariables;
+	private  Long requestTime = System.currentTimeMillis();
 	private MagicScriptContext magicScriptContext;
 	private Map<String, Object> headers;
-
 	private RequestEntity() {
-		this.request = null;
-		this.response = null;
-		this.requestedFromTest = false;
-		this.parameters = null;
-		this.pathVariables = null;
-		this.apiInfo = null;
+
 	}
 
 	public RequestEntity(HttpServletRequest request, HttpServletResponse response, boolean requestedFromTest, Map<String, Object> parameters, Map<String, Object> pathVariables) {
@@ -43,6 +36,27 @@ public class RequestEntity {
 		this.apiInfo = info != null ? info.copy() : null;
 	}
 
+	public RequestEntity(ApiInfo apiInfo, HttpServletRequest request, HttpServletResponse response, boolean requestedFromTest, Map<String, Object> parameters, Map<String, Object> pathVariables) {
+		this.apiInfo = apiInfo;
+		this.request = request;
+		this.response = response;
+		this.requestedFromTest = requestedFromTest;
+		this.parameters = parameters;
+		this.pathVariables = pathVariables;
+	}
+
+	public RequestEntity(HttpServletRequest request, HttpServletResponse response, boolean requestedFromTest, Map<String, Object> parameters, Map<String, Object> pathVariables, MagicScriptContext magicScriptContext, Map<String, Object> headers) {
+		ApiInfo info = MappingHandlerMapping.getMappingApiInfo(request);
+		this.apiInfo = info != null ? info.copy() : null;
+		this.request = request;
+		this.response = response;
+		this.requestedFromTest = requestedFromTest;
+		this.parameters = parameters;
+		this.pathVariables = pathVariables;
+		this.magicScriptContext = magicScriptContext;
+		this.headers = headers;
+	}
+
 	public static RequestEntity empty() {
 		return new RequestEntity();
 	}
@@ -90,4 +104,30 @@ public class RequestEntity {
 	public void setHeaders(Map<String, Object> headers) {
 		this.headers = headers;
 	}
+
+	public void setApiInfo(ApiInfo apiInfo) {
+		this.apiInfo = apiInfo;
+	}
+
+	public void setRequest(HttpServletRequest request) {
+		this.request = request;
+	}
+
+	public void setResponse(HttpServletResponse response) {
+		this.response = response;
+	}
+
+	public void setRequestedFromTest(boolean requestedFromTest) {
+		this.requestedFromTest = requestedFromTest;
+	}
+
+	public void setParameters(Map<String, Object> parameters) {
+		this.parameters = parameters;
+	}
+
+	public void setPathVariables(Map<String, Object> pathVariables) {
+		this.pathVariables = pathVariables;
+	}
+
+
 }