Use the same variable to check and extract LFS object id
It is easier to maintain when the same variable is used for both check and extraction of LFS object id. Change-Id: I5406f9bc4a085aa164c4565a9667ad2925105190 Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This commit is contained in:
parent
a66b4c29a8
commit
8f60297861
|
@ -128,13 +128,14 @@ protected void doGet(HttpServletRequest req,
|
||||||
private AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
|
private AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
|
||||||
HttpServletResponse rsp) throws IOException {
|
HttpServletResponse rsp) throws IOException {
|
||||||
String info = req.getPathInfo();
|
String info = req.getPathInfo();
|
||||||
if (info.length() != 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH) {
|
int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH;
|
||||||
|
if (info.length() != length) {
|
||||||
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat
|
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat
|
||||||
.format(LfsServerText.get().invalidPathInfo, info));
|
.format(LfsServerText.get().invalidPathInfo, info));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return LongObjectId.fromString(info.substring(1, 65));
|
return LongObjectId.fromString(info.substring(1, length));
|
||||||
} catch (InvalidLongObjectIdException e) {
|
} catch (InvalidLongObjectIdException e) {
|
||||||
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage());
|
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue