Re: Getting SlingHttpServletRequest in a HTTP Whiteboard

2020-11-17 Thread Julian Sedding
Hey Roy

No this is not possible. The SlingHttpServletRequest is only available
once you're "inside" the SlingMainServlet, i.e. in filters or servlets
registered within Sling. The HTTP Whiteboard is pure OSGi and filters
registered that way are executed before the SlingMainServlet.

The order of execution is something like this (in reality it is more
complicated once inside the SlingMainServlet):

1. OSGi HTTP Service filter chain
2. SlingMainServlet (SlingHttpServletRequest/Response available after
this point)
3. Sling filter chain (i.e. Filters registered with "sling.filter.scope")
4. Sling servlet / script (e.g. Servlets registered with
"sling.servlet.resourceTypes")

Regards
Julian


On Mon, Nov 16, 2020 at 4:37 PM Roy Teeuwen  wrote:
>
> 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: An issue when trying to use the i18n bundle

2020-04-26 Thread Julian Sedding
Hi Andrey

As the documentation states, you can use the SlingHttpServletRequest
object in your servlet implementations or rendering scripts to obtain
the locale of the request (as provided by the Accept-Language header).
And using this locale you can get a ResourceBundle instance. You can
then query the ResourceBundle with the definition string (aka key) in
order to obtain the translation. Of course you can also implement an
arbitrary other mechanism to load a ResourceBundle, e.g. you could get
the locale from a user-preference setting in a cookie.

There is no mechanism that I know of that would redirect you to the
"correct" JSON file, and that is not what is documented. If you
want/need that, you will need to implement the logic in a custom
servlet yourself.

Regards
Julian

On Fri, Apr 24, 2020 at 5:37 PM Andrey Shulinsky  wrote:
>
> Hi Julian,
>
> Thanks a lot for the prompt reply.
>
> You advice has worked for a separate request:
>
> 
> POST http://localhost:8123/libs/languages/english.json HTTP/1.1
> Content-Type: application/x-www-form-urlencoded
> User-Agent: Fiddler
> Host: localhost:8123
> Content-Length: 43
> Authorization: Basic YWRtaW46YWRtaW4=
>
> jcr:mixinTypes=mix:language:language=en
> 
>
> With that we now have the node
> jcr:root/libs/languages/english.json
> {
>   "jcr:language": "en",
>   "jcr:mixinTypes": [
> "mix:language"
>   ],
>   "jcr:primaryType": "nt:file"
> }
>
> Which has this child node:
> jcr:root/libs/languages/english.json/jcr:content
> {
>   "jcr:data": 
> "/bin/cpm/nodes/property.bin/libs/languages/english.json/_jcr_content?name=jcr%3Adata",
>   "jcr:mimeType": "application/json",
>   "jcr:primaryType": "nt:resource"
> }
>
>
> We have also created the jcr:root/libs/languages/deutch.json resource
> in the same way.
>
> We have not tried the single request yet, would like to understand how
> to get the language-specific content first.
>
> We can do a GET
> http://localhost:8123/libs/languages/[english|deutch].json which
> returns the corresponding bundle however to our understanding this is
> not the right way to get the language-specific information.
>
> The docs at 
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> mention the Accept-Language header.
> So we tried to use it with the requests like
>
> 
> GET http://localhost:8123/libs/languages HTTP/1.1// Also tried
> http://localhost:8123/libs/languages/* and a few others
> Content-Type: text/json   // Tried some other content types there
> Host: localhost:8123
> Content-Length: 0
> Authorization: Basic YWRtaW46YWRtaW4=
> Accept-Language: en
> 
>
> Nothing has worked so far unfortunately.
>
>
> Any advice please?
>
>
> Thanks,
> Andrey.
>
> On Fri, Apr 24, 2020 at 3:56 AM Julian Sedding  wrote:
> >
> > Hi
> >
> > I noticed that you set jcr:primaryType=mix:language. It should be
> > jcr:mixinTypes.
> >
> > Also no need to set the jcr:primaryType=nt:file, it should be set
> > automatically. Setting it again explicitly might actually cause issues.
> >
> > So just try posting
> >
> > ./jcr:mixinTypes=mix:language
> > ./jcr:language=en
> >
> > If that works in a separate request, you could try combining them into a
> > single request.
> >
> > Regards
> > Julian
> >
> > On Fri, 24 Apr 2020 at 03:47, Andrey Shulinsky  wrote:
> >
> > > Hi folks,
> > >
> > > We're trying to use this bundle with the JSON file option:
> > >
> > > https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based
> > >
> > > Have been having an issue we'd really appreciate help with.
> > >
> > >
> > > We'd like to add the language-specific bundles using the POST API.
> > >
> > >
> > > This is the structure from the doc mentioned above:
> > >/libs/languages
> > >+-- english.json (nt:file, mix:language)
> > >|+-- jcr:language = en
> > >|+-- jcr:content (nt:resource)
> > >| + jcr:data (containing the actual JSON file)
> > >
> > >
> > > When we do this request:
> > >
> > >
> > > 
> > > POST http://localhost:8123/l

Re: An issue when trying to use the i18n bundle

2020-04-24 Thread Julian Sedding
Hi

I noticed that you set jcr:primaryType=mix:language. It should be
jcr:mixinTypes.

Also no need to set the jcr:primaryType=nt:file, it should be set
automatically. Setting it again explicitly might actually cause issues.

So just try posting

./jcr:mixinTypes=mix:language
./jcr:language=en

If that works in a separate request, you could try combining them into a
single request.

Regards
Julian

On Fri, 24 Apr 2020 at 03:47, Andrey Shulinsky  wrote:

> Hi folks,
>
> We're trying to use this bundle with the JSON file option:
>
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based
>
> Have been having an issue we'd really appreciate help with.
>
>
> We'd like to add the language-specific bundles using the POST API.
>
>
> This is the structure from the doc mentioned above:
>/libs/languages
>+-- english.json (nt:file, mix:language)
>|+-- jcr:language = en
>|+-- jcr:content (nt:resource)
>| + jcr:data (containing the actual JSON file)
>
>
> When we do this request:
>
>
> 
> POST http://localhost:8123/libs/languages HTTP/1.1
> Content-Type: multipart/form-data;
> boundary=-acebdf13572468
> User-Agent: Fiddler
> Host: localhost:8123
> Content-Length: 257
> Authorization: Basic YWRtaW46YWRtaW4=
>
> ---acebdf13572468
> Content-Disposition: form-data; name="english.json";
> filename="english.json"
> Content-Type: application/json
>
> {
> "message1": "aaa",
> "message2": "bbb"
> }
>
> ---acebdf13572468--
> 
>
> We get a similar structure:
>
>/libs/languages
>+-- english.json (nt:file)
>|+-- jcr:content (nt:resource)
>| + jcr:data (containing the actual JSON file)
>
> And the messages1-2 are added properly.
>
> However it's lacking
> - the "mix:language" type on the english.json node
> - the jcr:language=en property on the english/json node
> Which are needed to get the proper language-specific content
>
> We have tried to modify the request above to add those properties,
> tried a separate request to add them:
>
> 
> POST http://localhost:8123/libs/languages/english.json HTTP/1.1
> Content-Type: application/x-www-form-urlencoded
> User-Agent: Fiddler
> Host: localhost:8123
> Content-Length: 52
> Authorization: Basic YWRtaW46YWRtaW4=
>
> jcr:primaryType=nt:file:primaryType=mix:language
> 
>
> But nothing has worked so far.
>
> So if anyone could do us a favor and advise how to add those
> properties that would be really helpful.
>
> Thanks in advance!
>
> Andrey.
>


Re: Sling 12 with Composite Node Store

2020-03-31 Thread Julian Sedding
Hi Andy

I have not done this before, I'm just trying to extrapolate from
looking at the code.

In your above config, I think the following config
"org.apache.jackrabbit.oak.segment.SegmentNodeStoreService~global"
should be "org.apache.jackrabbit.oak.segment.SegmentNodeStoreFactory~global".
Looking at CompositeNodeStoreService it only references
NodeStoreProvider services and not NodeStore services. It registers
itself as a NodeStore however, so in addition to a falty
CompositeNodeSore the system might get confused with two registered
NodeStore instances (one composite NS, one segment NS).

I hope this is correct and helps. YMMV.

Regards
Julian


On Tue, Mar 31, 2020 at 11:13 PM Andreas Schaefer
 wrote:
>
> I posted that to Jackrabbit Oak Dev mailing list (oak-dev) but did not get a 
> response so far.
>
> There are three things that looks bad to me:
>
> 1. The Global Node Store Service is not recognized as Global Node Store in 
> the Composite Node Store
> 2. The Global Node Store Factory is by definition only a secondary Node Store 
> even though with role composite-global it is treated like one
> 3. The Composite Node Store does not maintain a list of Node Store it 
> aggregates or maybe the name is wrong and it is more or less a redirector for 
> the given paths. That said if I have more than one secondary Node Stores I am 
> not sure how it then figures out which one to use
>
> - Andy
>
> > On Mar 31, 2020, at 1:06 PM, Daniel Klco  wrote:
> >
> > Thanks for looking into this Andy! I've been very curious about this as
> > well. The documentation is not detailed to say the least.
> >
> > I do wonder if this is an Apache Sling question or an Apache Jackrabbit
> > question though.
> >
> > On Tue, Mar 31, 2020 at 4:02 PM Andreas Schaefer 
> > wrote:
> >
> >> Hi
> >>
> >> Ruben and I want to setup a Sling 12 instance with a composite node store
> >> where /libs and /apps is in a read only repository and the rest in a
> >> read/write repo (general).
> >>
> >> I tried several approaches but for now I already fail by just trying to
> >> create a composite node store.
> >> This is my most promising approach:
> >>
> >> 1. Create a Segment Node Store for global
> >>
> >> "org.apache.jackrabbit.oak.segment.SegmentNodeStoreService~global": {
> >>  "service.ranking:Integer": "100",
> >>  "name": "Oak-Segment-Tar",
> >>  "repository.home": "launcher/repository-global",
> >>  "host": "localhost"
> >> },
> >>
> >> 2. Create a Secondary Segment Node Store using the factory:
> >>
> >> "org.apache.jackrabbit.oak.segment.SegmentNodeStoreFactory~libs": {
> >>  "repository.home": "launcher/repository-libs",
> >>  "customBlobStore": false,
> >>  "role": "composite-mount-libs",
> >>  "nodeDeduplicationCache.size": 0
> >> },
> >>
> >> 3. Create a Mount Info Provider for libs:
> >>
> >> "org.apache.jackrabbit.oak.composite.MountInfoProviderService": {
> >>  "mountName": "libs",
> >>  "readOnlyMount": false,
> >>  "pathsSupportingFragments": [
> >>"/oak:index/*$"
> >>  ],
> >>  "mountedPaths": [
> >>"/libs",
> >>"/apps",
> >>"/jcr:system/rep:permissionStore/oak:mount-libs-crx.default"
> >>  ]
> >> },
> >>
> >> 4. Finally create a Composite Node Store:
> >>
> >> "org.apache.jackrabbit.oak.composite.CompositeNodeStoreService": {
> >>  "seedMount": "libs",
> >>  "enabled": true,
> >>  "enableChecks": false
> >> }
> >>
> >> This setup fails because there is no global node store and therefore the
> >> composite node store is not created.
> >>
> >> When I create a Segment Node Store Factory Service for a global node store
> >> the composite node store is activated but still all changes are made in the
> >> global node store.
> >>
> >> When I start sling with just a global node store and then create a
> >> symbolic like from the global NS to the segment node store factory name
> >> (appended role)  then Sling is not starting correctly.
> >>
> >> Cheers - Andy
>


Re: Sling XML Namespace

2020-02-13 Thread Julian Sedding
Hi John

XML namespace names are usually URIs, supposedly to avoid collisions.
However, they are not required to be a URI nor are they required to
point to an actual document. The Wikipedia article on XML namespaces
has more detail:
https://en.wikipedia.org/wiki/XML_namespace#Namespace_names

The last sentence of the linked section sums it up nicely:

"In general, however, users should assume that the namespace URI is
simply a name, not the address of a document on the Web."

Regards
Julian

On Wed, Feb 12, 2020 at 10:08 PM John Kramer
 wrote:
>
> Hi guys,
>
> Sorry if this question is a bit naïve.
>
> I see the xml namespace http://sling.apache.org/jcr/sling/1.0 all over source 
> files, but that link is a 404. Where can I actually look at the namespace 
> definitions?
>
> Thanks!
>
> John Kramer
> Java Software Engineer
> E-Commerce Web Team
> e: john.kra...@panerabread.com
> m: 314-435-2370


Re: Executing xpath query with number in path

2019-09-05 Thread Julian Sedding
Hi Roy

Like others said before, ISO9075 is what you need. You only need to
encode the first digit. The encoding is simple enough to remember (if
used regularly ;) ):

0: _x0030_
1: _x0031_
2: _x0032_
...

Your query would thus become:
/jcr:root/content/launches/_x0032_019/_x0030_8/_x0032_9/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

As a shortcut in situations where the depth is known I sometimes use:
/jcr:root/content/launches/*/*/*/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

Another alternative would be:
/jcr:root/content/launches/*[fn:name() = '2019']/*[fn:name() =
'08']/*[fn:name() =
'29']/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

I believe that the ISO9075 encoded version performs best, but I didn't
verify that claim. Most likely performance is not your main concern in
any case, as all of the above should be reasonable fast  ;)

Regards
Julian

On Thu, Aug 29, 2019 at 6:52 PM Eric Norman  wrote:
>
> If I recall correctly, if you want to use paths in XPath queries then you
> need to escape the path segments according to ISO9075 rules.   For your
> referenced, there is a brief section about that on the wiki at [1].
>
> Also, there is a utility class in jackrabbit that can do the ISO9075 path
> encoding for you at [2] that you may utilize.
>
> 1.
> http://jackrabbit.apache.org/archive/wiki/JCR/EncodingAndEscaping_115513396.html
> 2.
> http://jackrabbit.apache.org/api/trunk/org/apache/jackrabbit/util/ISO9075.html
>
> I hope that helps.
>
> On Thu, Aug 29, 2019 at 8:54 AM Roy Teeuwen  wrote:
>
> > 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: Flexible adaptable not resulting in instantiation of correct model

2019-06-12 Thread Julian Sedding
Hi Liam

Based on the fact that the @Self injection should provide a Resource
object,  I assume your model is adaptable from a Resource (it would
help to provide the class including its @Model annotation).

The way this feature is implemented, I assume that it does not work
for adapting Resource objects. The reason is that the
SlingModelsUseProvider can handle the adaption before the
JavaUseProvider, but the implementation is only in the
JavaUseProvider.

The tests for SLING-6504 implement an adapter factory by hand (i.e.
don't use @Model), which is (I assume) why the SlingModelsUseProvider
doesn't handle it and the JavaUseProvider get's a chance.

Therefore, a workaround would be to implement an adapter factory by
hand. I agree that that kind of defies the point of Sling Models.
Another workaround might be to restrict your Sling Model to a specific
resource type.

I suggets you open a JIRA ticket and maybe you can provide a PR to
enhance the SlingModelsUseProvider to support the "adaptable" argument
as well.

@Vlad: I'm not sure that the feature is "not designed" to work with
Sling Models (after all Sling Models is just a convenient way to
register an adapter factory). I would be of the opinion that this is a
bug (or at least a limitation/oversight in the implementation). It
clearly is a violation of the principle of least surprise, which I
believe should be avoided.

Regards
Julian

On Wed, Jun 12, 2019 at 8:44 AM Vlad Bailescu  wrote:
>
> Hi Liam,
>
> AFAIK, the mentioned pattern is not designed to work with Sling Models. It
> simply uses the adaptTo pattern to transform the adaptable to the given
> class.
>
> Best,
> Vlad
>
>
> On Tue, Jun 11, 2019 at 9:00 PM Liam C  wrote:
>
> > Hello,
> >
> > Is anyone able to replicate this, or to confirm that they have been
> > able to get something similar to { 'com.example.ModelClass' @
> > adaptable=item} working in their projects, please?
> >
> > Failing this, is there some workaround that could be used within
> > Sightly/HTL to adapt a specified resource to a Model class? Although
> > it is possible to access resource properties (e.g. item.myProperty),
> > some business logic is contained within models that requires access
> > via getters rather than via the resource properties.
> >
> > Thanks for any guidance.
> >
> > Liam
> >
> > On 2019/04/01 12:13:43, Liam C  wrote:
> > > Hello everyone,
> > >
> > > In SLING-6504 (https://issues.apache.org/jira/browse/SLING-6504),
> > > functionality was added to allow adapting a resource that is different
> > > to the underlying page resource. Feike Visser's example
> > > (
> > https://github.com/heervisscher/htl-examples/commit/93666b5eebdeb36c25adf2e310f55049ec3767ce
> > )
> > > suggests that it is possible and simple, but I haven't managed to
> > > succesfully implement it. In my experience so far, the adaptable is
> > > ignored.
> > >
> > > If I use the following code in my Sling Model:
> > >
> > > @Self
> > > Resource adaptable;
> > > public Resource getAdaptableSelf()
> > > {
> > > return adaptable;
> > > }
> > >
> > > ...it reveals that the adaptable that reaches the model is null.
> > >
> > > I wondered if this might have to do with the fact that the code in
> > > SLING-6504 modified the JavaUseProvider, but the
> > > SlingModelsUseProvider handles the instantiation before the
> > > JavaUseProvider can be reached.
> > >
> > > Can anyone confirm whether this option is still working in Sling 11?
> > >
> > > Thanks,
> > >
> > > Liam
> > >
> >


Re: Multiple threads on same resource resolver

2019-03-29 Thread Julian Sedding
Hi Roy

Do your Site objects reference a resource resolver instance, e.g. via
a resource? If they do then it's likely the warning comes from this RR
being used concurrently.

Other than that (bar closing the RRs in the thread), I can't see
anything obviously wrong with your last code snippet.

Regards
Julian

On Thu, Mar 28, 2019 at 10:01 AM Roy Teeuwen  wrote:
>
> 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
>


Re: Upgrading to Oak 1.10.0 for Sling10

2019-02-25 Thread Julian Sedding
Hi Marc

>From your log, I suspect that the "sling" and "slingevent" Namespaces
are (not yet?) registered when the repository is being initialized.
During repository initialization all installed OSGi bundles are
inspected in order to see whether they contribute namespaces or
node-type definitions (via special manifest headers and embedded *.cnd
files).

The "sling" namespace is defined by the bundle
"org.apache.sling.jcr.resource", the "slingevent" namespace by
"org-apache-sling-event". Try making sure that they are installed
before repository initialization happens.

It may help to enable debug logging for "org.apache.sling.jcr.base" to
better understand when during initialization this happens.

Note: this advice is based on speculation, so YMMV.

Regards
Julian

On Sat, Feb 23, 2019 at 1:45 AM  wrote:
>
> Robert,
>
> Thanks for thinking about this issue with me.
>
> You asked: do you have any custom code that plugs into the repository 
> initialisation?
> I can not find any custom classes that are implementing RepositoryInitilizer.
>
> We have a custom class which provides the SlingRepository service and a 
> service ranking of 1000. It wraps the OakSlingRepositoryManager
>
>  
> @Reference(target="(component.name=org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager)")
>  private SlingRepository repository;
>
> We do this so that we can cast the Sessions as our own special Session 
> objects. This is what I've been able to figure out from walking up to this 
> project. This may be a defunct pattern since we have moved from Sling6 to 10 
> recently.
>
> The order of the bundles
> CustomWorkspace (14) <- contains the custom impl of
> Oak bundles(15)
> Sling JCR Oak Server (16)
>
> I've tried moving the order of the bundles around to see if I had something 
> in common with SLING-4556, but again this grasping with hope.
>
> You asked: "Are you able to inspect the repository after in the scenario 
> where this fails?"
> As far as a can tell the repository is completely unavailable. But I'm open 
> to debugging suggestions.
>
> You asked: "Can you adjust the configuration of the QuartzScheduler to 
> include 'oak' in the allowed pool names?"
> I'm not sure how to do this. Also, I see this error in both working and non 
> working instances.
>
> I've been looking at the logs from the working and failed state trying to 
> find an error or warning that is in one but not the other.  It looks like the 
> OakConstraint error on the missing null primary type actually happens in both 
> situations. So I think tracking down my first error message suspect is a dead 
> end.
>
> I lopped off the timestamps so I could diff the logs from a good and a bad 
> state. Below I've added the log messages I should have focused on.  Is there 
> a proper way to share whole logs on this mailing list? Attaching a 9mb file 
> didn't seem appropriate.
>
> Thank you for all you time so far,
> Marc
>
> 22.02.2019 12:52:40.867 *ERROR* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager
> start: Uncaught Throwable trying to access Repository, calling
> stopRepository()
> java.lang.NullPointerException: null
>  at
> org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:478)
>  at
> org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:85)
>  at
> org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:455)
> 22.02.2019 12:52:40.867 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager stop:
> Repository still running, forcing shutdown
> 22.02.2019 12:52:40.868 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [482,
> [org.apache.jackrabbit.api.jmx.QueryStatManagerMBean]] ServiceEvent
> UNREGISTERING
> 22.02.2019 12:52:40.869 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [483,
> [org.apache.jackrabbit.oak.api.jmx.RepositoryStatsMBean]] ServiceEvent
> UNREGISTERING
> 22.02.2019 12:52:40.870 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [484, [java.lang.Runnable]]
> ServiceEvent UNREGISTERING
> 22.02.2019 12:52:40.871 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [485,
> [org.apache.jackrabbit.oak.spi.gc.GCMonitor]] ServiceEvent UNREGISTERING
> 22.02.2019 12:52:40.874 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [403,
> [java.util.concurrent.Executor]] ServiceEvent UNREGISTERING
> 22.02.2019 12:52:40.875 *INFO* [Apache Sling Repository Startup Thread]
> org.apache.sling.jcr.oak.server Service [474, [java.lang.Runnable]]
> ServiceEvent UNREGISTERING
> 22.02.2019 12:52:40.896 *INFO* [Apache Sling Repository 

Re: How to create a namespace mapping from a remote test?

2019-02-08 Thread Julian Sedding
Hi Christian

I can see two options. However, both require deploying a custom bundle.

1. The JCR Content Loader has support for installing *.cnd files[0].
I.e. a (very slim) bundle could be installed to register a namespace
declared in a cnd file.
2. Deploy a custom bundle with a servlet that allows registering a
namespace. The servlet could even implement the majority of your test
case. I'm not sure how far the Teleporter junit rule would get you,
but it may be worth looking into.

Regards
Julian

[0] 
https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html#declared-node-type-registration

On Thu, Feb 7, 2019 at 10:53 AM Christian Schneider
 wrote:
>
> I would like to reproduce a problem with replication when a namespace is
> not present on publish.
>
> So I would like to:
> - create a new namespace mapping on author
> - Create a node with an attribute that uses the new namespace
> - publish the node to author and check if it is correct
>
> I can do all the steps but the namespace mapping creation.
>
> Does anyone know how to do this? I have not found any means on the sling
> testing client to do it.
>
> Christian
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Computer Scientist
> http://www.adobe.com


Re: Segment Tar based Sling clustering

2018-11-19 Thread Julian Sedding
Hi Stepan

This question is better suited for the Jackrabbit Oak list.

But here's my take anyways:

I am pretty sure that option 2 is not possible, because Segment Tar
assumes that the files are private to a single VM instance.

If I understand you correctly, in option 3 you are considering to use
some sort of remoting (e.g. RMI). While this may theoretically work, I
don't think you would get any (many?) of the benefits of a cluster.

Bottom line: Jackrabbit Oak offers different persistence options. Only
Mongo and RDBMS can be clustered. Segment Tar is implemented for a
different use-case (small, fast, independant instances).

Regards
Julian
On Fri, Nov 16, 2018 at 9:49 PM Степан Гащишин
 wrote:
>
> Hello,
>
> I am curious about the available ways to cluster sling, and from current
> standpoint I can observe next 3 options:
> - obviously Mongo based deployment
> - Segment Tar based deployment ( where two instances of Sling will use the
> same, mounted repository folder)
> - remote Oak deployment ( where two Slings will access standalone Oak
> server, which will use Tar based repo inside)
>
> My concerns are about latest 2 options. In theory i suppose third option
> may be possible to work. And i majorly doubt regarding the second.
>
> So that I want to ask community to describe if such ways of clustering are
> possible, and maybe there are some extra which i missed.
>
> Thank you in advance,
> Stepan


Re: JCR Observation, Type ResourceResolver & idle JCR sessions

2018-08-27 Thread Julian Sedding
Hi Jörg

I would argue that a new ResourceResolver for each "onEvent" call
would be advisable. Not only to avoid the problem you observe, but
also to avoid the risk of the session being used concurrently from
multiple threads. Not sure if JCR event hanlders may be called
concurrently though.

The alternative, which doesn't guard against concurrent use, would be
to call refresh on the long-lived ResourceResolver, which you use to
register the JCR event listener, as the first thing in the "onEvent"
call. This will also refresh the internal
"resourceTypeResourceResolver" if it exists (it is created when
isResourceType() is called for the first time on a ResourceResolver,
and it is bound to that ResourceResolver's life-cycle).

Regards
Julian

On Mon, Aug 27, 2018 at 10:38 AM Jörg Hoh
 wrote:
>
> Hi all,
>
> I just came across an exception which makes me wonder how to adress it;
> it's a JCR observation listener, which has been opened on the JCR session
> of a Sling ResourceResolver. And inside of the event handler the
> isResourceType() method of the Resource Resolver is called.
>
> 27.08.2018 11:16:42.092 *WARN* [sling-oak-observation-1]
> org.apache.jackrabbit.oak.jcr.session.RefreshStrategy This session has been
> idle for 1 minutes and might be out of date. Consider using a fresh session
> or explicitly refresh the session.
> java.lang.Exception: The session was created here:
> at
> org.apache.jackrabbit.oak.jcr.session.RefreshStrategy$LogOnce.(RefreshStrategy.java:170)
> at
> org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:285)
> ...
>at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.isResourceType(ResourceResolverImpl.java:1236)
> at
> org.apache.sling.api.resource.AbstractResource.isResourceType(AbstractResource.java:121)
> at com.mycorp.some.Observation.Listener.onEvent(Listener.java:273)
> at
> org.apache.jackrabbit.commons.observation.ListenerTracker$1.onEvent(ListenerTracker.java:190)
> at
> org.apache.jackrabbit.oak.jcr.observation.ChangeProcessor.contentChanged(ChangeProcessor.java:508)
>
> For me it seems that with the call of the "isResourceType" method a second
> ResourceResolver (the "type resource resolver") is opened which is backed
> by a JCR session as well. But because this session lives in the context and
> livecycle of the single ResourceResolver (which is primarily used for the
> JCR observation), it's a long running session and would need a timely
> refresh.
>
> What's the best way to solve this and avoid the WARN message? Use a
> dedicated session when doing the type checks, so the resource resolvers are
> not tied to a single livecycle? Also just adding some refresh() statements
> to the type resolver seems not good, because then the type resolver might
> see a different state of the repo than the other ("main") session.
>
> Jörg
>
>
> --
> Cheers,
> Jörg Hoh,
>
> http://cqdump.wordpress.com
> Twitter: @joerghoh


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

2017-11-17 Thread Julian Sedding
Congratulations Robert!

Regards
Julian

On Thu, Nov 16, 2017 at 5:29 PM, Roy Teeuwen  wrote:
> 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
>


Re: Export content as JSON ready to be imported

2017-04-04 Thread Julian Sedding
Hi Guillaume

AFAIK Jackrabbit FileVault uses a similar approach. I'm not super
familiar with the code, but you may find interesting details if you
look at the classes JackrabbitACLImporter[0] and/or
JcrACLManagement[1].

The order of ACEs is significant. IIRC later entries "override"
earlier ones (provided the principal matches). However, an ACE for a
principal representing a user always is "stronger" than one
representing a group (not really your concern when importing though).

Further reading regarding access control[2] can be found on the
Jackrabbit Oak website.

Regards
Julian

[0] 
https://github.com/apache/jackrabbit-filevault/blob/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
[1] 
https://github.com/apache/jackrabbit-filevault/blob/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/spi/impl/jcr20/JcrACLManagement.java
[2] http://jackrabbit.apache.org/oak/docs/security/accesscontrol.html

On Tue, Mar 28, 2017 at 4:32 PM, Guillaume Lucazeau  wrote:
> Hello Bertrand,
>
> Thank you for your reply. I have created SLING-6738 for the ACLs import.
>
> Before adding unit tests and sending a PR, I would like to know if I'm
> going in the right direction.
>
> I've seen that in JsonReader there are already createAce and createAcl
> methods, but they are used to create ACLs from the acl.json servlet.
>
> So, I've modified the handleSecurity method, and if the node is named
> "rep:policy", I call my own method "createAceFromPolicy". This method just
> loops on the subnodes of a "rep:policy" node (i.e. keys starting with
> "allow" or "deny", gather all information and calls
> contentCreator.createAce.
>
> It works fine for my case, but I would be curious to have some feedback and
> make sure I didn't forget anything. At the beginning of the discussion
> Robert was talking about editing the content importer, but I couldn't find
> how I was suppose to do that.
>
> Also, I would like to know if the order of the ACE is important. As there
> is no order property on the JSON returned by the content servlet, and has
> JSON is not ordered, I'm not able so far to keep the original order.
>
> Thank you for your help,
>
> Guillaume
>
> 2017-03-28 11:56 GMT+02:00 Bertrand Delacretaz :
>
>> Hi,
>>
>> On Tue, Mar 28, 2017 at 11:25 AM, Guillaume Lucazeau
>>  wrote:
>> > ...Considering the lack of responses, Re-importing exported JSON,
>> including
>> > the priviliges, doesn't seem to be a feature that lots of people need,
>> so I
>> > will try to patch the importer on my own :)..
>>
>> I actually have a use case for this on my list, but that's a long list
>> so I'm not sure when I'll start working on it.
>>
>> > ...I was wondering if pull requests on Github are the best way to submit
>> > patches to Sling, or if you prefer diff files attached to a ticket...
>>
>> We need a jira ticket in any case, but submitting patches as pull
>> requests works.
>>
>> Looking forward to your contributions!
>>
>> (and don't forget the tests ;-)
>>
>> -Bertrand
>>


Re: How to change run mode in Sling8

2017-01-11 Thread Julian Sedding
Why are you running the war file on Tomcat? It's not wrong of course.
However, I believe that most users use the standalone jar and
therefore help may be more readily available for that setup.

Regards
Julian


On Wed, Jan 11, 2017 at 4:19 AM, lancedolan  wrote:
> I cannot change run mode using the process I have in the past, with Sling8.
>
> The only thing that has worked for me was to crack open the
> org.apache.sling.launchpad-8-webapp.war file, crack open the oak jar file
> within it, edit sling_install.properties
> (sling.run.mode.install.options=oak|oak_mongo), and then zip it all back up
> again. This feels _wrong_ haha.
>
> Things I tried, which failed:
>
> -The Apache Sling Settings Service in OSGI console. It even says "The
> settings service manages some basic settings of Sling like run modes."
> However, there is no run mode config there.
>
> -JVM arguments. I've tried -Dsling.run.mode.options=oak,oak_mongo and
> -Dsling.run.modes=oak,oak_mongo. No luck.
>
> -Searched for other configurations in the configMgr console.
>
> How do I just tell a Sling instance to stop running oak_tar and start
> running oak_mongo?
>
>
>
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Read cache contents being continuously sent from primary to cold standby?

2016-11-08 Thread Julian Sedding
Hi John

I think you might have more luck with this question on the jackrabbit
users list. Sling uses Jackrabbit Oak under the hood, but the real
expertise is over there.

Regards
Julian

On Tue, Nov 8, 2016 at 8:08 PM, John Logan  wrote:
> Hi,
>
> Is there anyone who can provide guidance on a cold standby issue?
>
> It appears that my cold standby has made progress since my original
> email (below), but now I'm seeing a behavior that I didn't expect.
>
> The tarmk.log (below) for my cold standby shows that the head is being
> updated every 5-10 hours, with the longer intervals corresponding
> to 3pm to midnight local time.
>
> The primary's JMX standby metrics show that the number of transferred
> segments is not changing, while the number of transferred binaries
> continues to increase.
>
> I did some other checks on the read caches and the shared S3 bucket,
> and it looks like read cache contents are continually being
> transferred from the primary to the secondary, over and over
> again.  Is this what I should see?  If not, how do I troubleshoot
> this?
>
> Thanks!  John Logan
>
> tarmk.log:
>
> 2016-11-05 23:30:05,045 sending head request
> 2016-11-05 23:30:05,045 did send head request
> 2016-11-05 23:30:05,081 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-06 10:09:25,044 sending head request
> 2016-11-06 10:09:25,044 did send head request
> 2016-11-06 10:09:25,092 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-06 15:07:50,045 sending head request
> 2016-11-06 15:07:50,045 did send head request
> 2016-11-06 15:07:50,082 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-06 20:10:20,044 sending head request
> 2016-11-06 20:10:20,045 did send head request
> 2016-11-06 20:10:20,120 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-07 06:26:50,044 sending head request
> 2016-11-07 06:26:50,044 did send head request
> 2016-11-07 06:26:50,085 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-07 11:23:15,045 sending head request
> 2016-11-07 11:23:15,045 did send head request
> 2016-11-07 11:23:15,140 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-07 17:07:00,045 sending head request
> 2016-11-07 17:07:00,045 did send head request
> 2016-11-07 17:07:00,141 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-07 22:01:40,052 sending head request
> 2016-11-07 22:01:40,052 did send head request
> 2016-11-07 22:01:40,099 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-08 08:26:35,044 sending head request
> 2016-11-08 08:26:35,044 did send head request
> 2016-11-08 08:26:35,183 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
> 2016-11-08 14:05:50,046 sending head request
> 2016-11-08 14:05:50,046 did send head request
> 2016-11-08 14:05:50,159 updating current head to 
> 4cbe6d89-284c-4c4b-ac34-498068a9bcca.fe09
>
>
> On Wed, 2016-11-02 at 17:28 +, John Logan wrote:
>> Hi,
>>
>> I'm setting up a TarMK cold standby for a repository for the first time, and
>> have a couple of questions regarding synchronization and administration.
>> I've included the configuration and current dump of the primary and standby
>> MBeans below.  The primary and standby are in peered VPCs in AWS, using a
>> shared S3 bucket for blob storage.
>>
>> 1.) I'm curious as to how long I should expect to wait for the standby
>> to establish synchronization.  How much data gets moved over the wire?
>> I'm seeing a steady stream of read cache invalidations on the standby -
>> does this mean that all of the blob data must be transferred, even
>> though the two repositories use shared storage?
>>
>> 2.) I see in the logs a period where there are read cache invalidations,
>> and then there is a 12 hour period where nothing is logged, followed
>> by a 
>> "org.apache.jackrabbit.oak.plugins.segment.standby.client.SegmentLoaderHandler
>>  timeout"
>> message.  The quiet period is consistent with my setting
>> standby.readtimeout=I"4320".  Would it make sense to choose a
>> shorter timeout to lessen the impact of occasional network issues?
>> At what point might the timeout value be "too short"?
>>
>> 3.) Is there a definitive way to know that the standby is synced?
>> The SyncEndTimestamp value below corresponds to 2016-11-02T09:26:18+00:00,
>> which corresponds exactly to the timestamp of the
>> "SegmentLoaderHandler timeout" message.  This suggests that this
>> value doesn't really tell me that the standby is synchronized.
>> When I tried with small repositories, it appears that synchronization
>> was done when the tarmk.log file started outputting the same repository
>> head every 5 seconds ("interval" setting).
>>
>> 4.) Assuming that the standby eventually becomes synchronized,
>> is there a documented procedure by which I could "split the mirror";

Re: OO style inheritance of master website to child websites

2016-10-20 Thread Julian Sedding
The "Superimposing Resource Provider"[0] was created for this (or a
similar) use-case. YMMV.

Regards
Julian

[0] https://github.com/apache/sling/tree/trunk/contrib/extensions/superimposing

On Thu, Oct 20, 2016 at 2:59 PM, Bertrand Delacretaz
 wrote:
> Hi,
>
> On Thu, Oct 20, 2016 at 2:28 PM, Carsten Steckel
>  wrote:
>> ...Inheritance comes to mind where a Master website is defined and every 
>> child
>> inherits its masters config, content, assets, ... but overwrites if
>> necessary...
>
> The Sling Resource Merger [1] goes in that direction but I haven't
> heard so far from people using it in the way that you mention, what
> I've seen is simpler use cases where configuration-like resources are
> being merged.
>
> But if you stick to the Sling Resource API (as opposed to JCR) and
> manage access rights carefully it might work for your use case.
>
> -Bertrand
>
> [1] https://sling.apache.org/documentation/bundles/resource-merger.html


Re: launchpad with FileDataStore

2016-10-12 Thread Julian Sedding
 Hi Mike

> I can load the /system/console, but not the .explorer.html app. If I
> set customBlobStore=B"false" it works correctly again.

Are you referring to

(a) configuration being changed in a running system?
(b) configuration changed in previously initialised system and a
subsequent restart?
(c) a completely new system with the changed configuration, started
for the first time?

I would only expect (c) to work. If it doesn't, go to
/system/console/components and find the SegmentNodeStoreService, click
on it and check that for the "Reference blobStore" is "Satisfied" and
is "Bound" to a service with the PID
org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore.

Note: in your original post you used
org.apache.jackrabbit.core.data.FileDataStore as the configuration PID
instead of org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.
The change was in Robert's post, not sure if you noticed. Just
verifying, but this could be a possible cause for your issues.

Regards
Julian



On Thu, Oct 6, 2016 at 4:19 PM, Mike Nimer  wrote:
> One problem when I  make this change Sling will not start correctly.
> When I try to load an html page from my content bundle or the default
> app I get this message
>
> "AuthenticationSupport service missing. Cannot authenticate request."
>
> I can load the /system/console, but not the .explorer.html app. If I
> set customBlobStore=B"false" it works correctly again.
>
> any ideas?
> --mike
>
>
> On Mon, Oct 3, 2016 at 7:44 AM, Robert Munteanu  wrote:
>> Hi Mike,
>>
>> On Tue, 2016-09-06 at 19:26 -0500, Mike Nimer wrote:
>>> If I want to use the FileDataStore for blobs, with the
>>> SegmentNodeStore.  What dependencies do I need to add to my
>>> provisioning txt files, for launched 9-SNAPSHOT?
>>>
>>> Config:
>>> 
>>> [configurations runModes=oak_tar]
>>>   org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService
>>> name="Default\ NodeStore"
>>> customBlobStore="true"
>>>
>>>   org.apache.jackrabbit.core.data.FileDataStore
>>> minRecordLength="1024"
>>> cacheSize="1000"
>>> path="sling/files"
>>> ===
>>>
>>> I thought this would do it:
>>> org.apache.sling/org.apache.sling.installer.core/3.6.8
>>>
>>>
>>> When I set CustomBlogStore="true" the server starts up without any
>>> errors but I can not load the home page or /system/console app.  And
>>> I
>>> noticed that under the sling home folder I don't have the
>>> /repository/segmentstore folder or a /sling/files folder.
>>
>> The following minimal changes worked for me
>>
>> diff --git a/launchpad/builder/src/main/provisioning/oak.txt
>> b/launchpad/builder/src/main/provisioning/oak.txt
>> index 0d0d96b..49fde19 100644
>> --- a/launchpad/builder/src/main/provisioning/oak.txt
>> +++ b/launchpad/builder/src/main/provisioning/oak.txt
>> @@ -83,6 +83,10 @@
>>  [configurations runModes=oak_tar]
>>org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService
>>  name="Default\ NodeStore"
>> +customBlobStore=B"true"
>> +
>> +  org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore
>> +minRecordLength=I"4096"
>>
>>  [configurations runModes=oak_mongo]
>>org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService
>>
>> The main difference is that you would need to indicate the type of the
>> configuration property - so I for numeric and B for boolean.
>>
>> After making this change and building a new launchpad the FDS writes
>> the blobs under sling/repository/repository/datastore. By adding the
>> 'path' configuration option you should be able to control its location.
>>
>> HTH and sorry for the late reply :-)
>>
>> Robert


Re: XPath Query

2016-10-11 Thread Julian Sedding
Ah, now I see. Yes that makes perfect sense.

Regards
Julian

On Tue, Oct 11, 2016 at 2:59 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
> 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 Julian Sedding
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: Querying vs iterating

2016-06-20 Thread Julian Sedding
Hi Roy

Yes, I would expect that you cannot measure any meaningful difference.
Using a query may be marginally faster, because it can traverse using
internal Oak APIs. On the other hand it may be slightly slower,
because of possible QueryEngine overhead.

Personally I would test whether it works sufficiently well with a
query, because it is less code.

Note also that Sling Query
(https://sling.apache.org/documentation/bundles/sling-query.html)
allows you to express a query and choose traversal vs query as a
strategy. This may or may not help.

Regards
Julian


On Mon, Jun 20, 2016 at 3:52 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
> 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: Querying vs iterating

2016-06-20 Thread Julian Sedding
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  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  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  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  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-20 Thread Julian Sedding
Hi Ben

In such cases it is advisable to pass in the ResourceResolver from the
place where you need the Resource objects (or objects backed by live
Resources). Otherwise you cannot close the ResourceResolver OR your
objects are dead.

> Is it a good pattern to have a method in each service that I can call to 
> explicitly close the resolver?
In general I would say NO. Just pass the RR in and close it where you
created it. How would you tell a service to close the correct
ResourceResolver instance anyways? Remember, the service may be called
concurrently.

Regards
Julian



On Wed, Jun 15, 2016 at 4:19 PM, Ben Stockwell  wrote:
> This thread has got me worried about the lifespan of my resolvers,
> especially when the methods return resources. I understand how important it
> is to keep the lifespans short, but if I were to close in that case at the
> end of my method, I'd probably get something like "This session has already
> been closed." I'm probably done with those resources a few function calls
> later. Is it a good pattern to have a method in each service that I can
> call to explicitly close the resolver?
>
> Thanks,
> Ben
>
> On Wed, Jun 15, 2016 at 8:35 AM, Carsten Ziegeler 
> wrote:
>
>> Good catch, yes the javadocs is not precise. I'll update it
>>
>> Thanks
>> Carsten
>>
>> Roy Teeuwen wrote
>> > 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 
>> 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
>> >
>> >
>>
>>
>>
>> --
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziege...@apache.org
>>


Re: Sorting of a JCR Query

2016-03-03 Thread Julian Sedding
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  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


Re: Custom login form with a JSP

2016-01-13 Thread Julian Sedding
Hello Guillaume

Maybe you cannot render the resource, because the "anonymous" user
does not have read permissions? If you want to have a resource based
login page, you need to allow "anonymous" read access.

Hope this help!

Regards
Julian

On Wed, Jan 13, 2016 at 4:15 PM, Guillaume Lucazeau  wrote:
> Hello,
>
> I would like to provide a custom form reusing the form authentication
> provided by Sling, so I have followed this example:
> https://github.com/apache/sling/tree/trunk/samples/custom-login-form
>
> I works well with a static page, however I would like to reuse the
> header/footer fragments that I usually include with  in my
> application, to get the Javascript and CSS files.
>
> Is it possible to use a JSP there, while keeping the authentication
> mechanism provided by Sling?
>
> I didn't succeed to serve a page based on a resource for the authentication
> page, and didn't find much online.
>
> Thank you
> Guillaume


Re: How to reindex lucene

2016-01-06 Thread Julian Sedding
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  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.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
> 

Re: How to reindex lucene

2016-01-06 Thread Julian Sedding
Hi Roy

The issue you observe may be
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 <r...@teeuwen.be> 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 <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: s

Re: How to reindex lucene

2016-01-06 Thread Julian Sedding
I missed the last two messages. The issue mentioned is fixed in 1.0.23
(you are running 10.0.22). Since Chetan fixed it he may know much
better than I do if you may be observing the same issue ;)

Regards
Julian

On Wed, Jan 6, 2016 at 1:15 PM, Julian Sedding <jsedd...@gmail.com> wrote:
> Hi Roy
>
> The issue you observe may be
> 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 <r...@teeuwen.be> 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 <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(ThreadPoolExe

Re: Uploaded file MIME type

2015-10-09 Thread Julian Sedding
Have you inspected your HTTP traffic, specifically the POST request
that your client sends? Your client might be sending the image/x-png
as a Content-Type header. Not 100% sure that the SlingPostServlet
takes that into account, but I think it does.

Regards
Julian

On Fri, Oct 9, 2015 at 9:38 PM, Roll, Kevin  wrote:
> And I thought you were recommending that bundle as a solution. :) I'm still 
> completely stumped here. The MIME mapping table looks fine in the Web 
> Console, and I can't see any vast difference in the way these POSTs are done. 
> Yet, I get the type "image/x-png", whereas a few months ago it properly came 
> out as "image/png".
>
> Can I configure SlingPostServlet to use the content inspection? Can I write 
> my own servlet which extends/filters SlingPostServlet and convinces it to do 
> the right thing? Can I put something in my POST which explicitly sets the 
> MIME type (a not-ideal workaround)?
>
>
> -Original Message-
> From: Robert Munteanu [mailto:romb...@apache.org]
> Sent: Friday, October 09, 2015 3:31 PM
> To: users@sling.apache.org
> Subject: Re: Uploaded file MIME type
>
> On Fri, Oct 9, 2015 at 9:02 PM, Roll, Kevin  wrote:
>> Simply adding that bundle to my app doesn't seem to do the trick. Also, it 
>> looks like this discussion was centered on the Simple WebDav Servlet, 
>> however I am using the POST Servlet in my case. Is there a way to configure 
>> the POST servlet to use the content detection? My use case is low-volume 
>> enough that this is acceptable.
>
> Ah sorry, I though you were following the default launchpad and got a
> behaviour change due to the addition of this bundle.
>
> Robert
>
>>
>> -Original Message-
>> From: Robert Munteanu [mailto:romb...@apache.org]
>> Sent: Friday, October 09, 2015 11:28 AM
>> To: users@sling.apache.org
>> Subject: Re: Uploaded file MIME type
>>
>> On Fri, 2015-10-09 at 13:17 +, Roll, Kevin wrote:
>>> So if I understand correctly there are two possibilities:
>>>
>>> 1. A bundle was added at some point which changed the MIME mappings
>>> for PNG. Am I correct in assuming that any change would be reflected
>>> in the MIME registry as viewed from the Web Console? The mapping
>>> looks correct in my current installation.
>>
>> Maybe
>>
>>   SLING-4694 - Add ability to identify mime type based on file content
>>   https://issues.apache.org/jira/browse/SLING-4694
>>
>> is related?
>>
>> Robert
>>


Re: Control JcrInstaller (OsgiInstaller) Behavior of Bundle Updating vs Installing

2015-09-22 Thread Julian Sedding
Maybe this is abit far fetched. I get the impression that we are (need to
be) moving from a "per artifact" towards a "deployment" paradigm.

Approaches pioneered by crankstart and the provisioning model may become
desirable  (as an option) for the installer.

By specifying the desired deployment state in a provisioning model file,
the installer could make sure it has all required artifacts available (e.g.
local folder, maven repository, etc). Once that is the case it could
update/install/uninstall as it sees fit in order to attain the desired
system state.

This would make the question of "update vs install" mute. Also this new
feature does not preclude the old behaviour.

One open question, however, would be how partial deployments could be
controlled via provisioning model and the rest via the current mechanisms.

Thoughts?

Regards
Julian



On Tuesday, September 22, 2015, Carsten Ziegeler 
wrote:

> Am 22.09.15 um 01:24 schrieb Justin Edelson:
> > IMHO, coming up with general rules is going to be close to impossible.
> > Instead, we should make this configuration explicit, I.e. Have a
> > configuration on the installer which declares the action per BSN.
> >
>
> Well, right now we have general rules and they work for the majority of
> cases well.
> I've had several discussions with different people over the past years
> and it seems changing our rules to take the major version number into
> account is a good compromise - which again should work for the majority
> of cases.
> Granted, a general rule does not always work so we need a way to
> influence that.
> I think we all agree that we need this, they tougher question is really
> how? So far the OSGi installer has zero dependencies to configuration
> admin and I don't think you want to add a configuration to config admin
> whenever you put a file in an install folder.
> In general, as soon as you have to provide two pieces (the artifact and
> the configuration for that artifact) we might run into problems. So it
> would really be good if the artifact itself contains all relevant
> information.
>
> Carsten
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org 
>


Re: Control JcrInstaller (OsgiInstaller) Behavior of Bundle Updating vs Installing

2015-09-22 Thread Julian Sedding
Hi Carsten

I like your idea to use subsystems for provisioning model driven
deployments. From a provisioning model point of view, I suspect this
would provide a namespace/scope for a partial deployment (i.e. the
subsystem).

> There are tons of things we could do and I think we have pretty good
> plans on what / how to do it. We just need to implement them :)

:)

Regards
Julian


On Tue, Sep 22, 2015 at 9:36 AM, Carsten Ziegeler <cziege...@apache.org> wrote:
> Am 22.09.15 um 08:36 schrieb Julian Sedding:
>> Maybe this is abit far fetched. I get the impression that we are (need to
>> be) moving from a "per artifact" towards a "deployment" paradigm.
>
> I don't think this is far fetched.
>
>>
>> Approaches pioneered by crankstart and the provisioning model may become
>> desirable  (as an option) for the installer.
>>
>> By specifying the desired deployment state in a provisioning model file,
>> the installer could make sure it has all required artifacts available (e.g.
>> local folder, maven repository, etc). Once that is the case it could
>> update/install/uninstall as it sees fit in order to attain the desired
>> system state.
>>
>> This would make the question of "update vs install" mute. Also this new
>> feature does not preclude the old behaviour.
>>
>> One open question, however, would be how partial deployments could be
>> controlled via provisioning model and the rest via the current mechanisms.
>>
>
> I think one nice way of dealing with this is to create subsystems out of
> a (partial) provisioning model and deploy these things as subsystems and
> let the subsystem implementation take care of it. Using subsystems has
> additional advantages as it would allow to further control the exports
> (and imports).
>
> We could also leverage the resolver spec: basically what you usually
> want is to deploy a certain feature which comes along as a plain bundle.
> But usually this bundle has requirements which might not be installed in
> the target platform yet. The resolver allows you to find out which
> additional bundles you would need to install. A subsystem could be
> created out of this as well.
>
> There are tons of things we could do and I think we have pretty good
> plans on what / how to do it. We just need to implement them :)
>
> Carsten
>
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org


Re: Control JcrInstaller (OsgiInstaller) Behavior of Bundle Updating vs Installing

2015-09-22 Thread Julian Sedding
Hi Bertrand

I think a partial descriptor approach is a requirement. Firstly,
because it would be hard to transition to an "all or nothing" model in
a single step. Secondly, partial deployments may work well in a
customizable system: one descriptor is the vendor's deployment, the
other contains the client's customizations.

So yes, the challenge is to define an intuitive way of letting the old
and new worlds coexist in harmony.

Regards
Julian



On Tue, Sep 22, 2015 at 8:51 AM, Bertrand Delacretaz
<bdelacre...@apache.org> wrote:
> On Tue, Sep 22, 2015 at 8:36 AM, Julian Sedding <jsedd...@gmail.com> wrote:
>> ...By specifying the desired deployment state in a provisioning model file,
>> the installer could make sure it has all required artifacts available (e.g.
>> local folder, maven repository, etc). Once that is the case it could
>> update/install/uninstall as it sees fit in order to attain the desired
>> system state
>
> I've also been thinking about this lately.
>
> Are you thinking of an absolute approach as in "here's your new
> provisioning model, forget everything and move to that new state" or a
> relative/incremental one where a partial provisioning model specifies
> additions and exclusions?
>
> The former moves us closer to the immutable instances idea, which I
> like, but might be harder to manage when starting from a different
> model.
>
> Creating an installer provider based on the provisioning model
> shouldn't be hard in itself, but managing priorities and overrides
> between the various installation tools could be trickier.
>
> -Bertrand


Re: Route mapping for dynamic resources in Sling

2015-03-09 Thread Julian Sedding
Hi Duy

You may want to implement a ResourceProvider. It allows you to hook an
arbitrary resource subtree into Sling's resource tree backed by your
won logic. For the read-only case that's not even very complicated.

Bertrand created a PlanetResourceProvider example some time ago[0].
That may be helpful.

Regards
Julian

[0]
 
http://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/

On Mon, Mar 9, 2015 at 9:42 AM, Duy Nguyen duy.phngu...@gmail.com wrote:
 For some reasons (large data set, continuous changes in the original
 data, etc.), I'm not motivated to import the whole external data into
 the node tree structure.

 You're right that the universal servlet solution seems to be the very
 last choice, but I couldn't find any other way without importing the
 data.

 Any other advices are very welcomed!

 Thanks,
 Duy

 On Sun, Mar 8, 2015 at 1:22 PM,  jason.bai...@24601.org wrote:



 So in my naïve response to your situation. I don’t see the problem with 
 mapping directly to the resource model,  the first thing I would do is to 
 import the information into the node tree structure. The exact structure 
 isn’t really important as long as it mirrors the intent of the request.




 /content/document1

 /content/document2

 /content/document2/true/version1

 /content/document2/true/version2




 Then for each level where a file should be returned uses a sling 
 sling:resourceType that returns the file.




 If you have restrictions, like you know the name of the file but the 
 versions of the file are maintained separately and you don't have an ability 
 to import.




 You can have a node structure like




 /content/{document}/true




 With the sling:resourceType for the document retrieving the document in 
 question and the resourceType for true locating the version that's being 
 requested.




 If you don't know the document ahead of time, then you're back to a very 
 generic servlet interacting with another system. I would still avoid the 
 universal solution and look to implement something very specific for these 
 types of requests, based an identifier for the service.


 -Jason












 From: Duy Nguyen
 Sent: ‎Friday‎, ‎March‎ ‎6‎, ‎2015 ‎12‎:‎14‎ ‎PM
 To: users@sling.apache.org





 Hi,

 Sorry for the formatting error, as there were 3 different urls actually:

 /myhost/{documentName}

 /myhost//{hasRevision}/{revisionID}

 /myhost/-/users/{userName}

 * So in your example, it is like:

 /host/whitepaper

 /host/whitepaper/true/version-1

 /host/-/users/john123

 (I avoid .pdf as it can be misleading to a selector which is not the
 idea of my question)

 ---
 Duy


 On Fri, Mar 6, 2015, at 15:15, Jason E Bailey wrote:

 So I can get a clear picture of the request, a typical request would be
 for?

 /host/whitepaper.pdf/host/true/version-1/host/-/users/john123


 --=20
 Jason

 On Fri, Mar 6, 2015, at 09:50 AM, Duy Nguyen wrote:
  Hello,
=20
 I'm bringing here a use case in Sling and look forward to receiving some
 opinions from the community.
=20
 I need to write a server-side app that serves customized RESTful APIs for
 a
 client app (which is stable and the set of APIs is fixed). The problem
 comes from ugly API urls that can hardly be mapped into the resource
 model of Sling, for example:
=20
 */myhost/{documentName}/myhost/{**documentName*
 *}/{hasRevision}/{revisionID}/myhost/-/users/{userName}*
