--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<%@page import="com.liferay.portal.service.persistence.OrganizationUtil"%>
+<%@page import="com.liferay.portal.service.persistence.OrganizationFinderUtil"%>
+<% /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+*
+*This file is part of the work and learning management system Pentila Nero.
+*
+*Pentila Nero is free software. You can redistribute it and/or modify since
+*you respect the terms of either (at least one of the both license) :
+*- under the terms of the GNU Affero General Public License as
+*published by the Free Software Foundation, either version 3 of the
+*License, or (at your option) any later version.
+*- the CeCILL-C as published by CeCILL-C; either version 1 of the
+*License, or any later version
+*- the GNU Lesser General Public License as published by the
+*Free Software Foundation, either version 3 of the license,
+*or (at your option) any later version.
+*
+*There are special exceptions to the terms and conditions of the
+*licenses as they are applied to this software. View the full text of
+*the exception in file LICENSE-PROJECT.txt in the directory of this software
+*distribution.
+*
+*Pentila Nero is distributed in the hope that it will be useful,
+*but WITHOUT ANY WARRANTY; without even the implied warranty of
+*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+*Licenses for more details.
+*
+*You should have received a copy of the GNU Affero General Public License
+*and the CeCILL-C and the GNU Lesser General Public License along with
+*Pentila Nero. If not, see :
+*<http://www.gnu.org/licenses/> and
+*<http://www.cecill.info/licences.fr.html>.
+*/ %>
+<%@page import="java.text.Collator"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="java.util.Collections"%>
+<%@page import="java.util.List"%>
+<%@page import="java.util.Locale"%>
+
+<%@page import="javax.portlet.PortletPreferences"%>
+
+<%@page import="com.liferay.portal.kernel.json.JSONArray"%>
+<%@page import="com.liferay.portal.kernel.json.JSONObject"%>
+<%@page import="com.liferay.portal.kernel.servlet.HttpHeaders" %>
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="com.liferay.portal.service.OrganizationLocalServiceUtil"%>
+
+<%@page import="com.pentila.entSavoie.communityInfos.SearchUtil"%>
+<%@page import="com.pentila.entSavoie.ENTDisplayUtil"%>
+<%@page import="com.pentila.entSavoie.utils.GroupCacheUtil"%>
+
+<%@ include file="/init.jsp" %>
+
+<%
+ renderResponse.setContentType("text/xml");
+ response.setContentType("text/xml");
+ response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
+
+ final int start = ParamUtil.getInteger(renderRequest, "start");
+ final int limit = ParamUtil.getInteger(renderRequest, "limit");
+ int stop = start + limit;
+
+ final String search = ParamUtil.getString(renderRequest, "recherche", "").toLowerCase();
+
+
+ // on prend les org du user
+ List<Organization> orgsList = new ArrayList<Organization>();
+
+ // Keep non-migrated organizations
+ JSONObject userGroupsJson = GroupCacheUtil.getUserGroups(user);
+ JSONArray institutionalGroupsJsonArray = GroupCacheUtil.getInstitutionalGroups(user, userGroupsJson);
+ for (int i = 0 ; i < institutionalGroupsJsonArray.length() ; i++) {
+ JSONObject groupJson = institutionalGroupsJsonArray.getJSONObject(i);
+ String view = groupJson.getString(GroupCacheUtil.GROUP_DEFAULT_VIEW);
+ boolean isMigrated = groupJson.getBoolean(GroupCacheUtil.GROUP_IS_MIGRATED);
+ if (isMigrated) {
+ continue;
+ }
+ Organization org = OrganizationLocalServiceUtil.getOrganization(Long.parseLong(groupJson.getString(GroupCacheUtil.GROUP_ORG_ID)));
+ if (!org.isRoot()) {
+ orgsList.add(org);
+ }
+ }
+
+ List<Organization> orgsFiltered = new ArrayList<Organization>();
+ if (search.equals("")) {
+ orgsFiltered.addAll(orgsList);
+ }
+ else {
+ orgsFiltered = SearchUtil.filterOrganizations(orgsList, search);
+ }
+ //Collections.sort(orgsFiltered, new OrganizationNameComparator());
+
+ final int nbRecords = orgsFiltered.size();
+ if (stop>nbRecords) {
+ stop = nbRecords;
+ }
+ orgsFiltered = orgsFiltered.subList(start, stop);
+
+%>
+
+<orgs>
+ <% for (Organization o : orgsFiltered) {
+ %>
+ <org>
+ <type>organization</type>
+ <id><%= o.getOrganizationId() %></id>
+ <name><![CDATA[<%= ENTDisplayUtil.formatSCONETName(user, o.getName(), true) %>]]></name>
+ <total><%= nbRecords %></total>
+ </org>
+ <% } %>
+</orgs>