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

Update File Deployment

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