/** Converting App model to REST DTO. */ public RepositoryBaseResource getRepositoryRestModel(Request request, Repository repository) { RepositoryResource resource = null; if (repository.getRepositoryKind().isFacetAvailable(ProxyRepository.class)) { resource = getRepositoryProxyRestModel(repository.adaptToFacet(ProxyRepository.class)); } else if (repository.getRepositoryKind().isFacetAvailable(ShadowRepository.class)) { return getRepositoryShadowRestModel(request, repository.adaptToFacet(ShadowRepository.class)); } else { resource = new RepositoryResource(); } resource.setContentResourceURI(repositoryURLBuilder.getExposedRepositoryContentUrl(repository)); resource.setProvider(NexusCompat.getRepositoryProviderHint(repository)); resource.setProviderRole(NexusCompat.getRepositoryProviderRole(repository)); resource.setFormat(repository.getRepositoryContentClass().getId()); resource.setRepoType(getRestRepoType(repository)); resource.setId(repository.getId()); resource.setName(repository.getName()); resource.setWritePolicy(repository.getWritePolicy().name()); resource.setBrowseable(repository.isBrowseable()); resource.setIndexable(repository.isSearchable()); resource.setExposed(repository.isExposed()); resource.setNotFoundCacheTTL(repository.getNotFoundCacheTimeToLive()); // TODO: remove the default local storage, this is a work around for NEXUS-1994 // the new 1.4 API doesn't store the default URL, well, it is part of the CRepo, but it is not // exposed. // so we can figure it out again, I think the default local Storage should be removed from the // REST message // which is part of the reason for not exposing it. The other part is it is not used anywhere // except to set // the localUrl if not already set. // apples to apples here, man i hate this section of code!!!! // always set to default (see AbstractRepositoryConfigurator) String defaultLocalStorageUrl = ((CRepositoryCoreConfiguration) repository.getCurrentCoreConfiguration()) .getConfiguration(false) .defaultLocalStorageUrl; resource.setDefaultLocalStorageUrl(defaultLocalStorageUrl); // if not user set (but using default), this is null, otherwise it contains user-set value String overrideLocalStorageUrl = ((CRepositoryCoreConfiguration) repository.getCurrentCoreConfiguration()) .getConfiguration(false) .getLocalStorage() .getUrl(); if (StringUtils.isNotBlank(overrideLocalStorageUrl)) { resource.setOverrideLocalStorageUrl(overrideLocalStorageUrl); } if (repository.getRepositoryKind().isFacetAvailable(MavenRepository.class)) { resource.setRepoPolicy( repository.adaptToFacet(MavenRepository.class).getRepositoryPolicy().toString()); if (repository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) { resource.setChecksumPolicy( repository.adaptToFacet(MavenProxyRepository.class).getChecksumPolicy().toString()); resource.setDownloadRemoteIndexes( repository.adaptToFacet(MavenProxyRepository.class).isDownloadRemoteIndexes()); } } // as this is a required field on ui, we need this to be set for non-maven type repos else { resource.setRepoPolicy(RepositoryPolicy.MIXED.name()); resource.setChecksumPolicy(ChecksumPolicy.IGNORE.name()); resource.setDownloadRemoteIndexes(false); } return resource; }