/** * 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); } }
/** * 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); }
/** * 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(); }
/** * 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 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; }
@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); } } }