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

SlingModelPersist type handling cleanup #73

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

Conversation

badvision
Copy link
Contributor

This cleans up how primary type and resource type are managed. I removed the child content type feature because it was too confusing to use and even more confusing in the code implementation. Now if you want a jcr:content child, add a content property to your object and use a @nAmed("jcr:content") annotation. This means that the java object graph should be more or less identical to the jcr node graph.

@@ -18,10 +18,10 @@
*/
package org.apache.sling.models.persistor;

import com.drew.lang.annotations.NotNull;
Copy link
Contributor

Choose a reason for hiding this comment

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

@badvision any particular reason for changing annotation types? A number of other projects use the Jetbrains annotations, so it'd be better to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm good point, I think that was an oversight as I was having difficulty building in this one case -- happy to revert them back.

@@ -18,6 +18,7 @@
*/
package org.apache.sling.models.persistor.impl;

import com.drew.lang.annotations.NotNull;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment re:annotation

private static String getNodeType(Object obj) throws IllegalArgumentException, IllegalAccessException {
for (Field f : obj.getClass().getDeclaredFields()) {
Named namedAnnotation = f.getAnnotation(Named.class);
if (namedAnnotation != null && namedAnnotation.value().equals("jcr:primaryType")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, I try to avoid hard-coding too. Thanks for catching that.

@sonarcloud
Copy link

sonarcloud bot commented Apr 1, 2021

@sonarcloud
Copy link

sonarcloud bot commented Jul 10, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

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.

2 participants