/** Converting App model to REST DTO. */ public RepositoryProxyResource getRepositoryProxyRestModel(ProxyRepository repository) { RepositoryProxyResource resource = new RepositoryProxyResource(); resource.setRemoteStorage(new RepositoryResourceRemoteStorage()); resource.getRemoteStorage().setRemoteStorageUrl(repository.getRemoteUrl()); resource .getRemoteStorage() .setAuthentication( AbstractGlobalConfigurationPlexusResource.convert( NexusCompat.getRepositoryRawConfiguration(repository) .getRemoteStorage() .getAuthentication())); resource .getRemoteStorage() .setConnectionSettings( AbstractGlobalConfigurationPlexusResource.convert( NexusCompat.getRepositoryRawConfiguration(repository) .getRemoteStorage() .getConnectionSettings())); resource .getRemoteStorage() .setHttpProxySettings( AbstractGlobalConfigurationPlexusResource.convert( NexusCompat.getRepositoryRawConfiguration(repository) .getRemoteStorage() .getHttpProxySettings())); // set auto block resource.setAutoBlockActive(repository.isAutoBlockActive()); // set content validation resource.setFileTypeValidation(repository.isFileTypeValidation()); if (repository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) { resource.setArtifactMaxAge( repository.adaptToFacet(MavenProxyRepository.class).getArtifactMaxAge()); resource.setMetadataMaxAge( repository.adaptToFacet(MavenProxyRepository.class).getMetadataMaxAge()); resource.setItemMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getItemMaxAge()); } else { // This is a total hack to be able to retrieve this data from a non core repo if available try { Method artifactMethod = repository.getClass().getMethod("getArtifactMaxAge", new Class<?>[0]); Method metadataMethod = repository.getClass().getMethod("getMetadataMaxAge", new Class<?>[0]); Method itemMethod = repository.getClass().getMethod("getItemMaxAge", new Class<?>[0]); if (artifactMethod != null) { resource.setArtifactMaxAge((Integer) artifactMethod.invoke(repository, new Object[0])); } if (metadataMethod != null) { resource.setMetadataMaxAge((Integer) metadataMethod.invoke(repository, new Object[0])); } if (itemMethod != null) { resource.setItemMaxAge((Integer) itemMethod.invoke(repository, new Object[0])); } } catch (Exception e) { // nothing to do here, doesn't support artifactmax age } } return resource; }