use of org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror in project haikudepotserver by haiku.
the class RepositoryDumpExportJobRunner method createDumpRepository.
private DumpExportRepository createDumpRepository(Repository repository) {
DumpExportRepository dumpRepository = new DumpExportRepository();
dumpRepository.setCode(repository.getCode());
dumpRepository.setName(repository.getName());
dumpRepository.setDescription(repository.getDescription());
dumpRepository.setInformationUrl(repository.getInformationUrl());
dumpRepository.setRepositorySources(repository.getRepositorySources().stream().filter(_RepositorySource::getActive).filter(rs -> rs.tryGetPrimaryMirror().isPresent()).sorted(Comparator.comparing(_RepositorySource::getCode)).map((rs) -> {
DumpExportRepositorySource dumpRepositorySource = new DumpExportRepositorySource();
dumpRepositorySource.setCode(rs.getCode());
dumpRepositorySource.setArchitectureCode(Optional.ofNullable(rs.getArchitecture()).map(Architecture::getCode).orElse(null));
dumpRepositorySource.setIdentifier(rs.getIdentifier());
dumpRepositorySource.setRepoInfoUrl(rs.getIdentifier());
// ^^ deprecated; repoInfoUrl is replaced with identifier
dumpRepositorySource.setExtraIdentifiers(rs.getExtraIdentifiers());
dumpRepositorySource.setRepositorySourceMirrors(rs.getRepositorySourceMirrors().stream().filter(_RepositorySourceMirror::getActive).sorted(Comparator.comparing(_RepositorySourceMirror::getCode)).map(rsm -> {
DumpExportRepositorySourceMirror dumpMirror = new DumpExportRepositorySourceMirror();
dumpMirror.setBaseUrl(rsm.getBaseUrl());
dumpMirror.setCountryCode(rsm.getCountry().getCode());
dumpMirror.setDescription(rsm.getDescription());
dumpMirror.setIsPrimary(rsm.getIsPrimary());
return dumpMirror;
}).collect(Collectors.toList()));
return dumpRepositorySource;
}).collect(Collectors.toList()));
return dumpRepository;
}
use of org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror in project haikudepotserver by haiku.
the class RepositoryApiImpl method getRepository.
@Override
public GetRepositoryResult getRepository(GetRepositoryRequest getRepositoryRequest) {
Preconditions.checkNotNull(getRepositoryRequest);
Preconditions.checkState(!Strings.isNullOrEmpty(getRepositoryRequest.code));
final ObjectContext context = serverRuntime.newContext();
final Repository repository = getRepositoryOrThrow(context, getRepositoryRequest.code);
if (!permissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), repository, Permission.REPOSITORY_VIEW)) {
throw new AccessDeniedException("unable to view repository [" + repository + "]");
}
GetRepositoryResult result = new GetRepositoryResult();
result.active = repository.getActive();
result.code = repository.getCode();
result.name = repository.getName();
result.createTimestamp = repository.getCreateTimestamp().getTime();
result.modifyTimestamp = repository.getModifyTimestamp().getTime();
result.informationUrl = repository.getInformationUrl();
result.hasPassword = StringUtils.isNotBlank(repository.getPasswordHash());
result.repositorySources = repository.getRepositorySources().stream().filter(rs -> rs.getActive() || (null != getRepositoryRequest.includeInactiveRepositorySources && getRepositoryRequest.includeInactiveRepositorySources)).map(rs -> {
GetRepositoryResult.RepositorySource resultRs = new GetRepositoryResult.RepositorySource();
resultRs.active = rs.getActive();
resultRs.code = rs.getCode();
resultRs.url = rs.tryGetPrimaryMirror().map(_RepositorySourceMirror::getBaseUrl).orElse(null);
resultRs.identifier = rs.getIdentifier();
resultRs.architectureCode = Optional.ofNullable(rs.getArchitecture()).map(Architecture::getCode).orElse(null);
if (null != rs.getLastImportTimestamp()) {
resultRs.lastImportTimestamp = rs.getLastImportTimestamp().getTime();
}
return resultRs;
}).collect(Collectors.toList());
return result;
}
Aggregations