<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic access to the session in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/access-to-the-session/m-p/326444#M13445</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have created a seam validator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public void validateSAPNumber(FacesContext context, UIComponent component,
        Object value) {

    String messageString = null;
	Integer size = 1;

	String SAPNumber = (String) value;
	String DocId = navigationContext.getCurrentDocument().getId();

	String query = String.format("SELECT * FROM Document WHERE sap:SAPNumber = '%s' AND ecm:uuid != '%s'", SAPNumber, DocId);
    try {
	  DocumentModelList docs = documentManager.query(query);
	  size = docs.size();
    } catch (Exception e) {
    	messageString = "label.org.nuxeo.adambo.sap.SAPNumberActionsBean";
    }
	
	if (size&amp;gt;0) {
        FacesMessage message = new FacesMessage(
                FacesMessage.SEVERITY_ERROR, ComponentUtils.translate(
                        context, "label.org.nuxeo.adambo.sap.SAPNumberActionsBean"),
                null);
        context.addMessage(null, message);
        throw new ValidatorException(message);
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it works but only with a user permissions scope.
The problem is that the "query" method uses a "FilteresQuery" class.
I guess it is necessary to use the "createQuery" method of the "Session" class, but how get access to it?
The simple conversion of the documentManager to a "Session" class is not possible.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jul 2012 09:06:48 GMT</pubDate>
    <dc:creator>adam_bo_</dc:creator>
    <dc:date>2012-07-16T09:06:48Z</dc:date>
    <item>
      <title>access to the session</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/access-to-the-session/m-p/326444#M13445</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have created a seam validator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public void validateSAPNumber(FacesContext context, UIComponent component,
        Object value) {

    String messageString = null;
	Integer size = 1;

	String SAPNumber = (String) value;
	String DocId = navigationContext.getCurrentDocument().getId();

	String query = String.format("SELECT * FROM Document WHERE sap:SAPNumber = '%s' AND ecm:uuid != '%s'", SAPNumber, DocId);
    try {
	  DocumentModelList docs = documentManager.query(query);
	  size = docs.size();
    } catch (Exception e) {
    	messageString = "label.org.nuxeo.adambo.sap.SAPNumberActionsBean";
    }
	
	if (size&amp;gt;0) {
        FacesMessage message = new FacesMessage(
                FacesMessage.SEVERITY_ERROR, ComponentUtils.translate(
                        context, "label.org.nuxeo.adambo.sap.SAPNumberActionsBean"),
                null);
        context.addMessage(null, message);
        throw new ValidatorException(message);
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it works but only with a user permissions scope.
The problem is that the "query" method uses a "FilteresQuery" class.
I guess it is necessary to use the "createQuery" method of the "Session" class, but how get access to it?
The simple conversion of the documentManager to a "Session" class is not possible.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2012 09:06:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/access-to-the-session/m-p/326444#M13445</guid>
      <dc:creator>adam_bo_</dc:creator>
      <dc:date>2012-07-16T09:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: access to the session</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/access-to-the-session/m-p/326445#M13446</link>
      <description>&lt;P&gt;Ok, I have realised the Query method in this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    try {
    	String repoName = documentManager.getRepositoryName();
    	LocalSession lsession = new LocalSession();
    	lsession.connect(repoName, null);
    	Session session = lsession.getSession();
    	
    	Query compiledQuery = session.createQuery(query, Query.Type.NXQL);
    	
        QueryResult results = compiledQuery.execute();
        DocumentModelList dms = results.getDocumentModels();

        return dms;
        
    } catch (Exception e) {
        throw new ClientException("Failed to execute query.", e);
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure that it is the best and simplest solution, but it works.
Maybe it will help someone else.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2012 16:22:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/access-to-the-session/m-p/326445#M13446</guid>
      <dc:creator>adam_bo_</dc:creator>
      <dc:date>2012-07-16T16:22:50Z</dc:date>
    </item>
  </channel>
</rss>

