diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java index 2e26151..b61194e 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java @@ -212,8 +212,7 @@ public class DefaultAttachmentClient implements AttachmentClient { public Optional upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) { removeDuplicateObject(businessId, filename); - String res = documentCenterService.upload("ebtp-mall-cloud", businessId, - fileConvertor.toMultipartFile(filename, array)); + String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(filename, array)); log.info("document center upload result: {}", res); @@ -255,7 +254,7 @@ public class DefaultAttachmentClient implements AttachmentClient { * @param filename */ private void removeDuplicateObject(String businessId, String filename) { - log.info("remove duplicate name files {} in business: {}", filename, businessId); + log.info("remove files {} in business: {} if exists", filename, businessId); Optional op = findByBusinessId(Arrays.asList(businessId)); op.ifPresent(detail -> { diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java index fb08ed4..4852a04 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java @@ -45,12 +45,14 @@ public class ModelConvertor { AttachmentEntity entity = null; try { - SysStorageVO vo = tpDownPO(content); - log.debug("convert to model: {}", vo); + Optional op = tpDownPO(content); - entity = new AttachmentEntity(); - entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId()) - .setKey(vo.getFileName()); + if (op.isPresent()) { + SysStorageVO vo = op.get(); + entity = new AttachmentEntity(); + entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId()) + .setKey(vo.getFileName()); + } } catch (JsonProcessingException e) { log.error(json); log.error(e.getMessage()); @@ -82,7 +84,11 @@ public class ModelConvertor { public Optional toByteArray(String json) { return Optional.ofNullable(json).map(content -> { try { - return tpDownPO(content).getFileStream(); + Optional op = tpDownPO(content); + + if (op.isPresent()) { + return op.get().getFileStream(); + } } catch (JsonProcessingException e) { log.error(json); log.error(e.getMessage()); @@ -99,18 +105,20 @@ public class ModelConvertor { return Optional.ofNullable(json).map(content -> { DownloadEntity entity = null; try { - SysStorageVO vo = tpDownPO(content); + Optional op = tpDownPO(content); - entity = new DownloadEntity(); - entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8"))) - .setStream(vo.getFileStream()); + if (op.isPresent()) { + SysStorageVO vo = op.get(); + entity = new DownloadEntity(); + entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8"))) + .setStream(vo.getFileStream()); + } } catch (JsonProcessingException e) { log.error(json); log.error(e.getMessage()); } return entity; }); - } /** @@ -138,10 +146,10 @@ public class ModelConvertor { * @throws JsonMappingException * @throws JsonProcessingException */ - private SysStorageVO tpDownPO(String json) throws JsonMappingException, JsonProcessingException { + private Optional tpDownPO(String json) throws JsonMappingException, JsonProcessingException { log.debug("current convertor json is: {}", json); return Optional.ofNullable(objectMapper.readValue(json, DownStream.class)).map(ds -> ds.getData()) - .map(data -> data.getSysStorageVO()).orElseGet(SysStorageVO::new); + .map(data -> data.getSysStorageVO()); } /** diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties b/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties index 89e51e3..e62f226 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties +++ b/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties @@ -1,5 +1,6 @@ -ribbon.ReadTimeout=1800000 -ribbon.SocketTimeout=1800000 +feign.hystrix.enabled=true +feign.client.config.default.retryer=feign.Retryer.Default +hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=600000 # document center id document.center.service.id=core-service-document-center