add loadFilterTypeList api
This commit is contained in:
parent
a72cb7a307
commit
7ccd47d74b
|
@ -102,14 +102,14 @@ public class ScriptController extends BaseController {
|
|||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return buildReponseModel(false,
|
||||
"has no power for recording script!!!", "", -1, null, null,
|
||||
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);
|
||||
null, null, null,null);
|
||||
}
|
||||
}
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
@ -118,7 +118,7 @@ public class ScriptController extends BaseController {
|
|||
|
||||
return buildReponseModel(true, "", this.getScriptCapturer()
|
||||
.getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
||||
uuid.toString());
|
||||
uuid.toString(),null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/startScriptRecording", method = {
|
||||
|
@ -129,13 +129,13 @@ public class ScriptController extends BaseController {
|
|||
if (!checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return buildReponseModel(false,
|
||||
"has no power for stopScriptCapture!!!", "", -1, null,
|
||||
null, null);
|
||||
null, null,null);
|
||||
}
|
||||
|
||||
this.getScriptCapturer().startRecording(port);
|
||||
|
||||
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
||||
null, fileNameUUID);
|
||||
null, fileNameUUID,null);
|
||||
}
|
||||
|
||||
private String buildScriptSavePath() {
|
||||
|
@ -158,7 +158,7 @@ public class ScriptController extends BaseController {
|
|||
if (!checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return buildReponseModel(false,
|
||||
"has no power for stopScriptCapture!!!", "", -1, null,
|
||||
null, null);
|
||||
null, null,null);
|
||||
}
|
||||
|
||||
this.getScriptCapturer().stopCurrentRecord(port);
|
||||
|
@ -167,7 +167,7 @@ public class ScriptController extends BaseController {
|
|||
}
|
||||
|
||||
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
||||
null, fileNameUUID);
|
||||
null, fileNameUUID,null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveScriptToDB", method = { RequestMethod.GET,
|
||||
|
@ -179,14 +179,14 @@ public class ScriptController extends BaseController {
|
|||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return buildReponseModel(false,
|
||||
"saveScriptToDB check your scope fail!", "", -1, null,
|
||||
null, null);
|
||||
null, null,null);
|
||||
}
|
||||
|
||||
File file = new File(buildScriptSavePath()
|
||||
+ System.getProperty("file.separator") + fileNameUUID + ".xml");
|
||||
if (!file.exists()) {
|
||||
return buildReponseModel(false, "no that script", null, -1, null,
|
||||
null, fileNameUUID);
|
||||
null, fileNameUUID,null);
|
||||
}
|
||||
try {
|
||||
String content = FileUtils.readFileToString(file);
|
||||
|
@ -195,10 +195,10 @@ public class ScriptController extends BaseController {
|
|||
this.getPrincipal().getId(), content, null);
|
||||
// this.getUserService().add
|
||||
return buildReponseModel(success, "Save to DataBase!!", "", port,
|
||||
null, null, null);
|
||||
null, null, null,null);
|
||||
} catch (Exception e) {
|
||||
return buildReponseModel(false, "exception when read from file",
|
||||
null, -1, null, null, fileNameUUID);
|
||||
null, -1, null, null, fileNameUUID,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,12 +218,12 @@ public class ScriptController extends BaseController {
|
|||
boolean success = this.getScriptService().saveScript(scriptName,
|
||||
this.getPrincipal().getId(), scenarioModel, paramFiles);
|
||||
logger.info("upload script:" + scenarioModel);
|
||||
return buildReponseModel(success, null, null, -1, null, null, null);
|
||||
return buildReponseModel(success, null, null, -1, null, null, null,null);
|
||||
} catch (Exception e) {
|
||||
this.logger.error(ExceptionLog.getStackTrace(e));
|
||||
return buildReponseModel(false,
|
||||
"The script is not in the right format", null, -1, null,
|
||||
null, null);
|
||||
null, null,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,8 +238,22 @@ public class ScriptController extends BaseController {
|
|||
this.getPrincipal());
|
||||
|
||||
return this.buildReponseModel(true, null, null, 0,
|
||||
dealWithCollection(scripts), null, null);
|
||||
dealWithCollection(scripts), null, null,null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/loadFilterTypeList", method = { RequestMethod.POST,
|
||||
RequestMethod.GET })
|
||||
@ResponseBody
|
||||
public OperateScriptServerResponseModel loadFilterTypeList() {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return null;
|
||||
}
|
||||
String[] filterTypeList = this.getScriptService().loadFilterTypeList();
|
||||
|
||||
return this.buildReponseModel(true, null, null, 0,
|
||||
null, null, null,filterTypeList);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/queryScriptsByDate", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
|
@ -252,7 +266,7 @@ public class ScriptController extends BaseController {
|
|||
.queryScriptsByCreateTime(startDate, endDate,
|
||||
this.getPrincipal());
|
||||
return this.buildReponseModel(true, null, null, 0,
|
||||
dealWithCollection(scripts), null, null);
|
||||
dealWithCollection(scripts), null, null,null);
|
||||
}
|
||||
|
||||
private List<ScriptModel> dealWithCollection(Collection<Script> scripts) {
|
||||
|
@ -273,7 +287,7 @@ public class ScriptController extends BaseController {
|
|||
}
|
||||
return this.buildReponseModel(true, null, null, 0, null,
|
||||
BusinessModelMapFactory.toModel(this.getScriptService()
|
||||
.getScript(scriptId)), null);
|
||||
.getScript(scriptId)), null,null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryScriptByName", method = { RequestMethod.GET,
|
||||
|
@ -287,7 +301,7 @@ public class ScriptController extends BaseController {
|
|||
}
|
||||
return this.buildReponseModel(true, null, null, 0, null,
|
||||
BusinessModelMapFactory.toModel(this.getScriptService()
|
||||
.getScriptByName(name)), null);
|
||||
.getScriptByName(name)), null,null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteScript", method = { RequestMethod.GET,
|
||||
|
@ -301,7 +315,7 @@ public class ScriptController extends BaseController {
|
|||
return this.buildReponseModel(
|
||||
this.getScriptService().deleteScript(scriptId,
|
||||
this.getPrincipal().getId()), "", "", 0, null, null,
|
||||
null);
|
||||
null,null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "updateScript/{scriptId}", method = {
|
||||
|
@ -316,7 +330,7 @@ public class ScriptController extends BaseController {
|
|||
return this.buildReponseModel(
|
||||
this.getScriptService().alterScriptContent(scriptId,
|
||||
this.getPrincipal().getId(),content,scriptName), "", "", 0, null,
|
||||
null, null);
|
||||
null, null,null);
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "updateScript/{scriptId}", method = {
|
||||
|
@ -347,7 +361,7 @@ public class ScriptController extends BaseController {
|
|||
private OperateScriptServerResponseModel buildReponseModel(
|
||||
boolean isSuccess, String failCauseString, String hostName,
|
||||
int port, List<ScriptModel> scriptModels, ScriptModel scriptModel,
|
||||
String fileName) {
|
||||
String fileName,String[] filterTypeList) {
|
||||
OperateScriptServerResponseModel responseModel = new OperateScriptServerResponseModel();
|
||||
responseModel.setSuccess(isSuccess);
|
||||
responseModel.setFailCauseString(failCauseString);
|
||||
|
@ -359,6 +373,7 @@ public class ScriptController extends BaseController {
|
|||
scriptModels.add(scriptModel);
|
||||
}
|
||||
responseModel.setScriptModels(scriptModels);
|
||||
responseModel.setFilterTypeList(filterTypeList);
|
||||
return responseModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.bench4q.master.domain.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
|
@ -18,12 +21,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
@Component
|
||||
public class ScriptService {
|
||||
private ScriptRepositoty scriptRepositoty;
|
||||
private UserRepository userRepository;
|
||||
private Logger logger = Logger.getLogger(ScriptService.class);
|
||||
|
||||
private Properties properties = null;
|
||||
|
||||
private ScriptRepositoty getScriptRepositoty() {
|
||||
return scriptRepositoty;
|
||||
}
|
||||
|
@ -75,6 +81,11 @@ public class ScriptService {
|
|||
public List<Script> loadScripts(User user) {
|
||||
return this.getScriptRepositoty().loadEntities(user);
|
||||
}
|
||||
|
||||
public String[] loadFilterTypeList() {
|
||||
return getFilterTypeList();
|
||||
}
|
||||
|
||||
|
||||
public List<Script> queryScriptsByCreateTime(Date startDate, Date endDate,
|
||||
User user) {
|
||||
|
@ -119,4 +130,20 @@ public class ScriptService {
|
|||
script.setScriptContent(content);
|
||||
return this.getScriptRepositoty().update(script);
|
||||
}
|
||||
|
||||
private String[] getFilterTypeList(){
|
||||
if(properties == null){
|
||||
try {
|
||||
properties = new Properties();
|
||||
InputStream inputStream = ScriptService.class.getClassLoader()
|
||||
.getResourceAsStream(
|
||||
"org/bench4q/master/config/FilterType.properties");
|
||||
properties.load(inputStream);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return properties.getProperty("filter.type.list","").split(",");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue