shp파일등록방법변경

This commit is contained in:
2026-03-11 20:17:17 +09:00
parent 7347f2a8b1
commit 81312c7d1c
2 changed files with 9 additions and 24 deletions

View File

@@ -17,8 +17,7 @@ import org.springframework.stereotype.Component;
*
* <p>기존 GeoServerRegistrationService를 재사용하여 shapefile을 GeoServer에 등록
*
* <p>자동 선택 로직: - 파일 크기 < 100MB: REST API 업로드 (uploadShapefileZip) - 파일 크기 >= 100MB: 파일 경로 참조
* (registerShapefileByPath)
* <p>등록 방식: external.shp 엔드포인트를 사용한 file:// 경로 참조 (모든 파일 크기)
*
* <p>Conditional execution: geoserver.enabled=false 이면 skip
*/
@@ -28,8 +27,6 @@ public class GeoServerRegistrationTasklet implements Tasklet {
private static final Logger log = LoggerFactory.getLogger(GeoServerRegistrationTasklet.class);
private static final long FILE_SIZE_THRESHOLD = 100 * 1024 * 1024; // 100MB
private final GeoServerRegistrationService geoServerService;
@Value("#{jobParameters['geoserver.enabled'] ?: false}")
@@ -68,28 +65,15 @@ public class GeoServerRegistrationTasklet implements Tasklet {
throw new IllegalStateException("ZIP file path not available for GeoServer registration");
}
// Check file size to determine registration method
// Log file size for monitoring
File zipFile = new File(zipPath);
long fileSize = zipFile.length();
long fileSizeMB = fileSize / 1024 / 1024;
log.info("ZIP file size: {} bytes ({} MB)", fileSize, fileSizeMB);
//
// if (fileSize < FILE_SIZE_THRESHOLD) {
// // Small file: Use REST API upload
// log.info("Using REST API upload method (file size < 100MB)");
// geoServerService.uploadShapefileZip(zipPath, layerName);
// } else {
// // Large file: Use file path reference
// log.info(
// "Using file path reference method (file size >= 100MB, {} MB recommended for large"
// + " files)",
// fileSizeMB);
// log.info(
// "GeoServer will read the file from: {} (ensure GeoServer has file system access)",
// zipPath);
// geoServerService.registerShapefileByPath(zipPath, layerName);
// }
// Register using file:// path reference (external.shp endpoint) for all file sizes
log.info("Using file path reference method (external.shp endpoint)");
log.info("Note: GeoServer must have read access to the file path: {}", zipPath);
geoServerService.registerShapefileByPath(zipPath, layerName);
log.info("GeoServer registration completed successfully for layer: {}", layerName);

View File

@@ -225,10 +225,11 @@ public class GeoServerRegistrationService {
String fileUrl = "file://" + shpFilePath;
log.info("Using file URL: {}", fileUrl);
// GeoServer REST API endpoint
// GeoServer REST API endpoint for external file reference
// Use external.shp (not file.shp) for file:// URLs
String url =
String.format(
"%s/rest/workspaces/%s/datastores/%s/file.shp?configure=all",
"%s/rest/workspaces/%s/datastores/%s/external.shp?configure=all",
properties.getBaseUrl(), properties.getWorkspace(), layerName);
HttpHeaders headers = createHeaders();