You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "oliver.gregory@gmail.com" <ol...@gmail.com> on 2012/11/11 23:55:53 UTC

JCR_SQL2, query on jcr:mimeType

Hello,

I would like to know if it's possible in Jackrabbit with JCR_SQL2 to query
a node according to the jcr:mimeType property.
Something like :
SELECT * FROM [nt:unstructured] AS node WHERE node.id = 2 and
node.file.jcr:content[jcr:mimeType] = 'application/xml'

Thanks,

Grégory OLIVER

Re: JCR_SQL2, query on jcr:mimeType

Posted by "oliver.gregory@gmail.com" <ol...@gmail.com>.
Finally, i found the query with Jackrabbit :

select node.* from [nt:unstructured] as node
inner join [nt:file] as file on ischildnode(file, node)
inner join [nt:resource] as content on ischildnode(content, file)
where content.[jcr:mimeType] = 'application/pdf'

Thank you,

Grégory OLIVER



2012/11/13 joe verderber <jj...@gmail.com>

> I have a local CQ5 instance running and the following seems to work for me:
>
> Repository r = JcrUtils.getRepository("http://localhost:4502/crx/server/
> ");
>
> Session s = r.login( new SimpleCredentials("admin", "admin".toCharArray())
>   ,"crx.default");
>
> System.out.println("logged in!!!");
>
> NodeIterator ni =  s.getWorkspace().getQueryManager().createQuery("select *
> from [nt:unstructured] where" +
>
> " [nt:unstructured].'jcr:mimeType' like '%/%' ", "JCR-SQL2"
> ).execute().getNodes();
>
> while(ni.hasNext())
>
> {
>
>  System.out.println("currentNode.path='"+ni.nextNode().getPath()+"'");
>
>  System.out.println("currentNode.mimeType='"+ni.nextNode().getProperty(
> "jcr:mimeType").getString()+"'");
>
>   }
>
> s.logout();
>
> System.out.println("logged out.");
>
> On Sun, Nov 11, 2012 at 5:55 PM, oliver.gregory@gmail.com <
> oliver.gregory@gmail.com> wrote:
>
> > Hello,
> >
> > I would like to know if it's possible in Jackrabbit with JCR_SQL2 to
> query
> > a node according to the jcr:mimeType property.
> > Something like :
> > SELECT * FROM [nt:unstructured] AS node WHERE node.id = 2 and
> > node.file.jcr:content[jcr:mimeType] = 'application/xml'
> >
> > Thanks,
> >
> > Grégory OLIVER
> >
>

Re: JCR_SQL2, query on jcr:mimeType

Posted by joe verderber <jj...@gmail.com>.
I have a local CQ5 instance running and the following seems to work for me:

Repository r = JcrUtils.getRepository("http://localhost:4502/crx/server/");

Session s = r.login( new SimpleCredentials("admin", "admin".toCharArray())
  ,"crx.default");

System.out.println("logged in!!!");

NodeIterator ni =  s.getWorkspace().getQueryManager().createQuery("select *
from [nt:unstructured] where" +

" [nt:unstructured].'jcr:mimeType' like '%/%' ", "JCR-SQL2"
).execute().getNodes();

while(ni.hasNext())

{

 System.out.println("currentNode.path='"+ni.nextNode().getPath()+"'");

 System.out.println("currentNode.mimeType='"+ni.nextNode().getProperty(
"jcr:mimeType").getString()+"'");

  }

s.logout();

System.out.println("logged out.");

On Sun, Nov 11, 2012 at 5:55 PM, oliver.gregory@gmail.com <
oliver.gregory@gmail.com> wrote:

> Hello,
>
> I would like to know if it's possible in Jackrabbit with JCR_SQL2 to query
> a node according to the jcr:mimeType property.
> Something like :
> SELECT * FROM [nt:unstructured] AS node WHERE node.id = 2 and
> node.file.jcr:content[jcr:mimeType] = 'application/xml'
>
> Thanks,
>
> Grégory OLIVER
>