/** * Create exception with bytes of the invalid object id. * * @param bytes containing the invalid id. * @param offset in the byte array where the error occurred. * @param length of the sequence of invalid bytes. */ public InvalidLongObjectIdException(byte[] bytes, int offset, int length) { super(MessageFormat.format(LfsText.get().invalidLongId, asAscii(bytes, offset, length))); }
repo = getLargeFileRepository(request, path); if (repo == null) { throw new LfsException("unexpected error"); //$NON-NLS-1$ gson.toJson(handler.process(), w); } catch (LfsValidationError e) { sendError(res, w, SC_UNPROCESSABLE_ENTITY, e.getMessage()); } catch (LfsRepositoryNotFound e) { sendError(res, w, SC_NOT_FOUND, e.getMessage()); } catch (LfsRepositoryReadOnly e) { sendError(res, w, SC_FORBIDDEN, e.getMessage()); } catch (LfsRateLimitExceeded e) { sendError(res, w, SC_RATE_LIMIT_EXCEEDED, e.getMessage()); } catch (LfsBandwidthLimitExceeded e) { sendError(res, w, SC_BANDWIDTH_LIMIT_EXCEEDED, e.getMessage()); } catch (LfsInsufficientStorage e) { sendError(res, w, SC_INSUFFICIENT_STORAGE, e.getMessage()); } catch (LfsUnavailable e) { sendError(res, w, SC_SERVICE_UNAVAILABLE, e.getMessage()); } catch (LfsException e) { sendError(res, w, SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { w.flush();
/** * Convert a LongObjectId from hex characters. * * @param str * the string to read from. Must be 64 characters long. * @return the converted object id. */ public static LongObjectId fromString(String str) { if (str.length() != Constants.LONG_OBJECT_ID_STRING_LENGTH) throw new InvalidLongObjectIdException(str); return fromHexString(org.eclipse.jgit.lib.Constants.encodeASCII(str), 0); }
private void verifyHash() { AnyLongObjectId contentHash = LongObjectId .fromRaw(out.getMessageDigest().digest()); if (!contentHash.equals(id)) { abort(); throw new CorruptLongObjectException(id, contentHash, MessageFormat.format(LfsServerText.get().corruptLongObject, contentHash, id)); } }
private AnyLongObjectId getObjectToTransfer(HttpServletRequest req, HttpServletResponse rsp) throws IOException { String info = req.getPathInfo(); int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH; if (info.length() != length) { sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat .format(LfsServerText.get().invalidPathInfo, info)); return null; } try { return LongObjectId.fromString(info.substring(1, length)); } catch (InvalidLongObjectIdException e) { sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage()); return null; } }
private void uploadFile(Protocol.ObjectInfo o, Protocol.Action uploadAction, Path path) throws IOException, CorruptMediaFile { HttpConnection contentServer = LfsConnectionFactory .getLfsContentConnection(getRepository(), uploadAction, METHOD_PUT); contentServer.setDoOutput(true); try (OutputStream out = contentServer .getOutputStream()) { long size = Files.copy(path, out); if (size != o.size) { throw new CorruptMediaFile(path, o.size, size); } } int responseCode = contentServer.getResponseCode(); if (responseCode != HTTP_OK) { throw new IOException(MessageFormat.format( LfsText.get().serverFailure, contentServer.getURL(), Integer.valueOf(responseCode))); } } }
throw new LfsConfigInvalidException( LfsText.get().lfsNoDownloadUrl, ex); throw new LfsConfigInvalidException(LfsText.get().lfsNoDownloadUrl);
.format(LfsText.get().lfsFailedToGetRepository, path); LOG.error(error); throw new LfsException(error); LfsGson.toJson(handler.process(), w); } catch (LfsValidationError e) { sendError(res, w, SC_UNPROCESSABLE_ENTITY, e.getMessage()); } catch (LfsRepositoryNotFound e) { sendError(res, w, SC_NOT_FOUND, e.getMessage()); } catch (LfsRepositoryReadOnly e) { sendError(res, w, SC_FORBIDDEN, e.getMessage()); } catch (LfsRateLimitExceeded e) { sendError(res, w, SC_RATE_LIMIT_EXCEEDED, e.getMessage()); } catch (LfsBandwidthLimitExceeded e) { sendError(res, w, SC_BANDWIDTH_LIMIT_EXCEEDED, e.getMessage()); } catch (LfsInsufficientStorage e) { sendError(res, w, SC_INSUFFICIENT_STORAGE, e.getMessage()); } catch (LfsUnavailable e) { sendError(res, w, SC_SERVICE_UNAVAILABLE, e.getMessage()); } catch (LfsUnauthorized e) { sendError(res, w, SC_UNAUTHORIZED, e.getMessage()); } catch (LfsException e) { sendError(res, w, SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { w.flush();
/** * Convert a LongObjectId from hex characters. * * @param str * the string to read from. Must be 64 characters long. * @return the converted object id. */ public static LongObjectId fromString(final String str) { if (str.length() != Constants.LONG_OBJECT_ID_STRING_LENGTH) throw new InvalidLongObjectIdException(str); return fromHexString(org.eclipse.jgit.lib.Constants.encodeASCII(str), 0); }
/** * Create exception with bytes of the invalid object id. * * @param bytes containing the invalid id. * @param offset in the byte array where the error occurred. * @param length of the sequence of invalid bytes. */ public InvalidLongObjectIdException(byte[] bytes, int offset, int length) { super(MessageFormat.format(LfsText.get().invalidLongId, asAscii(bytes, offset, length))); }
private void verifyHash() { AnyLongObjectId contentHash = LongObjectId .fromRaw(out.getMessageDigest().digest()); if (!contentHash.equals(id)) { abort(); throw new CorruptLongObjectException(id, contentHash, MessageFormat.format(LfsText.get().corruptLongObject, contentHash, id)); } }
/** * Retrieve object id from request * * @param req * servlet request * @param rsp * servlet response * @return object id, or <code>null</code> if the object id could not be * retrieved * @throws java.io.IOException * if an I/O error occurs * @since 4.6 */ protected AnyLongObjectId getObjectToTransfer(HttpServletRequest req, HttpServletResponse rsp) throws IOException { String info = req.getPathInfo(); int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH; if (info.length() != length) { sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat .format(LfsServerText.get().invalidPathInfo, info)); return null; } try { return LongObjectId.fromString(info.substring(1, length)); } catch (InvalidLongObjectIdException e) { sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage()); return null; } }
long fsSize = Files.size(mediaFile); if (fsSize != size) { throw new CorruptMediaFile(mediaFile, size, fsSize); } else { FileUtils.delete(tmpFile.toFile());
private void fromHexString(byte[] bs, int p) { try { w1 = RawParseUtils.parseHexInt64(bs, p); w2 = RawParseUtils.parseHexInt64(bs, p + 16); w3 = RawParseUtils.parseHexInt64(bs, p + 32); w4 = RawParseUtils.parseHexInt64(bs, p + 48); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH); } }
private void fromHexString(final byte[] bs, int p) { try { w1 = RawParseUtils.parseHexInt64(bs, p); w2 = RawParseUtils.parseHexInt64(bs, p + 16); w3 = RawParseUtils.parseHexInt64(bs, p + 32); w4 = RawParseUtils.parseHexInt64(bs, p + 48); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH); } }
private static final AbbreviatedLongObjectId fromHexString(final byte[] bs, int ptr, final int end) { try { final long a = hexUInt64(bs, ptr, end); final long b = hexUInt64(bs, ptr + 16, end); final long c = hexUInt64(bs, ptr + 32, end); final long d = hexUInt64(bs, ptr + 48, end); return new AbbreviatedLongObjectId(end - ptr, a, b, c, d); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, ptr, end - ptr); } }
private static final AbbreviatedLongObjectId fromHexString(final byte[] bs, int ptr, final int end) { try { final long a = hexUInt64(bs, ptr, end); final long b = hexUInt64(bs, ptr + 16, end); final long c = hexUInt64(bs, ptr + 32, end); final long d = hexUInt64(bs, ptr + 48, end); return new AbbreviatedLongObjectId(end - ptr, a, b, c, d); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, ptr, end - ptr); } }
private static final LongObjectId fromHexString(final byte[] bs, int p) { try { final long a = RawParseUtils.parseHexInt64(bs, p); final long b = RawParseUtils.parseHexInt64(bs, p + 16); final long c = RawParseUtils.parseHexInt64(bs, p + 32); final long d = RawParseUtils.parseHexInt64(bs, p + 48); return new LongObjectId(a, b, c, d); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH); } }
private static final LongObjectId fromHexString(byte[] bs, int p) { try { final long a = RawParseUtils.parseHexInt64(bs, p); final long b = RawParseUtils.parseHexInt64(bs, p + 16); final long c = RawParseUtils.parseHexInt64(bs, p + 32); final long d = RawParseUtils.parseHexInt64(bs, p + 48); return new LongObjectId(a, b, c, d); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidLongObjectIdException(bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH); } }