Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jun 20, 2019
2 parents 60e54d1 + 5f38b61 commit 49a2355
Show file tree
Hide file tree
Showing 103 changed files with 302 additions and 349 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public final class TkApp implements Take {
}

@Override
public Response act(final Request req) throws IOException {
public Response act(final Request req) throws Exception {
return new RsText("Hello servlet!");
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@ new TkFork(
"/file/(?<path>[^/]+)",
new TkRegex() {
@Override
public Response act(final RqRegex request) throws IOException {
public Response act(final RqRegex request) throws Exception {
final File file = new File(
request.matcher().group("path")
);
Expand Down
2 changes: 1 addition & 1 deletion src/it/file-manager/src/main/java/org/takes/it/fm/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void main(final String... args) throws IOException {
}

@Override
public Response act(final Request request) throws IOException {
public Response act(final Request request) throws Exception {
return new TkFork(
new FkRegex("/", new TkRedirect("/f")),
new FkRegex(
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/takes/Take.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
package org.takes;

import java.io.IOException;

/**
* Take.
*
Expand Down Expand Up @@ -72,8 +70,8 @@ public interface Take {
* Convert request to response.
* @param req Request to process
* @return Response
* @throws IOException If fails
* @throws Exception If fails
*/
Response act(Request req) throws IOException;
Response act(Request req) throws Exception;

}
9 changes: 4 additions & 5 deletions src/main/java/org/takes/facets/auth/Pass.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.auth;

import java.io.IOException;
import org.takes.Request;
import org.takes.Response;
import org.takes.misc.Opt;
Expand All @@ -41,17 +40,17 @@ public interface Pass {
* Authenticate the user by the request.
* @param request The request
* @return Identity of the user found
* @throws IOException If fails
* @throws Exception If fails
*/
Opt<Identity> enter(Request request) throws IOException;
Opt<Identity> enter(Request request) throws Exception;

/**
* Wrap the response with the user.
* @param response Response
* @param identity Identity
* @return New response
* @throws IOException If fails
* @throws Exception If fails
*/
Response exit(Response response, Identity identity) throws IOException;
Response exit(Response response, Identity identity) throws Exception;

}
8 changes: 4 additions & 4 deletions src/main/java/org/takes/facets/auth/PsAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PsAll(final List<? extends Pass> passes, final int identity) {
}

@Override
public Opt<Identity> enter(final Request request) throws IOException {
public Opt<Identity> enter(final Request request) throws Exception {
final Opt<Identity> result;
if (this.allMatch(request)) {
result = this.all.get(this.index).enter(request);
Expand All @@ -70,7 +70,7 @@ public Opt<Identity> enter(final Request request) throws IOException {

@Override
public Response exit(final Response response, final Identity identity)
throws IOException {
throws Exception {
if (this.index >= this.all.size()) {
throw new IOException(
"Index of identity is greater than Pass collection size"
Expand Down Expand Up @@ -107,9 +107,9 @@ private int validated(final int idx) {
* Checks if you can enter every Pass with a request.
* @param request Request that is used to enter Passes.
* @return True if every request can be entered, false otherwise
* @throws IOException If any of enter attempts fail
* @throws Exception If any of enter attempts fail
*/
private boolean allMatch(final Request request) throws IOException {
private boolean allMatch(final Request request) throws Exception {
boolean success = true;
for (final Pass pass : this.all) {
if (!pass.enter(request).has()) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/takes/facets/auth/PsByFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.auth;

import java.io.IOException;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -94,7 +93,7 @@ public PsByFlag(final String flg, final Map<Pattern, Pass> map) {
}

@Override
public Opt<Identity> enter(final Request req) throws IOException {
public Opt<Identity> enter(final Request req) throws Exception {
final Iterator<String> flg = new RqHref.Base(req).href()
.param(this.flag).iterator();
Opt<Identity> user = new Opt.Empty<>();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/takes/facets/auth/PsChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.auth;

import java.io.IOException;
import java.util.Arrays;
import lombok.EqualsAndHashCode;
import org.takes.Request;
Expand Down Expand Up @@ -62,7 +61,7 @@ public PsChain(final Iterable<Pass> list) {
}

@Override
public Opt<Identity> enter(final Request req) throws IOException {
public Opt<Identity> enter(final Request req) throws Exception {
Opt<Identity> user = new Opt.Empty<>();
for (final Pass pass : this.passes) {
user = pass.enter(req);
Expand All @@ -75,7 +74,7 @@ public Opt<Identity> enter(final Request req) throws IOException {

@Override
public Response exit(final Response response,
final Identity identity) throws IOException {
final Identity identity) throws Exception {
Response res = response;
for (final Pass pass : this.passes) {
res = pass.exit(res, identity);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/takes/facets/auth/PsToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Opt<Identity> enter(final Request req) throws IOException {

@Override
public Response exit(final Response res,
final Identity idt) throws IOException {
final Identity idt) throws Exception {
final byte[] jwtheader = new Token.Jose(
this.signature.bitlength()
).encoded();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/takes/facets/auth/TkAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.auth;

import java.io.IOException;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.takes.Request;
Expand Down Expand Up @@ -80,7 +79,7 @@ public TkAuth(final Take take, final Pass pss, final String hdr) {
}

@Override
public Response act(final Request request) throws IOException {
public Response act(final Request request) throws Exception {
final Opt<Identity> user = this.pass.enter(request);
final Response response;
if (user.has()) {
Expand All @@ -96,10 +95,10 @@ public Response act(final Request request) throws IOException {
* @param req Request
* @param identity Identity
* @return Take
* @throws IOException If fails
* @throws Exception If fails
*/
private Response act(final Request req, final Identity identity)
throws IOException {
throws Exception {
Request wrap = new RqWithoutHeader(req, this.header);
if (!identity.equals(Identity.ANONYMOUS)) {
wrap = new RqWithAuth(identity, this.header, wrap);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/takes/facets/auth/TkSecure.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.auth;

import java.io.IOException;
import java.util.logging.Level;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand Down Expand Up @@ -74,7 +73,7 @@ public TkSecure(final Take take, final String location) {
}

@Override
public Response act(final Request request) throws IOException {
public Response act(final Request request) throws Exception {
if (new RqAuth(request).identity().equals(Identity.ANONYMOUS)) {
throw new RsForward(
new RsFlash("access denied", Level.WARNING),
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/takes/facets/cookies/TkJoinedCookies.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.cookies;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -67,7 +66,7 @@ public TkJoinedCookies(final Take take) {
super(
new Take() {
@Override
public Response act(final Request req) throws IOException {
public Response act(final Request req) throws Exception {
return TkJoinedCookies.join(take.act(req));
}
}
Expand All @@ -78,9 +77,9 @@ public Response act(final Request req) throws IOException {
* Join them.
* @param response The response
* @return New response
* @throws IOException If fails
* @throws Exception If fails
*/
private static Response join(final Response response) throws IOException {
private static Response join(final Response response) throws Exception {
final StringBuilder cookies = new StringBuilder();
for (final String header : response.head()) {
final Matcher matcher =
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/takes/facets/fallback/Fallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.fallback;

import java.io.IOException;
import org.takes.Response;
import org.takes.misc.Opt;

Expand All @@ -41,8 +40,8 @@ public interface Fallback {
* Dispatch this request and either swallow it or ignore.
* @param req Request
* @return An iterator of responses or an empty iterator
* @throws IOException If fails
* @throws Exception If fails
*/
Opt<Response> route(RqFallback req) throws IOException;
Opt<Response> route(RqFallback req) throws Exception;

}
3 changes: 1 addition & 2 deletions src/main/java/org/takes/facets/fallback/FbChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.fallback;

import java.io.IOException;
import java.util.Arrays;
import lombok.EqualsAndHashCode;
import org.takes.Response;
Expand Down Expand Up @@ -63,7 +62,7 @@ public FbChain(final Iterable<Fallback> fallbacks) {
new Fallback() {
@Override
public Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
Opt<Response> rsp = new Opt.Empty<>();
for (final Fallback fbk : fallbacks) {
final Opt<Response> opt = fbk.route(req);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/takes/facets/fallback/FbFixed.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.fallback;

import java.io.IOException;
import lombok.EqualsAndHashCode;
import org.takes.Response;
import org.takes.Take;
Expand Down Expand Up @@ -58,7 +57,7 @@ public FbFixed(final Take take) {
new Fallback() {
@Override
public Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
return new Opt.Single<>(take.act(req));
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/takes/facets/fallback/FbStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.fallback;

import java.io.IOException;
import java.util.regex.Pattern;
import lombok.EqualsAndHashCode;
import org.cactoos.iterable.Filtered;
Expand Down Expand Up @@ -71,7 +70,7 @@ public FbStatus(final Iterable<Integer> check) {
this(check, new Fallback() {
@Override
public Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
final Response res = new RsWithStatus(req.code());
return new Opt.Single<>(
new RsWithType(
Expand Down Expand Up @@ -111,7 +110,7 @@ public FbStatus(final int code, final Take take) {
new Fallback() {
@Override
public Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
return new Opt.Single<>(take.act(req));
}
}
Expand Down Expand Up @@ -177,7 +176,7 @@ public FbStatus(final Iterable<Integer> check,
new Fallback() {
@Override
public Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
Opt<Response> rsp = new Opt.Empty<>();
if (new ListOf<>(check).contains(req.code())) {
rsp = fallback.get().route(req);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/takes/facets/fallback/FbWrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.takes.facets.fallback;

import java.io.IOException;
import lombok.EqualsAndHashCode;
import org.takes.Response;
import org.takes.misc.Opt;
Expand Down Expand Up @@ -53,7 +52,7 @@ public FbWrap(final Fallback fbk) {

@Override
public final Opt<Response> route(final RqFallback req)
throws IOException {
throws Exception {
return this.origin.route(req);
}
}
Loading

0 comments on commit 49a2355

Please sign in to comment.