1 /*******************************************************************************
2 * Copyright � Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
3 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
4 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
6 * This file is part of the work and learning management system Pentila Nero.
8 * Pentila Nero is free software. You can redistribute it and/or modify since
9 * you respect the terms of either (at least one of the both license) :
10 * - under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
14 * License, or any later version
15 * - the GNU Lesser General Public License as published by the
16 * Free Software Foundation, either version 3 of the license,
17 * or (at your option) any later version.
19 * There are special exceptions to the terms and conditions of the
20 * licenses as they are applied to this software. View the full text of
21 * the exception in file LICENSE-PROJECT.txt in the directory of this software
24 * Pentila Nero is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * Licenses for more details.
29 * You should have received a copy of the GNU Affero General Public License
30 * and the CeCILL-C and the GNU Lesser General Public License along with
31 * Pentila Nero. If not, see :
32 * <http://www.gnu.org/licenses/> and
33 * <http://www.cecill.info/licences.fr.html>.
34 ******************************************************************************/
35 package com.pentila.entSavoie.organization;
37 import com.liferay.portal.ModelListenerException;
38 import com.liferay.portal.kernel.log.Log;
39 import com.liferay.portal.kernel.log.LogFactoryUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.model.Organization;
43 public class OrganizationListener implements ModelListener<Organization> {
45 public void onAfterAddAssociation(Object classPK,
46 String associationClassName, Object associationClassPK)
47 throws ModelListenerException {}
49 public void onAfterCreate(Organization model) {
52 final long userId = UserLocalServiceUtil.getDefaultUserId(model.getCompanyId());
53 final long groupId = model.getGroup().getGroupId();
54 final String fUrl = "/atelier";
56 final boolean isPrivate = true;
59 set = LayoutSetLocalServiceUtil.getLayoutSet(groupId, isPrivate);
60 } catch (NoSuchLayoutSetException e) {
61 if (_log.isDebugEnabled()) {
62 _log.debug("Le layout set est introuvable. Creation d'un nouveau");
64 set = LayoutSetLocalServiceUtil.addLayoutSet(groupId, isPrivate);
65 if (_log.isDebugEnabled()) {
66 _log.debug("Creation du LayoutSet finie");
70 //Initialise le layout set.
71 String defaultTheme = ThemeImpl.getDefaultRegularThemeId();
72 set.setThemeId(defaultTheme);
73 LayoutSetLocalServiceUtil.updateLayoutSet(set, true);
75 Layout l = LayoutLocalServiceUtil.addLayout(
78 set.getPrivateLayout(),
79 LayoutConstants.DEFAULT_PLID,
83 LayoutConstants.TYPE_PORTLET,
87 //Par defaut, le theme utilise une disposition a deux colonnes.
88 //reparties equitablement.
89 UnicodeProperties props = l.getTypeSettingsProperties();
90 props.setProperty("layout-template-id", "2_columns_i");
91 l.setTypeSettingsProperties(props);
93 LayoutLocalServiceUtil.updateLayout(l, true);
95 if (_log.isDebugEnabled()) {
96 _log.debug("Creation de page par defaut pour "+l.getName());
98 } catch (Exception e) {
99 if (_log.isErrorEnabled()) {
104 if (_log.isDebugEnabled()) {
105 _log.debug("Creation terminee.");
109 public void onAfterRemove(Organization model) throws ModelListenerException {}
111 public void onAfterRemoveAssociation(Object classPK,
112 String associationClassName, Object associationClassPK)
113 throws ModelListenerException {}
115 public void onAfterUpdate(Organization model) throws ModelListenerException {}
117 public void onBeforeAddAssociation(Object classPK,
118 String associationClassName, Object associationClassPK)
119 throws ModelListenerException {}
121 public void onBeforeCreate(Organization model) throws ModelListenerException {}
123 public void onBeforeRemove(Organization model) throws ModelListenerException {}
125 public void onBeforeRemoveAssociation(Object classPK,
126 String associationClassName, Object associationClassPK)
127 throws ModelListenerException {}
129 public void onBeforeUpdate(Organization model) throws ModelListenerException {}
131 private Log _log = LogFactoryUtil.getLog(this.getClass());