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-11497 - convert all cnd files to repoinit statements #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

niekraaijmakers
Copy link
Contributor

Make sure to include all cnd files to the aclmanager in sling initial content.
This will result in having the cnd definitions be converted to repoinit statements.

Make sure to include all cnd files to the aclmanager in sling initial content.
This will result in having the cnd definitions be converted to repoinit statements.
@@ -138,6 +141,11 @@ private void extractFile(JarEntry jarEntry, JarOutputStream bundleOutput) throws

SlingInitialContentBundleEntryMetaData bundleEntry = createSlingInitialContentBundleEntry(context, targetFile);
collectedSlingInitialContentBundleEntries.add(bundleEntry);
} else if (jarEntry.getName().endsWith(".cnd")) {
Copy link
Member

Choose a reason for hiding this comment

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

IMHO only those cnd files referenced in the manifest are considered in Sling Initial Content (https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html#node-type-and-namespace-definitions-cnd)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Let me work on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kwin implemented & pushed

Narrow down the nodetype registration to Sling-Nodetypes header
return false;
}

return jarEntry.getName().equals(slingNodeTypes);
Copy link
Member

Choose a reason for hiding this comment

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

This is potentially a comma separated list. Also a unit test/IT covering this would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again a good point.. implemented this and pushed.

@@ -109,12 +109,6 @@ void extractAndAddToAssembler(@NotNull BundleSlingInitialContentExtractContext c
throw new IOException("Can not convert " + file + " to enhanced DocView format", e);
}

// remap CND files to make sure they are picked up by the NodeTypesEntryHandler
if (context.getNamespaceRegistry().getRegisteredCndSystemIds().contains(file.getName())) {
contentPackageEntryPath = "/META-INF/vault/" + Text.getName(file.getName()) + ".cnd";
Copy link
Member

Choose a reason for hiding this comment

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

Why was the approach to convert to cnd files in a package discarded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't seem to have an effect afaik but I guess im wrong, il put it back in then

Copy link
Member

Choose a reason for hiding this comment

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

Either put into repo init statements or into content packages, not both!

Make Sling-Nodetypes multi valued, separated by comma
Unit test added + verify
Add integration test
@sonarcloud
Copy link

sonarcloud bot commented Jul 26, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

88.2% 88.2% Coverage
0.0% 0.0% Duplication

@rombert
Copy link
Contributor

rombert commented Aug 11, 2022

@kwin - do you have other comments regarding this PR?

@kwin
Copy link
Member

kwin commented Aug 11, 2022

For me the general approach of converting CNDs is not clear. In the past they were supposed to be wrapped in content-packages (coming from Sling Initial Content) and now they are supposed to be converted to RepoInit. Not sure if there former way was fully removed by this PR. Also the same conversion should be done for CND files coming from regular content packages (not via Sling-Initial Content). For that I don't see a test either.

@rombert
Copy link
Contributor

rombert commented Aug 11, 2022

Thanks @kwin , I guess we need @niekraaijmakers to look into this in more depth then.

@niekraaijmakers
Copy link
Contributor Author

@kwin so my question is, on the current state (master) where is the namespace registration handled? Wrapped in a content package?

Because when I execute it in a unit test ( the one in this PR ) I can't find it, but I might just be missing it.
The namespace I have comes from sling initial content. The sling initial content is extracted properly to mysite.core-apps.zip properly, but there is no cnd file (also not in the core package).

Should the CND file remain in the core package itself?

@kwin
Copy link
Member

kwin commented Aug 17, 2022

where is the namespace registration handled?

I don't know, my point is rather that this should be handled the same no matter whether the CND is provided through a package or via initial content. Please proof with additional test that
a) It works the same way for content packages
b) The CND is no longer contained in any output package but only in the repoinit contained in the model

Also it would be good to add the information to the readme how namespace and node type registration is handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants