本文整理汇总了Java中org.wisdom.api.annotations.Route类的典型用法代码示例。如果您正苦于以下问题:Java Route类的具体用法?Java Route怎么用?Java Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Route类属于org.wisdom.api.annotations包,在下文中一共展示了Route类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upload
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.POST, uri = "/uploading")
public Result upload() throws IOException {
String cookie = context().cookieValue("token");
for(Session session : coreServerController.getOpenSessionList()) {
if(session.getToken().toString().equalsIgnoreCase(cookie)){
if(!context().files().isEmpty()){
for (FileItem fileItem : context().files()) {
if(fileItem!=null){
byte[] buffer = new byte[8 * 1024];
FileOutputStream out = new FileOutputStream(new File(session.getWorkspaceFolder(),
fileItem.name()));
BufferedInputStream in = new BufferedInputStream(fileItem.stream());
while (in.read(buffer) != -1) {
out.write(buffer);
}
in.close();
out.close();
}
}
}
return ok();
}
}
return badRequest(render(homeContent));
}
示例2: settings
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/user/settings")
public Result settings() {
String token = context().cookieValue("token");
Session session = null;
for(Session s : coreServerController.getOpenSessionList()){
if(s.getToken().toString().equals(token)){
session = s;
}
}
if(session != null) {
return ok(render(userSettings, "session", session));
}
else {
return badRequest("Unexisting session.");
}
}
示例3: database
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/data/database")
public Result database() {
String token = context().cookieValue("token");
Session session = null;
for(Session s : coreServerController.getOpenSessionList()){
if(s.getToken().toString().equals(token)){
session = s;
}
}
if(session != null) {
DatabaseContent dbContent = session.getDatabaseContent();
int maxSize = 0;
for(DatabaseTable dbTable : dbContent.getTableList()){
maxSize = Math.max(maxSize, dbTable.getFieldList().size()+1);
}
return ok(render(databaseView,
"databaseContent", dbContent,
"cell_width_percent", (float)(100)/maxSize));
}
else {
return badRequest("Unexisting session.");
}
}
示例4: createArchive
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/createArchive")
public Result createArchive(@Parameter("jobId") String jobId) {
String token = context().cookieValue("token");
Session session = null;
for(Session s : coreServerController.getOpenSessionList()){
if(s.getToken().toString().equals(token)){
session = s;
}
}
if(session != null) {
File file = session.getResultAchive(jobId);
if(file != null) {
return ok(file, true);
}
return badRequest("Unable to create the result archive.");
}
else{
return badRequest("Unexisting session.");
}
}
示例5: threads
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
/**
* @return information about threads.
*/
@Route(method = HttpMethod.GET, uri = "/threads")
public Result threads() {
ArrayNode array = json.newArray();
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
for (long id : bean.getAllThreadIds()) {
ObjectNode node = json.newObject();
ThreadInfo ti = bean.getThreadInfo(id, 10);
node
.put("threadName", ti.getThreadName())
.put("threadId", ti.getThreadId())
.put("blockedTime", ti.getBlockedTime())
.put("blockedCount", ti.getBlockedCount())
.put("lockName", ti.getLockName())
.put("waitedTime", ti.getWaitedTime())
.put("waitedCount", ti.getWaitedCount())
.put("threadState", ti.getThreadState().toString())
.put("stack", stack(ti.getStackTrace()));
array.add(node);
}
return ok(array);
}
示例6: authenticate
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
/**
* Authenticates the user.
*
* @param username the username
* @param password the password
* @return the default page if the authentication succeed, the login page otherwise.
*/
@Route(method = HttpMethod.POST, uri = "/monitor/login")
public Result authenticate(@FormParameter("username") String username, @FormParameter("password") String password) {
if (!configuration.getBooleanWithDefault("monitor.auth.enabled", true)) {
// If the authentication is disabled, just jump to the dashboard page.
return dashboard();
}
final String name = configuration.getOrDie("monitor.auth.username");
final String pwd = configuration.getOrDie("monitor.auth.password");
if (name.equals(username) && pwd.equals(password)) {
session().put("wisdom.monitor.username", username);
logger().info("Authentication successful - {}", username);
return dashboard();
} else {
logger().info("Authentication failed - {}", username);
context().flash().error("Authentication failed - check your credentials");
return login();
}
}
示例7: index
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
/**
* Serves the asset list page, or a JSON form depending on the {@literal ACCEPT} header.
* @return the page, the json form or a bad request. Bad request are returned in "PROD" mode.
*/
@Route(method = HttpMethod.GET, uri = "/assets")
public Result index() {
if (configuration.isProd()) {
// Dumping assets is not enabled in PROD mode,
// returning a bad request result
return badRequest("Sorry, no asset dump in PROD mode.");
}
if (cache.isEmpty() || NOCACHE_VALUE.equalsIgnoreCase(context().header(CACHE_CONTROL))) {
// Refresh the cache.
all();
}
return Negotiation.accept(ImmutableMap.of(
MimeTypes.HTML, ok(render(template, "assets", cache)),
MimeTypes.JSON, ok(cache).json()
));
}
示例8: getControllers
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
/**
* @return the JSON structure read by the HTML page.
*/
@Route(method = HttpMethod.GET, uri = "/monitor/controllers/controllers")
public Result getControllers() {
ObjectNode node = json.newObject();
ArrayNode array = json.newArray();
for (org.wisdom.api.Controller controller : controllers) {
array.add(ControllerModel.from(controller, router, json));
}
for (InstanceDescription description : getInvalidControllers()) {
array.add(ControllerModel.from(description, json));
}
node.put("controllers", array);
node.put("invalid", getInvalidControllers().size());
return ok(node);
}
示例9: login
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.POST, uri = "/login")
@Async
public Result login() throws IOException {
String urlContent = URLDecoder.decode(context().reader().readLine(), "UTF-8");
String[] split = urlContent.split("&");
Session session = coreServerController.getSession(split[0].replaceAll(".*=", ""),
split[1].replaceAll(".*=", ""));
if(session != null) {
return ok(session.getToken().toString());
}
else {
return badRequest("Unrecognized credits.");
}
}
示例10: describeProcess
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/describeProcess")
public Result describeProcess(@Parameter("id") String id) throws IOException {
String token = context().cookieValue("token");
Session session = null;
for(Session s : coreServerController.getOpenSessionList()) {
if (s.getToken().toString().equals(token)) {
session = s;
Operation op = session.getOperation(id);
return ok(render(describeProcess, "operation", op, "session", session));
}
}
return badRequest(render(homeContent));
}
示例11: execute
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.POST, uri = "/execute")
public Result execute() throws IOException {
for(Session session : coreServerController.getOpenSessionList()) {
String urlContent = URLDecoder.decode(context().reader().readLine(), "UTF-8");
String[] split = urlContent.split("&");
String token = context().cookieValue("token");
if (session.getToken().toString().equals(token)) {
Map<String, String> inputData = new HashMap<>();
String id = "";
for (String str : split) {
String[] val = str.split("=");
if (val[0].equals("processId")) {
id = val[1];
} else {
if (val.length == 1) {
inputData.put(val[0], "");
} else {
inputData.put(val[0], val[1]);
}
}
}
session.executeOperation(id, inputData);
return ok();
}
}
return badRequest();
}
示例12: signIn
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.POST, uri = "/register")
public Result signIn() throws IOException {
String urlContent = URLDecoder.decode(context().reader().readLine(), "UTF-8");
String[] split = urlContent.split("&");
Session session = coreServerController.createSession(split[0].replaceAll(".*=", ""),
split[1].replaceAll(".*=", ""));
if(session != null) {
return ok(session.getToken().toString());
}
else {
return badRequest("Can not create user.");
}
}
示例13: data
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/data")
public Result data() {
String token = context().cookieValue("token");
for (Session session : coreServerController.getOpenSessionList()) {
if (session.getToken().toString().equals(token)) {
return ok(render(data));
}
}
return badRequest(render(data));
}
示例14: dataLeftNav
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/dataleftnav")
public Result dataLeftNav() {
String token = context().cookieValue("token");
for (Session session : coreServerController.getOpenSessionList()) {
if (session.getToken().toString().equals(token)) {
return ok(render(dataLeftNav));
}
}
return badRequest(render(data));
}
示例15: process
import org.wisdom.api.annotations.Route; //导入依赖的package包/类
@Route(method = HttpMethod.GET, uri = "/process")
public Result process() {
String token = context().cookieValue("token");
for(Session session : coreServerController.getOpenSessionList()) {
if (session.getToken().toString().equals(token)) {
return ok(render(process));
}
}
return badRequest(render(process));
}