|
@@ -2,6 +2,7 @@ package cn.reghao.oss.mgr.service;
|
|
|
|
|
|
|
|
import cn.reghao.jutil.jdk.media.model.*;
|
|
import cn.reghao.jutil.jdk.media.model.*;
|
|
|
import cn.reghao.jutil.jdk.web.result.Result;
|
|
import cn.reghao.jutil.jdk.web.result.Result;
|
|
|
|
|
+import cn.reghao.oss.api.constant.IdType;
|
|
|
import cn.reghao.oss.api.constant.ObjectAction;
|
|
import cn.reghao.oss.api.constant.ObjectAction;
|
|
|
import cn.reghao.oss.api.constant.ObjectScope;
|
|
import cn.reghao.oss.api.constant.ObjectScope;
|
|
|
import cn.reghao.oss.api.dto.ObjectChannel;
|
|
import cn.reghao.oss.api.dto.ObjectChannel;
|
|
@@ -17,6 +18,7 @@ import cn.reghao.oss.mgr.db.mapper.DataBlockMapper;
|
|
|
import cn.reghao.oss.mgr.db.mapper.FileMetaMapper;
|
|
import cn.reghao.oss.mgr.db.mapper.FileMetaMapper;
|
|
|
import cn.reghao.oss.mgr.db.mapper.UploadTaskMapper;
|
|
import cn.reghao.oss.mgr.db.mapper.UploadTaskMapper;
|
|
|
import cn.reghao.oss.mgr.db.repository.ObjectRepository;
|
|
import cn.reghao.oss.mgr.db.repository.ObjectRepository;
|
|
|
|
|
+import cn.reghao.oss.mgr.model.dto.DeleteObjectDto;
|
|
|
import cn.reghao.oss.mgr.model.po.*;
|
|
import cn.reghao.oss.mgr.model.po.*;
|
|
|
import cn.reghao.oss.mgr.rpc.RpcService;
|
|
import cn.reghao.oss.mgr.rpc.RpcService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -153,8 +155,6 @@ public class OssClientService {
|
|
|
return Result.success(signedUrl);
|
|
return Result.success(signedUrl);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
private UploadChannel getUploadChannel(long loginUser, String objectName) {
|
|
private UploadChannel getUploadChannel(long loginUser, String objectName) {
|
|
|
List<UploadChannel> uploadChannelList = uploadChannelService.getUploadChannelsByCreateBy(loginUser);
|
|
List<UploadChannel> uploadChannelList = uploadChannelService.getUploadChannelsByCreateBy(loginUser);
|
|
|
Collections.reverse(uploadChannelList);
|
|
Collections.reverse(uploadChannelList);
|
|
@@ -219,13 +219,29 @@ public class OssClientService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void deleteObject(String objectId) {
|
|
|
|
|
- DataBlock dataBlock = dataBlockMapper.findByObjectId(objectId);
|
|
|
|
|
- String hostPort = dataBlock.getHostPort();
|
|
|
|
|
- StoreService storeService = rpcService.getStoreService(hostPort);
|
|
|
|
|
|
|
+ public void deleteObject(DeleteObjectDto deleteObjectDto) {
|
|
|
|
|
+ String idType = deleteObjectDto.getIdType();
|
|
|
|
|
+ String id = deleteObjectDto.getId();
|
|
|
|
|
+ String objectId = null;
|
|
|
|
|
+ if (IdType.ObjectId.name().equals(idType)) {
|
|
|
|
|
+ objectId = id;
|
|
|
|
|
+ } else if (IdType.ObjectName.name().equals(idType)) {
|
|
|
|
|
+ FileMeta fileMeta = objectRepository.getFileMetaByName(id);
|
|
|
|
|
+ if (fileMeta != null) {
|
|
|
|
|
+ objectId = fileMeta.getObjectId();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (objectId == null) {
|
|
|
|
|
+ log.error("{} with {} not exist", idType, id);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- storeService.deleteFile(dataBlock.getAbsolutePath());
|
|
|
|
|
objectRepository.deleteObject(objectId);
|
|
objectRepository.deleteObject(objectId);
|
|
|
|
|
+ /*DataBlock dataBlock = dataBlockMapper.findByObjectId(objectId);
|
|
|
|
|
+ String hostPort = dataBlock.getHostPort();
|
|
|
|
|
+ StoreService storeService = rpcService.getStoreService(hostPort);
|
|
|
|
|
+ storeService.deleteFile(dataBlock.getAbsolutePath());*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void checkAndSetScope(String objectId, int scope) {
|
|
public void checkAndSetScope(String objectId, int scope) {
|
|
@@ -263,6 +279,10 @@ public class OssClientService {
|
|
|
httpPort = uploadTask.getHttpPort();
|
|
httpPort = uploadTask.getHttpPort();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (host == null) {
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!host.isEmpty() && httpPort != 0) {
|
|
if (!host.isEmpty() && httpPort != 0) {
|
|
|
String objectName = fileMeta.getObjectName();
|
|
String objectName = fileMeta.getObjectName();
|
|
|
StoreNode storeNode = storeNodeService.getStoreNode(host, httpPort);
|
|
StoreNode storeNode = storeNodeService.getStoreNode(host, httpPort);
|