Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
81f7697a
Unverified
Commit
81f7697a
authored
Jan 29, 2024
by
gaoyan
Committed by
GitHub
Jan 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added resource center synchronization of oss (#3075)
Co-authored-by:
gaoyan1998
<
gaoyan1998@users.noreply.github.com
>
parent
c3ea3843
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
234 additions
and
45 deletions
+234
-45
ResourceController.java
...rc/main/java/org/dinky/controller/ResourceController.java
+11
-0
Resources.java
...y-admin/src/main/java/org/dinky/data/model/Resources.java
+7
-1
BaseResourceManager.java
.../java/org/dinky/service/resource/BaseResourceManager.java
+13
-3
ResourcesService.java
...ain/java/org/dinky/service/resource/ResourcesService.java
+2
-0
HdfsResourceManager.java
.../org/dinky/service/resource/impl/HdfsResourceManager.java
+7
-0
LocalResourceManager.java
...org/dinky/service/resource/impl/LocalResourceManager.java
+42
-0
OssResourceManager.java
...a/org/dinky/service/resource/impl/OssResourceManager.java
+43
-0
ResourceServiceImpl.java
.../org/dinky/service/resource/impl/ResourceServiceImpl.java
+37
-10
OssTemplate.java
dinky-common/src/main/java/org/dinky/oss/OssTemplate.java
+43
-27
pages.ts
dinky-web/src/locales/en-US/pages.ts
+2
-0
pages.ts
dinky-web/src/locales/zh-CN/pages.ts
+3
-0
index.tsx
...rc/pages/RegCenter/Resource/components/FileTree/index.tsx
+10
-2
index.tsx
.../RegCenter/Resource/components/ResourceOverView/index.tsx
+12
-1
endpoints.tsx
dinky-web/src/services/endpoints.tsx
+1
-0
data.d.ts
dinky-web/src/types/Studio/data.d.ts
+1
-1
No files found.
dinky-admin/src/main/java/org/dinky/controller/ResourceController.java
View file @
81f7697a
...
@@ -56,6 +56,17 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -56,6 +56,17 @@ import lombok.extern.slf4j.Slf4j;
public
class
ResourceController
{
public
class
ResourceController
{
private
final
ResourcesService
resourcesService
;
private
final
ResourcesService
resourcesService
;
@GetMapping
(
"/syncRemoteDirectory"
)
@ApiOperation
(
"Sync Remote Directory Structure"
)
@Log
(
title
=
"Sync Remote Directory Structure"
,
businessType
=
BusinessType
.
INSERT
)
@SaCheckPermission
(
PermissionConstants
.
REGISTRATION_RESOURCE_UPLOAD
)
public
Result
<
TreeNodeDTO
>
syncRemoteDirectoryStructure
()
{
if
(
resourcesService
.
syncRemoteDirectoryStructure
())
{
return
Result
.
succeed
(
Status
.
SUCCESS
);
}
return
Result
.
failed
(
Status
.
FAILED
);
}
@PostMapping
(
"/createFolder"
)
@PostMapping
(
"/createFolder"
)
@ApiOperation
(
"Create Folder"
)
@ApiOperation
(
"Create Folder"
)
@Log
(
title
=
"Create Folder"
,
businessType
=
BusinessType
.
INSERT
)
@Log
(
title
=
"Create Folder"
,
businessType
=
BusinessType
.
INSERT
)
...
...
dinky-admin/src/main/java/org/dinky/data/model/Resources.java
View file @
81f7697a
...
@@ -37,17 +37,23 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
...
@@ -37,17 +37,23 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
/** @TableName dinky_resources */
/** @TableName dinky_resources */
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@TableName
(
value
=
"dinky_resources"
)
@TableName
(
value
=
"dinky_resources"
)
@Data
@Data
@ApiModel
(
value
=
"Resources"
,
description
=
"Resource Information"
)
@ApiModel
(
value
=
"Resources"
,
description
=
"Resource Information"
)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
Resources
extends
Model
<
Resources
>
{
public
class
Resources
extends
Model
<
Resources
>
{
@TableId
(
type
=
IdType
.
A
UTO
)
@TableId
(
type
=
IdType
.
A
SSIGN_ID
)
@ApiModelProperty
(
value
=
"ID"
,
dataType
=
"Integer"
,
example
=
"1"
,
notes
=
"Unique identifier for the resource"
)
@ApiModelProperty
(
value
=
"ID"
,
dataType
=
"Integer"
,
example
=
"1"
,
notes
=
"Unique identifier for the resource"
)
private
Integer
id
;
private
Integer
id
;
...
...
dinky-admin/src/main/java/org/dinky/service/resource/BaseResourceManager.java
View file @
81f7697a
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
package
org
.
dinky
.
service
.
resource
;
package
org
.
dinky
.
service
.
resource
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.model.Resources
;
import
org.dinky.data.model.SystemConfiguration
;
import
org.dinky.data.model.SystemConfiguration
;
import
org.dinky.oss.OssTemplate
;
import
org.dinky.oss.OssTemplate
;
import
org.dinky.service.resource.impl.HdfsResourceManager
;
import
org.dinky.service.resource.impl.HdfsResourceManager
;
...
@@ -32,6 +33,7 @@ import org.apache.hadoop.fs.FileSystem;
...
@@ -32,6 +33,7 @@ import org.apache.hadoop.fs.FileSystem;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.List
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -54,6 +56,8 @@ public interface BaseResourceManager {
...
@@ -54,6 +56,8 @@ public interface BaseResourceManager {
String
getFileContent
(
String
path
);
String
getFileContent
(
String
path
);
List
<
Resources
>
getFullDirectoryStructure
(
int
rootId
);
InputStream
readFile
(
String
path
);
InputStream
readFile
(
String
path
);
static
BaseResourceManager
getInstance
()
{
static
BaseResourceManager
getInstance
()
{
...
@@ -102,8 +106,14 @@ public interface BaseResourceManager {
...
@@ -102,8 +106,14 @@ public interface BaseResourceManager {
}
}
default
String
getFilePath
(
String
path
)
{
default
String
getFilePath
(
String
path
)
{
return
FileUtil
.
normalize
(
return
FileUtil
.
normalize
(
FileUtil
.
file
(
getBasePath
(),
path
).
toString
());
FileUtil
.
file
(
instances
.
getResourcesUploadBasePath
().
getValue
(),
path
)
}
.
toString
());
default
String
getBasePath
()
{
String
basePath
=
instances
.
getResourcesUploadBasePath
().
getValue
();
if
(!
basePath
.
endsWith
(
"/"
))
{
basePath
+=
"/"
;
}
return
basePath
;
}
}
}
}
dinky-admin/src/main/java/org/dinky/service/resource/ResourcesService.java
View file @
81f7697a
...
@@ -34,6 +34,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
...
@@ -34,6 +34,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
public
interface
ResourcesService
extends
IService
<
Resources
>
{
public
interface
ResourcesService
extends
IService
<
Resources
>
{
boolean
syncRemoteDirectoryStructure
();
/**
/**
* Create a new folder with the specified parameters.
* Create a new folder with the specified parameters.
*
*
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/HdfsResourceManager.java
View file @
81f7697a
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
package
org
.
dinky
.
service
.
resource
.
impl
;
package
org
.
dinky
.
service
.
resource
.
impl
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.model.Resources
;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.apache.hadoop.fs.FSDataOutputStream
;
import
org.apache.hadoop.fs.FSDataOutputStream
;
...
@@ -29,6 +30,7 @@ import org.apache.hadoop.fs.Path;
...
@@ -29,6 +30,7 @@ import org.apache.hadoop.fs.Path;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -85,6 +87,11 @@ public class HdfsResourceManager implements BaseResourceManager {
...
@@ -85,6 +87,11 @@ public class HdfsResourceManager implements BaseResourceManager {
return
IoUtil
.
readUtf8
(
readFile
(
path
));
return
IoUtil
.
readUtf8
(
readFile
(
path
));
}
}
@Override
public
List
<
Resources
>
getFullDirectoryStructure
(
int
rootId
)
{
throw
new
RuntimeException
(
"Sync HDFS Not implemented!"
);
}
@Override
@Override
public
InputStream
readFile
(
String
path
)
{
public
InputStream
readFile
(
String
path
)
{
try
{
try
{
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/LocalResourceManager.java
View file @
81f7697a
...
@@ -20,12 +20,20 @@
...
@@ -20,12 +20,20 @@
package
org
.
dinky
.
service
.
resource
.
impl
;
package
org
.
dinky
.
service
.
resource
.
impl
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.model.Resources
;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.dinky.service.resource.BaseResourceManager
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedInputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -81,6 +89,40 @@ public class LocalResourceManager implements BaseResourceManager {
...
@@ -81,6 +89,40 @@ public class LocalResourceManager implements BaseResourceManager {
return
IoUtil
.
readUtf8
(
readFile
(
path
));
return
IoUtil
.
readUtf8
(
readFile
(
path
));
}
}
@Override
public
List
<
Resources
>
getFullDirectoryStructure
(
int
rootId
)
{
String
basePath
=
getBasePath
();
try
(
Stream
<
Path
>
paths
=
Files
.
walk
(
Paths
.
get
(
basePath
)))
{
return
paths
.
map
(
path
->
{
if
(
path
.
compareTo
(
Paths
.
get
(
basePath
))
==
0
)
{
// 跳过根目录 | skip root directory
return
null
;
}
Path
parentPath
=
path
.
getParent
();
String
parent
=
""
;
if
(
parentPath
!=
null
)
{
parent
=
parentPath
.
toString
().
replace
(
basePath
,
""
);
}
String
self
=
path
.
toString
().
replace
(
basePath
,
""
);
int
pid
=
parent
.
isEmpty
()
?
rootId
:
parent
.
hashCode
();
File
file
=
new
File
(
path
.
toString
());
return
Resources
.
builder
()
.
id
(
self
.
hashCode
())
.
pid
(
pid
)
.
fullName
(
self
)
.
fileName
(
file
.
getName
())
.
isDirectory
(
file
.
isDirectory
())
.
type
(
0
)
.
size
(
file
.
length
())
.
build
();
})
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
@Override
@Override
public
InputStream
readFile
(
String
path
)
{
public
InputStream
readFile
(
String
path
)
{
return
FileUtil
.
getInputStream
(
getFilePath
(
path
));
return
FileUtil
.
getInputStream
(
getFilePath
(
path
));
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/OssResourceManager.java
View file @
81f7697a
...
@@ -21,16 +21,22 @@ package org.dinky.service.resource.impl;
...
@@ -21,16 +21,22 @@ package org.dinky.service.resource.impl;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.model.Resources
;
import
org.dinky.oss.OssTemplate
;
import
org.dinky.oss.OssTemplate
;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.dinky.service.resource.BaseResourceManager
;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.amazonaws.services.s3.model.CopyObjectRequest
;
import
com.amazonaws.services.s3.model.CopyObjectRequest
;
import
com.amazonaws.services.s3.model.DeleteObjectRequest
;
import
com.amazonaws.services.s3.model.DeleteObjectRequest
;
import
com.amazonaws.services.s3.model.S3ObjectSummary
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
...
@@ -80,6 +86,43 @@ public class OssResourceManager implements BaseResourceManager {
...
@@ -80,6 +86,43 @@ public class OssResourceManager implements BaseResourceManager {
return
IoUtil
.
readUtf8
(
readFile
(
path
));
return
IoUtil
.
readUtf8
(
readFile
(
path
));
}
}
@Override
public
List
<
Resources
>
getFullDirectoryStructure
(
int
rootId
)
{
String
basePath
=
getBasePath
();
List
<
S3ObjectSummary
>
listBucketObjects
=
getOssTemplate
().
listBucketObjects
(
getOssTemplate
().
getBucketName
(),
basePath
);
Map
<
Integer
,
Resources
>
resourcesMap
=
new
HashMap
<>();
for
(
S3ObjectSummary
obj
:
listBucketObjects
)
{
obj
.
setKey
(
obj
.
getKey
().
replace
(
basePath
,
""
));
if
(
obj
.
getKey
().
isEmpty
())
{
continue
;
}
String
[]
split
=
obj
.
getKey
().
split
(
"/"
);
String
parent
=
""
;
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
String
s
=
split
[
i
];
int
pid
=
parent
.
isEmpty
()
?
rootId
:
parent
.
hashCode
();
parent
=
parent
+
"/"
+
s
;
Resources
.
ResourcesBuilder
builder
=
Resources
.
builder
()
.
id
(
parent
.
hashCode
())
.
pid
(
pid
)
.
fullName
(
parent
)
.
fileName
(
s
)
.
isDirectory
(
obj
.
getKey
().
endsWith
(
"/"
))
.
size
(
obj
.
getSize
());
if
(
i
==
split
.
length
-
1
)
{
builder
.
isDirectory
(
obj
.
getKey
().
endsWith
(
"/"
));
}
else
{
builder
.
isDirectory
(
true
);
}
resourcesMap
.
put
(
parent
.
hashCode
(),
builder
.
build
());
}
}
return
new
ArrayList
<>(
resourcesMap
.
values
());
}
@Override
@Override
public
InputStream
readFile
(
String
path
)
{
public
InputStream
readFile
(
String
path
)
{
return
getOssTemplate
()
return
getOssTemplate
()
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java
View file @
81f7697a
...
@@ -33,6 +33,7 @@ import java.io.File;
...
@@ -33,6 +33,7 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -56,6 +57,37 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -56,6 +57,37 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
private
static
final
TimedCache
<
Integer
,
Resources
>
RESOURCES_CACHE
=
new
TimedCache
<>(
30
*
1000
);
private
static
final
TimedCache
<
Integer
,
Resources
>
RESOURCES_CACHE
=
new
TimedCache
<>(
30
*
1000
);
private
static
final
long
ALLOW_MAX_CAT_CONTENT_SIZE
=
10
*
1024
*
1024
;
private
static
final
long
ALLOW_MAX_CAT_CONTENT_SIZE
=
10
*
1024
*
1024
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
syncRemoteDirectoryStructure
()
{
Resources
rootResource
=
getOne
(
new
LambdaQueryWrapper
<
Resources
>().
eq
(
Resources:
:
getPid
,
-
1
));
if
(
rootResource
==
null
)
{
throw
new
BusException
(
"root directory is not exists!! please check database"
);
}
List
<
Resources
>
local
=
list
();
Map
<
Integer
,
Resources
>
localMap
=
local
.
stream
().
collect
(
Collectors
.
toMap
(
Resources:
:
getId
,
Function
.
identity
()));
List
<
Resources
>
resourcesList
=
getBaseResourceManager
().
getFullDirectoryStructure
(
rootResource
.
getId
()).
stream
()
.
filter
(
x
->
x
.
getPid
()
!=
-
1
)
.
peek
(
x
->
{
// Restore the existing information. If the remotmap is not available,
// it means that the configuration is out of sync and no processing will be done.
Resources
resources
=
localMap
.
get
(
x
.
getFileName
().
hashCode
());
if
(
resources
!=
null
)
{
x
.
setDescription
(
resources
.
getDescription
());
x
.
setType
(
resources
.
getType
());
x
.
setUserId
(
resources
.
getUserId
());
}
})
.
collect
(
Collectors
.
toList
());
// not delete root directory
this
.
remove
(
new
LambdaQueryWrapper
<
Resources
>().
ne
(
Resources:
:
getPid
,
-
1
));
this
.
saveBatch
(
resourcesList
);
return
true
;
}
@Override
@Override
public
TreeNodeDTO
createFolder
(
Integer
pid
,
String
fileName
,
String
desc
)
{
public
TreeNodeDTO
createFolder
(
Integer
pid
,
String
fileName
,
String
desc
)
{
long
count
=
count
(
long
count
=
count
(
...
@@ -212,13 +244,12 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -212,13 +244,12 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
}
}
/**
/**
*
* @param pid pid
* @param pid pid
* @param desc desc
* @param desc desc
* @param uploadAction uploadAction
* @param uploadAction uploadAction
* @param fileName fileName
* @param fileName
fileName
* @param pResource pResource
* @param pResource
pResource
* @param size size
* @param size
size
*/
*/
private
void
upload
(
private
void
upload
(
Integer
pid
,
String
desc
,
Consumer
<
String
>
uploadAction
,
String
fileName
,
Resources
pResource
,
long
size
)
{
Integer
pid
,
String
desc
,
Consumer
<
String
>
uploadAction
,
String
fileName
,
Resources
pResource
,
long
size
)
{
...
@@ -275,10 +306,6 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -275,10 +306,6 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
==
-
1
,
==
-
1
,
()
->
new
BusException
(
Status
.
ROOT_DIR_NOT_ALLOW_DELETE
));
()
->
new
BusException
(
Status
.
ROOT_DIR_NOT_ALLOW_DELETE
));
try
{
try
{
if
(
id
<
1
)
{
// todo 删除主目录,实际是清空
remove
(
new
LambdaQueryWrapper
<
Resources
>().
ne
(
Resources:
:
getId
,
0
));
}
Resources
byId
=
getById
(
id
);
Resources
byId
=
getById
(
id
);
if
(
isExistsChildren
(
id
))
{
if
(
isExistsChildren
(
id
))
{
if
(
byId
.
getIsDirectory
())
{
if
(
byId
.
getIsDirectory
())
{
...
...
dinky-common/src/main/java/org/dinky/oss/OssTemplate.java
View file @
81f7697a
...
@@ -43,6 +43,8 @@ import com.amazonaws.services.s3.AmazonS3Client;
...
@@ -43,6 +43,8 @@ import com.amazonaws.services.s3.AmazonS3Client;
import
com.amazonaws.services.s3.model.Bucket
;
import
com.amazonaws.services.s3.model.Bucket
;
import
com.amazonaws.services.s3.model.CannedAccessControlList
;
import
com.amazonaws.services.s3.model.CannedAccessControlList
;
import
com.amazonaws.services.s3.model.GeneratePresignedUrlRequest
;
import
com.amazonaws.services.s3.model.GeneratePresignedUrlRequest
;
import
com.amazonaws.services.s3.model.ListObjectsV2Request
;
import
com.amazonaws.services.s3.model.ListObjectsV2Result
;
import
com.amazonaws.services.s3.model.ObjectListing
;
import
com.amazonaws.services.s3.model.ObjectListing
;
import
com.amazonaws.services.s3.model.ObjectMetadata
;
import
com.amazonaws.services.s3.model.ObjectMetadata
;
import
com.amazonaws.services.s3.model.PutObjectRequest
;
import
com.amazonaws.services.s3.model.PutObjectRequest
;
...
@@ -71,7 +73,7 @@ public class OssTemplate {
...
@@ -71,7 +73,7 @@ public class OssTemplate {
* <p>
* <p>
*
*
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListBuckets">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListBuckets">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
List
<
Bucket
>
getAllBuckets
()
{
public
List
<
Bucket
>
getAllBuckets
()
{
return
amazonS3
.
listBuckets
();
return
amazonS3
.
listBuckets
();
...
@@ -80,7 +82,7 @@ public class OssTemplate {
...
@@ -80,7 +82,7 @@ public class OssTemplate {
/**
/**
* @param bucketName bucket名称
* @param bucketName bucket名称
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListBuckets">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListBuckets">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
Optional
<
Bucket
>
getBucket
(
String
bucketName
)
{
public
Optional
<
Bucket
>
getBucket
(
String
bucketName
)
{
return
amazonS3
.
listBuckets
().
stream
()
return
amazonS3
.
listBuckets
().
stream
()
...
@@ -91,7 +93,7 @@ public class OssTemplate {
...
@@ -91,7 +93,7 @@ public class OssTemplate {
/**
/**
* @param bucketName bucket名称
* @param bucketName bucket名称
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/DeleteBucket">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/DeleteBucket">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
void
removeBucket
(
String
bucketName
)
{
public
void
removeBucket
(
String
bucketName
)
{
amazonS3
.
deleteBucket
(
bucketName
);
amazonS3
.
deleteBucket
(
bucketName
);
...
@@ -101,9 +103,9 @@ public class OssTemplate {
...
@@ -101,9 +103,9 @@ public class OssTemplate {
* 根据文件前置查询文件
* 根据文件前置查询文件
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param prefix 前缀
* @param prefix
前缀
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListObjects">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/ListObjects">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
List
<
S3ObjectSummary
>
getAllObjectsByPrefix
(
String
bucketName
,
String
prefix
)
{
public
List
<
S3ObjectSummary
>
getAllObjectsByPrefix
(
String
bucketName
,
String
prefix
)
{
ObjectListing
objectListing
=
amazonS3
.
listObjects
(
bucketName
,
prefix
);
ObjectListing
objectListing
=
amazonS3
.
listObjects
(
bucketName
,
prefix
);
...
@@ -115,7 +117,7 @@ public class OssTemplate {
...
@@ -115,7 +117,7 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param minutes 过期时间,单位分钟,请注意该值必须小于7天
* @param minutes
过期时间,单位分钟,请注意该值必须小于7天
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
*/
*/
...
@@ -128,7 +130,7 @@ public class OssTemplate {
...
@@ -128,7 +130,7 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param expires 过期时间,请注意该值必须小于7天
* @param expires
过期时间,请注意该值必须小于7天
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
*/
*/
...
@@ -141,7 +143,7 @@ public class OssTemplate {
...
@@ -141,7 +143,7 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param minutes 过期时间,单位分钟,请注意该值必须小于7天
* @param minutes
过期时间,单位分钟,请注意该值必须小于7天
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
*/
*/
...
@@ -154,7 +156,7 @@ public class OssTemplate {
...
@@ -154,7 +156,7 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param expires 过期时间,请注意该值必须小于7天
* @param expires
过期时间,请注意该值必须小于7天
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration)
*/
*/
...
@@ -167,11 +169,11 @@ public class OssTemplate {
...
@@ -167,11 +169,11 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param minutes 过期时间,单位分钟,请注意该值必须小于7天
* @param minutes
过期时间,单位分钟,请注意该值必须小于7天
* @param method 文件操作方法:GET(下载)、PUT(上传)
* @param method
文件操作方法:GET(下载)、PUT(上传)
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod
*
method)
* method)
*/
*/
public
String
getObjectURL
(
String
bucketName
,
String
objectName
,
int
minutes
,
HttpMethod
method
)
{
public
String
getObjectURL
(
String
bucketName
,
String
objectName
,
int
minutes
,
HttpMethod
method
)
{
return
getObjectURL
(
bucketName
,
objectName
,
Duration
.
ofMinutes
(
minutes
),
method
);
return
getObjectURL
(
bucketName
,
objectName
,
Duration
.
ofMinutes
(
minutes
),
method
);
...
@@ -182,11 +184,11 @@ public class OssTemplate {
...
@@ -182,11 +184,11 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param expires 过期时间,请注意该值必须小于7天
* @param expires
过期时间,请注意该值必须小于7天
* @param method 文件操作方法:GET(下载)、PUT(上传)
* @param method
文件操作方法:GET(下载)、PUT(上传)
* @return url
* @return url
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod
* @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod
*
method)
* method)
*/
*/
public
String
getObjectURL
(
String
bucketName
,
String
objectName
,
Duration
expires
,
HttpMethod
method
)
{
public
String
getObjectURL
(
String
bucketName
,
String
objectName
,
Duration
expires
,
HttpMethod
method
)
{
// Set the pre-signed URL to expire after `expires`.
// Set the pre-signed URL to expire after `expires`.
...
@@ -222,7 +224,7 @@ public class OssTemplate {
...
@@ -222,7 +224,7 @@ public class OssTemplate {
* @param objectName 文件名称
* @param objectName 文件名称
* @return 二进制流
* @return 二进制流
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/GetObject">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/GetObject">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
S3Object
getObject
(
String
bucketName
,
String
objectName
)
{
public
S3Object
getObject
(
String
bucketName
,
String
objectName
)
{
return
amazonS3
.
getObject
(
bucketName
,
objectName
);
return
amazonS3
.
getObject
(
bucketName
,
objectName
);
...
@@ -233,7 +235,7 @@ public class OssTemplate {
...
@@ -233,7 +235,7 @@ public class OssTemplate {
*
*
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @param stream 文件流
* @param stream
文件流
* @throws IOException IOException
* @throws IOException IOException
*/
*/
public
void
putObject
(
String
bucketName
,
String
objectName
,
InputStream
stream
)
throws
IOException
{
public
void
putObject
(
String
bucketName
,
String
objectName
,
InputStream
stream
)
throws
IOException
{
...
@@ -243,9 +245,9 @@ public class OssTemplate {
...
@@ -243,9 +245,9 @@ public class OssTemplate {
/**
/**
* 上传文件 指定 contextType
* 上传文件 指定 contextType
*
*
* @param bucketName bucket名称
* @param bucketName
bucket名称
* @param objectName 文件名称
* @param objectName
文件名称
* @param stream 文件流
* @param stream
文件流
* @param contextType 文件类型
* @param contextType 文件类型
* @throws IOException IOException
* @throws IOException IOException
*/
*/
...
@@ -257,13 +259,13 @@ public class OssTemplate {
...
@@ -257,13 +259,13 @@ public class OssTemplate {
/**
/**
* 上传文件
* 上传文件
*
*
* @param bucketName bucket名称
* @param bucketName
bucket名称
* @param objectName 文件名称
* @param objectName
文件名称
* @param stream 文件流
* @param stream
文件流
* @param size 大小
* @param size
大小
* @param contextType 类型
* @param contextType 类型
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObject">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObject">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
PutObjectResult
putObject
(
public
PutObjectResult
putObject
(
String
bucketName
,
String
objectName
,
InputStream
stream
,
long
size
,
String
contextType
)
{
String
bucketName
,
String
objectName
,
InputStream
stream
,
long
size
,
String
contextType
)
{
...
@@ -285,7 +287,7 @@ public class OssTemplate {
...
@@ -285,7 +287,7 @@ public class OssTemplate {
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/GetObject">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/GetObject">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
S3Object
getObjectInfo
(
String
bucketName
,
String
objectName
)
{
public
S3Object
getObjectInfo
(
String
bucketName
,
String
objectName
)
{
return
amazonS3
.
getObject
(
bucketName
,
objectName
);
return
amazonS3
.
getObject
(
bucketName
,
objectName
);
...
@@ -297,12 +299,26 @@ public class OssTemplate {
...
@@ -297,12 +299,26 @@ public class OssTemplate {
* @param bucketName bucket名称
* @param bucketName bucket名称
* @param objectName 文件名称
* @param objectName 文件名称
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/DeleteObject">AWS API
* @see <a href= "http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/DeleteObject">AWS API
*
Documentation</a>
* Documentation</a>
*/
*/
public
void
removeObject
(
String
bucketName
,
String
objectName
)
{
public
void
removeObject
(
String
bucketName
,
String
objectName
)
{
amazonS3
.
deleteObject
(
bucketName
,
objectName
);
amazonS3
.
deleteObject
(
bucketName
,
objectName
);
}
}
public
List
<
S3ObjectSummary
>
listBucketObjects
(
String
bucketName
,
String
prefix
)
{
List
<
S3ObjectSummary
>
s3ObjectSummaries
=
new
ArrayList
<>();
ListObjectsV2Request
listObjectsRequest
=
new
ListObjectsV2Request
().
withBucketName
(
bucketName
).
withPrefix
(
prefix
);
ListObjectsV2Result
listing
;
do
{
listing
=
amazonS3
.
listObjectsV2
(
listObjectsRequest
);
s3ObjectSummaries
.
addAll
(
listing
.
getObjectSummaries
());
String
token
=
listing
.
getNextContinuationToken
();
listObjectsRequest
.
setContinuationToken
(
token
);
}
while
(
listing
.
isTruncated
());
return
s3ObjectSummaries
;
}
public
AmazonS3
getAmazonS3
()
{
public
AmazonS3
getAmazonS3
()
{
return
amazonS3
;
return
amazonS3
;
}
}
...
...
dinky-web/src/locales/en-US/pages.ts
View file @
81f7697a
...
@@ -972,6 +972,8 @@ export default {
...
@@ -972,6 +972,8 @@ export default {
'rc.resource.upload.tip1'
:
'Click or drag file to this area to upload'
,
'rc.resource.upload.tip1'
:
'Click or drag file to this area to upload'
,
'rc.resource.upload.tip2'
:
'rc.resource.upload.tip2'
:
'Support for a single or bulk upload. Strictly prohibited from uploading company data or
\
n other banned files.'
,
'Support for a single or bulk upload. Strictly prohibited from uploading company data or
\
n other banned files.'
,
'rc.resource.filelist'
:
'File list'
,
'rc.resource.sync'
:
'Sync remote files'
,
'rc.template.codeType'
:
'Code Type'
,
'rc.template.codeType'
:
'Code Type'
,
'rc.template.codeTypePlaceholder'
:
'Please select code type! '
,
'rc.template.codeTypePlaceholder'
:
'Please select code type! '
,
'rc.template.create'
:
'Create UDF Template'
,
'rc.template.create'
:
'Create UDF Template'
,
...
...
dinky-web/src/locales/zh-CN/pages.ts
View file @
81f7697a
...
@@ -930,6 +930,9 @@ export default {
...
@@ -930,6 +930,9 @@ export default {
'rc.resource.upload.fail'
:
'文件 【{fileName}】 上传失败'
,
'rc.resource.upload.fail'
:
'文件 【{fileName}】 上传失败'
,
'rc.resource.upload.tip1'
:
'点击或拖拽文件到此区域上传'
,
'rc.resource.upload.tip1'
:
'点击或拖拽文件到此区域上传'
,
'rc.resource.upload.tip2'
:
'支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。'
,
'rc.resource.upload.tip2'
:
'支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。'
,
'rc.resource.filelist'
:
'文件列表'
,
'rc.resource.sync'
:
'同步目录结构'
,
'rc.template.codeType'
:
'代码类型'
,
'rc.template.codeType'
:
'代码类型'
,
'rc.template.codeTypePlaceholder'
:
'请选择代码类型!'
,
'rc.template.codeTypePlaceholder'
:
'请选择代码类型!'
,
'rc.template.create'
:
'创建 UDF 模板'
,
'rc.template.create'
:
'创建 UDF 模板'
,
...
...
dinky-web/src/pages/RegCenter/Resource/components/FileTree/index.tsx
View file @
81f7697a
...
@@ -17,9 +17,11 @@
...
@@ -17,9 +17,11 @@
*
*
*/
*/
import
{
LoadingBtn
}
from
'@/components/CallBackButton/LoadingBtn'
;
import
{
buildResourceTreeData
}
from
'@/pages/RegCenter/Resource/components/FileTree/function'
;
import
{
buildResourceTreeData
}
from
'@/pages/RegCenter/Resource/components/FileTree/function'
;
import
{
ResourceInfo
}
from
'@/types/RegCenter/data'
;
import
{
ResourceInfo
}
from
'@/types/RegCenter/data'
;
import
{
Empty
,
Tree
}
from
'antd'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
Divider
,
Empty
,
Flex
,
Tree
,
Typography
}
from
'antd'
;
import
React
from
'react'
;
import
React
from
'react'
;
const
{
DirectoryTree
}
=
Tree
;
const
{
DirectoryTree
}
=
Tree
;
...
@@ -28,14 +30,20 @@ type FileTreeProps = {
...
@@ -28,14 +30,20 @@ type FileTreeProps = {
treeData
:
ResourceInfo
[];
treeData
:
ResourceInfo
[];
onNodeClick
:
(
info
:
any
)
=>
void
;
onNodeClick
:
(
info
:
any
)
=>
void
;
onRightClick
:
(
info
:
any
)
=>
void
;
onRightClick
:
(
info
:
any
)
=>
void
;
onSync
:
()
=>
void
;
selectedKeys
:
string
[];
selectedKeys
:
string
[];
};
};
const
FileTree
:
React
.
FC
<
FileTreeProps
>
=
(
props
)
=>
{
const
FileTree
:
React
.
FC
<
FileTreeProps
>
=
(
props
)
=>
{
const
{
treeData
,
selectedKeys
,
onNodeClick
,
onRightClick
}
=
props
;
const
{
treeData
,
selectedKeys
,
onNodeClick
,
onRightClick
,
onSync
}
=
props
;
return
(
return
(
<>
<>
<
Flex
justify=
{
'space-between'
}
align=
{
'center'
}
>
<
Typography
.
Text
>
{
l
(
'rc.resource.filelist'
)
}
</
Typography
.
Text
>
<
LoadingBtn
props=
{
{
type
:
'link'
}
}
click=
{
onSync
}
title=
{
l
(
'rc.resource.sync'
)
}
/>
</
Flex
>
<
Divider
style=
{
{
margin
:
'8px'
}
}
/>
{
treeData
.
length
>
0
?
(
{
treeData
.
length
>
0
?
(
<
DirectoryTree
<
DirectoryTree
className=
{
'treeList'
}
className=
{
'treeList'
}
...
...
dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx
View file @
81f7697a
...
@@ -27,7 +27,12 @@ import FileShow from '@/pages/RegCenter/Resource/components/FileShow';
...
@@ -27,7 +27,12 @@ import FileShow from '@/pages/RegCenter/Resource/components/FileShow';
import
FileTree
from
'@/pages/RegCenter/Resource/components/FileTree'
;
import
FileTree
from
'@/pages/RegCenter/Resource/components/FileTree'
;
import
ResourceModal
from
'@/pages/RegCenter/Resource/components/ResourceModal'
;
import
ResourceModal
from
'@/pages/RegCenter/Resource/components/ResourceModal'
;
import
ResourcesUploadModal
from
'@/pages/RegCenter/Resource/components/ResourcesUploadModal'
;
import
ResourcesUploadModal
from
'@/pages/RegCenter/Resource/components/ResourcesUploadModal'
;
import
{
handleOption
,
handleRemoveById
,
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
handleGetOption
,
handleOption
,
handleRemoveById
,
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
ResourceInfo
}
from
'@/types/RegCenter/data'
;
import
{
ResourceInfo
}
from
'@/types/RegCenter/data'
;
import
{
InitResourceState
}
from
'@/types/RegCenter/init.d'
;
import
{
InitResourceState
}
from
'@/types/RegCenter/init.d'
;
...
@@ -180,6 +185,11 @@ const ResourceOverView: React.FC = () => {
...
@@ -180,6 +185,11 @@ const ResourceOverView: React.FC = () => {
}));
}));
};
};
const
handleSync
=
async
()
=>
{
await
handleGetOption
(
API_CONSTANTS
.
RESOURCE_SYNC_DATA
,
l
(
'rc.resource.sync'
),
{});
await
refreshTree
();
};
/**
/**
* the rename cancel
* the rename cancel
*/
*/
...
@@ -260,6 +270,7 @@ const ResourceOverView: React.FC = () => {
...
@@ -260,6 +270,7 @@ const ResourceOverView: React.FC = () => {
treeData=
{
resourceState
.
treeData
}
treeData=
{
resourceState
.
treeData
}
onRightClick=
{
handleRightClick
}
onRightClick=
{
handleRightClick
}
onNodeClick=
{
(
info
:
any
)
=>
handleNodeClick
(
info
)
}
onNodeClick=
{
(
info
:
any
)
=>
handleNodeClick
(
info
)
}
onSync=
{
handleSync
}
/>
/>
<
RightContextMenu
<
RightContextMenu
contextMenuPosition=
{
resourceState
.
contextMenuPosition
}
contextMenuPosition=
{
resourceState
.
contextMenuPosition
}
...
...
dinky-web/src/services/endpoints.tsx
View file @
81f7697a
...
@@ -291,6 +291,7 @@ export enum API_CONSTANTS {
...
@@ -291,6 +291,7 @@ export enum API_CONSTANTS {
RESOURCE_CREATE_FOLDER
=
'/api/resource/createFolder'
,
RESOURCE_CREATE_FOLDER
=
'/api/resource/createFolder'
,
RESOURCE_RENAME
=
'/api/resource/rename'
,
RESOURCE_RENAME
=
'/api/resource/rename'
,
RESOURCE_UPLOAD
=
'/api/resource/uploadFile'
,
RESOURCE_UPLOAD
=
'/api/resource/uploadFile'
,
RESOURCE_SYNC_DATA
=
'/api/resource/syncRemoteDirectory'
,
// catalog
// catalog
DELETE_CATALOGUE_BY_ID_URL
=
'/api/catalogue/deleteCatalogueById'
,
DELETE_CATALOGUE_BY_ID_URL
=
'/api/catalogue/deleteCatalogueById'
,
...
...
dinky-web/src/types/Studio/data.d.ts
View file @
81f7697a
...
@@ -318,6 +318,6 @@ export type ButtonRoute = {
...
@@ -318,6 +318,6 @@ export type ButtonRoute = {
click
?:
()
=>
any
;
click
?:
()
=>
any
;
hotKey
?:
(
e
:
KeyboardEvent
)
=>
boolean
;
hotKey
?:
(
e
:
KeyboardEvent
)
=>
boolean
;
hotKeyDesc
?:
string
;
hotKeyDesc
?:
string
;
isShow
:
boolean
;
isShow
?
:
boolean
;
props
?:
ButtonProps
;
props
?:
ButtonProps
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment