Search in sources :

Example 1 with GetRepositorySourceMirrorResult

use of org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult in project haikudepotserver by haiku.

the class RepositoryApiImpl method getRepositorySourceMirror.

@Override
public GetRepositorySourceMirrorResult getRepositorySourceMirror(GetRepositorySourceMirrorRequest request) {
    Preconditions.checkArgument(null != request, "the request must be provided");
    Preconditions.checkArgument(StringUtils.isNotBlank(request.code), "a mirror code must be provided");
    final ObjectContext context = serverRuntime.newContext();
    RepositorySourceMirror repositorySourceMirror = RepositorySourceMirror.tryGetByCode(context, request.code).orElseThrow(() -> new ObjectNotFoundException(RepositorySourceMirror.class.getSimpleName(), request.code));
    GetRepositorySourceMirrorResult result = new GetRepositorySourceMirrorResult();
    result.active = repositorySourceMirror.getActive();
    result.baseUrl = repositorySourceMirror.getBaseUrl();
    result.code = repositorySourceMirror.getCode();
    result.countryCode = repositorySourceMirror.getCountry().getCode();
    result.createTimestamp = repositorySourceMirror.getCreateTimestamp().getTime();
    result.modifyTimestamp = repositorySourceMirror.getModifyTimestamp().getTime();
    result.description = repositorySourceMirror.getDescription();
    result.isPrimary = repositorySourceMirror.getIsPrimary();
    result.repositorySourceCode = repositorySourceMirror.getRepositorySource().getCode();
    return result;
}
Also used : GetRepositorySourceMirrorResult(org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult) org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror(org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror) RepositorySourceMirror(org.haiku.haikudepotserver.dataobjects.RepositorySourceMirror) ObjectNotFoundException(org.haiku.haikudepotserver.api1.support.ObjectNotFoundException) ObjectContext(org.apache.cayenne.ObjectContext)

Example 2 with GetRepositorySourceMirrorResult

use of org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult in project haikudepotserver by haiku.

the class RepositoryApiIT method testGetRepositorySourceMirror.

@Test
public void testGetRepositorySourceMirror() {
    integrationTestSupportService.createStandardTestData();
    GetRepositorySourceMirrorRequest request = new GetRepositorySourceMirrorRequest();
    request.code = "testreposrc_xyz_m_notpri";
    // ------------------------------------
    GetRepositorySourceMirrorResult result = repositoryApi.getRepositorySourceMirror(request);
    // ------------------------------------
    Assertions.assertThat(result.code).isEqualTo("testreposrc_xyz_m_notpri");
    Assertions.assertThat(result.baseUrl).isEqualTo("file://not-found/on-disk");
    Assertions.assertThat(result.countryCode).isEqualTo("ZA");
// ....
}
Also used : GetRepositorySourceMirrorResult(org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult) GetRepositorySourceMirrorRequest(org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorRequest) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

GetRepositorySourceMirrorResult (org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult)2 ObjectContext (org.apache.cayenne.ObjectContext)1 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 GetRepositorySourceMirrorRequest (org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorRequest)1 ObjectNotFoundException (org.haiku.haikudepotserver.api1.support.ObjectNotFoundException)1 RepositorySourceMirror (org.haiku.haikudepotserver.dataobjects.RepositorySourceMirror)1 org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror (org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror)1 Test (org.junit.jupiter.api.Test)1