/** * 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); }
/** * 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 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; } }
/** * 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))); }
/** * 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; } }
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 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); } }
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); } }