<?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>Getting Site repository from 'groupId' and 'repositoryId' values.</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121979940" />
  <subtitle>Getting Site repository from 'groupId' and 'repositoryId' values.</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121979940</id>
  <updated>2026-04-03T19:13:22Z</updated>
  <dc:date>2026-04-03T19:13:22Z</dc:date>
  <entry>
    <title>Getting Site repository from 'groupId' and 'repositoryId' values.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121979939" />
    <author>
      <name>txapeldot .</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121979939</id>
    <updated>2023-08-14T11:29:42Z</updated>
    <published>2023-08-14T11:29:41Z</published>
    <summary type="html">&lt;p&gt;When dealing with the Documents &amp;amp; Media API, and according to the
  official &lt;a
  href="https://help.liferay.com/hc/en-us/articles/360019952312-Getting-Started-with-the-Documents-and-Media-API-#specifying-repositories"&gt;documentation&lt;/a&gt;,
  &amp;quot;a Site (group) can have multiple repositories, but only one can
  be accessed via the portal UI. This is called the Site repository,
  which is effectively a Site’s default repository. To access this
  repository via the API, provide the group ID as the repositoryId&amp;quot;.&lt;/p&gt;
&lt;p&gt;That is, it's seems it has to be provided the 'groupId' to get the
  site repository object.&lt;/p&gt;
&lt;p&gt;Ok, the way I get the 'groupId' value is by means of the folowing sentence:&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;groupId = GroupLocalServiceUtil.getGroup(this.companyId, &amp;quot;Guest&amp;quot;).getGroupId(); //which provides value '20124'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, if it's analysed Liferay 'repository' table, it can be seen
  that the primary key is 'repositoryId' field, and if we check the rows
  of that table (within my current Liferay installation) I get these two rows:&lt;/p&gt;
&lt;p&gt;
  &lt;br&gt; repositoryId    groupId          companyId    ...&lt;br&gt;
  --------------------------------------------------------&lt;br&gt; 33727   
           20128            20101&lt;br&gt; 33970             20124            20101&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;My question is how it is possible to get the Site repository object
  from the 'groupId' value if the 'groupId' value (20124) is not among
  the primary keys of the repository table? That is, if we were to write
  the following sentences to get the Site repository object, isn't it
  supposed we have to pass the primary key associated to the Site repository?&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;@Reference
private RepositoryProvider repositoryProvider;
Repository repository = repositoryProvider.getRepository(repositoryId); // repositoryId &amp;lt;- groupId  &amp;lt;- 20124&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I find it somewhat confussing. Any clarification would really be
  appreciated. Thanks.&lt;/p&gt;</summary>
    <dc:creator>txapeldot .</dc:creator>
    <dc:date>2023-08-14T11:29:41Z</dc:date>
  </entry>
</feed>