=20
 Especially properties like =E2=80=9CdocumentName, =E2=80=9CrevisionID a=
 nd userName
 are
 not necessarily stored in jcr resources, but can also be from external
 sources. The flag =E2=80=9ChasRevision=E2=80=9D is either true or false v=
 alue, to check
 if
 the document has revision to be returned. So there must be some
 middleware
 that handles the requests coming to each of those paths (to determine if
 the needed resource can be retrieved from jcr or external sources, and
 revision to be taken into account).
=20
 Thinking in the implementation of some regular web frameworks (Django,
 Sinatra, etc.), it can be done by route mapping, such as:
 *get(/myhost/:**documentName*
 */:hasRevision?/:revisionID?) function()
 {=E2=80=A6}get(/myhost/-/users/:userName) function() {=E2=80=A6}*
=20
 Initially I have come up with two solutions in Sling:
=20
 1- Write a global SlingServlet for /myhost/, and then the rest of the
 url are params that will be analyzed in the servlet to handle different
 request patterns. However I don't think this is a very elegant solution,
 because this only one servlet is responsible for all requests following
 the
 path.
=20
 2- Use Sling Resource Mappings
 http://sling.apache.org/documentation/the-sling-engine/mappings-for-reso=
 urce-resolution.html
 to
 redirect the requests (categorized by reg-ex) to different resources, and
 then write separate SlingServlet for each of those resources. I still
 have
 some doubt if this is feasible.
