当前位置: 首页>>代码示例>>Java>>正文


Java Result类代码示例

本文整理汇总了Java中org.wisdom.api.http.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Result类属于org.wisdom.api.http包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: upload

import org.wisdom.api.http.Result; //导入依赖的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));
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:27,代码来源:MainController.java

示例2: settings

import org.wisdom.api.http.Result; //导入依赖的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.");
    }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:17,代码来源:MainController.java

示例3: database

import org.wisdom.api.http.Result; //导入依赖的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.");
    }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:24,代码来源:MainController.java

示例4: createArchive

import org.wisdom.api.http.Result; //导入依赖的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.");
    }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:21,代码来源:MainController.java

示例5: call

import org.wisdom.api.http.Result; //导入依赖的package包/类
/**
 * The interception method. The method should call {@link org.wisdom.api.interception.RequestContext#proceed()}
 * to call the next interception. Without this call it cuts the chain.
 *
 * @param configuration the interception configuration
 * @param context       the interception context
 * @return the result
 * @throws Exception if anything bad happen
 */
@Override
public Result call(Transactional configuration, RequestContext context) throws Exception {
    propagation.onEntry(configuration.propagation(),
            configuration.timeout(),
            context.route().getControllerMethod().getName());
    try {
        Result result = context.proceed();
        propagation.onExit(configuration.propagation(), context.route().getControllerMethod().getName(), null);
        return result;
    } catch (Exception e) {
        propagation.onError(e, configuration.propagation(), configuration.noRollbackFor(),
                configuration.rollbackOnlyFor(), context.route().getControllerMethod().getName(), null);
        throw e;
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:25,代码来源:TransactionInterceptor.java

示例6: testCallOK

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testCallOK() throws Exception {
    Transactional transactional = mock(Transactional.class);
    when(transactional.noRollbackFor()).thenReturn(new Class[0]);
    when(transactional.rollbackOnlyFor()).thenReturn(new Class[0]);
    when(transactional.propagation()).thenReturn(Propagation.REQUIRES);

    RequestContext ctx = mock(RequestContext.class);
    final MyController controller = new MyController();
    when(ctx.proceed()).thenAnswer(new Answer<Result>() {
        @Override
        public Result answer(InvocationOnMock invocation) throws Throwable {
            return controller.index();
        }
    });
    when(ctx.route()).thenReturn(new Route(HttpMethod.GET, "/", controller,
            MyController.class.getMethod("index")));

    interceptor.call(transactional, ctx);
    assertThat(transaction).isNotNull();
    assertThat(controller.status).isEqualTo(Status.STATUS_COMMITTED);
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:23,代码来源:TransactionInterceptorTest.java

示例7: createTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Route(method = PUT, uri = "/{id}")
@Transactional
public Result createTodo(final @Parameter("id") String id, @Valid @Body Todo todo) {
    TodoList todoList = listCrud.findOne(id);

    if (todoList == null) {
        return notFound();
    }

    if (todo == null) {
        return badRequest("Cannot create todo, content is null.");
    }

    todoList.getTodos().add(todo);
    todoList = listCrud.save(todoList);
    final Todo last = Iterables.getLast(todoList.getTodos());
    logger().info("Todo created (last) : " + last.getId());
    return ok(last).json();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:20,代码来源:TodoController.java

示例8: updateTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Route(method = POST, uri = "/{id}/{todoId}")
@Transactional
public Result updateTodo(@Parameter("id") String listId, @Parameter("todoId") long todoId, @Valid @Body Todo todo) {
    TodoList todoList = listCrud.findOne(listId);

    if (todoList == null) {
        return notFound();
    }

    if (todo == null) {
        return badRequest("The given todo is null");
    }

    if (todoId != todo.getId()) {
        return badRequest("The id of the todo does not match the url one");
    }

    for (Todo item : todoList.getTodos()) {
        if (item.getId() == todoId) {
            item.setDone(todo.getDone());
            return ok(item).json();
        }
    }
    return notFound();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:26,代码来源:TodoController.java

示例9: delTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Route(method = DELETE, uri = "/{id}/{todoId}")
@Transactional
public Result delTodo(@Parameter("id") String listId, @Parameter("todoId") long todoId) {
    TodoList todoList = listCrud.findOne(listId);

    if (todoList == null) {
        return notFound();
    }

    Iterator<Todo> itTodo = todoList.getTodos().iterator();
    while (itTodo.hasNext()) {
        if (itTodo.next().getId() == todoId) {
            itTodo.remove();
            return ok();
        }
    }
    return notFound();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:19,代码来源:TodoController.java

示例10: getTodos

import org.wisdom.api.http.Result; //导入依赖的package包/类
/**
 * Return the todolist of given id, 404 otherwise.
 *
 * @param id list id
 * @return the todolist of given id.
 */
@Route(method = GET,uri = "/{id}")
public Result getTodos(final @Parameter("id") String id){
    TodoList todoList = null;

    try{
        todoList = listCrud.findOne(id);
    }catch (IllegalArgumentException e){
        return badRequest();
    }
    if(todoList == null){
        return notFound();
    }

    return ok(todoList.getTodos()).json();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:22,代码来源:TodoController.java

示例11: createTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
/**
 * Create a new todo.
 *
 * @body.sample { "content" : "Get the milk", "done" : "true" }
 */
@Route(method = PUT,uri = "/{id}")
public Result createTodo(final @Parameter("id") String id,@Valid @Body Todo todo){
    TodoList todoList = listCrud.findOne(id);

    if(todoList == null){
        return notFound();
    }

    if(todo == null){
        return badRequest("Cannot create todo, content is null.");
    }

    todoList.getTodos().add(todo);
    todoList=listCrud.save(todoList);
    return ok(Iterables.getLast(todoList.getTodos())).json();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:22,代码来源:TodoController.java

示例12: updateTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Route(method = POST,uri = "/{id}/{todoId}")
public Result updateTodo(@Parameter("id") String listId,@Parameter("todoId") String todoId,@Valid @Body Todo todo){
    TodoList todoList = listCrud.findOne(listId);

    if(todoList == null){
        return notFound();
    }

    //TODO sometimes body is null her

    if(todo == null){
        return badRequest("The given todo is null");
    }

    if(!todoId.equals(todo.getId())){
        return badRequest("The id of the todo does not match the url one");
    }

    Iterator<Todo> itTodo = todoList.getTodos().iterator();
    while(itTodo.hasNext()){
        if(itTodo.next().getId().equals(todoId)){
            return ok(todoCrud.save(todo)).json();
        }
    }
    return notFound();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:27,代码来源:TodoController.java

示例13: delTodo

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Route(method = DELETE,uri = "/{id}/{todoId}")
public Result delTodo(@Parameter("id") String listId,@Parameter("todoId") String todoId){
    TodoList todoList = listCrud.findOne(listId);

    if(todoList == null){
        return notFound();
    }

    Iterator<Todo> itTodo = todoList.getTodos().iterator();

    while(itTodo.hasNext()){
        if(itTodo.next().getId().equals(todoId)){
            itTodo.remove();
            listCrud.save(todoList);
            return ok();
        }
    }

    return notFound();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:21,代码来源:TodoController.java

示例14: testSessionScope

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testSessionScope() throws MalformedURLException {
    File file = new File("src/test/resources/templates/var.mst.html");
    assertThat(file).isFile();

    final MustacheTemplate template = new MustacheTemplate(factory, file.toURI().toURL());

    Action.ActionResult result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return ok(template.render(controller, ImmutableMap.<String, Object>of("key",
                    "test")));
        }
    }).with(new FakeContext().addToSession("key2", "session")).invoke();

    String content = (String) result.getResult().getRenderable().content();
    assertThat(content)
            .contains("<span>KEY</span> = test")
            .contains("<span>KEY2</span> = session");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-mustache-template-engine,代码行数:21,代码来源:MustacheTemplateTest.java

示例15: testFlashScope

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testFlashScope() throws MalformedURLException {
    File file = new File("src/test/resources/templates/var.mst.html");
    assertThat(file).isFile();

    final MustacheTemplate template = new MustacheTemplate(factory, file.toURI().toURL());

    Action.ActionResult result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            context().flash().put("key2", "ongoing");
            return ok(template.render(controller));
        }
    }).with(new FakeContext().addToFlash("key", "incoming")).invoke();

    String content = (String) result.getResult().getRenderable().content();
    assertThat(content)
            .contains("<span>KEY</span> = incoming")
            .contains("<span>KEY2</span> = ongoing");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-mustache-template-engine,代码行数:21,代码来源:MustacheTemplateTest.java


注:本文中的org.wisdom.api.http.Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。