mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
Send the MissingRepositoryException message to the client
This commit is contained in:
@@ -78,7 +78,7 @@ public class Oauth2Filter implements Filter {
|
||||
);
|
||||
return;
|
||||
} catch (MissingRepositoryException e) {
|
||||
missing(project, (HttpServletResponse) servletResponse);
|
||||
missing(project, e, (HttpServletResponse) servletResponse);
|
||||
}
|
||||
Log.info("[{}] Auth not needed", project);
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
@@ -205,6 +205,7 @@ public class Oauth2Filter implements Filter {
|
||||
|
||||
private void missing(
|
||||
String projectName,
|
||||
MissingRepositoryException e,
|
||||
HttpServletResponse response
|
||||
) throws IOException {
|
||||
Log.info("[{}] Project missing.", projectName);
|
||||
@@ -216,9 +217,9 @@ public class Oauth2Filter implements Filter {
|
||||
response.setStatus(404);
|
||||
|
||||
PrintWriter w = response.getWriter();
|
||||
w.println("This project is not accessible over Git.");
|
||||
w.println();
|
||||
w.println("If you think this is an error, contact support at support@overleaf.com.");
|
||||
for (String line : e.getDescriptionLines()) {
|
||||
w.println(line);
|
||||
}
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,21 @@ import java.util.List;
|
||||
|
||||
public class MissingRepositoryException extends SnapshotAPIException {
|
||||
|
||||
private String message = "";
|
||||
|
||||
public MissingRepositoryException() {
|
||||
}
|
||||
|
||||
public MissingRepositoryException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJSON(JsonElement json) {}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "project not accessible over git";
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,9 +73,14 @@ public abstract class Request<T extends Result> {
|
||||
int sc = httpCause.getStatusCode();
|
||||
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
if (sc >= 400 && sc < 500) {
|
||||
} else if (sc == HttpServletResponse.SC_NOT_FOUND) {
|
||||
throw new MissingRepositoryException();
|
||||
} else if (sc >= 400 && sc < 500) {
|
||||
throw new MissingRepositoryException(
|
||||
"This project is currently inaccessible over Git.\n" +
|
||||
"\n" +
|
||||
"If you think this is an error, contact support at support@overleaf.com."
|
||||
);
|
||||
}
|
||||
throw new FailedConnectionException(cause);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user