Re: Sling integration with OpenTelemetry

2023-09-14 Thread Roy Teeuwen
Wow very nice Robert :)! I was on holiday for the last week so I sadly didn't 
have time yet to look into updating Sling Metrics to OpenTelemetry

Will definitely check it out

Greets,
Roy

> On 14 Sep 2023, at 16:52, Robert Munteanu  wrote:
> 
> Hi,
> 
> If you're using OpenTelemetry with your Sling apps (or plan to) you
> might want to look at an initial PR I created for OpenTelemetry to
> gather better traces for Sling apps.
> 
> https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/9469
> 
> Thanks,
> Robert



Re: JCR FileVault Install Hook - Load order

2023-01-30 Thread Roy Teeuwen
OK, the hard part is of course that the framework package i'm talking about is 
a third-party framework (in my case it is the accesscontroltool which provides 
a hook to trigger installation of acl rules), so I'd have to see if we can get 
it added in the third party framework.

Will already start with a fork of the repo and see if I can get it working with 
the situation you specify.

Thanks,
Roy

> On 29 Jan 2023, at 20:27, Konrad Windszus  wrote:
> 
> This can be expressed with the combination of
> a) package dependencies (package-with-install-hook needs to depend on the 
> package containing the bundle with the hook class)
> b) the package containing the bundle with the hook class needs to leverage 
> https://sling.apache.org/documentation/bundles/installer-provider-installhook.html
>  
> <https://sling.apache.org/documentation/bundles/installer-provider-installhook.html>
>  in order to deploy the bundle synchronously with the package installation.
> 
> That way the correct order is enforced.
> You need to specify the bundle path because that is actually used to figure 
> out the input stream to provide to the OSGi installer.
> 
> Konrad
> 
>> On 29. Jan 2023, at 10:36, Roy Teeuwen  wrote:
>> 
>> And to make things even more complicated, the package actually looks like:
>> 
>> 
>> - all
>>  - framework
>>  - framework-with-bundle
>>  - package-with-install-hook (dependant on framework-with-bundle)
>> 
>> So I tried to add the installPathRegex on the root 'all' package with as 
>> regex the path that is defined where the bundle from the framework would be 
>> installed, but this doesn't seem to fix anything
>> 
>> 
>>> On 29 Jan 2023, at 09:42, Roy Teeuwen  wrote:
>>> 
>>> I also doubted between Sling and Jackrabbit, but seeing as it is 
>>> specifically an issue when using OSGi where all classes are not available 
>>> yet, I decided to register it here.
>>> 
>>> I also found the following after posting the question, 
>>> https://sling.apache.org/documentation/bundles/installer-provider-installhook.html,
>>>  which sort of seemed to cover my use-case. Just wondering on how to 
>>> properly set the configuration. Having an install path regex seems a bit 
>>> brittle, instead of being able to specify things like bundle symbolic name 
>>> or something instead. I also have the feeling that I'd rather set the 
>>> dependency explicitly on the "package-with-install-hook" instead of setting 
>>> something on the "all" package
>>> 
>>> Roy
>>> 
>>>> On 27 Jan 2023, at 19:18, Konrad Windszus  wrote:
>>>> 
>>>> This is more a topic for Jackrabbit than for Sling. It is already tracked 
>>>> in https://issues.apache.org/jira/plugins/servlet/mobile#issue/JCRVLT-195 
>>>> but not yet implemented. Maybe you want to come up with a PR for that?
>>>> 
>>>> Konrad 
>>>> 
>>>>> Am 27.01.2023 um 09:56 schrieb Roy Teeuwen :
>>>>> 
>>>>> Hey,
>>>>> 
>>>>> We are using an install hook to trigger a migration of some sort after 
>>>>> the content package is installed. We have one specific issue with this, 
>>>>> namely that if have a fresh environment, the installhook main class might 
>>>>> not be available yet. Is there a way we can easily fix this?
>>>>> 
>>>>> The content package:
>>>>> 
>>>>> - all
>>>>> - package-with-bundle
>>>>> - package-with-install-hook
>>>>> 
>>>>> We can set the dependency of package-with-install-hook on the 
>>>>> package-with-bundle, but it's not because the package-with-bundle is 
>>>>> installed first, that the bundle contained in the package is already 
>>>>> started up. So instead of setting a dependency on a package being 
>>>>> installed, I'd like to set a dependency on a bundle being active. Is 
>>>>> there any way to achieve this?
>>>>> 
>>>>> Greets,
>>>>> Roy
>>>>> 
>>>>> 
>>> 
>> 
> 



Re: JCR FileVault Install Hook - Load order

2023-01-29 Thread Roy Teeuwen
And to make things even more complicated, the package actually looks like:


- all
- framework
- framework-with-bundle
- package-with-install-hook (dependant on framework-with-bundle)

So I tried to add the installPathRegex on the root 'all' package with as regex 
the path that is defined where the bundle from the framework would be 
installed, but this doesn't seem to fix anything


> On 29 Jan 2023, at 09:42, Roy Teeuwen  wrote:
> 
> I also doubted between Sling and Jackrabbit, but seeing as it is specifically 
> an issue when using OSGi where all classes are not available yet, I decided 
> to register it here.
> 
> I also found the following after posting the question, 
> https://sling.apache.org/documentation/bundles/installer-provider-installhook.html,
>  which sort of seemed to cover my use-case. Just wondering on how to properly 
> set the configuration. Having an install path regex seems a bit brittle, 
> instead of being able to specify things like bundle symbolic name or 
> something instead. I also have the feeling that I'd rather set the dependency 
> explicitly on the "package-with-install-hook" instead of setting something on 
> the "all" package
> 
> Roy
> 
>> On 27 Jan 2023, at 19:18, Konrad Windszus  wrote:
>> 
>> This is more a topic for Jackrabbit than for Sling. It is already tracked in 
>> https://issues.apache.org/jira/plugins/servlet/mobile#issue/JCRVLT-195 but 
>> not yet implemented. Maybe you want to come up with a PR for that?
>> 
>> Konrad 
>> 
>>> Am 27.01.2023 um 09:56 schrieb Roy Teeuwen :
>>> 
>>> Hey,
>>> 
>>> We are using an install hook to trigger a migration of some sort after the 
>>> content package is installed. We have one specific issue with this, namely 
>>> that if have a fresh environment, the installhook main class might not be 
>>> available yet. Is there a way we can easily fix this?
>>> 
>>> The content package:
>>> 
>>> - all
>>>   - package-with-bundle
>>>   - package-with-install-hook
>>> 
>>> We can set the dependency of package-with-install-hook on the 
>>> package-with-bundle, but it's not because the package-with-bundle is 
>>> installed first, that the bundle contained in the package is already 
>>> started up. So instead of setting a dependency on a package being 
>>> installed, I'd like to set a dependency on a bundle being active. Is there 
>>> any way to achieve this?
>>> 
>>> Greets,
>>> Roy
>>> 
>>> 
> 



Re: JCR FileVault Install Hook - Load order

2023-01-29 Thread Roy Teeuwen
I also doubted between Sling and Jackrabbit, but seeing as it is specifically 
an issue when using OSGi where all classes are not available yet, I decided to 
register it here.

I also found the following after posting the question, 
https://sling.apache.org/documentation/bundles/installer-provider-installhook.html,
 which sort of seemed to cover my use-case. Just wondering on how to properly 
set the configuration. Having an install path regex seems a bit brittle, 
instead of being able to specify things like bundle symbolic name or something 
instead. I also have the feeling that I'd rather set the dependency explicitly 
on the "package-with-install-hook" instead of setting something on the "all" 
package

Roy

> On 27 Jan 2023, at 19:18, Konrad Windszus  wrote:
> 
> This is more a topic for Jackrabbit than for Sling. It is already tracked in 
> https://issues.apache.org/jira/plugins/servlet/mobile#issue/JCRVLT-195 but 
> not yet implemented. Maybe you want to come up with a PR for that?
> 
> Konrad 
> 
>> Am 27.01.2023 um 09:56 schrieb Roy Teeuwen :
>> 
>> Hey,
>> 
>> We are using an install hook to trigger a migration of some sort after the 
>> content package is installed. We have one specific issue with this, namely 
>> that if have a fresh environment, the installhook main class might not be 
>> available yet. Is there a way we can easily fix this?
>> 
>> The content package:
>> 
>> - all
>>   - package-with-bundle
>>   - package-with-install-hook
>> 
>> We can set the dependency of package-with-install-hook on the 
>> package-with-bundle, but it's not because the package-with-bundle is 
>> installed first, that the bundle contained in the package is already started 
>> up. So instead of setting a dependency on a package being installed, I'd 
>> like to set a dependency on a bundle being active. Is there any way to 
>> achieve this?
>> 
>> Greets,
>> Roy
>> 
>> 



JCR FileVault Install Hook - Load order

2023-01-27 Thread Roy Teeuwen
Hey,

We are using an install hook to trigger a migration of some sort after the 
content package is installed. We have one specific issue with this, namely that 
if have a fresh environment, the installhook main class might not be available 
yet. Is there a way we can easily fix this?

The content package:

- all
- package-with-bundle
- package-with-install-hook

We can set the dependency of package-with-install-hook on the 
package-with-bundle, but it's not because the package-with-bundle is installed 
first, that the bundle contained in the package is already started up. So 
instead of setting a dependency on a package being installed, I'd like to set a 
dependency on a bundle being active. Is there any way to achieve this?

Greets,
Roy




Re: [Question] API Regions Report

2021-12-06 Thread Roy Teeuwen
Wouldn't it be nice to build a web console interface for this? Looks very
cumbersome at the moment and after having talks with internal Adobe
customer support I can already tell you that even support doesn't know how
api regions work (I asked why a package was not exported in Global, and
they just showed me a screenshot of the package that it's between the
exported packages, but that doesn't mean anything anymore if its not in the
global api region)

Will think about how it should look like if I find the time

On Mon, Aug 23, 2021 at 2:02 PM Daniel Klco  wrote:

> There's a reason for that. :-) I revised the script following your email.
>
> Rev 1 used reflection to construct a new RegionConfiguration using the
> BundleContext.
>
> On Mon, Aug 23, 2021, 3:04 AM David Bosschaert  >
> wrote:
>
> > Hi Daniel,
> >
> > Only looked at your groovy script after I wrote the mail and I see that
> it
> > does pretty much exactly what I described :)
> > The RegionConfiguration class also allows dynamic changes to the
> > configuration which can be found via ConfigAdmin.
> >
> > Cheers,
> >
> > David
> >
> > On Sun, 22 Aug 2021 at 22:49, David Bosschaert <
> david.bosscha...@gmail.com>
> > wrote:
> >
> >> Hi Daniel,
> >>
> >> You can find the API Regions definitions via the ResolverHookFactory
> >> service that implements the API Regions at runtime. Just look for the
> >> ResolverHookFactory service and then check its *.properties service
> >> registration properties. They contain the full path of the associated
> files:
> >>
> >> [org.osgi.framework.hooks.resolver.ResolverHookFactory]
> >> bundles.properties=.../bundles.properties
> >> features.properties=.../features.properties
> >> idbsnver.properties=.../idbsnver.properties
> >> regions.properties=.../regions.properties
> >>
> >> These files are the definition of the API Regions behaviour, so you can
> >> use them to generate a report, or look at them to see how the service is
> >> configured.
> >>
> >> Kind regards,
> >>
> >> David
> >>
> >>
> >> On Sun, 22 Aug 2021 at 18:49, Daniel Klco  wrote:
> >>
> >>> All,
> >>>
> >>> Is there a way to see a report on the API regions for an instance as a
> >>> consumer / extender of Sling?
> >>>
> >>> It seems like all of the information you'd need is in the API Regions
> >>> Runtime RegionConfiguration[1] class, but that's not in an exposed
> >>> package.
> >>>
> >>> The case I'm thinking of is if you are a customizer of a Sling-based
> app
> >>> and are importing a package that was not exposed in the API region of
> >>> your
> >>> bundle, how would you diagnose why the package is not resolving even
> >>> though
> >>> it is exported? If you don't have direct access to the model used to
> >>> create
> >>> that app (or if you aren't familiar with reading model files), I can't
> >>> see
> >>> how you could diagnose the issue.
> >>>
> >>> I wrote up a groovy script to dump this configuration, but, it's more
> >>> than
> >>> a little hack-y:
> >>> https://gist.github.com/klcodanr/28385db0ce6df72be36a4f60b433a8ec
> >>>
> >>> If there's not a good way currently, would others see value in having a
> >>> status web console to dump this information?
> >>>
> >>> -Dan
> >>>
> >>> [1]
> >>>
> >>>
> https://github.com/apache/sling-org-apache-sling-feature-apiregions/blob/master/src/main/java/org/apache/sling/feature/apiregions/impl/RegionConfiguration.java
> >>>
> >>
>


Re: [mock] best way to mock http(s) endpoint

2020-12-01 Thread Roy Teeuwen
Yup, you can also get some inspiration from the aem-stubs from Cognifide:

https://github.com/Cognifide/aem-stubs 

Not sure if there is any actual dependency on AEM for that one



> On 1 Dec 2020, at 10:39, Bertrand Delacretaz  wrote:
> 
> Hi,
> 
> On Tue, Dec 1, 2020 at 10:24 AM Stefan Seifert  wrote:
>> ...maybe wiremock? it does real HTTP communication but neatly integrated in 
>> junit (i've not tried to use it with JUnit 5).
>> https://github.com/tomakehurst/wiremock ...
> 
> I've been using wiremock in Sling,
> https://github.com/apache/sling-org-apache-sling-junit-teleporter/blob/master/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
> and like it!
> 
> Note that that code is from 5 years ago, there's probably been
> improvements in the meantime.
> 
> -Bertrand



Getting SlingHttpServletRequest in a HTTP Whiteboard

2020-11-16 Thread Roy Teeuwen
Hey all,

I would like to retrieve the SlingHttpServletRequest in a filter that has been 
registered through the HTTP whiteboard instead of registering it with OSGi DS 
and implementing the Filter service interface. Is this possible?

The code of the registration of the filter:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/fe1d698b3012909597490690b4fbcd054a10f4fa/bundle/src/main/java/com/adobe/acs/commons/http/headers/impl/AbstractDispatcherCacheHeaderFilter.java#L180
 


I already tried to set the context to org.apache.sling instead of *, but still 
when I debug the code, the request you get in the doFilter is the I18n…Request

If this is not possible, how can you register a Filter programatically that its 
inside the SlingHttpServletRequest chain?

Greets,
Roy

Re: Sling Slack Channel

2020-04-21 Thread Roy Teeuwen
+1

> On 21 Apr 2020, at 18:57, Daniel Klco  wrote:
> 
> Chris,
> 
> I agree, I'd be 100% on board with a Slack channel for Sling. A couple
> thoughts:
> 
> - There is already a slack org for the ASF: the-asf.slack.com we could use
> rather than setting up another slack org
> - We probably should call a formal vote rather than asking for replies in
> this thread
> 
> Regards,
> Dan
> 
> 
> On Tue, Apr 21, 2020 at 12:07 PM Cris Rockwell  wrote:
> 
>> I’ve read thread [1] and have a few observations:
>> 
>> 1. It happened on the Sling Dev email list. Sling Dev has too many daily
>> emails. The context and substance of most messages are difficult to
>> understand unless you’re already fully entrenched. I unsubscribed pretty
>> quick. It is not the best platform for all collaboration across the project
>> community.
>> 
>> 2. To summarize the respondents of thread [1] every non-Adobe responder in
>> the thread wanted Slack. Adobe already has a company chat platform. More
>> collaboration across organizational boundaries would be a good thing for
>> the project.
>> 
>> 3. There was no vote. Why don’t we use the decision making process for
>> Apache Software Foundation projects [2]?
>> 
>> Let’s put it to a vote and let the Sling Users have a say. Respond with +1
>> if you want a Slack Workspace for the Sling Community. Of course use of
>> Slack is optional, so there is no need to vote against. Don’t join unless
>> you want to!
>> 
>> Cris Rockwell
>> Applications Architect Sr
>> College of Literature, Science, and the Arts | University of Michigan
>> LSA Technology Services | 301 E Liberty Suite 500 | Ann Arbor, MI 48104
>> Desk: 734.763.6818 | Email: cmroc...@umich.edu 
>> 
>> [2]:  https://www.apache.org/foundation/how-it-works.html#decision-making
>> 
>> 
>> 
>> 
>> 
>>> On Apr 20, 2020, at 4:04 AM, Robert Munteanu > > wrote:
>>> 
>>> Hi Cris,
>>> 
>>> On Sat, 2020-04-18 at 11:03 -0400, Cris Rockwell wrote:
 Hi Sling Users
 
 Is there a community chat platform like Slack or gitter for Sling
 users and developers?
>>> 
>>> Not at the moment. See also [1] where we had this discussion and
>>> eventually abandoned the idea.
>>> 
>>> Thanks,
>>> Robert
>>> 
>>> [1]:
>> https://lists.apache.org/thread.html/r19665a94cb17d9b7607eb9c5fe4c91cfa1df8eed55219f2db9b53f05%40%3Cdev.sling.apache.org%3E
>> <
>> https://lists.apache.org/thread.html/r19665a94cb17d9b7607eb9c5fe4c91cfa1df8eed55219f2db9b53f05%40%3Cdev.sling.apache.org%3E
>>> 
>>> 
 
 Cris
 
>>> 
>> 
>> 



Executing xpath query with number in path

2019-08-29 Thread Roy Teeuwen
Hey all,

In the framework that we use (AEM) there is a folder structure as following:

/content/launches/2019/08/29/my-launch/content/site-name

I would like to do a query to search for subresources in this site, but it 
seems that this gives issues because an xpath query cannot take numbers as path 
names:

/jcr:root/content/launches/2019(*)/08/29/my-launch/content/site-name//*[@sling:resourceType='some/components/path'];
 expected: jcr:root, /, *, @, (, .

Is there any way around this to still make it work with xpath queries? Can I 
escape it in any way? Or can I say "start the query below 
/content/launches/2019/08/29/my-launch/content/site-name so that it doesnt see 
the numbers in the query

Thanks!
Roy



Re: Multiple threads on same resource resolver

2019-03-28 Thread Roy Teeuwen
Hey guys,

Thanks for the replies.

In the getServiceResourceResolver I do actually call 
resourceResolverFactory.getServiceResourceResolver, making it a new resource 
resolver instance for every thread. so in my knowledge this does create a new 
session, but it's on the same user name?

Greets,
Roy

> On 28 Mar 2019, at 08:52, Michael Dürig  wrote:
> 
> 
> Hi,
> 
> Sorry for missing the original post on the Oak list.
> 
> Like Carsten said, sessions do not support multiple threads. See also 
> https://docs.adobe.com/docs/en/spec/jcr/2.0/4_Connecting.html
> 
> The warning you receive is from a protection mechanism in Oak that prevents 
> the worst. I.e. data corruption. However, there are no guarantees beyond 
> that. E.g. performance or even progress (no deadlocks).
> 
> Michael
> 
> 
> On 28.03.19 07:32, Carsten Ziegeler wrote:
>> Hi,
>> a resource resolver is single threaded and must not be used concurrently by 
>> multiple threads. Main driver (but not the only one) is the JCR session 
>> which requires this.
>> However, there is nothing in the Sling code base blocking you from doing so 
>> anyways. So we don't have any additional checks like Oak/Jackrabbit has. 
>> Therefore the log message you see, is initiated by Oak. I don't want to sent 
>> you from one list to another, but to my knowledge your latest code looks ok 
>> to me and I'm not aware that you can only have one thread for a service 
>> user. But maybe your getServiceResourceResolver method is always returning 
>> the same instance and not creating one per call? If not, I fear this is an 
>> issue for Oak.
>> Regards
>> Carsten
>> Roy Teeuwen wrote
>>> Hey sling users,
>>> 
>>> This is a repost from the userlist of oak because I didn't get a reply 
>>> there, so I hope I might get one here:
>>> 
>>> 
>>> We have a system that migrates our sites based on migration rules, the 
>>> psuedocode is as the following:
>>> 
>>> resourceResolver = getServiceResourceResolver("migration-user");
>>> for(Site site in sites) {
>>> migrateSite(resourceResolver)
>>> }
>>> 
>>> Everything works fine, but we would like it more performant, so the change 
>>> I did was the following:
>>> 
>>> resourceResolver = getServiceResourceResolver("migration-user");
>>> for(Site site in sites) {
>>> threadPool.submit(new Runnable() { run() {
>>> migrateSite(resourceResolver)
>>> });
>>> }
>>> 
>>> This gave the following exception:
>>> 
>>> 21.03.2019 11:32:47.244 *WARN* 
>>> [sling-threadpool-fb6dc0ad-6c32-47c1-9779-e8acba0ef747-(migration-service)-4]
>>>  org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate Attempted to 
>>> perform hasProperty while thread 
>>> sling-threadpool-fb6dc0ad-6c32-47c1-9779-e8acba0ef747-(migration-service)-2 
>>> was concurrently writing to this session. Blocked until the other thread 
>>> finished using this session. Please review your code to avoid concurrent 
>>> use of a session.
>>> 
>>> So I decided to change the code to the following:
>>> 
>>> for(Site site in sites) {
>>> threadPool.submit(new Runnable() { run() {
>>> resourceResolver = getServiceResourceResolver("migration-user");
>>> migrateSite(resourceResolver)
>>>  });
>>> }
>>> 
>>> But it seems that the warn that is being thrown is still being thrown, does 
>>> this mean that getting a new service resourceresolver based on the same 
>>> user name still get into lockings / synchronizing issues? Is there any way 
>>> to solve this?
>>> 
>>> Thanks,
>>> Roy
>>> 
>> -- 
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziege...@apache.org



Multiple threads on same resource resolver

2019-03-27 Thread Roy Teeuwen
Hey sling users,

This is a repost from the userlist of oak because I didn't get a reply there, 
so I hope I might get one here:


We have a system that migrates our sites based on migration rules, the 
psuedocode is as the following:

resourceResolver = getServiceResourceResolver("migration-user");
for(Site site in sites) {
migrateSite(resourceResolver)
}

Everything works fine, but we would like it more performant, so the change I 
did was the following:

resourceResolver = getServiceResourceResolver("migration-user");
for(Site site in sites) {
threadPool.submit(new Runnable() { run() { 
migrateSite(resourceResolver)
});
}

This gave the following exception:

21.03.2019 11:32:47.244 *WARN* 
[sling-threadpool-fb6dc0ad-6c32-47c1-9779-e8acba0ef747-(migration-service)-4] 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate Attempted to perform 
hasProperty while thread 
sling-threadpool-fb6dc0ad-6c32-47c1-9779-e8acba0ef747-(migration-service)-2 was 
concurrently writing to this session. Blocked until the other thread finished 
using this session. Please review your code to avoid concurrent use of a 
session.

So I decided to change the code to the following:

for(Site site in sites) {
threadPool.submit(new Runnable() { run() { 
resourceResolver = getServiceResourceResolver("migration-user");
migrateSite(resourceResolver)
 });
}

But it seems that the warn that is being thrown is still being thrown, does 
this mean that getting a new service resourceresolver based on the same user 
name still get into lockings / synchronizing issues? Is there any way to solve 
this? 

Thanks,
Roy

Removing zips from install folder

2018-08-23 Thread Roy Teeuwen
Hey guys,

We previously installed content packages by adding them to the 
sling-home/install folder, enabling the osgi installer to pick them up and 
install them. We would now want them to be installed by the jcr packagemanager 
rest api and clean up our install folder. In older versions of sling you could 
just turn down your sling and remove stuff from the install folder, but it 
seems when you do that now that it actually uninstalls the zips when you start 
up again. Any way of disabling this behaviour?

Thanks!
Roy

Re: Unlocking a resource

2018-03-15 Thread Roy Teeuwen
Hey Robert,

I have tried adding the service user to the "administrators" group, and that 
didn't fix. So that probably means that the following code means that it has to 
be exactly the "admin" user? 

if (a != null && !a.isGroup()) {
return ((User) a).isAdmin();
}

I guess there is no alternative than using the login whitelist then, thats a 
pity. And from oak 1.10 I can just drop the code of unlocking, even better hehe.

Thanks!
Roy


> On 15 Mar 2018, at 21:15, Robert Munteanu <romb...@apache.org> wrote:
> 
> Hi Roy,
> 
> On Wed, 2018-03-14 at 13:01 +0100, Roy Teeuwen wrote:
>> Hey all,
>> 
>> I am trying to unlock a resource in a job that needs to modify the
>> resource or subresources, but since upgrading to service resource
>> resolvers this doesn't seem to be supported anymore. When doing the
>> following code, I get the exception "Not an owner of the lock
>> /content/my-site/nl/my-page/jcr:content". 
>> 
>> ```
>> LockManager lockManager =
>> resourceResolver.adaptTo(Session.class).getWorkspace().getLockManager
>> ();
>> lockManager.unlock(lockedResource.getPath());
>> ```
>> 
>> 
>> I tried to use the impersonate from service and then doing the unlock
>> with a lockmanager from that session but it still is not possible to
>> do it.
>> 
>> ```
>> def session = slingRepository.impersonateFromService("my-service",
>> new SimpleCredentials("my-user", "".toCharArray()), (String)null); 
>> ```
>> 
>> The only solution I have is to not use service resource resolvers,
>> but this would be the first case where I would have to allow the
>> login admin for a specific bundle so I would like to avoid it
>> 
>> Anyone has a solution for this?
> 
> My reading of the Oak code at [1] is that you either need to be an
> admin user or the lock owner to unlock.
> 
> Also note [2], which means that this area is unlikely to see
> improvements in the future.
> 
> Robert
> 
> 
> [1]: https://github.com/apache/jackrabbit-oak/blob/8f7bc6578cc2b5e8ecb2
> dd1544d771951678d011/oak-
> jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.ja
> va#L196-L207
> [2]: https://issues.apache.org/jira/browse/OAK-6421



Unlocking a resource

2018-03-14 Thread Roy Teeuwen
Hey all,

I am trying to unlock a resource in a job that needs to modify the resource or 
subresources, but since upgrading to service resource resolvers this doesn't 
seem to be supported anymore. When doing the following code, I get the 
exception "Not an owner of the lock /content/my-site/nl/my-page/jcr:content". 

```
LockManager lockManager = 
resourceResolver.adaptTo(Session.class).getWorkspace().getLockManager();
lockManager.unlock(lockedResource.getPath());
```


I tried to use the impersonate from service and then doing the unlock with a 
lockmanager from that session but it still is not possible to do it.

```
def session = slingRepository.impersonateFromService("my-service", new 
SimpleCredentials("my-user", "".toCharArray()), (String)null); 
```

The only solution I have is to not use service resource resolvers, but this 
would be the first case where I would have to allow the login admin for a 
specific bundle so I would like to avoid it

Anyone has a solution for this?

Thanks!
Roy

Re: Deprecation of SlingRepository.loginAdministrative()

2018-02-08 Thread Roy Teeuwen
Hey Jörg, Alexander,

Maybe it's just me, but for me the method works (on an AEM 6.3) without putting 
any impersonators on any user, thats why I of course mentioned the method, else 
it wouldn't have answered the question:

def session = slingRepository.impersonateFromService("my-service", new 
SimpleCredentials("my-user", "".toCharArray()), (String)null);

Maybe this is a security flaw :)? The reason I use it like this is because I 
also found that AEM itself uses this method to modify pages in name of users in 
workflows / jobs...

Greets,
Roy

> On 8 Feb 2018, at 00:25, Alexander Klimetschek <aklim...@adobe.com.INVALID> 
> wrote:
> 
> I had the same question previously. It is not very feasible to configure a 
> service user as a delegate on each individual human user. Especially when 
> these human users are constantly added or removed.
> 
> This is a question for Oak, I believe.
> 
> Cheers,
> Alex
> 
>> On 07.02.2018, at 14:03, Jörg Hoh <jhoh...@googlemail.com> wrote:
>> 
>> Hi Roy,
>> 
>> that's indeed good news, as it seems to solve the impersonation usecase. On
>> the other hand the javadoc is quite clear, that the requirements of the
>> impersonation process itself come from the underlying repository. I
>> typically use Oak and the Oak documentation at [1] says that with the
>> DefaultLoginModule it still requires some kind of prerequisits
>> ("Impersonation another user will only succeed if the impersonated user is
>> valid (i.e. exists and is not disabled) *and* the the user associated with
>> the editing session is allowed to impersonate this user.").
>> 
>> 
>> Jörg
>> 
>> 
>> 
>> [1]
>> https://jackrabbit.apache.org/oak/docs/security/authentication/default.html#impersonation
>> 
>> 
>> 
>> 2018-02-07 22:50 GMT+01:00 Roy Teeuwen <r...@teeuwen.be>:
>> 
>>> Hey Andres,
>>> 
>>> We had a similar use case to do impersonation, there is another method for
>>> that now:
>>> 
>>> https://sling.apache.org/apidocs/sling10/org/apache/
>>> sling/jcr/api/SlingRepository.html#impersonateFromService-
>>> java.lang.String-javax.jcr.Credentials-java.lang.String-
>>> 
>>> Greets,
>>> Roy
>>> 
>>> 
>>> On 7 Feb 2018, at 20:49, Andres Bott <cont...@andresbott.com> wrote:
>>> 
>>> Maybe a solution would be
>>> - deprecate / remove the method ( to avoid old code to run as admin)
>>> - rename the class / method and add an info to the log
>>> 
>>> in this way we make sure that old code gets migrated to service users, and
>>> the places where it really makes sense to use admin user, the developer
>>> should be aware of it.
>>> 
>>> Andres
>>> 
>>> 
>>> El 2018-02-06 14:09, Bertrand Delacretaz escribió:
>>> 
>>> On Tue, Feb 6, 2018 at 1:02 PM, Jörg Hoh <jhoh...@googlemail.com> wrote:
>>> 
>>> ...Long story short: Is the loginAdministrative() method planned to be
>>> removed? If yes, we should clearly give best practices and document how it
>>> can be replaced even in the non-trivial cases. If it's going to stay, we
>>> should remove the deprecation warning
>>> 
>>> I think we need to keep warnings that loginAdmin should be used as
>>> sparingly as possible.
>>> And probably provide some examples where it does make sense to use it.
>>> But deprecation might not be the correct term, as you indicate.
>>> -Bertrand
>>> 
>>> 
>>> 
>> 
>> 
>> --
>> Cheers,
>> Jörg Hoh,
>> 
>> http://cqdump.wordpress.com
>> Twitter: @joerghoh
> 



signature.asc
Description: Message signed with OpenPGP


Re: Deprecation of SlingRepository.loginAdministrative()

2018-02-07 Thread Roy Teeuwen
Hey Andres,

We had a similar use case to do impersonation, there is another method for that 
now:

https://sling.apache.org/apidocs/sling10/org/apache/sling/jcr/api/SlingRepository.html#impersonateFromService-java.lang.String-javax.jcr.Credentials-java.lang.String-
 


Greets,
Roy

> On 7 Feb 2018, at 20:49, Andres Bott  wrote:
> 
> Maybe a solution would be
> - deprecate / remove the method ( to avoid old code to run as admin)
> - rename the class / method and add an info to the log
> 
> in this way we make sure that old code gets migrated to service users, and 
> the places where it really makes sense to use admin user, the developer 
> should be aware of it.
> 
> Andres
> 
> 
> El 2018-02-06 14:09, Bertrand Delacretaz escribió:
>> On Tue, Feb 6, 2018 at 1:02 PM, Jörg Hoh  wrote:
>>> ...Long story short: Is the loginAdministrative() method planned to be
>>> removed? If yes, we should clearly give best practices and document how it
>>> can be replaced even in the non-trivial cases. If it's going to stay, we
>>> should remove the deprecation warning
>> I think we need to keep warnings that loginAdmin should be used as
>> sparingly as possible.
>> And probably provide some examples where it does make sense to use it.
>> But deprecation might not be the correct term, as you indicate.
>> -Bertrand



signature.asc
Description: Message signed with OpenPGP


Tracking of use of sling vanity urls

2017-12-20 Thread Roy Teeuwen
Hey all,

We have a use case that we would like to track in our analytics if a vanity url 
is used. A user comes in on the site with https://www.mysite.com/my-vanity-url 
 and gets rewritten to 
https://www.mysite.com/my/real/page.html 

How we think we could maybe solve this is by actually rewriting the url to 
https://www.mysite.com/my/real/page.html?s=/my-vanity-url 
 so that analytics 
can catch this. Is there any possibility so far to alter the behaviour of how 
the vanity url's get handled?

I'm asking here first because maybe you guys can already say, don't count on 
ever getting that to work without an entire rebuild of the vanity system :)...

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: Maven plugin to set property on a resource

2017-12-19 Thread Roy Teeuwen
Hey Jason,

Yup, thats what I got to at this point, maybe there was a cleaner way, but I 
guess this will do :)

Just for ppl for future references, this is my final result (pretty long, thats 
why I was looking for something less bulky, but could always make a separate 
plugin if necessary


org.codehaus.groovy.maven
gmaven-plugin


disable-dam-workflows
pre-integration-test

execute






enable-dam-workflows
post-integration-test

execute






Greets,
Roy

> On 19 Dec 2017, at 23:32, Jason E Bailey <jason.bai...@24601.org> wrote:
> 
> Maybe something like maven exec or maven antrun to perform a curl command?
> 
> --
> Jason
> 
> On Tue, Dec 19, 2017, at 1:04 PM, Roy Teeuwen wrote:
>> Hey all,
>> 
>> I am searching for the fastest way to set and delete a property on a
>> resource of a specific path. I could use the gmaven-plugin and write a
>> groovy script to do this, but maybe there is already someone with a
>> better plugin for this and I don't have to write an ugly script for it
>> in my pom.xml.
>> 
>> Just for the people who want to know what I want to achieve: I am
>> installing my content package with test content(filevault xmls) and
>> images inside, but before I want to install it, I would like to disable
>> a workflow (more specifically the update dam asset workflow) because the
>> renditions are already in the test-content and it slows down the system
>> because of the heavy workflow/jobs triggering.
>> 
>> Greets,
>> Roy
>> Email had 1 attachment:
>> + signature.asc
>>  1k (application/pgp-signature)



signature.asc
Description: Message signed with OpenPGP


Maven plugin to set property on a resource

2017-12-19 Thread Roy Teeuwen
Hey all,

I am searching for the fastest way to set and delete a property on a resource 
of a specific path. I could use the gmaven-plugin and write a groovy script to 
do this, but maybe there is already someone with a better plugin for this and I 
don't have to write an ugly script for it in my pom.xml.

Just for the people who want to know what I want to achieve: I am installing my 
content package with test content(filevault xmls) and images inside, but before 
I want to install it, I would like to disable a workflow (more specifically the 
update dam asset workflow) because the renditions are already in the 
test-content and it slows down the system because of the heavy workflow/jobs 
triggering.

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: [ANN] New Apache Sling PMC Chair: Robert Munteanu

2017-11-16 Thread Roy Teeuwen
Congratulations Robert!

Greets,
Roy

> On 16 Nov 2017, at 15:25, Carsten Ziegeler  wrote:
> 
> Hi,
> 
> it's my pleasure to announce that Robert took up the role as our new PMC
> chair.
> 
> Congrats Robert!
> 
> Regards
> Carsten
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



signature.asc
Description: Message signed with OpenPGP


Re: Daily content sync between environments

2017-10-23 Thread Roy Teeuwen
Hey Ioan,

In my initial post I already gave you all the experience I have so for, I have 
tested out 4 different tools (Content Packages, VLT RCP, Grabbit and 
oak-migration tool) and given my benefits and drawbacks.

I will give VLT a try again, but I think seeing as the problem I found when 
first using it through VLT RCP[1], so not the vlt co that Robert and Daniel 
suggested, I am not sure if that one will work out.
If VLT fails and no other solutions come up, I might probably go for the 
creating a daily content package based on a query which looks for new content 
created that day.

Greets,
Roy

[1] 
http://jackrabbit.510166.n4.nabble.com/Filevault-OakConstraint0021-Exception-td4666959.html
 
<http://jackrabbit.510166.n4.nabble.com/Filevault-OakConstraint0021-Exception-td4666959.html>


> On 23 Oct 2017, at 18:53, Ioan Eugen Stan <ieu...@netdava.com> wrote:
> 
> Hi Roy,
> 
> This is a use case that we have as well.
> 
> We need to be able to sync content between different instances
> periodically or on request. We are still in the planning phase and will
> start to implement Sling once we have enough resources.
> 
> Please share your experience so others can benefit (including us).
> 
> In our use case we have an Item Bank with lots of items and other
> content. Most of the time we need to update translations. In some cases
> (once every few months) we need to add/update the content/content
> structure. Translations can be handled in lots of ways, we might not
> even use the vlt solution Robert proposed.  For new content I think that
> is something that will help us.
> 
> 
> Regards,
> 
> 
> On 23.10.2017 18:58, Robert Munteanu wrote:
>> Hi Roy,
>> 
>> On Sun, 2017-10-22 at 19:39 +0200, Roy Teeuwen wrote:
>>> Hey guys,
>>> 
>>> I didn't know for sure where to put this question so thats why I am
>>> asking it in both Jackrabbit as in Sling, because both might have
>>> their own solution / proposal, and I have seen solutions that are
>>> pure Jackrabbit but some that also require Sling.
>>> 
>>> I was wondering about what some of you might achieve something like a
>>> daily content sync between different environments (Production to
>>> Acceptance/Development for example).
>> Never tried this, but maybe you can use vlt ci/co? Initially you run
>> vlt co against the 'source' instance and then vlt ci against the
>> 'target' instance. First time you will sync everything, but then
>> operations will be incremental.
>> 
>> You do have to find a clean way of switching the vlt url between
>> invocations though.
>> 
>> Robert
> 
> 



signature.asc
Description: Message signed with OpenPGP


Daily content sync between environments

2017-10-22 Thread Roy Teeuwen
Hey guys,

I didn't know for sure where to put this question so thats why I am asking it 
in both Jackrabbit as in Sling, because both might have their own solution / 
proposal, and I have seen solutions that are pure Jackrabbit but some that also 
require Sling.

I was wondering about what some of you might achieve something like a daily 
content sync between different environments (Production to 
Acceptance/Development for example).

I have been investigating it for a while now, and the current solution we use 
is by use of the oak-migration tool, where every release that we have, we bring 
the repo down, do an export of all the paths that we need (mainly /content and 
some stuff in /etc and /conf), and do an import on all the other lower 
environments. But I am not sure if this is the ideal solution, definitely if we 
want to go to a daily content sync instead of a release bound content sync, 
seeing as this required the instance be put offline before it can run (unless 
this changed in a future version, please correct me if it did because that 
would be very nice).

The tools I have found that might be of use until are the following:
One could create a JCR content package of production, and copy it over to the 
different environments daily. The downside of this is that when the package 
becomes big, it gets problematic (for example when a lot of images/videos start 
to get involved).
One could use VLT RCP, I have tried this but it seems that it has a bug[1] that 
when there is an error in the vlt rcp, it actually retries infinite amount to 
fix it, making the actual sync impossible from the moment one error for a 
specific node pops up. A second problem, and also sort of a dealbreaker is that 
for VLT RCP to work, you would have to make the production environment network 
accessible to all the other environments, or a bit better, use some proxy that 
has access to both production and the test environments.
Time Warner seems to have run into the same issue, and created Grabbit[2] for 
this, but their tool has also two mayor drawbacks. The first drawback is 
related to the VLT RCP, where you would need to have access from production to 
all the other environments, but even worse is that you can't do it with a proxy 
in between, meaning they really need to have access to each other. A second 
drawback that I really dislike is that their tool is written in Spring OSGi. I 
have no idea why one would make a tool in OSGi and then use Spring for it, but 
they bring in like 30 bundles just to do a content sync between environments, 
mainly outdated Spring 3.X bundles.
Lastly of course there is the oak migration tool, which is super fast in doing 
an export and import, it is the current one we use, but the drawback being that 
you have to bring down the environment.
The solutions that I am currently thinking of are one of the next two, which 
are almost similar, but it would be nice to hear some opinions from other 
people.

We could write a service that just specifies a list of node paths that have 
been altered in the current day, for example based on the jcr:lastModified date.
From this list, one could do one of the following this:
Create a dynamic jcr content package, based on the list provided by this 
service. The drawback being if there are a lot of new images/videos that 
specific day, the content package might get slow / be too big / time out
Create a dynamic list of include and merge paths for the oak-migration tool 
based on this service. The drawback being you would have to bring down your 
repo after this

Another solution when going for the second part would be to expand the 
oak-migration tool to optionally specify which paths it should export based on 
a specific date property being larger/smaller than the one you pass as parameter

Any opinions / suggestions on this are more than welcome.

Greets,
Roy Teeuwen

[1] 
http://jackrabbit.510166.n4.nabble.com/Filevault-OakConstraint0021-Exception-td4666959.html
 
<http://jackrabbit.510166.n4.nabble.com/Filevault-OakConstraint0021-Exception-td4666959.html>
[2] https://github.com/TWCable/grabbit <https://github.com/TWCable/grabbit>


signature.asc
Description: Message signed with OpenPGP


Re: File system resource provider - Performance

2017-09-29 Thread Roy Teeuwen
Hey Carsten,

What about doing the initial scanning also async? As in that you do the initial 
scanning in the first scheduled run, without throwing change events for that 
first run

Greets,
Roy

> On 29 Sep 2017, at 15:57, Carsten Ziegeler  wrote:
> 
> 
> 
> 
> Stefan Seifert wrote
>> 
>>> I think we could try using newer file features from Java 7 which might
>>> make the scanning obsolete. But I've never looked into it.
>> 
>> you mean with e.g. this?
>> https://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchService.html
>> 
>> i had this on my todo list some time ago for fsresource - but after some 
>> first experiments this seems to behave different depending on the operation 
>> system (windows vs. linux), so i dropped it that time. if someone comes up 
>> with a concept that works reliable on all operation systems i would be glad 
>> to help integrate it in fsresource.
>> 
> 
> Yes, I agree - this doesn't seem to help (I now remember that I looked
> into it a long time ago).
> 
> I'm not sure if this is a good idea, but we could have a switch that
> skips the initial scan and also skips registering the periodic scanners.
> Once a file is accessed we lazily add a scanner for that directory to
> the list. So once a resource/file is used you get change events. If a
> directory is never touched, we don't do anything.
> 
> Regards
> Carsten
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



signature.asc
Description: Message signed with OpenPGP


Re: File system resource provider - Performance

2017-09-29 Thread Roy Teeuwen
Hey Stefan,

I was planning to give that a try too, could you maybe elaborate on what 
hick-ups you noticed on the different OSes?

Greets
Roy

> On 29 Sep 2017, at 15:52, Stefan Seifert  wrote:
> 
> 
>> I think we could try using newer file features from Java 7 which might
>> make the scanning obsolete. But I've never looked into it.
> 
> you mean with e.g. this?
> https://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchService.html
> 
> i had this on my todo list some time ago for fsresource - but after some 
> first experiments this seems to behave different depending on the operation 
> system (windows vs. linux), so i dropped it that time. if someone comes up 
> with a concept that works reliable on all operation systems i would be glad 
> to help integrate it in fsresource.
> 
> stefan
> 
> 



signature.asc
Description: Message signed with OpenPGP


File system resource provider - Performance

2017-09-25 Thread Roy Teeuwen
Hey all,

We are using the file system resource provider to monitor a directory to be 
attached as resources. Currently in our directory we have around 5 levels deep 
with in total 200.000 files. The problem we are facing is that when our 
application starts up, it takes an unusual amount of time to get online. It 
appears that the file system resource provider is building up the monitor cache 
and this is the cause of the performance decay. We currently have one file 
system resource provider config for the entire directory, would it be better to 
have multiple on lower levels, and if so, how many files maximum per resource 
provider config should we take?

Or maybe the file system resource provider is not made to work on this large 
amount of files? For our use-case it looks perfect because we also use the 
events being triggered and because we like to use the files as resources in our 
application without having to import them as actual jcr nodes.

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: New Resource Provider SPI - limitations

2017-09-22 Thread Roy Teeuwen
Hey Carsten,

I have tested it further, and it seems that both the old and the new resource 
provider api has the same bug. Correct me if i'm wrong that it's a bug, but the 
following occurs:

- The resource provider gets deployed on a specific root (lets say 
/content/my-site/a-page), either the old api or the new spi
- Next time sling gets restarted, the JcrResourceProvider comes into this 
function: 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker#updateProviderContext
- Seeing as we now have a path /content/my-site/a-page, this will be added to 
the excludedPaths of JcrResourceProvider
- We can now no longer query to anything below /content/my-site/a-page. For 
example if there is a sling:alias on /content/my-site/a-page/jcr:content, it 
will not be loaded anymore on startup, nor will you be able to query any 
resources below it.

This used to work in the old api, I think because there was nothing like this 
excludedPaths functionality in the old api? You maybe got any suggestions on 
how to make it work in the current situation, either with the old or the new 
api, I have tried both now

Greets,
Roy


> On 18 Sep 2017, at 16:10, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> Roy Teeuwen wrote
>> Hey Carsten,
>> 
>> Thanks for the info! It seems by the way that the current implementation 
>> actually even breaks Slin when still using the old ResourceProvider api.
>> 
>> When you have for example a api.ResourceProvider mounted on path /content, 
>> it will be added to the excludedPaths of the ProviderContext => These paths 
>> are used in the BasicQueryLanguageProvider when doing a query in the 
>> resource resolver and returning a JcrNodeResourceIterator, making it that no 
>> results are returned anymore from /content.
>> 
>> I don't know if I should register this as a bug? What is the policy of 
>> deprecated classes? Shouldn't they still work as designed until they 
>> actually get removed?
>> 
> Hi,
> 
> yes, deprecated classes should work as designed, so this might be a bug.
> 
> Regards
> Carsten
> 
> 
> 
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



signature.asc
Description: Message signed with OpenPGP


Re: New Resource Provider SPI - limitations

2017-09-18 Thread Roy Teeuwen
Hey Carsten,

Thanks for the info! It seems by the way that the current implementation 
actually even breaks Slin when still using the old ResourceProvider api.

When you have for example a api.ResourceProvider mounted on path /content, it 
will be added to the excludedPaths of the ProviderContext => These paths are 
used in the BasicQueryLanguageProvider when doing a query in the resource 
resolver and returning a JcrNodeResourceIterator, making it that no results are 
returned anymore from /content.

I don't know if I should register this as a bug? What is the policy of 
deprecated classes? Shouldn't they still work as designed until they actually 
get removed?

Greets,
Roy
> On 15 Sep 2017, at 17:10, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> Hi,
> 
> to simplify the processing of providers we removed the explicit fallback
> to a "higher" provider. However, your resource provider gets a context
> which it can use to get a resource from a higher provider. So instead of
> returning null you explicitely call the parent and return that result
> from the parent.
> 
> Regards
> Carsten
> 
> Roy Teeuwen wrote
>> Hey all,
>> 
>> We are currently upgrading our environment, and of course the new resource 
>> provider SPI is now available. But it seems that our current resource 
>> provider would not be able to be used in this new SPI, seeing as in the old 
>> one you could dynamically look if the resource provider could return a 
>> resource for the request, and if not just return null, letting the next 
>> resource provider have a look.
>> 
>> Seeing as the old resource provider is deprecated, what would be the 
>> recommended approach to have the same kind of logic:
>> 
>> - Register on root level
>> - Check if the request has something that we are looking for (in our 
>> situation we are looking for a specific structure in the requested url)
>> - If yes, return a resource, if no let the default resource provider do 
>> their job
>> 
>> I could of course wait until the old resource provider api has really been 
>> removed, but I would rather work proactively :)
>> 
>> Greets,
>> Roy
>> 
> 
> 
> 
> 
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



signature.asc
Description: Message signed with OpenPGP


New Resource Provider SPI - limitations

2017-09-14 Thread Roy Teeuwen
Hey all,

We are currently upgrading our environment, and of course the new resource 
provider SPI is now available. But it seems that our current resource provider 
would not be able to be used in this new SPI, seeing as in the old one you 
could dynamically look if the resource provider could return a resource for the 
request, and if not just return null, letting the next resource provider have a 
look.

Seeing as the old resource provider is deprecated, what would be the 
recommended approach to have the same kind of logic:

- Register on root level
- Check if the request has something that we are looking for (in our situation 
we are looking for a specific structure in the requested url)
- If yes, return a resource, if no let the default resource provider do their 
job

I could of course wait until the old resource provider api has really been 
removed, but I would rather work proactively :)

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: Running junit integration tests with login administrative

2017-08-29 Thread Roy Teeuwen
Hey,

Ok i will give it a try, cant seem to find any projects online that use the 
testing.clients bundle sadly enough.

Thanks
Roy

> Op 29 aug. 2017 om 13:09 heeft Robert Munteanu <romb...@apache.org> het 
> volgende geschreven:
> 
> 
> Hi Roy,
> 
>> On Tue, 2017-08-29 at 13:06 +0200, Roy Teeuwen wrote:
>> Hey Robert,
>> 
>> Thanks for the info! It does look like something I could definitely
>> use for this, but if I look at the methods, I only see an
>> editConfiguration, and deleteConfiguration not an addConfiguration?
>> 
>> When I look at the comments, it says:
>> 
>> Sets properties of a config referenced by its PID. the properties to
>> be edited are passed as
>> * a map of property name,value pairs.
>> 
>> So I don't know if I can also actually add a new one with this
>> method?
> 
> You should definitely be able to add a new configuration.
> 
> Robert


Re: Running junit integration tests with login administrative

2017-08-29 Thread Roy Teeuwen
Hey Robert,

Thanks for the info! It does look like something I could definitely use for 
this, but if I look at the methods, I only see an editConfiguration, and 
deleteConfiguration not an addConfiguration?

When I look at the comments, it says:

 Sets properties of a config referenced by its PID. the properties to be edited 
are passed as
* a map of property name,value pairs.

So I don't know if I can also actually add a new one with this method?

Thanks,
Roy
> On 29 Aug 2017, at 12:40, Robert Munteanu <romb...@apache.org> wrote:
> 
> Hi Roy,
> 
> On Mon, 2017-08-28 at 14:44 +0200, Roy Teeuwen wrote:
>> Hey all,
>> 
>> I am trying to run integration tests based on the
>> org.apache.sling.junit.core bundle. So far this always used to work,
>> because I was able to use loginAdministrative, but now that this
>> feature is disabled I can not do this anymore without providing
>> a  org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-
>> junitcore config.
>> 
>> I have seen in the caconfig bundle for integration tests that it is
>> done there by using the provisioning model to give the config and a
>> repoinit to provide the user, but this is not possible in my use-
>> case, I am creating an integration test bundle for AEM 6.3, so there
>> is no more provisioning, it's against a running test instance.
>> 
>> Anyone has a good approach to tackle this issue, that the config (and
>> possibly even the user mapping) is still inside the integration test
>> bundle, and not that I have to pre provision it to the running
>> instance?
> 
> I would try and install the OSGi config at test time, using the
> OSGiConsoleClient.
> 
> Robert



signature.asc
Description: Message signed with OpenPGP


Running junit integration tests with login administrative

2017-08-28 Thread Roy Teeuwen
Hey all,

I am trying to run integration tests based on the org.apache.sling.junit.core 
bundle. So far this always used to work, because I was able to use 
loginAdministrative, but now that this feature is disabled I can not do this 
anymore without providing a  
org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-junitcore 
config.

I have seen in the caconfig bundle for integration tests that it is done there 
by using the provisioning model to give the config and a repoinit to provide 
the user, but this is not possible in my use-case, I am creating an integration 
test bundle for AEM 6.3, so there is no more provisioning, it's against a 
running test instance.

Anyone has a good approach to tackle this issue, that the config (and possibly 
even the user mapping) is still inside the integration test bundle, and not 
that I have to pre provision it to the running instance?

Thanks,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: Sling models - Resource decorator

2017-06-12 Thread Roy Teeuwen
Hey Justin,

Aha ok I get what you are saying. Then the problem indeed lies with the 
ResourceWrapper for not using the AdapterFactory. Thanks!

I guess I can change this in my own code to override the method in my resource 
wrapper, although it still feels like something I wouldn't expect, definitely 
because I'm using @Self.
Changing the ResourceWrapper implementation itself though would probably take 
it a lot further and have some side effects on dependent bundles :/.

Greets,
Roy
> On 12 Jun 2017, at 21:55, Justin Edelson <jus...@justinedelson.com> wrote:
> 
> Hi Roy,
> That's not the reason :) this is an implementation detail of the way the
> wrapping is done, so it belongs in the wrapper.
> 
> Here's a bit more detail on the problem which I hope helps explain where
> the issue lies.
> 
> When you call resource.adaptTo(Class) on a ResourceWrapper, it is actually
> returning the result of adaptTo(Class) on the wrapped resource, i.e. when
> you call
> 
> SelfModel selfModel = resource.adaptTo(SelfModel.class);
> 
> What is actually happening is
> 
> SelfModel selfModel = resource.getResource().adaptTo(SelfModel.class);
> 
> This is documented in the JavaDoc:
> http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceWrapper.java?view=markup#l174
> <http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceWrapper.java?revision=1751431=markup#l174>
> 
> If your wrapper needs to behave differently, then it stands to reason it
> would need to implement its own adaptTo() method. I've updated the test to
> use this technique. See
> http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/services/TestResourceDecorator.java?view=markup
> 
> That said, I agree that this is a bit intrusive. One idea could be to
> change the implementation in ResourceWrapper to do what I'm describing all
> the time.
> 
> Regards,
> Justin
> 
> 
> 
> 
> On Mon, Jun 12, 2017 at 3:40 PM Roy Teeuwen <r...@teeuwen.be> wrote:
> 
>> Hey Justin,
>> 
>> The reason why it is odd to me is that it should be agnostic to being
>> wrapped or not.
>> 
>> You use the resourceresolver to get the resource and then do an adapt, all
>> not knowing anything about being wrapped or not, seeing as the resource
>> resolver also does the wrapping internally, why wouldn't the adaptTo do it?
>> 
>> Resource resource = resourceResolver.getResource("/my/path");
>> SelfModel selfModel = resource.adaptTo(SelfModel.class);
>> 
>> Greets,
>> Roy
>> 
>>> On 12 Jun 2017, at 21:32, Justin Edelson <jus...@justinedelson.com>
>> wrote:
>>> 
>>> Hi Roy,
>>> OK. That makes sense (and I'm sorry I missed that part in your original
>>> email). The problem is that if you use WrappedResource, it delegates the
>>> adaptTo() call to the wrapped resource, i.e. the wrapper is lost at that
>>> point and the AdapterFactory (i.e. Sling Models) doesn't have access to
>> it
>>> anymore. I'm not sure how this can be best be handled. One approach would
>>> be in your wrapper class to implement the adaptTo method. Something like:
>>> 
>>> class Wrapper extends ResourceWrapper {
>>>   private Wrapper(Resource r) {
>>>   super(r);
>>>   }
>>> 
>>>   @Override
>>>   public  AdapterType adaptTo(Class type)
>> {
>>>   AdapterType adapter = adapterManager.getAdapter(this, type);
>>>   if (adapter != null) {
>>>   return adapter;
>>>   } else {
>>>   return super.adaptTo(type);
>>>   }
>>>   }
>>>   }
>>> 
>>> But this looks a bit odd to me, although I can't quite put my finger on
>> why.
>>> 
>>> Regards,
>>> Justin
>>> 
>>> On Mon, Jun 12, 2017 at 3:21 PM Roy Teeuwen <r...@teeuwen.be> wrote:
>>> 
>>>> Hey Justin,
>>>> 
>>>> Cool, thanks for the integration test!
>>>> Just change the modelFactory.createModel to
>>>> resource.adaptTo(SelfModel.class) and you will see that the test fails
>> :)
>>>> 
>>>> Greets,
>>>> Roy
>>>>> On 12 Jun 2017, at 18:52, Justin Edelson <jus...@justinedelson.com>
>>>> wrote:
>>>>> 
>>>>> FWIW, I committed an integration test at
>>>>> http://svn.apache.org/viewvc?view=revision=1

Re: Sling models - Resource decorator

2017-06-12 Thread Roy Teeuwen
Hey Justin,

The reason why it is odd to me is that it should be agnostic to being wrapped 
or not.

You use the resourceresolver to get the resource and then do an adapt, all not 
knowing anything about being wrapped or not, seeing as the resource resolver 
also does the wrapping internally, why wouldn't the adaptTo do it?

Resource resource = resourceResolver.getResource("/my/path");
SelfModel selfModel = resource.adaptTo(SelfModel.class);

Greets,
Roy

> On 12 Jun 2017, at 21:32, Justin Edelson <jus...@justinedelson.com> wrote:
> 
> Hi Roy,
> OK. That makes sense (and I'm sorry I missed that part in your original
> email). The problem is that if you use WrappedResource, it delegates the
> adaptTo() call to the wrapped resource, i.e. the wrapper is lost at that
> point and the AdapterFactory (i.e. Sling Models) doesn't have access to it
> anymore. I'm not sure how this can be best be handled. One approach would
> be in your wrapper class to implement the adaptTo method. Something like:
> 
> class Wrapper extends ResourceWrapper {
>private Wrapper(Resource r) {
>super(r);
>}
> 
>@Override
>public  AdapterType adaptTo(Class type) {
>AdapterType adapter = adapterManager.getAdapter(this, type);
>if (adapter != null) {
>return adapter;
>} else {
>return super.adaptTo(type);
>}
>}
>}
> 
> But this looks a bit odd to me, although I can't quite put my finger on why.
> 
> Regards,
> Justin
> 
> On Mon, Jun 12, 2017 at 3:21 PM Roy Teeuwen <r...@teeuwen.be> wrote:
> 
>> Hey Justin,
>> 
>> Cool, thanks for the integration test!
>> Just change the modelFactory.createModel to
>> resource.adaptTo(SelfModel.class) and you will see that the test fails :)
>> 
>> Greets,
>> Roy
>>> On 12 Jun 2017, at 18:52, Justin Edelson <jus...@justinedelson.com>
>> wrote:
>>> 
>>> FWIW, I committed an integration test at
>>> http://svn.apache.org/viewvc?view=revision=1798489 checking
>> that
>>> the wrapped resource is injected via the @Self annotation. Would be
>>> interesting to see how this differs from what you are doing.
>>> 
>>> Regards,
>>> Justin
>>> 
>>> On Mon, Jun 12, 2017 at 12:23 PM Justin Edelson <
>> jus...@justinedelson.com>
>>> wrote:
>>> 
>>>> Hi Roy,
>>>> This sounds like unexpected behavior. Please create a JIRA for this,
>>>> ideally with a test case, if you have not already.
>>>> 
>>>> Thanks,
>>>> Justin
>>>> 
>>>> On Mon, Jun 12, 2017 at 4:38 AM Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> 
>>>>> Hey Jason, Guys,
>>>>> 
>>>>> No one can give me an answer if this is a bug or something wanted? I
>> can
>>>>> always register a Jira ticket for and put it on the dev list of course
>>>>> 
>>>>> Greets,
>>>>> Roy
>>>>>> On 6 Jun 2017, at 21:50, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>>>> 
>>>>>> Hey Jason,
>>>>>> 
>>>>>> No to both assumptions
>>>>>> 
>>>>>> - I used @Inject public Resource resource. Just tried the @Self, same
>>>>> result
>>>>>> - I have @Model(adaptables = Resource.class). I don't want to bind my
>>>>> model to a custom Resource class, that would be the same as saying I
>> have
>>>>> to do @Model(adaptables = JcrNodeResource.class), the decorator just
>>>>> decorates your resource implementation class, has nothing to do with
>> your
>>>>> Resource interface you are coming from.
>>>>>> 
>>>>>> Greets,
>>>>>> Roy
>>>>>>> On 6 Jun 2017, at 21:41, Jason Bailey <jason.bai...@sas.com> wrote:
>>>>>>> 
>>>>>>> Hey Roy,
>>>>>>> 
>>>>>>> Couple of Assumptions:
>>>>>>> 
>>>>>>> For the Self resource you have it defined as:
>>>>>>> 
>>>>>>> @Self
>>>>>>> public Resource resource;
>>>>>>> 
>>>>>>> and for the @Model you have something like
>>>>>>> @Model(adaptables = RoysCustomDecorator.class)
>>>>>>> 
>>>>>>> Am I close?
>>>

Re: Sling models - Resource decorator

2017-06-12 Thread Roy Teeuwen
Hey Justin,

Cool, thanks for the integration test!
Just change the modelFactory.createModel to resource.adaptTo(SelfModel.class) 
and you will see that the test fails :)