=20
 Do you have some suggestions?
=20
 Thanks,
 

Re: Replacing resolver.getResource() with sling:include

2015-02-04 Thread Julian Sedding
Hi Robert

You could always do the following:

sling:include path=%= resource.getPath() %.config.js
resourceType=my/component/

Regards
Julian


On Wed, Feb 4, 2015 at 12:47 PM, Robert Munteanu romb...@apache.org wrote:
 Hi,

 I have a ResourceResolver.getResource call which I would like to replace
 with a sling:include / .

 What I currently have

 Resource configResource =
 resolver.getResource(my/component/config.js.jsp);
 cq:include script=%=configResource.getPath()% /

 What I want to have

 sling:include resource=%= resource %
 resourceType=my/component replaceSelectors=config /

 The problem here is that I need the extension to be set as well ( the
 original request's extension is set to .html ).

 A brief test done by creating a resource with sling:resourceType
 my/component at /content/test revealed that

 - /content/test.config.js returns the right content
 - /content/test.config.html does not

 So my questions are:

 1. Is there a way I can convince sling:include to include the extension?
 2. Is there isn't, is this a valid enhancement request?

 Thanks,

 Robert



Re: Configuring a service using sling:OsgiConfig

2015-02-02 Thread Julian Sedding
The class org.apache.sling.installer.provider.jcr.impl.JcrInstaller is
by default configured to only take folders into account that are
called install. In CQ/AEM folders may be called install or
config.

Regards
Julian

On Mon, Feb 2, 2015 at 1:54 PM, Bertrand Delacretaz
bdelacre...@apache.org wrote:
 Hi,

 On Mon, Feb 2, 2015 at 1:48 PM, connuser1 connuser1 connus...@gmail.com 
 wrote:
 ...Editing the
 config once using felix console does some (binding...?) magic which I am
 not sure of

 If you are able to edit your config from the Felix console it means
 that it was indeed created...

 If you create sling:OsgiConfig nodes and the corresponding config
 appears at /system/console/status-Configurations, all is good as far
 as the installer is concerned. If your OSGi component doesn't get the
 config that's a different story, probably a problem in your component.

 -Bertrand


Re: Make a JcrUtils created node writable from WebDAV?

2014-11-26 Thread Julian Sedding
Hi Bruce

Hmm, I'd expect this to work with WebDAV as admin. Creating nodes via
the API and then accessing them via WebDAV is expected, so that should
not cause any issues (provided you use nodetypes that are or inherit
from nt:folder and nt:file).

I believe the fact you see the mounted folder owned by 'bruce' should
not concern you. May it be due to the fact that you used user 'bruce'
to connect?

Sorry, I cannot currently see why it doesn't work for you. I'd
probably continue investigating by taking any locking and versioning
code out of the equation. Also, let us know the URL you use to connect
to WebDAV (at least in the CQ product, there are multiple WebDAV
servlets).

Regards
Julian


On Wed, Nov 26, 2014 at 8:00 AM, Bruce Edge
bruce.e...@nextissuemedia.com wrote:
 Hi Julian,

 The WebDAV mount is authenticated using the default admin account. I know 
 it's probably not a best practice to create nodes using JcrUtils, then jump 
 over to WebDAV to unpack a zip in the new nt:folder node, but this needs to 
 work with older code that expects a filesystem target directory.
 I would have expected the admin account to have appropriate write permissions.

 I find the fact that the new nodes are created using my local user's 
 ownership very odd as the server is running as a sling UID:
 % ps au | grep sling
 sling 7028 19.6  7.0 3832456 287164 pts/4  Sl   22:52   1:10 
 /usr/bin/java -Xmx384M 
 -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n -jar 
 /opt/sling/sling/org.apache.sling.launchpad-8-SNAPSHOT-standalone.jar -c 
 /var/lib/sling -p 8090 -a 0.0.0.0

 -Bruce

 From: Julian Sedding jsedd...@gmail.commailto:jsedd...@gmail.com
 Reply-To: users@sling.apache.orgmailto:users@sling.apache.org 
 users@sling.apache.orgmailto:users@sling.apache.org
 Date: Tuesday, November 25, 2014 at 10:42 PM
 To: users@sling.apache.orgmailto:users@sling.apache.org 
 users@sling.apache.orgmailto:users@sling.apache.org
 Subject: Re: Make a JcrUtils created node writable from WebDAV?

 Hi Bruce

 You could try authenticating your WebDAV connection with the admin
 credentials. If that works, it's likely to be an issue with the setup of
 your JCR permissions. You may well be connecting as anonymous currently and
 therefore be denied writes (I'm not familiar with the vanilla Sling
 permission setup).

 Regards
 Julian


 On Wednesday, November 26, 2014, Bruce Edge 
 bruce.e...@nextissuemedia.commailto:bruce.e...@nextissuemedia.com
 wrote:

 Apologies for asking something that seems like it should be so simple.
 What else do I need to make a node that I create using
 JcrUtils.getOrCreateByPath(..) be writable from WebDAV?

 adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
 adminSession = adminResolver.adaptTo(Session.class);
 Node destinationNode = JcrUtils.getOrCreateByPath(destination,
 JcrConstants.NT_FOLDER, adminSession);
 destinationNode.addMixin(JcrConstants.MIX_LOCKABLE);
 destinationNode.addMixin(JcrConstants.MIX_VERSIONABLE);
 adminSession.save();
 Lock lock = lockManager.lock(destination, true, true, Long.MAX_VALUE,
 NimJcrConstants.INGEST_JOB_TOPIC);

 VersionManager versionManager = workspace.getVersionManager();

 versionManager.checkout(destination);

 I'm calling a legacy library that expects a writable destination folder.
 I'm passing the WebDAV folder name and failing with:

 java.io.FileNotFoundException: /mnt/jcr/test/test.txt (Permission denied)

 The file system view shows the folder is owned by my UID rather than the
 UID of the sling daemon:
 % ls -ld /mnt/jcr/test
 drwx-- 1 bedge staff 2048 Nov 25 16:05 /mnt/jcr/test

 Can I set the file system permissions using javax.jcr?

 -Bruce




Re: looking for feedback

2014-11-25 Thread Julian Sedding
Hi Jason

You should be able to create a txt.jsp file and call your resource
with the txt extension. I.e. /content/foo.txt. This is assuming that
your resource is /content/foo and not /content/foo.html.

Implementing a servlet is (largely) equivalent to implementing a JSP.
So choose whichever is more convenient for implementing your
rendition.

Regards
Julian


On Mon, Nov 24, 2014 at 7:48 PM, Jason Bailey jason.bai...@sas.com wrote:
 I'm still feeling my way around the right way to implement solutions in Sling 
 that follow sling thinking and I'm hoping to get some confirmation from the 
 community.
 I've got a requirement where I need to render an html page as text. It 
 doesn't need to be perfect and I understand that there will be problems with 
 any solution I come up with - that's acknowledged.

 The two ways I have come up with so far are either as a selector, so that I 
 can call /content/foo.html as /content/foo.text.html and then have a text.jsp 
 under a component or maybe a pipeline service that listens for that selector 
 and filters out the text. The other consideration, which I'm leaning towards, 
 is a SlingServlet which would handle the txt extension where I would have it 
 iterate through the page resources and compare with a list of whiteboard 
 services that would render out text where appropriate.

 Anybody know if I'm missing a third option?

 TIA
 -Jason


Re: Make a JcrUtils created node writable from WebDAV?

2014-11-25 Thread Julian Sedding
Hi Bruce

You could try authenticating your WebDAV connection with the admin
credentials. If that works, it's likely to be an issue with the setup of
your JCR permissions. You may well be connecting as anonymous currently and
therefore be denied writes (I'm not familiar with the vanilla Sling
permission setup).

Regards
Julian


On Wednesday, November 26, 2014, Bruce Edge bruce.e...@nextissuemedia.com
wrote:

 Apologies for asking something that seems like it should be so simple.
 What else do I need to make a node that I create using
 JcrUtils.getOrCreateByPath(..) be writable from WebDAV?

 adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
 adminSession = adminResolver.adaptTo(Session.class);
 Node destinationNode = JcrUtils.getOrCreateByPath(destination,
 JcrConstants.NT_FOLDER, adminSession);
 destinationNode.addMixin(JcrConstants.MIX_LOCKABLE);
 destinationNode.addMixin(JcrConstants.MIX_VERSIONABLE);
 adminSession.save();
 Lock lock = lockManager.lock(destination, true, true, Long.MAX_VALUE,
 NimJcrConstants.INGEST_JOB_TOPIC);

 VersionManager versionManager = workspace.getVersionManager();

 versionManager.checkout(destination);

 I'm calling a legacy library that expects a writable destination folder.
 I'm passing the WebDAV folder name and failing with:

 java.io.FileNotFoundException: /mnt/jcr/test/test.txt (Permission denied)

 The file system view shows the folder is owned by my UID rather than the
 UID of the sling daemon:
 % ls -ld /mnt/jcr/test
 drwx-- 1 bedge staff 2048 Nov 25 16:05 /mnt/jcr/test

 Can I set the file system permissions using javax.jcr?

 -Bruce



Re: Script language independent overrides

2014-08-22 Thread Julian Sedding
The approach mentioned by Carsten has two drawbacks:
* it changes the selectors seen by any scripts included further down
the include stack (IIRC this was the reason why sling:call/ was
introduced in the first place)
* resourceResolution has to be done again, even though we know we want
to render the same resource (maybe sling:include
resource=${resource}/ also prevents this, I didn't check)

I created SLING-3874[0] with a proof-of-concept implementation for a
sling:partial/ tag. This allows selecting another rendering script
for the current resource with the specified selector. Downstream
includes are not affected by this, however.

Example page.jsp (see Gabriel's example above):
html
sling:partial selectors=head/
sling:partial selectors=body/
/html

Regards
Julian

[0] https://issues.apache.org/jira/browse/SLING-3874

On Fri, Aug 22, 2014 at 12:11 PM, Gabriel Walt gw...@adobe.com wrote:

 Wow, couldn't believe this was working, very nice!! :)

 Thanks!


 On 22/08/14 11:17, Carsten Ziegeler cziege...@apache.org wrote:

You can simply use sling:include instead, add a selector and your script
act on that specific selector - that's language independent.

Carsten


2014-08-22 10:50 GMT+02:00 Gabriel Walt gw...@adobe.com:


 Thanks for your answers! Let me try to provide more context and be more
 specific.

 With sling:resourceSuperType (or with /apps /libs overlaying), you can
 customize any script of your component. A common practice is to split
 large script templates into partials that can then each be independently
 customized, to avoid full script duplication, and to adapt only parts
 of it.

 The typical example is a page component that can for instance end up
with
 a structure like:
 - page.jsp
 - head.jsp
 - headlibs.jsp
- body.jsp
 - top.jsp
 - content.jsp
 - bottom.jsp
 - bodylibs.jsp

 These scripts are usually all included with something like a sling:call,
 but then this makes it impossible in an extending component to use a
 different script language than the one used in the super-type (so in our
 example we'd be forced to go with JSP, and couldn't use ESP, Sightly,
etc).

 Thus, it would be nice to be able to do an include of script partials
that
 are not binding to a particular script language, like for instance:
 sling:call script=myscript.* /
 instead of:
 sling:call script=myscript.jsp /

 Best,
 Gabriel





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



Re: Script language independent overrides

2014-08-22 Thread Julian Sedding
Yes, I would be in favour of deprecating sling:call/. It never felt
very slingish. If we can also get rid of sling:eval/, I believe we
could even simplify the ServletResolver and remove the methods that
were presumably added to support these tags.

One option could be to extend the sling:call/ tag in the following fashion:
* deprecate script attribute
* if the script attribute is present, remove the extension (i.e.
last dot) and interpret as selectorString
* add new attribute selectors, which is implemented like the
proposed sling:partial/ tag

Unless I am missing something, this would provide backwards
compatibility, while at the same time supporting Gabriel's use-case.

Regards
Julian


Re: Script language independent overrides

2014-08-22 Thread Julian Sedding
If we can keep the sling:include/ tag easy to understand, I would be
happy with such an approach. I fear, however, that it could get overly
complicated.

Just for consideration, I see these two use-cases:
* include a resource (currently sling:include/); this typically
re-dispatches the request internally
* modularize rendering scripts (currently sling:call/); this does
not re-dispatch the request, the context remains the same

Do the two use-cases justify separate tags? I don't know.

Regards
Julian


On Fri, Aug 22, 2014 at 12:56 PM, Carsten Ziegeler cziege...@apache.org wrote:
 I would be in favour of having just one tag, the include one - so if I see
 it correctly the only problem is that it changes the set of visible
 selectors. So if we allow a way to deal with that with the include tag, we
 have a single tag and people have not to wonder which tag to use when.

 Carsten


 2014-08-22 12:51 GMT+02:00 Julian Sedding jsedd...@gmail.com:

 Yes, I would be in favour of deprecating sling:call/. It never felt
 very slingish. If we can also get rid of sling:eval/, I believe we
 could even simplify the ServletResolver and remove the methods that
 were presumably added to support these tags.

 One option could be to extend the sling:call/ tag in the following
 fashion:
 * deprecate script attribute
 * if the script attribute is present, remove the extension (i.e.
 last dot) and interpret as selectorString
 * add new attribute selectors, which is implemented like the
 proposed sling:partial/ tag

 Unless I am missing something, this would provide backwards
 compatibility, while at the same time supporting Gabriel's use-case.

 Regards
 Julian




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


Re: Delayed node creation for audit logging

2013-04-05 Thread Julian Sedding
Hi Lukas

While the Jobs are automatically queued, these queues are persistent.
As I understand you are looking into batching several small writes
into one big write. Thus I don't think a job queue will help you, as
jobs are persisted, I assume using rather small writes.

Depending on what your audit log will record, Events may be an
adequate way to communicate log entries to the audit logger. E.g.
Resource CRUD could be logged in such a way, as the corresponding
events already exist.

In general, I think you want to keep a bounded list/queue of log
entries in memory and persist when the queue is full or after a
defined time interval has passed (for systems with low activity). Of
course this bares the risk of losing = queue-size log entries.

Regards
Julian



On Fri, Apr 5, 2013 at 8:52 AM, Lukas Eder lukas.e...@gmail.com wrote:

 Thanks, Sarwar.

 I had thought about Events and Jobs. This might indeed be the right
 way to implement this myself. I was just wondering if a concrete
 implementation for asynchronous node creation already existed
 somewhere.

 Cheers
 Lukas

 2013/4/4 Sarwar Bhuiyan sarwar.bhui...@gmail.com:
  There is Sling Events and Jobs. You raise events using the event admin. 
  Then write and EventHandler which handles the event and hands off to a 
  JobProcessor.
 
 
  The docs should show an example.
 
 
  Sarwar
  —
  Sent from Mailbox for iPhone
 
  On Thu, Apr 4, 2013 at 11:01 AM, Lukas Eder lukas.e...@gmail.com wrote:
 
  Hello,
  I am looking into the creation of an audit log node structure in a
  Sling-managed Jackrabbit repository. This structure might grow quickly
  to contain many nodes. As writing these nodes one-by-one can be
  costly, I'd like to avoid doing the writing to the repository
  synchronously. Instead, I'd like to dispatch an audit event to some
  sort of message bus, which is consumed by a dedicated Sling process
  that creates the nodes.
  This message bus may be synchronous or asynchronous, but ideally it
  would have some failure recovery mechanism to be sure that all
  dispatched audit events will be persisted to the repository,
  eventually.
  Does something like this already exist in Sling?
  Cheers
  Lukas


Re: Resolving adds repetetivly resource to the resource path

2013-02-05 Thread Julian Sedding
Hi Ulrich

Looking at the Recent Requests trace you provided, I would suspect
that your topnav.jsp has an include on itself. This results in endless
recursion, which is evident by the error you get. I would expect the
error message to be a RecursionTooDeepException, indicating that the
nesting of your scripts is suspiciously deep.

Hope this helps.

Regards
Julian


On Mon, Feb 4, 2013 at 4:50 PM, Ulrich Schmidt
ulrich-dieter.schm...@gombers.de wrote:
 Right now I'm dealing with this problem: The node:
 /apps/mywebsite/components/content/body.jsp references another jsp located 
 at
 /apps/mywebsite/components/topnav/topnav.jsp by the expression:
  cq:include path = topnav resourceType = mywebsite/components/topnav /
 within body.jsp.

 When rendering the webpage I get an error because by resolving the path
 mywebsite/components/topnav the string topnav is iteratively added to the
 ResourcePath. So it looks like:
  /content/mywebsite/en/products/jcr:content/topnav/topnav/topnav

 The error at the browser looks like this:
 Page =  /content/mywebsite/en/products
 ResourcePath =
  /content/mywebsite/en/products/jcr:content/topnav/topnav/topnav
 Cell = topnav
 CellSearchPath = contentpage | page/topnav/topnav/topnav.
 ComponentPath = /apps/mywebsite/en/components/topnav

 I made a mistake somewhere but I don't know where. I can delete what I did and
 try again - this will most probably solve the error. The samle did already 
 run,
 I started over again for training purposes. But it would be better for me to
 find the cause to get a feeling for what might go wrong and how to debug it.
 I can try to lookup any definition I made so far, but I would rather prefer to
 get some knowledge about the debugging possibilities right now available. I 
 know
 the Recent Requests-Trace already. I found the iteration (adding topnav to
 the resource path in a loop), but from this I can'T estimate for the reason.
 And this is what I would like to ask for here. What can I do to understand 
 where
 this behaviour might comes from.

 best Regards,
 Ulrich


  Snippet from the Recent Requests-Trace:

 -02-04 16:07:55) LOG Including script body.jsp for
 path=/content/mywebsite/en/products/jcr:content,
 type=mywebsite/components/contentpage:
 /apps/mywebsite/components/contentpage/body.jsp
 31 (2013-02-04 16:07:55)
 TIMER_START{/apps/mywebsite/components/contentpage/body.jsp}
 31 (2013-02-04 16:07:55) LOG Including resource SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav (SlingRequestPathInfo:
 path='/content/mywebsite/en/products/jcr:content/topnav', 
 selectorString='null',
 extension='html', suffix='null')
 31 (2013-02-04 16:07:55) TIMER_START{resolveServlet(SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav)}
 31 (2013-02-04 16:07:55) TIMER_END{0,resolveServlet(SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav)} Using servlet
 /apps/mywebsite/components/topnav/topnav.jsp
 31 (2013-02-04 16:07:55) LOG Applying Includefilters
 31 (2013-02-04 16:07:55) LOG Calling filter:
 com.day.cq.wcm.core.impl.WCMComponentFilter
 31 (2013-02-04 16:07:55) LOG Calling filter:
 com.day.cq.wcm.core.impl.WCMDebugFilter
 31 (2013-02-04 16:07:55)
 TIMER_START{/apps/mywebsite/components/topnav/topnav.jsp#2}
 31 (2013-02-04 16:07:55) LOG Including resource SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav/topnav
 (SlingRequestPathInfo:
 path='/content/mywebsite/en/products/jcr:content/topnav/topnav',
 selectorString='null', extension='html', suffix='null')
 31 (2013-02-04 16:07:55) TIMER_START{resolveServlet(SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav/topnav)}
 31 (2013-02-04 16:07:55) TIMER_END{0,resolveServlet(SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav/topnav)} Using servlet
 /apps/mywebsite/components/topnav/topnav.jsp
 31 (2013-02-04 16:07:55) LOG Applying Includefilters
 31 (2013-02-04 16:07:55) LOG Calling filter:
 com.day.cq.wcm.core.impl.WCMComponentFilter
 31 (2013-02-04 16:07:55) LOG Calling filter:
 com.day.cq.wcm.core.impl.WCMDebugFilter
 31 (2013-02-04 16:07:55)
 TIMER_START{/apps/mywebsite/components/topnav/topnav.jsp#3}
 31 (2013-02-04 16:07:55) LOG Including resource SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav/topnav/topnav
 (SlingRequestPathInfo:
 path='/content/mywebsite/en/products/jcr:content/topnav/topnav/topnav',
 selectorString='null', extension='html', suffix='null')
 31 (2013-02-04 16:07:55) TIMER_START{resolveServlet(SyntheticResource,
 type=mywebsite/components/topnav,
 path=/content/mywebsite/en/products/jcr:content/topnav/topnav/topnav)}
 31 (2013-02-04 16:07:55) 

Re: Resolving adds repetetivly resource to the resource path

2013-02-05 Thread Julian Sedding
Sling follows the principal of clear separation between public APIs
and implementation. The ResourceResolver is an interface, used to
define the API contract. This provides Sling itself with the freedom
to change or move the implementation (which is ResourceResolverImpl
btw). The implementation should normally not be of your concern,
however. If you're interested, I suggest you check out the Sling
source-code. To my knowledge, CQ also uses Sling's ResourceResolver,
but I am not familiar with the internals of the cq:include tag.

Regards
Julian


On Tue, Feb 5, 2013 at 11:28 AM, Ulrich Schmidt
ulrich-dieter.schm...@gombers.de wrote:
 Oh sh.. - I should have thought of this myself.  Thank you, that was it.

 But there is still the question left about behaviour of the ResourceResolver. 
 I
 think I should understand who is implementing this interface - Sling? CQ5?

 brgds,
 Ulrich




 Julian Sedding jsedd...@gmail.com hat am 5. Februar 2013 um 09:28 
 geschrieben:
 Hi Ulrich

 Looking at the Recent Requests trace you provided, I would suspect
 that your topnav.jsp has an include on itself. This results in endless
 recursion, which is evident by the error you get. I would expect the
 error message to be a RecursionTooDeepException, indicating that the
 nesting of your scripts is suspiciously deep.

 Hope this helps.

 Regards
 Julian


 On Mon, Feb 4, 2013 at 4:50 PM, Ulrich Schmidt
 ulrich-dieter.schm...@gombers.de wrote:
  Right now I'm dealing with this problem: The node:
  /apps/mywebsite/components/content/body.jsp references another jsp 
  located
  at
  /apps/mywebsite/components/topnav/topnav.jsp by the expression:
   cq:include path = topnav resourceType = mywebsite/components/topnav
  /
  within body.jsp.
 
  When rendering the webpage I get an error because by resolving the path
  mywebsite/components/topnav the string topnav is iteratively added to the
  ResourcePath. So it looks like:
  /content/mywebsite/en/products/jcr:content/topnav/topnav/topnav
 
  The error at the browser looks like this:
  Page = /content/mywebsite/en/products
  ResourcePath =
  /content/mywebsite/en/products/jcr:content/topnav/topnav/topnav
  Cell = topnav
  CellSearchPath = contentpage | page/topnav/topnav/topnav.
  ComponentPath = /apps/mywebsite/en/components/topnav
 
  I made a mistake somewhere but I don't know where. I can delete what I did
  and
  try again - this will most probably solve the error. The samle did already
  run,
  I started over again for training purposes. But it would be better for me 
  to
  find the cause to get a feeling for what might go wrong and how to debug 
  it.
  I can try to lookup any definition I made so far, but I would rather prefer
  to
  get some knowledge about the debugging possibilities right now available. I
  know
  the Recent Requests-Trace already. I found the iteration (adding topnav
  to
  the resource path in a loop), but from this I can'T estimate for the 
  reason.
  And this is what I would like to ask for here. What can I do to understand
  where
  this behaviour might comes from.
 
  best Regards,
  Ulrich
 
 
  Snippet from the Recent Requests-Trace:
 
  -02-04 16:07:55) LOG Including script body.jsp for
  path=/content/mywebsite/en/products/jcr:content,
  type=mywebsite/components/contentpage:
  /apps/mywebsite/components/contentpage/body.jsp
  31 (2013-02-04 16:07:55)
  TIMER_START{/apps/mywebsite/components/contentpage/body.jsp}
  31 (2013-02-04 16:07:55) LOG Including resource SyntheticResource,
  type=mywebsite/components/topnav,
  path=/content/mywebsite/en/products/jcr:content/topnav
  (SlingRequestPathInfo:
  path='/content/mywebsite/en/products/jcr:content/topnav',
  selectorString='null',
  extension='html', suffix='null')
  31 (2013-02-04 16:07:55) TIMER_START{resolveServlet(SyntheticResource,
  type=mywebsite/components/topnav,
  path=/content/mywebsite/en/products/jcr:content/topnav)}
  31 (2013-02-04 16:07:55) TIMER_END{0,resolveServlet(SyntheticResource,
  type=mywebsite/components/topnav,
  path=/content/mywebsite/en/products/jcr:content/topnav)} Using servlet
  /apps/mywebsite/components/topnav/topnav.jsp
  31 (2013-02-04 16:07:55) LOG Applying Includefilters
  31 (2013-02-04 16:07:55) LOG Calling filter:
  com.day.cq.wcm.core.impl.WCMComponentFilter
  31 (2013-02-04 16:07:55) LOG Calling filter:
  com.day.cq.wcm.core.impl.WCMDebugFilter
  31 (2013-02-04 16:07:55)
  TIMER_START{/apps/mywebsite/components/topnav/topnav.jsp#2}
  31 (2013-02-04 16:07:55) LOG Including resource SyntheticResource,
  type=mywebsite/components/topnav,
  path=/content/mywebsite/en/products/jcr:content/topnav/topnav
  (SlingRequestPathInfo:
  path='/content/mywebsite/en/products/jcr:content/topnav/topnav',
  selectorString='null', extension='html', suffix='null')
  31 (2013-02-04 16:07:55) TIMER_START{resolveServlet(SyntheticResource,
  type=mywebsite/components/topnav,
  path=/content/mywebsite/en/products/jcr:content/topnav/topnav)}
  31 (2013-02-04 16:07:55

Re: Resource Resolving basic questions

2013-01-28 Thread Julian Sedding
Hello Ulrich

Just a small thing I spotted:

If you request the URI /content/mywebsite/en/products/navimage.png,
the script at /apps/mywebsite/components/contentpage/navimage.png.java
will not help you. It might help you, if you were requesting
/content/mywebsite/en/products.navimage.png (note that I changed the
last slash into a dot, thus triggering the script that responds to the
selector navimage).

If this doesn't work (or if you want to learn more), try requesting
/content/mywebsite/en/products/jcr:content.navimage.png and look at
what's really happening in the previous two requests via
http://localhost:4502/system/console/requests (a very helpful tool, as
Alex suggested). This will point you to the scripts in
/libs/foundation/components/primary/cq/Page, which do some CQ-specific
handling of cq:Page nodes.

Hope this helps and you will soon start enjoying your Sling-experience more.

Regards
Julian


On Mon, Jan 28, 2013 at 11:32 AM, Ulrich Schmidt
ulrich-dieter.schm...@gombers.de wrote:
 Thank you for your comments. they were very valuable – I learned a lot by
 working with them.

 I've added my remarks within the text below.

 Ulrich


 Alexander Klimetschek aklim...@adobe.com hat am 25. Januar 2013 um 20:26
 geschrieben:

 On 25.01.2013, at 18:22, Ulrich Schmidt ulrich-dieter.schm...@gombers.de
 wrote:

  Being new with Sling, I need to get familiar with it. Until now I 
  understand
  that there is no comprehensive reference describing the Sling architecture
  and
  methods in detail. Until now I saw some CQ5-samples which don't work for me
  and
  I don't understand how one comes to expect that they should work.

 There's also

 http://sling.apache.org/site/architecture.html
 http://sling.apache.org/site/dispatching-requests.html
 http://sling.apache.org/site/url-decomposition.html

 and other links on http://sling.apache.org/site/the-sling-engine.html that
 might help.

 And the wiki https://cwiki.apache.org/SLING/index.html has some useful stuff
 as well.




 I saw those pages already. The sites itself don't tell much, I probably have 
 to
 follow the hyperlinks and read it all. It feels like searching the needle in 
 the
 haystack. As this is the the main purpose of Sling - relsoving resources - I
 would have expected that there is a basic description of it. To get a complete
 picture of this very basic stuff I have to combine all of the pages I read 
 until
 now and some more which I missed to read yet. I'm not used to this approach
 having the architectural description of a single function distributed over so
 much documents. But anyway - thank you for the hints. I will work on this and
 maybe ask some other questions in a separate thread.


  This is what I understand so far (source: Sling
  cheatsheet(http://dev.day.com/content/ddc/blog/2008/07/cheatsheet.html) and
  CQ
  Basics (http://dev.day.com/docs/en/cq/current/developing/the_basics.html):
 
  (1) Sling splts the URI in different parts and maps them to the resources.

 Yes.

  (2) The path is either mapped according to the sling:resourceType or the
  sling:resourceSuperType (both attributes either specified to the path-node
  or
  inherited from parents) or to the node (specified by the path) itself; in
  this
  case the node must be of type nt:file or contain a subnode of type nt:file.

 Not really. After parsing the URL, the longest matching resource found is 
 used
 as resource for the request. First step done.



 Isn't that what I explained above exactly that what Lars Trieloff explained in
 his Sling cheatsheet at  number 3 Get Resource Type?. I don't understand,
 what longest match means here. The cheatsheet explains an exact sequence here 
 -
 first sling:resourceType then sling:resourceSuperType and at  last nt:file



 To follow the cheatsheet-example: There is an absolute path /wiki/Sling 
 within
 the JCR. This node contains a rt=wiki/page







 Then for rendering, sling searches for a servlet/script. This is done based 
 on
 the sling:resourceType  sling:resourceSuperType, or, if not available, the
 node type of the request resource is used (for JCR resources; some:NodeType 
 =
 read like a resource type some/NodeType).





 I see that I have mixed up path resolution and resource resolution (retrieving
 rendering script). But what does longest matching resource mean. To use the
 cheatsheet-sample: The absolute path /wiki/Sling must exist to resolve the
 request (or it is mapped by some means. then the mapped path must exist). If 
 the
 node is of type nt:file we are done.

 If it contains a rt or rst-attribute this will be used to retrieve script
 location.


  (3) In either case (resolved by sling:resourceType, sling:resourceSuperType
  or
  using the node itself) Sling looks for scripts contained in the resolved
  node.

 If you mean resolve node = request resource, then no. The resource type is
 looked up
 - by path (if it's absolute): rt = /apps/project/components/foo
 - inside the resource resolver search path 

Re: Multi-tenancy support in Sling - SLING-2656

2012-11-12 Thread Julian Sedding
Hi Amit

Thanks for taking a stab at multi-tenancy support. I have looked at
your patch and I re-read Felix' draft spec on the wiki[0].

The code and the spec leave me with some thoughts. Sorry for the
lengthy reply, the thoughts are still pretty fresh in my mind.

The spec states that multi-tenancy support is targeted to a hosted
scenario, where several Sling applications (let's simplify to
websites) run side by side. I think this can easily be extended to
cases where a large corporation runs websites of several brands on the
same Sling instance. Assuming our brands are banana, kiwi and
lemon, we'd have a content structure like this:

tenants: {
banana: { ... },
kiwi: { ... },
lemon: { ... }
}

The main purpose of multi-tenancy support (as per my interpretation of
the spec) is to be able to use different rendering scripts for
different tenants, which is expressed via the concept of the
ResourceResolver(Factory)#searchPath.

Assuming we want the banana and lemon websites to be rendered with
the yellow application and the kiwi website with the green
application (and assuming we don't use CSS for this...), we might want
our rendering scripts organized like this:

apps: {
yellow: { ... },
green: { ... },
shared: { ... }
}

As far as I can see, the currently committed code doesn't enhance the
search paths yet. However, it looks like it is intended that tenants
get resolved mapped from the paths of any of the following:
* user home path (e.g. /home/users/banana/julian; this is kind of CQ
specific, afaik jackrabbit still uses the system workspace for users
by default, so there's no /home/users)
* resource path (e.g. /tenants/kiwi)

So if I request the page /tenants/kiwi logged in as julian, I could
get two different resolutions, depending on whether the implementation
adapts the Resource (/tenants/kiwi), which leads to the tenant green
or the ResourceResolver backed by the user julian, which leads to the
tenant yellow.

Considering that most requests to websites are anonymous, I suggest
that multi-tenancy support should only care about the resource being
requested, not about the requesting user, This also guarantees
consistent results for rendering.

Looking at the problem from this angle, script resolution (i.e.
looking up the resource type relative path) needs depend on the
location of the requested resource. This in turn rules out the
possibility to adapt a ResourceResolver to a tenant, because the RR
does not have a path. Also setting injecting the search path into the
RR is troublesome, because /tenants/kiwi might include resources from
/tenants/banana by reference and would thus need to trigger the
yellow rendering for these includes (or are there arguments against
this?).

Given the above thoughts, I would allow adapting a Resource to a
Tenant. The Tenant would correspond to the Resource itself or to an
ancestor of the Resource (i.e. hierarchical inheritance). Since the
tenant would thus correspond to a Resource, maybe it makes sense to
have the Tenant interface extend from Resource. If no Tenants are
configured, the attempt to adapt a Resource to a tenant may return
null or a default Tenant, which is rooted at the resource tree's root
(maybe this would simplify implementations).

All of this raises the question of the consistency of search paths, as
the ResourceResolver cannot convey tenant specific search paths,
however the script resolution would need to depend upon tenant
specific search paths. To me it seems that multi-tenancy support might
require the extension of some sling concepts. This extension could
(and should IMHO) be implemented as a hook, which allows to manipulate
script resolution. Having such a hook should decouple the
multi-tenancy implementation from the core of sling and possibly allow
for alternative implementations.

WDYT?

Regards
Julian

[0] https://cwiki.apache.org/SLING/multitenancy-support.html


On Mon, Nov 12, 2012 at 3:35 AM, Amit.. Gupta. amitg...@adobe.com wrote:
 Thanks Felix.

 I will work on the web console plugin.

 Thanks,
 Amit

 -Original Message-
 From: Felix Meschberger [mailto:fmesc...@adobe.com]
 Sent: 10 November 2012 04:23
 To: users@sling.apache.org
 Subject: Re: Multi-tenancy support in Sling - SLING-2656

 Hi Amit

 Thanks alot. I have applied your patch with some changes (see SLING-2656 for 
 details). I placed it as th extensions/tenant module in the contrib section 
 for now. As of now it only provides the Tenant API but no integration with 
 the rest in Sling. As such it is of use mainly to multi-tenancy aware uses.

 I think we should just provide read access through the TenantProvider and 
 leave management (create, update, delete) to some administrative tooling; 
 e.g. a web console plugin.

 I also removed the default configuration which does not relate to Sling.

 Would you be able to come up with a Web Console Plugin for management ?

 Regards
 Felix

 Am 08.11.2012 um 11:03 schrieb Amit.. Gupta.:

 Hi All,

 I 

Re: Multi-tenancy support in Sling - SLING-2656

2012-11-12 Thread Julian Sedding
Hi Felix

On Mon, Nov 12, 2012 at 10:55 AM, Felix Meschberger fmesc...@adobe.com wrote:
 Hi Julian

 Am 12.11.2012 um 10:33 schrieb Julian Sedding:

 Hi Amit

 Thanks for taking a stab at multi-tenancy support. I have looked at
 your patch and I re-read Felix' draft spec on the wiki[0].

 The code and the spec leave me with some thoughts. Sorry for the
 lengthy reply, the thoughts are still pretty fresh in my mind.

 The spec states that multi-tenancy support is targeted to a hosted
 scenario, where several Sling applications (let's simplify to
 websites) run side by side.

 Yes, that was an initial though. But running different applications for 
 different tenants is a tricky thing because the Java platform does not allow 
 use to properly sandbox those applications and thus to prevent on application 
 from starving another application.

 For now, only the TenantProvider/Tenant part is implemented and we did not 
 consider the tenant-specific ResourceResolution yet.

So if you are omitting the main feature of tenants as described in
Problem Scope in the draft specification[0] (Here you might want to
separate the resolution of resources for each client.), why call the
feature multi-tenancy support, why reference the specification and
why implement the interfaces described in the specification? The
problem scope statement does not mention the requirement to sand-box
applications. While I understand that sand-boxing may be desirable (or
even required) for some use-cases, it certainly is not necessary for
every use-case (e.g. one company runs several brand web-sites on the
same Sling instance).

Multi-tenancy support can certainly encompass a multitude of features
that are provided per-tenant. Script resolution is one of them,
tenant-specific users may be another one. Unfortunately the discussion
of what multi-tenancy support should mean in Sling has not happened
(yet?) on this mailing list.

[0] https://cwiki.apache.org/SLING/multitenancy-support.html


 I think this can easily be extended to
 cases where a large corporation runs websites of several brands on the
 same Sling instance. Assuming our brands are banana, kiwi and
 lemon, we'd have a content structure like this:

 tenants: {
banana: { ... },
kiwi: { ... },
lemon: { ... }
 }

 The main purpose of multi-tenancy support (as per my interpretation of
 the spec) is to be able to use different rendering scripts for
 different tenants, which is expressed via the concept of the
 ResourceResolver(Factory)#searchPath.

 Assuming we want the banana and lemon websites to be rendered with
 the yellow application and the kiwi website with the green
 application (and assuming we don't use CSS for this...), we might want
 our rendering scripts organized like this:

 apps: {
yellow: { ... },
green: { ... },
shared: { ... }
 }

 As far as I can see, the currently committed code doesn't enhance the
 search paths yet. However, it looks like it is intended that tenants
 get resolved mapped from the paths of any of the following:
 * user home path (e.g. /home/users/banana/julian; this is kind of CQ
 specific, afaik jackrabbit still uses the system workspace for users
 by default, so there's no /home/users)
 * resource path (e.g. /tenants/kiwi)

 So if I request the page /tenants/kiwi logged in as julian, I could
 get two different resolutions, depending on whether the implementation
 adapts the Resource (/tenants/kiwi), which leads to the tenant green
 or the ResourceResolver backed by the user julian, which leads to the
 tenant yellow.

 I think if you are logged in, you are being run under the hood of the tenant 
 to which you as the logged in user belong. So in your case, the tenant would 
 be green.

No, it would be yellow. But that's not the point, the point is that
rendering the same content might lead to different script resolution.
This feels very awkward to me.


 As a member of the green tenant you might not even have access the kiwi 
 tree. In which case, there is no reason to assume the request resource path 
 to be the tenant to consider.

I would avoid mixing up the concept of tenants and access control.
They are certainly complementary, but the user julian may equally well
have access to /tenants/kiwi. In that case we need to answer the
question if the tenant is identified by the logged in user or by the
content tree being rendered.


 As a consequence, I agree, that the anonymous user by itself is not running 
 under the hood of a tenant.



 Considering that most requests to websites are anonymous, I suggest
 that multi-tenancy support should only care about the resource being
 requested, not about the requesting user, This also guarantees
 consistent results for rendering.

 This (and the following) raise good questions. And we are not ready to answer 
 them (yet) and we are not even considering per-tenant applications (for above 
 stated reasons).

I hope that we can approach answering some of those questions on the
mailing

Re: Multi-tenancy support in Sling - SLING-2656

2012-11-12 Thread Julian Sedding
Hi Alex

On Mon, Nov 12, 2012 at 1:07 PM, Alexander Klimetschek
aklim...@adobe.com wrote:
 On 12.11.2012, at 10:55, Felix Meschberger fmesc...@adobe.com wrote:
 Considering that most requests to websites are anonymous, I suggest
 that multi-tenancy support should only care about the resource being
 requested, not about the requesting user, This also guarantees
 consistent results for rendering.

 This (and the following) raise good questions. And we are not ready to 
 answer them (yet) and we are not even considering per-tenant applications 
 (for above stated reasons).

 I'd agree with Julian. A tenant should be dependent on something clearly 
 defined through the URL: e.g. the domain / Host header or a URL path, such as 
 domain.com/tenant. So it's essentially request-dependent, not necessarily 
 user or content dependent.

 Otherwise it would also overlap too much with ACLs.

 * A ResourceResolver representing a user (just like JCR Session does) can be 
 adapted to a Tenant to which the user belongs.

 Hmm, I am not sure if a user belongs to a (single) tenant. What if a user 
 should be able to log into multiple tenants? For example, an agency with 
 multiple customers (who are tenants) or just the admin users of the site 
 provider.

I agree. For designing multi-tenancy support, we should assume that a
user may belong to several tenants. Support for the single tenant case
would thus be implied.


 * A Resource can be adapted to a Tenant under the assumption that the 
 respective Resource belongs to one of the Tenant's data areas in the 
 repository.

 What if there are shared resources? You probably need the resources from a 
 request-specific resource resolver, which in turn handles the 
 request-dependent tenant resolution, so you get the right tenant from the 
 resource based on that, but not based on the resource's location.

That's a good question, which I cannot currently answer. I think you
can find arguments for rendering this resource based on the
request-resource's tenant or on the resource's tenant itself. Maybe
this would need to be controllable by the user of the API, e.g. by
indicating the desired strategy when including a resource.


 Cheers,
 Alex

Regards
Julian


Re: mix:versionable on an nt:file node

2012-05-11 Thread Julian Sedding
Hi Günther

On Mac, I copy files in the Terminal in order to avoid the ._*
metadata files. That worked fine for me with WebDAV and
Jackrabbit/Sling so far.

Regarding your question: whether documents are indexed or not depends
on your configuration, namely the textFilterClasses option of your
search index[0]. You can find some more background on available
TextExtractors etc. on the Jackrabbit website[1].

Regards
Julian

[0] http://wiki.apache.org/jackrabbit/Search
[1] http://jackrabbit.apache.org/jackrabbit-text-extractors.html


On Wed, May 9, 2012 at 6:49 PM, Günther Schmidt gue.sch...@web.de wrote:
 Hello,

 I've just managed to upload a local directory to Apache Sling via an
 HttpClient I wrote in Java. For those who wonder why I haven't simply used
 WebDav for this: I'm using a Mac and every time you copy/move files from
 local filesystem to a mounted, non-mac one there are ._* files added where
 Apple will store indespensible, extremely important metadata about the file.
 No remedy for this is known to man.

 So anyway, the files and folders are uploaded and I even managed that the
 nt:files have the mix:versionable property set. And here's my question: The
 jcr:content node which contains the actual file data does not have the
 mix:versionable property set, just its parent, the nt:file node. Does this
 mean that the actual content of the file is not versioned, do I need to set
 it manually?

 Eventually I will study the JCR2.0 spec, just not yet.

 And are the files indexed via Jackrabbit's lucene too?

 Günther


Re: SlingPostServlet - Real-world concerns and general thoughts. Discussion encouraged!

2012-05-02 Thread Julian Sedding
Hi David

This is an interesting question and I consider the concerns you
mention absolutely valid. I have been thinking about this problem
before, but never got around to implementing/prototyping my ideas. In
a SlingPostProcessor, the changes should not yet be persisted, so it
should be possible to do a session.refresh(true), in order to reset
the session. Alternatively, I imagine that you could throw an
exception from a SlingPostProcessor, and have the action aborted. This
would need testing though.

My preferred idea would be a Filter implementation (scope request)
that checks whether the POST'ed parameters are allowed (and possibly
also whether they are valid). The allowed parameters (and validations)
could be described by a resource-type dependent description, which
could be expressed by a node structure. A contrived example:

/apps/sample/comment
/comment.jsp
/properties
/email (validate=email, mandatory=true)
/website (validate=url)
/text  (validate=length, min=20, max=500)

The filter implementation would then only allow POSTs where the
allowed parameters correspond to the configured properties. Different
validation implementations could be hooked in as OSGi services,
identified by name (e.g. email, url, length) and consuming any given
supplemental properties (e.g. min, max).

Of course there is more to it, e.g. how do you handle POSTs that
create intermittent nodes, i.e. ./node/property=value, how do you
deal with uploads etc. It should be possible to accommodate these into
whatever description of the allowed (white-listed) properties,
however.

Do you see the need for a use-case, where POST validation would not be
per resource-type?

Regards
Julian


On Wed, May 2, 2012 at 5:47 PM, David G. davidjgonza...@gmail.com wrote:

 I thought i'd throw this out there as I've been mulling it over for a while.

 Sling is a pretty powerful framework, and one of its most powerful pieces is 
 the SlingPostServlet, which provides a client-based interface for 
 manipulating data.

 Now, the SlingPostServlet seems very powerful and very useful in a trusted 
 environment - for example, on the authoring side of sling-based CMS ;)  -- 
 where there is some amount of trust that the folks w access won't fire up a 
 REST client and start shooting off operations (assuming they enjoy gainful 
 employment).

 When you expose the SlingPostServlet to the public (internet) things seem 
 like they can get dicey. For example, if I find a set of nodes that that are 
 writeable to me (say under my profile, or some suer generated content tree) I 
 could start adding unexpected data, like unexpected properties that could 
 show up in public representations of the resource (XML, JSON, etc.) or 
 moving/renaming nodes, etc.

 There are a couple ways to help mitigate this:
 1) Ensure all the correct permissions are applied to the resources in 
 question (however this only helps prevent certain operations - if a resource 
 is writable, permissioning won't restrict what properties I can write to it)
 2) Create SlingPostProcessors that handle all the various conditions - 
 PostProcessors are executed after the POST operation has taken place, and I'm 
 not aware of a way to tell Sling to revert all changes and fail the operation.
 3) Create workflows/eventhandlers that perform some sort of async data 
 verification/scrubbing - I don't like this sort of async as bad things can 
 still happen to the data, and its difficult to alert the client of an issue.

 Which leaves creating POST servlet/jsp handlers for each resource-type to 
 handle data manipulation, which will be used in lieu of the SlingPostServlet.

 TLDR

 My problem in using the SlingPostServlet requires you to develop 
 (conceptually) a blacklist of behaviors/operations/data that should not be 
 allowed - rather than a whitelist  -- and I hope most of us will concede that 
 a whitelist is (almost) always better than a blacklist when it comes to 
 managing security.


 Am i missing something here?

 Does anyone have examples of actual Prod sites where the SlingPostServlet is 
 heavily leveraged to allow public clients manipulate data?

 I'd love to hear everyone's thoughts and how they've handle similar 
 situations.

 --
 David Gonzalez
 Sent with Sparrow (http://www.sparrowmailapp.com/?sig)



Re: creating or giving users full write access?

2011-07-28 Thread Julian Sedding
Hi Craig

1. Child nodes do inherit permissions from parent nodes.

2. The admin user is special (in Jackrabbit) and therefore not a good
example to look at. It has access to everything and cannot be
restricted AFAIK. I don't know about default groups/users in
Jackrabbit, since I work with CRX, but I suspect that there are none.

You probably want to start by creating a group and granting it full
access to the root node. Then assign your user to the group and check
if that works as expected.

Regards
Julian


On Wed, Jul 27, 2011 at 7:17 PM, Craig Ganoe cga...@psu.edu wrote:

 I did look at that page which seems to suggest that I would need to
 individually set permissions for each and every node. That isn't what I
 want, unless child nodes inherit parent permissions.

 I did the list users on the page I linked and even the admin user does not
 seem to be a member of anything. Is there a group that has full write access
 by default that I could add the users to?

 On Jul 27, 2011, at 12:39 PM, Julian Sedding wrote:

 Hi Craig

 Your newly created user is probably doesn't have any permissions and
 is not in a group from which it could inherit permissions. Did you see
 the documentation about managing permissions[0] in Sling?

 Regards
 Julian

 [0]
 http://sling.apache.org/site/managing-permissions-jackrabbitaccessmanager.html




 On Wed, Jul 27, 2011 at 6:33 PM, Craig Ganoe cga...@psu.edu wrote:

 How can I create a user that has full write access (including adding
 nodes
 and modifying their properties)?

 I followed the instructions here under Create user:

 http://sling.apache.org/site/managing-users-and-groups-jackrabbitusermanager.html

 But the users I create using the instructions seem to have read-only
 access.
 I even tried adding -u admin:admin to the curl command which seemed to
 let
 me get around the Self-Registration Enabled setting (I was hoping this
 would
 make the accounts non-anonymous), but they still end up with read-only
 access.

 The Jackrabbit docs talk about 3 classes of users: anonymous, normal and
 system the latter 2 of which have full read/write, but I don't see
 anywhere
 there about how to control that either.

 Sorry if this is already explained somewhere that I'm missing. Thanks!

 Craig







Re: creating or giving users full write access?

2011-07-27 Thread Julian Sedding
Hi Craig

Your newly created user is probably doesn't have any permissions and
is not in a group from which it could inherit permissions. Did you see
the documentation about managing permissions[0] in Sling?

Regards
Julian

[0] 
http://sling.apache.org/site/managing-permissions-jackrabbitaccessmanager.html




On Wed, Jul 27, 2011 at 6:33 PM, Craig Ganoe cga...@psu.edu wrote:

 How can I create a user that has full write access (including adding nodes
 and modifying their properties)?

 I followed the instructions here under Create user:
 http://sling.apache.org/site/managing-users-and-groups-jackrabbitusermanager.html

 But the users I create using the instructions seem to have read-only access.
 I even tried adding -u admin:admin to the curl command which seemed to let
 me get around the Self-Registration Enabled setting (I was hoping this would
 make the accounts non-anonymous), but they still end up with read-only
 access.

 The Jackrabbit docs talk about 3 classes of users: anonymous, normal and
 system the latter 2 of which have full read/write, but I don't see anywhere
 there about how to control that either.

 Sorry if this is already explained somewhere that I'm missing. Thanks!

 Craig




Re: Changing the extension with sling:include

2011-07-17 Thread Julian Sedding
Hi Phil

You can simply do sling:include path=.json/ if you want the
current resource rendered as json or in your case sling:include
path=%=child.getPath()%.json/ (optionally with resourceType
attribute).

Note: the default json rendering servlet sets the Content-Type header
to application/json. This can cause your HTML to be returned with the
incorrect content type. You can mitigate this by explicitly flushing
the output stream before the include.

Regards
Julian


On Sun, Jul 17, 2011 at 11:56 AM, Phil Rice
phil.rice.erud...@googlemail.com wrote:
 I would like to be able to make it so that when I use a
 sling:include I can request the included resource to have a
 different extension. In the following experiment I am trying to get
 the .json representation of the children to be included.

 I tried the following in sling/servlet/default/hello.jsp (headers
 removed for clarity)

     This is the default from hello.jsp/br /
         % for (IteratorResource iterator = resource.listChildren();
 iterator.hasNext();){ %
         %    Resource child = iterator.next(); %
            ul
            liChildPath: %= child.getPath() %/li
            liJustTag sling:include resource=%= child % //li
            liWith resourceType sling:include resource=%= child %
 resourceType=components/summary //li
            liWith replaceSuffix sling:include resource=%= child %
 replaceSuffix=json //li
            liWith replaceSelectors sling:include resource=%= child %
 replaceSelectors=json //li
            liWith addSelectors sling:include resource=%= child %
 addSelectors=json //li
            /ul
         % } %

 I have a hello.jsp in components/hello.jsp and another in
 components/summary/hello.jsp

 When I view a page with one child (and the page didn't have a
 resourceType) I get the following

 This is the default from hello.jsp
 ChildPath: /content/mynode/ChildNode
 JustTag This is the default from hello.jsp
 With resourceType This is the components/summary/hello.jsp
 With replaceSuffix This is the default from hello.jsp
 With replaceSelectors This is the default from hello.jsp
 With addSelectors This is the default from hello.jsp

 So what is happening is that the extension of the original query is
 being propogated through the sling:include tag. By specifying the
 sling:resourceType I can actually execute arbitray scripts, as long as
 they have the same extension type as the original query.

 Is there any mechanism for getting the html that I would have got from
  childNode.json and including it in the output?



Re: Beginners question with Sling.

2011-07-08 Thread Julian Sedding
Hi Phil

Check out the integration tests, as Bertrand suggested. In the class
AbstractAuthenticatedTest[0] there is pretty much the same code you're
trying to write. I think that should get you going.

Regards
Julian

[0] 
http://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java




On Fri, Jul 8, 2011 at 11:19 AM, Alexander Klimetschek
aklim...@adobe.com wrote:
 On 08.07.11 10:39, Phil Rice phil.rice.erud...@googlemail.com wrote:
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(new AuthScope(localhost,
8080), new UsernamePasswordCredentials(admin, admin));

 I guess you need to use preemptive auth:

 client.getParams().setAuthenticationPreemptive(true);

 http://hc.apache.org/httpclient-3.x/authentication.html


 Regards,
 Alex

 --
 Alexander Klimetschek
 Developer // Adobe (Day) // Berlin - Basel







Re: serve static file?

2011-05-12 Thread Julian Sedding
Good to hear. To ease your development setup the FileSystem resource
provider should do the trick.

Regards
Julian


On Thu, May 12, 2011 at 1:08 PM, sam lee skyn...@gmail.com wrote:
 Thanks.

 I just did not want to put static files in the repository. It was difficult
 to synchronize files on our VCS and the repository. Normal workflow was,
 edit javascript and css files. And, then push them to the repository to see
 the change. If things work, commit to VCS.

 I could have used WebDAV mount. I was too lazy to mount sling WebDAV to
 existing directory and see what happens.

  Static files will be served from CDN eventually. So, I'm not concerned with
 performance.



 On Thu, May 12, 2011 at 6:30 AM, Julian Sedding jsedd...@gmail.com wrote:

 Hi Sam

 Why would you want to do this? If it's for performance reasons, did
 you measure if there is actually a problem?

 If you request the static resource from Sling (and it is backed by a
 JCR Node), it is just spooled out to the client. In case of binaries,
 they would typically be served out of JackRabbit's DataStore and
 therefore be served from the filesystem already. So all you could get
 rid of is the Sling overhead, which should be minimal.

 Alternatively, it is possible to install the FileSystem Provider[0]
 bundle, which is available on the Downloads page[1]. This allows you
 to serve resources from the file system, but is still handled by Sling
 and thus is ultimately served by the SlingMainServlet.

 Regards
 Julian

 [0]
 http://sling.apache.org/site/accessing-filesystem-resources-extensionsfsresource.html
 [1] http://sling.apache.org/site/downloads.cgi#Downloads-SlingComponents



 On Thu, May 12, 2011 at 12:07 PM, sam lee skyn...@gmail.com wrote:
  Hey,
 
  Is there a way to serve static files from filesystem (not repository)?
 
  For example,
 
  GET /static/js/jquery.js
 
  will be served from /var/www/media/js/jquery.js   of filesystem, not
  repository.
 
  (/static/*  is served from /var/www/media/*)
 




Re: implicit sling:resourceType?

2011-03-03 Thread Julian Sedding
Hi Sam

I think the RequestDispatcherOptions[0] might be what you're looking
for. It allows you to control certain aspects of re-dispatching
(forwarding and including) a request, including forcing a
different resource type. You could use this API in a servlet
registered for the edit selector, as you suggested.

Regards
Julian

[0] 
http://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestDispatcherOptions.html



On Thu, Mar 3, 2011 at 8:17 PM, sam lee skyn...@gmail.com wrote:
 Hey,

 I have a node:

 /content/page

 whose sling:resourceType = /apps/foo/bar

 So,  GET /content/page.html  will be handled by /apps/foo/bar/html.jsp

 I cannot modify sling:resourceType of /content/page.

 However, I would like GET /content/page.edit.html  to be handled by
 /apps/foo/bar2/edit.html.jsp

 Is this possible? I cannot modify /apps/foo/bar  and /content/page. But I
 want .edit.html to be handled by /apps/foo/bar2.

 Should I add a servlet with:
 sling.servlet.resourceTypes = sling/servlet/default
 sling.servlet.selectors = edit

 to capture all .edit.html  and somehow call /apps/foo/bar2/edit.html.jsp
 ?  (maybe a redirect?)



Re: alias or reference?

2010-11-08 Thread Julian Sedding
Hi Sam

Regarding SLING-1778: it's not feasible to leverage the SLING-1778 features
for all aspects within CQ5, as some of the CQ5 features directly access the
JCR API and thus the ResourceProvider magic happening in Sling is not
effective. This is especially true for page nodes.

If the nodes you're using are fully controlled by your application, you can
try building the symlinks bundle from the SLING-1778 patch and install it.
It's self-contained and IIRC there are no dependency issues in CQ5.3. So no
patching or updating of bundles delivered with CQ should be required. Only
the symlinks bundle would then be at your responsibility.

Regards
Julian



On Fri, Nov 5, 2010 at 8:25 PM, sam lee skyn...@gmail.com wrote:

 Ah, Thank you. I see.

 I hope sling:alias could be String[]. Even if I set sling:alias =
 {png, gif, tiff}.. only the first entry, png, is used.

 For example,
 /some/path/jpeg (sling:alias = {png, gif, tiff})

 then,
 GET /some/path/jpeg.json  == good
 GET /some/path/png.json  == good
 GET /some/path/gif.json == bad
 GET /some/path/tiff.json== bad

 I ended up writing /etc/map config to redirect stuff to
 /some/path/jpeg (according to
 http://sling.apache.org/site/mappings-for-resource-resolution.html)

 I tried mix:shareable .. it was a nightmare since I did not back up
 the node before setting mixin.. And it's impossible to remove
 mix:shareable mixin :P

 SLING-1778 looks promising. I can't apply patches. I'm using Day CQ
 and have to wait until they apply the patch to the sling they ship
 with.

 Thanks.
 Sam

 On Wed, Nov 3, 2010 at 10:02 AM, Justin Edelson
 jus...@justinedelson.com wrote:
  Hi...
 
  sling:alias only works within the same path segment, i.e. if
 
  /some/path/j...@sling:alias = jpg
 
  then you could request either /some/path/jpeg or /some/path/jpg and
  get the resource at /some/path/jpeg.
 
  JCR 2 Shareable Nodes might be a solution for you. Or take a look at
 SLING-1778.
 
  Justin
 
 
  On Tue, Nov 2, 2010 at 4:07 PM, sam lee skyn...@gmail.com wrote:
  Hey,
 
  I want:
  GET /some/path/jpeg.tidy.infinity.json
 
  to be equivalent to:
  GET /some/other/path/foo.tidy.infinity.json
 
  I tried:
  /some/path/jpeg/sling:resourceType = /some/other/path/foo
  and
  /some/path/jpeg/sling:resourceSuperType = /some/other/path/foo
 
  but, the json returned by
  GET /some/path/jpeg.tidy.infinity.json
  is not same as the json returned by
  GET /some/other/path/foo.tidy.inifinity.json
 
  Should I use something other than sling:resourceType ?
  sling:alias?
 
  Thanks.
  Sam