try {
String uri = getItemUri(parentId, sessionInfo);
String srcUri = getItemUri(srcNodeId, sessionInfo);
String srcSegment = Text.getName(srcUri, true);
OrderPatchMethod method;
if (beforeNodeId == null) {
// move src to the end
method = new OrderPatchMethod(uri, OrderingConstants.ORDERING_TYPE_CUSTOM, srcSegment, false);
} else {
// insert src before the targetSegment
String beforeUri = getItemUri(beforeNodeId, sessionInfo);
String targetSegment = Text.getName(beforeUri, true);
method = new OrderPatchMethod(uri, OrderingConstants.ORDERING_TYPE_CUSTOM, srcSegment, targetSegment, true);
}
methods.add(method);
} catch (IOException e) {
throw new RepositoryException(e);
}