/** * Returns true if the repository is of type {@link GroupType} * * @since 3.6.1 */ protected boolean isGroupRepository(final Repository repository) { return groupType.equals(repository.getType()); }
/** * Invalidates the group or proxy caches of the specified repository based on type. * * This is a no-op for hosted repositories. */ public static void invalidateCaches(final Repository repository) { checkNotNull(repository); if (GroupType.NAME.equals(repository.getType().getValue())) { invalidateGroupCaches(repository); } else if (ProxyType.NAME.equals(repository.getType().getValue())) { invalidateProxyAndNegativeCaches(repository); } }
@Override protected void doValidate(final Configuration configuration) throws Exception { facet(ConfigurationFacet.class).validateSection( configuration, CONFIG_KEY, Config.class, Default.class, getRepository().getType().getValidationGroup()); }
@Override protected void doValidate(final Configuration configuration) throws Exception { facet(ConfigurationFacet.class).validateSection(configuration, CONFIG_KEY, Config.class, Default.class, getRepository().getType().getValidationGroup() ); }
@Override public void cleanup(final BooleanSupplier cancelledCheck) { AtomicLong totalDeletedCount = new AtomicLong(0L); repositoryManager.browse().forEach(repository -> { if (!cancelledCheck.getAsBoolean() && !repository.getType().equals(groupType)) { totalDeletedCount.addAndGet(this.cleanup(repository, cancelledCheck)); } }); log.info("{} components cleaned up across all repositories", totalDeletedCount.get()); }
@Override protected void doValidate(final Configuration configuration) throws Exception { facet(ConfigurationFacet.class).validateSection(configuration, CONFIG_KEY, Config.class, Default.class, getRepository().getType().getValidationGroup() ); }
/** * Prefetch proxy repository index files, if possible. Returns {@code true} if successful. Accepts only maven proxy * types. Returns {@code true} if successfully prefetched files (they exist on remote and are locally cached). */ public static boolean prefetchIndexFiles(final Repository repository) throws IOException { checkNotNull(repository); checkArgument(ProxyType.NAME.equals(repository.getType().getValue())); return prefetch(repository, INDEX_PROPERTY_FILE) && prefetch(repository, INDEX_MAIN_CHUNK_FILE); }
/** * Processes this facet's associated repository as a group repository, iterating over its members. */ private void processAsGroup(final MavenGroupFacet groupFacet, final int numberOfDays) { groupFacet.members().stream() .filter(member -> hostedType.equals(member.getType()) || groupType.equals(member.getType())) .forEach(member -> member.facet(PurgeUnusedSnapshotsFacet.class).purgeUnusedSnapshots(numberOfDays)); }
@Override protected void doValidate(final Configuration configuration) throws Exception { facet(ConfigurationFacet.class).validateSection( configuration, CONFIG_KEY, Config.class, Default.class, getRepository().getType().getValidationGroup()); }
/** * Invalidates the group caches for given repository. */ public static void invalidateGroupCaches(final Repository repository) { checkNotNull(repository); checkArgument(GroupType.NAME.equals(repository.getType().getValue())); GroupFacet groupFacet = repository.facet(GroupFacet.class); groupFacet.invalidateGroupCaches(); }
@Override protected void doValidate(final Configuration configuration) throws Exception { facet(ConfigurationFacet.class).validateSection(configuration, STORAGE, Config.class, Default.class, getRepository().getType().getValidationGroup() ); StorageFacetImpl.Config configToValidate = facet(ConfigurationFacet.class) .readSection(configuration, STORAGE, StorageFacetImpl.Config.class); Set<ConstraintViolation<?>> violations = new HashSet<>(); maybeAdd(violations, validateBlobStoreNotInGroup(configToValidate.blobStoreName)); maybePropagate(violations, log); }
/** * Invalidates the proxy and negative caches for given repository. */ public static void invalidateProxyAndNegativeCaches(final Repository repository) { checkNotNull(repository); checkArgument(ProxyType.NAME.equals(repository.getType().getValue())); ProxyFacet proxyFacet = repository.facet(ProxyFacet.class); proxyFacet.invalidateProxyCaches(); NegativeCacheFacet negativeCacheFacet = repository.facet(NegativeCacheFacet.class); negativeCacheFacet.invalidate(); } }
private List<Repository> getRepositories(final Repository repository) { checkNotNull(repository); if (groupType.equals(repository.getType())) { return repository.facet(GroupFacet.class).leafMembers(); } return ImmutableList.of(repository); }
private UploadHandler getUploadHandler(final Repository repository) { if (!(repository.getType() instanceof HostedType)) { throw new ValidationErrorsException( format("Uploading components to a '%s' type repository is unsupported, must be '%s'", repository.getType().getValue(), HostedType.NAME)); } String repositoryFormat = repository.getFormat().toString(); UploadHandler uploadHandler = uploadHandlers.get(repositoryFormat); if (uploadHandler == null) { throw new ValidationErrorsException( format("Uploading components to '%s' repositories is unsupported", repositoryFormat)); } return uploadHandler; }
@Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryEvent event) { if (isRecording()) { Repository repository = event.getRepository(); AuditData data = new AuditData(); data.setDomain(DOMAIN); data.setType(type(event.getClass())); data.setContext(repository.getName()); Map<String, String> attributes = data.getAttributes(); attributes.put("name", repository.getName()); attributes.put("type", repository.getType().getValue()); attributes.put("format", repository.getFormat().getValue()); record(data); } } }
private boolean containsGroup(Repository root, String repositoryName, Set<Repository> checkedGroups) { return root.facet(GroupFacet.class).members().stream().anyMatch((repository) -> { return checkedGroups.add(repository) && (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))); }); }
private List<Repository> allMembers(final Repository repository) { if (groupType.equals(repository.getType())) { return repository.facet(GroupFacet.class).allMembers(); } else { return Collections.singletonList(repository); } }
/** * Iterate over group members which may contain snapshots and recursively apply the snapshot removal. */ private void processGroup(final MavenGroupFacet groupFacet, final RemoveSnapshotsConfig config) { groupFacet.members().stream() .filter(member -> isSnapshotRepo(member) || groupType.equals(member.getType())) .forEach(member -> member.facet(RemoveSnapshotsFacet.class).removeSnapshots(config)); }