отделили реализацию minio в отлдельный модуль
This commit is contained in:
@@ -4,14 +4,15 @@ import io.minio.MinioClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.di9.mirror.core.service.MinioService;
|
||||
import ru.di9.mirror.core.repository.FileStorageRepository;
|
||||
import ru.di9.mirror.minio.service.MinioRepository;
|
||||
|
||||
@Configuration
|
||||
public class MinioConfig {
|
||||
|
||||
@Bean
|
||||
public MinioService minioService(MinioClient minioClient, @Value("${minio.bucket}") String bucket) {
|
||||
return new MinioService(minioClient, bucket);
|
||||
public FileStorageRepository fileStorageRepository(MinioClient minioClient, @Value("${minio.bucket}") String bucket) {
|
||||
return new MinioRepository(minioClient, bucket);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -9,7 +9,7 @@ import ru.di9.mirror.core.handler.IndexOfHandler;
|
||||
import ru.di9.mirror.core.handler.MavenHandler;
|
||||
import ru.di9.mirror.core.repository.ArtifactRepository;
|
||||
import ru.di9.mirror.core.service.ExternalMavenService;
|
||||
import ru.di9.mirror.core.service.MinioService;
|
||||
import ru.di9.mirror.core.repository.FileStorageRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,15 +17,15 @@ import java.util.List;
|
||||
public class WebConfig {
|
||||
|
||||
@Bean
|
||||
public MavenHandler mavenHandler(MinioService minioService,
|
||||
public MavenHandler mavenHandler(FileStorageRepository fileStorageRepository,
|
||||
List<ExternalMavenService> externalMavenServices,
|
||||
ArtifactRepository artifactRepository) {
|
||||
return new MavenHandler(minioService, externalMavenServices, artifactRepository);
|
||||
return new MavenHandler(fileStorageRepository, externalMavenServices, artifactRepository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IndexOfHandler indexOfHandler(MinioService minioService) {
|
||||
return new IndexOfHandler(minioService);
|
||||
public IndexOfHandler indexOfHandler(FileStorageRepository fileStorageRepository) {
|
||||
return new IndexOfHandler(fileStorageRepository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import ru.di9.mirror.core.Utils;
|
||||
import ru.di9.mirror.core.domain.ItemRecord;
|
||||
import ru.di9.mirror.core.domain.FileItem;
|
||||
import ru.di9.mirror.core.handler.IndexOfHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,7 +28,7 @@ public class IndexOfMavenController {
|
||||
@ModelAttribute("model") ModelMap model) {
|
||||
String path = correctingHttpPath(httpPath);
|
||||
|
||||
List<ItemRecord> walker = indexOfHandler.walker(path);
|
||||
List<FileItem> walker = indexOfHandler.walker(path);
|
||||
List<ModelLink> links = new ArrayList<>();
|
||||
|
||||
StringBuilder sb = new StringBuilder("/maven");
|
||||
@@ -46,13 +46,13 @@ public class IndexOfMavenController {
|
||||
sb.setLength(resetLength);
|
||||
sb.append("/");
|
||||
resetLength = sb.length();
|
||||
for (ItemRecord itemRecord : walker) {
|
||||
for (FileItem fileItem : walker) {
|
||||
if (Utils.isNotEmptyString(path)) {
|
||||
sb.append(path).append("/");
|
||||
}
|
||||
sb.append(itemRecord.name());
|
||||
sb.append(fileItem.name());
|
||||
|
||||
links.add(new ModelLink(itemRecord.name() + (itemRecord.isDir() ? "/" : ""), sb.toString()));
|
||||
links.add(new ModelLink(fileItem.name() + (fileItem.isDir() ? "/" : ""), sb.toString()));
|
||||
sb.setLength(resetLength);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user