[Developer] #424 stop guessing protected object ORDS paths
This commit is contained in:
@@ -13,8 +13,4 @@ public record DatabaseObjectOption(
|
||||
public String label() {
|
||||
return owner + "." + objectName + " (" + objectType + ")";
|
||||
}
|
||||
|
||||
public String defaultOrdsPath() {
|
||||
return owner.toLowerCase() + "/" + objectName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,7 @@ public interface ProtectedObjectMapper {
|
||||
@Param("columnName") String columnName,
|
||||
@Param("sensitiveYn") String sensitiveYn);
|
||||
|
||||
int updateOrdsPath(@Param("objectId") long objectId, @Param("ordsPath") String ordsPath);
|
||||
|
||||
int disableObject(@Param("objectId") long objectId);
|
||||
}
|
||||
|
||||
@@ -68,29 +68,8 @@ public class ProtectedObjectService {
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
List<String> columns = mapper.findDatabaseColumns(owner, objectName);
|
||||
if (columns.isEmpty()) {
|
||||
throw new AppException("DB 객체 컬럼을 찾을 수 없습니다: " + owner + "." + objectName);
|
||||
}
|
||||
long objectId = mapper.nextObjectId();
|
||||
mapper.insertObject(objectId, new ProtectedObjectCreateCommand(
|
||||
owner,
|
||||
objectName,
|
||||
defaultOrdsPath(owner, objectName),
|
||||
String.join(",", columns),
|
||||
""
|
||||
));
|
||||
for (String column : columns) {
|
||||
mapper.insertColumn(mapper.nextColumnId(), objectId, column, "N");
|
||||
}
|
||||
auditService.record(new AuditEvent("PROTECTED_OBJECT_CREATED", null, objectId, "SUCCESS", null, null,
|
||||
owner + "." + objectName));
|
||||
return mapper.findById(objectId);
|
||||
}
|
||||
|
||||
private String defaultOrdsPath(String owner, String objectName) {
|
||||
String schemaPath = owner.equalsIgnoreCase("CB_ORDS") ? "cb-ords" : owner.toLowerCase(Locale.ROOT);
|
||||
return schemaPath + "/" + objectName.toLowerCase(Locale.ROOT);
|
||||
throw new AppException("테이블/뷰 관리에서 실제 ORDS Path를 먼저 등록하세요: "
|
||||
+ owner.toUpperCase(Locale.ROOT) + "." + objectName.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
private ProtectedObjectCreateCommand normalizeCreateCommand(ProtectedObjectCreateCommand command) {
|
||||
@@ -98,7 +77,7 @@ public class ProtectedObjectService {
|
||||
String objectName = command.objectName().trim().toUpperCase(Locale.ROOT);
|
||||
String ordsPath = command.ordsPath();
|
||||
if (ordsPath == null || ordsPath.isBlank()) {
|
||||
ordsPath = defaultOrdsPath(owner, objectName);
|
||||
throw new AppException("ORDS Path는 실제 ORDS module/template 경로를 입력해야 합니다.");
|
||||
}
|
||||
String columns = command.columns();
|
||||
if (columns == null || columns.isBlank()) {
|
||||
@@ -107,6 +86,19 @@ public class ProtectedObjectService {
|
||||
return new ProtectedObjectCreateCommand(owner, objectName, ordsPath.trim(), columns, command.sensitiveColumns());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateOrdsPath(long objectId, String ordsPath) {
|
||||
if (ordsPath == null || ordsPath.isBlank()) {
|
||||
throw new AppException("ORDS Path는 필수입니다.");
|
||||
}
|
||||
int updated = mapper.updateOrdsPath(objectId, ordsPath.trim());
|
||||
if (updated == 0) {
|
||||
throw new AppException("보호 객체를 찾을 수 없습니다.");
|
||||
}
|
||||
auditService.record(new AuditEvent("PROTECTED_OBJECT_ORDS_PATH_UPDATED", null, objectId, "SUCCESS", null, null,
|
||||
ordsPath.trim()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void disableObject(long objectId) {
|
||||
int updated = mapper.disableObject(objectId);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cloudhandson.vpdbackoffice.web;
|
||||
|
||||
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedObjectCreateCommand;
|
||||
import com.cloudhandson.vpdbackoffice.service.AppException;
|
||||
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -34,9 +35,28 @@ public class ProtectedObjectController {
|
||||
@RequestParam(required = false) String sensitiveColumns,
|
||||
RedirectAttributes redirectAttributes
|
||||
) {
|
||||
protectedObjectService.createObject(
|
||||
new ProtectedObjectCreateCommand(owner, objectName, ordsPath, columns, sensitiveColumns));
|
||||
redirectAttributes.addFlashAttribute("message", "보호 객체를 추가했습니다.");
|
||||
try {
|
||||
protectedObjectService.createObject(
|
||||
new ProtectedObjectCreateCommand(owner, objectName, ordsPath, columns, sensitiveColumns));
|
||||
redirectAttributes.addFlashAttribute("message", "보호 객체를 추가했습니다.");
|
||||
} catch (AppException exception) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", exception.getMessage());
|
||||
}
|
||||
return "redirect:/objects";
|
||||
}
|
||||
|
||||
@PostMapping("/objects/ords-path")
|
||||
public String updateOrdsPath(
|
||||
@RequestParam long objectId,
|
||||
@RequestParam String ordsPath,
|
||||
RedirectAttributes redirectAttributes
|
||||
) {
|
||||
try {
|
||||
protectedObjectService.updateOrdsPath(objectId, ordsPath);
|
||||
redirectAttributes.addFlashAttribute("message", "ORDS Path를 수정했습니다.");
|
||||
} catch (AppException exception) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", exception.getMessage());
|
||||
}
|
||||
return "redirect:/objects";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user