Commit 9d55bc5a authored by Roberto Loayza's avatar Roberto Loayza

Update File Deployment

parent dc869573
......@@ -11,6 +11,8 @@ import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiParam;
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import lombok.extern.log4j.Log4j2;
......@@ -195,13 +197,14 @@ public class AgentController {
@DeleteMapping("/file-upload/{uuid}")
public ResponseEntity<String> deleteBdc(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
Gson gson = gsonBuilder.create();
Map<String, String> resp = new HashMap<>();
try {
orquestadorService.deleteBcd(uuid);
String response = "Todo Ok";
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
resp.put("message", "OK");
return new ResponseEntity<>(gson.toJson(resp), HttpStatus.OK);
} catch (Exception e) {
log.error("Error detectado: ", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
resp.put("message", "ERROR");
return new ResponseEntity<>(gson.toJson(resp), HttpStatus.OK);
}
}
......
......@@ -94,14 +94,14 @@ public class BucketService {
public void delete(String uuid) {
Optional<BusinessParameter> businessParameter = businessParameterRepository.findByKey("Bucket");
if (!businessParameter.isPresent()) {
throw new NotFoundException("No existe el parametro de negocio del bucket.");
throw new NotFoundException();
}
String bucketName = businessParameter.get().getDefaultValue();
try {
AmazonS3 s3Client = getS3Client();
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
if (!questionFile.isPresent()) {
throw new NotFoundException("El uuid no se encuentra enlazado con un file");
throw new NotFoundException();
}
String keyName = String.format("%s/%s/%s/%s/%s",tenant, uuid, version, fileDir, questionFile.get().getName());
s3Client.deleteObject(new DeleteObjectRequest(bucketName, keyName));
......
......@@ -150,13 +150,15 @@ public class OrquestadorService {
public void deleteBcd(String uuid) {
Optional<BdcControl> bdcControl = bdcControlRepository.findByUuid(uuid);
if (!bdcControl.isPresent()) {
throw new NotFoundException("Control no encontrado.");
//throw new NotFoundException("Control no encontrado.");
throw new NotFoundException();
}
BdcControl model = bdcControl.get();
if (model.getStatus().equals(StatusBcdEnum.INDEXADO.getName())) {
boolean step = knowledgeService.delete(uuid);
if (!step) {
throw new NotFoundException("Error a eliminar modelo del bucket");
//throw new NotFoundException("Error a eliminar modelo del bucket");
throw new NotFoundException();
}
model.setStatus(StatusBcdEnum.INDEXANDO.getName());
model = bdcControlRepository.save(model);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment