Logger.error("Cannot move, parent item is not a folder. Parent: %s Item: %s", parent, toItem);
return;
}
Logger.info("Attempting to move file from: %s(%s) To: %s(%s)", from, fromId, RuleUtils.getParent(to), toItem);
HttpResponse resp = req("/files/" + fromId)
.body(new Gson().toJson(new BoxMoveReq(toItem.id, RuleUtils.basename(to))))
.put();
if (resp.success()) {
BoxItem file = new Gson().fromJson(resp.getJson(), BoxItem.class);
invalidate(RuleUtils.getParent(from));
invalidate(from);
invalidate(RuleUtils.getParent(to));
invalidate(to);
Logger.info("Successfully moved file from %s to %s. File: %s",
from, to, file);
return;
}
Logger.error("Failed moving from %s to %s Error: %s", from, to, getError(resp));
// 400 indicates file name collision
if (Integer.valueOf(400).equals(resp.getStatus())) {
throw new FileMoveCollisionException(String.format("From: %s To: %s", from, to));
}
}