Greets,
Roy
> On 12 Jun 2017, at 18:52, Justin Edelson <jus...@justinedelson.com> wrote:
> 
> FWIW, I committed an integration test at
> http://svn.apache.org/viewvc?view=revision=1798489 checking that
> the wrapped resource is injected via the @Self annotation. Would be
> interesting to see how this differs from what you are doing.
> 
> Regards,
> Justin
> 
> On Mon, Jun 12, 2017 at 12:23 PM Justin Edelson <jus...@justinedelson.com>
> wrote:
> 
>> Hi Roy,
>> This sounds like unexpected behavior. Please create a JIRA for this,
>> ideally with a test case, if you have not already.
>> 
>> Thanks,
>> Justin
>> 
>> On Mon, Jun 12, 2017 at 4:38 AM Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>>> Hey Jason, Guys,
>>> 
>>> No one can give me an answer if this is a bug or something wanted? I can
>>> always register a Jira ticket for and put it on the dev list of course
>>> 
>>> Greets,
>>> Roy
>>>> On 6 Jun 2017, at 21:50, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> 
>>>> Hey Jason,
>>>> 
>>>> No to both assumptions
>>>> 
>>>> - I used @Inject public Resource resource. Just tried the @Self, same
>>> result
>>>> - I have @Model(adaptables = Resource.class). I don't want to bind my
>>> model to a custom Resource class, that would be the same as saying I have
>>> to do @Model(adaptables = JcrNodeResource.class), the decorator just
>>> decorates your resource implementation class, has nothing to do with your
>>> Resource interface you are coming from.
>>>> 
>>>> Greets,
>>>> Roy
>>>>> On 6 Jun 2017, at 21:41, Jason Bailey <jason.bai...@sas.com> wrote:
>>>>> 
>>>>> Hey Roy,
>>>>> 
>>>>> Couple of Assumptions:
>>>>> 
>>>>> For the Self resource you have it defined as:
>>>>> 
>>>>> @Self
>>>>> public Resource resource;
>>>>> 
>>>>> and for the @Model you have something like
>>>>> @Model(adaptables = RoysCustomDecorator.class)
>>>>> 
>>>>> Am I close?
>>>>> 
>>>>> -Jason
>>>>> 
>>>>> -Original Message-
>>>>> From: Roy Teeuwen [mailto:r...@teeuwen.be]
>>>>> Sent: Tuesday, June 06, 2017 10:08 AM
>>>>> To: users@sling.apache.org
>>>>> Subject: Sling models - Resource decorator
>>>>> 
>>>>> Hey all,
>>>>> 
>>>>> I am using sling models version 1.2.2, and I have the following logic:
>>>>> 
>>>>> - I find some resources with the resource resolver
>>> (resourceResolver.findResources)
>>>>> - The returned resources are the correct resources which are decorated
>>> by my custom resource decorator
>>>>> - I iterate the list to cast them to the sling model I want them to
>>> be, using a resource.adaptTo
>>>>> - The sling model itself has a field Resource resource, to inject
>>> itself
>>>>> 
>>>>> What I notice now is that the injected resource is a JcrNodeResource
>>> and not my decorated resource class anymore. I guess this is a bug in the
>>> sling models implementation? Am I doing something wrong here or is this an
>>> actual bug in the sling models implementation? Is this maybe already fixed
>>> in any of the future versions?
>>>>> 
>>>>> Greets,
>>>>> Roy
>>>> 
>>> 
>>> 



signature.asc
Description: Message signed with OpenPGP


Re: Sling models - Resource decorator

2017-06-12 Thread Roy Teeuwen
Hey Jason, Guys,

No one can give me an answer if this is a bug or something wanted? I can always 
register a Jira ticket for and put it on the dev list of course

Greets,
Roy
> On 6 Jun 2017, at 21:50, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Hey Jason,
> 
> No to both assumptions
> 
> - I used @Inject public Resource resource. Just tried the @Self, same result
> - I have @Model(adaptables = Resource.class). I don't want to bind my model 
> to a custom Resource class, that would be the same as saying I have to do 
> @Model(adaptables = JcrNodeResource.class), the decorator just decorates your 
> resource implementation class, has nothing to do with your Resource interface 
> you are coming from.
> 
> Greets,
> Roy
>> On 6 Jun 2017, at 21:41, Jason Bailey <jason.bai...@sas.com> wrote:
>> 
>> Hey Roy,
>> 
>> Couple of Assumptions:
>> 
>> For the Self resource you have it defined as:
>> 
>> @Self
>> public Resource resource;
>> 
>> and for the @Model you have something like
>> @Model(adaptables = RoysCustomDecorator.class)
>> 
>> Am I close?
>> 
>> -Jason
>> 
>> -Original Message-
>> From: Roy Teeuwen [mailto:r...@teeuwen.be]
>> Sent: Tuesday, June 06, 2017 10:08 AM
>> To: users@sling.apache.org
>> Subject: Sling models - Resource decorator
>> 
>> Hey all,
>> 
>> I am using sling models version 1.2.2, and I have the following logic:
>> 
>> - I find some resources with the resource resolver 
>> (resourceResolver.findResources)
>> - The returned resources are the correct resources which are decorated by my 
>> custom resource decorator
>> - I iterate the list to cast them to the sling model I want them to be, 
>> using a resource.adaptTo
>> - The sling model itself has a field Resource resource, to inject itself
>> 
>> What I notice now is that the injected resource is a JcrNodeResource and not 
>> my decorated resource class anymore. I guess this is a bug in the sling 
>> models implementation? Am I doing something wrong here or is this an actual 
>> bug in the sling models implementation? Is this maybe already fixed in any 
>> of the future versions?
>> 
>> Greets,
>> Roy
> 



signature.asc
Description: Message signed with OpenPGP


Re: Sling models - Resource decorator

2017-06-06 Thread Roy Teeuwen
Hey Jason,

No to both assumptions

- I used @Inject public Resource resource. Just tried the @Self, same result
- I have @Model(adaptables = Resource.class). I don't want to bind my model to 
a custom Resource class, that would be the same as saying I have to do 
@Model(adaptables = JcrNodeResource.class), the decorator just decorates your 
resource implementation class, has nothing to do with your Resource interface 
you are coming from.

Greets,
Roy
> On 6 Jun 2017, at 21:41, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> Hey Roy,
> 
> Couple of Assumptions:
> 
> For the Self resource you have it defined as:
> 
> @Self
> public Resource resource;
> 
> and for the @Model you have something like
> @Model(adaptables = RoysCustomDecorator.class)
> 
> Am I close?
> 
> -Jason
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be]
> Sent: Tuesday, June 06, 2017 10:08 AM
> To: users@sling.apache.org
> Subject: Sling models - Resource decorator
> 
> Hey all,
> 
> I am using sling models version 1.2.2, and I have the following logic:
> 
> - I find some resources with the resource resolver 
> (resourceResolver.findResources)
> - The returned resources are the correct resources which are decorated by my 
> custom resource decorator
> - I iterate the list to cast them to the sling model I want them to be, using 
> a resource.adaptTo
> - The sling model itself has a field Resource resource, to inject itself
> 
> What I notice now is that the injected resource is a JcrNodeResource and not 
> my decorated resource class anymore. I guess this is a bug in the sling 
> models implementation? Am I doing something wrong here or is this an actual 
> bug in the sling models implementation? Is this maybe already fixed in any of 
> the future versions?
> 
> Greets,
> Roy



signature.asc
Description: Message signed with OpenPGP


Sling models - Resource decorator

2017-06-06 Thread Roy Teeuwen
Hey all,

I am using sling models version 1.2.2, and I have the following logic:

- I find some resources with the resource resolver 
(resourceResolver.findResources)
- The returned resources are the correct resources which are decorated by my 
custom resource decorator
- I iterate the list to cast them to the sling model I want them to be, using a 
resource.adaptTo
- The sling model itself has a field Resource resource, to inject itself

What I notice now is that the injected resource is a JcrNodeResource and not my 
decorated resource class anymore. I guess this is a bug in the sling models 
implementation? Am I doing something wrong here or is this an actual bug in the 
sling models implementation? Is this maybe already fixed in any of the future 
versions?

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP


Re: Different ways to define initial content :: Content.xml vs Json equivalent

2017-04-04 Thread Roy Teeuwen
Hey Andy,

As you can see in the ticket, there is already something that exists:

> a good starting point for this may be the wcm.io content package maven plugin:
>   • 
> http://wcm.io/tooling/maven/plugins/wcmio-content-package-maven-plugin/
>   • 
> https://github.com/wcm-io/wcm-io-tooling/tree/develop/maven/plugins/wcmio-content-package-maven-plugin


Greets,
Roy
> On 4 Apr 2017, at 17:28, Andreas Schaefer Sr. <schaef...@me.com> wrote:
> 
> Yes, I was thinking that might be the issue.
> 
> Do you guess have already something on Git?
> 
> Thanks - Andy Schaefer
> 
>> On Apr 4, 2017, at 12:13 AM, Robert Munteanu <romb...@apache.org> wrote:
>> 
>> On Tue, 2017-04-04 at 08:32 +0200, Roy Teeuwen wrote:
>>> Hey Andy,
>>> 
>>> The license inside might not be good enough ;)
>>> 
>>> Greets,
>>> Roy
>>>> On 3 Apr 2017, at 22:50, Andreas Schaefer <schaef...@mac.com>
>>>> wrote:
>>>> 
>>>> Why is that necessary? The one from Adobe isn't good enough?
>> 
>> IANAL and speaking only as an Apache committer, not as an Adobe
>> employee.
>> 
>> That being said, that artifact is not present on Maven central, and on
>> repo.adobe.com the following disclaimer is used
>> 
>>   This maven2 repository provides access to public artifacts used in
>>   conjunction with developing java-based applications on Adobe
>>   frameworks. Adobe Terms apply.
>> 
>> Adobe terms links to http://www.adobe.com/misc/terms.html .
>> 
>> I for one would not use that plugin in Apache Sling applications
>> without legal advice, but a brief look tells me that these are not
>> intended for use with non-Adobe apps.
>> 
>> Robert
>> 
>>>> 
>>>> - Andy Schaefer
>>>> 
>>>>> On Apr 3, 2017, at 3:23 AM, Robert Munteanu <romb...@apache.org>
>>>>> wrote:
>>>>> 
>>>>> Hi Greg,
>>>>> 
>>>>>> On Sat, 2017-04-01 at 13:18 +0200, Greg Fullard wrote:
>>>>>> Hi All
>>>>>> 
>>>>>> I see that there is some difference between how content
>>>>>> projects are
>>>>>> handled between the Sling IDE tools and the Maven archetypes.
>>>>>> 
>>>>>> 
>>>>>>  1. The "Sling Content Project" wizard creates a project with
>>>>>> a
>>>>>> jcr_root
>>>>>>  folder which then contains folders and content.xml files.
>>>>>> This is
>>>>>> very
>>>>>>  similar to what I'm used to with AEM Archetype 10.
>>>>> 
>>>>> In addition to what others have said, there is plan ( with no
>>>>> time
>>>>> commitment ) to add our own content-package Maven plugin, which
>>>>> would
>>>>> make this kind of project usable with Maven.
>>>>> 
>>>>> https://issues.apache.org/jira/browse/SLING-6081
>>>>> 
>>>>> Robert
>>>>> 
>>>>>>  2. The sling-initial-content-archetype, on the other hand,
>>>>>> generates a
>>>>>>  SLING-INF folder with an XML node descriptor file (as
>>>>>> explained at
>>>>>>  http://sling.apache.org/documentation/bundles/content-loading
>>>>>> -jcr-
>>>>>> contentloader.html
>>>>>>  )
>>>>>>  3. The Slingbucks example uses JSON descriptor files.
>>>>>> 
>>>>>> 
>>>>>> Obviously all these methods work, but I'm interested to get an
>>>>>> idea
>>>>>> of what
>>>>>> the recommended method is. Perhaps based on specific criteria
>>>>>> of my
>>>>>> project?
>>>>>> 
>>>>>> Much appreciated
>>>>>> 
>>>>>> Greg
>>>>>> 
>>> 
>>> 
>> 
> 



signature.asc
Description: Message signed with OpenPGP


Re: Different ways to define initial content :: Content.xml vs Json equivalent

2017-04-04 Thread Roy Teeuwen
Hey Andy,

The license inside might not be good enough ;)

Greets,
Roy
> On 3 Apr 2017, at 22:50, Andreas Schaefer  wrote:
> 
> Why is that necessary? The one from Adobe isn't good enough?
> 
> - Andy Schaefer
> 
>> On Apr 3, 2017, at 3:23 AM, Robert Munteanu  wrote:
>> 
>> Hi Greg,
>> 
>>> On Sat, 2017-04-01 at 13:18 +0200, Greg Fullard wrote:
>>> Hi All
>>> 
>>> I see that there is some difference between how content projects are
>>> handled between the Sling IDE tools and the Maven archetypes.
>>> 
>>> 
>>>   1. The "Sling Content Project" wizard creates a project with a
>>> jcr_root
>>>   folder which then contains folders and content.xml files. This is
>>> very
>>>   similar to what I'm used to with AEM Archetype 10.
>> 
>> In addition to what others have said, there is plan ( with no time
>> commitment ) to add our own content-package Maven plugin, which would
>> make this kind of project usable with Maven.
>> 
>> https://issues.apache.org/jira/browse/SLING-6081
>> 
>> Robert
>> 
>>>   2. The sling-initial-content-archetype, on the other hand,
>>> generates a
>>>   SLING-INF folder with an XML node descriptor file (as explained at
>>>   http://sling.apache.org/documentation/bundles/content-loading-jcr-
>>> contentloader.html
>>>   )
>>>   3. The Slingbucks example uses JSON descriptor files.
>>> 
>>> 
>>> Obviously all these methods work, but I'm interested to get an idea
>>> of what
>>> the recommended method is. Perhaps based on specific criteria of my
>>> project?
>>> 
>>> Much appreciated
>>> 
>>> Greg
>>> 
>> 



signature.asc
Description: Message signed with OpenPGP


Re: Fling Installation on Trunk

2017-04-01 Thread Roy Teeuwen
Hey Andreas,

You can make your own custom launchpads with a maven project.

In your pom.xml you use the following plugin:


org.apache.sling
slingstart-maven-plugin
true


Until sling 9 is released you use the following snapshot dependency, or you 
could also use sling version 8:


org.apache.sling
org.apache.sling.launchpad
9-SNAPSHOT
slingstart


Add a boot.txt in the directory src/main/provisioning containing the following 
info:

[feature name=:boot]

[artifacts]
org.apache.sling/org.apache.sling.launchpad/9-SNAPSHOT/slingstart

Add any txt file in the same directory to add your custom stuff you need. For 
example add a thymeleaf.txt containing:

[feature name=thymeleaf]

# Add the dependencies on the Model exporter
[artifacts]
   org.attoparser/attoparser/2.0.2.RELEASE
   org.unbescape/unbescape/1.1.4.RELEASE
   org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
   org.javassist/javassist/3.20.0-GA
   org.apache.sling/org.apache.sling.scripting.thymeleaf/1.1.1-SNAPSHOT

Now build your project, and in your target folder you will have your custom 
created launchpad jar

Greets,
Roy



> On 31 Mar 2017, at 23:39, Andreas Schaefer Sr.  wrote:
> 
> For something else I delved into Sling Provisioning and I
> came up with a way to import Thymeleaf. Not sure if  that
> is the best way but it seems to work.
> 
> When I add a file called thymeleaf.txt to 
> launchpad/builder/src/main/provisioning
> with that content:
> 
> [feature name=thymeleaf]
> 
> # Add the dependencies on the Model exporter
> [artifacts]
>org.attoparser/attoparser/2.0.2.RELEASE
>org.unbescape/unbescape/1.1.4.RELEASE
>org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
>org.javassist/javassist/3.20.0-GA
>org.apache.sling/org.apache.sling.scripting.thymeleaf/1.1.1-SNAPSHOT
> 
> Build and start sling (just the builder) I have thymeleaf installed and 
> prepped
> and ready.
> 
> So I am wondering if there is a better way or if I can create my own 
> provisioning
> models but keep them in a separate folder.
> 
> Thanks - Andy Schaefer
> 
>> On Mar 28, 2017, at 1:22 AM, Oliver Lietz  wrote:
>> 
>> On Monday 27 March 2017 13:05:38 Andreas Schaefer Sr. wrote:
>>> Hi
>>> 
>>> I tried to install Fling from the Samples but failed with the latest Sling.
>>> 
>>> First I had to install Sling Messaging and Sling Query but then
>>> I gave up on Sling Thymeleaf which has dependencies on
>>> com.fasterxml.jackson.ocre etc that are not deployed in Sling and it also
>>> looks like they are not deployed by any other bundle.
>>> 
>>> A sample does not much good if I cannot build and install it, right?
>> 
>> *sigh
>> 
>>> I am pretty fluent with package dependencies and so if I cannot
>>> figure it out in an acceptable time frame then who will.
>> 
>> Stop whining and start reading, please.
>> 
>>> Any pointers on how to get this working would be very much
>>> appreciated.
>> 
>> The version of Fling is 0.0.1-SNAPSHOT which clearly indicates that it is 
>> work
>> in progress. Fling itself depends on some snapshots namely Validation and
>> Messaging (and therefore has to be adjusted sometimes when those dependencies
>> do incompatible changes – see my latest commits). Fling's prerequisites are
>> listed in the README: 
>> https://github.com/apache/sling/tree/trunk/samples/fling
>> 
>> How to install Scripting Thymeleaf is described in its README (and btw.
>> Jackson is optional):
>> https://github.com/apache/sling/tree/trunk/contrib/scripting/org.apache.sling.scripting.thymeleaf
>> 
>> If you are unable to install those dependencies into Launchpad you can try
>> with Sling's Karaf Distribution:
>> https://github.com/apache/sling/tree/trunk/karaf
>> 
>> Start Karaf and open http://localhost:8181/system/console/features, install
>> sling-launchpad-oak-tar and sling-samples-fling by clicking the play/install
>> buttons on the right. Open http://localhost:8181/fling.html
>> 
>> O.
>> 
>>> Thanks - Andy Schaefer
>> 
> 



