add startProxyServer and startRecording api
This commit is contained in:
parent
38b11ff38f
commit
56bee56bab
|
@ -67,6 +67,33 @@ public class ScriptController extends BaseController {
|
||||||
this.portPoolService = portPoolService;
|
this.portPoolService = portPoolService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @RequestMapping(value = "/startScriptRecordServer", method = {
|
||||||
|
// RequestMethod.GET, RequestMethod.POST })
|
||||||
|
// @ResponseBody
|
||||||
|
// public OperateScriptServerResponseModel startScriptRecordServer()
|
||||||
|
// throws UnknownHostException {
|
||||||
|
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
|
// return buildReponseModel(false,
|
||||||
|
// "has no power for recording script!!!", "", -1, null, null,
|
||||||
|
// null);
|
||||||
|
// }
|
||||||
|
// Port port = new Port();
|
||||||
|
// synchronized (PORT_LOCK) {
|
||||||
|
// port = this.getPortPoolService().getAPortNotInUse();
|
||||||
|
// if (port == null) {
|
||||||
|
// return buildReponseModel(false, "port is in use!", "", -1,
|
||||||
|
// null, null, null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// UUID uuid = UUID.randomUUID();
|
||||||
|
// this.getScriptCapturer().startRecord(port.getPort(),
|
||||||
|
// buildScriptSavePath(), uuid.toString());
|
||||||
|
//
|
||||||
|
// return buildReponseModel(true, "", this.getScriptCapturer()
|
||||||
|
// .getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
||||||
|
// uuid.toString());
|
||||||
|
// }
|
||||||
|
|
||||||
@RequestMapping(value = "/startScriptRecordServer", method = {
|
@RequestMapping(value = "/startScriptRecordServer", method = {
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
RequestMethod.GET, RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -86,14 +113,31 @@ public class ScriptController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
this.getScriptCapturer().startRecord(port.getPort(),
|
this.getScriptCapturer().startRecordServer(port.getPort(),
|
||||||
buildScriptSavePath(), uuid.toString());
|
buildScriptSavePath(), uuid.toString());
|
||||||
|
|
||||||
return buildReponseModel(true, "", this.getScriptCapturer()
|
return buildReponseModel(true, "", this.getScriptCapturer()
|
||||||
.getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
.getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
||||||
uuid.toString());
|
uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/startScriptRecording", method = {
|
||||||
|
RequestMethod.POST, RequestMethod.GET })
|
||||||
|
@ResponseBody
|
||||||
|
public OperateScriptServerResponseModel startScriptRecording(
|
||||||
|
@RequestParam int port, @RequestParam String fileNameUUID) {
|
||||||
|
if (!checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
|
return buildReponseModel(false,
|
||||||
|
"has no power for stopScriptCapture!!!", "", -1, null,
|
||||||
|
null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getScriptCapturer().startRecording(port);
|
||||||
|
|
||||||
|
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
||||||
|
null, fileNameUUID);
|
||||||
|
}
|
||||||
|
|
||||||
private String buildScriptSavePath() {
|
private String buildScriptSavePath() {
|
||||||
String dirString = "Scripts" + System.getProperty("file.separator")
|
String dirString = "Scripts" + System.getProperty("file.separator")
|
||||||
+ this.getPrincipal().getUserName()
|
+ this.getPrincipal().getUserName()
|
||||||
|
|
|
@ -64,7 +64,30 @@ public class ScriptCapturer {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void startRecordServer(int port, String fileDir, String fileName){
|
||||||
|
try {
|
||||||
|
HttpCapture httpCapture = buildACapture(port, fileDir, fileName);
|
||||||
|
httpCapture.startProxyServer();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (UserException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void startRecording(int port){
|
||||||
|
try {
|
||||||
|
HttpCapture httpCapture = this.getHttpCaptureMap().get(new Integer(port));
|
||||||
|
httpCapture.startRecording();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (UserException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
private HttpCapture buildACapture(int port, String filePath, String fileName) {
|
private HttpCapture buildACapture(int port, String filePath, String fileName) {
|
||||||
HttpCapture httpCapture = new HttpCapture(filePath, fileName, port,
|
HttpCapture httpCapture = new HttpCapture(filePath, fileName, port,
|
||||||
HTTPCATUREGENERATOR_STRING, new JTextArea());
|
HTTPCATUREGENERATOR_STRING, new JTextArea());
|
||||||
|
|
|
@ -277,7 +277,17 @@ public class ScriptController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@RequestMapping("startRecording")
|
||||||
|
@ResponseBody
|
||||||
|
public Map<String, Object> startRecording(
|
||||||
|
@ModelAttribute("accessToken") String accessToken,
|
||||||
|
@RequestParam String port, @RequestParam String scriptRecordUUID) {
|
||||||
|
return processScriptResponse(
|
||||||
|
new HashMap<String, Object>(),
|
||||||
|
this.getScriptMessager().startRecording(accessToken,
|
||||||
|
port, scriptRecordUUID));
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("stopRecordServer")
|
@RequestMapping("stopRecordServer")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> stopRecordServer(
|
public Map<String, Object> stopRecordServer(
|
||||||
|
|
|
@ -27,6 +27,16 @@ public class ScriptMessager extends MasterMessager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OperateScriptServerResponseModel startRecording(
|
||||||
|
String accessToken, String port, String fileNameUUID) {
|
||||||
|
String url = this.getBaseUrl() + "/startRecording";
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("port", port);
|
||||||
|
params.put("fileNameUUID", fileNameUUID);
|
||||||
|
return this.getOperateScriptServerResponseModelByPost(url, params,
|
||||||
|
accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
public OperateScriptServerResponseModel stopScriptRecordServer(
|
public OperateScriptServerResponseModel stopScriptRecordServer(
|
||||||
String accessToken, String port, String fileNameUUID) {
|
String accessToken, String port, String fileNameUUID) {
|
||||||
String url = this.getBaseUrl() + "/stopScriptRecordServer";
|
String url = this.getBaseUrl() + "/stopScriptRecordServer";
|
||||||
|
|
Loading…
Reference in New Issue