use of org.haiku.haikudepotserver.api1.model.repository.RemoveRepositorySourceMirrorRequest in project haikudepotserver by haiku.
the class RepositoryApiIT method testRemoveRepositorySourceMirror.
@Test
public void testRemoveRepositorySourceMirror() {
integrationTestSupportService.createStandardTestData();
RemoveRepositorySourceMirrorRequest request = new RemoveRepositorySourceMirrorRequest();
request.code = "testreposrc_xyz_m_notpri";
{
ObjectContext context = serverRuntime.newContext();
Assertions.assertThat(RepositorySourceMirror.tryGetByCode(context, "testreposrc_xyz_m_notpri").isPresent()).isTrue();
}
// ------------------------------------
repositoryApi.removeRepositorySourceMirror(request);
// ------------------------------------
{
ObjectContext context = serverRuntime.newContext();
Assertions.assertThat(RepositorySourceMirror.tryGetByCode(context, "testreposrc_xyz_m_notpri").isPresent()).isFalse();
}
}
use of org.haiku.haikudepotserver.api1.model.repository.RemoveRepositorySourceMirrorRequest 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