• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RsFlash类的典型用法和代码示例

java 1次浏览

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

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

示例1: ocket

点赞 3

import org.takes.facets.flash.RsFlash; //导入依赖的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

点赞 3

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例3: act

点赞 3

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例4: act

点赞 3

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String name = new RqFormBase(req).param("name")
        .iterator().next().trim();
    try {
        new SafeUser(this.base.user(new RqUser(req).name())).add(name);
    } catch (final SafeUser.InvalidNameException ex) {
        throw TkAdd.forward(new RsFlash(ex));
    }
    return TkAdd.forward(
        new RsFlash(
            String.format(
                "domain \"%s\" added", name
            )
        )
    );
}
 

开发者ID:yegor256,
项目名称:jare,
代码行数:18,
代码来源:TkAdd.java

示例5: act

点赞 3

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例6: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例7: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例8: user

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例9: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例10: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例11: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例12: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例13: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例14: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例15: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例16: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的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

示例17: RsFailure

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Ctor.
 * @param cause Cause
 * @param loc Location to redirect to
 * @throws UnsupportedEncodingException If fails
 * @since 0.21
 */
public RsFailure(final Throwable cause, final CharSequence loc)
    throws UnsupportedEncodingException {
    super(
        new RsFlash(cause),
        HttpURLConnection.HTTP_MOVED_PERM,
        loc
    );
}
 

开发者ID:yegor256,
项目名称:takes,
代码行数:16,
代码来源:RsFailure.java

示例18: buildsStackTrace

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * RsForward can build a proper stacktrace.
 * @throws IOException If some problem inside
 */
@Test
public void buildsStackTrace() throws IOException {
    MatcherAssert.assertThat(
        ExceptionUtils.getFullStackTrace(
            new RsForward(new RsFlash(new IOException("the failure")))
        ),
        Matchers.containsString("failure")
    );
}
 

开发者ID:yegor256,
项目名称:takes,
代码行数:14,
代码来源:RsForwardTest.java

示例19: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    new RqDoc(req, this.base).doc().delete();
    return new RsForward(
        new RsFlash("file deleted")
    );
}
 

开发者ID:libreio,
项目名称:libre,
代码行数:8,
代码来源:TkDelete.java

示例20: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String friend = new RqHref.Smart(
        new RqHref.Base(req)
    ).single("friend");
    new RqDoc(req, this.base).doc().friends().add(friend);
    return new RsForward(
        new RsFlash(
            String.format(
                "document shared with \"%s\"", friend
            )
        )
    );
}
 

开发者ID:libreio,
项目名称:libre,
代码行数:15,
代码来源:TkAddFriend.java

示例21: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String friend = new RqHref.Smart(
        new RqHref.Base(req)
    ).single("friend");
    new RqDoc(req, this.base).doc().friends().eject(friend);
    return new RsForward(
        new RsFlash(String.format("friend \"%s\" ejected", friend))
    );
}
 

开发者ID:libreio,
项目名称:libre,
代码行数:11,
代码来源:TkEjectFriend.java

示例22: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final RqForm.Smart form = new RqForm.Smart(new RqForm.Base(req));
    final Decks decks = new RqUser(req, this.base).get().decks();
    final String name = form.single("name");
    decks.add(name);
    return new RsForward(
        new RsFlash(String.format("deck \"%s\" added", name))
    );
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:11,
代码来源:TkAddDeck.java

示例23: get

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Get user.
 * @return User
 * @throws IOException If fails
 */
