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

SLING-10786 : DefaultAclManager - sonar finding #110

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,29 @@ private String getRelativeIntermediatePath(@NotNull String intermediatePath) thr
}

protected @Nullable CreatePath getCreatePath(@NotNull RepoPath path, @NotNull List<VaultPackageAssembler> packageAssemblers) {
if (path.getParent() == null) {
log.debug("Omit create path statement for path '{}'", path);
return null;
}

CreatePath cp = new CreatePath(null);
boolean foundType = processSegments(path, packageAssemblers, cp);

if (!foundType && isBelowUserRoot(path)) {
// if no type information has been detected, don't issue a 'create path' statement for nodes below the
// user-root
log.warn("Failed to extract primary type information for node at path '{}'", path);
return null;
} else {
// assume that primary type information is present or can be extracted from default primary type definition
// of the the top-level nodes (i.e. their effective node type definition).
return cp;
}
}

private static boolean processSegments(@NotNull RepoPath path, @NotNull List<VaultPackageAssembler> packageAssemblers, @NotNull CreatePath cp) {
String platformPath = "";
boolean foundType = false;

CreatePath cp = new CreatePath(null);
for (String part : path.getSegments()) {
String platformname = PlatformNameFormat.getPlatformName(part);
platformPath += platformPath.isEmpty() ? platformname : "/" + platformname;
Expand All @@ -444,20 +463,7 @@ private String getRelativeIntermediatePath(@NotNull String intermediatePath) thr
cp.addSegment(part, null);
}
}

if (!foundType && isBelowUserRoot(path)) {
// if no type information has been detected, don't issue a 'create path' statement for nodes below the
// user-root
log.warn("Failed to extract primary type information for node at path '{}'", path);
return null;
} else if (path.getParent() == null) {
log.debug("Omit create path statement for path '{}'", path);
return null;
} else {
// assume that primary type information is present or can be extracted from default primary type definition
// of the the top-level nodes (i.e. their effective node type definition).
return cp;
}
return foundType;
}

private static boolean addSegment(@NotNull CreatePath cp, @NotNull String part, @NotNull File currentContent) {
Expand Down