From 3207b48d3ab0cb023d45f1ae8fba87e19d0c3a0f Mon Sep 17 00:00:00 2001 From: fanfuxiaoran <495538672@qq.com> Date: Tue, 22 Apr 2014 23:17:01 +0800 Subject: [PATCH] fix the upload script and file --- .../bench4q/master/api/ScriptController.java | 23 ++++++------------- .../master/domain/entity/plugin/FileType.java | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java index 56dfe802..d05dc7d5 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java @@ -9,8 +9,6 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import javax.xml.bind.JAXBException; - import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.bench4q.master.domain.entity.Port; @@ -22,8 +20,6 @@ import org.bench4q.master.domain.service.UserService; import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.ExceptionLog; import org.bench4q.recorder.ScriptCapturer; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.agent.RunScenarioModel; import org.bench4q.share.models.master.OperateScriptServerResponseModel; import org.bench4q.share.models.master.ScriptModel; import org.springframework.beans.factory.annotation.Autowired; @@ -163,11 +159,12 @@ public class ScriptController extends BaseController { } } - @RequestMapping(value = "/uploadScript/{scriptName}", method = RequestMethod.PUT) + @RequestMapping(value = "/uploadScript/{scriptName}", method = { + RequestMethod.PUT, RequestMethod.POST }) @ResponseBody public OperateScriptServerResponseModel uploadScriptToDB( @PathVariable String scriptName, - @RequestParam RunScenarioModel scenarioModel, + @RequestParam String scenarioModel, @RequestParam(value = "paramFiles[]", required = false) List paramFiles) throws Bench4QException { if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { @@ -175,17 +172,11 @@ public class ScriptController extends BaseController { + "for upload a script", "/uploadScript"); } try { - boolean success = this.getScriptService().saveScript( - scriptName, - this.getPrincipal().getId(), - MarshalHelper - .marshal(RunScenarioModel.class, scenarioModel), - paramFiles); - logger.info("upload script:" - + MarshalHelper.marshal(RunScenarioModel.class, - scenarioModel)); + 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); - } catch (JAXBException e) { + } catch (Exception e) { this.logger.error(ExceptionLog.getStackTrace(e)); return buildReponseModel(false, "The script is not in the right format", null, -1, null, diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java index 7c042299..66695552 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java @@ -5,7 +5,7 @@ import javax.persistence.Entity; import javax.persistence.Table; @Entity -@Table(name = "fieldType") +@Table(name = "fileType") public class FileType extends ParamType { private String text;