• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Result类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testParameter

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testParameter() 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().session().put("key2", "ongoing");
            return ok(template.render(controller));
        }
    }).parameter("key", "param").invoke();

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


示例17: serve

import org.wisdom.api.http.Result; //导入依赖的package包/类
/**
 * @return the result serving the asset.
 */
public Result serve() {
    String path = context().parameterFromPath("path");
    if (path.startsWith("/")) {
        path = path.substring(1);
    }

    Asset<?> asset = getAssetFromFS(path);
    if (asset == null && manageAssetsFromBundles) {
        asset = getAssetFromBundle(path);
    }

    if (asset != null) {
        return CacheUtils.fromAsset(context(), asset, configuration);
    }
    return notFound();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:20,代码来源:AssetController.java


示例18: testContext

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testContext() {
    Action.ActionResult result = Action.action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            if (context().parameter("p").equals("v")
                    && context().cookieValue("c").equals("cc")) {
                return Results.ok();
            } else {
                return Results.badRequest();
            }
        }
    }).with(new FakeContext().setParameter("p", "v").setCookie("c", "cc")).invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(200);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:17,代码来源:ActionTest.java


示例19: call

import org.wisdom.api.http.Result; //导入依赖的package包/类
/**
 * Intercepts the action, and checks if the current request is authenticated.
 * the results depends on two factors: if the request is authenticated and the availability of authenticator.
 * <p>
 * If there are no authenticator, it returns a unauthorized response.
 * If there are an authenticator matching the set ones (in the annotation), use it. If the authenticator cannot
 * authenticate the request, it will be used to get the unauthorized response.
 * If these are no authenticator matching the request, it returns an unauthorized response.
 * <p>
 * If the annotation does not specify the authenticator, it uses the first one. If several ones are available,
 * a warning is thrown.
 *
 * @param configuration the authenticated annotation instance
 * @param context       the interception context
 * @return the result
 * @throws Exception if anything bad happen
 */
@Override
public Result call(Authenticated configuration, RequestContext context) throws Exception {
    Authenticator authenticator = getAuthenticator(context, configuration.value());
    if (authenticator != null) {
        String username = authenticator.getUserName(context.context());
        if (username == null) {
            // We cut the interception chain on purpose.
            context.context().request().setUsername(null);
            return authenticator.onUnauthorized(context.context());
        } else {
            // Set the username.
            context.context().request().setUsername(username);
            return context.proceed();
        }
    } else {
        context.context().request().setUsername(null);
        // No authenticator
        return Results.unauthorized();
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:38,代码来源:AuthenticationInterceptor.java


示例20: testAcceptWhenNoAcceptOrRequest

import org.wisdom.api.http.Result; //导入依赖的package包/类
@Test
public void testAcceptWhenNoAcceptOrRequest() throws Exception {
    Controller controller = new DefaultController() {
        public Result method1() {
            return null;
        }
    };

    Route route1 = new RouteBuilder().route(HttpMethod.GET).on("/foo").to(controller, "method1").accepts
            ("text/plain");
    assertThat(route1.isCompliantWithRequestContentType(null)).isEqualTo(2);

    route1 = new RouteBuilder().route(HttpMethod.GET).on("/foo").to(controller, "method1");
    Request request1 = mock(Request.class);
    when(request1.contentMimeType()).thenReturn("text/plain");
    assertThat(route1.isCompliantWithRequestContentType(request1)).isEqualTo(2);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:18,代码来源:RouteTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteBufferOutputStream类代码示例发布时间:2022-05-22
下一篇:
Java GLUtessellatorCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap