Skip to content
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

Fixed problem with lowercase validation of path on CSIP107 #312

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.roda_project.commons_ip2.mets_v1_12.beans.MdSecType;
import org.roda_project.commons_ip2.mets_v1_12.beans.MetsType;
import org.roda_project.commons_ip2.mets_v1_12.beans.StructMapType;
import org.roda_project.commons_ip2.model.IPConstants;
import org.roda_project.commons_ip2.validator.common.MetsParser;
import org.roda_project.commons_ip2.validator.constants.Constants;
import org.roda_project.commons_ip2.validator.handlers.MetsHandler;
Expand Down Expand Up @@ -1283,15 +1284,25 @@ protected ReporterDetails validateCSIP107(final StructureValidatorState structur
final StringBuilder path = new StringBuilder();
if (metsValidatorState.isRootMets()) {
if (metsValidatorState.getMets().getOBJID() != null) {
path.append(metsValidatorState.getMets().getOBJID()).append("/").append(label.toLowerCase());
if (label.startsWith(IPConstants.REPRESENTATIONS_WITH_FIRST_LETTER_CAPITAL)) {
path.append(metsValidatorState.getMets().getOBJID()).append("/")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck> reported by reviewdog 🐶
The String "/" appears 3 times in the file.

.append(label.substring(0, 1).toLowerCase()).append(label.substring(1));
} else {
path.append(metsValidatorState.getMets().getOBJID()).append("/").append(label.toLowerCase());
}
} else {
return new ReporterDetails(Constants.VALIDATION_REPORT_HEADER_CSIP_VERSION,
Message.createErrorMessage("mets/OBJECTID in %1$s can't be null",
metsValidatorState.getMetsName(), metsValidatorState.isRootMets()),
false, false);
}
} else {
path.append(metsValidatorState.getMetsPath()).append(label.toLowerCase());
if (label.startsWith(IPConstants.REPRESENTATIONS_WITH_FIRST_LETTER_CAPITAL)) {
path.append(metsValidatorState.getMetsPath()).append(label.substring(0, 1).toLowerCase())
.append(label.substring(1));
} else {
path.append(metsValidatorState.getMetsPath()).append(label.toLowerCase());
}
}
if (!structureValidatorState.getZipManager().checkDirectory(structureValidatorState.getIpPath(),
path.toString())) {
Expand All @@ -1303,8 +1314,14 @@ protected ReporterDetails validateCSIP107(final StructureValidatorState structur
false, false);
}
} else {
String normalizedLable;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'normalizedLable' should be declared final.

if (label.startsWith(IPConstants.REPRESENTATIONS_WITH_FIRST_LETTER_CAPITAL)) {
normalizedLable = label.substring(0, 1).toLowerCase() + label.substring(1);
} else {
normalizedLable = label.toLowerCase();
}
if (!structureValidatorState.getFolderManager()
.checkDirectory(Paths.get(metsValidatorState.getMetsPath()).resolve(label.toLowerCase()))) {
.checkDirectory(Paths.get(metsValidatorState.getMetsPath()).resolve(normalizedLable))) {
message.append("mets/structMap[@LABEL='CSIP']/div/div/@LABEL in %1$s ( ").append(label).append(" )")
.append("does not lead to a directory ( ")
.append(Paths.get(metsValidatorState.getMetsPath()).resolve(label.toLowerCase())).append(" )");
Expand Down