[jira] [Commented] (SLING-7768) Add String Interpolation support to /etc/map

2020-01-22 Thread Carsten Ziegeler (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-7768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17021814#comment-17021814
 ] 

Carsten Ziegeler commented on SLING-7768:
-

Thanks for updating [~andysch] - the PR looks basically good to me, I've added 
some comments which would need to be addressed 

> Add String Interpolation support to /etc/map
> 
>
> Key: SLING-7768
> URL: https://issues.apache.org/jira/browse/SLING-7768
> Project: Sling
>  Issue Type: Improvement
>  Components: ResourceResolver
> Environment: Sling 11-SNAPSHOT, JDK 1.8
>Reporter: Andreas Schaefer
>Priority: Major
> Attachments: Screenshot 2018-07-06 11.41.58.png, Screenshot 
> 2018-07-06 11.42.41.png, Screenshot 2018-07-06 11.43.34.png
>
>
> Having worked on migrations of a Sling derivate Ruben & I ran into issues 
> where the /etc/map would map to production instead of testing environment.
>  Many big customer have extensive /etc/maps and also many different 
> environments like dev, qa, staging, prod etc.
>  It would be great to have a tool where for example items like the host name 
> or external links in /etc/map could be configured outside so that just one 
> entry has to adjusted rather than creating a full copy of the /etc/map tree.
>   
>  Example:
>   
>  /etc/map/http/phv.fq.host.name.8080
>   
>  Placeholder provides:
>  DEV: phv.fq.host.name=localhost
>  QA: phv.fq.host.name=qa.author.acme.com
>  STAGING: 
> phv.fq.host.name=[staging.author.acme.com|http://staging.author.acme.com/]
>  PROD: phv.fq.host.name=[acme.com|http://acme.com/]
>   
>  At runtime these are the resolved values:
>  DEV: http/localhost.8080
>  QA: http/qa.author.acme.com.8080
>  STAGING: http/[staging.author.acme.com|http://staging.author.acme.com/].8080
>  PROD: http/[acme.com|http://acme.com/].8080
>   
>  Not only does that make it easier and faster to create new test environments 
> but it also cuts down on the chance of copy-n-paste errors.
>   
>  I have a working POC with an PlaceholderProvider OSGi service and an 
> enhanced MapEntries that resolved any placeholders if found.
>   
>  Attached are 3 screenshots:
>  1. OSGi Placeholder Provider Configuration
>  2. /etc/map (Composum)
>  3. Result of [http://andreass.local:8080/] call



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369952814
 
 

 ##
 File path: 
src/test/java/org/apache/sling/resourceresolver/impl/mapping/EtcMappingMapEntriesTest.java
 ##
 @@ -16,12 +16,40 @@
  */
 package org.apache.sling.resourceresolver.impl.mapping;
 
 Review comment:
   There are a lot of changes in this test and I can't see whether these are 
just improvements or tests need to be adapted? 


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369952361
 
 

 ##
 File path: 
src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
 ##
 @@ -399,7 +400,7 @@ private Resource buildResource(String fullpath, 
Iterable children) {
 @SuppressWarnings("unchecked")
 private Resource buildResource(String fullpath, Iterable 
children, ResourceResolver resourceResolver, ResourceProvider provider, 
String ... properties) {
 Resource resource = Mockito.mock(Resource.class);
-Mockito.when(resource.getName()).thenReturn(getName(fullpath));
+Mockito.when(resource.getName()).thenReturn(getResourceName(fullpath));
 
 Review comment:
   ResourceUtil.getName() ?


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369952231
 
 

 ##
 File path: 
src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
 ##
 @@ -428,15 +429,15 @@ private Resource buildResource(String fullpath, 
Iterable children, Res
 }
 
 
-/**
- * extract the name from a path.
- * @param fullpath
- * @return
- */
-private String getName(String fullpath) {
-int n = fullpath.lastIndexOf("/");
-return fullpath.substring(n+1);
-}
+///**
 
 Review comment:
   Please remove the commented code


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951714
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderImpl.java
 ##
 @@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.metatype.annotations.Designate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Designate(ocd = StringInterpolationProviderConfiguration.class)
+@Component(name = 
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl")
+public class StringInterpolationProviderImpl
+implements StringInterpolationProvider
+{
+private static final String TYPE_ENV = "env";
+
+private static final String TYPE_PROP = "prop";
+
+private static final String DIRECTIVE_DEFAULT = "default";
+
+/** Logger. */
+private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+private Map placeholderEntries = new HashMap<>();
 
 Review comment:
   You either need to make this a concurrent map or change the logic in 
activate as modified() can change the map while it is used


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951773
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderImpl.java
 ##
 @@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.metatype.annotations.Designate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Designate(ocd = StringInterpolationProviderConfiguration.class)
+@Component(name = 
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl")
+public class StringInterpolationProviderImpl
+implements StringInterpolationProvider
+{
+private static final String TYPE_ENV = "env";
+
+private static final String TYPE_PROP = "prop";
+
+private static final String DIRECTIVE_DEFAULT = "default";
+
+/** Logger. */
+private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+private Map placeholderEntries = new HashMap<>();
+private BundleContext context;
+
+// -- SCR Integration -
+
+/**
+ * Activates this component (called by SCR before)
+ */
+@Activate
 
 Review comment:
   I suggest to change this to a constructor


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951714
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderImpl.java
 ##
 @@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.metatype.annotations.Designate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Designate(ocd = StringInterpolationProviderConfiguration.class)
+@Component(name = 
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl")
+public class StringInterpolationProviderImpl
+implements StringInterpolationProvider
+{
+private static final String TYPE_ENV = "env";
+
+private static final String TYPE_PROP = "prop";
+
+private static final String DIRECTIVE_DEFAULT = "default";
+
+/** Logger. */
+private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+private Map placeholderEntries = new HashMap<>();
 
 Review comment:
   Can be marked as final


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951347
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderImpl.java
 ##
 @@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.metatype.annotations.Designate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Designate(ocd = StringInterpolationProviderConfiguration.class)
+@Component(name = 
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl")
+public class StringInterpolationProviderImpl
+implements StringInterpolationProvider
+{
+private static final String TYPE_ENV = "env";
+
+private static final String TYPE_PROP = "prop";
+
+private static final String DIRECTIVE_DEFAULT = "default";
+
+/** Logger. */
+private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+private Map placeholderEntries = new HashMap<>();
+private BundleContext context;
+
+// -- SCR Integration -
+
+/**
+ * Activates this component (called by SCR before)
+ */
+@Activate
+protected void activate(final BundleContext bundleContext, final 
StringInterpolationProviderConfiguration config) {
+this.context = bundleContext;
+
+String[] valueMap = config.placeHolderKeyValuePairs();
+// Clear out any existing values
+placeholderEntries.clear();
+for(String line: valueMap) {
+// Ignore no or empty lines
+if(line != null && !line.isEmpty()) {
+// Ignore comments
+if(line.charAt(0) != '#') {
+int index = line.indexOf('=');
+if (index <= 0) {
+logger.warn("Placeholder Entry does not contain a key: 
'{}' -> ignored", line);
+} else if (index > line.length() - 2) {
+logger.warn("Placeholder Entry does not contain a 
value: '{}' -> ignored", line);
+} else {
+placeholderEntries.put(line.substring(0, index), 
line.substring(index + 1));
+}
+}
+}
+}
+}
+
+/**
+ * Modifies this component (called by SCR to update this component)
+ */
+@Modified
+protected void modified(final BundleContext bundleContext, final 
StringInterpolationProviderConfiguration config) {
+this.activate(bundleContext, config);
+}
+
+/**
+ * Deactivates this component (called by SCR to take out of service)
+ */
+@Deactivate
+protected void deactivate(final BundleContext bundleContext) {
+this.context = null;
+this.placeholderEntries = new HashMap<>();
+}
+
+/**
+ * This is the method that is used by the Map Entries service to 
substitute values with
+ * the proper format
+ * @param text Text to be converted
+ * @return Should be either the substituted text or the original given text
+ */
+@Override
+public String substitute(String text) {
+logger.trace("Substitute: '{}'", text);
+Object result = Interpolator.replace(text, (type, name, dir) -> {
+String v = null;
+if (TYPE_ENV.equals(type)) {
+v = getVariableFromEnvironment(name);
+} else if (TYPE_PROP.equals(type)) {
+v = getVariableFromProperty(name);
+} else {
 
 Review comment:
   we should define a type for this, like "config:" and not let all types 
fallback to this. The fallback prevents adding new types later on (if 

[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951126
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderImpl.java
 ##
 @@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.metatype.annotations.Designate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Designate(ocd = StringInterpolationProviderConfiguration.class)
+@Component(name = 
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl")
 
 Review comment:
   name attribute is not needed


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369951054
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/StringInterpolationProviderConfiguration.java
 ##
 @@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(
+name = "Apache Sling String Interpolation Provider",
+description = "Configures the String Interpolation Provider and the 
location of its key/value pairs"
+)
+public @interface StringInterpolationProviderConfiguration {
+
+@AttributeDefinition(
+name = "Placeholder Values",
+description = "A list of key / value pairs separated by a equal (=) 
sign. " +
+"The key is not permitted to contain a '=' sign and the first 
occurrence of '=' " +
+"separates the key from the value. If no '=' is found the entire 
key / value pair " +
+"is dropped.")
+String[] placeHolderKeyValuePairs() default 
{"phv.default.host.name=localhost"};
 
 Review comment:
   Do we really need such a default value?


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369950823
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
 ##
 @@ -140,8 +142,10 @@
 
 private boolean updateBloomFilterFile = false;
 
+private StringInterpolationProvider stringInterpolationProvider;
 
 Review comment:
   This can be marked as final


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369950715
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/Interpolator.java
 ##
 @@ -0,0 +1,154 @@
+/*
 
 Review comment:
   It's ok to have a copy here for getting the functionality in, but we should 
rather directly use the class from Apache Felix by embedding just that class 
(and using the maven shade plugin to move it to a different package). But we 
can do this in a follow up commit


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369950369
 
 

 ##
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
 ##
 @@ -107,6 +109,19 @@
 @Reference
 EventAdmin eventAdmin;
 
+/** Event admin. */
 
 Review comment:
   Comment above seems to be wrong :) Please make the reference greedy and 
remove the commented out lines below


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [sling-org-apache-sling-resourceresolver] cziegeler commented on a change in pull request #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
cziegeler commented on a change in pull request #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#discussion_r369950213
 
 

 ##
 File path: pom.xml
 ##
 @@ -63,6 +63,32 @@
 
 
 

Re: [VOTE] Promote sling-org-apache-sling-feature-starter / sling-slingstart-feature-maven-plugin to its own Sling Module

2020-01-22 Thread Carsten Ziegeler

Hi Andreas,

thanks, so the feature starter is - simplified - an improved feature 
launcher already containing all the required pieces including a basic 
feature model. Is that correct?


Regards
Carsten

On 23.01.2020 01:42, Andreas Schaefer wrote:

Hi Carsten

That is not what I had in mind. The Feature Starter is only containing the 
Feature Launcher and its necessary components to get it working (extensions) 
and the Sling FM file. The rest is downloaded and started through the Feature 
Launcher as if you started it with the Feature Launcher.

The JAR file has two options:
1) Provide an override of the Sling FM to run your very own Sling or Sling / 
Customized FMs
2) Provide additional FMs to add your customized FMs to the released Sling FM / 
instance

The rest of the options are the same as for the Sling Starter even though the 
Launcher Home is not supported yet.

This means that a user can either start Sling or can start its own project(s) + 
Sling with the Sling Feature Starter.

- Andy


On Jan 21, 2020, at 8:54 AM, Carsten Ziegeler  wrote:

So it seems you are suggestion, that if someone wants to build a Sling 
application, you clone/fork the feature-starter project, add your own feature 
models and build the project, right? So this is kind of a template for an own 
application project.

Lets assume we go this route, how would we change the current sling-starter 
project, which is the demo application we have?

Regards
Carsten

On 20.01.2020 07:05, Carsten Ziegeler wrote:

Can you explain a little bit more how this works for users wanting to build an 
application?
Today, you can create your own maven project, add/import provisioning models 
and build a startable jar (and a webapp which we don't need to support for 
feature models right now). You can then use this jar without any tooling.
Thanks
Carsten
On 20.01.2020 01:58, Andreas Schaefer wrote:

As far as I see the 'sling-org-apache-sling-feature-starter’ this is not just a 
test but rather the official way to start Sling XX. It does have the option to 
add additional Feature Models (customer FMs) to the startup and we can also add 
startup scripts so that it can be launched as a Unix style service.

I am fine with both approaches but we should make a decision one way or the 
other.

- Andy


On Jan 19, 2020, at 3:13 AM, Carsten Ziegeler  wrote:

Sorry for getting late to this, but is the slingstart-feature-maven-plugin also 
creating the startable jar?

While I suggested to create separate modules (which I continue to think is good), I'm a 
little bit worried about "org-apache-sling-feature-starter" - The current 
starter project is a demo setup for Sling, making it easy to try out and test Sling.
Maybe it would be better to have the feature equivalent on the master branch of 
"sling-org-apache-sling-starter" and we move current master branch to a 
"provisioning-model" branch.

Regards
Carsten

On 17.01.2020 17:41, Andreas Schaefer wrote:

Hi
This is a vote to promote the sling-org-apache-sling-feature-starter and 
sling-slingstart-feature-maven-plugin to their own Sling Module. This first 
module is the Feature Model counterpart of the sling-org-apache-sling-starter 
and will create an executable JAR file. The second is the counterpart of the 
sling-slingstart-maven-plugin which will start and stop a Sling Instance from a 
Maven run and is mostly used to run Integration Tests.
Sling Feature Starter:
1. Code Location: both are in the ‘sling-whiteboard’ under 
'sling-org-apache-sling-feature-starter` folder
2. Proposed Github Repo name (I just added feature into the name):
- sling-org-apache-sling-feature-starter
3. Proposed artifact ids (group id: org.apache.sling)
- org.apache.sling.feature.starter
Sling Start Feature Maven Plugin:
1. Code Location: both are in the ‘sling-whiteboard’ under 
'sling-slingstart-feature-maven-plugin` folder
2. Proposed Github Repo names (I just added feature into the name):
- sling-slingstart-feature-maven-plugin
3. Proposed artifact ids (group id: org.apache.sling)
- slingstart-feature-maven-plugin
As requested by Carsten I created separate modules for the Feature 
counterparts. The modules work but the are not finished. The Sling Feature 
Starter is actually using the Sling Start Feature Maven Plugin to run the IT 
tests.
- Andy


--
--
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org




--
--
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org




--
--
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org


[jira] [Commented] (SLING-7768) Add String Interpolation support to /etc/map

2020-01-22 Thread Andreas Schaefer (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-7768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17021803#comment-17021803
 ] 

Andreas Schaefer commented on SLING-7768:
-

Pushed my changes with the Interpolation and the 
$[type:name;default=defaultValue] syntax.

A few notes:
 # I could not remove the interface SlingInterpolationProvider as this did not 
work with the tests but I also like to have an interface to clearly show what 
function(s) a service exposes
 # Interpolation was copied over from Felix with the difference that a missing 
type results to taking the values from the Config map
 # env, prop and Config map values and defaults are supported
 # Only sling:match can have the placeholders
 # $[, ], :, ; and = for the placeholder separators are hard coded

> Add String Interpolation support to /etc/map
> 
>
> Key: SLING-7768
> URL: https://issues.apache.org/jira/browse/SLING-7768
> Project: Sling
>  Issue Type: Improvement
>  Components: ResourceResolver
> Environment: Sling 11-SNAPSHOT, JDK 1.8
>Reporter: Andreas Schaefer
>Priority: Major
> Attachments: Screenshot 2018-07-06 11.41.58.png, Screenshot 
> 2018-07-06 11.42.41.png, Screenshot 2018-07-06 11.43.34.png
>
>
> Having worked on migrations of a Sling derivate Ruben & I ran into issues 
> where the /etc/map would map to production instead of testing environment.
>  Many big customer have extensive /etc/maps and also many different 
> environments like dev, qa, staging, prod etc.
>  It would be great to have a tool where for example items like the host name 
> or external links in /etc/map could be configured outside so that just one 
> entry has to adjusted rather than creating a full copy of the /etc/map tree.
>   
>  Example:
>   
>  /etc/map/http/phv.fq.host.name.8080
>   
>  Placeholder provides:
>  DEV: phv.fq.host.name=localhost
>  QA: phv.fq.host.name=qa.author.acme.com
>  STAGING: 
> phv.fq.host.name=[staging.author.acme.com|http://staging.author.acme.com/]
>  PROD: phv.fq.host.name=[acme.com|http://acme.com/]
>   
>  At runtime these are the resolved values:
>  DEV: http/localhost.8080
>  QA: http/qa.author.acme.com.8080
>  STAGING: http/[staging.author.acme.com|http://staging.author.acme.com/].8080
>  PROD: http/[acme.com|http://acme.com/].8080
>   
>  Not only does that make it easier and faster to create new test environments 
> but it also cuts down on the chance of copy-n-paste errors.
>   
>  I have a working POC with an PlaceholderProvider OSGi service and an 
> enhanced MapEntries that resolved any placeholders if found.
>   
>  Attached are 3 screenshots:
>  1. OSGi Placeholder Provider Configuration
>  2. /etc/map (Composum)
>  3. Result of [http://andreass.local:8080/] call



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [sling-org-apache-sling-resourceresolver] sonarcloud[bot] commented on issue #15: Feature/sling 7768: String Interpolation for ETC Map

2020-01-22 Thread GitBox
sonarcloud[bot] commented on issue #15: Feature/sling 7768: String 
Interpolation for ETC Map
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/15#issuecomment-577517510
 
 
   SonarCloud Quality Gate failed.
   
   [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=BUG)
 [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=BUG)
  
   [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=VULNERABILITY)
 [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=VULNERABILITY)
 (and [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=SECURITY_HOTSPOT)
 [1 Security 
Hotspot](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=SECURITY_HOTSPOT)
 to review)  
   [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=CODE_SMELL)
 [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=CODE_SMELL)
 [8 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver=15=false=CODE_SMELL)
   
   [](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver=15=new_coverage=list)
 [0.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver=15=new_coverage=list)
  
   [](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver=15=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver=15=new_duplicated_lines_density=list)
   
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


Re: Slow queries and unexpected results

2020-01-22 Thread Carlos Munoz
I double checked and we do have the mapping. We copied all the provisioning
files from the commit you recommended earlier [1] and deployed like that.

In fact, you can see our provisioning files here: [2] We are only adding a
single file with our own bundle and configurations.

[1] https://github.com/apache/sling-org-apache-sling-starter/commit/c4f6e3b
[2]
https://github.com/redhataccess/pantheon/tree/upgrade-sling-bundles/pantheon-slingstart/src/main/provisioning

On Wed, Jan 22, 2020 at 4:54 PM Robert Munteanu  wrote:

> On Wed, 2020-01-22 at 16:16 -0500, Carlos Munoz wrote:
> > Thanks for the tip Daniel!
> >
> > Robert - we were able to successfully package the sling starter with
> > the
> > latest definitions as you pointed, but when deploying on top of an
> > existing
> > database we started getting a JCR error:
> >
> > javax.jcr.LoginException: Can neither derive user name nor principal
> > names
> > for bundle org.apache.sling.jcr.resource [152] and sub service
> > observation
> >
> > We don't get the same error when deploying on a fresh database.
>
> It seems that you have some missing service user mappings. Those might
> be required by newer versions of the bundles that you just consumed. In
> the Sling Starter the current mapping is defined at [1].
>
> Does adding that as a configuration to your application help?
>
> Thanks,
> Robert
>
>
> [1]:
> https://github.com/apache/sling-org-apache-sling-starter/blob/7eac121fc3f00c95ef5b8ac38133f6796a4a6c08/src/main/provisioning/sling.txt#L199-L202
>
>


Re: [VOTE] Promote sling-org-apache-sling-feature-starter / sling-slingstart-feature-maven-plugin to its own Sling Module

2020-01-22 Thread Andreas Schaefer
Hi Carsten

That is not what I had in mind. The Feature Starter is only containing the 
Feature Launcher and its necessary components to get it working (extensions) 
and the Sling FM file. The rest is downloaded and started through the Feature 
Launcher as if you started it with the Feature Launcher.

The JAR file has two options:
1) Provide an override of the Sling FM to run your very own Sling or Sling / 
Customized FMs
2) Provide additional FMs to add your customized FMs to the released Sling FM / 
instance

The rest of the options are the same as for the Sling Starter even though the 
Launcher Home is not supported yet.

This means that a user can either start Sling or can start its own project(s) + 
Sling with the Sling Feature Starter.

- Andy

> On Jan 21, 2020, at 8:54 AM, Carsten Ziegeler  wrote:
> 
> So it seems you are suggestion, that if someone wants to build a Sling 
> application, you clone/fork the feature-starter project, add your own feature 
> models and build the project, right? So this is kind of a template for an own 
> application project.
> 
> Lets assume we go this route, how would we change the current sling-starter 
> project, which is the demo application we have?
> 
> Regards
> Carsten
> 
> On 20.01.2020 07:05, Carsten Ziegeler wrote:
>> Can you explain a little bit more how this works for users wanting to build 
>> an application?
>> Today, you can create your own maven project, add/import provisioning models 
>> and build a startable jar (and a webapp which we don't need to support for 
>> feature models right now). You can then use this jar without any tooling.
>> Thanks
>> Carsten
>> On 20.01.2020 01:58, Andreas Schaefer wrote:
>>> As far as I see the 'sling-org-apache-sling-feature-starter’ this is not 
>>> just a test but rather the official way to start Sling XX. It does have the 
>>> option to add additional Feature Models (customer FMs) to the startup and 
>>> we can also add startup scripts so that it can be launched as a Unix style 
>>> service.
>>> 
>>> I am fine with both approaches but we should make a decision one way or the 
>>> other.
>>> 
>>> - Andy
>>> 
 On Jan 19, 2020, at 3:13 AM, Carsten Ziegeler  wrote:
 
 Sorry for getting late to this, but is the slingstart-feature-maven-plugin 
 also creating the startable jar?
 
 While I suggested to create separate modules (which I continue to think is 
 good), I'm a little bit worried about "org-apache-sling-feature-starter" - 
 The current starter project is a demo setup for Sling, making it easy to 
 try out and test Sling.
 Maybe it would be better to have the feature equivalent on the master 
 branch of "sling-org-apache-sling-starter" and we move current master 
 branch to a "provisioning-model" branch.
 
 Regards
 Carsten
 
 On 17.01.2020 17:41, Andreas Schaefer wrote:
> Hi
> This is a vote to promote the sling-org-apache-sling-feature-starter and 
> sling-slingstart-feature-maven-plugin to their own Sling Module. This 
> first module is the Feature Model counterpart of the 
> sling-org-apache-sling-starter and will create an executable JAR file. 
> The second is the counterpart of the sling-slingstart-maven-plugin which 
> will start and stop a Sling Instance from a Maven run and is mostly used 
> to run Integration Tests.
> Sling Feature Starter:
> 1. Code Location: both are in the ‘sling-whiteboard’ under 
> 'sling-org-apache-sling-feature-starter` folder
> 2. Proposed Github Repo name (I just added feature into the name):
> - sling-org-apache-sling-feature-starter
> 3. Proposed artifact ids (group id: org.apache.sling)
> - org.apache.sling.feature.starter
> Sling Start Feature Maven Plugin:
> 1. Code Location: both are in the ‘sling-whiteboard’ under 
> 'sling-slingstart-feature-maven-plugin` folder
> 2. Proposed Github Repo names (I just added feature into the name):
> - sling-slingstart-feature-maven-plugin
> 3. Proposed artifact ids (group id: org.apache.sling)
> - slingstart-feature-maven-plugin
> As requested by Carsten I created separate modules for the Feature 
> counterparts. The modules work but the are not finished. The Sling 
> Feature Starter is actually using the Sling Start Feature Maven Plugin to 
> run the IT tests.
> - Andy
 
 -- 
 -- 
 Carsten Ziegeler
 Adobe Research Switzerland
 cziege...@apache.org
>>> 
> 
> -- 
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



[jira] [Resolved] (SLING-9021) sling-mock: Respect context request when resolving sling binding properties

2020-01-22 Thread Stefan Seifert (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-9021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Seifert resolved SLING-9021.
---
Resolution: Fixed

https://github.com/apache/sling-org-apache-sling-testing-sling-mock/commit/fca63d1b43ac09f3b3ffab0c4da508bb63f5f148

> sling-mock: Respect context request when resolving sling binding properties
> ---
>
> Key: SLING-9021
> URL: https://issues.apache.org/jira/browse/SLING-9021
> Project: Sling
>  Issue Type: Improvement
>  Components: Testing
>Reporter: Stefan Seifert
>Assignee: Stefan Seifert
>Priority: Major
> Fix For: Testing Sling Mock 2.4.0
>
>
> in downstream implementations of Sling Mock Context it is required to get 
> hold of the current request when resolving sling binding properties, because 
> this request may be different from the sling context when sling models 
> ModelFactory is used.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (SLING-9021) sling-mock: Respect context request when resolving sling binding properties

2020-01-22 Thread Stefan Seifert (Jira)
Stefan Seifert created SLING-9021:
-

 Summary: sling-mock: Respect context request when resolving sling 
binding properties
 Key: SLING-9021
 URL: https://issues.apache.org/jira/browse/SLING-9021
 Project: Sling
  Issue Type: Improvement
  Components: Testing
Reporter: Stefan Seifert
Assignee: Stefan Seifert
 Fix For: Testing Sling Mock 2.4.0


in downstream implementations of Sling Mock Context it is required to get hold 
of the current request when resolving sling binding properties, because this 
request may be different from the sling context when sling models ModelFactory 
is used.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


Re: Slow queries and unexpected results

2020-01-22 Thread Robert Munteanu
On Wed, 2020-01-22 at 16:16 -0500, Carlos Munoz wrote:
> Thanks for the tip Daniel!
> 
> Robert - we were able to successfully package the sling starter with
> the
> latest definitions as you pointed, but when deploying on top of an
> existing
> database we started getting a JCR error:
> 
> javax.jcr.LoginException: Can neither derive user name nor principal
> names
> for bundle org.apache.sling.jcr.resource [152] and sub service
> observation
> 
> We don't get the same error when deploying on a fresh database.

It seems that you have some missing service user mappings. Those might
be required by newer versions of the bundles that you just consumed. In
the Sling Starter the current mapping is defined at [1].

Does adding that as a configuration to your application help?

Thanks,
Robert


[1]: 
https://github.com/apache/sling-org-apache-sling-starter/blob/7eac121fc3f00c95ef5b8ac38133f6796a4a6c08/src/main/provisioning/sling.txt#L199-L202



Re: Slow queries and unexpected results

2020-01-22 Thread Carlos Munoz
Thanks for the tip Daniel!

Robert - we were able to successfully package the sling starter with the
latest definitions as you pointed, but when deploying on top of an existing
database we started getting a JCR error:

javax.jcr.LoginException: Can neither derive user name nor principal names
for bundle org.apache.sling.jcr.resource [152] and sub service observation

We don't get the same error when deploying on a fresh database.

Carlos

On Wed, Jan 22, 2020 at 12:22 PM Daniel Klco  wrote:

> You can also try using the explain keyword to get introspection into how
> the JCR repository is planning to execute the query which may identify any
> traversal or index issues:
> https://jackrabbit.apache.org/oak/docs/query/grammar-sql2.html#explain
>
>
> On Wed, Jan 22, 2020 at 12:06 PM Carlos Munoz  wrote:
>
> > Thanks heaps Robert, sounds like way more than I was expecting :)
> >
> > I'll try these things and let you know how it goes.
> >
> >
> >
> > On Wed, Jan 22, 2020 at 9:31 AM Robert Munteanu 
> > wrote:
> >
> > > Hi Carlos,
> > >
> > > On Wed, 2020-01-22 at 07:11 -0500, Carlos Munoz wrote:
> > > > Thanks for the reply Robert. We are using the latest Sling release
> > > > (11) and
> > > > its corresponding bundle versions, so that would make it oak 1.8.8.
> > > >
> > > > We could proably be using more updated bundles, but without a stable
> > > > release or tag we're not sure how to gauge whether a set of bundles
> > > > is
> > > > stable enough.
> > >
> > > Latest released bundles as found in the current sling starter [1]
> > > should be stable. You could try and update to a later Oak, we have
> > > validated that Oak 1.16.0 works fine, see commit [2] for details.
> > >
> > > I would suggest the following:
> > >
> > > 1. Try and update to Oak 1.16.0, following commit [2] .
> > > 2. If that does not solve your problem, update to latest Oak (currently
> > > 1.22.0). If that does not work for you, let me know and we'll figure it
> > > out.
> > > 3. If that still does not work, you probably should ask in the
> > > Jackrabbit project.
> > >
> > > How does that sound?
> > >
> > > Thanks,
> > > Robert
> > >
> > >
> > > [1]: https://github.com/apache/sling-org-apache-sling-starter
> > > [2]:
> > >
> https://github.com/apache/sling-org-apache-sling-starter/commit/c4f6e3b
> > > >
> > > > Regards,
> > > >
> > > > Carlos
> > > >
> > > >
> > > > On Wed, Jan 22, 2020 at 4:47 AM Robert Munteanu 
> > > > wrote:
> > > >
> > > > > Hi Carlos,
> > > > >
> > > > > On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> > > > > > Hi,
> > > > > >
> > > > > > My team is using Sling for an internal application and we've run
> > > > > > into
> > > > > > a
> > > > > > couple of unexpected scenarios:
> > > > > >
> > > > > > 1. When modifying the nodetypes.cnd file included with our bundle
> > > > > > (e.g.
> > > > > > adding a new node type), the application queries seem to stop
> > > > > > working. This
> > > > > > only happens when the queries use the following form: "select *
> > > > > > from
> > > > > > [custom:type] ..." and not when using something like "select *
> > > > > > from
> > > > > > [nt:base] where [jcr:primaryType] = 'custom:type'"
> > > > > >
> > > > > > 2. There is a specific query which runs very slowly only the
> > > > > > first
> > > > > > time it
> > > > > > is executed. Once it is executed that one time it runs
> > > > > > considerably
> > > > > > faster
> > > > > > on subsequent runs.
> > > > >
> > > > > These both look like Jackrabbit/Oak issues, so first let me ask you
> > > > > which version of Jackrabbit/Jackrabbit Oak are you using?
> > > > >
> > > > > Thanks,
> > > > > Robert
> > > > >
> > > > > > I was wondering if the Sling community would be able to shed some
> > > > > > light on
> > > > > > some possible causes to these two scenarios.
> > > > > >
> > > > > > Thanks in advance!
> > >
> > >
> >
>


Re: [VOTE] Release Apache Sling Service User Mapper 1.4.6

2020-01-22 Thread davidb
+1

David

On Wed, 22 Jan 2020 at 12:45, Karl Pauls  wrote:

> We solved 1 issues in this release:
> https://issues.apache.org/jira/projects/SLING/versions/12344584
>
> Staging repository:
> https://repository.apache.org/content/repositories/orgapachesling-2186/
>
> You can use this UNIX script to download the release and verify the
> signatures:
>
> https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD
>
> Usage:
> sh check_staged_release.sh 2186 /tmp/sling-staging
>
> Please vote to approve this release:
>
>   [ ] +1 Approve the release
>   [ ]  0 Don't care
>   [ ] -1 Don't release, because ...
>


RE: [VOTE] Release Apache Sling Service User Mapper 1.4.6

2020-01-22 Thread Stefan Seifert
+1



Re: Slow queries and unexpected results

2020-01-22 Thread Daniel Klco
You can also try using the explain keyword to get introspection into how
the JCR repository is planning to execute the query which may identify any
traversal or index issues:
https://jackrabbit.apache.org/oak/docs/query/grammar-sql2.html#explain


On Wed, Jan 22, 2020 at 12:06 PM Carlos Munoz  wrote:

> Thanks heaps Robert, sounds like way more than I was expecting :)
>
> I'll try these things and let you know how it goes.
>
>
>
> On Wed, Jan 22, 2020 at 9:31 AM Robert Munteanu 
> wrote:
>
> > Hi Carlos,
> >
> > On Wed, 2020-01-22 at 07:11 -0500, Carlos Munoz wrote:
> > > Thanks for the reply Robert. We are using the latest Sling release
> > > (11) and
> > > its corresponding bundle versions, so that would make it oak 1.8.8.
> > >
> > > We could proably be using more updated bundles, but without a stable
> > > release or tag we're not sure how to gauge whether a set of bundles
> > > is
> > > stable enough.
> >
> > Latest released bundles as found in the current sling starter [1]
> > should be stable. You could try and update to a later Oak, we have
> > validated that Oak 1.16.0 works fine, see commit [2] for details.
> >
> > I would suggest the following:
> >
> > 1. Try and update to Oak 1.16.0, following commit [2] .
> > 2. If that does not solve your problem, update to latest Oak (currently
> > 1.22.0). If that does not work for you, let me know and we'll figure it
> > out.
> > 3. If that still does not work, you probably should ask in the
> > Jackrabbit project.
> >
> > How does that sound?
> >
> > Thanks,
> > Robert
> >
> >
> > [1]: https://github.com/apache/sling-org-apache-sling-starter
> > [2]:
> > https://github.com/apache/sling-org-apache-sling-starter/commit/c4f6e3b
> > >
> > > Regards,
> > >
> > > Carlos
> > >
> > >
> > > On Wed, Jan 22, 2020 at 4:47 AM Robert Munteanu 
> > > wrote:
> > >
> > > > Hi Carlos,
> > > >
> > > > On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> > > > > Hi,
> > > > >
> > > > > My team is using Sling for an internal application and we've run
> > > > > into
> > > > > a
> > > > > couple of unexpected scenarios:
> > > > >
> > > > > 1. When modifying the nodetypes.cnd file included with our bundle
> > > > > (e.g.
> > > > > adding a new node type), the application queries seem to stop
> > > > > working. This
> > > > > only happens when the queries use the following form: "select *
> > > > > from
> > > > > [custom:type] ..." and not when using something like "select *
> > > > > from
> > > > > [nt:base] where [jcr:primaryType] = 'custom:type'"
> > > > >
> > > > > 2. There is a specific query which runs very slowly only the
> > > > > first
> > > > > time it
> > > > > is executed. Once it is executed that one time it runs
> > > > > considerably
> > > > > faster
> > > > > on subsequent runs.
> > > >
> > > > These both look like Jackrabbit/Oak issues, so first let me ask you
> > > > which version of Jackrabbit/Jackrabbit Oak are you using?
> > > >
> > > > Thanks,
> > > > Robert
> > > >
> > > > > I was wondering if the Sling community would be able to shed some
> > > > > light on
> > > > > some possible causes to these two scenarios.
> > > > >
> > > > > Thanks in advance!
> >
> >
>


Re: Slow queries and unexpected results

2020-01-22 Thread Carlos Munoz
Thanks heaps Robert, sounds like way more than I was expecting :)

I'll try these things and let you know how it goes.



On Wed, Jan 22, 2020 at 9:31 AM Robert Munteanu  wrote:

> Hi Carlos,
>
> On Wed, 2020-01-22 at 07:11 -0500, Carlos Munoz wrote:
> > Thanks for the reply Robert. We are using the latest Sling release
> > (11) and
> > its corresponding bundle versions, so that would make it oak 1.8.8.
> >
> > We could proably be using more updated bundles, but without a stable
> > release or tag we're not sure how to gauge whether a set of bundles
> > is
> > stable enough.
>
> Latest released bundles as found in the current sling starter [1]
> should be stable. You could try and update to a later Oak, we have
> validated that Oak 1.16.0 works fine, see commit [2] for details.
>
> I would suggest the following:
>
> 1. Try and update to Oak 1.16.0, following commit [2] .
> 2. If that does not solve your problem, update to latest Oak (currently
> 1.22.0). If that does not work for you, let me know and we'll figure it
> out.
> 3. If that still does not work, you probably should ask in the
> Jackrabbit project.
>
> How does that sound?
>
> Thanks,
> Robert
>
>
> [1]: https://github.com/apache/sling-org-apache-sling-starter
> [2]:
> https://github.com/apache/sling-org-apache-sling-starter/commit/c4f6e3b
> >
> > Regards,
> >
> > Carlos
> >
> >
> > On Wed, Jan 22, 2020 at 4:47 AM Robert Munteanu 
> > wrote:
> >
> > > Hi Carlos,
> > >
> > > On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> > > > Hi,
> > > >
> > > > My team is using Sling for an internal application and we've run
> > > > into
> > > > a
> > > > couple of unexpected scenarios:
> > > >
> > > > 1. When modifying the nodetypes.cnd file included with our bundle
> > > > (e.g.
> > > > adding a new node type), the application queries seem to stop
> > > > working. This
> > > > only happens when the queries use the following form: "select *
> > > > from
> > > > [custom:type] ..." and not when using something like "select *
> > > > from
> > > > [nt:base] where [jcr:primaryType] = 'custom:type'"
> > > >
> > > > 2. There is a specific query which runs very slowly only the
> > > > first
> > > > time it
> > > > is executed. Once it is executed that one time it runs
> > > > considerably
> > > > faster
> > > > on subsequent runs.
> > >
> > > These both look like Jackrabbit/Oak issues, so first let me ask you
> > > which version of Jackrabbit/Jackrabbit Oak are you using?
> > >
> > > Thanks,
> > > Robert
> > >
> > > > I was wondering if the Sling community would be able to shed some
> > > > light on
> > > > some possible causes to these two scenarios.
> > > >
> > > > Thanks in advance!
>
>


[jira] [Created] (SLING-9020) JournalAvailableChecker should consider the journal as unavailable after 1 error

2020-01-22 Thread Timothee Maret (Jira)
Timothee Maret created SLING-9020:
-

 Summary: JournalAvailableChecker should consider the journal as 
unavailable after 1 error
 Key: SLING-9020
 URL: https://issues.apache.org/jira/browse/SLING-9020
 Project: Sling
  Issue Type: Bug
  Components: Content Distribution
Affects Versions: Content Distribution Journal Core 0.1.6
Reporter: Timothee Maret
 Fix For: Content Distribution Journal Core 0.1.8


Currently the JournalAvailableChecker waits 2 errors before considering the 
journal to be unavailable. There are some cases, however, were a single error 
will be thrown. An example is an error thrown from an agent 
DistributionSubscriber activate method. In this example, the agent fails to 
activate and the availability checker fails to turn the agent off/on.

Retries should be moved in the messaging implementation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Resolved] (SLING-9019) The XSSFilter will mark URLs containing both escaped characters and HTML entities as invalid

2020-01-22 Thread Radu Cotescu (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-9019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Radu Cotescu resolved SLING-9019.
-
Resolution: Fixed

Fixed in [commit 
f8f046b|https://github.com/apache/sling-org-apache-sling-xss/commit/f8f046b].

> The XSSFilter will mark URLs containing both escaped characters and HTML 
> entities as invalid
> 
>
> Key: SLING-9019
> URL: https://issues.apache.org/jira/browse/SLING-9019
> Project: Sling
>  Issue Type: Bug
>  Components: XSS Protection API
>Affects Versions: XSS Protection API 2.0.4
>Reporter: Radu Cotescu
>Assignee: Radu Cotescu
>Priority: Major
> Fix For: XSS Protection API 2.2.0
>
>
> A URL similar to {{http://localhost/?q=a+br=1}} will be marked as 
> invalid by the {{XSSFilterImpl}} implementation. However, the URL provided is 
> valid and should not be filtered.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


Re: [VOTE] Release Apache Sling Service User Mapper 1.4.6

2020-01-22 Thread Carsten Ziegeler

+1

Carsten

On 22.01.2020 13:45, Karl Pauls wrote:

We solved 1 issues in this release:
https://issues.apache.org/jira/projects/SLING/versions/12344584

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2186/

You can use this UNIX script to download the release and verify the signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2186 /tmp/sling-staging

Please vote to approve this release:

   [ ] +1 Approve the release
   [ ]  0 Don't care
   [ ] -1 Don't release, because ...



--
--
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org


[jira] [Created] (SLING-9019) The XSSFilter will mark URLs containing both escaped characters and HTML entities as invalid

2020-01-22 Thread Radu Cotescu (Jira)
Radu Cotescu created SLING-9019:
---

 Summary: The XSSFilter will mark URLs containing both escaped 
characters and HTML entities as invalid
 Key: SLING-9019
 URL: https://issues.apache.org/jira/browse/SLING-9019
 Project: Sling
  Issue Type: Bug
  Components: XSS Protection API
Affects Versions: XSS Protection API 2.0.4
Reporter: Radu Cotescu
Assignee: Radu Cotescu
 Fix For: XSS Protection API 2.2.0


A URL similar to {{http://localhost/?q=a+br=1}} will be marked as invalid 
by the {{XSSFilterImpl}} implementation. However, the URL provided is valid and 
should not be filtered.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


Re: Slow queries and unexpected results

2020-01-22 Thread Robert Munteanu
Hi Carlos,

On Wed, 2020-01-22 at 07:11 -0500, Carlos Munoz wrote:
> Thanks for the reply Robert. We are using the latest Sling release
> (11) and
> its corresponding bundle versions, so that would make it oak 1.8.8.
> 
> We could proably be using more updated bundles, but without a stable
> release or tag we're not sure how to gauge whether a set of bundles
> is
> stable enough.

Latest released bundles as found in the current sling starter [1]
should be stable. You could try and update to a later Oak, we have
validated that Oak 1.16.0 works fine, see commit [2] for details.

I would suggest the following:

1. Try and update to Oak 1.16.0, following commit [2] .
2. If that does not solve your problem, update to latest Oak (currently
1.22.0). If that does not work for you, let me know and we'll figure it
out.
3. If that still does not work, you probably should ask in the
Jackrabbit project.

How does that sound?

Thanks,
Robert


[1]: https://github.com/apache/sling-org-apache-sling-starter
[2]: https://github.com/apache/sling-org-apache-sling-starter/commit/c4f6e3b
> 
> Regards,
> 
> Carlos
> 
> 
> On Wed, Jan 22, 2020 at 4:47 AM Robert Munteanu 
> wrote:
> 
> > Hi Carlos,
> > 
> > On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> > > Hi,
> > > 
> > > My team is using Sling for an internal application and we've run
> > > into
> > > a
> > > couple of unexpected scenarios:
> > > 
> > > 1. When modifying the nodetypes.cnd file included with our bundle
> > > (e.g.
> > > adding a new node type), the application queries seem to stop
> > > working. This
> > > only happens when the queries use the following form: "select *
> > > from
> > > [custom:type] ..." and not when using something like "select *
> > > from
> > > [nt:base] where [jcr:primaryType] = 'custom:type'"
> > > 
> > > 2. There is a specific query which runs very slowly only the
> > > first
> > > time it
> > > is executed. Once it is executed that one time it runs
> > > considerably
> > > faster
> > > on subsequent runs.
> > 
> > These both look like Jackrabbit/Oak issues, so first let me ask you
> > which version of Jackrabbit/Jackrabbit Oak are you using?
> > 
> > Thanks,
> > Robert
> > 
> > > I was wondering if the Sling community would be able to shed some
> > > light on
> > > some possible causes to these two scenarios.
> > > 
> > > Thanks in advance!



Re: [VOTE] Release Apache Sling Service User Mapper 1.4.6

2020-01-22 Thread Radu Cotescu
+1

> On 22 Jan 2020, at 13:45, Karl Pauls  wrote:
> 
> Please vote to approve this release:
> 
>  [ ] +1 Approve the release
>  [ ]  0 Don't care
>  [ ] -1 Don't release, because ...



[jira] [Commented] (SLING-8757) Add option to set/edit access control policies at user homes

2020-01-22 Thread Angela Schreiber (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-8757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17021021#comment-17021021
 ] 

Angela Schreiber commented on SLING-8757:
-

[~bdelacretaz], my patches are ready for being reviewed an possibly merged. 
since the were built on top of your patch for the parser, i didn't want to 
create a pull request as the parser changes probably needed to go first (note 
though that i additionally added constants to the repoinit-parser module). i 
for sure won't have time this week, so feel free to pick up my patch...

> Add option to set/edit access control policies at user homes
> 
>
> Key: SLING-8757
> URL: https://issues.apache.org/jira/browse/SLING-8757
> Project: Sling
>  Issue Type: Improvement
>  Components: Repoinit
>Reporter: Angela Schreiber
>Priority: Major
> Fix For: Repoinit JCR 1.1.18, Repoinit Parser 1.3.4
>
>
> [~rombert], while looking into moving all service user creation and 
> permission setup from content packages to repo init, i noticed that there is 
> one special case that doesn't seem to be covered by repo init but possible 
> with Jackrabbit content packages: creating/editing access control policies at 
> a user home. the path of those is an implementation detail and cannot be 
> 'guessed'.
> based on my previous work on the repo-init grammar, i could envision the 
> following main options to include this functionality.
> # explicitly extend the 'path-token' which is currently defined to be 
> {{(PATH_STRING> | t = )}} to something like {{(PATH_STRING> 
> | t =  | )}}.
> # similar to the first one: but don't touch the grammar just extend the 
> jcr-implementation: if 'path' is a relative path and is not _repository_, 
> treat it as userId and try to obtain a path from the corresponding user 
> object.
> # completely separate it from the 'pathList' and don't allow a combination of 
> absolute paths, repository-marker and userIds, explicitly include the notion 
> that the edited policy is not bound to a regular path but to a user home 
> instead of {{on /abspath, repository}} it then would e.g. say {{on user id1, 
> id2}}
> without having looked into it in great detail and given the fact that there 
> are already so many different ways to edit access control content with 
> repo-init, the first option would feel the most natural to me. 
> wdyt? i could try to come up with a patch/tests/docu, but i would love to 
> avoid investing a lot of time and then have to throw it away or redo it all 
> over again.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[VOTE] Release Apache Sling Service User Mapper 1.4.6

2020-01-22 Thread Karl Pauls
We solved 1 issues in this release:
https://issues.apache.org/jira/projects/SLING/versions/12344584

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2186/

You can use this UNIX script to download the release and verify the signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2186 /tmp/sling-staging

Please vote to approve this release:

  [ ] +1 Approve the release
  [ ]  0 Don't care
  [ ] -1 Don't release, because ...


Re: Slow queries and unexpected results

2020-01-22 Thread Carlos Munoz
Thanks for the reply Robert. We are using the latest Sling release (11) and
its corresponding bundle versions, so that would make it oak 1.8.8.

We could proably be using more updated bundles, but without a stable
release or tag we're not sure how to gauge whether a set of bundles is
stable enough.

Regards,

Carlos


On Wed, Jan 22, 2020 at 4:47 AM Robert Munteanu  wrote:

> Hi Carlos,
>
> On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> > Hi,
> >
> > My team is using Sling for an internal application and we've run into
> > a
> > couple of unexpected scenarios:
> >
> > 1. When modifying the nodetypes.cnd file included with our bundle
> > (e.g.
> > adding a new node type), the application queries seem to stop
> > working. This
> > only happens when the queries use the following form: "select * from
> > [custom:type] ..." and not when using something like "select * from
> > [nt:base] where [jcr:primaryType] = 'custom:type'"
> >
> > 2. There is a specific query which runs very slowly only the first
> > time it
> > is executed. Once it is executed that one time it runs considerably
> > faster
> > on subsequent runs.
>
> These both look like Jackrabbit/Oak issues, so first let me ask you
> which version of Jackrabbit/Jackrabbit Oak are you using?
>
> Thanks,
> Robert
>
> >
> > I was wondering if the Sling community would be able to shed some
> > light on
> > some possible causes to these two scenarios.
> >
> > Thanks in advance!
>
>


[jira] [Commented] (SLING-8986) osgi-mock: Incorrect selection of fields with assignable types for Set references

2020-01-22 Thread Robert Munteanu (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-8986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17020932#comment-17020932
 ] 

Robert Munteanu commented on SLING-8986:


Thanks for the fix, [~sseifert]!

> osgi-mock: Incorrect selection of fields with assignable types for Set 
> references
> -
>
> Key: SLING-8986
> URL: https://issues.apache.org/jira/browse/SLING-8986
> Project: Sling
>  Issue Type: Bug
>  Components: Testing
>Affects Versions: Testing OSGi Mock 2.4.10
>Reporter: Robert Munteanu
>Assignee: Stefan Seifert
>Priority: Major
> Fix For: Testing OSGi Mock 2.4.12
>
>
> When trying to inject references to fields that are of type collection, the 
> injection fails, due to the following {{isAssignableFrom}} check in the code 
> below:
> {noformat}
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
>  return field;
>  }
>  }
> }
> {noformat}
> The {{type}} parameter is always Collection.class, and the 
> {{field.getType()}} is a subclass of Collection, such as Set or List. The 
> problem is that the check is inverted, e.g. 
> {{Set.class.isAssignableFrom(Collection.class)}} is false, whereas 
> {{Collection.class.isAssignableFrom(Set.class)}} is true. The least specific 
> class type should be first, opposite of the {{instanceof}} check ( I always 
> find this confusing ).
> I have prepared a simple patch, but unfortunately the build fails with 
> {{MockBundleContextDynamicReferencesOsgiR6Test.testReferenceWithDynamicTargetFilter:172->assertDependencies3DynamicFiltered:209
>  expected: but was:}}.
> I am not familiar enough with the codebase to understand whether I should 
> update the test or try and find out what breaks.
> The patch I tried is:
> {noformat}diff --git 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> index 8726f9d..71b7e9a 100644
> --- 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> +++ 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> @@ -340,7 +340,7 @@ final class OsgiServiceUtil {
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> -if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
> +if (StringUtils.equals(field.getName(), fieldName) && 
> type.isAssignableFrom(field.getType())) {
>  return field;
>  }
>  }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Resolved] (SLING-8986) osgi-mock: Incorrect selection of fields with assignable types for Set references

2020-01-22 Thread Stefan Seifert (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-8986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Seifert resolved SLING-8986.
---
Fix Version/s: Testing OSGi Mock 2.4.12
   Resolution: Fixed

fixed: 
https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/commit/f5e384846ff35f2aa697990f53f255a3d9142ccf

> osgi-mock: Incorrect selection of fields with assignable types for Set 
> references
> -
>
> Key: SLING-8986
> URL: https://issues.apache.org/jira/browse/SLING-8986
> Project: Sling
>  Issue Type: Bug
>  Components: Testing
>Affects Versions: Testing OSGi Mock 2.4.10
>Reporter: Robert Munteanu
>Assignee: Stefan Seifert
>Priority: Major
> Fix For: Testing OSGi Mock 2.4.12
>
>
> When trying to inject references to fields that are of type collection, the 
> injection fails, due to the following {{isAssignableFrom}} check in the code 
> below:
> {noformat}
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
>  return field;
>  }
>  }
> }
> {noformat}
> The {{type}} parameter is always Collection.class, and the 
> {{field.getType()}} is a subclass of Collection, such as Set or List. The 
> problem is that the check is inverted, e.g. 
> {{Set.class.isAssignableFrom(Collection.class)}} is false, whereas 
> {{Collection.class.isAssignableFrom(Set.class)}} is true. The least specific 
> class type should be first, opposite of the {{instanceof}} check ( I always 
> find this confusing ).
> I have prepared a simple patch, but unfortunately the build fails with 
> {{MockBundleContextDynamicReferencesOsgiR6Test.testReferenceWithDynamicTargetFilter:172->assertDependencies3DynamicFiltered:209
>  expected: but was:}}.
> I am not familiar enough with the codebase to understand whether I should 
> update the test or try and find out what breaks.
> The patch I tried is:
> {noformat}diff --git 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> index 8726f9d..71b7e9a 100644
> --- 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> +++ 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> @@ -340,7 +340,7 @@ final class OsgiServiceUtil {
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> -if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
> +if (StringUtils.equals(field.getName(), fieldName) && 
> type.isAssignableFrom(field.getType())) {
>  return field;
>  }
>  }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (SLING-8986) osgi-mock: Incorrect selection of fields with assignable types for Set references

2020-01-22 Thread Stefan Seifert (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-8986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Seifert updated SLING-8986:
--
Summary: osgi-mock: Incorrect selection of fields with assignable types for 
Set references  (was: Incorrect selection of fields with assignable types for 
collection references)

this problem is specific to Set (or to be more precise non-Collection and 
non-List field types). the implementation assumed only Collection and List 
needs to be supported.

> osgi-mock: Incorrect selection of fields with assignable types for Set 
> references
> -
>
> Key: SLING-8986
> URL: https://issues.apache.org/jira/browse/SLING-8986
> Project: Sling
>  Issue Type: Bug
>  Components: Testing
>Affects Versions: Testing OSGi Mock 2.4.10
>Reporter: Robert Munteanu
>Assignee: Stefan Seifert
>Priority: Major
>
> When trying to inject references to fields that are of type collection, the 
> injection fails, due to the following {{isAssignableFrom}} check in the code 
> below:
> {noformat}
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
>  return field;
>  }
>  }
> }
> {noformat}
> The {{type}} parameter is always Collection.class, and the 
> {{field.getType()}} is a subclass of Collection, such as Set or List. The 
> problem is that the check is inverted, e.g. 
> {{Set.class.isAssignableFrom(Collection.class)}} is false, whereas 
> {{Collection.class.isAssignableFrom(Set.class)}} is true. The least specific 
> class type should be first, opposite of the {{instanceof}} check ( I always 
> find this confusing ).
> I have prepared a simple patch, but unfortunately the build fails with 
> {{MockBundleContextDynamicReferencesOsgiR6Test.testReferenceWithDynamicTargetFilter:172->assertDependencies3DynamicFiltered:209
>  expected: but was:}}.
> I am not familiar enough with the codebase to understand whether I should 
> update the test or try and find out what breaks.
> The patch I tried is:
> {noformat}diff --git 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> index 8726f9d..71b7e9a 100644
> --- 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> +++ 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> @@ -340,7 +340,7 @@ final class OsgiServiceUtil {
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> -if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
> +if (StringUtils.equals(field.getName(), fieldName) && 
> type.isAssignableFrom(field.getType())) {
>  return field;
>  }
>  }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


Re: Slow queries and unexpected results

2020-01-22 Thread Robert Munteanu
Hi Carlos,

On Tue, 2020-01-21 at 22:31 -0500, Carlos Munoz wrote:
> Hi,
> 
> My team is using Sling for an internal application and we've run into
> a
> couple of unexpected scenarios:
> 
> 1. When modifying the nodetypes.cnd file included with our bundle
> (e.g.
> adding a new node type), the application queries seem to stop
> working. This
> only happens when the queries use the following form: "select * from
> [custom:type] ..." and not when using something like "select * from
> [nt:base] where [jcr:primaryType] = 'custom:type'"
> 
> 2. There is a specific query which runs very slowly only the first
> time it
> is executed. Once it is executed that one time it runs considerably
> faster
> on subsequent runs.

These both look like Jackrabbit/Oak issues, so first let me ask you
which version of Jackrabbit/Jackrabbit Oak are you using?

Thanks,
Robert

> 
> I was wondering if the Sling community would be able to shed some
> light on
> some possible causes to these two scenarios.
> 
> Thanks in advance!



[jira] [Assigned] (SLING-8986) Incorrect selection of fields with assignable types for collection references

2020-01-22 Thread Stefan Seifert (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-8986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Seifert reassigned SLING-8986:
-

Assignee: Stefan Seifert

> Incorrect selection of fields with assignable types for collection references
> -
>
> Key: SLING-8986
> URL: https://issues.apache.org/jira/browse/SLING-8986
> Project: Sling
>  Issue Type: Bug
>  Components: Testing
>Affects Versions: Testing OSGi Mock 2.4.10
>Reporter: Robert Munteanu
>Assignee: Stefan Seifert
>Priority: Major
>
> When trying to inject references to fields that are of type collection, the 
> injection fails, due to the following {{isAssignableFrom}} check in the code 
> below:
> {noformat}
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
>  return field;
>  }
>  }
> }
> {noformat}
> The {{type}} parameter is always Collection.class, and the 
> {{field.getType()}} is a subclass of Collection, such as Set or List. The 
> problem is that the check is inverted, e.g. 
> {{Set.class.isAssignableFrom(Collection.class)}} is false, whereas 
> {{Collection.class.isAssignableFrom(Set.class)}} is true. The least specific 
> class type should be first, opposite of the {{instanceof}} check ( I always 
> find this confusing ).
> I have prepared a simple patch, but unfortunately the build fails with 
> {{MockBundleContextDynamicReferencesOsgiR6Test.testReferenceWithDynamicTargetFilter:172->assertDependencies3DynamicFiltered:209
>  expected: but was:}}.
> I am not familiar enough with the codebase to understand whether I should 
> update the test or try and find out what breaks.
> The patch I tried is:
> {noformat}diff --git 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> index 8726f9d..71b7e9a 100644
> --- 
> a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> +++ 
> b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
> @@ -340,7 +340,7 @@ final class OsgiServiceUtil {
>  private static Field getFieldWithAssignableType(Class clazz, String 
> fieldName, Class type) {
>  Field[] fields = clazz.getDeclaredFields();
>  for (Field field : fields) {
> -if (StringUtils.equals(field.getName(), fieldName) && 
> field.getType().isAssignableFrom(type)) {
> +if (StringUtils.equals(field.getName(), fieldName) && 
> type.isAssignableFrom(field.getType())) {
>  return field;
>  }
>  }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


Re: [VOTE] Promote sling-org-apache-sling-feature-starter / sling-slingstart-feature-maven-plugin to its own Sling Module

2020-01-22 Thread Bertrand Delacretaz
Hi,

On Tue, Jan 21, 2020 at 5:54 PM Carsten Ziegeler  wrote:
>
> So it seems you are suggestion, that if someone wants to build a Sling
> application, you clone/fork the feature-starter project, add your own
> feature models and build the project, right?...

FWIW this sounds like how someone would use a Maven archetype.

-Bertrand