public User get() throws IOException {
    final Identity identity = new RqAuth(this).identity();
    if (identity.equals(Identity.ANONYMOUS)) {
        throw new RsForward(
            new RsFlash("you are not logged in")
        );
    }
    return this.base.user(identity.properties().get("login"));
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:15,
代码来源:RqUser.java

示例24: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final Decks decks = new RqUser(req, this.base).get().decks();
    final String deck = new RqDeck(this.base, req).deck().name();
    final String cmd = new RqHref.Smart(new RqHref.Base(req))
        .single("command");
    final Deck.Smart smart = new Deck.Smart(decks.get(deck));
    smart.update(TkCommand.answer(smart.xml(), cmd));
    throw new RsForward(new RsFlash("thanks!"));
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:11,
代码来源:TkCommand.java

示例25: domain

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Domain command.
 * @param args Arguments
 * @return Directives
 * @throws IOException If fails
 */
private static Iterable<Directive> domain(final String... args)
    throws IOException {
    if (args.length == 0) {
        throw new RsForward(
            new RsFlash(
                "'domain' command supports 'add' and 'remove'"
            )
        );
    }
    final Directives dirs = new Directives();
    if ("add".equals(args[0])) {
        dirs.addIf("domains").add("domain").set(args[1]);
    } else if ("remove".equals(args[0])) {
        dirs.xpath(
            String.format(
                "/deck/domains/domain[.='%s']", args[1]
            )
        ).remove();
    } else {
        throw new RsForward(
            new RsFlash(
                String.format(
                    "should be either 'add' or 'remove': '%s' is wrong",
                    args[0]
                )
            )
        );
    }
    return dirs;
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:37,
代码来源:TkCommand.java

示例26: repo

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Repo command.
 * @param deck XML deck
 * @param args Arguments
 * @return Directives
 * @throws IOException If fails
 */
private static Iterable<Directive> repo(final XML deck,
    final String... args) throws IOException {
    if (args.length == 0) {
        throw new RsForward(
            new RsFlash(
                "'repo' command supports 'put'"
            )
        );
    }
    final Directives dirs = new Directives();
    if ("put".equals(args[0])) {
        if (deck.nodes("/deck/images/image").size() > 2) {
            throw new IllegalArgumentException(
                "there are too many images as is, waste a few first"
            );
        }
        final String today = DateFormatUtils.ISO_DATETIME_FORMAT.format(
            new Date()
        );
        dirs.xpath("/deck").add("repo")
            .attr("added", today)
            .add("name")
            .set(String.format("%08x", TkCommand.RND.nextInt())).up()
            .add("uri").set(args[1]);
    } else if ("remove".equals(args[0])) {
        dirs.xpath("/deck/repo").remove();
    } else {
        throw new IllegalArgumentException(
            String.format(
                "should be only 'put': '%s' is wrong",
                args[0]
            )
        );
    }
    return dirs;
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:44,
代码来源:TkCommand.java

示例27: container

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Container command.
 * @param args Arguments
 * @return Directives
 * @throws IOException If fails
 */
private static Iterable<Directive> container(final String... args)
    throws IOException {
    if (args.length == 0) {
        throw new RsForward(
            new RsFlash(
                "'container' command supports 'waste'"
            )
        );
    }
    final Directives dirs = new Directives();
    if ("waste".equals(args[0])) {
        final String today = DateFormatUtils.ISO_DATETIME_FORMAT.format(
            new Date()
        );
        dirs.xpath(
            String.format(
                "/deck/containers/container[name='%s']",
                args[1]
            )
        ).attr("waste", today);
    } else {
        throw new IllegalArgumentException(
            String.format(
                "should be only 'waste': '%s' is wrong",
                args[0]
            )
        );
    }
    return dirs;
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:37,
代码来源:TkCommand.java

示例28: image

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
/**
 * Image command.
 * @param args Arguments
 * @return Directives
 * @throws IOException If fails
 */
private static Iterable<Directive> image(final String... args)
    throws IOException {
    if (args.length == 0) {
        throw new RsForward(
            new RsFlash(
                "'image' command supports 'waste'"
            )
        );
    }
    final Directives dirs = new Directives();
    if ("waste".equals(args[0])) {
        final String today = DateFormatUtils.ISO_DATETIME_FORMAT.format(
            new Date()
        );
        dirs.xpath(
            String.format(
                "/deck/images/image[name='%s']",
                args[1]
            )
        ).attr("waste", today);
    } else {
        throw new IllegalArgumentException(
            String.format(
                "should be only 'waste': '%s' is wrong argument",
                args[0]
            )
        );
    }
    return dirs;
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:37,
代码来源:TkCommand.java

示例29: act

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final Decks decks = new RqUser(req, this.base).get().decks();
    final String deck = new RqDeck(this.base, req).deck().name();
    decks.delete(deck);
    return new RsForward(
        new RsFlash(
            String.format("deck \"%s\" deleted", deck)
        )
    );
}
 

开发者ID:yegor256,
项目名称:thindeck,
代码行数:12,
代码来源:TkDelete.java

示例30: enter

点赞 2

import org.takes.facets.flash.RsFlash; //导入依赖的package包/类
@Override
public Opt<Identity> enter(final Request request) throws IOException {
    final Iterator<String> headers = new RqHeaders.Smart(
        new RqHeaders.Base(request)
    ).header("authorization").iterator();
    if (!headers.hasNext()) {
        throw new RsForward(
            new RsWithHeader(
                String.format(
                    "WWW-Authenticate: Basic ream=\"%s\" ",
                    this.realm
                )
            ),
            HttpURLConnection.HTTP_UNAUTHORIZED,
            new RqHref.Base(request).href()
        );
    }
    final String decoded = new Utf8String(
        DatatypeConverter.parseBase64Binary(
            PsBasic.AUTH.split(headers.next())[1]
        )
    ).string().trim();
    final String user = decoded.split(":")[0];
    final Opt<Identity> identity = this.entry.enter(
        user,
        decoded.substring(user.length() + 1)
    );
    if (!identity.has()) {
        throw new RsForward(
            new RsWithHeader(
                new RsFlash("access denied", Level.WARNING),
                String.format(
                    "WWW-Authenticate: Basic ream=\"%s\"",
                    this.realm
                )
            ),
            HttpURLConnection.HTTP_UNAUTHORIZED,
            new RqHref.Base(request).href()
        );
    }
    return identity;
}
 

开发者ID:yegor256,
项目名称:takes,
代码行数:43,
代码来源:PsBasic.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)