Browse Source

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>
stable-4.7
David Pursehouse 8 years ago committed by Matthias Sohn
parent
commit
590141163f
  1. 3
      org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
  2. 11
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
  3. 1
      org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties
  4. 1
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java

3
org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF

@ -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)"

11
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java

@ -59,6 +59,7 @@ import java.io.InputStreamReader;
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.LfsRepositoryReadOnly;
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 @@ import com.google.gson.GsonBuilder;
* @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 @@ public abstract class LfsProtocolServlet extends HttpServlet {
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

1
org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties

@ -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}

1
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java

@ -68,4 +68,5 @@ public class LfsText extends TranslationBundle {
/***/ public String repositoryReadOnly; /***/ public String repositoryReadOnly;
/***/ public String lfsUnavailable; /***/ public String lfsUnavailable;
/***/ public String lfsUnathorized; /***/ public String lfsUnathorized;
/***/ public String lfsFailedToGetRepository;
} }

Loading…
Cancel
Save