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

Java RsForward类代码示例

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

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



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

示例1: ocket

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public String ocket(final long time) throws IOException {
    final Iterator<Item> items = this.region.table("logs")
        .frame()
        .through(new QueryValve().withLimit(1))
        .where("group", this.group())
        .where(
            "start",
            new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(
                    new AttributeValue().withN(Long.toString(time))
                )
        )
        .iterator();
    if (!items.hasNext()) {
        throw new RsForward(
            new RsFlash("Can't find log"),
            "/scripts"
        );
    }
    return items.next().get("ocket").getS();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:24,代码来源:DyScript.java


示例2: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final String name = new RqHref.Smart(request).single("script");
    return new RsForward(
        String.format(
            "/log?name=%s",
            URLEncoder.encode(
                new RqUser(this.base, request).script(name).ocket(
                    Long.parseLong(
                        new RqHref.Smart(request).single("time")
                    )
                ),
                StandardCharsets.UTF_8.displayName()
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:18,代码来源:TkLogLink.java


示例3: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final User user = new RqUser(this.base, request);
    final RqFormSmart form = new RqFormSmart(new RqGreedy(request));
    final String name = form.single("script");
    final long cents = Long.parseLong(form.single("cents"));
    try {
        user.script(name).pay(
            cents, form.single("token"), form.single("email")
        );
    } catch (final IOException ex) {
        throw new RsForward(new RsFlash(ex));
    }
    return new RsForward(
        new RsFlash(
            String.format(
                "Script \"%s\" funded for $%.2f.",
                // @checkstyle MagicNumber (1 line)
                name, (double) cents / 100.0d
            )
        ),
        "/scripts"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:25,代码来源:TkPay.java


示例4: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final Identity identity = new RqAuth(request).identity();
    if (identity.equals(Identity.ANONYMOUS)) {
        throw new RsForward(
            new RsFlash("You must be logged in to view logs.")
        );
    }
    final String login = identity.properties().get("login");
    final String name = new RqHref.Smart(request).single("name");
    if (!name.startsWith(String.format("%s_", login))) {
        throw new RsForward(
            new RsFlash(
                String.format(
                    "Permission denied: \"%s\".", name
                )
            )
        );
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    this.bucket.ocket(name).read(baos);
    return new RsText(baos.toByteArray());
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:24,代码来源:TkLog.java


示例5: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final RqRegex req) throws IOException {
    final Matcher matcher = req.matcher();
    // @checkstyle MagicNumber (1 line)
    String path = matcher.group(3);
    if (path.isEmpty()) {
        throw new RsForward(
            String.format("%s/index.html", matcher.group(0))
        );
    }
    path = path.substring(1);
    return new IoCheckedFunc<>(
        new IoCheckedBiFunc<>(this.reports).apply(
            matcher.group(1),
            matcher.group(2)
        )
    ).apply(path);
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:TkReport.java


示例6: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String visibility = new RqForm.Smart(
        new RqForm.Base(req)
    ).single("visibility", "Private");
    new RqDoc(req, this.base).doc().attributes().show(
        "Public".equals(visibility)
    );
    return new RsForward(
        new RsFlash(
            String.format(
                "document visibility set to \"%s\"", visibility
            )
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:17,代码来源:TkSetVisibility.java


示例7: deck

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
/**
 * Get deck.
 * @return The deck
 * @throws IOException If fails
 */
@SuppressWarnings("PMD.PreserveStackTrace")
public Deck deck() throws IOException {
    final User user = new RqUser(this, this.base).get();
    final String name = new RqHeaders.Smart(
        new RqHeaders.Base(this)
    ).single("X-Thindeck-Deck");
    try {
        return user.decks().get(name);
    } catch (final IOException ex) {
        throw new RsForward(
            new RsText(ex.getLocalizedMessage()),
            HttpURLConnection.HTTP_NOT_FOUND
        );
    }
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:21,代码来源:RqDeck.java


示例8: redirect

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
/**
 * Redirect to the bout.
 * @param deck Deck name
 * @param take Take
 * @return New take
 */
private static Take redirect(final String deck, final Take take) {
    return new Take() {
        @Override
        public Response act(final Request req) throws IOException {
            try {
                return take.act(req);
            } catch (final RsForward ex) {
                if (ex.code() == HttpURLConnection.HTTP_SEE_OTHER) {
                    throw new RsForward(
                        ex,
                        new RqHref.Smart(
                            new RqHref.Base(req)
                        ).home().path("d").path(deck)
                    );
                }
                throw ex;
            }
        }
    };
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:FkDeck.java


示例9: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final User user = new RqUser(this.base, request);
    final String name = new RqHref.Smart(request).single("name");
    user.script(name).flush();
    return new RsForward(
        new RsFlash(
            String.format("Script \"%s\" flushed, it will start now.", name)
        ),
        "/scripts"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:13,代码来源:TkFlush.java


示例10: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final User user = new RqUser(this.base, request);
    final String name = new RqHref.Smart(request).single("name");
    user.script(name).delete();
    return new RsForward(
        new RsFlash(
            String.format("Script \"%s\" deleted.", name)
        ),
        "/scripts"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:13,代码来源:TkDelete.java


示例11: user

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
/**
 * Get user name (GitHub handle).
 * @return The user found
 * @throws IOException If fails
 */
private User user() throws IOException {
    final Identity identity = new RqAuth(this.request).identity();
    if (identity.equals(Identity.ANONYMOUS)) {
        throw new RsForward(
            new RsFlash("You must be logged in.")
        );
    }
    return this.base.user(
        identity.properties().get("login").toLowerCase(Locale.ENGLISH)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:17,代码来源:RqUser.java


示例12: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final User user = new RqUser(this.base, request);
    final String group = new RqHref.Smart(request).single("group");
    final long start = Long.parseLong(
        new RqHref.Smart(request).single("start")
    );
    user.delete(group, start);
    return new RsForward(
        new RsFlash(
            String.format("Log \"%[email protected]%d\" deleted.", group, start)
        ),
        "/logs"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:16,代码来源:TkDeleteLog.java


示例13: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    final User user = new RqUser(this.base, request);
    final RqFormSmart form = new RqFormSmart(new RqGreedy(request));
    final String name = form.single("name");
    user.script(name).update(form.single("body"));
    return new RsForward(
        new RsFlash(
            String.format("Script \"%s\" updated/saved.", name)
        ),
        "/scripts"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:14,代码来源:TkSave.java


示例14: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String url = new RqHref.Base(req).href()
        .param("url").iterator().next();
    final String path = String.format(
        "/?u=%s",
        URLEncoder.encode(
            url,
            "UTF-8"
        )
    );
    final AmazonCloudFront aws = AmazonCloudFrontClientBuilder.standard()
        .withCredentials(
            new AWSStaticCredentialsProvider(
                new BasicAWSCredentials(this.key, this.secret)
            )
        )
        .build();
    final CreateInvalidationResult result = aws.createInvalidation(
        new CreateInvalidationRequest(
            "E2QC66VZY6F0QA",
            new InvalidationBatch(
                new Paths().withItems(path).withQuantity(1),
                UUID.randomUUID().toString()
            )
        )
    );
    return new RsForward(
        new RsFlash(
            String.format(
                "URL \"%s\" was invalidated (ID=\"%s\", Status=\"%s\")",
                url,
                result.getInvalidation().getId(),
                result.getInvalidation().getStatus()
            )
        ),
        "/domains"
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:40,代码来源:TkInvalidate.java


示例15: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    this.base.user(new RqUser(req).urn()).pipes().add(
        new RqFormBase(req).param("json").iterator().next().trim()
    );
    return new RsForward(
        new RsFlash("pipe created"),
        "/pipes"
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:11,代码来源:TkPipeAdd.java


示例16: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final User user = this.base.user(new RqUser(req).urn());
    final Event event = user.events().event(
        new RqHref.Base(req).href().param("title").iterator().next()
    );
    event.vote(-Tv.TEN);
    return new RsForward(new RsFlash("event down-voted"));
}
 
开发者ID:yegor256,项目名称:wring,代码行数:10,代码来源:TkEventDown.java


示例17: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final Pipe pipe = this.base.user(new RqUser(req).urn()).pipes().pipe(
        Long.parseLong(
            new RqHref.Base(req).href().param("id").iterator().next()
        )
    );
    final String msg = new XePrint(pipe.asXembly()).text(
        "pipe #{/pipe/id/text()} deleted"
    );
    pipe.delete();
    return new RsForward(new RsFlash(msg), "/pipes");
}
 
开发者ID:yegor256,项目名称:wring,代码行数:14,代码来源:TkPipeDelete.java


示例18: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final User user = this.base.user(new RqUser(req).urn());
    final Event event = user.events().event(
        new RqHref.Base(req).href().param("title").iterator().next()
    );
    final String msg = new XePrint(event.asXembly()).text(
        "event \"{/event/title/text()}\" deleted"
    );
    event.delete();
    return new RsForward(new RsFlash(msg));
}
 
开发者ID:yegor256,项目名称:wring,代码行数:13,代码来源:TkEventDelete.java


示例19: act

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
    if (new RqAuth(request).identity().equals(Identity.ANONYMOUS)) {
        throw new RsForward(
            new RsFlash("access denied", Level.WARNING),
            this.loc
        );
    }
    return this.origin.act(request);
}
 
开发者ID:yegor256,项目名称:takes,代码行数:11,代码来源:TkSecure.java


示例20: handleConnectionWithInvalidCredential

import org.takes.facets.forward.RsForward; //导入依赖的package包/类
/**
 * PsBasic can handle connection with invalid credential.
 * @throws Exception If some problem inside
 */
@Test
public void handleConnectionWithInvalidCredential() throws Exception {
    RsForward forward = new RsForward();
    try {
        new PsBasic(
            "RealmB",
            new PsBasic.Empty()
        ).enter(
            new RqWithHeaders(
                new RqFake(
                    RqMethod.GET,
                    String.format(
                        "?invalid_code=%s",
                        RandomStringUtils.randomAlphanumeric(Tv.TEN)
                    )
                ),
                PsBasicTest.header("username", "wrong")
            )
        );
    } catch (final RsForward ex) {
        forward = ex;
    }
    MatcherAssert.assertThat(
        new RsPrint(forward).printHead(),
        Matchers.allOf(
            Matchers.containsString("HTTP/1.1 401 Unauthorized"),
            Matchers.containsString(
                "WWW-Authenticate: Basic ream=\"RealmB\""
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:37,代码来源:PsBasicTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java KeyWithDefaultValue类代码示例发布时间:2022-05-22
下一篇:
Java AppRater类代码示例发布时间: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