Merge changes I38e1798e,Id1fe1c20,I945ba188,I2c6be9cb
* changes: Allow setting detail message and cause when constructing most exceptions Use message from ServiceNotAuthorizedException, ServiceNotEnabledException dumb HTTP: Clarify AsIsFilter by introducing req and res locals Clarify description of ServiceNotAuthorizedException
This commit is contained in:
commit
2508f1695f
|
@ -80,14 +80,16 @@ public void destroy() {
|
|||
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
try {
|
||||
final Repository db = getRepository(request);
|
||||
asIs.access((HttpServletRequest) request, db);
|
||||
asIs.access(req, db);
|
||||
chain.doFilter(request, response);
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
((HttpServletResponse) response).sendError(SC_UNAUTHORIZED);
|
||||
res.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
((HttpServletResponse) response).sendError(SC_FORBIDDEN);
|
||||
res.sendError(SC_FORBIDDEN, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,11 +137,10 @@ public void doFilter(ServletRequest request, ServletResponse response,
|
|||
try {
|
||||
rp = receivePackFactory.create(req, getRepository(req));
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
rsp.sendError(SC_UNAUTHORIZED);
|
||||
rsp.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
return;
|
||||
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
sendError(req, rsp, SC_FORBIDDEN);
|
||||
sendError(req, rsp, SC_FORBIDDEN, e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,10 +137,10 @@ public void doFilter(final ServletRequest request,
|
|||
sendError(req, res, SC_NOT_FOUND);
|
||||
return;
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
sendError(req, res, SC_FORBIDDEN);
|
||||
sendError(req, res, SC_FORBIDDEN, e.getMessage());
|
||||
return;
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
res.sendError(SC_UNAUTHORIZED);
|
||||
res.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
return;
|
||||
} catch (ServiceMayNotContinueException e) {
|
||||
sendError(req, res, SC_FORBIDDEN, e.getMessage());
|
||||
|
|
|
@ -98,7 +98,7 @@ public void doFilter(ServletRequest request, ServletResponse response,
|
|||
try {
|
||||
begin(req, db);
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
res.sendError(SC_UNAUTHORIZED);
|
||||
res.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
return;
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
sendError(req, res, SC_FORBIDDEN, e.getMessage());
|
||||
|
@ -132,11 +132,9 @@ private void service(ServletRequest request, ServletResponse response)
|
|||
advertise(req, new PacketLineOutRefAdvertiser(out));
|
||||
buf.close();
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
res.sendError(SC_UNAUTHORIZED);
|
||||
|
||||
res.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
sendError(req, res, SC_FORBIDDEN);
|
||||
|
||||
sendError(req, res, SC_FORBIDDEN, e.getMessage());
|
||||
} catch (ServiceMayNotContinueException e) {
|
||||
if (e.isOutput())
|
||||
buf.close();
|
||||
|
|
|
@ -137,11 +137,10 @@ public void doFilter(ServletRequest request, ServletResponse response,
|
|||
try {
|
||||
rp = uploadPackFactory.create(req, getRepository(req));
|
||||
} catch (ServiceNotAuthorizedException e) {
|
||||
rsp.sendError(SC_UNAUTHORIZED);
|
||||
rsp.sendError(SC_UNAUTHORIZED, e.getMessage());
|
||||
return;
|
||||
|
||||
} catch (ServiceNotEnabledException e) {
|
||||
sendError(req, rsp, SC_FORBIDDEN);
|
||||
sendError(req, rsp, SC_FORBIDDEN, e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -531,7 +531,6 @@ selectingCommits=Selecting commits
|
|||
sequenceTooLargeForDiffAlgorithm=Sequence too large for difference algorithm.
|
||||
serviceNotEnabledNoName=Service not enabled
|
||||
serviceNotPermitted={0} not permitted
|
||||
serviceNotPermittedNoName=Service not permitted
|
||||
shallowCommitsAlreadyInitialized=Shallow commits have already been initialized
|
||||
shortCompressedStreamAt=Short compressed stream at {0}
|
||||
shortReadOfBlock=Short read of block.
|
||||
|
@ -602,6 +601,7 @@ unableToCheckConnectivity=Unable to check connectivity.
|
|||
unableToCreateNewObject=Unable to create new object: {0}
|
||||
unableToStore=Unable to store {0}.
|
||||
unableToWrite=Unable to write {0}
|
||||
unauthorized=Unauthorized
|
||||
unencodeableFile=Unencodable file: {0}
|
||||
unexpectedCompareResult=Unexpected metadata comparison result: {0}
|
||||
unexpectedEndOfConfigFile=Unexpected end of config file
|
||||
|
|
|
@ -43,6 +43,15 @@
|
|||
public class RefNotFoundException extends GitAPIException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public RefNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,15 @@ public class StashApplyFailureException extends GitAPIException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public StashApplyFailureException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a StashApplyFailedException
|
||||
*
|
||||
|
|
|
@ -61,4 +61,13 @@ public UnmergedPathsException() {
|
|||
public UnmergedPathsException(Throwable cause) {
|
||||
super(JGitText.get().unmergedPaths, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public UnmergedPathsException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,4 +51,25 @@
|
|||
*/
|
||||
public class DiffInterruptedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public DiffInterruptedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @since 4.1
|
||||
*/
|
||||
public DiffInterruptedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DiffInterruptedException() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,20 @@ public class LockFailedException extends IOException {
|
|||
|
||||
private File file;
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* file that could not be locked
|
||||
* @param message
|
||||
* exception message
|
||||
* @param cause
|
||||
* cause, for later retrieval by {@link Throwable#getCause()}
|
||||
* @since 4.1
|
||||
*/
|
||||
public LockFailedException(File file, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a CannotLockException for the given file and message
|
||||
*
|
||||
|
|
|
@ -590,7 +590,6 @@ public static JGitText get() {
|
|||
/***/ public String sequenceTooLargeForDiffAlgorithm;
|
||||
/***/ public String serviceNotEnabledNoName;
|
||||
/***/ public String serviceNotPermitted;
|
||||
/***/ public String serviceNotPermittedNoName;
|
||||
/***/ public String shallowCommitsAlreadyInitialized;
|
||||
/***/ public String shortCompressedStreamAt;
|
||||
/***/ public String shortReadOfBlock;
|
||||
|
@ -661,6 +660,7 @@ public static JGitText get() {
|
|||
/***/ public String unableToCreateNewObject;
|
||||
/***/ public String unableToStore;
|
||||
/***/ public String unableToWrite;
|
||||
/***/ public String unauthorized;
|
||||
/***/ public String unencodeableFile;
|
||||
/***/ public String unexpectedCompareResult;
|
||||
/***/ public String unexpectedEndOfConfigFile;
|
||||
|
|
|
@ -45,12 +45,34 @@
|
|||
|
||||
import org.eclipse.jgit.internal.JGitText;
|
||||
|
||||
/** Indicates the request service is not authorized for current user. */
|
||||
/**
|
||||
* Indicates that the requested service requires authentication that
|
||||
* the current user has not provided.
|
||||
* <p>
|
||||
* This corresponds to response code
|
||||
* {@link javax.servlet.http.HttpServletResponse#SC_UNAUTHORIZED}.
|
||||
*/
|
||||
public class ServiceNotAuthorizedException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** Indicates the request service is not available. */
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public ServiceNotAuthorizedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @since 4.1
|
||||
*/
|
||||
public ServiceNotAuthorizedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ServiceNotAuthorizedException() {
|
||||
super(JGitText.get().serviceNotPermittedNoName);
|
||||
super(JGitText.get().unauthorized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,23 @@
|
|||
public class ServiceNotEnabledException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
* @since 4.1
|
||||
*/
|
||||
public ServiceNotEnabledException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @since 4.1
|
||||
*/
|
||||
public ServiceNotEnabledException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/** Indicates the request service is not available. */
|
||||
public ServiceNotEnabledException() {
|
||||
super(JGitText.get().serviceNotEnabledNoName);
|
||||
|
|
Loading…
Reference in New Issue