use of org.haiku.haikudepotserver.api1.model.repository.RemoveRepositorySourceMirrorResult in project haikudepotserver by haiku.
the class RepositoryApiImpl method removeRepositorySourceMirror.
@Override
public RemoveRepositorySourceMirrorResult removeRepositorySourceMirror(RemoveRepositorySourceMirrorRequest request) {
Preconditions.checkArgument(null != request, "the request is required");
Preconditions.checkArgument(StringUtils.isNotBlank(request.code), "the code is required on the request");
final ObjectContext context = serverRuntime.newContext();
RepositorySourceMirror repositorySourceMirror = RepositorySourceMirror.tryGetByCode(context, request.code).orElseThrow(() -> new ObjectNotFoundException(RepositorySourceMirror.class.getSimpleName(), request.code));
if (repositorySourceMirror.getIsPrimary()) {
throw new IllegalStateException("unable to remove the primary mirror");
}
repositorySourceMirror.getRepositorySource().getRepository().setModifyTimestamp();
context.deleteObject(repositorySourceMirror);
context.commitChanges();
LOGGER.info("did remote the repository source mirror [{}]", request.code);
return new RemoveRepositorySourceMirrorResult();
}
Aggregations