|  |  |  | 
|---|
|  |  |  | @Async | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void parseStorageMinioEvent(String message) { | 
|---|
|  |  |  | JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class); | 
|---|
|  |  |  | if (jsonsRootBean != null) { | 
|---|
|  |  |  | Records records = jsonsRootBean.getRecords().get(0); | 
|---|
|  |  |  | StorageMinioEvent storageMinioEvent = new StorageMinioEvent(); | 
|---|
|  |  |  | storageMinioEvent.setEventTime(records.getEventTime()); | 
|---|
|  |  |  | storageMinioEvent.setEventType(records.getEventName()); | 
|---|
|  |  |  | storageMinioEvent.setBucketName(records.getS3().getBucket().getName()); | 
|---|
|  |  |  | String encode = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8"); | 
|---|
|  |  |  | } catch (UnsupportedEncodingException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | storageMinioEvent.setObjectName(encode); | 
|---|
|  |  |  | storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize()); | 
|---|
|  |  |  | storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType()); | 
|---|
|  |  |  | storageMinioEvent.setHost(records.getSource().getHost()); | 
|---|
|  |  |  | storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint()); | 
|---|
|  |  |  | storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class); | 
|---|
|  |  |  | if (jsonsRootBean != null) { | 
|---|
|  |  |  | Records records = jsonsRootBean.getRecords().get(0); | 
|---|
|  |  |  | StorageMinioEvent storageMinioEvent = new StorageMinioEvent(); | 
|---|
|  |  |  | storageMinioEvent.setEventTime(records.getEventTime()); | 
|---|
|  |  |  | String eventType = records.getEventName().substring(0, records.getEventName().indexOf(":", records.getEventName().indexOf(":") + 1));//不包含本身位置 | 
|---|
|  |  |  | storageMinioEvent.setEventType(eventType); | 
|---|
|  |  |  | storageMinioEvent.setBucketName(records.getS3().getBucket().getName()); | 
|---|
|  |  |  | String encode = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8"); | 
|---|
|  |  |  | } catch (UnsupportedEncodingException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | storageMinioEvent.setObjectName(encode); | 
|---|
|  |  |  | storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize()); | 
|---|
|  |  |  | storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType()); | 
|---|
|  |  |  | storageMinioEvent.setHost(records.getSource().getHost()); | 
|---|
|  |  |  | storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint()); | 
|---|
|  |  |  | storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int i = insertStorageMinioEvent(storageMinioEvent); | 
|---|
|  |  |  | if(i>0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | log.debug("minio操作日志入库成功!【"+storageMinioEvent.getEventType()+"】"); | 
|---|
|  |  |  | int i = insertStorageMinioEvent(storageMinioEvent); | 
|---|
|  |  |  | if (i > 0) { | 
|---|
|  |  |  | log.debug("minio操作日志入库成功!【" + storageMinioEvent.getEventType() + "】"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | log.error("minio事件格式化异常:"+ex.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|