You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Bruce Edge <br...@nextissuemedia.com> on 2014/11/26 01:37:55 UTC

Make a JcrUtils created node writable from WebDAV?

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: Make a JcrUtils created node writable from WebDAV?

Posted by Julian Sedding <js...@gmail.com>.
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
<br...@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 <js...@gmail.com>>
> Reply-To: "users@sling.apache.org<ma...@sling.apache.org>" <us...@sling.apache.org>>
> Date: Tuesday, November 25, 2014 at 10:42 PM
> To: "users@sling.apache.org<ma...@sling.apache.org>" <us...@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 <br...@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: Make a JcrUtils created node writable from WebDAV?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Bruce,

On Wed, Nov 26, 2014 at 8:00 AM, Bruce Edge
<br...@nextissuemedia.com> wrote:
>...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,...

Doing that is absolutely fine, to find out what's wrong I suggest
first doing the same thing using curl to create the folder, then
create another folder with your JcrUtils code and compare - both
should be visible and writeable (ACLs permitting) via WebDAV.

You can also use the tidy.infinity.json dumps to see subtle
differences like node types.

If that doesn't work with curl, show us your curl command and we can
hopefully help.

-Bertrand

Re: Make a JcrUtils created node writable from WebDAV?

Posted by Bruce Edge <br...@nextissuemedia.com>.
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 <js...@gmail.com>>
Reply-To: "users@sling.apache.org<ma...@sling.apache.org>" <us...@sling.apache.org>>
Date: Tuesday, November 25, 2014 at 10:42 PM
To: "users@sling.apache.org<ma...@sling.apache.org>" <us...@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 <br...@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: Make a JcrUtils created node writable from WebDAV?

Posted by Julian Sedding <js...@gmail.com>.
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 <br...@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
>