<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to get allCurrentSites by API</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110627076" />
  <subtitle>How to get allCurrentSites by API</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110627076</id>
  <updated>2026-04-04T09:34:21Z</updated>
  <dc:date>2026-04-04T09:34:21Z</dc:date>
  <entry>
    <title>RE: How to get allCurrentSites by API</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110634762" />
    <author>
      <name>Victor Zorin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110634762</id>
    <updated>2018-07-24T23:19:32Z</updated>
    <published>2018-07-24T23:19:32Z</published>
    <summary type="html">&lt;p&gt;The following code will narrow down the search query to pull the
  sites only (tested on 7/DXP):&lt;/p&gt;
&lt;p&gt;            LinkedHashMap&amp;lt;String, Object&amp;gt; params = new
  LinkedHashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;           
   params.put(&amp;quot;site&amp;quot;, new Boolean(true));&lt;br /&gt;           
   List&amp;lt;Group&amp;gt; allGroupsList =
  GroupLocalServiceUtil.search(companyId, params , QueryUtil.ALL_POS,
  QueryUtil.ALL_POS);&lt;br /&gt;  &lt;/p&gt;</summary>
    <dc:creator>Victor Zorin</dc:creator>
    <dc:date>2018-07-24T23:19:32Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to get allCurrentSites by API</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110634256" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110634256</id>
    <updated>2018-07-24T17:42:59Z</updated>
    <published>2018-07-24T17:42:59Z</published>
    <summary type="html">&lt;p&gt;I don't think there is an other way. Could you cache them? Maybe add
  a model listener that clears the cache?&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2018-07-24T17:42:59Z</dc:date>
  </entry>
  <entry>
    <title>How to get allCurrentSites by API</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110627075" />
    <author>
      <name>Iñigo Boyano</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110627075</id>
    <updated>2018-07-24T12:46:29Z</updated>
    <published>2018-07-24T12:46:29Z</published>
    <summary type="html">&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;I need to show all current Sites in a portlet. &lt;/p&gt;
&lt;p&gt;I've read that sites are Groups in liferay whit type=1 and isSite=true.&lt;/p&gt;
&lt;p&gt;After a time searching in Internet how to do this, I found the
  following solution:&lt;/p&gt;
&lt;p&gt;List&amp;lt;Group&amp;gt; listAllCompanies =
  GroupLocalServiceUtil.search(PortalUtil.getCompanyId(request), null,
  null,null, QueryUtil.ALL_POS, QueryUtil.ALL_POS);&lt;/p&gt;
&lt;p&gt;
  &lt;br /&gt; // define a new list ONLY for sites,&lt;br /&gt; List&amp;lt;Group&amp;gt;
  sites = new ArrayList&amp;lt;Group&amp;gt;();&lt;br /&gt; // filter the original
  list and populate the new list&lt;br /&gt; for (Group group:
  listAllCompanies) {&lt;br /&gt;     if (group.getType() == 1 &amp;amp;&amp;amp;
  group.isSite()) {&lt;br /&gt;         sites.add(group);&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;
  &lt;br /&gt; This code works properly and in sites variable I have only the
  sites I want to show, the problem is the performance, I have about
  55000 groups to loop.&lt;/p&gt;
&lt;p&gt;Is there any way to improve this performance or maybe using other API?&lt;/p&gt;
&lt;p&gt;Kind regards, &lt;/p&gt;
&lt;p&gt;Iñigo&lt;/p&gt;</summary>
    <dc:creator>Iñigo Boyano</dc:creator>
    <dc:date>2018-07-24T12:46:29Z</dc:date>
  </entry>
</feed>
