001    /**
002     * Copyright (c) 2000-2013 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.portal.service.impl;
016    
017    import com.liferay.portal.NoSuchLayoutException;
018    import com.liferay.portal.kernel.cache.ThreadLocalCachable;
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.exception.SystemException;
021    import com.liferay.portal.kernel.lar.MissingReferences;
022    import com.liferay.portal.kernel.messaging.DestinationNames;
023    import com.liferay.portal.kernel.repository.model.FileEntry;
024    import com.liferay.portal.kernel.scheduler.CronTrigger;
025    import com.liferay.portal.kernel.scheduler.SchedulerEngineHelperUtil;
026    import com.liferay.portal.kernel.scheduler.StorageType;
027    import com.liferay.portal.kernel.scheduler.Trigger;
028    import com.liferay.portal.kernel.util.Digester;
029    import com.liferay.portal.kernel.util.DigesterUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.StringPool;
032    import com.liferay.portal.kernel.util.TempFileUtil;
033    import com.liferay.portal.kernel.util.Validator;
034    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
035    import com.liferay.portal.messaging.LayoutsLocalPublisherRequest;
036    import com.liferay.portal.messaging.LayoutsRemotePublisherRequest;
037    import com.liferay.portal.model.Group;
038    import com.liferay.portal.model.Layout;
039    import com.liferay.portal.model.LayoutConstants;
040    import com.liferay.portal.model.LayoutReference;
041    import com.liferay.portal.model.LayoutTypePortlet;
042    import com.liferay.portal.model.Plugin;
043    import com.liferay.portal.model.User;
044    import com.liferay.portal.security.permission.ActionKeys;
045    import com.liferay.portal.security.permission.PermissionChecker;
046    import com.liferay.portal.service.ServiceContext;
047    import com.liferay.portal.service.base.LayoutServiceBaseImpl;
048    import com.liferay.portal.service.permission.GroupPermissionUtil;
049    import com.liferay.portal.service.permission.LayoutPermissionUtil;
050    import com.liferay.portal.service.permission.PortletPermissionUtil;
051    import com.liferay.portal.util.PortletKeys;
052    import com.liferay.portlet.PortletPreferencesFactoryUtil;
053    
054    import java.io.File;
055    import java.io.InputStream;
056    
057    import java.util.ArrayList;
058    import java.util.Date;
059    import java.util.List;
060    import java.util.Locale;
061    import java.util.Map;
062    
063    /**
064     * Provides the remote service for accessing, adding, deleting, exporting,
065     * importing, scheduling publishing of, and updating layouts. Its methods
066     * include permission checks.
067     *
068     * @author Brian Wing Shun Chan
069     * @author Wesley Gong
070     * @author Tibor Lipusz
071     */
072    public class LayoutServiceImpl extends LayoutServiceBaseImpl {
073    
074            /**
075             * Adds a layout with additional parameters.
076             *
077             * <p>
078             * This method handles the creation of the layout including its resources,
079             * metadata, and internal data structures. It is not necessary to make
080             * subsequent calls to any methods to setup default groups, resources, ...
081             * etc.
082             * </p>
083             *
084             * @param      groupId the primary key of the group
085             * @param      privateLayout whether the layout is private to the group
086             * @param      parentLayoutId the primary key of the parent layout
087             *             (optionally {@link
088             *             com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID})
089             * @param      localeNamesMap the layout's locales and localized names
090             * @param      localeTitlesMap the layout's locales and localized titles
091             * @param      descriptionMap the layout's locales and localized
092             *             descriptions
093             * @param      keywordsMap the layout's locales and localized keywords
094             * @param      robotsMap the layout's locales and localized robots
095             * @param      type the layout's type (optionally {@link
096             *             com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}). The
097             *             possible types can be found in {@link
098             *             com.liferay.portal.model.LayoutConstants}.
099             * @param      hidden whether the layout is hidden
100             * @param      friendlyURL the layout's locales and localized friendly URLs.
101             *             To see how the URL is normalized when accessed, see {@link
102             *             com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
103             *             String)}.
104             * @param      serviceContext the service context to be applied. Must set
105             *             the UUID for the layout. Can set the creation date,
106             *             modification date, and expando bridge attributes for the
107             *             layout. For layouts that belong to a layout set prototype, an
108             *             attribute named <code>layoutUpdateable</code> can be used to
109             *             specify whether site administrators can modify this page
110             *             within their site.
111             * @return     the layout
112             * @throws     PortalException if a group with the primary key could not be
113             *             found, if the group did not have permission to manage the
114             *             layouts involved, if layout values were invalid, or if a
115             *             portal exception occurred
116             * @throws     SystemException if a system exception occurred
117             * @deprecated As of 6.2.0, replaced by {@link #addLayout(long, boolean,
118             *             long, Map, Map, Map, Map, Map, String, String, boolean, Map,
119             *             ServiceContext)}
120             */
121            @Override
122            public Layout addLayout(
123                            long groupId, boolean privateLayout, long parentLayoutId,
124                            Map<Locale, String> localeNamesMap,
125                            Map<Locale, String> localeTitlesMap,
126                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
127                            Map<Locale, String> robotsMap, String type, boolean hidden,
128                            String friendlyURL, ServiceContext serviceContext)
129                    throws PortalException, SystemException {
130    
131                    PermissionChecker permissionChecker = getPermissionChecker();
132    
133                    if (parentLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
134                            GroupPermissionUtil.check(
135                                    permissionChecker, groupId, ActionKeys.ADD_LAYOUT);
136                    }
137                    else {
138                            LayoutPermissionUtil.check(
139                                    permissionChecker, groupId, privateLayout, parentLayoutId,
140                                    ActionKeys.ADD_LAYOUT);
141                    }
142    
143                    return layoutLocalService.addLayout(
144                            getUserId(), groupId, privateLayout, parentLayoutId, localeNamesMap,
145                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
146                            hidden, friendlyURL, serviceContext);
147            }
148    
149            /**
150             * Adds a layout with additional parameters.
151             *
152             * <p>
153             * This method handles the creation of the layout including its resources,
154             * metadata, and internal data structures. It is not necessary to make
155             * subsequent calls to any methods to setup default groups, resources, ...
156             * etc.
157             * </p>
158             *
159             * @param  groupId the primary key of the group
160             * @param  privateLayout whether the layout is private to the group
161             * @param  parentLayoutId the primary key of the parent layout (optionally
162             *         {@link
163             *         com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID})
164             * @param  localeNamesMap the layout's locales and localized names
165             * @param  localeTitlesMap the layout's locales and localized titles
166             * @param  descriptionMap the layout's locales and localized descriptions
167             * @param  keywordsMap the layout's locales and localized keywords
168             * @param  robotsMap the layout's locales and localized robots
169             * @param  type the layout's type (optionally {@link
170             *         com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}). The
171             *         possible types can be found in {@link
172             *         com.liferay.portal.model.LayoutConstants}.
173             * @param  typeSettings the settings to load the unicode properties object.
174             *         See {@link com.liferay.portal.kernel.util.UnicodeProperties
175             *         #fastLoad(String)}.
176             * @param  hidden whether the layout is hidden
177             * @param  friendlyURLMap the layout's locales and localized friendly URLs.
178             *         To see how the URL is normalized when accessed, see {@link
179             *         com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
180             *         String)}.
181             * @param  serviceContext the service context to be applied. Must set the
182             *         UUID for the layout. Can set the creation date, modification
183             *         date, and expando bridge attributes for the layout. For layouts
184             *         that belong to a layout set prototype, an attribute named
185             *         <code>layoutUpdateable</code> can be used to specify whether site
186             *         administrators can modify this page within their site.
187             * @return the layout
188             * @throws PortalException if a group with the primary key could not be
189             *         found, if the group did not have permission to manage the layouts
190             *         involved, if layout values were invalid, or if a portal exception
191             *         occurred
192             * @throws SystemException if a system exception occurred
193             */
194            @Override
195            public Layout addLayout(
196                            long groupId, boolean privateLayout, long parentLayoutId,
197                            Map<Locale, String> localeNamesMap,
198                            Map<Locale, String> localeTitlesMap,
199                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
200                            Map<Locale, String> robotsMap, String type, String typeSettings,
201                            boolean hidden, Map<Locale, String> friendlyURLMap,
202                            ServiceContext serviceContext)
203                    throws PortalException, SystemException {
204    
205                    PermissionChecker permissionChecker = getPermissionChecker();
206    
207                    if (parentLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
208                            GroupPermissionUtil.check(
209                                    permissionChecker, groupId, ActionKeys.ADD_LAYOUT);
210                    }
211                    else {
212                            LayoutPermissionUtil.check(
213                                    permissionChecker, groupId, privateLayout, parentLayoutId,
214                                    ActionKeys.ADD_LAYOUT);
215                    }
216    
217                    return layoutLocalService.addLayout(
218                            getUserId(), groupId, privateLayout, parentLayoutId, localeNamesMap,
219                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
220                            typeSettings, hidden, friendlyURLMap, serviceContext);
221            }
222    
223            /**
224             * Adds a layout with single entry maps for name, title, and description to
225             * the default locale.
226             *
227             * <p>
228             * This method handles the creation of the layout including its resources,
229             * metadata, and internal data structures. It is not necessary to make
230             * subsequent calls to any methods to setup default groups, resources, ...
231             * etc.
232             * </p>
233             *
234             * @param  groupId the primary key of the group
235             * @param  privateLayout whether the layout is private to the group
236             * @param  parentLayoutId the primary key of the parent layout (optionally
237             *         {@link
238             *         com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID})
239             * @param  name Map the layout's locales and localized names
240             * @param  title Map the layout's locales and localized titles
241             * @param  description Map the layout's locales and localized descriptions
242             * @param  type the layout's type (optionally {@link
243             *         com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}). The
244             *         possible types can be found in {@link
245             *         com.liferay.portal.model.LayoutConstants}.
246             * @param  hidden whether the layout is hidden
247             * @param  friendlyURL the layout's locales and localized friendly URLs. To
248             *         see how the URL is normalized when accessed, see {@link
249             *         com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
250             *         String)}.
251             * @param  serviceContext the service context to be applied. Must set the
252             *         UUID for the layout. Can specify the creation date, modification
253             *         date, and expando bridge attributes for the layout. For layouts
254             *         that belong to a layout set prototype, an attribute named
255             *         <code>layoutUpdateable</code> can be used to specify whether site
256             *         administrators can modify this page within their site.
257             * @return the layout
258             * @throws PortalException if a group with the primary key could not be
259             *         found, if the group did not have permission to manage the layouts
260             *         involved, if layout values were invalid, or if a portal exception
261             *         occurred
262             * @throws SystemException if a system exception occurred
263             */
264            @Override
265            public Layout addLayout(
266                            long groupId, boolean privateLayout, long parentLayoutId,
267                            String name, String title, String description, String type,
268                            boolean hidden, String friendlyURL, ServiceContext serviceContext)
269                    throws PortalException, SystemException {
270    
271                    PermissionChecker permissionChecker = getPermissionChecker();
272    
273                    if (parentLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
274                            GroupPermissionUtil.check(
275                                    permissionChecker, groupId, ActionKeys.ADD_LAYOUT);
276                    }
277                    else {
278                            LayoutPermissionUtil.check(
279                                    permissionChecker, groupId, privateLayout, parentLayoutId,
280                                    ActionKeys.ADD_LAYOUT);
281                    }
282    
283                    return layoutLocalService.addLayout(
284                            getUserId(), groupId, privateLayout, parentLayoutId, name, title,
285                            description, type, hidden, friendlyURL, serviceContext);
286            }
287    
288            @Override
289            public FileEntry addTempFileEntry(
290                            long groupId, String fileName, String tempFolderName,
291                            InputStream inputStream, String mimeType)
292                    throws PortalException, SystemException {
293    
294                    GroupPermissionUtil.check(
295                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
296    
297                    return TempFileUtil.addTempFile(
298                            groupId, getUserId(), fileName,
299                            DigesterUtil.digestHex(Digester.SHA_256, tempFolderName),
300                            inputStream, mimeType);
301            }
302    
303            /**
304             * Deletes the layout with the primary key, also deleting the layout's child
305             * layouts, and associated resources.
306             *
307             * @param  groupId the primary key of the group
308             * @param  privateLayout whether the layout is private to the group
309             * @param  layoutId the primary key of the layout
310             * @param  serviceContext the service context to be applied
311             * @throws PortalException if the user did not have permission to delete the
312             *         layout, if a matching layout could not be found , or if some
313             *         other portal exception occurred
314             * @throws SystemException if a system exception occurred
315             */
316            @Override
317            public void deleteLayout(
318                            long groupId, boolean privateLayout, long layoutId,
319                            ServiceContext serviceContext)
320                    throws PortalException, SystemException {
321    
322                    LayoutPermissionUtil.check(
323                            getPermissionChecker(), groupId, privateLayout, layoutId,
324                            ActionKeys.DELETE);
325    
326                    layoutLocalService.deleteLayout(
327                            groupId, privateLayout, layoutId, serviceContext);
328            }
329    
330            /**
331             * Deletes the layout with the plid, also deleting the layout's child
332             * layouts, and associated resources.
333             *
334             * @param  plid the primary key of the layout
335             * @param  serviceContext the service context to be applied
336             * @throws PortalException if the user did not have permission to delete the
337             *         layout, if a layout with the primary key could not be found , or
338             *         if some other portal exception occurred
339             * @throws SystemException if a system exception occurred
340             */
341            @Override
342            public void deleteLayout(long plid, ServiceContext serviceContext)
343                    throws PortalException, SystemException {
344    
345                    LayoutPermissionUtil.check(
346                            getPermissionChecker(), plid, ActionKeys.DELETE);
347    
348                    layoutLocalService.deleteLayout(plid, serviceContext);
349            }
350    
351            @Override
352            public void deleteTempFileEntry(
353                            long groupId, String fileName, String tempFolderName)
354                    throws PortalException, SystemException {
355    
356                    GroupPermissionUtil.check(
357                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
358    
359                    TempFileUtil.deleteTempFile(
360                            groupId, getUserId(), fileName,
361                            DigesterUtil.digestHex(Digester.SHA_256, tempFolderName));
362            }
363    
364            /**
365             * Exports the layouts that match the primary keys and the criteria as a
366             * byte array.
367             *
368             * @param  groupId the primary key of the group
369             * @param  privateLayout whether the layout is private to the group
370             * @param  layoutIds the primary keys of the layouts to be exported
371             * @param  parameterMap the mapping of parameters indicating which
372             *         information to export. For information on the keys used in the
373             *         map see {@link
374             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
375             * @param  startDate the export's start date
376             * @param  endDate the export's end date
377             * @return the layouts as a byte array
378             * @throws PortalException if a group or any layout with the primary key
379             *         could not be found, if the group did not have permission to
380             *         manage the layouts, or if some other portal exception occurred
381             * @throws SystemException if a system exception occurred
382             */
383            @Override
384            public byte[] exportLayouts(
385                            long groupId, boolean privateLayout, long[] layoutIds,
386                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
387                    throws PortalException, SystemException {
388    
389                    GroupPermissionUtil.check(
390                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
391    
392                    return layoutLocalService.exportLayouts(
393                            groupId, privateLayout, layoutIds, parameterMap, startDate,
394                            endDate);
395            }
396    
397            /**
398             * Exports all layouts that match the criteria as a byte array.
399             *
400             * @param  groupId the primary key of the group
401             * @param  privateLayout whether the layout is private to the group
402             * @param  parameterMap the mapping of parameters indicating which
403             *         information to export. For information on the keys used in the
404             *         map see {@link
405             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
406             * @param  startDate the export's start date
407             * @param  endDate the export's end date
408             * @return the layout as a byte array
409             * @throws PortalException if a group with the primary key could not be
410             *         found, if the group did not have permission to manage the
411             *         layouts, or if some other portal exception occurred
412             * @throws SystemException if a system exception occurred
413             */
414            @Override
415            public byte[] exportLayouts(
416                            long groupId, boolean privateLayout,
417                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
418                    throws PortalException, SystemException {
419    
420                    GroupPermissionUtil.check(
421                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
422    
423                    return layoutLocalService.exportLayouts(
424                            groupId, privateLayout, parameterMap, startDate, endDate);
425            }
426    
427            /**
428             * Exports all layouts that match the primary keys and criteria as a file.
429             *
430             * @param  groupId the primary key of the group
431             * @param  privateLayout whether the layout is private to the group
432             * @param  layoutIds the primary keys of the layouts to be exported
433             *         (optionally <code>null</code>)
434             * @param  parameterMap the mapping of parameters indicating which
435             *         information to export. For information on the keys used in the
436             *         map see {@link
437             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
438             * @param  startDate the export's start date
439             * @param  endDate the export's end date
440             * @return the layouts as a File
441             * @throws PortalException if a group or any layout with the primary key
442             *         could not be found, it the group did not have permission to
443             *         manage the layouts, or if some other portal exception occurred
444             * @throws SystemException if a system exception occurred
445             */
446            @Override
447            public File exportLayoutsAsFile(
448                            long groupId, boolean privateLayout, long[] layoutIds,
449                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
450                    throws PortalException, SystemException {
451    
452                    GroupPermissionUtil.check(
453                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
454    
455                    return layoutLocalService.exportLayoutsAsFile(
456                            groupId, privateLayout, layoutIds, parameterMap, startDate,
457                            endDate);
458            }
459    
460            @Override
461            public long exportLayoutsAsFileInBackground(
462                            String taskName, long groupId, boolean privateLayout,
463                            long[] layoutIds, Map<String, String[]> parameterMap,
464                            Date startDate, Date endDate, String fileName)
465                    throws PortalException, SystemException {
466    
467                    GroupPermissionUtil.check(
468                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
469    
470                    return layoutLocalService.exportLayoutsAsFileInBackground(
471                            getUserId(), taskName, groupId, privateLayout, layoutIds,
472                            parameterMap, startDate, endDate, fileName);
473            }
474    
475            /**
476             * Exports the portlet information (categories, permissions, ... etc.) as a
477             * byte array.
478             *
479             * @param  plid the primary key of the layout
480             * @param  groupId the primary key of the group
481             * @param  portletId the primary key of the portlet
482             * @param  parameterMap the mapping of parameters indicating which
483             *         information to export. For information on the keys used in the
484             *         map see {@link
485             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
486             * @param  startDate the export's start date
487             * @param  endDate the export's end date
488             * @return the portlet information as a byte array
489             * @throws PortalException if a layout, group, or portlet with the primary
490             *         key could not be found, if the group did not have permission to
491             *         manage the layouts involved, or if some other portal exception
492             *         occurred
493             * @throws SystemException if a system exception occurred
494             */
495            @Override
496            public byte[] exportPortletInfo(
497                            long plid, long groupId, String portletId,
498                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
499                    throws PortalException, SystemException {
500    
501                    Layout layout = layoutLocalService.getLayout(plid);
502    
503                    GroupPermissionUtil.check(
504                            getPermissionChecker(), layout.getGroupId(),
505                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
506    
507                    return layoutLocalService.exportPortletInfo(
508                            plid, groupId, portletId, parameterMap, startDate, endDate);
509            }
510    
511            @Override
512            public byte[] exportPortletInfo(
513                            long companyId, String portletId,
514                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
515                    throws PortalException, SystemException {
516    
517                    Group companyGroup = groupLocalService.getCompanyGroup(companyId);
518    
519                    GroupPermissionUtil.check(
520                            getPermissionChecker(), companyGroup.getGroupId(),
521                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
522    
523                    return layoutLocalService.exportPortletInfo(
524                            companyId, portletId, parameterMap, startDate, endDate);
525            }
526    
527            /**
528             * Exports the portlet information (categories, permissions, ... etc.) as a
529             * file.
530             *
531             * @param  plid the primary key of the layout
532             * @param  groupId the primary key of the group
533             * @param  portletId the primary key of the portlet
534             * @param  parameterMap the mapping of parameters indicating which
535             *         information to export. For information on the keys used in the
536             *         map see {@link
537             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
538             * @param  startDate the export's start date
539             * @param  endDate the export's end date
540             * @return the portlet information as a file
541             * @throws PortalException if a layout, group, or portlet with the primary
542             *         key could not be found, it the group did not have permission to
543             *         manage the layouts involved, or if some other portal exception
544             *         occurred
545             * @throws SystemException if a system exception occurred
546             */
547            @Override
548            public File exportPortletInfoAsFile(
549                            long plid, long groupId, String portletId,
550                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
551                    throws PortalException, SystemException {
552    
553                    Layout layout = layoutLocalService.getLayout(plid);
554    
555                    GroupPermissionUtil.check(
556                            getPermissionChecker(), layout.getGroupId(),
557                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
558    
559                    return layoutLocalService.exportPortletInfoAsFile(
560                            plid, groupId, portletId, parameterMap, startDate, endDate);
561            }
562    
563            @Override
564            public File exportPortletInfoAsFile(
565                            String portletId, Map<String, String[]> parameterMap,
566                            Date startDate, Date endDate)
567                    throws PortalException, SystemException {
568    
569                    User user = userPersistence.findByPrimaryKey(getUserId());
570    
571                    Group companyGroup = groupLocalService.getCompanyGroup(
572                            user.getCompanyId());
573    
574                    GroupPermissionUtil.check(
575                            getPermissionChecker(), companyGroup.getGroupId(),
576                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
577    
578                    return layoutLocalService.exportPortletInfoAsFile(
579                            user.getCompanyId(), portletId, parameterMap, startDate, endDate);
580            }
581    
582            @Override
583            public long exportPortletInfoAsFileInBackground(
584                            String taskName, long plid, long groupId, String portletId,
585                            Map<String, String[]> parameterMap, Date startDate, Date endDate,
586                            String fileName)
587                    throws PortalException, SystemException {
588    
589                    Layout layout = layoutLocalService.getLayout(plid);
590    
591                    GroupPermissionUtil.check(
592                            getPermissionChecker(), layout.getGroupId(),
593                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
594    
595                    return layoutLocalService.exportPortletInfoAsFileInBackground(
596                            getUserId(), taskName, plid, groupId, portletId, parameterMap,
597                            startDate, endDate, fileName);
598            }
599    
600            @Override
601            public long exportPortletInfoAsFileInBackground(
602                            String taskName, String portletId,
603                            Map<String, String[]> parameterMap, Date startDate, Date endDate,
604                            String fileName)
605                    throws PortalException, SystemException {
606    
607                    User user = userPersistence.findByPrimaryKey(getUserId());
608    
609                    Group companyGroup = groupLocalService.getCompanyGroup(
610                            user.getCompanyId());
611    
612                    GroupPermissionUtil.check(
613                            getPermissionChecker(), companyGroup.getGroupId(),
614                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
615    
616                    return layoutLocalService.exportPortletInfoAsFileInBackground(
617                            getUserId(), taskName, portletId, parameterMap, startDate, endDate,
618                            fileName);
619            }
620    
621            /**
622             * Returns all the ancestor layouts of the layout.
623             *
624             * @param  plid the primary key of the layout
625             * @return the ancestor layouts of the layout
626             * @throws PortalException if a matching layout could not be found or if a
627             *         portal exception occurred
628             * @throws SystemException if a system exception occurred
629             */
630            @Override
631            public List<Layout> getAncestorLayouts(long plid)
632                    throws PortalException, SystemException {
633    
634                    Layout layout = layoutLocalService.getLayout(plid);
635    
636                    List<Layout> ancestors = layout.getAncestors();
637    
638                    return filterLayouts(ancestors);
639            }
640    
641            /**
642             * Returns the primary key of the default layout for the group.
643             *
644             * @param  groupId the primary key of the group
645             * @param  scopeGroupId the primary key of the scope group. See {@link
646             *         com.liferay.portal.service.ServiceContext#getScopeGroupId()}.
647             * @param  privateLayout whether the layout is private to the group
648             * @param  portletId the primary key of the portlet
649             * @return Returns the primary key of the default layout group; {@link
650             *         com.liferay.portal.model.LayoutConstants#DEFAULT_PLID} otherwise
651             * @throws PortalException if a group, layout, or portlet with the primary
652             *         key could not be found
653             * @throws SystemException if a system exception occurred
654             */
655            @Override
656            public long getDefaultPlid(
657                            long groupId, long scopeGroupId, boolean privateLayout,
658                            String portletId)
659                    throws PortalException, SystemException {
660    
661                    if (groupId <= 0) {
662                            return LayoutConstants.DEFAULT_PLID;
663                    }
664    
665                    PermissionChecker permissionChecker = getPermissionChecker();
666    
667                    String scopeGroupLayoutUuid = null;
668    
669                    Group scopeGroup = groupLocalService.getGroup(scopeGroupId);
670    
671                    if (scopeGroup.isLayout()) {
672                            Layout scopeGroupLayout = layoutLocalService.getLayout(
673                                    scopeGroup.getClassPK());
674    
675                            scopeGroupLayoutUuid = scopeGroupLayout.getUuid();
676                    }
677    
678                    Map<Long, javax.portlet.PortletPreferences> jxPortletPreferencesMap =
679                            PortletPreferencesFactoryUtil.getPortletSetupMap(
680                                    scopeGroup.getCompanyId(), groupId,
681                                    PortletKeys.PREFS_OWNER_ID_DEFAULT,
682                                    PortletKeys.PREFS_OWNER_TYPE_LAYOUT, portletId, privateLayout);
683    
684                    for (Map.Entry<Long, javax.portlet.PortletPreferences> entry :
685                                    jxPortletPreferencesMap.entrySet()) {
686    
687                            long plid = entry.getKey();
688    
689                            Layout layout = null;
690    
691                            try {
692                                    layout = layoutLocalService.getLayout(plid);
693                            }
694                            catch (NoSuchLayoutException nsle) {
695                                    continue;
696                            }
697    
698                            if (!LayoutPermissionUtil.contains(
699                                            permissionChecker, layout, ActionKeys.VIEW)) {
700    
701                                    continue;
702                            }
703    
704                            if (!layout.isTypePortlet()) {
705                                    continue;
706                            }
707    
708                            LayoutTypePortlet layoutTypePortlet =
709                                    (LayoutTypePortlet)layout.getLayoutType();
710    
711                            if (!layoutTypePortlet.hasPortletId(portletId)) {
712                                    continue;
713                            }
714    
715                            javax.portlet.PortletPreferences jxPortletPreferences =
716                                    entry.getValue();
717    
718                            String scopeType = GetterUtil.getString(
719                                    jxPortletPreferences.getValue("lfrScopeType", null));
720    
721                            if (scopeGroup.isLayout()) {
722                                    String scopeLayoutUuid = GetterUtil.getString(
723                                            jxPortletPreferences.getValue("lfrScopeLayoutUuid", null));
724    
725                                    if (Validator.isNotNull(scopeType) &&
726                                            Validator.isNotNull(scopeLayoutUuid) &&
727                                            scopeLayoutUuid.equals(scopeGroupLayoutUuid)) {
728    
729                                            return layout.getPlid();
730                                    }
731                            }
732                            else if (scopeGroup.isCompany()) {
733                                    if (Validator.isNotNull(scopeType) &&
734                                            scopeType.equals("company")) {
735    
736                                            return layout.getPlid();
737                                    }
738                            }
739                            else {
740                                    if (Validator.isNull(scopeType)) {
741                                            return layout.getPlid();
742                                    }
743                            }
744                    }
745    
746                    return LayoutConstants.DEFAULT_PLID;
747            }
748    
749            @Override
750            @ThreadLocalCachable
751            public long getDefaultPlid(
752                            long groupId, long scopeGroupId, String portletId)
753                    throws PortalException, SystemException {
754    
755                    long plid = getDefaultPlid(groupId, scopeGroupId, false, portletId);
756    
757                    if (plid == 0) {
758                            plid = getDefaultPlid(groupId, scopeGroupId, true, portletId);
759                    }
760    
761                    return plid;
762            }
763    
764            /**
765             * Returns the layout matching the UUID, group, and privacy.
766             *
767             * @param  uuid the layout's UUID
768             * @param  groupId the primary key of the group
769             * @param  privateLayout whether the layout is private to the group
770             * @return the matching layout
771             * @throws PortalException if a matching layout could not be found, if the
772             *         user did not have permission to view the layout, or if some other
773             *         portal exception occurred
774             * @throws SystemException if a system exception occurred
775             */
776            @Override
777            public Layout getLayoutByUuidAndGroupId(
778                            String uuid, long groupId, boolean privateLayout)
779                    throws PortalException, SystemException {
780    
781                    Layout layout = layoutLocalService.getLayoutByUuidAndGroupId(
782                            uuid, groupId, privateLayout);
783    
784                    LayoutPermissionUtil.check(
785                            getPermissionChecker(), layout, ActionKeys.VIEW);
786    
787                    return layout;
788            }
789    
790            /**
791             * Returns the name of the layout.
792             *
793             * @param  groupId the primary key of the group
794             * @param  privateLayout whether the layout is private to the group
795             * @param  layoutId the primary key of the layout
796             * @param  languageId the primary key of the language. For more information
797             *         See {@link java.util.Locale}.
798             * @return the layout's name
799             * @throws PortalException if a matching layout could not be found
800             * @throws SystemException if a system exception occurred
801             */
802            @Override
803            public String getLayoutName(
804                            long groupId, boolean privateLayout, long layoutId,
805                            String languageId)
806                    throws PortalException, SystemException {
807    
808                    Layout layout = layoutLocalService.getLayout(
809                            groupId, privateLayout, layoutId);
810    
811                    return layout.getName(languageId);
812            }
813    
814            /**
815             * Returns the layout references for all the layouts that belong to the
816             * company and belong to the portlet that matches the preferences.
817             *
818             * @param  companyId the primary key of the company
819             * @param  portletId the primary key of the portlet
820             * @param  preferencesKey the portlet's preference key
821             * @param  preferencesValue the portlet's preference value
822             * @return the layout references of the matching layouts
823             * @throws SystemException if a system exception occurred
824             */
825            @Override
826            public LayoutReference[] getLayoutReferences(
827                            long companyId, String portletId, String preferencesKey,
828                            String preferencesValue)
829                    throws SystemException {
830    
831                    return layoutLocalService.getLayouts(
832                            companyId, portletId, preferencesKey, preferencesValue);
833            }
834    
835            @Override
836            public List<Layout> getLayouts(long groupId, boolean privateLayout)
837                    throws SystemException {
838    
839                    return layoutPersistence.filterFindByG_P(groupId, privateLayout);
840            }
841    
842            @Override
843            public List<Layout> getLayouts(
844                            long groupId, boolean privateLayout, long parentLayoutId)
845                    throws SystemException {
846    
847                    return layoutPersistence.filterFindByG_P_P(
848                            groupId, privateLayout, parentLayoutId);
849            }
850    
851            @Override
852            public List<Layout> getLayouts(
853                            long groupId, boolean privateLayout, long parentLayoutId,
854                            boolean incomplete, int start, int end)
855                    throws SystemException {
856    
857                    return layoutPersistence.filterFindByG_P_P(
858                            groupId, privateLayout, parentLayoutId, start, end);
859            }
860    
861            @Override
862            public int getLayoutsCount(
863                            long groupId, boolean privateLayout, long parentLayoutId)
864                    throws SystemException {
865    
866                    return layoutPersistence.filterCountByG_P_P(
867                            groupId, privateLayout, parentLayoutId);
868            }
869    
870            @Override
871            public String[] getTempFileEntryNames(long groupId, String tempFolderName)
872                    throws PortalException, SystemException {
873    
874                    GroupPermissionUtil.check(
875                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
876    
877                    return TempFileUtil.getTempFileEntryNames(
878                            groupId, getUserId(),
879                            DigesterUtil.digestHex(Digester.SHA_256, tempFolderName));
880            }
881    
882            /**
883             * Imports the layouts from the byte array.
884             *
885             * @param  groupId the primary key of the group
886             * @param  privateLayout whether the layout is private to the group
887             * @param  parameterMap the mapping of parameters indicating which
888             *         information will be imported. For information on the keys used in
889             *         the map see {@link
890             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
891             * @param  bytes the byte array with the data
892             * @throws PortalException if a group with the primary key could not be
893             *         found, if the group did not have permission to manage the
894             *         layouts, or if some other portal exception occurred
895             * @throws SystemException if a system exception occurred
896             * @see    com.liferay.portal.lar.LayoutImporter
897             */
898            @Override
899            public void importLayouts(
900                            long groupId, boolean privateLayout,
901                            Map<String, String[]> parameterMap, byte[] bytes)
902                    throws PortalException, SystemException {
903    
904                    GroupPermissionUtil.check(
905                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
906    
907                    layoutLocalService.importLayouts(
908                            getUserId(), groupId, privateLayout, parameterMap, bytes);
909            }
910    
911            /**
912             * Imports the layouts from the file.
913             *
914             * @param  groupId the primary key of the group
915             * @param  privateLayout whether the layout is private to the group
916             * @param  parameterMap the mapping of parameters indicating which
917             *         information will be imported. For information on the keys used in
918             *         the map see {@link
919             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
920             * @param  file the LAR file with the data
921             * @throws PortalException if a group with the primary key could not be
922             *         found, if the group did not have permission to manage the layouts
923             *         and publish, or if some other portal exception occurred
924             * @throws SystemException if a system exception occurred
925             * @see    com.liferay.portal.lar.LayoutImporter
926             */
927            @Override
928            public void importLayouts(
929                            long groupId, boolean privateLayout,
930                            Map<String, String[]> parameterMap, File file)
931                    throws PortalException, SystemException {
932    
933                    GroupPermissionUtil.check(
934                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
935    
936                    layoutLocalService.importLayouts(
937                            getUserId(), groupId, privateLayout, parameterMap, file);
938            }
939    
940            /**
941             * Imports the layouts from the input stream.
942             *
943             * @param  groupId the primary key of the group
944             * @param  privateLayout whether the layout is private to the group
945             * @param  parameterMap the mapping of parameters indicating which
946             *         information will be imported. For information on the keys used in
947             *         the map see {@link
948             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
949             * @param  is the input stream
950             * @throws PortalException if a group with the primary key could not be
951             *         found, if the group did not have permission to manage the
952             *         layouts, or if some other portal exception occurred
953             * @throws SystemException if a system exception occurred
954             * @see    com.liferay.portal.lar.LayoutImporter
955             */
956            @Override
957            public void importLayouts(
958                            long groupId, boolean privateLayout,
959                            Map<String, String[]> parameterMap, InputStream is)
960                    throws PortalException, SystemException {
961    
962                    GroupPermissionUtil.check(
963                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
964    
965                    layoutLocalService.importLayouts(
966                            getUserId(), groupId, privateLayout, parameterMap, is);
967            }
968    
969            @Override
970            public long importLayoutsInBackground(
971                            String taskName, long groupId, boolean privateLayout,
972                            Map<String, String[]> parameterMap, File file)
973                    throws PortalException, SystemException {
974    
975                    GroupPermissionUtil.check(
976                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
977    
978                    return layoutLocalService.importLayoutsInBackground(
979                            getUserId(), taskName, groupId, privateLayout, parameterMap, file);
980            }
981    
982            @Override
983            public long importLayoutsInBackground(
984                            String taskName, long groupId, boolean privateLayout,
985                            Map<String, String[]> parameterMap, InputStream inputStream)
986                    throws PortalException, SystemException {
987    
988                    GroupPermissionUtil.check(
989                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
990    
991                    return layoutLocalService.importLayoutsInBackground(
992                            getUserId(), taskName, groupId, privateLayout, parameterMap,
993                            inputStream);
994            }
995    
996            /**
997             * Imports the portlet information (categories, permissions, ... etc.) from
998             * the file.
999             *
1000             * @param  plid the primary key of the layout
1001             * @param  groupId the primary key of the group
1002             * @param  portletId the primary key of the portlet
1003             * @param  parameterMap the mapping of parameters indicating which
1004             *         information will be imported. For information on the keys used in
1005             *         the map see {@link
1006             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
1007             * @param  file the LAR file with the data
1008             * @throws PortalException if a group, layout, or portlet with the primary
1009             *         key could not be found, or if the group did not have permission
1010             *         to manage the layouts
1011             * @throws SystemException if a system exception occurred
1012             */
1013            @Override
1014            public void importPortletInfo(
1015                            long plid, long groupId, String portletId,
1016                            Map<String, String[]> parameterMap, File file)
1017                    throws PortalException, SystemException {
1018    
1019                    GroupPermissionUtil.check(
1020                            getPermissionChecker(), groupId,
1021                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1022    
1023                    layoutLocalService.importPortletInfo(
1024                            getUserId(), plid, groupId, portletId, parameterMap, file);
1025            }
1026    
1027            /**
1028             * Imports the portlet information (categories, permissions, ... etc.) from
1029             * the input stream.
1030             *
1031             * @param  plid the primary key of the layout
1032             * @param  groupId the primary key of the group
1033             * @param  portletId the primary key of the portlet
1034             * @param  parameterMap the mapping of parameters indicating which
1035             *         information will be imported. For information on the keys used in
1036             *         the map see {@link
1037             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
1038             * @param  is the input stream
1039             * @throws PortalException if a group, portlet, or layout with the primary
1040             *         key could not be found or if the group did not have permission to
1041             *         manage the layouts
1042             * @throws SystemException if a system exception occurred
1043             */
1044            @Override
1045            public void importPortletInfo(
1046                            long plid, long groupId, String portletId,
1047                            Map<String, String[]> parameterMap, InputStream is)
1048                    throws PortalException, SystemException {
1049    
1050                    GroupPermissionUtil.check(
1051                            getPermissionChecker(), groupId,
1052                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1053    
1054                    layoutLocalService.importPortletInfo(
1055                            getUserId(), plid, groupId, portletId, parameterMap, is);
1056            }
1057    
1058            @Override
1059            public void importPortletInfo(
1060                            String portletId, Map<String, String[]> parameterMap, File file)
1061                    throws PortalException, SystemException {
1062    
1063                    User user = userPersistence.findByPrimaryKey(getUserId());
1064    
1065                    Group companyGroup = groupLocalService.getCompanyGroup(
1066                            user.getCompanyId());
1067    
1068                    GroupPermissionUtil.check(
1069                            getPermissionChecker(), companyGroup.getGroupId(),
1070                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1071    
1072                    layoutLocalService.importPortletInfo(
1073                            getUserId(), portletId, parameterMap, file);
1074            }
1075    
1076            @Override
1077            public void importPortletInfo(
1078                            String portletId, Map<String, String[]> parameterMap,
1079                            InputStream is)
1080                    throws PortalException, SystemException {
1081    
1082                    User user = userPersistence.findByPrimaryKey(getUserId());
1083    
1084                    Group companyGroup = groupLocalService.getCompanyGroup(
1085                            user.getCompanyId());
1086    
1087                    GroupPermissionUtil.check(
1088                            getPermissionChecker(), companyGroup.getGroupId(),
1089                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1090    
1091                    layoutLocalService.importPortletInfo(
1092                            getUserId(), portletId, parameterMap, is);
1093            }
1094    
1095            @Override
1096            public long importPortletInfoInBackground(
1097                            String taskName, long plid, long groupId, String portletId,
1098                            Map<String, String[]> parameterMap, File file)
1099                    throws PortalException, SystemException {
1100    
1101                    GroupPermissionUtil.check(
1102                            getPermissionChecker(), groupId,
1103                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1104    
1105                    return layoutLocalService.importPortletInfoInBackground(
1106                            getUserId(), taskName, plid, groupId, portletId, parameterMap,
1107                            file);
1108            }
1109    
1110            @Override
1111            public long importPortletInfoInBackground(
1112                            String taskName, long plid, long groupId, String portletId,
1113                            Map<String, String[]> parameterMap, InputStream is)
1114                    throws PortalException, SystemException {
1115    
1116                    GroupPermissionUtil.check(
1117                            getPermissionChecker(), groupId,
1118                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1119    
1120                    return layoutLocalService.importPortletInfoInBackground(
1121                            getUserId(), taskName, plid, groupId, portletId, parameterMap, is);
1122            }
1123    
1124            @Override
1125            public void importPortletInfoInBackground(
1126                            String taskName, String portletId,
1127                            Map<String, String[]> parameterMap, File file)
1128                    throws PortalException, SystemException {
1129    
1130                    User user = userPersistence.findByPrimaryKey(getUserId());
1131    
1132                    Group companyGroup = groupLocalService.getCompanyGroup(
1133                            user.getCompanyId());
1134    
1135                    GroupPermissionUtil.check(
1136                            getPermissionChecker(), companyGroup.getGroupId(),
1137                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1138    
1139                    layoutLocalService.importPortletInfoInBackground(
1140                            getUserId(), taskName, portletId, parameterMap, file);
1141            }
1142    
1143            @Override
1144            public void importPortletInfoInBackground(
1145                            String taskName, String portletId,
1146                            Map<String, String[]> parameterMap, InputStream is)
1147                    throws PortalException, SystemException {
1148    
1149                    User user = userPersistence.findByPrimaryKey(getUserId());
1150    
1151                    Group companyGroup = groupLocalService.getCompanyGroup(
1152                            user.getCompanyId());
1153    
1154                    GroupPermissionUtil.check(
1155                            getPermissionChecker(), companyGroup.getGroupId(),
1156                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1157    
1158                    layoutLocalService.importPortletInfoInBackground(
1159                            getUserId(), taskName, portletId, parameterMap, is);
1160            }
1161    
1162            /**
1163             * Schedules a range of layouts to be published.
1164             *
1165             * @param  sourceGroupId the primary key of the source group
1166             * @param  targetGroupId the primary key of the target group
1167             * @param  privateLayout whether the layout is private to the group
1168             * @param  layoutIdMap the layouts considered for publishing, specified by
1169             *         the layout IDs and booleans indicating whether they have children
1170             * @param  parameterMap the mapping of parameters indicating which
1171             *         information will be used. See {@link
1172             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}
1173             * @param  scope the scope of the pages. It can be <code>all-pages</code> or
1174             *         <code>selected-pages</code>.
1175             * @param  startDate the start date
1176             * @param  endDate the end date
1177             * @param  groupName the group name (optionally {@link
1178             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1179             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1180             * @param  cronText the cron text. See {@link
1181             *         com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1182             * @param  schedulerStartDate the scheduler start date
1183             * @param  schedulerEndDate the scheduler end date
1184             * @param  description the scheduler description
1185             * @throws PortalException if the group did not have permission to manage
1186             *         and publish
1187             * @throws SystemException if a system exception occurred
1188             */
1189            @Override
1190            public void schedulePublishToLive(
1191                            long sourceGroupId, long targetGroupId, boolean privateLayout,
1192                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1193                            String scope, Date startDate, Date endDate, String groupName,
1194                            String cronText, Date schedulerStartDate, Date schedulerEndDate,
1195                            String description)
1196                    throws PortalException, SystemException {
1197    
1198                    GroupPermissionUtil.check(
1199                            getPermissionChecker(), targetGroupId, ActionKeys.PUBLISH_STAGING);
1200    
1201                    String jobName = PortalUUIDUtil.generate();
1202    
1203                    Trigger trigger = new CronTrigger(
1204                            jobName, groupName, schedulerStartDate, schedulerEndDate, cronText);
1205    
1206                    String command = StringPool.BLANK;
1207    
1208                    if (scope.equals("all-pages")) {
1209                            command = LayoutsLocalPublisherRequest.COMMAND_ALL_PAGES;
1210                    }
1211                    else if (scope.equals("selected-pages")) {
1212                            command = LayoutsLocalPublisherRequest.COMMAND_SELECTED_PAGES;
1213                    }
1214    
1215                    LayoutsLocalPublisherRequest publisherRequest =
1216                            new LayoutsLocalPublisherRequest(
1217                                    command, getUserId(), sourceGroupId, targetGroupId,
1218                                    privateLayout, layoutIdMap, parameterMap, startDate, endDate);
1219    
1220                    SchedulerEngineHelperUtil.schedule(
1221                            trigger, StorageType.PERSISTED, description,
1222                            DestinationNames.LAYOUTS_LOCAL_PUBLISHER, publisherRequest, 0);
1223            }
1224    
1225            /**
1226             * Schedules a range of layouts to be stored.
1227             *
1228             * @param  sourceGroupId the primary key of the source group
1229             * @param  privateLayout whether the layout is private to the group
1230             * @param  layoutIdMap the layouts considered for publishing, specified by
1231             *         the layout IDs and booleans indicating whether they have children
1232             * @param  parameterMap the mapping of parameters indicating which
1233             *         information will be used. See {@link
1234             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}
1235             * @param  remoteAddress the remote address
1236             * @param  remotePort the remote port
1237             * @param  remotePathContext the remote path context
1238             * @param  secureConnection whether the connection is secure
1239             * @param  remoteGroupId the primary key of the remote group
1240             * @param  remotePrivateLayout whether remote group's layout is private
1241             * @param  startDate the start date
1242             * @param  endDate the end date
1243             * @param  groupName the group name. Optionally {@link
1244             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1245             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1246             * @param  cronText the cron text. See {@link
1247             *         com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1248             * @param  schedulerStartDate the scheduler start date
1249             * @param  schedulerEndDate the scheduler end date
1250             * @param  description the scheduler description
1251             * @throws PortalException if a group with the source group primary key was
1252             *         not found or if the group did not have permission to publish
1253             * @throws SystemException if a system exception occurred
1254             */
1255            @Override
1256            public void schedulePublishToRemote(
1257                            long sourceGroupId, boolean privateLayout,
1258                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1259                            String remoteAddress, int remotePort, String remotePathContext,
1260                            boolean secureConnection, long remoteGroupId,
1261                            boolean remotePrivateLayout, Date startDate, Date endDate,
1262                            String groupName, String cronText, Date schedulerStartDate,
1263                            Date schedulerEndDate, String description)
1264                    throws PortalException, SystemException {
1265    
1266                    GroupPermissionUtil.check(
1267                            getPermissionChecker(), sourceGroupId, ActionKeys.PUBLISH_STAGING);
1268    
1269                    LayoutsRemotePublisherRequest publisherRequest =
1270                            new LayoutsRemotePublisherRequest(
1271                                    getUserId(), sourceGroupId, privateLayout, layoutIdMap,
1272                                    parameterMap, remoteAddress, remotePort, remotePathContext,
1273                                    secureConnection, remoteGroupId, remotePrivateLayout, startDate,
1274                                    endDate);
1275    
1276                    String jobName = PortalUUIDUtil.generate();
1277    
1278                    Trigger trigger = new CronTrigger(
1279                            jobName, groupName, schedulerStartDate, schedulerEndDate, cronText);
1280    
1281                    SchedulerEngineHelperUtil.schedule(
1282                            trigger, StorageType.PERSISTED, description,
1283                            DestinationNames.LAYOUTS_REMOTE_PUBLISHER, publisherRequest, 0);
1284            }
1285    
1286            /**
1287             * Sets the layouts for the group, replacing and prioritizing all layouts of
1288             * the parent layout.
1289             *
1290             * @param  groupId the primary key of the group
1291             * @param  privateLayout whether the layout is private to the group
1292             * @param  parentLayoutId the primary key of the parent layout
1293             * @param  layoutIds the primary keys of the layouts
1294             * @param  serviceContext the service context to be applied
1295             * @throws PortalException if a group or layout with the primary key could
1296             *         not be found, if the group did not have permission to manage the
1297             *         layouts, if no layouts were specified, if the first layout was
1298             *         not page-able, if the first layout was hidden, or if some other
1299             *         portal exception occurred
1300             * @throws SystemException if a system exception occurred
1301             */
1302            @Override
1303            public void setLayouts(
1304                            long groupId, boolean privateLayout, long parentLayoutId,
1305                            long[] layoutIds, ServiceContext serviceContext)
1306                    throws PortalException, SystemException {
1307    
1308                    GroupPermissionUtil.check(
1309                            getPermissionChecker(), groupId, ActionKeys.UPDATE);
1310    
1311                    layoutLocalService.setLayouts(
1312                            groupId, privateLayout, parentLayoutId, layoutIds, serviceContext);
1313            }
1314    
1315            /**
1316             * Deletes the job from the scheduler's queue.
1317             *
1318             * @param  groupId the primary key of the group
1319             * @param  jobName the job name
1320             * @param  groupName the group name (optionally {@link
1321             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1322             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1323             * @throws PortalException if the group did not permission to manage staging
1324             *         and publish
1325             * @throws SystemException if a system exception occurred
1326             */
1327            @Override
1328            public void unschedulePublishToLive(
1329                            long groupId, String jobName, String groupName)
1330                    throws PortalException, SystemException {
1331    
1332                    GroupPermissionUtil.check(
1333                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1334    
1335                    SchedulerEngineHelperUtil.delete(
1336                            jobName, groupName, StorageType.PERSISTED);
1337            }
1338    
1339            /**
1340             * Deletes the job from the scheduler's persistent queue.
1341             *
1342             * @param  groupId the primary key of the group
1343             * @param  jobName the job name
1344             * @param  groupName the group name (optionally {@link
1345             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1346             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1347             * @throws PortalException if a group with the primary key could not be
1348             *         found or if the group did not have permission to publish
1349             * @throws SystemException if a system exception occurred
1350             */
1351            @Override
1352            public void unschedulePublishToRemote(
1353                            long groupId, String jobName, String groupName)
1354                    throws PortalException, SystemException {
1355    
1356                    GroupPermissionUtil.check(
1357                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1358    
1359                    SchedulerEngineHelperUtil.delete(
1360                            jobName, groupName, StorageType.PERSISTED);
1361            }
1362    
1363            /**
1364             * Updates the layout with additional parameters.
1365             *
1366             * @param  groupId the primary key of the group
1367             * @param  privateLayout whether the layout is private to the group
1368             * @param  layoutId the primary key of the layout
1369             * @param  parentLayoutId the primary key of the layout's new parent layout
1370             * @param  localeNamesMap the layout's locales and localized names
1371             * @param  localeTitlesMap the layout's locales and localized titles
1372             * @param  descriptionMap the locales and localized descriptions to merge
1373             *         (optionally <code>null</code>)
1374             * @param  keywordsMap the locales and localized keywords to merge
1375             *         (optionally <code>null</code>)
1376             * @param  robotsMap the locales and localized robots to merge (optionally
1377             *         <code>null</code>)
1378             * @param  type the layout's new type (optionally {@link
1379             *         com.liferay.portal.model.LayoutConstants#TYPE_PORTLET})
1380             * @param  hidden whether the layout is hidden
1381             * @param  friendlyURLMap the layout's locales and localized friendly URLs.
1382             *         To see how the URL is normalized when accessed see {@link
1383             *         com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
1384             *         String)}.
1385             * @param  iconImage whether the icon image will be updated
1386             * @param  iconBytes the byte array of the layout's new icon image
1387             * @param  serviceContext the service context to be applied. Can set the
1388             *         modification date and expando bridge attributes for the layout.
1389             * @return the updated layout
1390             * @throws PortalException if a group or layout with the primary key could
1391             *         not be found, if the user did not have permission to update the
1392             *         layout, if a unique friendly URL could not be generated, if a
1393             *         valid parent layout ID to use could not be found, or if the
1394             *         layout parameters were invalid
1395             * @throws SystemException if a system exception occurred
1396             */
1397            @Override
1398            public Layout updateLayout(
1399                            long groupId, boolean privateLayout, long layoutId,
1400                            long parentLayoutId, Map<Locale, String> localeNamesMap,
1401                            Map<Locale, String> localeTitlesMap,
1402                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
1403                            Map<Locale, String> robotsMap, String type, boolean hidden,
1404                            Map<Locale, String> friendlyURLMap, Boolean iconImage,
1405                            byte[] iconBytes, ServiceContext serviceContext)
1406                    throws PortalException, SystemException {
1407    
1408                    LayoutPermissionUtil.check(
1409                            getPermissionChecker(), groupId, privateLayout, layoutId,
1410                            ActionKeys.UPDATE);
1411    
1412                    return layoutLocalService.updateLayout(
1413                            groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap,
1414                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
1415                            hidden, friendlyURLMap, iconImage, iconBytes, serviceContext);
1416            }
1417    
1418            /**
1419             * Updates the layout with additional parameters.
1420             *
1421             * @param      groupId the primary key of the group
1422             * @param      privateLayout whether the layout is private to the group
1423             * @param      layoutId the primary key of the layout
1424             * @param      parentLayoutId the primary key of the layout's new parent
1425             *             layout
1426             * @param      localeNamesMap the layout's locales and localized names
1427             * @param      localeTitlesMap the layout's locales and localized titles
1428             * @param      descriptionMap the locales and localized descriptions to
1429             *             merge (optionally <code>null</code>)
1430             * @param      keywordsMap the locales and localized keywords to merge
1431             *             (optionally <code>null</code>)
1432             * @param      robotsMap the locales and localized robots to merge
1433             *             (optionally <code>null</code>)
1434             * @param      type the layout's new type (optionally {@link
1435             *             com.liferay.portal.model.LayoutConstants#TYPE_PORTLET})
1436             * @param      hidden whether the layout is hidden
1437             * @param      friendlyURL the layout's locales and new friendly URLs. To
1438             *             see how the URL is normalized when accessed, see {@link
1439             *             com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
1440             *             String)}.
1441             * @param      iconImage whether the icon image will be updated
1442             * @param      iconBytes the byte array of the layout's new icon image
1443             * @param      serviceContext the service context to be applied. Can set the
1444             *             modification date and expando bridge attributes for the
1445             *             layout.
1446             * @return     the updated layout
1447             * @throws     PortalException if a group or layout with the primary key
1448             *             could not be found, if the user did not have permission to
1449             *             update the layout, if a unique friendly URL could not be
1450             *             generated, if a valid parent layout ID to use could not be
1451             *             found, or if the layout parameters were invalid
1452             * @throws     SystemException if a system exception occurred
1453             * @deprecated As of 6.2.0, replaced by {@link #updateLayout(long, boolean,
1454             *             long, long, Map, Map, Map, Map, Map, String, boolean, Map,
1455             *             Boolean, byte[], ServiceContext)}
1456             */
1457            @Override
1458            public Layout updateLayout(
1459                            long groupId, boolean privateLayout, long layoutId,
1460                            long parentLayoutId, Map<Locale, String> localeNamesMap,
1461                            Map<Locale, String> localeTitlesMap,
1462                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
1463                            Map<Locale, String> robotsMap, String type, boolean hidden,
1464                            String friendlyURL, Boolean iconImage, byte[] iconBytes,
1465                            ServiceContext serviceContext)
1466                    throws PortalException, SystemException {
1467    
1468                    LayoutPermissionUtil.check(
1469                            getPermissionChecker(), groupId, privateLayout, layoutId,
1470                            ActionKeys.UPDATE);
1471    
1472                    return layoutLocalService.updateLayout(
1473                            groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap,
1474                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
1475                            hidden, friendlyURL, iconImage, iconBytes, serviceContext);
1476            }
1477    
1478            /**
1479             * Updates the layout replacing its type settings.
1480             *
1481             * @param  groupId the primary key of the group
1482             * @param  privateLayout whether the layout is private to the group
1483             * @param  layoutId the primary key of the layout
1484             * @param  typeSettings the settings to load the unicode properties object.
1485             *         See {@link com.liferay.portal.kernel.util.UnicodeProperties
1486             *         #fastLoad(String)}.
1487             * @return the updated layout
1488             * @throws PortalException if a matching layout could not be found or if the
1489             *         user did not have permission to update the layout
1490             * @throws SystemException if a system exception occurred
1491             */
1492            @Override
1493            public Layout updateLayout(
1494                            long groupId, boolean privateLayout, long layoutId,
1495                            String typeSettings)
1496                    throws PortalException, SystemException {
1497    
1498                    LayoutPermissionUtil.check(
1499                            getPermissionChecker(), groupId, privateLayout, layoutId,
1500                            ActionKeys.UPDATE);
1501    
1502                    return layoutLocalService.updateLayout(
1503                            groupId, privateLayout, layoutId, typeSettings);
1504            }
1505    
1506            /**
1507             * Updates the look and feel of the layout.
1508             *
1509             * @param  groupId the primary key of the group
1510             * @param  privateLayout whether the layout is private to the group
1511             * @param  layoutId the primary key of the layout
1512             * @param  themeId the primary key of the layout's new theme
1513             * @param  colorSchemeId the primary key of the layout's new color scheme
1514             * @param  css the layout's new CSS
1515             * @param  wapTheme whether the theme is for WAP browsers
1516             * @return the updated layout
1517             * @throws PortalException if a matching layout could not be found, or if
1518             *         the user did not have permission to update the layout and
1519             *         permission to apply the theme
1520             * @throws SystemException if a system exception occurred
1521             */
1522            @Override
1523            public Layout updateLookAndFeel(
1524                            long groupId, boolean privateLayout, long layoutId, String themeId,
1525                            String colorSchemeId, String css, boolean wapTheme)
1526                    throws PortalException, SystemException {
1527    
1528                    LayoutPermissionUtil.check(
1529                            getPermissionChecker(), groupId, privateLayout, layoutId,
1530                            ActionKeys.UPDATE);
1531    
1532                    if (Validator.isNotNull(themeId)) {
1533                            pluginSettingLocalService.checkPermission(
1534                                    getUserId(), themeId, Plugin.TYPE_THEME);
1535                    }
1536    
1537                    return layoutLocalService.updateLookAndFeel(
1538                            groupId, privateLayout, layoutId, themeId, colorSchemeId, css,
1539                            wapTheme);
1540            }
1541    
1542            /**
1543             * Updates the name of the layout matching the group, layout ID, and
1544             * privacy.
1545             *
1546             * @param  groupId the primary key of the group
1547             * @param  privateLayout whether the layout is private to the group
1548             * @param  layoutId the primary key of the layout
1549             * @param  name the layout's new name
1550             * @param  languageId the primary key of the language. For more information
1551             *         see {@link java.util.Locale}.
1552             * @return the updated layout
1553             * @throws PortalException if a matching layout could not be found, if the
1554             *         user did not have permission to update the layout, or if the new
1555             *         name was <code>null</code>
1556             * @throws SystemException if a system exception occurred
1557             */
1558            @Override
1559            public Layout updateName(
1560                            long groupId, boolean privateLayout, long layoutId, String name,
1561                            String languageId)
1562                    throws PortalException, SystemException {
1563    
1564                    LayoutPermissionUtil.check(
1565                            getPermissionChecker(), groupId, privateLayout, layoutId,
1566                            ActionKeys.UPDATE);
1567    
1568                    return layoutLocalService.updateName(
1569                            groupId, privateLayout, layoutId, name, languageId);
1570            }
1571    
1572            /**
1573             * Updates the name of the layout matching the primary key.
1574             *
1575             * @param  plid the primary key of the layout
1576             * @param  name the name to be assigned
1577             * @param  languageId the primary key of the language. For more information
1578             *         see {@link java.util.Locale}.
1579             * @return the updated layout
1580             * @throws PortalException if a layout with the primary key could not be
1581             *         found, or if the user did not have permission to update the
1582             *         layout, or if the name was <code>null</code>
1583             * @throws SystemException if a system exception occurred
1584             */
1585            @Override
1586            public Layout updateName(long plid, String name, String languageId)
1587                    throws PortalException, SystemException {
1588    
1589                    LayoutPermissionUtil.check(
1590                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1591    
1592                    return layoutLocalService.updateName(plid, name, languageId);
1593            }
1594    
1595            /**
1596             * Updates the parent layout ID of the layout matching the group, layout ID,
1597             * and privacy.
1598             *
1599             * @param  groupId the primary key of the group
1600             * @param  privateLayout whether the layout is private to the group
1601             * @param  layoutId the primary key of the layout
1602             * @param  parentLayoutId the primary key to be assigned to the parent
1603             *         layout
1604             * @return the matching layout
1605             * @throws PortalException if a valid parent layout ID to use could not be
1606             *         found, if a matching layout could not be found, or if the user
1607             *         did not have permission to update the layout
1608             * @throws SystemException if a system exception occurred
1609             */
1610            @Override
1611            public Layout updateParentLayoutId(
1612                            long groupId, boolean privateLayout, long layoutId,
1613                            long parentLayoutId)
1614                    throws PortalException, SystemException {
1615    
1616                    LayoutPermissionUtil.check(
1617                            getPermissionChecker(), groupId, privateLayout, layoutId,
1618                            ActionKeys.UPDATE);
1619    
1620                    return layoutLocalService.updateParentLayoutId(
1621                            groupId, privateLayout, layoutId, parentLayoutId);
1622            }
1623    
1624            /**
1625             * Updates the parent layout ID of the layout matching the primary key. If a
1626             * layout matching the parent primary key is found, the layout ID of that
1627             * layout is assigned, otherwise {@link
1628             * com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID} is
1629             * assigned.
1630             *
1631             * @param  plid the primary key of the layout
1632             * @param  parentPlid the primary key of the parent layout
1633             * @return the layout matching the primary key
1634             * @throws PortalException if a layout with the primary key could not be
1635             *         found, if the user did not have permission to update the layout,
1636             *         or if a valid parent layout ID to use could not be found
1637             * @throws SystemException if a system exception occurred
1638             */
1639            @Override
1640            public Layout updateParentLayoutId(long plid, long parentPlid)
1641                    throws PortalException, SystemException {
1642    
1643                    LayoutPermissionUtil.check(
1644                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1645    
1646                    return layoutLocalService.updateParentLayoutId(plid, parentPlid);
1647            }
1648    
1649            @Override
1650            public Layout updateParentLayoutIdAndPriority(
1651                            long plid, long parentPlid, int priority)
1652                    throws PortalException, SystemException {
1653    
1654                    return layoutLocalService.updateParentLayoutIdAndPriority(
1655                            plid, parentPlid, priority);
1656            }
1657    
1658            /**
1659             * Updates the priority of the layout matching the group, layout ID, and
1660             * privacy.
1661             *
1662             * @param  groupId the primary key of the group
1663             * @param  privateLayout whether the layout is private to the group
1664             * @param  layoutId the primary key of the layout
1665             * @param  priority the layout's new priority
1666             * @return the updated layout
1667             * @throws PortalException if a matching layout could not be found or if the
1668             *         user did not have permission to update the layout
1669             * @throws SystemException if a system exception occurred
1670             */
1671            @Override
1672            public Layout updatePriority(
1673                            long groupId, boolean privateLayout, long layoutId, int priority)
1674                    throws PortalException, SystemException {
1675    
1676                    LayoutPermissionUtil.check(
1677                            getPermissionChecker(), groupId, privateLayout, layoutId,
1678                            ActionKeys.UPDATE);
1679    
1680                    return layoutLocalService.updatePriority(
1681                            groupId, privateLayout, layoutId, priority);
1682            }
1683    
1684            /**
1685             * Updates the priority of the layout matching the group, layout ID, and
1686             * privacy, setting the layout's priority based on the priorities of the
1687             * next and previous layouts.
1688             *
1689             * @param  groupId the primary key of the group
1690             * @param  privateLayout whether the layout is private to the group
1691             * @param  layoutId the primary key of the layout
1692             * @param  nextLayoutId the primary key of the next layout
1693             * @param  previousLayoutId the primary key of the previous layout
1694             * @return the updated layout
1695             * @throws PortalException if a matching layout could not be found or if the
1696             *         user did not have permission to update the layout
1697             * @throws SystemException if a system exception occurred
1698             */
1699            @Override
1700            public Layout updatePriority(
1701                            long groupId, boolean privateLayout, long layoutId,
1702                            long nextLayoutId, long previousLayoutId)
1703                    throws PortalException, SystemException {
1704    
1705                    LayoutPermissionUtil.check(
1706                            getPermissionChecker(), groupId, privateLayout, layoutId,
1707                            ActionKeys.UPDATE);
1708    
1709                    return layoutLocalService.updatePriority(
1710                            groupId, privateLayout, layoutId, nextLayoutId, previousLayoutId);
1711            }
1712    
1713            /**
1714             * Updates the priority of the layout matching the primary key.
1715             *
1716             * @param  plid the primary key of the layout
1717             * @param  priority the layout's new priority
1718             * @return the updated layout
1719             * @throws PortalException if a layout with the primary key could not be
1720             *         found
1721             * @throws SystemException if a system exception occurred
1722             */
1723            @Override
1724            public Layout updatePriority(long plid, int priority)
1725                    throws PortalException, SystemException {
1726    
1727                    LayoutPermissionUtil.check(
1728                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1729    
1730                    return layoutLocalService.updatePriority(plid, priority);
1731            }
1732    
1733            @Override
1734            public MissingReferences validateImportLayoutsFile(
1735                            long groupId, boolean privateLayout,
1736                            Map<String, String[]> parameterMap, File file)
1737                    throws PortalException, SystemException {
1738    
1739                    GroupPermissionUtil.check(
1740                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1741    
1742                    return layoutLocalService.validateImportLayoutsFile(
1743                            getUserId(), groupId, privateLayout, parameterMap, file);
1744            }
1745    
1746            @Override
1747            public MissingReferences validateImportLayoutsFile(
1748                            long groupId, boolean privateLayout,
1749                            Map<String, String[]> parameterMap, InputStream inputStream)
1750                    throws PortalException, SystemException {
1751    
1752                    GroupPermissionUtil.check(
1753                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1754    
1755                    return layoutLocalService.validateImportLayoutsFile(
1756                            getUserId(), groupId, privateLayout, parameterMap, inputStream);
1757            }
1758    
1759            @Override
1760            public MissingReferences validateImportPortletInfo(
1761                            long plid, long groupId, String portletId,
1762                            Map<String, String[]> parameterMap, File file)
1763                    throws PortalException, SystemException {
1764    
1765                    PortletPermissionUtil.check(
1766                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
1767    
1768                    return layoutLocalService.validateImportPortletInfo(
1769                            getUserId(), plid, groupId, portletId, parameterMap, file);
1770            }
1771    
1772            @Override
1773            public MissingReferences validateImportPortletInfo(
1774                            long plid, long groupId, String portletId,
1775                            Map<String, String[]> parameterMap, InputStream inputStream)
1776                    throws PortalException, SystemException {
1777    
1778                    PortletPermissionUtil.check(
1779                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
1780    
1781                    return layoutLocalService.validateImportPortletInfo(
1782                            getUserId(), plid, groupId, portletId, parameterMap, inputStream);
1783            }
1784    
1785            protected List<Layout> filterLayouts(List<Layout> layouts)
1786                    throws PortalException, SystemException {
1787    
1788                    List<Layout> filteredLayouts = new ArrayList<Layout>();
1789    
1790                    for (Layout layout : layouts) {
1791                            if (LayoutPermissionUtil.contains(
1792                                            getPermissionChecker(), layout.getPlid(),
1793                                            ActionKeys.VIEW)) {
1794    
1795                                    filteredLayouts.add(layout);
1796                            }
1797                    }
1798    
1799                    return filteredLayouts;
1800            }
1801    
1802    }