Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1105 Внедрение механизмов обеспечения безопасности цепочки поставки программных проектов
Legacy
scanned-projects
Mediaarchive
Commits
0b0874b2
Commit
0b0874b2
authored
4 years ago
by
Рудакова Ольга Сергеевна
Browse files
Options
Download
Patches
Plain Diff
Fix delete of channel 3
parent
ad5c8f51
master
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/com/rudakova/media_archive/converter/FileConverter.java
+16
-14
...a/com/rudakova/media_archive/converter/FileConverter.java
src/main/java/com/rudakova/media_archive/google/GoogleService.java
+4
-3
...java/com/rudakova/media_archive/google/GoogleService.java
target/MediaArchive-1.0-SNAPSHOT.jar
+0
-0
target/MediaArchive-1.0-SNAPSHOT.jar
with
20 additions
and
17 deletions
+20
-17
src/main/java/com/rudakova/media_archive/converter/FileConverter.java
+
16
−
14
View file @
0b0874b2
...
...
@@ -13,23 +13,24 @@ import java.util.List;
*/
public
class
FileConverter
{
public
static
File
convertFromGoogleFile
(
com
.
google
.
api
.
services
.
drive
.
model
.
File
file
,
Account
account
,
String
folderId
)
{
File
fileModel
=
convertFromGoogleFile
(
file
,
account
);
public
static
File
convertFromGoogleFile
(
com
.
google
.
api
.
services
.
drive
.
model
.
File
file
,
File
fileFromBd
,
Account
account
,
String
folderId
)
{
File
fileModel
=
convertFromGoogleFile
(
file
,
fileFromBd
,
account
);
fileModel
.
setBaseFolderId
(
folderId
);
return
fileModel
;
}
public
static
File
convertFromGoogleFile
(
com
.
google
.
api
.
services
.
drive
.
model
.
File
file
,
Account
account
)
{
File
fileModel
=
new
File
();
file
Model
.
setAccount
(
account
);
file
Model
.
setName
(
file
.
getName
());
file
Model
.
setId
(
file
.
getId
());
file
Model
.
setParents
(
file
.
getParents
());
file
Model
.
setMimeType
(
file
.
getMimeType
());
file
Model
.
setCreatedDate
(
file
.
getCreatedTime
()
==
null
?
null
:
file
.
getCreatedTime
().
toString
());
file
Model
.
setWebLink
(
file
.
getWebViewLink
());
file
Model
.
setPreview
(
file
.
getThumbnailLink
());
return
file
Model
;
public
static
File
convertFromGoogleFile
(
com
.
google
.
api
.
services
.
drive
.
model
.
File
file
,
File
fileFromBd
,
Account
account
)
{
file
FromBd
.
setAccount
(
account
);
file
FromBd
.
setName
(
file
.
getName
());
file
FromBd
.
setId
(
file
.
getId
());
file
FromBd
.
setParents
(
file
.
getParents
());
file
FromBd
.
setMimeType
(
file
.
getMimeType
());
file
FromBd
.
setCreatedDate
(
file
.
getCreatedTime
()
==
null
?
null
:
file
.
getCreatedTime
().
toString
());
file
FromBd
.
setWebLink
(
file
.
getWebViewLink
());
file
FromBd
.
setPreview
(
file
.
getThumbnailLink
());
return
file
FromBd
;
}
public
static
com
.
google
.
api
.
services
.
drive
.
model
.
File
convertToGoogleShortcut
(
File
file
,
String
parentId
)
{
...
...
@@ -48,7 +49,8 @@ public class FileConverter {
public
static
List
<
File
>
convertList
(
FileList
fileList
,
Account
account
,
String
folderId
)
{
List
<
File
>
files
=
new
ArrayList
<>();
for
(
com
.
google
.
api
.
services
.
drive
.
model
.
File
googleFile
:
fileList
.
getFiles
())
{
files
.
add
(
convertFromGoogleFile
(
googleFile
,
account
,
folderId
));
File
file
=
new
File
();
files
.
add
(
convertFromGoogleFile
(
googleFile
,
file
,
account
,
folderId
));
}
return
files
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/rudakova/media_archive/google/GoogleService.java
+
4
−
3
View file @
0b0874b2
...
...
@@ -271,17 +271,17 @@ public class GoogleService {
Queue
<
String
>
folders
,
com
.
google
.
api
.
services
.
drive
.
model
.
File
file
)
{
String
mimeType
=
file
.
getMimeType
();
NotificationDto
.
Address
address
;
File
savedFile
;
File
savedFile
=
fileRepository
.
findById
(
file
.
getId
()).
orElse
(
new
File
())
;
if
(
mimeType
.
equals
(
"application/vnd.google-apps.folder"
))
{
folders
.
offer
(
file
.
getId
());
address
=
NotificationDto
.
Address
.
FOLDER
;
savedFile
=
fileRepository
.
save
(
FileConverter
.
convertFromGoogleFile
(
file
,
account
,
folderId
));
fileRepository
.
save
(
FileConverter
.
convertFromGoogleFile
(
file
,
savedFile
,
account
,
folderId
));
}
else
if
(
mimeType
.
contains
(
"video"
))
{
if
(
file
.
getHasThumbnail
())
{
savePreview
(
file
);
}
address
=
NotificationDto
.
Address
.
VIDEO
;
savedFile
=
fileRepository
.
save
(
FileConverter
.
convertFromGoogleFile
(
file
,
account
,
folderId
));
fileRepository
.
save
(
FileConverter
.
convertFromGoogleFile
(
file
,
savedFile
,
account
,
folderId
));
}
else
{
return
;
}
...
...
@@ -296,6 +296,7 @@ public class GoogleService {
deleteWatchChannel
(
savedFile
.
getChannel
(),
account
);
savedFile
.
setChannel
(
null
);
savedFile
.
setNeedChannel
(
false
);
fileRepository
.
save
(
savedFile
);
}
}
...
...
This diff is collapsed.
Click to expand it.
target/MediaArchive-1.0-SNAPSHOT.jar
+
0
−
0
View file @
0b0874b2
No preview for this file type
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets