cancel
Showing results for 
Search instead for 
Did you mean: 

GROUP_EVERYONE

slothrop
Champ in-the-making
Champ in-the-making
I would like to use the following code to iterate through the users in Javascript in Alfresco v2.1.

 var peeps = people.getMembers(people.getGroup("GROUP_EVERYONE"));

However, people.getGroup("GROUP_EVERYONE") doesn't seem to return anything.  I have tried several variations on the capitalization.  Is there a special way to refer to GROUP_EVERYONE or another way to get all users?
9 REPLIES 9

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

GROUP_EVERYONE is special type of Authority. You won't find this in the web client group management when you try to list all available groups . There is a sample webscript called getUsers to search for users.


getUsers.get.js

var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";

if ((args.s) && (args.s != ""))
{
   query += " AND (";
   var terms = args.s.split(" ");
   for (i = 0; i < terms.length; i++)
   {
      term = terms[i];
      query += "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:*" + term;
      query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:*" + term;
      query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + term;
      query += "*)) ";   // final space here is important as default OR separator
   }
   query += ")";
}

model.searchResults = search.luceneSearch(query);

For your purpose to get all users you could just do a lucene search for all nodes of type Person and manipulate the result as you like.


var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
model.searchResults = search.luceneSearch(query);



Regards,
Shagul

slothrop
Champ in-the-making
Champ in-the-making
Hi,

GROUP_EVERYONE is special type of Authority. You won't find this in the web client group management when you try to list all available groups . There is a sample webscript called getUsers to search for users.


getUsers.get.js

var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";

if ((args.s) && (args.s != ""))
{
   query += " AND (";
   var terms = args.s.split(" ");
   for (i = 0; i < terms.length; i++)
   {
      term = terms[i];
      query += "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:*" + term;
      query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:*" + term;
      query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + term;
      query += "*)) ";   // final space here is important as default OR separator
   }
   query += ")";
}

model.searchResults = search.luceneSearch(query);

For your purpose to get all users you could just do a lucene search for all nodes of type Person and manipulate the result as you like.


var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
model.searchResults = search.luceneSearch(query);



Regards,
Shagul

Thanks Shagul,
Using the code you recommended I was able to get an array of all people objects.  From these objects I wanted to get the home folder of each user and if the user had a certain home folder, assign them to a certain permission group.  Unfortunately,
var h = peeps[i].properties["cm:homeFolder"];
returned a noderef fo type cm:folder which had no cm:name property.  The following,
var h = search.findNode(peeps[i].properties["cm:homeFolder"]);
returned a ScriptNode which had a cm:name property but for every user the cm:name of the home folder thus returned was "Projects Search" which is not the home folder of any of the users and as far as I can tell does not exist on my system.

So I wonder, is this approach worth pursuing or should I give up and try something else?  Any suggestions will be appreciated.

slothrop
Champ in-the-making
Champ in-the-making
My users can be divided into 3 types: those with their own home folder under User Homes, those with their own home folder in a subfolder under User Homes and those who don't have their own home folder but have a collective home folder under User Homes.  But the node returned by
var h = search.findNode(peeps[i].properties["cm:homeFolder"]);
is identical in all cases.

What gives?

monitloth
Champ on-the-rise
Champ on-the-rise
Hi,

I have looked your post. I use the same search function. I am not familiar with FreeMarker. Here is my code:
JSP:

var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
model.searchResults = search.luceneSearch(query);

if (model.searchResults== undefined)
{
      status.code = 404;
   status.message = "No persons.";
   status.redirect = true;
}

FreeMarker:


<#list model.searchResults as result>
  ${result}<br>
</#list>

I also tried ${result.properties.username}<br>.
I get a 500 and not so not a 440. Error I have:
org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expression model is undefined on line 28, column 8 in org/alfresco/my/folders.get.html.ftl.'. Please contact your system administrator.
So what's wrong with my loop?

Thanks very much.

slothrop
Champ in-the-making
Champ in-the-making
Try this:
<#list searchResults as result>
  ${result.name}<br>
</#list>

monitloth
Champ on-the-rise
Champ on-the-rise
Thanks for your answer.

No difference. Here is the traceback (which is the same):
500 Description:    An error inside the HTTP server which prevented it from fulfilling the request.

Message:   Error during processing of the template 'Expression model is undefined on line 7, column 10 in org/alfresco/sample/listing.get.html.ftl.'. Please contact your system administrator.
   
Exception:   freemarker.core.InvalidReferenceException - Expression model is undefined on line 7, column 10 in org/alfresco/sample/listing.get.html.ftl.
   
   freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
   freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
   freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
   freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.Environment.process(Environment.java:188)
   freemarker.template.Template.process(Template.java:237)
   org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:201)
   org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:377)
   org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:280)
   org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:173)
   org.alfresco.repo.web.scripts.RepositoryContainer$1.execute(RepositoryContainer.java:309)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:294)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:209)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:320)
   org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:264)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:240)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
   org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.alfresco.web.app.servlet.MTWebScriptAuthenticationFilter.doFilter(MTWebScriptAuthenticationFilter.java:102)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.alfresco.module.vti.VtiContextFilter.doFilter(VtiContextFilter.java:94)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   java.lang.Thread.run(Thread.java:595)
   
Exception:   org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expression model is undefined on line 7, column 10 in org/alfresco/sample/listing.get.html.ftl.'. Please contact your system administrator.
   
   org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:205)
Thanks very much.

mikeh
Star Contributor
Star Contributor
Your Freemarker script is probably cached if you've removed all "model." references, redeployed. and are still getting the same error.

Try going to /service/index and refresh webscripts.

Mike

chicks
Champ in-the-making
Champ in-the-making
Message:   Error during processing of the template 'Expression model is undefined on line 7, column 10 in org/alfresco/sample/listing.get.html.ftl.'. Please contact your system administrator.

Your answer is right here.  You have "model.searchResults" in your .html.ftl.  You just need "searchResults".

monitloth
Champ on-the-rise
Champ on-the-rise
Great , it works. I think the catch was not updated.

And for those also having the same problem:
Not ${result.name} but ${result.properties.userName}