Copyright ? ????? ?
The Baidu Story Our name was inspired by a poem written more than 800 years ago during the Song Dynasty. The poem compares the search for a retreating beauty amid chaotic glamour with the search for one's dream while confronted by life's many obstacles. "¡hundreds and thousands of times, for her I searched in chaos, suddenly, I turned by chance, to where the lights were waning, and there she stood." Baidu, whose literal meaning is ¡°hundreds of times¡±, represents a persistent search for the ideal.
+Baidu was founded in 2000 by Internet pioneer Robin Li, creator of visionary search technology Hyperlink Analysis, with the mission of providing the best way for people to find what they¡¯re looking for online. Over the past decade we have strived to fulfill this mission by listening carefully to our users¡¯ needs and wants. To provide intelligent, relevant search results for the tens of billions of queries that are entered into our search platform every day, we focus on powering the best technology optimized for up-to-date local tastes and preferences. Our deep understanding of Chinese language and culture is central to our success and this kind of knowledge allows us to tailor our search technology for our users¡¯ needs. Just to cite one example, we believe there are at least 38 ways of saying "I" in the Chinese language. It is important that we recognize these nuances to effectively address our users¡¯ requests.
+
+We provide our users with many channels to find and share information. In addition to our core web search product, we power many popular community-based products, such as Baidu PostBar, the world¡¯s first and largest Chinese-language query-based searchable online community platform, Baidu Knows, the world¡¯s largest Chinese-language interactive knowledge-sharing platform, and Baidu Encyclopedia, the world¡¯s largest user-generated Chinese-language encyclopedia, to name but a few. Beyond these marquee products we also offer dozens of helpful vertical search-based products, such as Maps, Image Search, Video Search, News Search, and many more. We power these through our cutting-edge technology, continually innovating to enhance these services. Our new Box Computing Open Platform brings users deep-linked content and even applications they can use directly through their search box. We believe that Box Computing will dramatically improve people¡¯s search experience and become ubiquitous across all Internet devices including computers and mobile platforms.
+
+In addition to serving individual users, we also serve as a media platform for online marketing customers. Our business model is mainly based on a performance-oriented marketing platform for businesses to cost effectively reach relevant Internet users. We offer performance-based online marketing services and display advertisements through both Baidu organic websites and our affiliated websites (our Union business). Our affiliated websites lead traffic to us through integrating a Baidu search box into their sites and/or by displaying relevant contextual promotional links for our customers. The majority of our revenue is derived from performance-based online marketing services and our customers pay on a cost per click basis ¨C that is, our customers only pay when their paid-link is clicked through and they get the ¡°lead¡±. Our goal is to give our customers an online marketing platform that has a wide range of functions which they can use to meet their marketing needs and an extensive selection of tools for managing their accounts as well as data for analyzing and optimizing ROI.
+
+To best serve our customers, our sales efforts consist of direct sales teams in first tier cities and third-party distributors in lower tier cities. This allows us to better penetrate each market and tailor our support and personal interaction based on customers¡¯ needs. Today, our online marketing platform serves hundreds of thousands of small- and medium-sized enterprises (SMEs) and many branded multinational customers. The measurable ROI offered by our online marketing platform has made it one of the most effective marketing platforms for companies targeting the Chinese market. We will continue to strive to provide an extra level of value-added sales and customer service to address a wide range of customer needs. Our focus is to help the market continue to develop and educate the many companies who don¡¯t understand the benefits of search engine marketing so that we can help them grow their businesses.
+
+You don¡¯t need us to tell you that China¡¯s Internet space is booming. With the world¡¯s largest Internet user population ¨C 564 million as of end of 2012 ¨C and a long way to go to reach internet penetration levels of developed countries, China¡¯s internet is growing in both influence and sophistication. And as more and more Chinese come online, Baidu continues to innovate to meet their increasingly diverse tastes. With our goal of best serving the needs of our users and customers with intelligent and relevant solutions, we look forward to a robust future.
+
Copyright ? Baidu, Inc. All Rights Reserved.
behaviorModels;
- List usePluginModels;
- String scriptName;
-
- public List getBehaviorModels() {
- return behaviorModels;
- }
-
- public void setBehaviorModels(List behaviorModels) {
- this.behaviorModels = behaviorModels;
- }
-
- public List getUsePluginModels() {
- return usePluginModels;
- }
-
- public void setUsePluginModels(List usePluginModels) {
- this.usePluginModels = usePluginModels;
- }
-
- public String getScriptName() {
- return scriptName;
- }
-
- public void setScriptName(String scriptName) {
- this.scriptName = scriptName;
- }
-
-}
+package org.bench4q.share.models.master;
+
+import java.util.List;
+
+import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
+import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
+
+public class PluginEditScriptRequestModel {
+
+ List behaviorModels;
+ List usePluginModels;
+ String scriptName;
+
+ public List getBehaviorModels() {
+ return behaviorModels;
+ }
+
+ public void setBehaviorModels(List behaviorModels) {
+ this.behaviorModels = behaviorModels;
+ }
+
+ public List getUsePluginModels() {
+ return usePluginModels;
+ }
+
+ public void setUsePluginModels(List usePluginModels) {
+ this.usePluginModels = usePluginModels;
+ }
+
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public void setScriptName(String scriptName) {
+ this.scriptName = scriptName;
+ }
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodModel.java
index cea01c5a..b1c4779f 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodModel.java
@@ -1,35 +1,35 @@
-package org.bench4q.share.models.master.plugin;
-
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class MethodModel {
- private Set methodParams;
-
- private String name;
-
- @XmlElement
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- @XmlElementWrapper(name = "params")
- @XmlElement(name = "param", type = MethodParamModel.class)
- public Set getMethodParams() {
- return methodParams;
- }
-
- public void setMethodParams(Set methodParams) {
- this.methodParams = methodParams;
- }
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class MethodModel {
+ private Set methodParams;
+
+ private String name;
+
+ @XmlElement
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ @XmlElementWrapper(name = "params")
+ @XmlElement(name = "param", type = MethodParamModel.class)
+ public Set getMethodParams() {
+ return methodParams;
+ }
+
+ public void setMethodParams(Set methodParams) {
+ this.methodParams = methodParams;
+ }
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamModel.java
index b3756d7b..9c135df5 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamModel.java
@@ -1,69 +1,69 @@
-package org.bench4q.share.models.master.plugin;
-
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class MethodParamModel {
- private String name;
- private String lable;
- private ParamTypeEnum paramType;
- private String valueSeperator = ";";
- private String fieldSeperator = ",";
- private Set methodParamProperties;
-
- @XmlElement
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @XmlElement
- public String getLable() {
- return lable;
- }
-
- public void setLable(String lable) {
- this.lable = lable;
- }
-@XmlElement
- public ParamTypeEnum getParamType() {
- return paramType;
- }
-
- public void setParamType(ParamTypeEnum paramType) {
- this.paramType = paramType;
- }
- @XmlElement
- public String getValueSeperator() {
- return valueSeperator;
- }
-
- public void setValueSeperator(String valueSeperator) {
- this.valueSeperator = valueSeperator;
- }
- @XmlElement
- public String getFieldSeperator() {
- return fieldSeperator;
- }
-
- public void setFieldSeperator(String fieldSeperator) {
- this.fieldSeperator = fieldSeperator;
- }
- @XmlElement
- public Set getMethodParamProperties() {
- return methodParamProperties;
- }
-
- public void setMethodParamProperties(
- Set methodParamProperties) {
- this.methodParamProperties = methodParamProperties;
- }
-
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class MethodParamModel {
+ private String name;
+ private String lable;
+ private ParamTypeEnum paramType;
+ private String valueSeperator = ";";
+ private String fieldSeperator = ",";
+ private Set methodParamProperties;
+
+ @XmlElement
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @XmlElement
+ public String getLable() {
+ return lable;
+ }
+
+ public void setLable(String lable) {
+ this.lable = lable;
+ }
+@XmlElement
+ public ParamTypeEnum getParamType() {
+ return paramType;
+ }
+
+ public void setParamType(ParamTypeEnum paramType) {
+ this.paramType = paramType;
+ }
+ @XmlElement
+ public String getValueSeperator() {
+ return valueSeperator;
+ }
+
+ public void setValueSeperator(String valueSeperator) {
+ this.valueSeperator = valueSeperator;
+ }
+ @XmlElement
+ public String getFieldSeperator() {
+ return fieldSeperator;
+ }
+
+ public void setFieldSeperator(String fieldSeperator) {
+ this.fieldSeperator = fieldSeperator;
+ }
+ @XmlElement
+ public Set getMethodParamProperties() {
+ return methodParamProperties;
+ }
+
+ public void setMethodParamProperties(
+ Set methodParamProperties) {
+ this.methodParamProperties = methodParamProperties;
+ }
+
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamPropertyModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamPropertyModel.java
index f849f35b..c9d3e67a 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamPropertyModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/MethodParamPropertyModel.java
@@ -1,30 +1,30 @@
-package org.bench4q.share.models.master.plugin;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class MethodParamPropertyModel {
-
- private String key;
- private String value;
-
- @XmlElement
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- @XmlElement
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class MethodParamPropertyModel {
+
+ private String key;
+ private String value;
+
+ @XmlElement
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ @XmlElement
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeEnum.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeEnum.java
index 5e775171..ed9c38ac 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeEnum.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeEnum.java
@@ -1,6 +1,6 @@
-package org.bench4q.share.models.master.plugin;
-
-public enum ParamTypeEnum {
- Field, MultiField, CheckBox, Table
-
-}
+package org.bench4q.share.models.master.plugin;
+
+public enum ParamTypeEnum {
+ Field, MultiField, CheckBox, Table
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginGUI.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginGUI.java
index 3d2e6f2e..a0acebce 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginGUI.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginGUI.java
@@ -1,18 +1,18 @@
-package org.bench4q.share.models.master.plugin;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class PluginGUI {
-
- private PluginModel plugin;
- @XmlElement
- public PluginModel getPlugin() {
- return plugin;
- }
- public void setPlugin(PluginModel plugin) {
- this.plugin = plugin;
- }
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class PluginGUI {
+
+ private PluginModel plugin;
+ @XmlElement
+ public PluginModel getPlugin() {
+ return plugin;
+ }
+ public void setPlugin(PluginModel plugin) {
+ this.plugin = plugin;
+ }
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginModel.java
index 41149810..5a52dcb3 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginModel.java
@@ -1,33 +1,33 @@
-package org.bench4q.share.models.master.plugin;
-
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class PluginModel {
- private Set methods;
- private String name;
-
- @XmlElementWrapper(name = "methods")
- @XmlElement(name = "method", type = MethodModel.class)
- public Set getMethods() {
- return methods;
- }
-
- public void setMethods(Set methods) {
- this.methods = methods;
- }
-
- @XmlElement
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class PluginModel {
+ private Set methods;
+ private String name;
+
+ @XmlElementWrapper(name = "methods")
+ @XmlElement(name = "method", type = MethodModel.class)
+ public Set getMethods() {
+ return methods;
+ }
+
+ public void setMethods(Set methods) {
+ this.methods = methods;
+ }
+
+ @XmlElement
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginResponseModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginResponseModel.java
index a79617f1..10138845 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginResponseModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/PluginResponseModel.java
@@ -1,78 +1,78 @@
-package org.bench4q.share.models.master.plugin;
-
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class PluginResponseModel {
-
- private boolean success;
- private List pluginList;
- private List methodList;
- private Set methosMethodParamModels;
- private String failMessage;
- private Set methodModels;
-
- @XmlElement
- public boolean isSuccess() {
- return success;
- }
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-
- @XmlElement
- public List getPluginList() {
- return pluginList;
- }
-
- public void setPluginList(List pluginList) {
- this.pluginList = pluginList;
- }
-
- @XmlElement
- public List getMethodList() {
- return methodList;
- }
-
- public void setMethodList(List methodList) {
- this.methodList = methodList;
- }
-
- @XmlElementWrapper(name = "methodParamList")
- @XmlElement(name = "methodParam", type = MethodParamModel.class)
- public Set getMethosMethodParamModels() {
- return methosMethodParamModels;
- }
-
- public void setMethosMethodParamModels(
- Set methosMethodParamModels) {
- this.methosMethodParamModels = methosMethodParamModels;
- }
-
- @XmlElement
- public String getFailMessage() {
- return failMessage;
- }
-
- public void setFailMessage(String failMessage) {
- this.failMessage = failMessage;
- }
-
- @XmlElementWrapper(name = "methods")
- @XmlElement
- public Set getMethodModels() {
- return methodModels;
- }
-
- public void setMethodModels(Set methodModels) {
- this.methodModels = methodModels;
- }
-
-
-}
+package org.bench4q.share.models.master.plugin;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class PluginResponseModel {
+
+ private boolean success;
+ private List pluginList;
+ private List methodList;
+ private Set methosMethodParamModels;
+ private String failMessage;
+ private Set methodModels;
+
+ @XmlElement
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ @XmlElement
+ public List getPluginList() {
+ return pluginList;
+ }
+
+ public void setPluginList(List pluginList) {
+ this.pluginList = pluginList;
+ }
+
+ @XmlElement
+ public List getMethodList() {
+ return methodList;
+ }
+
+ public void setMethodList(List methodList) {
+ this.methodList = methodList;
+ }
+
+ @XmlElementWrapper(name = "methodParamList")
+ @XmlElement(name = "methodParam", type = MethodParamModel.class)
+ public Set getMethosMethodParamModels() {
+ return methosMethodParamModels;
+ }
+
+ public void setMethosMethodParamModels(
+ Set methosMethodParamModels) {
+ this.methosMethodParamModels = methosMethodParamModels;
+ }
+
+ @XmlElement
+ public String getFailMessage() {
+ return failMessage;
+ }
+
+ public void setFailMessage(String failMessage) {
+ this.failMessage = failMessage;
+ }
+
+ @XmlElementWrapper(name = "methods")
+ @XmlElement
+ public Set getMethodModels() {
+ return methodModels;
+ }
+
+ public void setMethodModels(Set methodModels) {
+ this.methodModels = methodModels;
+ }
+
+
+}
diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/statistics/ScriptResultModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/statistics/ScriptResultModel.java
index 29a16ea0..0ed9123a 100644
--- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/statistics/ScriptResultModel.java
+++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/statistics/ScriptResultModel.java
@@ -1,73 +1,73 @@
-package org.bench4q.share.models.master.statistics;
-
-import java.util.Date;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class ScriptResultModel extends SampleModel {
-
- private ScriptBriefResultModel scriptBriefResultModel;
- private ScriptBehaviorsBriefModel scriptBehaviorsBriefModel;
- private ScriptPagesBriefModel scriptPagesBriefModel;
-
- @XmlElement
- public ScriptBriefResultModel getScriptBriefResultModel() {
- return scriptBriefResultModel;
- }
-
- public void setScriptBriefResultModel(
- ScriptBriefResultModel scriptBriefResultModel) {
- this.scriptBriefResultModel = scriptBriefResultModel;
- }
-
- @XmlElement
- public ScriptBehaviorsBriefModel getScriptBehaviorsBriefModel() {
- return scriptBehaviorsBriefModel;
- }
-
- public void setScriptBehaviorsBriefModel(
- ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) {
- this.scriptBehaviorsBriefModel = scriptBehaviorsBriefModel;
- }
-
- @XmlElement
- public ScriptPagesBriefModel getScriptPagesBriefModel() {
- return scriptPagesBriefModel;
- }
-
- public void setScriptPagesBriefModel(
- ScriptPagesBriefModel scriptPagesBriefModel) {
- this.scriptPagesBriefModel = scriptPagesBriefModel;
- }
-
- public static ScriptResultModel buildFinishedResult() {
- ScriptResultModel result = new ScriptResultModel();
- result.setScriptBehaviorsBriefModel(buildFinishedBehaviors());
- result.setScriptBriefResultModel(buildFinishedScenario());
- result.setScriptPagesBriefModel(buildFinishedPages());
- return result;
- }
-
- private static ScriptPagesBriefModel buildFinishedPages() {
- ScriptPagesBriefModel result = new ScriptPagesBriefModel();
- result.setFinished(true);
- result.setSamplingTime(new Date());
- return result;
- }
-
- private static ScriptBriefResultModel buildFinishedScenario() {
- ScriptBriefResultModel result = new ScriptBriefResultModel();
- result.setSamplingTime(new Date());
- result.setFinished(true);
- return result;
- }
-
- private static ScriptBehaviorsBriefModel buildFinishedBehaviors() {
- ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel();
- result.setSamplingTime(new Date());
- result.setFinished(true);
- return result;
- }
-}
+package org.bench4q.share.models.master.statistics;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ScriptResultModel extends SampleModel {
+
+ private ScriptBriefResultModel scriptBriefResultModel;
+ private ScriptBehaviorsBriefModel scriptBehaviorsBriefModel;
+ private ScriptPagesBriefModel scriptPagesBriefModel;
+
+ @XmlElement
+ public ScriptBriefResultModel getScriptBriefResultModel() {
+ return scriptBriefResultModel;
+ }
+
+ public void setScriptBriefResultModel(
+ ScriptBriefResultModel scriptBriefResultModel) {
+ this.scriptBriefResultModel = scriptBriefResultModel;
+ }
+
+ @XmlElement
+ public ScriptBehaviorsBriefModel getScriptBehaviorsBriefModel() {
+ return scriptBehaviorsBriefModel;
+ }
+
+ public void setScriptBehaviorsBriefModel(
+ ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) {
+ this.scriptBehaviorsBriefModel = scriptBehaviorsBriefModel;
+ }
+
+ @XmlElement
+ public ScriptPagesBriefModel getScriptPagesBriefModel() {
+ return scriptPagesBriefModel;
+ }
+
+ public void setScriptPagesBriefModel(
+ ScriptPagesBriefModel scriptPagesBriefModel) {
+ this.scriptPagesBriefModel = scriptPagesBriefModel;
+ }
+
+ public static ScriptResultModel buildFinishedResult() {
+ ScriptResultModel result = new ScriptResultModel();
+ result.setScriptBehaviorsBriefModel(buildFinishedBehaviors());
+ result.setScriptBriefResultModel(buildFinishedScenario());
+ result.setScriptPagesBriefModel(buildFinishedPages());
+ return result;
+ }
+
+ private static ScriptPagesBriefModel buildFinishedPages() {
+ ScriptPagesBriefModel result = new ScriptPagesBriefModel();
+ result.setFinished(true);
+ result.setSamplingTime(new Date());
+ return result;
+ }
+
+ private static ScriptBriefResultModel buildFinishedScenario() {
+ ScriptBriefResultModel result = new ScriptBriefResultModel();
+ result.setSamplingTime(new Date());
+ result.setFinished(true);
+ return result;
+ }
+
+ private static ScriptBehaviorsBriefModel buildFinishedBehaviors() {
+ ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel();
+ result.setSamplingTime(new Date());
+ result.setFinished(true);
+ return result;
+ }
+}
diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptActionController.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptActionController.java
index 69ce7d47..551158bb 100644
--- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptActionController.java
+++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptActionController.java
@@ -1,432 +1,432 @@
-package org.bench4q.web.api;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.bind.JAXBException;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import org.apache.log4j.Logger;
-import org.bench4q.share.helper.ExceptionLog;
-import org.bench4q.share.helper.MarshalHelper;
-import org.bench4q.share.models.agent.RunScenarioModel;
-import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
-import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
-import org.bench4q.share.models.master.OperateScriptServerResponseModel;
-import org.bench4q.share.models.master.PluginEditScriptRequestModel;
-import org.bench4q.share.models.master.ScriptModel;
-import org.bench4q.web.exception.CustomGenericException;
-import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
-import org.bench4q.web.model.BaseResponseModel;
-import org.bench4q.web.service.BaseService;
-import org.bench4q.web.service.ScriptService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.ModelAttribute;
-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.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.SessionAttributes;
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
-import org.xml.sax.SAXException;
-
-import com.google.gson.Gson;
-
-@Controller
-@SessionAttributes("accessToken")
-public class ScriptActionController {
-
- private final String baseUrl = "RecordScript";
- private ScriptService scriptService;
- private final String BASECALLER = "ScriptActionController:";
-
- private String getBaseUrl() {
- return baseUrl;
- }
-
- private ScriptService getScriptService() {
- return scriptService;
- }
-
- @Autowired
- private void setScriptService(ScriptService scriptService) {
- this.scriptService = scriptService;
- }
-
- @RequestMapping("loadScript")
- public @ResponseBody
- BaseResponseModel loadScript(
- @ModelAttribute("accessToken") String accessToken)
- throws CustomGenericException {
- String caller = "ScriptActionController:loadScripts";
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken,
- this.getBaseUrl() + "/loadScriptList",
- OperateScriptServerResponseModel.class, null, caller);
-
- if (operateScriptServerResponseModel.isSuccess()) {
- List scripts = operateScriptServerResponseModel
- .getScriptModels();
- if (scripts == null)
- scripts = new ArrayList();
- return new BaseResponseModel(true, scripts);
- } else {
-
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- }
-
- }
-
- @RequestMapping("deleteScript")
- public @ResponseBody
- BaseResponseModel deletescript(
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam String scriptId) throws CustomGenericException {
- String caller = new String("ScriptActionComntroller:deleteScript");
- String url = this.getBaseUrl() + "/deleteScript";
- Map params = BaseService.makeParamsMap("scriptId",
- scriptId);
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken, url,
- OperateScriptServerResponseModel.class, params, caller);
- if (operateScriptServerResponseModel.isSuccess()) {
- return new BaseResponseModel(true);
- } else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- }
-
- @RequestMapping("editScript")
- public @ResponseBody
- BaseResponseModel editScript(HttpServletRequest request,
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam String scriptId) throws CustomGenericException,
- JAXBException {
- String caller = this.BASECALLER + "editScript";
- String url = this.getBaseUrl() + "/queryScriptById";
- Map params = BaseService.makeParamsMap("scriptId",
- scriptId);
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken, url,
- OperateScriptServerResponseModel.class, params, caller);
-
- /*
- * Logger.getLogger(ScriptActionController.class).info(
- * MarshalHelper.marshal(OperateScriptServerResponseModel.class,
- * operateScriptServerResponseModel));
- */
- if (operateScriptServerResponseModel.isSuccess()) {
- List scripts = operateScriptServerResponseModel
- .getScriptModels();
- if (scripts == null || scripts.isEmpty())
- return new BaseResponseModel(false, "data empty");
- else {
- Iterator it = scripts.iterator();
- ScriptModel script = it.next();
- if (script.getScriptContent() == null
- || script.getScriptContent().isEmpty())
- return new BaseResponseModel(false, "data empty");
- else {
- try {
- RunScenarioModel result = (RunScenarioModel) ObjectXmlExchange
- .fromXml(RunScenarioModel.class,
- script.getScriptContent());
- Gson gson = new Gson();
- String scriptContent = null;
- Logger.getLogger(ScriptActionController.class).info(
- "edit script Before toJson :"
- + script.getScriptContent());
- scriptContent = gson.toJson(result);
- Logger.getLogger(ScriptActionController.class).info(
- "edit script after toJson :" + scriptContent);
- return new BaseResponseModel(true,
- (Object) scriptContent);
- } catch (JAXBException e) {
- throw new CustomGenericException("1",
- "script content is invalidate", caller);
- }
- }
- }
- } else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
-
- }
-
- @RequestMapping("saveEditScript")
- public @ResponseBody
- BaseResponseModel saveEditScript(
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam String scriptId, @RequestParam String script)
- throws CustomGenericException {
- String url = this.getBaseUrl() + "/updateScript"+"/"+scriptId;
- String caller = this.BASECALLER + "saveScript";
- Gson gson = new Gson();
- RunScenarioModel scriptModel = gson.fromJson(script,
- RunScenarioModel.class);
- try {
- String scriptContent = ObjectXmlExchange.toXml(
- RunScenarioModel.class, scriptModel);
-
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModelByPut(accessToken, url,scriptContent,
- OperateScriptServerResponseModel.class,
- caller);
- if (operateScriptServerResponseModel.isSuccess()) {
- return new BaseResponseModel(true);
- } else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- } catch (JAXBException e) {
- return new BaseResponseModel(false, e.getMessage());
- }
- }
-
- @RequestMapping("startRecordServer")
- public @ResponseBody
- BaseResponseModel startRecordServer(
- @ModelAttribute("accessToken") String accessToken)
- throws JAXBException, CustomGenericException {
- String url = this.getBaseUrl() + "/startScriptRecordServer";
- String caller = BASECALLER + "startRecordServer";
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken, url,
- OperateScriptServerResponseModel.class, null, caller);
-
- if (operateScriptServerResponseModel.isSuccess())
- return new BaseResponseModel(true, operateScriptServerResponseModel);
- else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- }
-
- @RequestMapping("stopRecordServer")
- public @ResponseBody
- BaseResponseModel stopRecordServer(
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam String port, @RequestParam String fileNameUUID)
- throws CustomGenericException {
- String caller = BASECALLER + "stopeRecordServer";
- String url = this.getBaseUrl() + "/stopScriptRecordServer";
- Map params = BaseService.makeParamsMap("port", port);
- params.put("fileNameUUID", fileNameUUID);
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken, url,
- OperateScriptServerResponseModel.class, params, caller);
- if (operateScriptServerResponseModel.isSuccess())
- return new BaseResponseModel(true);
- else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- }
-
- @RequestMapping("saveRecordScript")
- public @ResponseBody
- BaseResponseModel saveScriptToDB(HttpServletRequest request,
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam String port, @RequestParam String scriptName,
- @RequestParam String fileNameUUID) throws CustomGenericException {
- String caller = BASECALLER + "saveRecordScript";
- String url = this.getBaseUrl() + "/saveScriptToDB";
- Map params = BaseService.makeParamsMap("scriptName",
- scriptName);
- params.put("port", port);
- params.put("fileNameUUID", fileNameUUID);
-
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getScriptService()
- .getCommunicateWithMaster()
- .getResponseModel(accessToken, url,
- OperateScriptServerResponseModel.class, params, caller);
- if (operateScriptServerResponseModel.isSuccess())
- return new BaseResponseModel(true);
- else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
-
- }
-
- @RequestMapping(value = "uploadScript", method = RequestMethod.POST)
- @ResponseBody
- public BaseResponseModel uploadScript(
- @ModelAttribute("accessToken") String accessToken,
- @RequestParam("script") CommonsMultipartFile script,
- @RequestParam String scriptName) throws CustomGenericException {
- if (script.isEmpty()) {
- return new BaseResponseModel(false, "empty file");
- }
- if (scriptName == null || scriptName.equals(""))
- return new BaseResponseModel(false, "empty file name");
- try {
- String scenarioModel = new String(script.getBytes());
- MarshalHelper.unmarshal(RunScenarioModel.class, scenarioModel);
- OperateScriptServerResponseModel operateScriptServerResponseModel = this
- .getScriptService().uploadScript(accessToken,
- scenarioModel, scriptName);
- Logger.getLogger(ScriptActionController.class).info(
- "script:" + scenarioModel);
- if (operateScriptServerResponseModel.isSuccess())
- return new BaseResponseModel(true, (Object) new String(
- "upload script:" + scriptName + " success!"));
-
- else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- } catch (JAXBException e) {
- Logger.getLogger(ScriptActionController.class).info(
- ExceptionLog.getStackTrace(e));
- return new BaseResponseModel(false,
- "Failed:invalidated script file!");
- }
-
- }
-
- @RequestMapping("validateScript")
- public @ResponseBody
- String validateScript(@ModelAttribute("accessToken") String accessToken,
- @RequestParam String content) {
- String result;
- String message = "";
- String schemaFileName = "src/main/webapp/WEB-INF/validateScript.xsd";
- content = content.replace("runScenario", "runscenario")
- .replace("poolSize", "poolsize")
- .replace("usePlugin", "useplugin")
- .replace("userBehavior", "userbehavior")
- .replace("timerBehavior", "timerbehavior")
- .replace("userbehaviors", "behaviors");
- try {
- result = validateXmlWithSchema(schemaFileName, content);
- if (result == "true") {
- message = "Success";
- } else {
- message = URLEncoder.encode(result, "UTF-8").replace("+", "");
- }
- } catch (Exception e) {
- System.out.println("analysis of failure:" + e.toString());
- message = "failed to read schema file";
- }
- // System.out.println(message);
- return message;
- }
-
- private String validateXmlWithSchema(String schemaFileName, String xmlScript)
- throws SAXException, IOException {
- String validationResult = "";
- SchemaFactory schemaFactory = SchemaFactory
- .newInstance("http://www.w3.org/2001/XMLSchema");
- File schemaFile = new File(schemaFileName);
- Schema schema = schemaFactory.newSchema(schemaFile);
- Validator validator = schema.newValidator();
- InputStream script = new ByteArrayInputStream(xmlScript.getBytes());
- Source source = new StreamSource(script);
- try {
- // System.out.println("enter validateXmlWithSchema");
- validator.validate(source);
- validationResult = "true";
- } catch (Exception ex) {
- validationResult = ex.toString();
- }
- return validationResult;
- }
-
- @RequestMapping("readSchemaContent")
- public @ResponseBody
- String readSchemaContent() throws Exception {
- String schema = "";
- FileReader fr = new FileReader("src/main/webapp/WEB-INF/schema.json");
- BufferedReader br = new BufferedReader(fr);
- StringBuilder sb = new StringBuilder();
- while ((schema = br.readLine()) != null) {
- sb.append(schema);
- }
- br.close();
- String str = sb.toString();
- return str;
- }
-
- @RequestMapping(value = "uploadPluginEditedScript", method = RequestMethod.POST)
- @ResponseBody
- public BaseResponseModel uploadPluginEditedScript(
- @ModelAttribute("accessToken") String accessToken,
- @RequestBody String content) throws CustomGenericException {
- Gson gson = new Gson();
- Logger.getLogger(ScriptActionController.class).info(content);
- PluginEditScriptRequestModel pluginEditScriptRequestModel = null;
- try {
- pluginEditScriptRequestModel = gson.fromJson(content,
- PluginEditScriptRequestModel.class);
- } catch (Exception e) {
- Logger.getLogger(ScriptActionController.class).info(
- ExceptionLog.getStackTrace(e));
- }
- List behaviorModelsList = pluginEditScriptRequestModel
- .getBehaviorModels();
- List usePluginModelsList = pluginEditScriptRequestModel
- .getUsePluginModels();
- String scriptName = pluginEditScriptRequestModel.getScriptName();
- if (!validateScript(behaviorModelsList, usePluginModelsList))
- return new BaseResponseModel(false, "invalidate script");
- RunScenarioModel runScenarioModel = this
- .getScriptService()
- .createRunScenarioModel(behaviorModelsList, usePluginModelsList);
- try {
- String script = ObjectXmlExchange.toXml(RunScenarioModel.class,
- runScenarioModel);
-
- OperateScriptServerResponseModel operateScriptServerResponseModel = this
- .getScriptService().uploadScript(accessToken, script,
- scriptName);
- if (operateScriptServerResponseModel.isSuccess())
- return new BaseResponseModel(true, (Object) new String(
- "upload script:" + scriptName + " success!"));
-
- else
- return new BaseResponseModel(false,
- operateScriptServerResponseModel.getFailCauseString());
- } catch (JAXBException e) {
- return new BaseResponseModel(false,
- "Failed:invalidated script file!");
- }
-
- }
-
- private boolean validateScript(List behaviorModels,
- List usePluginModels) {
-
- if (behaviorModels == null || behaviorModels.size() == 0)
- return false;
- if (usePluginModels == null || usePluginModels.size() == 0)
- return false;
- return true;
- }
-
-}
+package org.bench4q.web.api;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.bind.JAXBException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.apache.log4j.Logger;
+import org.bench4q.share.helper.ExceptionLog;
+import org.bench4q.share.helper.MarshalHelper;
+import org.bench4q.share.models.agent.RunScenarioModel;
+import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
+import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
+import org.bench4q.share.models.master.OperateScriptServerResponseModel;
+import org.bench4q.share.models.master.PluginEditScriptRequestModel;
+import org.bench4q.share.models.master.ScriptModel;
+import org.bench4q.web.exception.CustomGenericException;
+import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
+import org.bench4q.web.model.BaseResponseModel;
+import org.bench4q.web.service.BaseService;
+import org.bench4q.web.service.ScriptService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+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.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.SessionAttributes;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+import org.xml.sax.SAXException;
+
+import com.google.gson.Gson;
+
+@Controller
+@SessionAttributes("accessToken")
+public class ScriptActionController {
+
+ private final String baseUrl = "RecordScript";
+ private ScriptService scriptService;
+ private final String BASECALLER = "ScriptActionController:";
+
+ private String getBaseUrl() {
+ return baseUrl;
+ }
+
+ private ScriptService getScriptService() {
+ return scriptService;
+ }
+
+ @Autowired
+ private void setScriptService(ScriptService scriptService) {
+ this.scriptService = scriptService;
+ }
+
+ @RequestMapping("loadScript")
+ public @ResponseBody
+ BaseResponseModel loadScript(
+ @ModelAttribute("accessToken") String accessToken)
+ throws CustomGenericException {
+ String caller = "ScriptActionController:loadScripts";
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken,
+ this.getBaseUrl() + "/loadScriptList",
+ OperateScriptServerResponseModel.class, null, caller);
+
+ if (operateScriptServerResponseModel.isSuccess()) {
+ List scripts = operateScriptServerResponseModel
+ .getScriptModels();
+ if (scripts == null)
+ scripts = new ArrayList();
+ return new BaseResponseModel(true, scripts);
+ } else {
+
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ }
+
+ }
+
+ @RequestMapping("deleteScript")
+ public @ResponseBody
+ BaseResponseModel deletescript(
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam String scriptId) throws CustomGenericException {
+ String caller = new String("ScriptActionComntroller:deleteScript");
+ String url = this.getBaseUrl() + "/deleteScript";
+ Map params = BaseService.makeParamsMap("scriptId",
+ scriptId);
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken, url,
+ OperateScriptServerResponseModel.class, params, caller);
+ if (operateScriptServerResponseModel.isSuccess()) {
+ return new BaseResponseModel(true);
+ } else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ }
+
+ @RequestMapping("editScript")
+ public @ResponseBody
+ BaseResponseModel editScript(HttpServletRequest request,
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam String scriptId) throws CustomGenericException,
+ JAXBException {
+ String caller = this.BASECALLER + "editScript";
+ String url = this.getBaseUrl() + "/queryScriptById";
+ Map params = BaseService.makeParamsMap("scriptId",
+ scriptId);
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken, url,
+ OperateScriptServerResponseModel.class, params, caller);
+
+ /*
+ * Logger.getLogger(ScriptActionController.class).info(
+ * MarshalHelper.marshal(OperateScriptServerResponseModel.class,
+ * operateScriptServerResponseModel));
+ */
+ if (operateScriptServerResponseModel.isSuccess()) {
+ List scripts = operateScriptServerResponseModel
+ .getScriptModels();
+ if (scripts == null || scripts.isEmpty())
+ return new BaseResponseModel(false, "data empty");
+ else {
+ Iterator it = scripts.iterator();
+ ScriptModel script = it.next();
+ if (script.getScriptContent() == null
+ || script.getScriptContent().isEmpty())
+ return new BaseResponseModel(false, "data empty");
+ else {
+ try {
+ RunScenarioModel result = (RunScenarioModel) ObjectXmlExchange
+ .fromXml(RunScenarioModel.class,
+ script.getScriptContent());
+ Gson gson = new Gson();
+ String scriptContent = null;
+ Logger.getLogger(ScriptActionController.class).info(
+ "edit script Before toJson :"
+ + script.getScriptContent());
+ scriptContent = gson.toJson(result);
+ Logger.getLogger(ScriptActionController.class).info(
+ "edit script after toJson :" + scriptContent);
+ return new BaseResponseModel(true,
+ (Object) scriptContent);
+ } catch (JAXBException e) {
+ throw new CustomGenericException("1",
+ "script content is invalidate", caller);
+ }
+ }
+ }
+ } else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+
+ }
+
+ @RequestMapping("saveEditScript")
+ public @ResponseBody
+ BaseResponseModel saveEditScript(
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam String scriptId, @RequestParam String script)
+ throws CustomGenericException {
+ String url = this.getBaseUrl() + "/updateScript"+"/"+scriptId;
+ String caller = this.BASECALLER + "saveScript";
+ Gson gson = new Gson();
+ RunScenarioModel scriptModel = gson.fromJson(script,
+ RunScenarioModel.class);
+ try {
+ String scriptContent = ObjectXmlExchange.toXml(
+ RunScenarioModel.class, scriptModel);
+
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModelByPut(accessToken, url,scriptContent,
+ OperateScriptServerResponseModel.class,
+ caller);
+ if (operateScriptServerResponseModel.isSuccess()) {
+ return new BaseResponseModel(true);
+ } else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ } catch (JAXBException e) {
+ return new BaseResponseModel(false, e.getMessage());
+ }
+ }
+
+ @RequestMapping("startRecordServer")
+ public @ResponseBody
+ BaseResponseModel startRecordServer(
+ @ModelAttribute("accessToken") String accessToken)
+ throws JAXBException, CustomGenericException {
+ String url = this.getBaseUrl() + "/startScriptRecordServer";
+ String caller = BASECALLER + "startRecordServer";
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken, url,
+ OperateScriptServerResponseModel.class, null, caller);
+
+ if (operateScriptServerResponseModel.isSuccess())
+ return new BaseResponseModel(true, operateScriptServerResponseModel);
+ else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ }
+
+ @RequestMapping("stopRecordServer")
+ public @ResponseBody
+ BaseResponseModel stopRecordServer(
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam String port, @RequestParam String fileNameUUID)
+ throws CustomGenericException {
+ String caller = BASECALLER + "stopeRecordServer";
+ String url = this.getBaseUrl() + "/stopScriptRecordServer";
+ Map params = BaseService.makeParamsMap("port", port);
+ params.put("fileNameUUID", fileNameUUID);
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken, url,
+ OperateScriptServerResponseModel.class, params, caller);
+ if (operateScriptServerResponseModel.isSuccess())
+ return new BaseResponseModel(true);
+ else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ }
+
+ @RequestMapping("saveRecordScript")
+ public @ResponseBody
+ BaseResponseModel saveScriptToDB(HttpServletRequest request,
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam String port, @RequestParam String scriptName,
+ @RequestParam String fileNameUUID) throws CustomGenericException {
+ String caller = BASECALLER + "saveRecordScript";
+ String url = this.getBaseUrl() + "/saveScriptToDB";
+ Map params = BaseService.makeParamsMap("scriptName",
+ scriptName);
+ params.put("port", port);
+ params.put("fileNameUUID", fileNameUUID);
+
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getScriptService()
+ .getCommunicateWithMaster()
+ .getResponseModel(accessToken, url,
+ OperateScriptServerResponseModel.class, params, caller);
+ if (operateScriptServerResponseModel.isSuccess())
+ return new BaseResponseModel(true);
+ else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+
+ }
+
+ @RequestMapping(value = "uploadScript", method = RequestMethod.POST)
+ @ResponseBody
+ public BaseResponseModel uploadScript(
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestParam("script") CommonsMultipartFile script,
+ @RequestParam String scriptName) throws CustomGenericException {
+ if (script.isEmpty()) {
+ return new BaseResponseModel(false, "empty file");
+ }
+ if (scriptName == null || scriptName.equals(""))
+ return new BaseResponseModel(false, "empty file name");
+ try {
+ String scenarioModel = new String(script.getBytes());
+ MarshalHelper.unmarshal(RunScenarioModel.class, scenarioModel);
+ OperateScriptServerResponseModel operateScriptServerResponseModel = this
+ .getScriptService().uploadScript(accessToken,
+ scenarioModel, scriptName);
+ Logger.getLogger(ScriptActionController.class).info(
+ "script:" + scenarioModel);
+ if (operateScriptServerResponseModel.isSuccess())
+ return new BaseResponseModel(true, (Object) new String(
+ "upload script:" + scriptName + " success!"));
+
+ else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ } catch (JAXBException e) {
+ Logger.getLogger(ScriptActionController.class).info(
+ ExceptionLog.getStackTrace(e));
+ return new BaseResponseModel(false,
+ "Failed:invalidated script file!");
+ }
+
+ }
+
+ @RequestMapping("validateScript")
+ public @ResponseBody
+ String validateScript(@ModelAttribute("accessToken") String accessToken,
+ @RequestParam String content) {
+ String result;
+ String message = "";
+ String schemaFileName = "src/main/webapp/WEB-INF/validateScript.xsd";
+ content = content.replace("runScenario", "runscenario")
+ .replace("poolSize", "poolsize")
+ .replace("usePlugin", "useplugin")
+ .replace("userBehavior", "userbehavior")
+ .replace("timerBehavior", "timerbehavior")
+ .replace("userbehaviors", "behaviors");
+ try {
+ result = validateXmlWithSchema(schemaFileName, content);
+ if (result == "true") {
+ message = "Success";
+ } else {
+ message = URLEncoder.encode(result, "UTF-8").replace("+", "");
+ }
+ } catch (Exception e) {
+ System.out.println("analysis of failure:" + e.toString());
+ message = "failed to read schema file";
+ }
+ // System.out.println(message);
+ return message;
+ }
+
+ private String validateXmlWithSchema(String schemaFileName, String xmlScript)
+ throws SAXException, IOException {
+ String validationResult = "";
+ SchemaFactory schemaFactory = SchemaFactory
+ .newInstance("http://www.w3.org/2001/XMLSchema");
+ File schemaFile = new File(schemaFileName);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ InputStream script = new ByteArrayInputStream(xmlScript.getBytes());
+ Source source = new StreamSource(script);
+ try {
+ // System.out.println("enter validateXmlWithSchema");
+ validator.validate(source);
+ validationResult = "true";
+ } catch (Exception ex) {
+ validationResult = ex.toString();
+ }
+ return validationResult;
+ }
+
+ @RequestMapping("readSchemaContent")
+ public @ResponseBody
+ String readSchemaContent() throws Exception {
+ String schema = "";
+ FileReader fr = new FileReader("src/main/webapp/WEB-INF/schema.json");
+ BufferedReader br = new BufferedReader(fr);
+ StringBuilder sb = new StringBuilder();
+ while ((schema = br.readLine()) != null) {
+ sb.append(schema);
+ }
+ br.close();
+ String str = sb.toString();
+ return str;
+ }
+
+ @RequestMapping(value = "uploadPluginEditedScript", method = RequestMethod.POST)
+ @ResponseBody
+ public BaseResponseModel uploadPluginEditedScript(
+ @ModelAttribute("accessToken") String accessToken,
+ @RequestBody String content) throws CustomGenericException {
+ Gson gson = new Gson();
+ Logger.getLogger(ScriptActionController.class).info(content);
+ PluginEditScriptRequestModel pluginEditScriptRequestModel = null;
+ try {
+ pluginEditScriptRequestModel = gson.fromJson(content,
+ PluginEditScriptRequestModel.class);
+ } catch (Exception e) {
+ Logger.getLogger(ScriptActionController.class).info(
+ ExceptionLog.getStackTrace(e));
+ }
+ List behaviorModelsList = pluginEditScriptRequestModel
+ .getBehaviorModels();
+ List usePluginModelsList = pluginEditScriptRequestModel
+ .getUsePluginModels();
+ String scriptName = pluginEditScriptRequestModel.getScriptName();
+ if (!validateScript(behaviorModelsList, usePluginModelsList))
+ return new BaseResponseModel(false, "invalidate script");
+ RunScenarioModel runScenarioModel = this
+ .getScriptService()
+ .createRunScenarioModel(behaviorModelsList, usePluginModelsList);
+ try {
+ String script = ObjectXmlExchange.toXml(RunScenarioModel.class,
+ runScenarioModel);
+
+ OperateScriptServerResponseModel operateScriptServerResponseModel = this
+ .getScriptService().uploadScript(accessToken, script,
+ scriptName);
+ if (operateScriptServerResponseModel.isSuccess())
+ return new BaseResponseModel(true, (Object) new String(
+ "upload script:" + scriptName + " success!"));
+
+ else
+ return new BaseResponseModel(false,
+ operateScriptServerResponseModel.getFailCauseString());
+ } catch (JAXBException e) {
+ return new BaseResponseModel(false,
+ "Failed:invalidated script file!");
+ }
+
+ }
+
+ private boolean validateScript(List behaviorModels,
+ List usePluginModels) {
+
+ if (behaviorModels == null || behaviorModels.size() == 0)
+ return false;
+ if (usePluginModels == null || usePluginModels.size() == 0)
+ return false;
+ return true;
+ }
+
+}
diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/model/NameAndIdMap.java b/Bench4Q-Web/src/main/java/org/bench4q/web/model/NameAndIdMap.java
index 1ee40773..7cc94085 100644
--- a/Bench4Q-Web/src/main/java/org/bench4q/web/model/NameAndIdMap.java
+++ b/Bench4Q-Web/src/main/java/org/bench4q/web/model/NameAndIdMap.java
@@ -1,29 +1,29 @@
-package org.bench4q.web.model;
-
-public class NameAndIdMap {
- private int id;
- private String name;
-
- public NameAndIdMap(int id, String name) {
- this.id = id;
- this.name = name;
-
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
+package org.bench4q.web.model;
+
+public class NameAndIdMap {
+ private int id;
+ private String name;
+
+ public NameAndIdMap(int id, String name) {
+ this.id = id;
+ this.name = name;
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/service/ScriptService.java b/Bench4Q-Web/src/main/java/org/bench4q/web/service/ScriptService.java
index b31f2e55..4344adbc 100644
--- a/Bench4Q-Web/src/main/java/org/bench4q/web/service/ScriptService.java
+++ b/Bench4Q-Web/src/main/java/org/bench4q/web/service/ScriptService.java
@@ -1,311 +1,311 @@
-package org.bench4q.web.service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBException;
-
-import org.bench4q.share.models.agent.ParameterModel;
-import org.bench4q.share.models.agent.RunScenarioModel;
-import org.bench4q.share.models.agent.scriptrecord.BatchModel;
-import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
-import org.bench4q.share.models.agent.scriptrecord.PageModel;
-import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
-import org.bench4q.share.models.master.OperateScriptServerResponseModel;
-import org.bench4q.share.models.master.ScriptModel;
-import org.bench4q.web.exception.CustomGenericException;
-import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
-import org.bench4q.web.model.NameAndIdMap;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ScriptService extends BaseService {
- private String baseUrl = "RecordScript";
-
- public String getBaseUrl() {
- return baseUrl;
- }
-
- public void setBaseUrl(String baseUrl) {
- this.baseUrl = baseUrl;
- }
-
- public ScriptModel queryScriptById(int id, String accessToken)
- throws CustomGenericException {
- // check script id and return throw exception
- String caller = "ScriptService:queryScript";
-
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getCommunicateWithMaster().getResponseModel(accessToken,
- this.getBaseUrl() + "/queryScriptById",
- OperateScriptServerResponseModel.class,
- makeParamsMap("scriptId", String.valueOf(id)), caller);
- if (operateScriptServerResponseModel.isSuccess())
- return operateScriptServerResponseModel.getScriptModels().get(0);
- else
- throw new CustomGenericException("5", "query script failed", caller
- + ":" + id);
- }
-
- public ScriptModel queryScriptByName(String scriptName, String accessToken)
- throws CustomGenericException {
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getCommunicateWithMaster().getResponseModel(accessToken,
- this.getBaseUrl() + "/queryScriptByName",
- OperateScriptServerResponseModel.class,
- makeParamsMap("name", scriptName), "");
- if (operateScriptServerResponseModel.isSuccess())
- return operateScriptServerResponseModel.getScriptModels().get(0);
- else
- throw new CustomGenericException("5", "query script failed", ""
- + ":" + scriptName);
- }
-
- public List queryScripts(List scriptIds,
- String accessToken) throws CustomGenericException {
- String caller = "ScriptService:queryScript";
- List scriptModels = new ArrayList();
- for (Integer scriptId : scriptIds) {
- OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
- .getCommunicateWithMaster()
- .getResponseModel(
- accessToken,
- this.getBaseUrl() + "/queryScriptById",
- OperateScriptServerResponseModel.class,
- makeParamsMap("scriptId", String.valueOf(scriptId)),
- caller);
- if (operateScriptServerResponseModel.isSuccess())
- scriptModels.add(operateScriptServerResponseModel
- .getScriptModels().get(0));
- else
- throw new CustomGenericException("5", "query script failed",
- caller + ":" + scriptId);
- }
- return scriptModels;
- }
-
- public Map getScriptNameIdMap(
- List scriptModels) throws CustomGenericException {
- Map map = new HashMap();
- for (ScriptModel scriptModel : scriptModels) {
- map.put(scriptModel.getName(), scriptModel.getId());
- }
- return map;
- }
-
- public List getScriptIdNameMap(List scriptModels)
- throws CustomGenericException {
- List nameAndIdMaps = new ArrayList();
- for (ScriptModel scriptModel : scriptModels) {
- NameAndIdMap nameAndIdMap = new NameAndIdMap(scriptModel.getId(),
- scriptModel.getName());
- nameAndIdMaps.add(nameAndIdMap);
- }
- return nameAndIdMaps;
- }
-
- public Map getPageNameAndIdMap(
- List scriptModels) throws JAXBException {
- try {
- Map map = new HashMap();
- for (ScriptModel scriptModel : scriptModels) {
- Map pageMap = getPageNameAndIdMap((RunScenarioModel) ObjectXmlExchange
- .fromXml(RunScenarioModel.class,
- scriptModel.getScriptContent()));
- if (pageMap != null)
- map.putAll(pageMap);
- }
- return map;
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- private Map getPageNameAndIdMap(
- RunScenarioModel runScenarioModel) {
-
- List pageModels = runScenarioModel.getPages();
- try {
- Map map = new HashMap();
- for (int i = 0; i < pageModels.size(); i++) {
- map.put("page_" + i, i);
- }
- return map;
- } catch (NullPointerException e) {
- return null;
- }
-
- }
-
- public Map getBehaviorNameAndIdMap(
- List scriptModels) throws JAXBException {
- try {
- Map map = new HashMap();
- for (ScriptModel scriptModel : scriptModels) {
- Map behaviorMap = getBehaviorNameAndIdMap((RunScenarioModel) ObjectXmlExchange
- .fromXml(RunScenarioModel.class,
- scriptModel.getScriptContent()));
- if (behaviorMap != null)
- map.putAll(behaviorMap);
- }
- return map;
- } catch (NullPointerException e) {
- return null;
- }
- }
-
- public List getScriptPages(RunScenarioModel runScenarioModel) {
- try {
- List scriptPages = new ArrayList();
- for (int i = 1; i < scriptPages.size(); i++) {
- scriptPages.add("page_" + i);
- }
- return scriptPages;
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public List getScriptBehaviorUrl(RunScenarioModel runScenarioModel) {
-
- List behaviorModelsWithUrl = getBehaviorModelsHasUrl(runScenarioModel);
- if (behaviorModelsWithUrl == null)
- return null;
- List urList = new ArrayList();
- for (BehaviorModel behaviorModelWithUrl : behaviorModelsWithUrl) {
- String url = generateUrl(behaviorModelWithUrl.getParameters());
- urList.add(url);
- }
- return urList;
- }
-
- public Map getBehaviorNameAndIdMap(
- RunScenarioModel runScenarioModel) {
- try {
- Map map = new HashMap();
- List behaviorModels = this
- .getBehaviorModelsHasUrl(runScenarioModel);
- if (behaviorModels == null)
- return null;
- for (BehaviorModel behaviorModel : behaviorModels) {
- String url = this.generateUrl(behaviorModel.getParameters());
- if (url != null)
- map.put(url, behaviorModel.getId());
- }
- return map;
-
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- private String generateUrl(List parameterModels) {
- String url = new String("");
- int i = 0;
- for (ParameterModel parameterModel : parameterModels) {
- if (i == 1 && parameterModel.getValue() != null)
- url += "?" + parameterModel.getValue();
- if (i > 1 && parameterModel.getValue() != null)
- url += "&" + parameterModel.getValue();
- i++;
- }
- if (url.length() <= 0)
- return null;
- return url;
- }
-
- private List getBehaviorModelsHasUrl(
- RunScenarioModel runScenarioModel) {
- try {
-
- List behaviorModels = getBehaviorModels(runScenarioModel);
- if (behaviorModels == null)
- return null;
- List behaviorModelsWithUrl = new ArrayList();
- for (BehaviorModel behaviorModel : behaviorModels) {
- List parameterModels = new ArrayList();
- parameterModels.addAll(behaviorModel.getParameters());
- for (ParameterModel parameterModel : parameterModels) {
- if (parameterModel.getKey().equals("url"))
- behaviorModelsWithUrl.add(behaviorModel);
- break;
- }
- }
-
- return behaviorModelsWithUrl;
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- private List getBehaviorModels(
- RunScenarioModel runScenarioModel) {
- try {
- List batchModels = new ArrayList();
- for (PageModel pageModel : runScenarioModel.getPages())
- batchModels.addAll(pageModel.getBatches());
- List behaviorModels = new ArrayList();
- for (BatchModel batchModel : batchModels)
- behaviorModels.addAll(batchModel.getBehaviors());
- return behaviorModels;
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public RunScenarioModel createRunScenarioModel(
- List behaviorModels,
- List usedPluginModels) {
- RunScenarioModel runScenarioModel = new RunScenarioModel();
- runScenarioModel
- .setPages(createPageModelsWithBehaviorList(behaviorModels));
- runScenarioModel.setUsePlugins(usedPluginModels);
- return runScenarioModel;
- }
-
- private List createPageModelsWithBehaviorList(
- List behaviorModels) {
- List pageModels = new ArrayList();
- for (BehaviorModel behaviorModel : behaviorModels) {
- pageModels.add(createPageModelWithOneBehaviorModel(behaviorModel));
- }
- return pageModels;
-
- }
-
- private PageModel createPageModelWithOneBehaviorModel(
- BehaviorModel behaviorModel) {
- PageModel pageModel = new PageModel();
- pageModel.setBatches(new ArrayList());
- pageModel.getBatches().add(
- createBatchModelWithOneBehavior(behaviorModel));
- return pageModel;
- }
-
- private BatchModel createBatchModelWithOneBehavior(
- BehaviorModel behaviorModel) {
- BatchModel batchModel = new BatchModel();
- batchModel.setBehaviors(new ArrayList());
- batchModel.getBehaviors().add(behaviorModel);
- batchModel.setChildId(-1);
- batchModel.setParentId(-1);
- batchModel.setId(behaviorModel.getId());
- return batchModel;
- }
-
- public OperateScriptServerResponseModel uploadScript(String accessToken,
- String scenarioModel, String scriptName)
- throws CustomGenericException {
- String url = "RecordScript" + "/uploadScript" + "/" + scriptName;
- return (OperateScriptServerResponseModel) getCommunicateWithMaster()
- .getResponseModelByPut(accessToken, url, scenarioModel,
- OperateScriptServerResponseModel.class, "upload script");
- }
-}
+package org.bench4q.web.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBException;
+
+import org.bench4q.share.models.agent.ParameterModel;
+import org.bench4q.share.models.agent.RunScenarioModel;
+import org.bench4q.share.models.agent.scriptrecord.BatchModel;
+import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
+import org.bench4q.share.models.agent.scriptrecord.PageModel;
+import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
+import org.bench4q.share.models.master.OperateScriptServerResponseModel;
+import org.bench4q.share.models.master.ScriptModel;
+import org.bench4q.web.exception.CustomGenericException;
+import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
+import org.bench4q.web.model.NameAndIdMap;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ScriptService extends BaseService {
+ private String baseUrl = "RecordScript";
+
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl;
+ }
+
+ public ScriptModel queryScriptById(int id, String accessToken)
+ throws CustomGenericException {
+ // check script id and return throw exception
+ String caller = "ScriptService:queryScript";
+
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getCommunicateWithMaster().getResponseModel(accessToken,
+ this.getBaseUrl() + "/queryScriptById",
+ OperateScriptServerResponseModel.class,
+ makeParamsMap("scriptId", String.valueOf(id)), caller);
+ if (operateScriptServerResponseModel.isSuccess())
+ return operateScriptServerResponseModel.getScriptModels().get(0);
+ else
+ throw new CustomGenericException("5", "query script failed", caller
+ + ":" + id);
+ }
+
+ public ScriptModel queryScriptByName(String scriptName, String accessToken)
+ throws CustomGenericException {
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getCommunicateWithMaster().getResponseModel(accessToken,
+ this.getBaseUrl() + "/queryScriptByName",
+ OperateScriptServerResponseModel.class,
+ makeParamsMap("name", scriptName), "");
+ if (operateScriptServerResponseModel.isSuccess())
+ return operateScriptServerResponseModel.getScriptModels().get(0);
+ else
+ throw new CustomGenericException("5", "query script failed", ""
+ + ":" + scriptName);
+ }
+
+ public List queryScripts(List scriptIds,
+ String accessToken) throws CustomGenericException {
+ String caller = "ScriptService:queryScript";
+ List scriptModels = new ArrayList();
+ for (Integer scriptId : scriptIds) {
+ OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
+ .getCommunicateWithMaster()
+ .getResponseModel(
+ accessToken,
+ this.getBaseUrl() + "/queryScriptById",
+ OperateScriptServerResponseModel.class,
+ makeParamsMap("scriptId", String.valueOf(scriptId)),
+ caller);
+ if (operateScriptServerResponseModel.isSuccess())
+ scriptModels.add(operateScriptServerResponseModel
+ .getScriptModels().get(0));
+ else
+ throw new CustomGenericException("5", "query script failed",
+ caller + ":" + scriptId);
+ }
+ return scriptModels;
+ }
+
+ public Map getScriptNameIdMap(
+ List scriptModels) throws CustomGenericException {
+ Map map = new HashMap();
+ for (ScriptModel scriptModel : scriptModels) {
+ map.put(scriptModel.getName(), scriptModel.getId());
+ }
+ return map;
+ }
+
+ public List getScriptIdNameMap(List scriptModels)
+ throws CustomGenericException {
+ List nameAndIdMaps = new ArrayList();
+ for (ScriptModel scriptModel : scriptModels) {
+ NameAndIdMap nameAndIdMap = new NameAndIdMap(scriptModel.getId(),
+ scriptModel.getName());
+ nameAndIdMaps.add(nameAndIdMap);
+ }
+ return nameAndIdMaps;
+ }
+
+ public Map getPageNameAndIdMap(
+ List scriptModels) throws JAXBException {
+ try {
+ Map map = new HashMap();
+ for (ScriptModel scriptModel : scriptModels) {
+ Map pageMap = getPageNameAndIdMap((RunScenarioModel) ObjectXmlExchange
+ .fromXml(RunScenarioModel.class,
+ scriptModel.getScriptContent()));
+ if (pageMap != null)
+ map.putAll(pageMap);
+ }
+ return map;
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private Map getPageNameAndIdMap(
+ RunScenarioModel runScenarioModel) {
+
+ List pageModels = runScenarioModel.getPages();
+ try {
+ Map map = new HashMap();
+ for (int i = 0; i < pageModels.size(); i++) {
+ map.put("page_" + i, i);
+ }
+ return map;
+ } catch (NullPointerException e) {
+ return null;
+ }
+
+ }
+
+ public Map getBehaviorNameAndIdMap(
+ List scriptModels) throws JAXBException {
+ try {
+ Map map = new HashMap();
+ for (ScriptModel scriptModel : scriptModels) {
+ Map behaviorMap = getBehaviorNameAndIdMap((RunScenarioModel) ObjectXmlExchange
+ .fromXml(RunScenarioModel.class,
+ scriptModel.getScriptContent()));
+ if (behaviorMap != null)
+ map.putAll(behaviorMap);
+ }
+ return map;
+ } catch (NullPointerException e) {
+ return null;
+ }
+ }
+
+ public List getScriptPages(RunScenarioModel runScenarioModel) {
+ try {
+ List scriptPages = new ArrayList();
+ for (int i = 1; i < scriptPages.size(); i++) {
+ scriptPages.add("page_" + i);
+ }
+ return scriptPages;
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public List getScriptBehaviorUrl(RunScenarioModel runScenarioModel) {
+
+ List behaviorModelsWithUrl = getBehaviorModelsHasUrl(runScenarioModel);
+ if (behaviorModelsWithUrl == null)
+ return null;
+ List urList = new ArrayList