signature.asc
Description: Message signed with OpenPGP


Re: Sling Resource Rendering Inheritance

2017-03-23 Thread Roy Teeuwen
Hey Andreas,

My approach here is the following:

Libs is for libraries that enhance Sling => Composum is a library that is meant 
to be used to enhance Sling. They also give the benefit that when you package 
your library/module and let other developers use it, they can extend/override 
the actual libraries, like composum, by placing stuff under /apps/composum 
without having to actually change the code of the library itself in the /libs 
folder

Apps is for projects that use sling => A website for example. A website will 
normally not be extended, seeing as it is your own website, and you won't 
distribute that code to other developers for other projects.

I think for the most part this holds true.

Greets,
Roy
> On 23 Mar 2017, at 17:31, Andreas Schaefer Sr. <schaef...@me.com> wrote:
> 
> Hi Roy
> 
> Thanks for all your help.
> 
> At the end it turns out that I made a mistake when using the HTL include:
> 
> This was my first include:
> 
>
> 
> which fails. But using this:
> 
>
> 
> does work.
> 
> So on another node I saw some Sling apps (samples and Composum) that place
> their components under /libs instead of /apps.
> 
> In AEM developers were told not to put anything under /libs and now Sling it 
> going
> the other way. Is there a reason for this shift. As far as I know there’s no 
> difference.
> 
> Thanks for all your help - Andy
> 
>> On Mar 23, 2017, at 12:30 AM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>> Hey Andreas,
>> 
>> I am not sure why it is not working for you that way, but that should 
>> definitely still work, there is no dependency whatsoever to a folder being 
>> named "components", see my next examples:
>> 
>> page-example-2.zip: I moved everything right under /apps/idoneus, no 
>> /components => still works
>> page-example-3.zip: I moved everything to under /libs/idoneus => still works
>> 
>> https://www.dropbox.com/s/3d64tqd62wb81n9/page-example-2.zip?dl=1 
>> <https://www.dropbox.com/s/3d64tqd62wb81n9/page-example-2.zip?dl=1>
>> https://www.dropbox.com/s/tw0edw4dddi9ksh/page-example-3.zip?dl=1 
>> <https://www.dropbox.com/s/tw0edw4dddi9ksh/page-example-3.zip?dl=1>
>> 
>> Greets,
>> Roy
>> 
>>> On 22 Mar 2017, at 19:48, Andreas Schaefer Sr. <schaef...@me.com 
>>> <mailto:schaef...@me.com>> wrote:
>>> 
>>> Yeah, the have a big “Download Now” button and that is not the file.
>>> I think the reason was that I use Safari w/o Flash and then the link won’t 
>>> show.
>>> 
>>> That said your code words and the major difference I saw is that the 
>>> inheritance
>>> only works if it is in the /apps//components folder. I 
>>> tried
>>> that after I got mine working by copying the working resource type 
>>> definitions back
>>> up to /apps/.
>>> 
>>> This structure works:
>>> 
>>> /apps
>>> /testApps
>>> /components
>>> /home
>>> body.html
>>> /page
>>> body.html
>>>             page.html
>>> 
>>> The page.html has a HTL import of body.html and it will take the one from 
>>> actual
>>> resource type (here testApps/components/home).
>>> 
>>> Can anyone from the sling team verify that? If so why, where is that 
>>> defined and
>>> is that configurable?
>>> 
>>> I used the sling sample Fling as an example but that does not use 
>>> inheritance.
>>> 
>>> Thanks for you swift help - Andy Schaefer
>>> 
>>>> On Mar 22, 2017, at 11:05 AM, Roy Teeuwen <r...@teeuwen.be 
>>>> <mailto:r...@teeuwen.be>> wrote:
>>>> 
>>>> Hey Andreas,
>>>> 
>>>> Huh, I think you pushed the advertisement button or something, or maybe 
>>>> you have to click twice. Anyway, here, my dropbox:
>>>> 
>>>> https://www.dropbox.com/s/0sem7twkr5a2icp/page-example-1.zip?dl=1 
>>>> <https://www.dropbox.com/s/0sem7twkr5a2icp/page-example-1.zip?dl=1>
>>>> 
>>>> Greetings,
>>>> Roy
>>>>> On 22 Mar 2017, at 18:26, Andreas Schaefer <a...@headwire.com> wrote:
>>>>> 
>>>>> Hi Roy
>>>>> 
>>>>> I tried to download your example but I am not going to install
>>>>> an Installer software just to see a ZIP file.
>>>>> 
>

Re: Sling Resource Rendering Inheritance

2017-03-23 Thread Roy Teeuwen
Hey Andreas,

I am not sure why it is not working for you that way, but that should 
definitely still work, there is no dependency whatsoever to a folder being 
named "components", see my next examples:

page-example-2.zip: I moved everything right under /apps/idoneus, no 
/components => still works
page-example-3.zip: I moved everything to under /libs/idoneus => still works

https://www.dropbox.com/s/3d64tqd62wb81n9/page-example-2.zip?dl=1 
<https://www.dropbox.com/s/3d64tqd62wb81n9/page-example-2.zip?dl=1>
https://www.dropbox.com/s/tw0edw4dddi9ksh/page-example-3.zip?dl=1 
<https://www.dropbox.com/s/tw0edw4dddi9ksh/page-example-3.zip?dl=1>

Greets,
Roy

> On 22 Mar 2017, at 19:48, Andreas Schaefer Sr. <schaef...@me.com> wrote:
> 
> Yeah, the have a big “Download Now” button and that is not the file.
> I think the reason was that I use Safari w/o Flash and then the link won’t 
> show.
> 
> That said your code words and the major difference I saw is that the 
> inheritance
> only works if it is in the /apps//components folder. I 
> tried
> that after I got mine working by copying the working resource type 
> definitions back
> up to /apps/.
> 
> This structure works:
> 
> /apps
>   /testApps
>   /components
>   /home
>   body.html
>   /page
>   body.html
>   page.html
> 
> The page.html has a HTL import of body.html and it will take the one from 
> actual
> resource type (here testApps/components/home).
> 
> Can anyone from the sling team verify that? If so why, where is that defined 
> and
> is that configurable?
> 
> I used the sling sample Fling as an example but that does not use inheritance.
> 
> Thanks for you swift help - Andy Schaefer
> 
>> On Mar 22, 2017, at 11:05 AM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>> Hey Andreas,
>> 
>> Huh, I think you pushed the advertisement button or something, or maybe you 
>> have to click twice. Anyway, here, my dropbox:
>> 
>> https://www.dropbox.com/s/0sem7twkr5a2icp/page-example-1.zip?dl=1
>> 
>> Greetings,
>> Roy
>>> On 22 Mar 2017, at 18:26, Andreas Schaefer <a...@headwire.com> wrote:
>>> 
>>> Hi Roy
>>> 
>>> I tried to download your example but I am not going to install
>>> an Installer software just to see a ZIP file.
>>> 
>>> Can you share this file by any other means?
>>> 
>>> Thanks - Andy Schaefer
>>> 
>>>> On Mar 21, 2017, at 9:52 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> 
>>>> Hey Andreas,
>>>> 
>>>> I made an example package in sling-9, you can use composum to install the 
>>>> package.
>>>> 
>>>> http://www12.zippyshare.com/v/nWrL1Azm/file.html
>>>> 
>>>> It works for me, I made the following:
>>>> 
>>>> /apps/idoneus/components/page => contains page.html and header.html which 
>>>> does a data-sly-include of header.html
>>>> /apps/idoneus/components/home => supertype is page, and overwrites the 
>>>> header.html
>>>> /content/idoneus/en => is a homepage, you can see that the header now says 
>>>> "Header home page"
>>>> /content/indoneus/en/test-page => is a normal page, has as header "Header 
>>>> base page"
>>>> 
>>>> Can you verify the package and maybe share what is different, so that it 
>>>> also gets typed textual on the mailing list for future reference
>>>> 
>>>> Greets,
>>>> Roy
>>>> 
>>>> 
>>>> 
>>>>> On 21 Mar 2017, at 20:18, Andreas Schaefer <a...@headwire.com> wrote:
>>>>> 
>>>>> Hi
>>>>> 
>>>>> As a long time CQ / AEM backend developer I ran into some issues
>>>>> to adjust to Sling.
>>>>> 
>>>>> I have a resource ‘Home Page’ that should render a JCR node as
>>>>> a HTML page. The Home page component then only adjust
>>>>> the layout of the Body and Head and the rest should be inherited from
>>>>> its Resource Super Type “Page’. I tried that but it does not render
>>>>> without the home.html as well as the footer missing in Home is not
>>>>> picked up.
>>>>> 
>>>>> This is my configuration:
>>>>> 
>>>>> 1. JCR Content Node (/content/sample/home)
>&

Re: Sling Resource Rendering Inheritance

2017-03-22 Thread Roy Teeuwen
Hey Andreas,

Have you checked my example? Did you find the difference? Can you elaborate a 
bit more

Greets,
Roy
> On 22 Mar 2017, at 22:27, Andreas Schaefer <a...@headwire.com> wrote:
> 
> This also came from a Sling Sample (I think Fling but I am not sure).
> 
> But removing that is not enough. The only way to make it work is to place the 
> components in
> the folder ‘components’ under my apps folder.
> 
> - Andy
> 
>> On Mar 22, 2017, at 12:43 PM, Henry Saginor <hsaginor.apa...@gmail.com> 
>> wrote:
>> 
>> Hi Andreas
>> 
>> I was looking at the configuration you provided in your initial e-mail. I 
>> noticed that sling:resourceSuperType under your home page content node is 
>> different from what’s under component node (“sample” vs “sample/page”). Have 
>> you tried deleting this property from the content node? It should be 
>> sufficient to just have sling:resourceSuperType on the component node for 
>> inheritance to work correctly.
>> 
>> Henry
>> 
>>> On Mar 22, 2017, at 10:26 AM, Andreas Schaefer <a...@headwire.com> wrote:
>>> 
>>> Hi Roy
>>> 
>>> I tried to download your example but I am not going to install
>>> an Installer software just to see a ZIP file.
>>> 
>>> Can you share this file by any other means?
>>> 
>>> Thanks - Andy Schaefer
>>> 
>>>> On Mar 21, 2017, at 9:52 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> 
>>>> Hey Andreas,
>>>> 
>>>> I made an example package in sling-9, you can use composum to install the 
>>>> package.
>>>> 
>>>> http://www12.zippyshare.com/v/nWrL1Azm/file.html
>>>> 
>>>> It works for me, I made the following:
>>>> 
>>>> /apps/idoneus/components/page => contains page.html and header.html which 
>>>> does a data-sly-include of header.html
>>>> /apps/idoneus/components/home => supertype is page, and overwrites the 
>>>> header.html
>>>> /content/idoneus/en => is a homepage, you can see that the header now says 
>>>> "Header home page"
>>>> /content/indoneus/en/test-page => is a normal page, has as header "Header 
>>>> base page"
>>>> 
>>>> Can you verify the package and maybe share what is different, so that it 
>>>> also gets typed textual on the mailing list for future reference
>>>> 
>>>> Greets,
>>>> Roy
>>>> 
>>>> 
>>>> 
>>>>> On 21 Mar 2017, at 20:18, Andreas Schaefer <a...@headwire.com> wrote:
>>>>> 
>>>>> Hi
>>>>> 
>>>>> As a long time CQ / AEM backend developer I ran into some issues
>>>>> to adjust to Sling.
>>>>> 
>>>>> I have a resource ‘Home Page’ that should render a JCR node as
>>>>> a HTML page. The Home page component then only adjust
>>>>> the layout of the Body and Head and the rest should be inherited from
>>>>> its Resource Super Type “Page’. I tried that but it does not render
>>>>> without the home.html as well as the footer missing in Home is not
>>>>> picked up.
>>>>> 
>>>>> This is my configuration:
>>>>> 
>>>>> 1. JCR Content Node (/content/sample/home)
>>>>> 
>>>>> 
>>>>> http://www.jcp.org/jcr/1.0 
>>>>> <http://www.jcp.org/jcr/1.0>" xmlns:nt="http://www.jcp.org/jcr/nt/1.0 
>>>>> <http://www.jcp.org/jcr/nt/1.0>" 
>>>>> xmlns:sling="http://sling.apache.org/jcr/sling/1.0 
>>>>> <http://sling.apache.org/jcr/sling/1.0>"
>>>>> jcr:primaryType="nt:unstructured"
>>>>> jcr:title="Sample Home"
>>>>> jcr:description="Sample Home Page"
>>>>> sling:resourceType="sample/home"
>>>>> sling:resourceSuperType="sample"
>>>>> />
>>>>> 
>>>>> 2. Home Page configuration (/apps/sample/home):
>>>>> 
>>>>> 
>>>>> http://www.jcp.org/jcr/1.0 
>>>>> <http://www.jcp.org/jcr/1.0>" xmlns:nt="http://www.jcp.org/jcr/nt/1.0 
>>>>> <http://www.jcp.org/jcr/nt/1.0>" 
>>>>> xmlns:sling="http://sling.apache.org/jcr/sling/1.0 
>>>>> <http://sling

Re: How to create Rest APIs for non-JCR data in Sling 8??

2017-01-28 Thread Roy Teeuwen
Hey Oli,

Isnt that the whiteboard that I gave?
https://github.com/apache/aries-jax-rs-whiteboard 


Greets
Roy


> On 28 Jan 2017, at 09:43, olimination  wrote:
> 
> Hi Lance,
> 
> as Mike already mentioned the "Neba framework" offers you the full
> Spring power, meaning you can easily write Spring controllers which then
> for example inject your needed OSGi services and you then do whatever
> you need to do plus you have access to all the possibilities Spring
> offers you.
> 
> See doc here: http://neba.io/documentation.html#spring_mvc
> 
> Or as far as I know with OSGi R7 there will be support for JAX-RS.
> 
> See here: https://adapt.to/2016/en/schedule/osgi-r7.html
> 
> cheers,
> Oli
> 
> On 28.01.2017 07:23, Henry Saginor wrote:
>> Can’t you just create sling servlet registered to some resource type? 
>> You can then simply create JCR node(s) mapped to your resource type. 
>> You can also use a SynthaticResource via custom resource provider, which is 
>> the track you’re on and what Steven is suggesting. 
>> But I find that in most cases just creating a JCR node is more convenient 
>> and you can apply JCR ACLs to it control access if you need it. 
>> 
>>> On Jan 27, 2017, at 9:34 PM, Steven Walters  wrote:
>>> 
>>> On Sat, Jan 28, 2017 at 6:27 AM, lancedolan  wrote:
 Hi friends,
 
 I've tried routing questions through stackoverflow to cut down my mails to
 this list. I'm losing lots of time on this one, though, and am stuck.
 
 I need to create APIs which don't represent Sling Resources. Example:
 /services/images/123123123
 that image will exist somewhere else.
 
 Bertrand suggests creating a ResourceProvider, as in the example here [1].
 However, that uses the spi package which is not in version 2.9.0 of
 org.apache.sling.api, and thus, not available to me in Sling 8.
 
 I did find a ResourceProvider interface to implement though, and created
 this code:
 
 /**
 * Created by lancedolan on 1/27/17.
 */
 @Component
 @Service(value=ResourceProvider.class)
 @Properties({
   @Property(name = ResourceProvider.ROOTS, value = "things"),
   @Property(name = ResourceProvider.OWNS_ROOTS, value = "true")
 })
 public class ImageResourceProvider implements ResourceProvider {
 
   /** If this provider required a context this would be more elaborate,
*  but for this simple example we don't need one.
*/
   public static class DoesNotNeedAContext {
   };
 
   @Override
   public Resource getResource(ResourceResolver resourceResolver, String
 path) {
   Resource returnResource = new SyntheticResource(resourceResolver,
 path, "edlio/microservice/image");
   returnResource.getValueMap().put("myProp" , "myValue");
   return returnResource;
   }
 
   @Override
   public Resource getResource(ResourceResolver resourceResolver,
 HttpServletRequest httpServletRequest, String path) {
   return getResource(resourceResolver , path);
   }
 
   @Override
   public Iterator listChildren(Resource resource) {
   return null;
   }
 }
 
 
 The result is that I get a 403 response. How do I control the 
 authentication
 for resources that don't actually exist? The fact that I'm not getting 404
 means that my ResourceProvider is at least registering successfully.
 
 Finally, I'd much prefer to use Jersey if possible... Anybody have success
 getting Jersey to work in Sling 8? I dumped a bunch of time into it and 
 gave
 up after class not found errors for classes that should be found [2].
 
 The ultimate goal is just to provide a restful API in Sling 8 and the
 static-path-declaration of SlingSafeMethodsServlet just doesn't cut it.
 
 Thanks a million guys...
>>> 
>>> The Sling paradigm for this is to create resources through the
>>> resource provider,
>>> and then create/register a servlet to respond to the resource type
>>> you're creating (not a static path).
>>> 
>>> So from your above code, you'd create an additional servlet registered
>>> to the resourceType "edlio/microservice/image" (instead of registered
>>> to a static path) and implement GET inside it.
>>> 
>>> Without the corresponding servlet, this is most likely being served by
>>> the default GET servlet, which will not particularly understand how to
>>> deal with these resources, thus the errors.
>> 
>> 



Re: How to create Rest APIs for non-JCR data in Sling 8??

2017-01-27 Thread Roy Teeuwen
Hey Lance,

If you really want to use jax-rs, have a look at the following:
https://github.com/apache/aries-jax-rs-whiteboard 


Greets,
Roy

> On 27 Jan 2017, at 23:29, lancedolan  wrote:
> 
> These APIs I'm looking to build are likely to use other OSGI services I've
> written, and perhaps even write to the JCR for other reasons. Imagine doing
> a GET /api/images/my-new-image.jpg and the image lives in Amazon S3, but you
> want to write some audit data into the JCR.
> 
> I'm still thinking through the overall solution, and have considered you're
> suggestion, but I don't want to give up on building APIs inside of
> OSGI/Sling unless I really need to.
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/How-to-create-Rest-APIs-for-non-JCR-data-in-Sling-8-tp4069947p4069949.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



signature.asc
Description: Message signed with OpenPGP


Re: Using OSGi Mocks with OSGi DS annotations

2016-12-23 Thread Roy Teeuwen
Hey Stefan,

Cool! Nice to know, thanks :) Will definitely do that then

Greets,
Roy
> On 23 Dec 2016, at 11:28, Stefan Seifert <sseif...@pro-vision.de> wrote:
> 
> please note you can also mix sling mocks 1.x and osgi mocks 2.x if you are 
> using OSGi R6 in your application but still use an older sling version (e.g. 
> AEM 6.1).
> 
> this talks lists the possible version matrix combinations
> https://adapt.to/2016/en/schedule/unit-testing-with-sling-aem-mocks.html
> 
> sefan
> 
>> -----Original Message-
>> From: Roy Teeuwen [mailto:r...@teeuwen.be]
>> Sent: Wednesday, December 21, 2016 9:12 AM
>> To: users@sling.apache.org
>> Subject: Re: Using OSGi Mocks with OSGi DS annotations
>> 
>> Hey Robbert,
>> 
>> Aha okey that explains it, I'm still on the 1.x branch for now! I will have
>> to wait until I can do an upgrade to the new sling api, or maybe backport
>> the functionality, thanks!
>> 
>> Greets
>> Roy
>> 
>>> Op 21 dec. 2016 om 08:49 heeft Robert Munteanu <romb...@apache.org> het
>> volgende geschreven:
>>> 
>>> Hi Roy,
>>> 
>>>> On Tue, 2016-12-20 at 23:03 +0100, Roy Teeuwen wrote:
>>>> Hey all,
>>>> 
>>>> I am trying to use the osgi mocks in the following setup:
>>>> @Component
>>>> @Designate(ocd = ServiceImpl.Config.class)
>>>> public class ServiceImpl implements Service {
>>>> 
>>>>@ObjectClassDefinition
>>>>@interface Config {
>>>> 
>>>>String property() default "value";
>>>>}
>>>> 
>>>>private Config config;
>>>> 
>>>>@Activate
>>>>public void activate(Config config) {
>>>>this.config = config;
>>>>}
>>>> }
>>>> Test class:
>>>> service = context.registerInjectActivateService(new ServiceImpl(),
>>>> "property", "some-value");
>>>> But I am getting the following exception:
>>>> 
>>>> java.lang.RuntimeException: No matching activation method with name
>>>> 'activate'  found in class some.packagename.ServiceImpl
>>> 
>>> (snip)
>>> 
>>> Support for annotation classes as configuration was added with
>>> 
>>> https://issues.apache.org/jira/browse/SLING-5327
>>> 
>>> which is part of OSGi Mocks 2.0.0 . What version are you using?
>>> 
>>> Robert
> 
> 



Re: Using OSGi Mocks with OSGi DS annotations

2016-12-21 Thread Roy Teeuwen
Hey Robbert,

Aha okey that explains it, I'm still on the 1.x branch for now! I will have to 
wait until I can do an upgrade to the new sling api, or maybe backport the 
functionality, thanks!

Greets
Roy

> Op 21 dec. 2016 om 08:49 heeft Robert Munteanu <romb...@apache.org> het 
> volgende geschreven:
> 
> Hi Roy,
> 
>> On Tue, 2016-12-20 at 23:03 +0100, Roy Teeuwen wrote:
>> Hey all,
>> 
>> I am trying to use the osgi mocks in the following setup:
>> @Component
>> @Designate(ocd = ServiceImpl.Config.class)
>> public class ServiceImpl implements Service {
>> 
>> @ObjectClassDefinition
>> @interface Config {
>> 
>> String property() default "value";
>> }
>> 
>> private Config config;
>> 
>> @Activate
>> public void activate(Config config) {
>> this.config = config;
>> }
>> }
>> Test class:
>> service = context.registerInjectActivateService(new ServiceImpl(),
>> "property", "some-value");
>> But I am getting the following exception:
>> 
>> java.lang.RuntimeException: No matching activation method with name
>> 'activate'  found in class some.packagename.ServiceImpl
> 
> (snip)
> 
> Support for annotation classes as configuration was added with
> 
>  https://issues.apache.org/jira/browse/SLING-5327
> 
> which is part of OSGi Mocks 2.0.0 . What version are you using?
> 
> Robert


Using OSGi Mocks with OSGi DS annotations

2016-12-20 Thread Roy Teeuwen
Hey all,

I am trying to use the osgi mocks in the following setup:
@Component
@Designate(ocd = ServiceImpl.Config.class)
public class ServiceImpl implements Service {

@ObjectClassDefinition
@interface Config {

String property() default "value";
}

private Config config;

@Activate
public void activate(Config config) {
this.config = config;
}
}
Test class:
service = context.registerInjectActivateService(new ServiceImpl(), "property", 
"some-value");
But I am getting the following exception:

java.lang.RuntimeException: No matching activation method with name 'activate'  
found in class some.packagename.ServiceImpl

at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:157)
at 
org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:209)
at 
org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:220)
at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:160)
at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:174)

Is this a known issue or am I using it wrong?

Greets,
Roy

Re: Getting the context path of the application

2016-12-13 Thread Roy Teeuwen
Hey Felix,

Ah right, I see your point. Thanks for the clarification!

Greets,
Roy

> On 13 Dec 2016, at 09:03, Felix Meschberger <fmesc...@adobe.com> wrote:
> 
> Hi Roy
> 
> Yes, you can set the property like this. But this basically just becomes a 
> framework property which is used directly by the Felix Http Service Jetty 
> bundle. Having it as a command line option is merely a convenience.
> 
> Regards
> Felix
> 
>> Am 13.12.2016 um 08:57 schrieb Roy Teeuwen <r...@teeuwen.be>:
>> 
>> Hey Felix,
>> 
>> Yeah, my problem has been resolved :)! Just thinking out loud a bit here. 
>> 
>> Seeing as you can specify the context path with a launchpad command line 
>> option when starting the jar (-r path) and you can also specify it in the 
>> sling.properties file, I thought it might be a nice addition to the sling 
>> settings service to also be exposed in some way after startup. 
>> 
>> Greetings,
>> Roy
>> 
>>> On 13 Dec 2016, at 08:37, Felix Meschberger <fmesc...@adobe.com> wrote:
>>> 
>>> Hi Roy
>>> 
>>> While the approach sounds interesting with some caveats: It has the 
>>> whiteboard.listener property twice and it attaches to the default Http 
>>> Context which may or may not reflect Sling’s own servlet context (mostly it 
>>> does, but there is no guarantee). What you could do is use the 
>>> CONTEXT_SELECT property and select the org.apache.sling context.
>>> 
>>> But then, I don’t think we should expose the Servlet Context Path in the 
>>> Sling Settings. IMHO Sling Settings is about the Sling Application as a 
>>> whole and not a specific aspect of Sling.
>>> 
>>> And if the context path is properly exposed to your TransformerFactory, I 
>>> think you just have everything you need. As I expect your 
>>> TransformerFactory to only be used as part of request processing anyway, 
>>> right ?
>>> 
>>> Regards
>>> Felix
>>> 
>>>> Am 12.12.2016 um 22:07 schrieb Roy Teeuwen <r...@teeuwen.be>:
>>>> 
>>>> Hey Carsten,
>>>> 
>>>> Ok cool, thanks for the info! Maybe it would be useful to add the context 
>>>> path to the SlingSettingsService? I created an initial patch:
>>>> 
>>>> https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service
>>>>  
>>>> <https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service>
>>>> 
>>>> What do you think?
>>>> 
>>>> Greets,
>>>> Roy
>>>> 
>>>>> On 12 Dec 2016, at 16:14, Carsten Ziegeler <cziege...@apache.org> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> you either need a servlet request or servlet context, you can get a
>>>>> servlet context through the init method of a servlet or by registering a
>>>>> servlet context listener (assuming you use latest Sling which is using
>>>>> the http whiteboard).
>>>>> Other than those, I think there is no good way
>>>>> 
>>>>> Regards
>>>>> Carsten
>>>>> 
>>>>> Roy Teeuwen wrote
>>>>>> Hey all,
>>>>>> 
>>>>>> It seems I was able to fix it by using the sling request fro 
>>>>>> ProcessingContext that is available in the TransformerFactory init 
>>>>>> method :). 
>>>>>> But it would still be nice to know if it is possible to get the context 
>>>>>> path without a sling request!
>>>>>> 
>>>>>> Greets,
>>>>>> Roy
>>>>>> 
>>>>>> 
>>>>>>> On 9 Dec 2016, at 17:14, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>>>>> 
>>>>>>> Hey all,
>>>>>>> 
>>>>>>> I am trying to get the context path of the sling application somewhere 
>>>>>>> where I don't have a HttpServletRequest at hand, so I cant call 
>>>>>>> request.getContextPath(). 
>>>>>>> 
>>>>>>> More specifically I have a bug in a TransformerFactory that transforms 
>>>>>>> links to versioned clientlibs (acs-aem-commons 
>>>>>>> VersionedClientlibsTransformerFactory), but my application has a 
>>>>>>> context path, so this doesn't work. 
>>>>>>> I want to try and see if I can fix it myself and create a PR instead 
>>>>>>> reporting a bug, but I'm a bit lost in how to get the context path. 
>>>>>>> Anyone can help?
>>>>>>> 
>>>>>>> Greets,
>>>>>>> Roy
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> Carsten Ziegeler
>>>>> Adobe Research Switzerland
>>>>> cziege...@apache.org
>>>>> 
>>>> 
>>> 
>> 
> 



Re: Getting the context path of the application

2016-12-12 Thread Roy Teeuwen
Hey Felix,

Yeah, my problem has been resolved :)! Just thinking out loud a bit here. 

Seeing as you can specify the context path with a launchpad command line option 
when starting the jar (-r path) and you can also specify it in the 
sling.properties file, I thought it might be a nice addition to the sling 
settings service to also be exposed in some way after startup. 

Greetings,
Roy

> On 13 Dec 2016, at 08:37, Felix Meschberger <fmesc...@adobe.com> wrote:
> 
> Hi Roy
> 
> While the approach sounds interesting with some caveats: It has the 
> whiteboard.listener property twice and it attaches to the default Http 
> Context which may or may not reflect Sling’s own servlet context (mostly it 
> does, but there is no guarantee). What you could do is use the CONTEXT_SELECT 
> property and select the org.apache.sling context.
> 
> But then, I don’t think we should expose the Servlet Context Path in the 
> Sling Settings. IMHO Sling Settings is about the Sling Application as a whole 
> and not a specific aspect of Sling.
> 
> And if the context path is properly exposed to your TransformerFactory, I 
> think you just have everything you need. As I expect your TransformerFactory 
> to only be used as part of request processing anyway, right ?
> 
> Regards
> Felix
> 
>> Am 12.12.2016 um 22:07 schrieb Roy Teeuwen <r...@teeuwen.be>:
>> 
>> Hey Carsten,
>> 
>> Ok cool, thanks for the info! Maybe it would be useful to add the context 
>> path to the SlingSettingsService? I created an initial patch:
>> 
>> https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service
>>  
>> <https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service>
>> 
>> What do you think?
>> 
>> Greets,
>> Roy
>> 
>>> On 12 Dec 2016, at 16:14, Carsten Ziegeler <cziege...@apache.org> wrote:
>>> 
>>> Hi,
>>> 
>>> you either need a servlet request or servlet context, you can get a
>>> servlet context through the init method of a servlet or by registering a
>>> servlet context listener (assuming you use latest Sling which is using
>>> the http whiteboard).
>>> Other than those, I think there is no good way
>>> 
>>> Regards
>>> Carsten
>>> 
>>> Roy Teeuwen wrote
>>>> Hey all,
>>>> 
>>>> It seems I was able to fix it by using the sling request fro 
>>>> ProcessingContext that is available in the TransformerFactory init method 
>>>> :). 
>>>> But it would still be nice to know if it is possible to get the context 
>>>> path without a sling request!
>>>> 
>>>> Greets,
>>>> Roy
>>>> 
>>>> 
>>>>> On 9 Dec 2016, at 17:14, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>>> 
>>>>> Hey all,
>>>>> 
>>>>> I am trying to get the context path of the sling application somewhere 
>>>>> where I don't have a HttpServletRequest at hand, so I cant call 
>>>>> request.getContextPath(). 
>>>>> 
>>>>> More specifically I have a bug in a TransformerFactory that transforms 
>>>>> links to versioned clientlibs (acs-aem-commons 
>>>>> VersionedClientlibsTransformerFactory), but my application has a context 
>>>>> path, so this doesn't work. 
>>>>> I want to try and see if I can fix it myself and create a PR instead 
>>>>> reporting a bug, but I'm a bit lost in how to get the context path. 
>>>>> Anyone can help?
>>>>> 
>>>>> Greets,
>>>>> Roy
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> Carsten Ziegeler
>>> Adobe Research Switzerland
>>> cziege...@apache.org
>>> 
>> 
> 



Re: Getting the context path of the application

2016-12-12 Thread Roy Teeuwen
Hey Carsten,

Ok cool, thanks for the info! Maybe it would be useful to add the context path 
to the SlingSettingsService? I created an initial patch:

https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service
 
<https://github.com/apache/sling/compare/trunk...royteeuwen:feature/add-context-path-to-sling-settings-service>

What do you think?

Greets,
Roy

> On 12 Dec 2016, at 16:14, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> Hi,
> 
> you either need a servlet request or servlet context, you can get a
> servlet context through the init method of a servlet or by registering a
> servlet context listener (assuming you use latest Sling which is using
> the http whiteboard).
> Other than those, I think there is no good way
> 
> Regards
> Carsten
> 
> Roy Teeuwen wrote
>> Hey all,
>> 
>> It seems I was able to fix it by using the sling request fro 
>> ProcessingContext that is available in the TransformerFactory init method 
>> :). 
>> But it would still be nice to know if it is possible to get the context path 
>> without a sling request!
>> 
>> Greets,
>> Roy
>> 
>> 
>>> On 9 Dec 2016, at 17:14, Roy Teeuwen <r...@teeuwen.be> wrote:
>>> 
>>> Hey all,
>>> 
>>> I am trying to get the context path of the sling application somewhere 
>>> where I don't have a HttpServletRequest at hand, so I cant call 
>>> request.getContextPath(). 
>>> 
>>> More specifically I have a bug in a TransformerFactory that transforms 
>>> links to versioned clientlibs (acs-aem-commons 
>>> VersionedClientlibsTransformerFactory), but my application has a context 
>>> path, so this doesn't work. 
>>> I want to try and see if I can fix it myself and create a PR instead 
>>> reporting a bug, but I'm a bit lost in how to get the context path. Anyone 
>>> can help?
>>> 
>>> Greets,
>>> Roy
>> 
>> 
> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org
> 



Getting the context path of the application

2016-12-09 Thread Roy Teeuwen
Hey all,

I am trying to get the context path of the sling application somewhere where I 
don't have a HttpServletRequest at hand, so I cant call 
request.getContextPath(). 

More specifically I have a bug in a TransformerFactory that transforms links to 
versioned clientlibs (acs-aem-commons VersionedClientlibsTransformerFactory), 
but my application has a context path, so this doesn't work. 
I want to try and see if I can fix it myself and create a PR instead reporting 
a bug, but I'm a bit lost in how to get the context path. Anyone can help?

Greets,
Roy

PAXExam vs Sling Teleporter (vs Sling Mocks)

2016-12-04 Thread Roy Teeuwen
Hello all,

I have been going through the code base of Apache Sling and it is clear there 
are so many ways to test the code, you have two different bundles for PAX Exam 
(org.apache.sling.testing.paxexam and org.apache.sling.paxexam.util), you have 
the Teleporter and you also have the Sling Mocks. It makes me wonder in what is 
the criteria to choose between these three different ways of testing your code. 
When would you say it is enough to use Sling Mocks, where you can even go for a 
real OAK JCR based ResourceResolver, or when would you go for PAX Exam or the 
Teleporter? What are the benefits of doing your integration tests with 
Teleporter vs PAX Exam?

Thanks for any clarifications!
Greetings,
Roy

Use of namespaces in node names

2016-11-13 Thread Roy Teeuwen
Hey all,

Could anyone explain me what the benefit is of using node (or property) names 
that contain a namespace, instead of just using nodetypes to force rules on 
what can be placed on certain nodes? For example for the context aware config 
there has been chosen to call the node sling:settings and the property 
sling:configRef, or in AEM they use cq:dialog, cq:template and cq:editConfig 
Does this give any advantage over just using a normal node name with a custom 
primaryType? I have noticed you can not use arbitrarily namespaces if they 
haven't been registered, for example trying to make a node named custom:node 
will throw a RepositoryException if custom is not registered, so they 
definitely get checked specifically.

Thanks!
Greetings,
Roy

Re: Creating a service user for your own bundle

2016-11-07 Thread Roy Teeuwen
Hey Oliver,

Forcing a user of a bundle to go and look up the git project to find the 
README.md to see which permissions are needed doesn't sound like a good 
solution for me, it should be present somehow in the built jar from the maven 
central repo. So I would also go for the manifest file here like Carsten 
proposed.

I can follow that the provide capability could be something more of a nice to 
have seeing as Carsten said in his first reply, it should be the user who puts 
up the mapping between the users and the bundles that need the service users. 
But he should of course know that he needs to do this, hence the need for the 
require capability.

Greetings,
Roy


> On 7 Nov 2016, at 10:05, Oliver Lietz <apa...@oliverlietz.de> wrote:
> 
> On Monday 07 November 2016 07:58:33 Carsten Ziegeler wrote:
>> Roy Teeuwen wrote
> 
> Hi Roy,
> 
>>> Hey Carsten,
>>> 
>>> Thanks for the info, I will definitely follow up on the progress of what
>>> you are making then :).
>>> 
>>> One remark though, you say it's not the task of the bundle developer to
>>> create the user and assigning the rights. I can follow in this, but this
>>> also means that the potential users of the bundle you create has to know
>>> exactly the name of the service user and the rights required for the
>>> bundle to work.
> 
> which service user is mapped to the bundle is not important – but it has to 
> be 
> a service user with sufficient permissions.
> To ensure a user mapping is present for your component before getting 
> activated use ServiceUserMapped[1].
> 
> Which permissions (JCR ACLs) are required by a bundle should be documented in 
> the module's README but for now you have to look at provisioning model in 
> launchpad/builder.
> 
>>> Is there going to be some sort of mechanism (like the
>>> require-capability header) to tell the users of the bundle what the
>>> needed user and rights are? Maybe even a webconsole plugin showing which
>>> bundles aren't satisfied
>> That's indeed a good point, so far we don't have any mechanism here.
>> Defining the requirement is easy and we could add an entry to the
>> manifest of a bundle if the bundle requires a service user including the
>> sub module names.
>> 
>> The problematic part is providing the capability as these can't be
>> dynamically created and added to a module at runtime. For example, it
>> would not be possible that the Oak implementation bundle adds the
>> provide capabilities entries based on the available service users.
>> 
>> I think the only option we have is using OSGi services as these are
>> dynamic and requirements can be easily expressed through services. I
>> don't have any good idea on how to do this with service users, but I
>> should definitely be possible and I agree that we should provide
>> something like this.
> 
> We would have to observe the repository for all system users' ACLs and 
> provide 
> both as capabilities (or services) – is it worth the effort?
> 
> Regards,
> O.
> 
> [1] 
> https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermapping/ServiceUserMapped.html
>  
> <https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermapping/ServiceUserMapped.html>
> 
>> Regards
>> 
>> Carsten



Re: Creating a service user for your own bundle

2016-11-06 Thread Roy Teeuwen
Hey Carsten,

Thanks for the info, I will definitely follow up on the progress of what you 
are making then :).

One remark though, you say it's not the task of the bundle developer to create 
the user and assigning the rights. 
I can follow in this, but this also means that the potential users of the 
bundle you create has to know exactly the name of the service user and the 
rights required for the bundle to work. 
Is there going to be some sort of mechanism (like the require-capability 
header) to tell the users of the bundle what the needed user and rights are? 
Maybe even a webconsole plugin showing which bundles aren't satisfied 

Greetings,
Roy

> On 6 Nov 2016, at 09:51, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> Roy Teeuwen wrote
>> Hey all,
>> 
>> Seeing as it is now best practice to not use the getAdminResourceResolver 
>> anymore but go for the getServiceResourceResolver, what is the best way to 
>> have a bundle on it's own create the service user that belongs to the 
>> bundle. I know you can put the 
>> org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-mybundle.xml
>>  in the SLING-INF folder, but this only creates the mapping of the service 
>> user for your bundle, not the actual user. I have seen some mails about the 
>> repo init interface, but if I understand this correctly then that interface 
>> is fired on startup and before the jcr repository is live as osgi service. 
>> What then when you want to install a bundle that creates a service user for 
>> itself after the instance is already live?
>> 
> 
> I think the best way to do this is doing it outside of the bundle.
> Creating a service user, assigning rights to the user and associating
> this with a bundle is not the task of the bundle developer.
> 
> The easiest way to create a service user including the required OSGi
> configurations and ACLs is the provisioning model using the repoinit part.
> 
> At the moment, this requires to add all this info to the launchpad
> provisioning model you have and therefore is nothing you can do at
> runtime. But I'm working on a tool which exactly allows this. So you can
> put a provisioning model into an install folder and it will install
> everything contained in that model including repoinit stuff.
> 
> Carsten
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org
> 



Creating a service user for your own bundle

2016-11-05 Thread Roy Teeuwen
Hey all,

Seeing as it is now best practice to not use the getAdminResourceResolver 
anymore but go for the getServiceResourceResolver, what is the best way to have 
a bundle on it's own create the service user that belongs to the bundle. I know 
you can put the 
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-mybundle.xml
 in the SLING-INF folder, but this only creates the mapping of the service user 
for your bundle, not the actual user. I have seen some mails about the repo 
init interface, but if I understand this correctly then that interface is fired 
on startup and before the jcr repository is live as osgi service. What then 
when you want to install a bundle that creates a service user for itself after 
the instance is already live?

Greetings,
Roy

Custom HTL attributes

2016-10-31 Thread Roy Teeuwen
Hello all,

With the refactoring of the HTL bundle into multiple bundles and opening the 
API's, is it now yet possible to create custom HTL attributes, or is this still 
not feasible?

Greetings,
Roy

Re: Including attributes with Sightly/HTL

2016-10-31 Thread Roy Teeuwen
Hey Vlad,

Ok thanks for the info, I guess I will have to solve it in another way then!

Greets,
Roy
> On 28 Oct 2016, at 14:33, Vlad Bailescu <v...@bailescu.ro> wrote:
> 
> Hi Roy,
> 
> HTL does not allow arbitrary inclusion of scripts output. The scripts
> output for data-sly-include is appended to the current element content. The
> proper way to add attributes would be to use data-sly-attribute and provide
> the attributes from a Use API object and not from an external script.
> 
> That said, for your example it would probably be nicer to throw a parsing
> error instead of simply passing through/ignoring the  fragments.
> 
> Vlad
> 
> On Fri, Oct 28, 2016 at 3:20 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
>> To clarify further, because a part of the script was missng:
>> 
>> I am doing >  >  The following
>> output is created (see the wrongly put sly tag):
>> 
>> 
>> data-analytics-page-id=“page id"
>> data-analytics-page-type=“page-type"
>> 
>> 
>> Greetings,
>> Roy
>>> On 28 Oct 2016, at 13:39, Roy Teeuwen <r...@teeuwen.be> wrote:
>>> 
>>> Hey all,
>>> 
>>> When using HTL, how does one include attributes in a div when it’s
>> coming from another script? In jsp we would be able to do it like the
>> following:
>>> 
>>>  >>
>>>> 
>>> 
>>> This doesn’t seem possible in sightly in a way I can find?
>>> 
>>> Greetings,
>>> Roy
>> 
>> 



Re: Including attributes with Sightly/HTL

2016-10-28 Thread Roy Teeuwen
To clarify further, because a part of the script was missng:

I am doing  >  The following output is 
created (see the wrongly put sly tag):


 data-analytics-page-id=“page id"
 data-analytics-page-type=“page-type"


Greetings,
Roy
> On 28 Oct 2016, at 13:39, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Hey all,
> 
> When using HTL, how does one include attributes in a div when it’s coming 
> from another script? In jsp we would be able to do it like the following:
> 
>
>> 
> 
> This doesn’t seem possible in sightly in a way I can find?
> 
> Greetings,
> Roy



Including attributes with Sightly/HTL

2016-10-28 Thread Roy Teeuwen
Hey all,

When using HTL, how does one include attributes in a div when it’s coming from 
another script? In jsp we would be able to do it like the following:


>

This doesn’t seem possible in sightly in a way I can find?

Greetings,
Roy

Re: Migrating from JSP to HTL/Sightly

2016-10-18 Thread Roy Teeuwen
Hey all,

Sorry for the bump, there is also a second issue that I would like to ask 
concerning the migration from JSP to HTL. We have versioned resource types in 
folders concerning the release date. For example 
/apps/myapp/1702/components/mycomponent

Now when switching to sightly, we get following exception:

org.apache.sling.scripting.sightly.impl.compiler.CompilerException: 
org.apache.sling.scripting.sightly.impl.compiler.CompilerException: 
org.apache.sling.scripting.sightly.impl.compiler.CompilerException: Compilation 
errors in apps/myapp/1702/components/mycomponent/SightlyJava_main.java:
Line 19, column 971 : The declared package "apps.myapp" does not match the 
expected package "apps.myapp.1702.components.mycomponent"
Line 19, column 981 : Syntax error on token ".1702", delete this token
at 
org.apache.sling.scripting.sightly.impl.compiler.SightlyJavaCompilerService.compileSource(SightlyJavaCompilerService.java:143)

I guess this is because it translates the folders to package names, and 1702 is 
not a valid package identifier, but why isn’t it throwing this exception then 
in all your already existing jsp components? And is there a workaround for this 
or should I register a bug.

Greetings,
Roy
> On 12 Oct 2016, at 18:11, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Hey all,
> 
> For one of our current projects, we are in the process of making all the new 
> components/templates in HTL instead of JSP. One of the things we did notice 
> though is that when we use a component as resourceSuperType that still uses 
> jsp, that in those jsp files we use the following as stated on how to use it 
> in the docs[1]:
> 
> 
> 
> This makes it that we can’t overwrite the myscript.jsp file by a 
> myscript.html file because the script call specifically states myscript.jsp. 
> Now I tried it out by removing the .jsp extension from the script attribute, 
> and this seems to work! 
> So my question now is, is there a reason not to do it this way? Why is it 
> stated in the docs that you should say myscript.jsp instead of just myscript, 
> seeing as myscript alone already works too and would have made it possible to 
> overwrite the specific scripts by other template engines.
> 
> Greetings,
> Roy
> 
> [1] 
> https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call
>  
> <https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call>


Re: XPath Query

2016-10-11 Thread Roy Teeuwen
Hey Julian,

No, because then you get as result from the query the some-component, what I 
want the result returned by the query to be the element cq:PageContent (that 
contains a parsys with some-component on)

Greets,
Roy
> On 11 Oct 2016, at 14:54, Julian Sedding <jsedd...@gmail.com> wrote:
> 
> Hi Roy
> 
> I see, thanks for the pointer. I didn't know that was allowed in XPath.
> 
> Glad you got a solution. I'm almost certain that the following would
> also work: 
> /jcr:root/content/site//element(*,cq:PageContent)/parsys/some-component
> for your case.
> 
> Regards
> Julian
> 
> 
> On Tue, Oct 11, 2016 at 1:44 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> Hey Julian,
>> 
>> This is standard XPath and worked in JCR 2, for example if you look at these 
>> samples provided by microsoft:
>> https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx 
>> <https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx>
>> book[excerpt] : All  elements that contain at least one  
>> element child.
>> 
>> A real life used example:  
>> /jcr:root/content/site//element(*,cq:PageContent)[parsys/some-component] to 
>> select pages with a specific component in the parsys
>> But they gave me a workable solution in the oak-dev channel, although it 
>> should still work in the old way according to xpath :)
>> 
>> The solution they provided:  something like 
>> /jcr:root/content/site//element(*,cq:PageContent)[parsys/some-component/@jcr:primaryType]
>> 
>> Greetings,
>> Roy
>> 
>>> On 11 Oct 2016, at 11:54, Julian Sedding <jsedd...@gmail.com> wrote:
>>> 
>>> Not sure why this worked in JR2 (and whether that was a  bug or a feature).
>>> 
>>> IMO you need to test for /jcr:root//*[fn:name() = 'test'] (or if there
>>> are no other conditions simply /jcr:root//test).
>>> 
>>> Regards
>>> Julian
>>> 
>>> 
>>> On Mon, Oct 10, 2016 at 1:14 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> Hey all,
>>>> 
>>>> I’m not really getting a reply in the oak-dev channel, so I might as well 
>>>> also try here because I’m trying it in a sling application :)
>>>> 
>>>> When doing the following XPath query in JCR 2, it would select me all the 
>>>> nodes that has a subnode named test. But since upgrading to oak, this 
>>>> query does not work anymore. Is there a reason this stopped working or a 
>>>> way to make it work again
>>>> 
>>>> Some query example:
>>>> /jcr:root//*[test] or 
>>>> /jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin' 
>>>> and test]
>>>> 
>>>> Greetings,
>>>> Roy
>> 



Re: XPath Query

2016-10-11 Thread Roy Teeuwen
Hey Julian,

This is standard XPath and worked in JCR 2, for example if you look at these 
samples provided by microsoft:
https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx 
<https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx>
book[excerpt] : All  elements that contain at least one  element 
child.

A real life used example:  
/jcr:root/content/site//element(*,cq:PageContent)[parsys/some-component] to 
select pages with a specific component in the parsys
But they gave me a workable solution in the oak-dev channel, although it should 
still work in the old way according to xpath :)

The solution they provided:  something like 
/jcr:root/content/site//element(*,cq:PageContent)[parsys/some-component/@jcr:primaryType]
 

Greetings,
Roy

> On 11 Oct 2016, at 11:54, Julian Sedding <jsedd...@gmail.com> wrote:
> 
> Not sure why this worked in JR2 (and whether that was a  bug or a feature).
> 
> IMO you need to test for /jcr:root//*[fn:name() = 'test'] (or if there
> are no other conditions simply /jcr:root//test).
> 
> Regards
> Julian
> 
> 
> On Mon, Oct 10, 2016 at 1:14 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> Hey all,
>> 
>> I’m not really getting a reply in the oak-dev channel, so I might as well 
>> also try here because I’m trying it in a sling application :)
>> 
>> When doing the following XPath query in JCR 2, it would select me all the 
>> nodes that has a subnode named test. But since upgrading to oak, this query 
>> does not work anymore. Is there a reason this stopped working or a way to 
>> make it work again
>> 
>> Some query example:
>> /jcr:root//*[test] or 
>> /jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin' 
>> and test]
>> 
>> Greetings,
>> Roy



XPath Query

2016-10-10 Thread Roy Teeuwen
Hey all,

I’m not really getting a reply in the oak-dev channel, so I might as well also 
try here because I’m trying it in a sling application :)

When doing the following XPath query in JCR 2, it would select me all the nodes 
that has a subnode named test. But since upgrading to oak, this query does not 
work anymore. Is there a reason this stopped working or a way to make it work 
again

Some query example:
/jcr:root//*[test] or 
/jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin' and 
test]

Greetings,
Roy

Re: Authentication handler

2016-10-04 Thread Roy Teeuwen
Hey Stefan,

Thanks! Exactly what I was looking for then ;)

Greets,
Roy
> On 4 Oct 2016, at 17:22, Stefan Seifert <sseif...@pro-vision.de> wrote:
> 
> when the repository is up and running the repository authentication is used 
> for web console as well.
> but during startup phase, or when the repository is down/unavailable the 
> authentication built into the web console itself takes place.
> 
> you need to change the admin password in the osgi config "Apache Felix OSGi 
> Management Console" as well. esp. on production systems or you have a 
> security leak if the repository is not available for whatever reason.
> 
> stefan
> 
>> -Original Message-
>> From: Roy Teeuwen [mailto:r...@teeuwen.be]
>> Sent: Tuesday, October 4, 2016 4:45 PM
>> To: users@sling.apache.org
>> Subject: Authentication handler
>> 
>> Hey all,
>> 
>> When starting up our sling instance, if you go to /system/console in the
>> VERY beginning (like 1-3 seconds after doing a startup), it is possible to
>> log in with admin/admin, even when the admin password has been changed to
>> something else.
>> What bundle has to come active for this hardcoded default login not to work
>> anymore?
>> 
>> Greetings,
>> Roy
> 



Authentication handler

2016-10-04 Thread Roy Teeuwen
Hey all,

When starting up our sling instance, if you go to /system/console in the VERY 
beginning (like 1-3 seconds after doing a startup), it is possible to log in 
with admin/admin, even when the admin password has been changed to something 
else. 
What bundle has to come active for this hardcoded default login not to work 
anymore?

Greetings,
Roy

Adding jcr:created date to resource

2016-09-20 Thread Roy Teeuwen
Hello all,

I am trying to create an nt:unstructured resource programatically, which 
contains a jcr:created property, but I don’t seem to find a way to add this 
programatically, nor how to add a jcr:mixinType (which would make it possible).

I tried the following, but it isn’t working:

Resource myResource = resourceResolver.getResource("/myresource");
Map properties = new HashMap();
properties.put("jcr:primaryType", "nt:unstructured”);
properties.put("jcr:mixinTypes", new NameValue[] 
{NameValue.valueOf("mix:created")});
properties.put(“jcr:created”, Calendar.getInstance());
Resource dummy = resourceResolver.create(myResource, "dummy", properties);
resourceResolver.commit();

I get the following exception:

java.lang.IllegalArgumentException: Value can't be stored in the repository: 
org.apache.jackrabbit.value.NameValue@0


Can anyone tell me on how to add this on creation time?

Thanks!
Roy

Re: Sling models adaptTo taglib

2016-08-22 Thread Roy Teeuwen
Hey Jason,

I do agree with it, I just don’t know what Adobe’s support model is when you 
upgrade jar’s that have been provided by their product instead of asking for a 
hotfix package or something. 
Thats why I tend not to upgrade those bundles myself.

Greetings,
Roy
> On 22 Aug 2016, at 15:06, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> IMHO the big selling point of OSGi, is the ability to add additional packages 
> as you go. If the package is needing an api of a particular version that 
> isn't in your environment it just won't turn on.
> 
> If the bundle is defined correctly, which I admit, seems to be a difficult 
> thing to do. Then the version of the bundle is less important then the 
> package version of the api's that it exports.
> 
> -Jason
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
> Sent: Saturday, August 20, 2016 8:28 AM
> To: users@sling.apache.org
> Subject: Re: Sling models adaptTo taglib
> 
> Hey Dan,
> 
> Ok cool, thanks, I guess it is indeed just a patch version upgrade from 2.2.4 
> to 2.2.6, so it’s worth a shot :)!
> 
> Greets
> Roy
>> On 19 Aug 2016, at 15:00, Daniel Klco <dk...@apache.org> wrote:
>> 
>> Roy,
>> 
>> You can pretty safely upgrade the version of Sling Taglibs without 
>> upgrading the overall application version. If you include the newer 
>> version of the bundle into your build package in a folder like 
>> /apps/[app-name]/install, Sling will pick up the more recent version 
>> of the bundle and install it. If you have any issues, you can force 
>> Sling to recompile the JSP's from the OSGi console.
>> 
>> Regards,
>> Dan
>> 
>> On Fri, Aug 19, 2016 at 7:37 AM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>>> Hey Júnior,
>>> 
>>> Thanks!
>>> 
>>> Darnit, it seems that I will have to wait until after the upgrade to 
>>> AEM
>>> 6.2 ;).
>>> 
>>> Greets,
>>> Roy
>>> 
>>> 
>>>> On 19 Aug 2016, at 13:34, Júnior <fjunio...@gmail.com> wrote:
>>>> 
>>>> Hi Roy,
>>>> 
>>>> There is an Issue about the problem you are facing:
>>>> 
>>>> https://issues.apache.org/jira/browse/SLING-5653
>>>> 
>>>> And it seems to be fixed. Not sure in which version it is included.
>>>> 
>>>> Thanks
>>>> 
>>>> 
>>>> 2016-08-19 8:25 GMT-03:00 Roy Teeuwen <r...@teeuwen.be>:
>>>> 
>>>>> Hello all,
>>>>> 
>>>>> I am trying to use the sling models taglib, and I am using the 
>>>>> following
>>>>> input:
>>>>> 
>>>>> <%@ page import=“my.packages.TestModel" %>
>>>>> 
>>>>> >>>> var="model"/>
>>>>> ${model.testString}
>>>>> 
>>>>> 
>>>>> But when doing this, I get the following exception:
>>>>> 
>>>>> java.lang.ClassCastException: java.lang.Object cannot be cast to 
>>>>> java.lang.String
>>>>>  at javax.servlet.jsp.tagext.TagData.getAttributeString(
>>>>> TagData.java:138)
>>>>>  at org.apache.sling.scripting.jsp.taglib.tei.AdaptToTEI.
>>>>> getClassName(AdaptToTEI.java:26)
>>>>>  at org.apache.sling.scripting.jsp.taglib.tei.AbstractVarTEI.
>>>>> getVariableInfo(AbstractVarTEI.java:78)
>>>>> I would expect this to work? Is there any way I could get it to 
>>>>> work
>>> like
>>>>> this? It is nicer if I can import it so that my IDE has a clearer 
>>>>> sight
>>> of
>>>>> which classes are used in the jsp’s instead of having to write the
>>> class as
>>>>> a plain string form:
>>>>> 
>>>>> >>>> var="model"/>
>>>>> ${model.testString}
>>>>> 
>>>>> (I am used to working with slice from cognifide, and am not trying 
>>>>> out sling models, in slice you could say >>>> class=“<%=TestModel.class%>”/> without calling the getName but just
>>> using
>>>>> the class object )
>>>>> 
>>>>> Thanks!
>>>>> Roy
>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Francisco Ribeiro
>>>> *SCEA|SCJP|SCWCD|IBM Certified SOA Associate*
>>> 
>>> 
> 



Re: Sling models adaptTo taglib

2016-08-20 Thread Roy Teeuwen
Hey Dan,

Ok cool, thanks, I guess it is indeed just a patch version upgrade from 2.2.4 
to 2.2.6, so it’s worth a shot :)!

Greets
Roy
> On 19 Aug 2016, at 15:00, Daniel Klco <dk...@apache.org> wrote:
> 
> Roy,
> 
> You can pretty safely upgrade the version of Sling Taglibs without
> upgrading the overall application version. If you include the newer version
> of the bundle into your build package in a folder like
> /apps/[app-name]/install, Sling will pick up the more recent version of the
> bundle and install it. If you have any issues, you can force Sling to
> recompile the JSP's from the OSGi console.
> 
> Regards,
> Dan
> 
> On Fri, Aug 19, 2016 at 7:37 AM, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
>> Hey Júnior,
>> 
>> Thanks!
>> 
>> Darnit, it seems that I will have to wait until after the upgrade to AEM
>> 6.2 ;).
>> 
>> Greets,
>> Roy
>> 
>> 
>>> On 19 Aug 2016, at 13:34, Júnior <fjunio...@gmail.com> wrote:
>>> 
>>> Hi Roy,
>>> 
>>> There is an Issue about the problem you are facing:
>>> 
>>> https://issues.apache.org/jira/browse/SLING-5653
>>> 
>>> And it seems to be fixed. Not sure in which version it is included.
>>> 
>>> Thanks
>>> 
>>> 
>>> 2016-08-19 8:25 GMT-03:00 Roy Teeuwen <r...@teeuwen.be>:
>>> 
>>>> Hello all,
>>>> 
>>>> I am trying to use the sling models taglib, and I am using the following
>>>> input:
>>>> 
>>>> <%@ page import=“my.packages.TestModel" %>
>>>> 
>>>> >>> var="model"/>
>>>> ${model.testString}
>>>> 
>>>> 
>>>> But when doing this, I get the following exception:
>>>> 
>>>> java.lang.ClassCastException: java.lang.Object cannot be cast to
>>>> java.lang.String
>>>>   at javax.servlet.jsp.tagext.TagData.getAttributeString(
>>>> TagData.java:138)
>>>>   at org.apache.sling.scripting.jsp.taglib.tei.AdaptToTEI.
>>>> getClassName(AdaptToTEI.java:26)
>>>>   at org.apache.sling.scripting.jsp.taglib.tei.AbstractVarTEI.
>>>> getVariableInfo(AbstractVarTEI.java:78)
>>>> I would expect this to work? Is there any way I could get it to work
>> like
>>>> this? It is nicer if I can import it so that my IDE has a clearer sight
>> of
>>>> which classes are used in the jsp’s instead of having to write the
>> class as
>>>> a plain string form:
>>>> 
>>>> >>> var="model"/>
>>>> ${model.testString}
>>>> 
>>>> (I am used to working with slice from cognifide, and am not trying out
>>>> sling models, in slice you could say >>> class=“<%=TestModel.class%>”/> without calling the getName but just
>> using
>>>> the class object )
>>>> 
>>>> Thanks!
>>>> Roy
>>> 
>>> 
>>> 
>>> 
>>> --
>>> Francisco Ribeiro
>>> *SCEA|SCJP|SCWCD|IBM Certified SOA Associate*
>> 
>> 



Sling models adaptTo taglib

2016-08-19 Thread Roy Teeuwen
Hello all,

I am trying to use the sling models taglib, and I am using the following input:

<%@ page import=“my.packages.TestModel" %>


${model.testString}


But when doing this, I get the following exception:

java.lang.ClassCastException: java.lang.Object cannot be cast to 
java.lang.String
at javax.servlet.jsp.tagext.TagData.getAttributeString(TagData.java:138)
at 
org.apache.sling.scripting.jsp.taglib.tei.AdaptToTEI.getClassName(AdaptToTEI.java:26)
at 
org.apache.sling.scripting.jsp.taglib.tei.AbstractVarTEI.getVariableInfo(AbstractVarTEI.java:78)
I would expect this to work? Is there any way I could get it to work like this? 
It is nicer if I can import it so that my IDE has a clearer sight of which 
classes are used in the jsp’s instead of having to write the class as a plain 
string form:


${model.testString}

(I am used to working with slice from cognifide, and am not trying out sling 
models, in slice you could say ”/> without calling the getName but just using the 
class object )

Thanks!
Roy

Re: Getting the actual resource from a request

2016-08-01 Thread Roy Teeuwen
Hey Jason,

That would solve the selector problem, but it wouldn't really solve the suffix 
problem though. But that one can be fixed in the same way although I would 
expect the whitelisting to be a bit tougher in that one ;), seeing as suffix is 
used as a dynamic variable most of the times. For my specific needs I did solve 
it now by actually looking at the request and seeing if the modification date 
equals the actual asset modification date. Thanks for all the help!

Resource resource = request.getResource();
if(resource instanceof NonExistingResource) {
LOG.info("Asset resource {} using the cdn selector does not exist", 
resource.getPath());
response.sendError(404);
} else if(!"last-modified".equals(getSuffixSegment(request, 0))) {
LOG.info("Asset resource {} is not using the last modified suffix", 
resource.getPath());
response.sendError(404);
} else if(resource.adaptTo(Asset.class) == null) {
LOG.info("Resource {} is not an asset", resource.getPath());
response.sendError(404);
} else 
if(!String.valueOf(((Asset)resource.adaptTo(Asset.class)).getLastModified()).equals(getSuffixSegment(request,
 1))) {
LOG.info("Asset resource {} does not have the same last modified date as 
request: {}", resource.getPath(), getSuffixSegment(request, 1));
response.sendError(404);
} else {
RequestDispatcherOptions opts = new RequestDispatcherOptions();
opts.setReplaceSelectors("");
RequestDispatcher dispatcher = request.getRequestDispatcher(resource, opts);
if(dispatcher != null) {
dispatcher.forward(request, response);
} else {
LOG.error("Could not get request dispatcher for asset resource {}", 
resource.getPath());
}
}

Greets
Roy

> On 1 Aug 2016, at 16:26, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> If we're talking dispatcher, then yes, this is the wrong list :) However if 
> we focus on the general concern, which is that as a by-product of its design. 
> There is an inherent exploit which can result in DOS attack when using a 
> cache.
> 
> One solution might be a generic selector filter, one that can accept a list 
> of patterns to whitelist or blacklist.
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
> Sent: Saturday, July 30, 2016 6:58 AM
> To: users@sling.apache.org
> Subject: Re: Getting the actual resource from a request
> 
> Hey Jason,
> 
> Just come back to the dispatcher caching problem you saw. I think this is 
> actually a global problem that happens anywhere, is there any rule in the 
> dispatcher to be able stop this? Just to look at a fun real life example:
> 
> http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png
>  
> <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png>
> http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg
>  
> <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg>
> http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg
>  
> <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg>
> 
> It seems to make a new image in the dispatcher cache for every request. But I 
> guess we would be on the wrong list to discuss something like this ;)
> 
> Greets
> Roy
> 
> 
>> On 29 Jul 2016, at 15:04, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>> Hey Jason,
>> 
>> You are absolutely right, damn :)! It’s because I didn’t realise that the 
>> .jpg didn’t count as extension. I’m going to keep it with a suffix though: 
>> /content/dam/nice-image.jpg.cdn./mod-date/20160815/nice-image.jpg just so 
>> that in the browser it still looks like the image is called nice-image.jpg 
>> ;). 
>> 
>> And you are also right about the second part, sadly enough :P. So maybe it 
>> would be safe to make the servlet after all, so that I can check the 
>> mod-date suffix part and see if that asset actually exists with that last 
>> modified date and only return it then, and else return a 404. This would 
>> solve the caching possibility of infinite image issue!
>> 
>> Thanks
>> Roy
>> 
>> 
>>> On 29 Jul 2016, at 14:31, Jason Bailey <jason.bai...@sas.com> wrote:
>>> 
>>> Roy,
>>> 
>>> I think you may slap your forehead on this one :)  You had to 
>>> implement a service because when you added t

Re: Getting the actual resource from a request

2016-07-30 Thread Roy Teeuwen
Hey Jason,

Just come back to the dispatcher caching problem you saw. I think this is 
actually a global problem that happens anywhere, is there any rule in the 
dispatcher to be able stop this? Just to look at a fun real life example:

http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png
 
<http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png>
http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg
 
<http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg>
http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg
 
<http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg>

It seems to make a new image in the dispatcher cache for every request. But I 
guess we would be on the wrong list to discuss something like this ;)

Greets
Roy


> On 29 Jul 2016, at 15:04, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Hey Jason,
> 
> You are absolutely right, damn :)! It’s because I didn’t realise that the 
> .jpg didn’t count as extension. I’m going to keep it with a suffix though: 
> /content/dam/nice-image.jpg.cdn./mod-date/20160815/nice-image.jpg just so 
> that in the browser it still looks like the image is called nice-image.jpg 
> ;). 
> 
> And you are also right about the second part, sadly enough :P. So maybe it 
> would be safe to make the servlet after all, so that I can check the mod-date 
> suffix part and see if that asset actually exists with that last modified 
> date and only return it then, and else return a 404. This would solve the 
> caching possibility of infinite image issue!
> 
> Thanks
> Roy
> 
> 
>> On 29 Jul 2016, at 14:31, Jason Bailey <jason.bai...@sas.com> wrote:
>> 
>> Roy,
>> 
>> I think you may slap your forehead on this one :)  You had to implement a 
>> service because when you added the cdn between the image name and the jpeg. 
>> It broke the resource resolution. That's why you had problems with the 
>> request.getResource()
>> 
>> Once you fixed it by moving the selector, the resource is identified. That 
>> means, it's found the image. You don't need to have a service. The Sling 
>> application will take your URL, identify the resource and return that 
>> resource.
>> 
>> So if all you did was just append  .%timestamp$.  to the end of your assets 
>> it will do what you want it do
>> 
>> content/dam/nice-image.jpg.20160815.
>> 
>> This is a nice idea for cdn's but you need to be aware of a potential issue. 
>> I know, from a dispatcher point of view that the ability to add selectors to 
>> any resource and return the original resource is a potential attack vector.  
>> An example would be if that url you gave was behind a dispatcher that does 
>> caching. I could sit there and call that asset with a millisecond time stamp 
>> and each time I did it, it would be cached, and the cache would get larger. 
>> Until some point I have consumed all of your disk space. 
>> 
>> I'm assuming a similar type issue with cdn's
>> 
>> -Jason
>> 
>> -Original Message-
>> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
>> Sent: Friday, July 29, 2016 8:14 AM
>> To: users@sling.apache.org
>> Subject: Re: Getting the actual resource from a request
>> 
>> Hey all,
>> 
>> Ok so I fixed it finally by doing the following:
>> 
>> @SlingServlet(
>>   resourceTypes = "sling/servlet/default",
>>   selectors = "cdn"
>> )
>> @Service({Servlet.class})
>> public class CDNAssetServlet extends SlingSafeMethodsServlet {
>> 
>>   private static final Logger LOG = 
>> LoggerFactory.getLogger(CDNAssetServlet.class);
>> 
>>   @Override
>>   protected void doGet(SlingHttpServletRequest request, 
>> SlingHttpServletResponse response) throws ServletException, IOException {
>>   Resource resource = request.getResource();
>>   if (resource instanceof NonExistingResource) {
>>   LOG.info("Asset resource {} using the cdn selector does not 
>> exist", resource.getPath());
>>   response.sendError(HttpServletResponse.SC_NOT_FOUND);
>>   } else {
>>   RequestDispatcherOptions opts = new RequestDispatcherOptions();
>>   opts.setReplaceSelectors("");
>>   RequestDi

Re: Getting the actual resource from a request

2016-07-29 Thread Roy Teeuwen
Hey Jason,

You are absolutely right, damn :)! It’s because I didn’t realise that the .jpg 
didn’t count as extension. I’m going to keep it with a suffix though: 
/content/dam/nice-image.jpg.cdn./mod-date/20160815/nice-image.jpg just so that 
in the browser it still looks like the image is called nice-image.jpg ;). 

And you are also right about the second part, sadly enough :P. So maybe it 
would be safe to make the servlet after all, so that I can check the mod-date 
suffix part and see if that asset actually exists with that last modified date 
and only return it then, and else return a 404. This would solve the caching 
possibility of infinite image issue!

Thanks
Roy


> On 29 Jul 2016, at 14:31, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> Roy,
> 
> I think you may slap your forehead on this one :)  You had to implement a 
> service because when you added the cdn between the image name and the jpeg. 
> It broke the resource resolution. That's why you had problems with the 
> request.getResource()
> 
> Once you fixed it by moving the selector, the resource is identified. That 
> means, it's found the image. You don't need to have a service. The Sling 
> application will take your URL, identify the resource and return that 
> resource.
> 
> So if all you did was just append  .%timestamp$.  to the end of your assets 
> it will do what you want it do
> 
> content/dam/nice-image.jpg.20160815.
> 
> This is a nice idea for cdn's but you need to be aware of a potential issue. 
> I know, from a dispatcher point of view that the ability to add selectors to 
> any resource and return the original resource is a potential attack vector.  
> An example would be if that url you gave was behind a dispatcher that does 
> caching. I could sit there and call that asset with a millisecond time stamp 
> and each time I did it, it would be cached, and the cache would get larger. 
> Until some point I have consumed all of your disk space. 
> 
> I'm assuming a similar type issue with cdn's
> 
> -Jason
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
> Sent: Friday, July 29, 2016 8:14 AM
> To: users@sling.apache.org
> Subject: Re: Getting the actual resource from a request
> 
> Hey all,
> 
> Ok so I fixed it finally by doing the following:
> 
> @SlingServlet(
>resourceTypes = "sling/servlet/default",
>selectors = "cdn"
> )
> @Service({Servlet.class})
> public class CDNAssetServlet extends SlingSafeMethodsServlet {
> 
>private static final Logger LOG = 
> LoggerFactory.getLogger(CDNAssetServlet.class);
> 
>@Override
>protected void doGet(SlingHttpServletRequest request, 
> SlingHttpServletResponse response) throws ServletException, IOException {
>Resource resource = request.getResource();
>if (resource instanceof NonExistingResource) {
>LOG.info("Asset resource {} using the cdn selector does not 
> exist", resource.getPath());
>response.sendError(HttpServletResponse.SC_NOT_FOUND);
>} else {
>RequestDispatcherOptions opts = new RequestDispatcherOptions();
>opts.setReplaceSelectors("");
>RequestDispatcher dispatcher = 
> request.getRequestDispatcher(resource, opts);
>if (dispatcher != null) {
>dispatcher.forward(request, response);
>} else {
>LOG.error("Could not get request dispatcher for asset resource 
> {}", resource.getPath());
>}
>}
>}
> }
> 
> And then using the url provided by Jason :) thanks!
> @Olivier
> Still don’t know what you meant by just serving the resource instead of 
> forwarding it, if you have an example you can still give it for when it would 
> be more performant/better.
> Thanks all,
> Greets
> Roy
> 
> 
> 
>> On 29 Jul 2016, at 00:01, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>> Also lastly to combine with my previous mail, it doesn’t have to be 
>> only images. It could also be pdf’s, zips,… So the approach I am using 
>> now won’t work in all the cases I want :)
>> 
>> 
>>> On 28 Jul 2016, at 23:44, Roy Teeuwen <r...@teeuwen.be> wrote:
>>> 
>>> Hey Jason, Olivier,
>>> 
>>> @Jason:
>>> Damn, I feel so stupid now :D indeed, using 
>>> /content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg 
>>> fixes everything. I don’t have to implement the nonexistingservlet anymore 
>>> ;), I was indeed thinking that jpg was the extension and so that the cdn 
>>> HAD to be before the jpg because else the cdn would be t

Re: Getting the actual resource from a request

2016-07-29 Thread Roy Teeuwen
Hey all,

Ok so I fixed it finally by doing the following:

@SlingServlet(
resourceTypes = "sling/servlet/default",
selectors = "cdn"
)
@Service({Servlet.class})
public class CDNAssetServlet extends SlingSafeMethodsServlet {

private static final Logger LOG = 
LoggerFactory.getLogger(CDNAssetServlet.class);

@Override
protected void doGet(SlingHttpServletRequest request, 
SlingHttpServletResponse response) throws ServletException, IOException {
Resource resource = request.getResource();
if (resource instanceof NonExistingResource) {
LOG.info("Asset resource {} using the cdn selector does not exist", 
resource.getPath());
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
RequestDispatcherOptions opts = new RequestDispatcherOptions();
opts.setReplaceSelectors("");
RequestDispatcher dispatcher = 
request.getRequestDispatcher(resource, opts);
if (dispatcher != null) {
dispatcher.forward(request, response);
} else {
LOG.error("Could not get request dispatcher for asset resource 
{}", resource.getPath());
}
}
}
}

And then using the url provided by Jason :) thanks!
@Olivier
Still don’t know what you meant by just serving the resource instead of 
forwarding it, if you have an example you can still give it for when it would 
be more performant/better.
Thanks all,
Greets
Roy



> On 29 Jul 2016, at 00:01, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Also lastly to combine with my previous mail, it doesn’t have to be only 
> images. It could also be pdf’s, zips,… So the approach I am using now won’t 
> work in all the cases I want :)
> 
> 
>> On 28 Jul 2016, at 23:44, Roy Teeuwen <r...@teeuwen.be> wrote:
>> 
>> Hey Jason, Olivier,
>> 
>> @Jason:
>> Damn, I feel so stupid now :D indeed, using 
>> /content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg 
>> fixes everything. I don’t have to implement the nonexistingservlet anymore 
>> ;), I was indeed thinking that jpg was the extension and so that the cdn HAD 
>> to be before the jpg because else the cdn would be the extension, but your 
>> explanation makes sense!
>> 
>> @Olivier:
>> "What's the reason for forwarding instead of reading/serving the resource 
>> from the repository in your current servlet?” Currently I am doing it like 
>> that, but I find the implementation a bit nasty… See how I did it:
>> 
>> @Override
>> protected void doGet(SlingHttpServletRequest request, 
>> SlingHttpServletResponse response) throws ServletException, IOException {
>> Resource resource = request.getResource();
>> final Image image = new Image(resource);
>> image.set(Image.PN_REFERENCE, resource.getPath());
>> try {
>> final String mimeType = image.getMimeType();
>> final Layer layer = image.getLayer(false, false, false);
>> double quality = mimeType.equals(MIME_TYPE_GIF) ? 255 : 1.0;
>> response.setContentType(mimeType);
>> layer.write(mimeType, quality, response.getOutputStream());
>> response.getOutputStream().flush();
>> } catch (RepositoryException e) {
>> LOG.error("could not get layer", e);
>> }
>> }
>> 
>> Thats why I would think it would be easier / nicer to just forward it to the 
>> normal jpg handling servlet so that I don’t actually have to manually write 
>> it to the servlet response output. If there is a better way in serving the 
>> image resource from the repo, do tell :D.
>> 
>> (For when you might be curious on why I am doing all of this, I am adding 
>> the latest modification date to all the image urls because the image urls 
>> actually get served by a cdn in front that proxies to the dam: 
>> https://some.azureedge.net/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg
>>  , this way when the same image gets replaced in the dam by a new image with 
>> the same name on a page, I don’t have to invalidate the azure cdn cache 
>> because the modification date changing in the url takes care of that, and 
>> because I am not using a query string I also don’t have to care about 
>> nullifying the browser client-side caching)
>> 
>> Thanks so far!
>> Greets,
>> Roy
>> 
>> 
>>> On 28 Jul 2016, at 23:02, Jason Bailey <jason.bai...@sas.com> wrote:
>>> 
>>> I was going to say that you shouldn't need to implement NonExistingResource 
>>> interface because a selector wouldn't impact res

Re: Getting the actual resource from a request

2016-07-28 Thread Roy Teeuwen
Also lastly to combine with my previous mail, it doesn’t have to be only 
images. It could also be pdf’s, zips,… So the approach I am using now won’t 
work in all the cases I want :)


> On 28 Jul 2016, at 23:44, Roy Teeuwen <r...@teeuwen.be> wrote:
> 
> Hey Jason, Olivier,
> 
> @Jason:
> Damn, I feel so stupid now :D indeed, using 
> /content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg 
> fixes everything. I don’t have to implement the nonexistingservlet anymore 
> ;), I was indeed thinking that jpg was the extension and so that the cdn HAD 
> to be before the jpg because else the cdn would be the extension, but your 
> explanation makes sense!
> 
> @Olivier:
> "What's the reason for forwarding instead of reading/serving the resource 
> from the repository in your current servlet?” Currently I am doing it like 
> that, but I find the implementation a bit nasty… See how I did it:
> 
> @Override
> protected void doGet(SlingHttpServletRequest request, 
> SlingHttpServletResponse response) throws ServletException, IOException {
> Resource resource = request.getResource();
> final Image image = new Image(resource);
> image.set(Image.PN_REFERENCE, resource.getPath());
> try {
> final String mimeType = image.getMimeType();
> final Layer layer = image.getLayer(false, false, false);
> double quality = mimeType.equals(MIME_TYPE_GIF) ? 255 : 1.0;
> response.setContentType(mimeType);
> layer.write(mimeType, quality, response.getOutputStream());
> response.getOutputStream().flush();
> } catch (RepositoryException e) {
> LOG.error("could not get layer", e);
> }
> }
> 
> Thats why I would think it would be easier / nicer to just forward it to the 
> normal jpg handling servlet so that I don’t actually have to manually write 
> it to the servlet response output. If there is a better way in serving the 
> image resource from the repo, do tell :D.
> 
> (For when you might be curious on why I am doing all of this, I am adding the 
> latest modification date to all the image urls because the image urls 
> actually get served by a cdn in front that proxies to the dam: 
> https://some.azureedge.net/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg
>  
> <https://some.azureedge.net/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg>
>  , this way when the same image gets replaced in the dam by a new image with 
> the same name on a page, I don’t have to invalidate the azure cdn cache 
> because the modification date changing in the url takes care of that, and 
> because I am not using a query string I also don’t have to care about 
> nullifying the browser client-side caching)
> 
> Thanks so far!
> Greets,
> Roy
> 
> 
>> On 28 Jul 2016, at 23:02, Jason Bailey <jason.bai...@sas.com 
>> <mailto:jason.bai...@sas.com>> wrote:
>> 
>> I was going to say that you shouldn't need to implement NonExistingResource 
>> interface because a selector wouldn't impact resolution then I had one of 
>> those blinding aha moments.
>> 
>> In the case of the url you posted you aren't adding a selector, you are 
>> modifying the resource name.  '/content/dam/nice-image.jpg' does not have an 
>> extension in the traditional sense, in the traditional sling sense the 
>> resource would actually be '/content/dam/nice-image' and jpg would be a 
>> handler that would return the asset as a jpeg. 
>> 
>> So when you are adding a selector to it it's not matching anything because 
>> there is no '/content/dam/nice-image' resource to match against.
>> 
>> So first make your request find the resource without the servlet in the way. 
>> If you switch around the .cdn to the end and add a period at the end of cdn 
>> like this... 
>> 
>> content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg
>> 
>> This should work to return the original nice-image.jpg at that point it 
>> should be easier to create a servlet that will have the resource as part of 
>> the request.
>> 
>> Or optionally you could try adding a sling:resourceType to the image and 
>> have a selector within that resource type that does what you need it do.
>> 
>> -Jason
>> 
>> 
>> 
>> -Original Message-
>> From: Roy Teeuwen [mailto:r...@teeuwen.be <mailto:r...@teeuwen.be>] 
>> Sent: Thursday, July 28, 2016 3:17 PM
>> To: users@sling.apache.org <mailto:users@sling.apache.org>
>> Subject: Re: Getting the actual resource from a request
>> 
>> Hmm Sorry Jason,
>> 
>

Re: Getting the actual resource from a request

2016-07-28 Thread Roy Teeuwen
Hey Jason, Olivier,

@Jason:
Damn, I feel so stupid now :D indeed, using 
/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg 
fixes everything. I don’t have to implement the nonexistingservlet anymore ;), 
I was indeed thinking that jpg was the extension and so that the cdn HAD to be 
before the jpg because else the cdn would be the extension, but your 
explanation makes sense!

@Olivier:
"What's the reason for forwarding instead of reading/serving the resource from 
the repository in your current servlet?” Currently I am doing it like that, but 
I find the implementation a bit nasty… See how I did it:

@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse 
response) throws ServletException, IOException {
Resource resource = request.getResource();
final Image image = new Image(resource);
image.set(Image.PN_REFERENCE, resource.getPath());
try {
final String mimeType = image.getMimeType();
final Layer layer = image.getLayer(false, false, false);
double quality = mimeType.equals(MIME_TYPE_GIF) ? 255 : 1.0;
response.setContentType(mimeType);
layer.write(mimeType, quality, response.getOutputStream());
response.getOutputStream().flush();
} catch (RepositoryException e) {
LOG.error("could not get layer", e);
}
}

Thats why I would think it would be easier / nicer to just forward it to the 
normal jpg handling servlet so that I don’t actually have to manually write it 
to the servlet response output. If there is a better way in serving the image 
resource from the repo, do tell :D.

(For when you might be curious on why I am doing all of this, I am adding the 
latest modification date to all the image urls because the image urls actually 
get served by a cdn in front that proxies to the dam: 
https://some.azureedge.net/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg
 
<https://some.azureedge.net/content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg>
 , this way when the same image gets replaced in the dam by a new image with 
the same name on a page, I don’t have to invalidate the azure cdn cache because 
the modification date changing in the url takes care of that, and because I am 
not using a query string I also don’t have to care about nullifying the browser 
client-side caching)

Thanks so far!
Greets,
Roy


> On 28 Jul 2016, at 23:02, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> I was going to say that you shouldn't need to implement NonExistingResource 
> interface because a selector wouldn't impact resolution then I had one of 
> those blinding aha moments.
> 
> In the case of the url you posted you aren't adding a selector, you are 
> modifying the resource name.  '/content/dam/nice-image.jpg' does not have an 
> extension in the traditional sense, in the traditional sling sense the 
> resource would actually be '/content/dam/nice-image' and jpg would be a 
> handler that would return the asset as a jpeg. 
> 
> So when you are adding a selector to it it's not matching anything because 
> there is no '/content/dam/nice-image' resource to match against.
> 
> So first make your request find the resource without the servlet in the way. 
> If you switch around the .cdn to the end and add a period at the end of cdn 
> like this... 
> 
> content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg
> 
> This should work to return the original nice-image.jpg at that point it 
> should be easier to create a servlet that will have the resource as part of 
> the request.
> 
> Or optionally you could try adding a sling:resourceType to the image and have 
> a selector within that resource type that does what you need it do.
> 
> -Jason
> 
> 
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
> Sent: Thursday, July 28, 2016 3:17 PM
> To: users@sling.apache.org
> Subject: Re: Getting the actual resource from a request
> 
> Hmm Sorry Jason,
> 
> I might have had to notice that I am extending SlingSafeMethodServlet but 
> also implementing the following servlet:
> https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/commons/servlets/NonExistingResourceServlet.html
> 
> And as it states in the docs itself, it also says:
>  public boolean accepts(SlingHttpServletRequest request) {
>  // get non-existing path (incl. selectors and extension!)
>  String path = request.getResource().getPath();
>  // return true if this servlet can handle this path
>  return true;
>  }
> 
> So probably it’s not possible to do it through this interface in without 
> manually parseing :) It also says in the docs: Please note: This is a 
> temporary solution until Sling provides a built-in 

Re: Getting the actual resource from a request

2016-07-28 Thread Roy Teeuwen
Already tried that one ;) it returns a non existing resource with the path 
/content/dam/nice-image.cdn.jpg/modification-date/20160815/nice-image.jpg

Greetings,
Roy
> On 28 Jul 2016, at 18:35, Jason Bailey <jason.bai...@sas.com> wrote:
> 
> I'm under the understanding that it is;
> 
> request.getResource().getPath()
> 
> -Original Message-
> From: Roy Teeuwen [mailto:r...@teeuwen.be] 
> Sent: Thursday, July 28, 2016 12:31 PM
> To: users@sling.apache.org
> Subject: Getting the actual resource from a request
> 
> Hey all,
> 
> I am creating a SlingServlet that will work by both using a selector and a 
> suffix. The resource is for example /content/dam/image.jpg and the actual url 
> will be 
> /content/dam/nice-image.cdn.jpg/modification-date/20160815/nice-image.jpg
> 
> What is the most easy way to get the actual resource path again from the 
> SlingHttpServletRequest? Currently I am doing the following but I find it a 
> bit cumbersome:
> 
> private String getResourcePath(SlingHttpServletRequest request) {
>String requestUrl = request.getRequestPathInfo().getResourcePath();
>int endIndex = 
> requestUrl.lastIndexOf(request.getRequestPathInfo().getSuffix());
>String resourcePathWithSelector = requestUrl.substring(0, endIndex);
>endIndex = 
> resourcePathWithSelector.lastIndexOf(request.getRequestPathInfo().getSelectorString()
>  + "." + request.getRequestPathInfo().getExtension());
>return resourcePathWithSelector.substring(0, endIndex) + 
> request.getRequestPathInfo().getExtension();
> }
> 
> Is there an easier way or is parsing it like this the only way?
> 
> Also after I got the actual resourcePath, I tried doing the following, but 
> this doesn’t seem to work, any clue on why? 
> 
> @Override
> protected void doGet(SlingHttpServletRequest request, 
> SlingHttpServletResponse response) throws ServletException, IOException {
>  RequestDispatcherOptions opts = new RequestDispatcherOptions();
>  opts.setReplaceSelectors("");
>  String resourcePath = getResourcePath(request);
>  RequestDispatcher dispatcher = 
> request.getRequestDispatcher(resourcePath, opts);
>  if (dispatcher != null) {
>  dispatcher.forward(request, response);
>  }
> }
> 
> I would expect that the previous would actually just forward it to the actual 
> image being fetched from the getResourcePath but it just gives me a 404 not 
> found (I checked the getResourcePath and it does return 
> /content/dam/nice-image.jpg)
> 
> Thanks!
> Roy



Getting the actual resource from a request

2016-07-28 Thread Roy Teeuwen
Hey all,

I am creating a SlingServlet that will work by both using a selector and a 
suffix. The resource is for example /content/dam/image.jpg and the actual url 
will be 
/content/dam/nice-image.cdn.jpg/modification-date/20160815/nice-image.jpg

What is the most easy way to get the actual resource path again from the 
SlingHttpServletRequest? Currently I am doing the following but I find it a bit 
cumbersome:

private String getResourcePath(SlingHttpServletRequest request) {
String requestUrl = request.getRequestPathInfo().getResourcePath();
int endIndex = 
requestUrl.lastIndexOf(request.getRequestPathInfo().getSuffix());
String resourcePathWithSelector = requestUrl.substring(0, endIndex);
endIndex = 
resourcePathWithSelector.lastIndexOf(request.getRequestPathInfo().getSelectorString()
 + "." + request.getRequestPathInfo().getExtension());
return resourcePathWithSelector.substring(0, endIndex) + 
request.getRequestPathInfo().getExtension();
}

Is there an easier way or is parsing it like this the only way?

Also after I got the actual resourcePath, I tried doing the following, but this 
doesn’t seem to work, any clue on why? 

@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse 
response) throws ServletException, IOException {
  RequestDispatcherOptions opts = new RequestDispatcherOptions();
  opts.setReplaceSelectors("");
  String resourcePath = getResourcePath(request);
  RequestDispatcher dispatcher = request.getRequestDispatcher(resourcePath, 
opts);
  if (dispatcher != null) {
  dispatcher.forward(request, response);
  }
 }

I would expect that the previous would actually just forward it to the actual 
image being fetched from the getResourcePath but it just gives me a 404 not 
found (I checked the getResourcePath and it does return 
/content/dam/nice-image.jpg)

Thanks!
Roy

Re: One Resource to multiple views in different locations

2016-07-16 Thread Roy Teeuwen
Hey Vkum,

We use osgi configs per site for this :). We define per sitename the fallback 
roots (so that would in your example be site1 and if not available fall back to 
generic)

Greets
Roy
> On 14 Jul 2016, at 14:48, vkum14  wrote:
> 
> Hi Roy,
> 
> My apology here if I asked the same information. You have been great help
> :). 
> I guess the only thing which is still not clear (and might be either I was
> not able to explain or I didn't get it right) to me is the 2nd point in my
> email below. I got your point on using a separate resourceType and that
> works great but what about the following scenario:
> 1. resourceType is changed from /apps/site/components/comp1 to
> /apps/site1/components/comp1 based on request for a page under site1.
> 2. My scripts reside in 2 folders than just one:
> a) //site1/components/comp1
> b) //generic/components/comp1
> and I want to use all the scripts under these 2 folders to be used in
> weighted alogorith for sling to find the best match, I am not sure how to do
> that. I am thinking to use ResoureProvider here like ResourceMerger does.
> Thanks so much again for all the help.
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062556.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



Re: One Resource to multiple views in different locations

2016-07-14 Thread Roy Teeuwen
Hey Vkmag,

I only showed you like two lines ;) of course the handling of this is a lot 
more than this. There is a check that they both inherit from the same 
/apps/site-common/components/header component, with a fallback to the 
site-common header component and stuff like that. You can all do that, thats up 
to you to figure out what requirements you have :D

Greetings,
Roy
> On 14 Jul 2016, at 11:09, vkum14 <vkuma...@sapient.com> wrote:
> 
> Yes but my use case demands to do the same with same component as to avoid 
> defining a new component when more brands come onboard. Have you done that 
> sort of something as well?
> 
> VINEET KUMAR
> Sr. Specialist
> -
> SapientNitro
> Gurgaon Infospace Limited SEZ, Ground Floor, Tower A, Building 2,
> Sector 21, Old Delhi-Gurgaon Road, Dundahera
> Gurgaon 122 016
> Haryana, India
> 
> desk  +91-124-676-7695
> mobile  +91-88-609-99936
> 
> The information transmitted is intended only for the person or entity to 
> which it is addressed and may contain confidential and/or privileged 
> material. Any review, retransmission, dissemination or other use of, or 
> taking of any action in reliance upon, this information by persons or 
> entities other than the intended recipient is prohibited. If you received 
> this in error, please contact the sender and delete the material from any 
> computer.
> 
> From: Roy Teeuwen [via Apache Sling] 
> [mailto:ml-node+s73963n4062546...@n3.nabble.com]
> Sent: Thursday, July 14, 2016 2:37 PM
> To: Vineet Kumar
> Subject: Re: One Resource to multiple views in different locations
> 
> Two components, as you can clearly see I said we have a component at 
> /apps/siteA/components/header and /apps/siteB/components/header
> 
>> On 14 Jul 2016, at 10:28, vkum14 <[hidden 
>> email]> wrote:
>> 
>> Sounds good. One quick qns- did you have 2 components or one component since
>> you seem to be playing around with resourcetype?
>> 
>> 
>> 
>> --
>> View this message in context: 
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062545.html
>> Sent from the Sling - Users mailing list archive at Nabble.com.
> 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062546.html
> To unsubscribe from One Resource to multiple views in different locations, 
> click 
> here<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code=4061093=dmt1bWFyMTRAc2FwaWVudC5jb218NDA2MTA5M3wyNTc5NzAxODA=>.
> NAML<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer=instant_html%21nabble%3Aemail.naml=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062548.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



Re: One Resource to multiple views in different locations

2016-07-13 Thread Roy Teeuwen
Hey Vkum,

We had the exact same problem, two sites, siteA and siteB, where there was a 
livecopy from siteA to siteB, but siteB had some specific header and footer 
components and stuff like that. How we solved this is by creating a filter that 
went over the resources of the request and when we detected that there was a 
specific implementation of a component for siteB, then we force this supertype.

So for example you have /apps/siteA/components/header and 
/apps/siteB/components/header. If we are in siteB and we see that there is a 
resourceType on the exact same location as the siteA/components/header for 
siteB: siteB/components/header, then we replace it:
final RequestDispatcherOptions requestDispatcherOptions = new 
RequestDispatcherOptions();
requestDispatcherOptions.setForceResourceType(siteSpecificResourceType);
Greets
Roy
> On 13 Jul 2016, at 19:02, vkum14  wrote:
> 
> Ohhh now I see what you are saying. Makes sense for simple use cases but here 
> your breadcrumb is taking the responsibility of figuring out what script to 
> load. Consider for use cases where in you have to identify script based on 
> selector, extn etc, you will end up replicating what sling does very well. I 
> would like to leverage same capability here so if I could tell sling to use 
> scripts from different set of folders, nothing better than that.
> 
> On Jul 13, 2016 9:23 PM, "Jason Bailey [via Apache Sling]" 
>  > wrote:
>> 
>> I've never needed to have the resource resolver select a different script. 
>> 
>> Referencing your example of breadcrumb.  I've had the main breadcrumb script 
>> import the specific implementation based on a configuration. 
>> 
>> /apps/www/components/breadcrumb/breadcrumb.jsp 
>> /apps/www/components/breadcrumb/breadcrumb-site1.jsp 
>> /apps/www/components/breadcrumb/breadcrumb-site2.jsp 
>> 
>> The main breadcrumb.jsp is always executed and within that script is the 
>> logic that determines which version of the breadcrumb we want to provide. At 
>> that point we pull in the relevant jsp to render the site specific markup. 
>> 
>> This keeps all your breadcrumb logic within a single structure. It also adds 
>> value in the form of being able to offer sites options on how they would 
>> like their breadcrumbs to look that could be controlled by configuration. 
>> 
>> 
>> 
>> -Original Message- 
>> From: vkum14 [mailto:[hidden email]] 
>> Sent: Wednesday, July 13, 2016 10:27 AM 
>> To: [hidden email] 
>> Subject: Re: One Resource to multiple views in different locations 
>> 
>> Hi Jason, 
>> 
>> I believe you are talking about css/js here while my use case is to have 
>> even different markups for the same component based on the site, it is being 
>> rendered. IMO, this is a typical use case of telling servletresourceresolver 
>> to pick different scripts based on the site input. Have you done some sorts 
>> of that? 
>> 
>> 
>> 
>> -- 
>> View this message in context: 
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
>>  
>> 
>> Sent from the Sling - Users mailing list archive at Nabble.com 
>> . 
>> 
>> 
>> 
>> If you reply to this email, your message will be added to the discussion 
>> below:
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html
>>  
>> 
>> To unsubscribe from One Resource to multiple views in different locations, 
>> click here.
>> NAML
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html
>  
> 
> Sent from the Sling - Users mailing list archive at Nabble.com 
> .



Re: adaptTo() 2016 - Agenda published

2016-06-21 Thread Roy Teeuwen
Hey Stefan,

Can’t wait for it ;) looks great!

Greets
Roy
> On 21 Jun 2016, at 22:41, Stefan Seifert  wrote:
> 
> 
> We're proud to present this year's agenda http://adapt.to/schedule
> 
> Luckily, there are still tickets available http://adapt.to/tickets
> 
> #adaptTo
> 
> Kind regards on behalf of the adaptTo() team
> 
> stefan
> 



Re: Querying vs iterating

2016-06-20 Thread Roy Teeuwen
Hey Julian,

Ok cool, for me the context is querying on a page in AEM, so I am creating a 
query for one cq:Page node, so that will be most of the times max like 10-20 
nodes. 
So what you are saying then is that it shouldn’t really matter in performance 
to choose either for manually traverse myself or doing a query when looking to 
see if a specific property name exists on the page, 
because behind the scene it will most likely traverse itself then anyway, right?

Thanks!
Roy
> On 20 Jun 2016, at 15:43, Julian Sedding <jsedd...@gmail.com> wrote:
> 
> Hi Roy
> 
> From you question ("hard to put an index to it") I assume that you are
> running on an Oak repository. If that is incorrect, my answer does not
> apply.
> 
> Oak will always consider traversal as an alternative to existing
> indexes. For most queries the cost of traversal is so high that an
> index is chosen. However, if no suitable index exists (and
> theoretically also if the traversal is cheaper than a lookup in a
> matching index), it will do a traversal behind the scenes. Note that
> traversal logs a warning every 1 traversed nodes. So if you plan
> to traverse more than that you should really consider creating an
> index.
> 
> In short: with Oak using a query on a small subtree should give you
> what you want, even without an index.
> 
> Regards
> Julian
> 
> 
> On Thu, Jun 16, 2016 at 4:44 PM, Steven Walters <kemu...@gmail.com> wrote:
>> Hopefully other people chime in here, I've only had bad experiences
>> with utilizing queries and have often resulted in personally never
>> using them - so I always end up iterating/navigating myself.
>> 
>> Theoretically if you have a REALLY GOOD index then you may get some
>> similar performances, but if your index(es) are inefficient, then it's
>> just wasted CPU cycles (you'd wish those CPU cycles were going to a
>> good cause, but they're not).
>> 
>> the transition of Sling (and AEM) to Oak from Jackrabbit 2.x made this
>> experience worse with the awkward indexing policies/process in Oak,
>> and the fact that Oak never seemed to ever use multiple indexes.
>> Oak always seemed to calculates the costs of the entire query against
>> all the available indexes and only chooses the ONE best index.
>> This sounds like a good idea in theory, but then most DBMS I've used
>> in the past utilize ALL the indexes they can - not just one.
>> 
>> So basically i guess this comes to be "If you have a good index (in
>> that it can apply to ALL the conditions/attributes/properties of your
>> query) then using a query should be fine, otherwise iterate yourself"
>> having any condition missing from the index can be fatal in
>> performance, such as lacking the evaluatePathRestrictions = true,
>> which without it is basically death of the system if you have a lot of
>> content.
>> 
>> But really, I hope some other people with more positive experiences
>> can provide some better advice.
>> 
>> On Thu, Jun 16, 2016 at 11:08 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>>> Ok, it would be handy to have an estimate on the approximate amount / 
>>> levels of resources when to go for iterating vs querying :).
>>> 
>>> Greets
>>> Roy
>>>> On 16 Jun 2016, at 16:06, Steven Walters <kemu...@gmail.com> wrote:
>>>> 
>>>> if you know there are that few resources, then I say iterating would be
>>>> better performing than XPath / JCR-SQL2 queries.
>>>> This is primarily from past experience speaking in that queries have
>>>> generally turned out (often MUCH) slower than directly iterating if you
>>>> know what you're actually looking for.
>>>> 
>>>> 
>>>> On Thu, Jun 16, 2016 at 10:28 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>>>> 
>>>>> Hello all,
>>>>> 
>>>>> Lets say I got a resource with around 10-20 child/grand-child resources,
>>>>> not going deeper than 3 levels max. What is the most performant when
>>>>> searching for the child resources containing a specific property (the
>>>>> property is configurable with OSGi, so hard to put an index on it).
>>>>> Iterating the child / grand-child resources until you find it or making an
>>>>> xpath/jcr-sql2 query? When would one option start to be more performant
>>>>> than the other.
>>>>> 
>>>>> Thanks!
>>>>> Roy
>>> 



Re: Using the resource resolver

2016-06-15 Thread Roy Teeuwen
Hey Carsten,

Then the javadocs seem a bit wrong to me, no?:

https://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceResolver.html#isLive--
 
<https://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceResolver.html#isLive-->

boolean isLive()

Returns true if this resource resolver has not been closed yet.
Unlike the other methods defined in this interface, this method will never 
throw an exception even after the resource resolver has been closed.

Greetings,
Roy

> On 15 Jun 2016, at 13:55, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> Roy Teeuwen wrote
>> Hey,
>> 
>> Thanks all for the responses. 
>> 
>> @Paul I would indeed ideally use the HTTP request, but there is no http 
>> request for the service that I am creating, but indeed that would be the 
>> best option.
>> 
>> @Jason Yeah, I am still using the getAdminResourceResolver because it is for 
>> AEM 5.6.1. When the upgrade is done, these will be removed ;)
>> 
>> @Carsten Wow, didn’t know about that last thing, then what is the use case 
>> of the isLive function? Where would you use it then?
>> 
> 
> The isLive is there to check whether you can still use the resource
> resolver, for example you got a resource resolver and while you're using
> it, the JCR provider is removed (or updated). In that case your resolver
> is not live anymore as one provider is not live anymore.
> 
> Regards
> Carsten
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



Re: Using the resource resolver

2016-06-14 Thread Roy Teeuwen
Hey,

Thanks all for the responses. 

@Paul I would indeed ideally use the HTTP request, but there is no http request 
for the service that I am creating, but indeed that would be the best option.

@Jason Yeah, I am still using the getAdminResourceResolver because it is for 
AEM 5.6.1. When the upgrade is done, these will be removed ;)

@Carsten Wow, didn’t know about that last thing, then what is the use case of 
the isLive function? Where would you use it then?

Thanks!
Roy

> On 14 Jun 2016, at 17:55, Carsten Ziegeler <cziege...@apache.org> wrote:
> 
> I think in general its considered bad practice to have a long running
> resource resolver. It might have stale content and you would constantly
> need to call refresh() on it whenever you use it. Keep also in mind that
> it is not thread safe, so if your doSomething is called concurrently
> this might fail.
> 
> So far I have not seen a problem with simply creating and closing a
> resource resolver each time you need it. But the probably the best
> solution is to pass the resolver in.
> 
> And :) you should close the resource resolver in deactivate regardless
> whether it is live or not.
> 
> Regards
> Carsten
> 
> Roy Teeuwen wrote
>> Hello all,
>> 
>> I am wondering on the usage of the resource resolver and on how long it 
>> should stay open. Lets say I have the following implementation:
>> 
>> @Component
>> @Service(SomeService.class)
>> public class SomeServiceImpl implements SomeService {
>> 
>> @Reference
>> private ResourceResolverFactory resourceResolverFactory;
>> 
>> private ResourceResolver resourceResolver;
>> 
>>@Activate
>>protected synchronized void activate(Map<String, Object> properties) 
>> throws Exception {
>>   try {
>>resourceResolver = 
>> resourceResolverFactory.getAdministrativeResourceResolver(null);
>>} catch (LoginException e) {
>>LOG.error("Failed to get admin resourceresolver", e);
>>throw e;
>>}
>>}
>> 
>> @Deactivate
>>protected synchronized void deactivate(Map<String, Object> properties) 
>> throws Exception {
>>if (resourceResolver != null && resourceResolver.isLive()) {
>>resourceResolver.close();
>>}
>>}
>> 
>>   public void doSomething(String path) {
>>  Resource resource = resourceResolver.getResource(path);
>>   //do something
>> }
>> }
>> 
>> 
>> Is there anything wrong on using this? Knowing that this means the 
>> resourceresolver will stay open for possible months/years… 
>> Or should one try and make the resourceresolver opening as short as 
>> possible? Knowing that the method will be called around 1000-2000 times an 
>> hour. 
>> 
>> Another solution is of course passing the resourceResolver to do the 
>> doSomething, but then the question still remains, how long should you keep a 
>> resourceresolver open 
>> 
>> Greetings,
>> Roy
>> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org



Re: Creating templates for primary types

2016-05-05 Thread Roy Teeuwen
Hey Robert, Justin,

Yeah I meant scripts indeed, sorry. Ah ok nice, thanks for the explanation. 
Is it obligated to be directly under /apps, or can you also put it somewhere 
else?

Thanks!
Roy


> On 05 May 2016, at 14:38, Justin Edelson <jus...@justinedelson.com> wrote:
> 
> Hi,
> I'm assuming you mean scripts. In this case, you can replace the colon in
> the type name with a slash, so it would be something like
> /apps/myns/TypeName/typename.esp (for myns:TypeName node type).
> 
> Regards,
> Justin
> 
> On Thu, May 5, 2016 at 8:09 AM Robert Munteanu <romb...@apache.org> wrote:
> 
>> Hi Roy,
>> 
>> On Thu, 2016-05-05 at 13:03 +0200, Roy Teeuwen wrote:
>>> Hello all,
>>> 
>>> I have a question, how can you create templates that work on
>>> resources with a specific primary type instead of resource type?
>>> 
>>> Thanks!
>>> Roy
>> 
>> I may be missing some context here, but what do you mean by template?
>> 
>> Thanks,
>> 
>> Robert
>> 



Creating templates for primary types

2016-05-05 Thread Roy Teeuwen
Hello all,

I have a question, how can you create templates that work on resources with a 
specific primary type instead of resource type? 

Thanks!
Roy

Re: Exception when trying out the fling sample

2016-05-01 Thread Roy Teeuwen
Hey Olivier,

Thanks for the explanation! For me real the benefit would be that I could take 
a vanilla sling launchpad and install the project where I would add a config 
file making the thymeleaf engine a higher service ranking and it would all work 
without any manual action of the user in the system console (unless there is a 
way I don’t know of that you can deactivate bundles through a config / maven 
plugin).

