38
38
import java .util .Map ;
39
39
import java .util .Queue ;
40
40
import java .util .Set ;
41
+ import java .util .Objects ;
41
42
import java .util .concurrent .ConcurrentHashMap ;
42
43
import java .util .regex .Matcher ;
43
44
@@ -1341,7 +1342,8 @@ public void importNotes(List<String> files, Page parent, String conflict, Identi
1341
1342
notesFilePath = file ;
1342
1343
}
1343
1344
if (file .contains ("/" + FEATURED_IMAGE_FOLDER + "/" )) {
1344
- String imageId = file .substring (file .lastIndexOf ("/" ) + 1 );
1345
+ String fileName = file .substring (file .lastIndexOf ("/" ) + 1 );
1346
+ String imageId = fileName .substring (0 , fileName .lastIndexOf ("." ));
1345
1347
featuredImages .put (imageId , file );
1346
1348
}
1347
1349
}
@@ -1975,6 +1977,7 @@ private void importNote(Page note,
1975
1977
String conflict ,
1976
1978
Identity userIdentity ) throws Exception {
1977
1979
1980
+ Page targetNote = null ;
1978
1981
File featuredImageFile = extractNoteFeaturedImageFileToImport (note , featuredImages );
1979
1982
Page parent_ = getNoteOfNoteBookByName (wiki .getType (), wiki .getOwner (), parent .getName ());
1980
1983
if (parent_ == null ) {
@@ -1991,6 +1994,7 @@ private void importNote(Page note,
1991
1994
imagesSubLocationPath );
1992
1995
note .setContent (processedContent );
1993
1996
note_ = createNote (wiki , parent_ .getName (), note , userIdentity , false );
1997
+ targetNote = note_ ;
1994
1998
} else {
1995
1999
if (StringUtils .isNotEmpty (conflict )) {
1996
2000
if (conflict .equals ("overwrite" ) || conflict .equals ("replaceAll" )) {
@@ -2000,24 +2004,27 @@ private void importNote(Page note,
2000
2004
imagesSubLocationPath );
2001
2005
note .setContent (processedContent );
2002
2006
note_ = createNote (wiki , parent_ .getName (), note , userIdentity , false );
2003
-
2007
+ targetNote = note_ ;
2004
2008
}
2005
2009
if (conflict .equals ("duplicate" )) {
2006
2010
String processedContent = htmlUploadImageProcessor .processSpaceImages (note .getContent (),
2007
2011
wiki .getOwner (),
2008
2012
imagesSubLocationPath );
2009
2013
note .setContent (processedContent );
2010
2014
note_ = createNote (wiki , parent_ .getName (), note , userIdentity );
2015
+ targetNote = note_ ;
2011
2016
}
2012
2017
if (conflict .equals ("update" )) {
2013
- if (!note_2 .getTitle ().equals (note .getTitle ()) || !note_2 .getContent ().equals (note .getContent ())) {
2018
+ if (!note_2 .getTitle ().equals (note .getTitle ()) || !note_2 .getContent ().equals (note .getContent ())
2019
+ || !Objects .equals (note_2 .getProperties (), note .getProperties ())) {
2014
2020
note_2 .setTitle (note .getTitle ());
2015
2021
String processedContent = htmlUploadImageProcessor .processSpaceImages (note .getContent (),
2016
2022
wiki .getOwner (),
2017
2023
imagesSubLocationPath );
2018
2024
note_2 .setContent (processedContent );
2019
2025
note_2 = updateNote (note_2 , PageUpdateType .EDIT_PAGE_CONTENT , userIdentity );
2020
2026
createVersionOfNote (note_2 , userIdentity .getUserId ());
2027
+ targetNote = note_2 ;
2021
2028
}
2022
2029
}
2023
2030
}
@@ -2026,20 +2033,21 @@ private void importNote(Page note,
2026
2033
if (StringUtils .isNotEmpty (conflict )
2027
2034
&& (conflict .equals ("update" ) || conflict .equals ("overwrite" ) || conflict .equals ("replaceAll" ))) {
2028
2035
Page note_1 = getNoteOfNoteBookByName (wiki .getType (), wiki .getOwner (), note .getName ());
2029
- if (!note .getContent ().equals (note_1 .getContent ())) {
2036
+ if (!note .getContent ().equals (note_1 .getContent ()) || ! Objects . equals ( note_1 . getProperties (), note . getProperties ()) ) {
2030
2037
String processedContent = htmlUploadImageProcessor .processSpaceImages (note .getContent (),
2031
2038
wiki .getOwner (),
2032
2039
imagesSubLocationPath );
2033
2040
note .setContent (processedContent );
2034
2041
note_1 .setContent (processedContent );
2035
2042
note_1 = updateNote (note_1 , PageUpdateType .EDIT_PAGE_CONTENT , userIdentity );
2036
2043
createVersionOfNote (note_1 , userIdentity .getUserId ());
2044
+ targetNote = note_1 ;
2037
2045
}
2038
2046
}
2039
2047
}
2040
2048
if (featuredImageFile != null ) {
2041
2049
saveImportedFeaturedImage (featuredImageFile ,
2042
- note ,
2050
+ targetNote ,
2043
2051
Long .parseLong (identityManager .getOrCreateUserIdentity (userIdentity .getUserId ()).getId ()));
2044
2052
}
2045
2053
if (note .getChildren () != null ) {
0 commit comments