in src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectAction.java [50:91]
public Response<?> apply(ProjectResource resource, RevisionInput input) throws RestApiException {
if (!preConditions.canCallFetchApi()) {
throw new AuthException("not allowed to call fetch command");
}
try {
if (Strings.isNullOrEmpty(input.getLabel())) {
throw new BadRequestException("Source label cannot be null or empty");
}
if (Strings.isNullOrEmpty(input.getRefName())) {
throw new BadRequestException("Ref-update refname cannot be null or empty");
}
if (Objects.isNull(input.getRevisionData())) {
deleteRefCommand.deleteRef(resource.getNameKey(), input.getRefName(), input.getLabel());
return Response.created(input);
}
if (Objects.isNull(input.getRevisionData().getCommitObject())
|| Objects.isNull(input.getRevisionData().getCommitObject().getContent())
|| input.getRevisionData().getCommitObject().getContent().length == 0
|| Objects.isNull(input.getRevisionData().getCommitObject().getType())) {
throw new BadRequestException("Ref-update commit object cannot be null or empty");
}
if (Objects.isNull(input.getRevisionData().getTreeObject())
|| Objects.isNull(input.getRevisionData().getTreeObject().getContent())
|| Objects.isNull(input.getRevisionData().getTreeObject().getType())) {
throw new BadRequestException("Ref-update tree object cannot be null");
}
command.applyObject(
resource.getNameKey(), input.getRefName(), input.getRevisionData(), input.getLabel());
return Response.created(input);
} catch (MissingParentObjectException e) {
throw new ResourceConflictException(e.getMessage(), e);
} catch (NumberFormatException | IOException e) {
throw RestApiException.wrap(e.getMessage(), e);
} catch (RefUpdateException e) {
throw new UnprocessableEntityException(e.getMessage());
}
}