本文整理汇总了Java中org.takes.facets.forward.RsForward类的典型用法代码示例。如果您正苦于以下问题:Java RsForward类的具体用法?Java RsForward怎么用?Java RsForward使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RsForward类属于org.takes.facets.forward包,在下文中一共展示了RsForward类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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()
)
)
);
}
示例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"
);
}
示例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());
}
示例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);
}
示例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
)
)
);
}
示例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
);
}
}
示例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;
}
}
};
}
示例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"
);
}
示例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"
);
}
示例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)
);
}
示例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"
);
}
示例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"
);
}
示例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"
);
}
示例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"
);
}