001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.exportimport.lifecycle;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.MapUtil;
020    import com.liferay.portal.model.StagedModel;
021    import com.liferay.portlet.exportimport.lar.PortletDataContext;
022    import com.liferay.portlet.exportimport.model.ExportImportConfiguration;
023    
024    import java.io.Serializable;
025    
026    import java.util.Map;
027    
028    /**
029     * @author Daniel Kocsis
030     */
031    public class LoggerExportImportLifecycleListener
032            extends BaseExportImportLifecycleListener {
033    
034            @Override
035            public boolean isParallel() {
036                    return false;
037            }
038    
039            @Override
040            public void onExportImportLifecycleEvent(
041                            ExportImportLifecycleEvent exportImportLifecycleEvent)
042                    throws Exception {
043    
044                    if (!_log.isDebugEnabled()) {
045                            return;
046                    }
047    
048                    super.onExportImportLifecycleEvent(exportImportLifecycleEvent);
049            }
050    
051            @Override
052            protected void onLayoutExportFailed(
053                            PortletDataContext portletDataContext, Throwable throwable)
054                    throws Exception {
055    
056                    if (!_log.isDebugEnabled()) {
057                            return;
058                    }
059    
060                    _log.debug(
061                            "Layout export failed for group " + portletDataContext.getGroupId(),
062                            throwable);
063            }
064    
065            @Override
066            protected void onLayoutExportStarted(PortletDataContext portletDataContext)
067                    throws Exception {
068    
069                    if (!_log.isDebugEnabled()) {
070                            return;
071                    }
072    
073                    _log.debug(
074                            "Layout export started for group " +
075                                    portletDataContext.getGroupId());
076            }
077    
078            @Override
079            protected void onLayoutExportSucceeded(
080                            PortletDataContext portletDataContext)
081                    throws Exception {
082    
083                    if (!_log.isDebugEnabled()) {
084                            return;
085                    }
086    
087                    _log.debug(
088                            "Layout export succeeded for group " +
089                                    portletDataContext.getGroupId());
090            }
091    
092            @Override
093            protected void onLayoutImportFailed(
094                            PortletDataContext portletDataContext, Throwable throwable)
095                    throws Exception {
096    
097                    if (!_log.isDebugEnabled()) {
098                            return;
099                    }
100    
101                    _log.debug(
102                            "Layout import failed for group " + portletDataContext.getGroupId(),
103                            throwable);
104            }
105    
106            @Override
107            protected void onLayoutImportStarted(PortletDataContext portletDataContext)
108                    throws Exception {
109    
110                    if (!_log.isDebugEnabled()) {
111                            return;
112                    }
113    
114                    _log.debug(
115                            "Layout import started for group " +
116                                    portletDataContext.getGroupId());
117            }
118    
119            @Override
120            protected void onLayoutImportSucceeded(
121                            PortletDataContext portletDataContext)
122                    throws Exception {
123    
124                    if (!_log.isDebugEnabled()) {
125                            return;
126                    }
127    
128                    _log.debug(
129                            "Layout import succeeded for group " +
130                                    portletDataContext.getGroupId());
131            }
132    
133            @Override
134            protected void onLayoutLocalPublicationFailed(
135                            ExportImportConfiguration exportImportConfiguration,
136                            Throwable throwable)
137                    throws Exception {
138    
139                    if (!_log.isDebugEnabled()) {
140                            return;
141                    }
142    
143                    _log.debug(
144                            "Layout publication failed for group " +
145                                    exportImportConfiguration.getGroupId(),
146                            throwable);
147            }
148    
149            @Override
150            protected void onLayoutLocalPublicationStarted(
151                            ExportImportConfiguration exportImportConfiguration)
152                    throws Exception {
153    
154                    if (!_log.isDebugEnabled()) {
155                            return;
156                    }
157    
158                    _log.debug(
159                            "Layout publication started for group " +
160                                    exportImportConfiguration.getGroupId());
161            }
162    
163            @Override
164            protected void onLayoutLocalPublicationSucceeded(
165                            ExportImportConfiguration exportImportConfiguration)
166                    throws Exception {
167    
168                    if (!_log.isDebugEnabled()) {
169                            return;
170                    }
171    
172                    _log.debug(
173                            "Layout publication succeeded for group " +
174                                    exportImportConfiguration.getGroupId());
175            }
176    
177            @Override
178            protected void onLayoutRemotePublicationFailed(
179                            ExportImportConfiguration exportImportConfiguration,
180                            Throwable throwable)
181                    throws Exception {
182    
183                    if (!_log.isDebugEnabled()) {
184                            return;
185                    }
186    
187                    _log.debug(
188                            "Layout remote publication failed for group " +
189                                    exportImportConfiguration.getGroupId(),
190                            throwable);
191            }
192    
193            @Override
194            protected void onLayoutRemotePublicationStarted(
195                            ExportImportConfiguration exportImportConfiguration)
196                    throws Exception {
197    
198                    if (!_log.isDebugEnabled()) {
199                            return;
200                    }
201    
202                    _log.debug(
203                            "Layout publication started for group " +
204                                    exportImportConfiguration.getGroupId());
205            }
206    
207            @Override
208            protected void onLayoutRemotePublicationSucceeded(
209                            ExportImportConfiguration exportImportConfiguration)
210                    throws Exception {
211    
212                    if (!_log.isDebugEnabled()) {
213                            return;
214                    }
215    
216                    _log.debug(
217                            "Layout remote publication succeeded for group " +
218                                    exportImportConfiguration.getGroupId());
219            }
220    
221            @Override
222            protected void onPortletExportFailed(
223                            PortletDataContext portletDataContext, Throwable throwable)
224                    throws Exception {
225    
226                    if (!_log.isDebugEnabled()) {
227                            return;
228                    }
229    
230                    _log.debug(
231                            "Portlet export failed for portlet " +
232                                    portletDataContext.getPortletId(),
233                            throwable);
234            }
235    
236            @Override
237            protected void onPortletExportStarted(PortletDataContext portletDataContext)
238                    throws Exception {
239    
240                    if (!_log.isDebugEnabled()) {
241                            return;
242                    }
243    
244                    _log.debug(
245                            "Portlet export started for portlet " +
246                                    portletDataContext.getPortletId());
247            }
248    
249            @Override
250            protected void onPortletExportSucceeded(
251                            PortletDataContext portletDataContext)
252                    throws Exception {
253    
254                    if (!_log.isDebugEnabled()) {
255                            return;
256                    }
257    
258                    _log.debug(
259                            "Portlet export succeeded for portlet " +
260                                    portletDataContext.getPortletId());
261            }
262    
263            @Override
264            protected void onPortletImportFailed(
265                            PortletDataContext portletDataContext, Throwable throwable)
266                    throws Exception {
267    
268                    if (!_log.isDebugEnabled()) {
269                            return;
270                    }
271    
272                    _log.debug(
273                            "Portlet import failed for portlet " +
274                                    portletDataContext.getPortletId(),
275                            throwable);
276            }
277    
278            @Override
279            protected void onPortletImportStarted(PortletDataContext portletDataContext)
280                    throws Exception {
281    
282                    if (!_log.isDebugEnabled()) {
283                            return;
284                    }
285    
286                    _log.debug(
287                            "Portlet import started for portlet " +
288                                    portletDataContext.getPortletId());
289            }
290    
291            @Override
292            protected void onPortletImportSucceeded(
293                            PortletDataContext portletDataContext)
294                    throws Exception {
295    
296                    if (!_log.isDebugEnabled()) {
297                            return;
298                    }
299    
300                    _log.debug(
301                            "Portlet import succeeded for portlet " +
302                                    portletDataContext.getPortletId());
303            }
304    
305            @Override
306            protected void onPortletPublicationFailed(
307                            ExportImportConfiguration exportImportConfiguration,
308                            Throwable throwable)
309                    throws Exception {
310    
311                    if (!_log.isDebugEnabled()) {
312                            return;
313                    }
314    
315                    Map<String, Serializable> settingsMap =
316                            exportImportConfiguration.getSettingsMap();
317    
318                    String portletId = MapUtil.getString(settingsMap, "portletId");
319    
320                    _log.debug(
321                            "Portlet publication failed for portlet " + portletId, throwable);
322            }
323    
324            @Override
325            protected void onPortletPublicationStarted(
326                            ExportImportConfiguration exportImportConfiguration)
327                    throws Exception {
328    
329                    if (!_log.isDebugEnabled()) {
330                            return;
331                    }
332    
333                    Map<String, Serializable> settingsMap =
334                            exportImportConfiguration.getSettingsMap();
335    
336                    String portletId = MapUtil.getString(settingsMap, "portletId");
337    
338                    _log.debug("Portlet publication started for portlet " + portletId);
339            }
340    
341            @Override
342            protected void onPortletPublicationSucceeded(
343                            ExportImportConfiguration exportImportConfiguration)
344                    throws Exception {
345    
346                    if (!_log.isDebugEnabled()) {
347                            return;
348                    }
349    
350                    Map<String, Serializable> settingsMap =
351                            exportImportConfiguration.getSettingsMap();
352    
353                    String portletId = MapUtil.getString(settingsMap, "portletId");
354    
355                    _log.debug("Portlet publication succeeded for portlet " + portletId);
356            }
357    
358            @Override
359            protected void onStagedModelExportFailed(
360                            PortletDataContext portletDataContext, StagedModel stagedModel,
361                            Throwable throwable)
362                    throws Exception {
363    
364                    if (!_log.isDebugEnabled()) {
365                            return;
366                    }
367    
368                    _log.debug(
369                            "Staged model " + stagedModel.getStagedModelType() +
370                                    " export failed",
371                            throwable);
372            }
373    
374            @Override
375            protected void onStagedModelExportStarted(
376                            PortletDataContext portletDataContext, StagedModel stagedModel)
377                    throws Exception {
378    
379                    if (!_log.isDebugEnabled()) {
380                            return;
381                    }
382    
383                    _log.debug(
384                            "Staged model " + stagedModel.getStagedModelType() +
385                                    " export started");
386            }
387    
388            @Override
389            protected void onStagedModelExportSucceeded(
390                            PortletDataContext portletDataContext, StagedModel stagedModel)
391                    throws Exception {
392    
393                    if (!_log.isDebugEnabled()) {
394                            return;
395                    }
396    
397                    _log.debug(
398                            "Staged model " + stagedModel.getStagedModelType() +
399                                    " export succeeded");
400            }
401    
402            @Override
403            protected void onStagedModelImportFailed(
404                            PortletDataContext portletDataContext, StagedModel stagedModel,
405                            Throwable throwable)
406                    throws Exception {
407    
408                    if (!_log.isDebugEnabled()) {
409                            return;
410                    }
411    
412                    _log.debug(
413                            "Staged model " + stagedModel.getStagedModelType() +
414                                    " import failed",
415                            throwable);
416            }
417    
418            @Override
419            protected void onStagedModelImportStarted(
420                            PortletDataContext portletDataContext, StagedModel stagedModel)
421                    throws Exception {
422    
423                    if (!_log.isDebugEnabled()) {
424                            return;
425                    }
426    
427                    _log.debug(
428                            "Staged model " + stagedModel.getStagedModelType() +
429                                    " import started");
430            }
431    
432            @Override
433            protected void onStagedModelImportSucceeded(
434                            PortletDataContext portletDataContext, StagedModel stagedModel)
435                    throws Exception {
436    
437                    if (!_log.isDebugEnabled()) {
438                            return;
439                    }
440    
441                    _log.debug(
442                            "Staged model " + stagedModel.getStagedModelType() +
443                                    " import succeeded");
444            }
445    
446            private static final Log _log = LogFactoryUtil.getLog(
447                    LoggerExportImportLifecycleListener.class);
448    
449    }