shp 파일 geosjon 등록추가, 파일다운로드 파일명 오류 수정
This commit is contained in:
@@ -6,17 +6,50 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ExternalJarRunner {
|
||||
|
||||
public void run(String jarPath, String batchIds, String inferenceId, String mapIds) {
|
||||
private static final long TIMEOUT_MINUTES = 30;
|
||||
|
||||
/**
|
||||
* shp 파일 생성
|
||||
*
|
||||
* @param jarPath jar 경로
|
||||
* @param batchIds 배치 아이디
|
||||
* @param inferenceId uid
|
||||
* @param mapIds 도엽 Id
|
||||
*/
|
||||
public void run(String jarPath, String batchIds, String inferenceId, String mapIds) {
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
addArg(args, "converter.inference-id", inferenceId);
|
||||
addArg(args, "converter.map-ids", mapIds);
|
||||
addArg(args, "converter.batch-ids", batchIds);
|
||||
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* geoserver 등록
|
||||
*
|
||||
* @param jarPath jar 파일경로
|
||||
* @param register shp 경로
|
||||
* @param layer geoserver에 등록될 레이어 이름
|
||||
*/
|
||||
public void run(String jarPath, String register, String layer) {
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
addArg(args, "register", register);
|
||||
addArg(args, "layer", layer);
|
||||
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
private void execJar(String jarPath, List<String> args) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
try {
|
||||
@@ -24,16 +57,7 @@ public class ExternalJarRunner {
|
||||
cmd.add("java");
|
||||
cmd.add("-jar");
|
||||
cmd.add(jarPath);
|
||||
|
||||
if (inferenceId != null && !inferenceId.isBlank()) {
|
||||
cmd.add("--converter.inference-id=" + inferenceId);
|
||||
}
|
||||
if (mapIds != null && !mapIds.isBlank()) {
|
||||
cmd.add("--converter.map-ids=" + mapIds);
|
||||
}
|
||||
if (batchIds != null && !batchIds.isBlank()) {
|
||||
cmd.add("--converter.batch-ids=" + batchIds);
|
||||
}
|
||||
cmd.addAll(args);
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
pb.redirectErrorStream(true);
|
||||
@@ -49,7 +73,7 @@ public class ExternalJarRunner {
|
||||
}
|
||||
}
|
||||
|
||||
boolean finished = p.waitFor(30, TimeUnit.MINUTES);
|
||||
boolean finished = p.waitFor(TIMEOUT_MINUTES, TimeUnit.MINUTES);
|
||||
if (!finished) {
|
||||
p.destroyForcibly();
|
||||
throw new RuntimeException("jar timeout\n" + out);
|
||||
@@ -66,4 +90,10 @@ public class ExternalJarRunner {
|
||||
log.error("jar execution error. output=\n{}", out, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addArg(List<String> args, String key, String value) {
|
||||
if (value != null && !value.isBlank()) {
|
||||
args.add("--" + key + "=" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user