<?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 Re: Search on all the documents (even on those where the user don&amp;apos;t have permissions) in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/search-on-all-the-documents-even-on-those-where-the-user-don/m-p/317107#M4108</link>
    <description>&lt;P&gt;This can cause a lot of problem for you security but if you want to do it, you can use an unrestrictedsessionrunner like this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Operation(id = Bla.ID, category = Constants.CAT_SERVICES, label = "Bla.getTitleUnrestricted", description = "")
public class Bla {

public static final String ID = "Bla.getTitlesUnRestricted";

@Param(name = "query", required = true)
protected String query;

@Context
CoreSession session;

public class DocumentDescription {

    private DocumentModel doc;

    public DocumentDescription(DocumentModel doc) {
        this.doc = doc;
    }

    public String getTitle() throws ClientException {
        return (String) doc.getPropertyValue("dc:title");
    }

    public String getDescription() throws ClientException {
        return (String) doc.getPropertyValue("dc:description");
    }

}

@OperationMethod
public Blob run() throws Exception {
    final List&amp;lt;DocumentDescription&amp;gt; results = new ArrayList&amp;lt;DocumentDescription&amp;gt;();
    UnrestrictedSessionRunner runner = new UnrestrictedSessionRunner(
            session) {

        @Override
        public void run() throws ClientException {
            DocumentModelList docs = session.query(query);
            for (DocumentModel doc : docs) {
                results.add(new DocumentDescription(doc));
            }

        }
    };
    runner.runUnrestricted();

    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, results);
    return new InputStreamBlob(new ByteArrayInputStream(
            writer.toString().getBytes("UTF-8")), "application/json");

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;}&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2013 17:47:58 GMT</pubDate>
    <dc:creator>Damien_Metzler</dc:creator>
    <dc:date>2013-03-14T17:47:58Z</dc:date>
    <item>
      <title>Search on all the documents (even on those where the user don&amp;apos;t have permissions)</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/search-on-all-the-documents-even-on-those-where-the-user-don/m-p/317106#M4107</link>
      <description>&lt;P&gt;Is it possible to do a search where the permissions is not considered? So the user can see the results (title and author) but not read the actual file if he/she doesn't have the read permission.&lt;/P&gt;
&lt;P&gt;if not, is it possible to create a gadget that uses another credentials?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2013 04:18:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/search-on-all-the-documents-even-on-those-where-the-user-don/m-p/317106#M4107</guid>
      <dc:creator>Paco_Zarate</dc:creator>
      <dc:date>2013-03-14T04:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Search on all the documents (even on those where the user don&amp;apos;t have permissions)</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/search-on-all-the-documents-even-on-those-where-the-user-don/m-p/317107#M4108</link>
      <description>&lt;P&gt;This can cause a lot of problem for you security but if you want to do it, you can use an unrestrictedsessionrunner like this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Operation(id = Bla.ID, category = Constants.CAT_SERVICES, label = "Bla.getTitleUnrestricted", description = "")
public class Bla {

public static final String ID = "Bla.getTitlesUnRestricted";

@Param(name = "query", required = true)
protected String query;

@Context
CoreSession session;

public class DocumentDescription {

    private DocumentModel doc;

    public DocumentDescription(DocumentModel doc) {
        this.doc = doc;
    }

    public String getTitle() throws ClientException {
        return (String) doc.getPropertyValue("dc:title");
    }

    public String getDescription() throws ClientException {
        return (String) doc.getPropertyValue("dc:description");
    }

}

@OperationMethod
public Blob run() throws Exception {
    final List&amp;lt;DocumentDescription&amp;gt; results = new ArrayList&amp;lt;DocumentDescription&amp;gt;();
    UnrestrictedSessionRunner runner = new UnrestrictedSessionRunner(
            session) {

        @Override
        public void run() throws ClientException {
            DocumentModelList docs = session.query(query);
            for (DocumentModel doc : docs) {
                results.add(new DocumentDescription(doc));
            }

        }
    };
    runner.runUnrestricted();

    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, results);
    return new InputStreamBlob(new ByteArrayInputStream(
            writer.toString().getBytes("UTF-8")), "application/json");

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2013 17:47:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/search-on-all-the-documents-even-on-those-where-the-user-don/m-p/317107#M4108</guid>
      <dc:creator>Damien_Metzler</dc:creator>
      <dc:date>2013-03-14T17:47:58Z</dc:date>
    </item>
  </channel>
</rss>