Also I still seem to be getting errors in the fling sample. 

Firstly, when going to the form page, I get following error which can be fixed 
by making the  tags closed in the templates:

org.thymeleaf.exceptions.TemplateInputException: Exception parsing 
document: template="/apps/fling/page/form/html.html", line 52 - column 
Caused by: org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 
9; The element type "input" must be terminated by the matching end-tag 
"”.

Secondly, when I manually close the input tags myself in the 
/apps/fling/page/form/html.html template and I submit the form, I just get 
redirected to following page and no validation occures:

Content modified /content/fling/validation

Status  200
Message OK
Location/fling/validation
Parent Location /fling
Path/content/fling/validation
Referer http://localhost:8080/fling/validation.html
ChangeLog   
modified("/content/fling/validation/formType");modified("/content/fling/validation/name");
Go Back

Modified Resource

Parent of Modified Resource

Lastly, I was wondering what should be on the sling commons messaging page in 
the example. I just get a page with three columns, subject from and text but 
nothing filled in.

Thanks!
Greetings,
Roy



> On 01 May 2016, at 09:42, Oliver Lietz  wrote:
> 
> On Sunday 01 May 2016 10:05:33 Vlad Bailescu wrote:
>> Hi,
>> 
>> My comments are inline.
>> 
>> On Sunday, 1 May 2016, Oliver Lietz  wrote:
>>> On Saturday 30 April 2016 22:04:57 Vlad Bailescu wrote:
 On Saturday, 30 April 2016, Oliver Lietz >> 
>>> > wrote:
> (service ranking is not honored by Sling's script engine manager, no
>>> 
>>> need
>>> 
> to try).
 
 Any idea why this is not a bug?
>>> 
>>> Why do you think it should be a bug?
>> 
>> Because Sling generally uses the service ranking and it's a great mechanism.
> 
> "generally" is a somewhat optimistic term when it comes to service ranking at 
> Sling. I don't think it's a bug still, but using service ranking could be an 
> improvement indeed.
> 
>>> Sling's Scripting support is built around Java's Scripting API (JSR-223)
>>> and
>>> that was obviously not designed to handle multiple script engines for one
>>> extension or mime type. So it is a limitation in Java's Scripting API.
>> 
>> The implementation could use service ranking as an optional/custom
>> extension of the standard.
> 
> Right. And we will need an extension somehow when script engine manager is 
> asked for an engine by extension or mime type. The manager could return null, 
> throw an Exception or select the engine by service ranking when more than one 
> engine is registered per extension or mime type. It will be implemented as 
> part of SLING-4330 (work in progress).
> 
  https://issues.apache.org/jira/browse/SLING-4330
 
 I was under the impression SLING-4330 is about using both Sightly and
 Thymeleaf in the same running instance; and how to solve which one gets
 used on a file/script level.
>>> 
>>> Right.
>>> 
 But for using just one scripting engine (Thymeleaf in this case) for a
 given extension we could just use the service ranking.
>>> 
>>> What is the benefit?
>>> 
>>> If you give Thymeleaf's script engine a higher service ranking than
>>> Sightly's
>>> to render HTML templates (.html) you make Sightly quite useless. The
>>> result is
>>> similar to deactivating/deinstalling Sightly's bundles (correct me if I'm
>>> wrong).
>>> 
>>> The other way round is not that destructive because Thymeleaf's script
>>> engine
>>> can be configured for different extensions (e.g. .htm, .thtml), can handle
>>> not
>>> only HTML but also XML, CSS, JavaScript, text and raw templates and makes
>>> its
>>> TemplateEngine available as OSGi service to render templates outside of
>>> Sling's Scripting context (see Fling sample).
>>> 
>>> So unless SLING-4330 is implemented and you want to use Thymeleaf for
>>> .html
>>> just deinstall Sightly.
>> 
>> Right, but that seems a bit counter-intuitive since Sightly ships as
>> default with Sling. From an user point of view it would make sense to just
>> bump the ranking of Thymeleaf to make it "cut in front" instead of
>> uninstalling something.
> 
> Sling Launchpad ships with Sightly because Adobe is pushing Sightly with full 
> 

Re: Exception when trying out the fling sample

2016-04-30 Thread Roy Teeuwen
Hey Vlad,

Thanks. I changed the HTML 5 Template Handler pattern to *.html and the 
Thymeleaf Script Engine Factory service ranking to 150 in the felix config 
manager. But still I get the same error. I don’t see anything about this in the 
docs you sent? Deactivating the sightly engine bundle also fixes it but I would 
rather fix it by configuration when possible of course.

Greets,
Roy
> On 30 Apr 2016, at 19:34, Vlad Bailescu <v...@bailescu.ro> wrote:
> 
> Hi Roy,
> 
> It seems Thymeleaf is not handling the HTML scripts, they get processed by 
> Sightly instead. You could check the configured service ranking of Thymeleaf, 
> as suggested in 
> https://sling.apache.org/documentation/bundles/scripting/scripting-thymeleaf.html
>  
> <https://sling.apache.org/documentation/bundles/scripting/scripting-thymeleaf.html>
> 
> Best,
> Vlad
> 
> On Saturday, 30 April 2016, Roy Teeuwen <r...@teeuwen.be 
> <mailto:r...@teeuwen.be>> wrote:
> Hello all,
> 
> When navigating to fling.html after installing the fling samples I get 
> following exception, any thought on what is going wrong?
> Parsing error in template /apps/fling/page/simple/html.html at line 20: 
> extraneous input '(' expecting {'}', '.', '&&', '||', '[', '@'} for 
> expression 
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)} (500)
> 
> The requested URL /fling.html resulted in an error in 
> /apps/fling/page/simple/html.html.
> 
> Exception:
> 
> org.apache.sling.scripting.sightly.SightlyException: Parsing error in 
> template /apps/fling/page/simple/html.html at line 20: extraneous input '(' 
> expecting {'}', '.', '&&', '||', '[', '@'} for expression 
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)}
> at 
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.getSourceCodeForScript(UnitLoader.java:135)
> at 
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.createUnit(UnitLoader.java:100)
> at 
> org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:91)
> 
> The installed bundles that I am using to get the sample active on the current 
> Sling 9-SNAPSHOT launchpad are the following:
> 
> 
> org.apache.sling.samples
> org.apache.sling.samples.fling
> 0.0.1-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.query
> 3.0.0
> 
> 
> 
> org.apache.sling
> 
> org.apache.sling.jcr.jackrabbit.usermanager
> 2.2.4
> 
> 
> 
> org.apache.sling
> org.apache.sling.scripting.thymeleaf
> 0.0.6
> 
> 
> org.thymeleaf
> thymeleaf
> 3.0.0.BETA02
> 
> 
> org.apache.sling
> org.apache.sling.i18n
> 2.2.10
> 
> 
> org.javassist
> javassist
> 3.18.2-GA
> 
> 
> commons-io
> commons-io
> 2.4
> 
> 
> org.apache.servicemix.bundles
> org.apache.servicemix.bundles.xerces
> 2.11.0_1
> 
> 
> org.apache.servicemix.bundles
> org.apache.servicemix.bundles.xmlresolver
> 1.2_5
> 
> 
> 
> org.apache.sling
> org.apache.sling.validation.api
> 1.0.0-SNAPSHOT
> 
> 
> org.apache.sling
> org.apache.sling.validation.core
> 1.0.0-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.commons.messaging
> 0.0.1-SNAPSHOT
> 
> 
> Greetings,
> Roy
> 
> 
> -- 
> Sent from mobile



Exception when trying out the fling sample

2016-04-30 Thread Roy Teeuwen
Hello all,

When navigating to fling.html after installing the fling samples I get 
following exception, any thought on what is going wrong?
Parsing error in template /apps/fling/page/simple/html.html at line 20: 
extraneous input '(' expecting {'}', '.', '&&', '||', '[', '@'} for expression 
page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)} (500)

The requested URL /fling.html resulted in an error in 
/apps/fling/page/simple/html.html.

Exception:

org.apache.sling.scripting.sightly.SightlyException: Parsing error in template 
/apps/fling/page/simple/html.html at line 20: extraneous input '(' expecting 
{'}', '.', '&&', '||', '[', '@'} for expression 
page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)}
at 
org.apache.sling.scripting.sightly.impl.engine.UnitLoader.getSourceCodeForScript(UnitLoader.java:135)
at 
org.apache.sling.scripting.sightly.impl.engine.UnitLoader.createUnit(UnitLoader.java:100)
at 
org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:91)

The installed bundles that I am using to get the sample active on the current 
Sling 9-SNAPSHOT launchpad are the following:


org.apache.sling.samples
org.apache.sling.samples.fling
0.0.1-SNAPSHOT



org.apache.sling
org.apache.sling.query
3.0.0



org.apache.sling
org.apache.sling.jcr.jackrabbit.usermanager
2.2.4



org.apache.sling
org.apache.sling.scripting.thymeleaf
0.0.6


org.thymeleaf
thymeleaf
3.0.0.BETA02


org.apache.sling
org.apache.sling.i18n
2.2.10


org.javassist
javassist
3.18.2-GA


commons-io
commons-io
2.4


org.apache.servicemix.bundles
org.apache.servicemix.bundles.xerces
2.11.0_1


org.apache.servicemix.bundles
org.apache.servicemix.bundles.xmlresolver
1.2_5



org.apache.sling
org.apache.sling.validation.api
1.0.0-SNAPSHOT


org.apache.sling
org.apache.sling.validation.core
1.0.0-SNAPSHOT



org.apache.sling
org.apache.sling.commons.messaging
0.0.1-SNAPSHOT


Greetings,
Roy

Sling Events 4.0

2016-04-08 Thread Roy Teeuwen
Hey all,

After upgrading to sling events 4.0, the EventUtil has disappeared. I have been 
using EventUtil.isLocal(event) throughout my codebase, and in the documentation 
of the deprecation it states that one should check if the property exists. Does 
this mean that it is enough to replace this everywhere by 
event.getProperty(“event.application”) == null?

Thanks
Roy

Re: JCR Namespace prefix

2016-04-06 Thread Roy Teeuwen
Hey Robert,

Hmm, it seems it only occurs when you make files in the format of 
_test_file.scss, try doing a vlt commit of that file. It will give the same 
error:

Collecting commit information...
adding. _test_file.scss
Transmitting file data...
[ERROR] Error while writing artifacts of /apps: javax.jcr.NamespaceException: 
test: is not a registered namespace prefix.
[ERROR] commit: com.day.jcr.vault.vlt.VltException: Error while committing
caused by: javax.jcr.NamespaceException: test: is not a registered namespace 
prefix.

Checking out a file that is called _test_file.scss will check it out with 
double underscore as prefix instead of a single underscore: __test_file.scss
Guess it is possible to work around it then by altering the files to double 
underscore on maven deploy… 

Thanks :)!
Roy

> On 06 Apr 2016, at 17:04, Robert Munteanu <romb...@apache.org> wrote:
> 
> Hi Roy,
> 
> On Wed, 2016-04-06 at 09:57 +0200, Roy Teeuwen wrote:
>> Hello all,
>> 
>> I am currently trying to develop a sass compiler that will compile
>> the sass files natively in Sling instead of using CSS files. The
>> issue that I am facing at this moment though is that when I try to
>> upload the sass files I get following exception:
>> 
>> *ERROR* [qtp2101349382-74]
>> org.apache.jackrabbit.vault.packaging.impl.ZipVaultPackage Error
>> during install.
>> javax.jcr.RepositoryException: OakName0001: Invalid namespace
>> prefix([, nt, xmpRights, pdf, stFNT, album, xs, crxde, social,
>> prismusagerights, rdf, sv, xmpBJ, idPriv, fn, prism, tiff, exif, dc,
>> plus, oauth, acdsee, xmp, xml, MP, cq, sling, scg, pdfx, dam, cc, lr,
>> s7sitecatalyst, dex, xmpPLUS, xmpNote, jcr, slingevent, DICOM,
>> mediapro, oak, stEvt, stMfs, stRef, MicrosoftPhoto, photoshop, xmpDM,
>> granite, crs, s7userdata, adobe_dam, xmpTPg, xmpGImg, xmpG, fn_old,
>> crx, mix, viewerpreset, psAux, vlt, xmpMM, slice, Iptc4xmpExt,
>> Iptc4xmpCore, rep, prl]): colors
>> at
>> org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryExcep
>> tion(CommitFailedException.java:249)
>> at
>> org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryExcep
>> tion(CommitFailedException.java:212)
>> 
>> This is because all the sass partial files are being prefixed with an
>> underscore, this is how sass works by default, partials are snippets
>> that will be imported in the main css file and should be prefixed
>> with an underscore. The file it is complaining about now is called
>> _colors.sass. Is there any way around this, that it doesn’t look at
>> these files like if it they have a namespace?
> 
> The compiler sounds pretty cool :-)
> 
> Related to the error, I was able to create a file named _test.txt in
> the Sling launchpad without any issues, so I don't think the issue is
> at the JCR level.
> 
> It looks to me like the issue is with the vault package, which IIRC
> uses '_' to mask the ':' character in file names. But I'm not sure if
> this is a bug in the package manager or something that you can adjust
> in your package.
> 
> Robert



JCR Namespace prefix

2016-04-06 Thread Roy Teeuwen
Hello all,

I am currently trying to develop a sass compiler that will compile the sass 
files natively in Sling instead of using CSS files. The issue that I am facing 
at this moment though is that when I try to upload the sass files I get 
following exception:

*ERROR* [qtp2101349382-74] 
org.apache.jackrabbit.vault.packaging.impl.ZipVaultPackage Error during install.
javax.jcr.RepositoryException: OakName0001: Invalid namespace prefix([, nt, 
xmpRights, pdf, stFNT, album, xs, crxde, social, prismusagerights, rdf, sv, 
xmpBJ, idPriv, fn, prism, tiff, exif, dc, plus, oauth, acdsee, xmp, xml, MP, 
cq, sling, scg, pdfx, dam, cc, lr, s7sitecatalyst, dex, xmpPLUS, xmpNote, jcr, 
slingevent, DICOM, mediapro, oak, stEvt, stMfs, stRef, MicrosoftPhoto, 
photoshop, xmpDM, granite, crs, s7userdata, adobe_dam, xmpTPg, xmpGImg, xmpG, 
fn_old, crx, mix, viewerpreset, psAux, vlt, xmpMM, slice, Iptc4xmpExt, 
Iptc4xmpCore, rep, prl]): colors
at 
org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:249)
at 
org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:212)

This is because all the sass partial files are being prefixed with an 
underscore, this is how sass works by default, partials are snippets that will 
be imported in the main css file and should be prefixed with an underscore. The 
file it is complaining about now is called _colors.sass. Is there any way 
around this, that it doesn’t look at these files like if it they have a 
namespace?

Thanks,
Roy

Re: Sorting of a JCR Query

2016-03-03 Thread Roy Teeuwen
Hey Julian,

Oke, thanks! 

Greetings,
Roy
> On 03 Mar 2016, at 13:11, Julian Sedding <jsedd...@gmail.com> wrote:
> 
> Hello Roy
> 
> XPath queries allow ordering by a property:
> /jcr:root/A//element(*, nt:unstructured) [
>jcr:contains(property, ‘value’)
> ] order by @otherProperty descending
> 
> If you want the child order, you should iterate over the child node
> using the API:
> 
> NodeIterator children = session.getNode("/A").getNodes();
> while (children.hasNext()) {
>Node child = children.nextNode();
>// do something with it
> }
> 
> In other words: query results don't know about the sibling order of nodes.
> 
> Regards
> Julian
> 
> 
> 
> On Wed, Mar 2, 2016 at 7:13 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> Hello all,
>> 
>> I have a node A with subnodes B,C,D and am creating a JCR query to retrieve 
>> some of the subnodes by using the following XPATH query:
>> 
>> /jcr:root/A//element(*, nt:unstructured) [
>>jcr:contains(property, ‘value’)
>> ]
>> 
>> The problem that I am facing at this moment that the order it retrieves the 
>> elements seem te be random. Sometimes it gives back B,D and sometimes D,B.
>> What I would like is that it always gives back the order that the nodes have 
>> below A has in the jcr repository, is it possible to pass this to the query 
>> (either XPath or an SQL for the same result)
>> 
>> Thanks
>> Roy



Sorting of a JCR Query

2016-03-02 Thread Roy Teeuwen
Hello all,

I have a node A with subnodes B,C,D and am creating a JCR query to retrieve 
some of the subnodes by using the following XPATH query:

/jcr:root/A//element(*, nt:unstructured) [
jcr:contains(property, ‘value’)
]

The problem that I am facing at this moment that the order it retrieves the 
elements seem te be random. Sometimes it gives back B,D and sometimes D,B. 
What I would like is that it always gives back the order that the nodes have 
below A has in the jcr repository, is it possible to pass this to the query 
(either XPath or an SQL for the same result)

Thanks
Roy

Re: How to reindex lucene

2016-01-06 Thread Roy Teeuwen
Hey Julian,

I indeed already took this action, it just recreated the index folder but the 
error messages keep coming. 

The only way to “solve" it is by temporary disabling the oak-lucene bundle so 
that I can access the JCR Explorer with decent performance, set the reindex 
property for oak:index/lucene on true and then restart the oak-lucene bundle. 
During the recreation of the Lucene index you still see the exceptions being 
thrown in the error log but from the moment it finishes the reindexing the 
error messages disappear.

Shall I put this on the mailing list for Jackrabbit oak?

Thanks!
Roy

> On 06 Jan 2016, at 12:47, Julian Sedding <jsedd...@gmail.com> wrote:
> 
> Hi Roy
> 
> This relates more to Jackrabbit Oak then to Sling, so you might get
> better assistance there.
> 
> The Lucene-Index implementation in Oak copies the index data from the
> repository to the local file system as an I/O optimization. Therefore
> the files on the file system are redundant.
> 
> You can try the following:
> - shut down your Sling instance
> - delete /opt/aem_author/crx-quickstart/repository/index
> - start your Sling instance
> 
> If all goes as expected, you will see that the folder
> /opt/aem_author/crx-quickstart/repository/index is recreated and the
> log messages disappear. If this is not the case, please report back
> with your observations.
> 
> Hope this helps.
> 
> Regards
> Julian
> 
> 
> On Wed, Jan 6, 2016 at 10:14 AM, Roy Teeuwen <r...@teeuwen.be> wrote:
>> I am having a problem with my lucene index, it is throwing the exception
>> shown in the logs below. Last time I got this solved by setting the reindex
>> property on true for the oak:index/lucene but now my system is so slow
>> because it throws the exception so many times per second that I can't even
>> get into the explorer to set the property on true. Is there a way to let my
>> lucene index reindex by changing a property on the filesystem? Or is there a
>> fix for this exception because reindexing every time also doesn't seem to be
>> a correct way of handling this.
>> 
>> 06.01.2016 09:55:16.310 *WARN* [oak-lucene-0]
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
>> [/oak:index/lucene] Error occurred while copying file [segments_1rt] from
>> Directory for /oak:index/lucene to
>> MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
>> lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
>> java.io.FileNotFoundException: segments_1rt
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.openInput(OakDirectory.java:133)
>>at org.apache.lucene.store.Directory.copy(Directory.java:185)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.access$600(IndexCopier.java:296)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory$1.run(IndexCopier.java:379)
>>at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>>at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>>at java.lang.Thread.run(Thread.java:745)
>> 06.01.2016 09:55:16.310 *WARN* [oak-lucene-0]
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
>> [/oak:index/lucene] Error occurred while copying file [segments_1ru] from
>> Directory for /oak:index/lucene to
>> MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
>> lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
>> java.io.FileNotFoundException: segments_1ru
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.openInput(OakDirectory.java:133)
>>at org.apache.lucene.store.Directory.copy(Directory.java:185)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.access$600(IndexCopier.java:296)
>>at
>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory$1.run(IndexCopier.java:379)
>>at
>> java.util.concurrent.Thr

How to reindex lucene

2016-01-06 Thread Roy Teeuwen
I am having a problem with my lucene index, it is throwing the exception
shown in the logs below. Last time I got this solved by setting the reindex
property on true for the oak:index/lucene but now my system is so slow
because it throws the exception so many times per second that I can't even
get into the explorer to set the property on true. Is there a way to let my
lucene index reindex by changing a property on the filesystem? Or is there a
fix for this exception because reindexing every time also doesn't seem to be
a correct way of handling this.

06.01.2016 09:55:16.310 *WARN* [oak-lucene-0]
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
[/oak:index/lucene] Error occurred while copying file [segments_1rt] from
Directory for /oak:index/lucene to
MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
java.io.FileNotFoundException: segments_1rt
at
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.openInput(OakDirectory.java:133)
at org.apache.lucene.store.Directory.copy(Directory.java:185)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.access$600(IndexCopier.java:296)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory$1.run(IndexCopier.java:379)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
06.01.2016 09:55:16.310 *WARN* [oak-lucene-0]
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
[/oak:index/lucene] Error occurred while copying file [segments_1ru] from
Directory for /oak:index/lucene to
MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
java.io.FileNotFoundException: segments_1ru
at
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.openInput(OakDirectory.java:133)
at org.apache.lucene.store.Directory.copy(Directory.java:185)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.access$600(IndexCopier.java:296)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory$1.run(IndexCopier.java:379)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
06.01.2016 09:55:16.572 *WARN* [qtp483471336-38]
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
[/oak:index/lucene] Error occurred while copying file [_1sa.cfs] from
Directory for /oak:index/lucene to
MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
java.io.EOFException: reached end of stream after reading 0 bytes; 717339
bytes expected
at com.google.common.io.ByteStreams.readFully(ByteStreams.java:697)
at
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexFile.loadBlob(OakDirectory.java:261)
at
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexFile.readBytes(OakDirectory.java:307)
at
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexInput.readBytes(OakDirectory.java:404)
at org.apache.lucene.store.DataOutput.copyBytes(DataOutput.java:254)
at org.apache.lucene.store.Directory.copy(Directory.java:186)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.prefetchIndexFiles(IndexCopier.java:394)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.(IndexCopier.java:320)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier.wrapForRead(IndexCopier.java:136)
at
org.apache.jackrabbit.oak.plugins.index.lucene.IndexNode.open(IndexNode.java:51)
at

Re: How to reindex lucene

2016-01-06 Thread Roy Teeuwen
Ah cool, thanks for the help!

Greetings,
Roy
> On 06 Jan 2016, at 13:15, Julian Sedding-3 [via Apache Sling] 
> <ml-node+s73963n4058187...@n3.nabble.com> wrote:
> 
> Hi Roy 
> 
> The issue you observe may be 
> https://issues.apache.org/jira/browse/OAK-3504 
> <https://issues.apache.org/jira/browse/OAK-3504>. I don't know which Oak 
> version you are running, compare to the issue's fix version. If you 
> are running a "fixed" version, please report the issue on the Oak 
> list. Thanks. 
> 
> Regards 
> Julian 
> 
> 
> On Wed, Jan 6, 2016 at 12:58 PM, Roy Teeuwen <[hidden email] 
> > wrote:
> 
> > Hey Julian, 
> > 
> > I indeed already took this action, it just recreated the index folder but 
> > the error messages keep coming. 
> > 
> > The only way to “solve" it is by temporary disabling the oak-lucene bundle 
> > so that I can access the JCR Explorer with decent performance, set the 
> > reindex property for oak:index/lucene on true and then restart the 
> > oak-lucene bundle. During the recreation of the Lucene index you still see 
> > the exceptions being thrown in the error log but from the moment it 
> > finishes the reindexing the error messages disappear. 
> > 
> > Shall I put this on the mailing list for Jackrabbit oak? 
> > 
> > Thanks! 
> > Roy 
> > 
> >> On 06 Jan 2016, at 12:47, Julian Sedding <[hidden email] 
> >> > wrote: 
> >> 
> >> Hi Roy 
> >> 
> >> This relates more to Jackrabbit Oak then to Sling, so you might get 
> >> better assistance there. 
> >> 
> >> The Lucene-Index implementation in Oak copies the index data from the 
> >> repository to the local file system as an I/O optimization. Therefore 
> >> the files on the file system are redundant. 
> >> 
> >> You can try the following: 
> >> - shut down your Sling instance 
> >> - delete /opt/aem_author/crx-quickstart/repository/index 
> >> - start your Sling instance 
> >> 
> >> If all goes as expected, you will see that the folder 
> >> /opt/aem_author/crx-quickstart/repository/index is recreated and the 
> >> log messages disappear. If this is not the case, please report back 
> >> with your observations. 
> >> 
> >> Hope this helps. 
> >> 
> >> Regards 
> >> Julian 
> >> 
> >> 
> >> On Wed, Jan 6, 2016 at 10:14 AM, Roy Teeuwen <[hidden email] 
> >> > wrote: 
> >>> I am having a problem with my lucene index, it is throwing the exception 
> >>> shown in the logs below. Last time I got this solved by setting the 
> >>> reindex 
> >>> property on true for the oak:index/lucene but now my system is so slow 
> >>> because it throws the exception so many times per second that I can't 
> >>> even 
> >>> get into the explorer to set the property on true. Is there a way to let 
> >>> my 
> >>> lucene index reindex by changing a property on the filesystem? Or is 
> >>> there a 
> >>> fix for this exception because reindexing every time also doesn't seem to 
> >>> be 
> >>> a correct way of handling this. 
> >>> 
> >>> 06.01.2016 09:55:16.310 *WARN* [oak-lucene-0] 
> >>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier 
> >>> [/oak:index/lucene] Error occurred while copying file [segments_1rt] from 
> >>> Directory for /oak:index/lucene to 
> >>> MMapDirectory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
> >>>  
> >>> lockFactory=NativeFSLockFactory@/opt/aem_author/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/2
> >>>  
> >>> java.io.FileNotFoundException: segments_1rt 
> >>>at 
> >>> org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.openInput(OakDirectory.java:133)
> >>>  
> >>>at org.apache.lucene.store.Directory.copy(Directory.java:185) 
> >>>at 
> >>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.copyFilesToLocal(IndexCopier.java:420)
> >>>  
> >>>at 
> >>> org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.access$600(IndexCopier.java:296)
> >>>  
> >>>at 
> >>> org.apache.jackrabbit.oak.plugins.i

  1   2   >