@Override protected boolean appliesTo(final Repository repository) { return repository.getFormat().getValue().equals(Maven2Format.NAME); }
@Override protected boolean appliesTo(final Repository repository) { return repository.getFormat().getValue().equals(Maven2Format.NAME); }
@Override @Nullable public URL getIndexSettings(final Repository repository) { checkNotNull(repository); if (format.equals(repository.getFormat())) { return Resources.getResource(getClass(), MAPPING_JSON); } return null; } }
private AutoBlockConfiguration getAutoBlockConfiguration() { AutoBlockConfiguration config = this.autoBlockConfiguration.get(getRepository().getFormat().getValue()); if (config == null) { config = autoBlockConfiguration.get(DEFAULT); } return config; }
/** * Returns the repository if it have format of {@link NpmFormat} only, {@code null} otherwise. */ @Nullable private Repository findNpmRepository(final String repositoryName) { final Repository repository = repositoryManager.get(repositoryName); if (repository != null && NpmFormat.NAME.equals(repository.getFormat().getValue())) { return repository; } return null; }
public void repairRepository(final Repository repository) { if (shouldRepairRepository(repository)) { doRepairRepository(repository); } else { log.info("Not running post processing after repairing {} repository {}", repository.getFormat(), repository.getName()); } }
private ComponentMaintenance getComponentMaintenanceFacet(final Repository repository) { try { return repository.facet(ComponentMaintenance.class); } catch (MissingFacetException e) { throw new IllegalOperationException( format("Deleting from repository %s of type %s is not supported", repository.getName(), repository.getFormat()), e); } } }
@Override protected boolean appliesTo(final Repository repository) { return maven2Format.equals(repository.getFormat()) && repository.optionalFacet(RemoveSnapshotsFacet.class).isPresent() && repository.facet(MavenFacet.class).getVersionPolicy() != VersionPolicy.RELEASE; }
private Optional<Context> buildContext(final String blobStoreName, final BlobStore blobStore, final BlobId blobId) { return Optional.of(new Context(blobStoreName, blobStore, blobId)) .map(c -> c.blob(c.blobStore.get(c.blobId, true))) .map(c -> c.blobAttributes(c.blobStore.getBlobAttributes(c.blobId))) .map(c -> c.properties(c.blobAttributes.getProperties())) .map(c -> c.repositoryName(c.properties.getProperty(HEADER_PREFIX + REPO_NAME_HEADER))) .map(c -> c.repository(repositoryManager.get(c.repositoryName))) .map(c -> c.restoreBlobStrategy(restoreBlobStrategies.get(c.repository.getFormat().getValue()))); }
public RepositoryContentSelectorPermission(final SelectorConfiguration selector, final Repository repository, final List<String> actions) { this(selector.getName(), repository.getFormat().getValue(), repository.getName(), actions); }
protected boolean shouldRepairRepository(final Repository repository) { return repository.getFormat().equals(format) && repository.getType().equals(type); }
@Override public boolean canDeleteAsset(final Repository repository, final Asset asset) { String repositoryFormat = repository.getFormat().toString(); return canDeleteAssetInRepository(repository, repositoryFormat, variableResolverAdapterManager.get(repositoryFormat), asset); }
@Nullable protected String processBatch(final Repository repository, final String lastId) throws Exception { log.info("Processing next batch of {} packages for repair. Starting at id = {} with max batch size = {}", repository.getFormat(), lastId, BATCH_SIZE); return TransactionalStoreMetadata.operation .withDb(repository.facet(StorageFacet.class).txSupplier()) .throwing(Exception.class) .call(() -> { Iterable<Asset> assets = readAssets(repository, lastId); return updateAssets(repository, assets); }); }
@Override protected void doInit(final Configuration configuration) throws Exception { super.doInit(configuration); mavenPathParser = checkNotNull(mavenPathParsers.get(getRepository().getFormat().getValue())); storageFacet = getRepository().facet(StorageFacet.class); storageFacet.registerWritePolicySelector(new MavenWritePolicySelector()); }
@Override protected boolean appliesTo(final Repository repository) { return maven2Format.equals(repository.getFormat()) && (hostedType.equals(repository.getType()) || groupType.equals(repository.getType())); }
private Asset getAsset(final StorageTx tx, final NpmPackageId packageId) { Bucket bucket = tx.findBucket(getRepository()); Asset asset = findPackageRootAsset(tx, bucket, packageId); if (isNull(asset)) { asset = tx.createAsset(bucket, getRepository().getFormat()).name(packageId.id()); } return asset; }
@Override public void ensurePermitted(final Request request) { checkNotNull(request); // determine permission action from request String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } }
@Override public VariableSource fromRequest(final Request request, final Repository repository) { VariableSourceBuilder builder = new VariableSourceBuilder(); builder.addResolver(new ConstantVariableResolver(request.getPath(), PATH)); builder.addResolver(new ConstantVariableResolver(repository.getFormat().getValue(), FORMAT)); addFromRequest(builder, request); return builder.build(); }
@TransactionalStoreBlob protected Content doPutRepositoryRoot(final TempBlob tempBlob, final Content content) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = findRepositoryRootAsset(tx, bucket); if (asset == null) { asset = tx.createAsset(bucket, getRepository().getFormat()).name(NpmFacetUtils.REPOSITORY_ROOT_ASSET); } return saveRepositoryRoot(tx, asset, tempBlob, content); }