LfsProtocolServlet: Improve error on getLargeFileRepository failure
Externalize the error message and make it more specific. Also emit an error log. Change-Id: Ie7b1c90c54673bfb8e133fb0aa19a117d4ca6587 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
7245aa0316
commit
590141163f
|
@ -33,4 +33,5 @@ Import-Package: com.google.gson;version="[2.2.4,3.0.0)",
|
||||||
org.eclipse.jgit.nls;version="[4.7.0,4.8.0)",
|
org.eclipse.jgit.nls;version="[4.7.0,4.8.0)",
|
||||||
org.eclipse.jgit.transport.http;version="[4.7.0,4.8.0)",
|
org.eclipse.jgit.transport.http;version="[4.7.0,4.8.0)",
|
||||||
org.eclipse.jgit.transport.http.apache;version="[4.7.0,4.8.0)",
|
org.eclipse.jgit.transport.http.apache;version="[4.7.0,4.8.0)",
|
||||||
org.eclipse.jgit.util;version="[4.7.0,4.8.0)"
|
org.eclipse.jgit.util;version="[4.7.0,4.8.0)",
|
||||||
|
org.slf4j;version="[1.7.0,2.0.0)"
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -75,6 +76,9 @@
|
||||||
import org.eclipse.jgit.lfs.errors.LfsUnauthorized;
|
import org.eclipse.jgit.lfs.errors.LfsUnauthorized;
|
||||||
import org.eclipse.jgit.lfs.errors.LfsUnavailable;
|
import org.eclipse.jgit.lfs.errors.LfsUnavailable;
|
||||||
import org.eclipse.jgit.lfs.errors.LfsValidationError;
|
import org.eclipse.jgit.lfs.errors.LfsValidationError;
|
||||||
|
import org.eclipse.jgit.lfs.internal.LfsText;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gson.FieldNamingPolicy;
|
import com.google.gson.FieldNamingPolicy;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
@ -88,6 +92,8 @@
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public abstract class LfsProtocolServlet extends HttpServlet {
|
public abstract class LfsProtocolServlet extends HttpServlet {
|
||||||
|
private static Logger LOG = LoggerFactory
|
||||||
|
.getLogger(LfsProtocolServlet.class);
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -183,7 +189,10 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res)
|
||||||
try {
|
try {
|
||||||
repo = getLargeFileRepository(request, path);
|
repo = getLargeFileRepository(request, path);
|
||||||
if (repo == null) {
|
if (repo == null) {
|
||||||
throw new LfsException("unexpected error"); //$NON-NLS-1$
|
String error = MessageFormat
|
||||||
|
.format(LfsText.get().lfsFailedToGetRepository, path);
|
||||||
|
LOG.error(error);
|
||||||
|
throw new LfsException(error);
|
||||||
}
|
}
|
||||||
res.setStatus(SC_OK);
|
res.setStatus(SC_OK);
|
||||||
TransferHandler handler = TransferHandler
|
TransferHandler handler = TransferHandler
|
||||||
|
|
|
@ -8,3 +8,4 @@ repositoryNotFound=Repository {0} not found
|
||||||
repositoryReadOnly=Repository {0} is read-only
|
repositoryReadOnly=Repository {0} is read-only
|
||||||
lfsUnavailable=LFS is not available for repository {0}
|
lfsUnavailable=LFS is not available for repository {0}
|
||||||
lfsUnathorized=Not authorized to perform operation {0} on repository {1}
|
lfsUnathorized=Not authorized to perform operation {0} on repository {1}
|
||||||
|
lfsFailedToGetRepository=failed to get repository {0}
|
||||||
|
|
|
@ -68,4 +68,5 @@ public static LfsText get() {
|
||||||
/***/ public String repositoryReadOnly;
|
/***/ public String repositoryReadOnly;
|
||||||
/***/ public String lfsUnavailable;
|
/***/ public String lfsUnavailable;
|
||||||
/***/ public String lfsUnathorized;
|
/***/ public String lfsUnathorized;
|
||||||
|
/***/ public String lfsFailedToGetRepository;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue