-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5565 allow edit of file position in directory structure #5650
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
0e45247
#5565 allow edit of file directory
sekmiller f57d2a5
#5565 add directory label to filesFragment/File page
sekmiller 6f87904
Merge branch 'develop' into 5565-allow-edit-of-file-directory
mheppler 29517e1
Layout clean up of the file hierarchy metadata on dataset and file pg…
mheppler 610d451
Revised hierarchy input label [ref #5565]
mheppler 85ed63e
Added placeholder documentation for File Path to Dataset + File Manag…
mheppler b301621
#5565 strip out leading/trailing slashes. fix tests
sekmiller 20d7eda
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller ae7897b
Fixing unrelated syntax errors
dlmurphy d5c13ae
Compressed Files section edits [#5565]
dlmurphy 3241413
#5565 improve validator and UI
sekmiller eb727c6
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller cfcc5e9
Revised File Path and Download Files docs [#5565]
dlmurphy d3c4bcb
#5565 add validation message for file directory
sekmiller b7cdb19
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller 9516c41
#5565 remove comments/debug code
sekmiller 12716e6
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller 050941c
#5565 clean up formatting around directory input. remove immediate
sekmiller 19aa312
#5565 remove ineffective validators
sekmiller 44027ac
add some tests #5565
pdurbin a2b9133
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller efb6ce4
#5565 strip multiple inner slashes add tests
sekmiller 5b42b0d
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller 71d805f
fix for the sanitize method for the folder names. (#5565)
landreev fadf409
more cleanup fixes.
landreev 6901b03
validation cleanup (#5565)
landreev d995c39
Flyway upgrade script, to sanitize any existing folder labels in File…
landreev c528995
allow directoryLabel (File Path) to be set via API
pdurbin 56a3798
Merge branch 'develop' into 5565-allow-edit-of-file-directory
sekmiller f64ec15
shouldn't have removed all those backslashes. #5565
landreev 394e9c0
Merge branch '5565-allow-edit-of-file-directory' of https://github.co…
landreev c6965ac
Added "aggressive sanitizing" of the folder names found in uploaded z…
landreev ae08a6f
renamed the FLyway migration script, to reflect the 4-digit version n…
landreev b2f04e4
update SQL name example #5565
pdurbin 13de9cf
Merge pull request #5678 from IQSS/set-directory-label-via-api
djbrooke dd3f6be
documentation snippets for the automatically applied sanitizing rules…
landreev 893f8bf
Merge branch 'develop' into 5565-allow-edit-of-file-directory
landreev File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
In this release users are given an option to edit the folder names in the file metadata. Strict validation rules for the folder names are also introduced. Only the following characters are allowed: the alphanumerics, '_', '-', '.' and ' ' (white space). Some datafiles in your Dataverse may already have folder names saved in the database (if they were extracted from uploaded zip archives with folder structure). The following sanitizing rules will be applied to all the existing folder names in the database: any invalid characters will be replaced by the '.' character. Any sequences of dots will be further replaced with a single dot. For example, the folder name ``data&info/code=@137`` will be converted to ``data.info/code.137``. This update will be automatically applied to the database the first time this release is deployed. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/edu/harvard/iq/dataverse/FileDirectoryNameValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package edu.harvard.iq.dataverse; | ||
|
||
import edu.harvard.iq.dataverse.util.StringUtil; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
/** | ||
* | ||
* @author skraffmi | ||
*/ | ||
public class FileDirectoryNameValidator implements ConstraintValidator<ValidateDataFileDirectoryName, String> { | ||
|
||
@Override | ||
public void initialize(ValidateDataFileDirectoryName constraintAnnotation) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isValid(String value, ConstraintValidatorContext context) { | ||
return isFileDirectoryNameValid(value, context); | ||
|
||
} | ||
|
||
public static boolean isFileDirectoryNameValid(String value, ConstraintValidatorContext context) { | ||
|
||
if (value == null || value.isEmpty()) { | ||
return true; | ||
} | ||
String validCharacters = "[\\w\\\\/. -]+"; | ||
Pattern p = Pattern.compile(validCharacters); | ||
Matcher m = p.matcher(value); | ||
return m.matches(); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/edu/harvard/iq/dataverse/ValidateDataFileDirectoryName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package edu.harvard.iq.dataverse; | ||
|
||
import java.lang.annotation.Documented; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import java.lang.annotation.Retention; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
import java.lang.annotation.Target; | ||
import javax.validation.Constraint; | ||
import javax.validation.Payload; | ||
|
||
/** | ||
* | ||
* @author skraffmi | ||
*/ | ||
@Target({FIELD}) | ||
@Retention(RUNTIME) | ||
@Constraint(validatedBy = {FileDirectoryNameValidator.class}) | ||
@Documented | ||
public @interface ValidateDataFileDirectoryName { | ||
|
||
String message() default "Failed Validation for Validate Data File Directory Name"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I get the exact same folder structure as I originally uploaded? Here's an example of how we changed directory names and sometimes file names in the DVN 3 days: IQSS/dataverse-client-r#18 (comment)
The zip file I uploaded to DVN 3
The zip file I downloaded from DVN 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested this on demo (thanks for the suggestion at standup) and here's how it works as of Dataverse 4.11.
The zip file I uploaded to Dataverse 4.11
The zip file I downloaded from Dataverse 4.11
This is looking good to me. Dataverse adds the MANIFEST.TXT file, but this is a feature. Here is the content of that file: