1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.transport.minio.internal;
20
21 import javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import java.util.Map;
25
26 import io.minio.MinioClient;
27 import org.eclipse.aether.RepositorySystemSession;
28 import org.eclipse.aether.repository.RemoteRepository;
29 import org.eclipse.aether.transport.minio.MinioTransporterConfigurationKeys;
30 import org.eclipse.aether.transport.minio.ObjectName;
31 import org.eclipse.aether.transport.minio.ObjectNameMapper;
32 import org.eclipse.aether.transport.minio.ObjectNameMapperFactory;
33 import org.eclipse.aether.util.ConfigUtils;
34
35
36
37
38
39 @Singleton
40 @Named(FixedBucketObjectNameMapperFactory.NAME)
41 public class FixedBucketObjectNameMapperFactory implements ObjectNameMapperFactory {
42 public static final String NAME = "fixedBucket";
43
44 @Override
45 public ObjectNameMapper create(
46 RepositorySystemSession session,
47 RemoteRepository repository,
48 MinioClient unused,
49 Map<String, String> headers) {
50 String bucket = ConfigUtils.getString(
51 session,
52 MinioTransporterConfigurationKeys.CONFIG_PROP_FIXED_BUCKET_NAME,
53 MinioTransporterConfigurationKeys.CONFIG_PROP_FIXED_BUCKET_NAME + "." + repository.getId(),
54 MinioTransporterConfigurationKeys.DEFAULT_FIXED_BUCKET_NAME);
55 return path -> new ObjectName(bucket, repository.getId() + "/" + ObjectName.normalize(path));
56 }
57 }