You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "enapps-enorman (via GitHub)" <gi...@apache.org> on 2025/10/30 16:50:01 UTC
[PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
enapps-enorman opened a new pull request, #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6
The lookup of serviceuser configurations throws an exception if the sling:OsgiConfig type is not registered. This can happen when the org.apache.sling.installer.provider.jcr bundle is not installed.
The logs report an error about the unknown node type and the browser shows a "500 Server Error" page.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "enapps-enorman (via GitHub)" <gi...@apache.org>.
enapps-enorman commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2512246141
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
@kwin With the [e5a97f1](https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6/commits/e5a97f1880a1dc4f89a72b7ce19a15d870cc10f7) checkin, I made a new attempt to utilize OSGi Config Admin API for reading/writing. I left the old way as a fallback since I didn't see a convenient way to tell ConfiguationAdmin to store the data in a specific location.
A summary of the changed behavior is below:
1. Use ConfigurationAdmin to find the OSGi configurations to display on the service user details UI
a) Also change the rendering of the configuration items to render a link to the /system/console/configMgr/[pid] for each item
2. Add a code path for using ConfigurationAdmin to store the configuration state from the "Create Service User" form.
a) Changed the "Application Path" field to now be optional. Also this field now not rendered at all if the "sling:OsgiConfig" nodetype has not been deployed since it doesn't make sense without JcrInstaller available.
b) Added a new "Configuration Instance Identifier" field which defines the suffix for the configuration PID. Previously this value came from the last segment of the "Application Path" field which is now optional.
So the new behavior is that if "Application Path" is empty or the "sling:OsgiConfig" nodetype is not available, the configuration will be applied by delegating to the ConfigurationAdmin APIs. Otherwise, when there is a specific "Application Path" value supplied, the configuration will be applied by persisting a configuration resource as it was before.
Please let me know if this resolves your previous concerns.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2479318468
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
I checked out the UI and the location where the it is persisted is not even exposed, so I think one should use https://docs.osgi.org/javadoc/osgi.cmpn/8.1.0/org/osgi/service/cm/ConfigurationAdmin.html instead of leveraging a query. This can also be used to store new configs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "enapps-enorman (via GitHub)" <gi...@apache.org>.
enapps-enorman commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2478967914
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
Maybe @klcodanr can confirm since he committed the original code. But it looks like to me this is just displaying the locations where the configuration resources were persisted. It isn't using the configuration data for anything.
Is it possible to dig that information out of what you would get from using the Config Admin API?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2479318468
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
I checked out the UI and the location where the it is persisted is not even exposed, so I think one should use https://docs.osgi.org/javadoc/osgi.cmpn/8.1.0/org/osgi/service/cm/ConfigurationAdmin.html instead of leveraging a query. This can also be used to store new configs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3514221235
## [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [87.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3567074846
## [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [87.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3513948688
## [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6) **Quality Gate failed**
Failed conditions
 [75.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_coverage&view=list) (required ≥ 80%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2479019362
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
Not directly but if this is only about configs provided via OSGI installer there is https://sling.apache.org/apidocs/sling13/org/apache/sling/installer/api/info/InfoProvider.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "enapps-enorman (via GitHub)" <gi...@apache.org>.
enapps-enorman merged PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3514256640
## [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [87.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3469023716
## [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6) **Quality Gate failed**
Failed conditions
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6&metric=new_coverage&view=list) (required ≥ 80%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-serviceuser-webconsole&pullRequest=6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#discussion_r2478943643
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -295,18 +298,44 @@ private Bundle findBundle(String symbolicName, Map<String, Bundle> bundles) {
return bundles.get(symbolicName);
}
+ /**
+ * Helper to check if the specified node type has been registered
+ *
+ * @param resolver the resolver to check
+ * @param typeName the node type name to check
+ * @return true if the node type exists, false otherwise
+ */
+ private boolean hasRegisteredNodeType(@NotNull ResourceResolver resolver, @NotNull String typeName) {
+ boolean hasNodeType = false;
+ final @Nullable Session jcrSession = resolver.adaptTo(Session.class);
+ if (jcrSession != null) {
+ try {
+ final NodeTypeManager nodeTypeManager =
+ jcrSession.getWorkspace().getNodeTypeManager();
+ hasNodeType = nodeTypeManager.hasNodeType(typeName);
+ } catch (RepositoryException e) {
+ log.warn("Unable to detemine if node type is registered", e);
+ }
+ }
+ return hasNodeType;
+ }
+
private Object findConfigurations(ResourceResolver resolver, String name, List<String> affectedPaths) {
List<String> configurations = new ArrayList<>();
- Iterator<Resource> configResources = resolver.findResources(
- "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
- + name + "'",
- Query.JCR_SQL2);
- while (configResources.hasNext()) {
- Resource configResource = configResources.next();
- affectedPaths.add(configResource.getPath());
- configurations.add(configResource.getPath());
+ Iterator<Resource> configResources;
+ if (hasRegisteredNodeType(resolver, "sling:OsgiConfig")) {
+ configResources = resolver.findResources(
+ "SELECT * FROM [sling:OsgiConfig] AS s WHERE (ISDESCENDANTNODE([/apps]) OR ISDESCENDANTNODE([/libs])) AND NAME(s) LIKE 'org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended%' AND [user.mapping] LIKE '%="
Review Comment:
For me the whole approach is kind of wrong. Using OSGi Config Admin API for reading/writing that info should be used. Sling OSGi Installer with its `sling:OsgiConfig` nodes is just one of the multiple ways how to deploy an OSGi config…
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] SLING-12987 Viewing serviceuser details may fail if sling:OsgiConfig nodetype is not registered [sling-org-apache-sling-serviceuser-webconsole]
Posted by "enapps-enorman (via GitHub)" <gi...@apache.org>.
enapps-enorman commented on PR #6:
URL: https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/6#issuecomment-3567078298
Given that there have been no further feedback on the latest proposal for a couple of weeks, this is the last chance for anyone to review the changes. I intend to merge this on November 25th if there are no further objections.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org