shp파일등록방법변경
This commit is contained in:
@@ -17,8 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*
|
*
|
||||||
* <p>기존 GeoServerRegistrationService를 재사용하여 shapefile을 GeoServer에 등록
|
* <p>기존 GeoServerRegistrationService를 재사용하여 shapefile을 GeoServer에 등록
|
||||||
*
|
*
|
||||||
* <p>자동 선택 로직: - 파일 크기 < 100MB: REST API 업로드 (uploadShapefileZip) - 파일 크기 >= 100MB: 파일 경로 참조
|
* <p>등록 방식: external.shp 엔드포인트를 사용한 file:// 경로 참조 (모든 파일 크기)
|
||||||
* (registerShapefileByPath)
|
|
||||||
*
|
*
|
||||||
* <p>Conditional execution: geoserver.enabled=false 이면 skip
|
* <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 Logger log = LoggerFactory.getLogger(GeoServerRegistrationTasklet.class);
|
||||||
|
|
||||||
private static final long FILE_SIZE_THRESHOLD = 100 * 1024 * 1024; // 100MB
|
|
||||||
|
|
||||||
private final GeoServerRegistrationService geoServerService;
|
private final GeoServerRegistrationService geoServerService;
|
||||||
|
|
||||||
@Value("#{jobParameters['geoserver.enabled'] ?: false}")
|
@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");
|
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);
|
File zipFile = new File(zipPath);
|
||||||
long fileSize = zipFile.length();
|
long fileSize = zipFile.length();
|
||||||
long fileSizeMB = fileSize / 1024 / 1024;
|
long fileSizeMB = fileSize / 1024 / 1024;
|
||||||
|
|
||||||
log.info("ZIP file size: {} bytes ({} MB)", fileSize, fileSizeMB);
|
log.info("ZIP file size: {} bytes ({} MB)", fileSize, fileSizeMB);
|
||||||
//
|
|
||||||
// if (fileSize < FILE_SIZE_THRESHOLD) {
|
// Register using file:// path reference (external.shp endpoint) for all file sizes
|
||||||
// // Small file: Use REST API upload
|
log.info("Using file path reference method (external.shp endpoint)");
|
||||||
// log.info("Using REST API upload method (file size < 100MB)");
|
log.info("Note: GeoServer must have read access to the file path: {}", zipPath);
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
geoServerService.registerShapefileByPath(zipPath, layerName);
|
geoServerService.registerShapefileByPath(zipPath, layerName);
|
||||||
|
|
||||||
log.info("GeoServer registration completed successfully for layer: {}", layerName);
|
log.info("GeoServer registration completed successfully for layer: {}", layerName);
|
||||||
|
|||||||
@@ -225,10 +225,11 @@ public class GeoServerRegistrationService {
|
|||||||
String fileUrl = "file://" + shpFilePath;
|
String fileUrl = "file://" + shpFilePath;
|
||||||
log.info("Using file URL: {}", fileUrl);
|
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 url =
|
||||||
String.format(
|
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);
|
properties.getBaseUrl(), properties.getWorkspace(), layerName);
|
||||||
|
|
||||||
HttpHeaders headers = createHeaders();
|
HttpHeaders headers = createHeaders();
|
||||||
|
|||||||
Reference in New Issue
Block a user