001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 PortalException, SystemException {
856    
857                    List<Layout> layouts = layoutLocalService.getLayouts(
858                            groupId, privateLayout, parentLayoutId, incomplete, start, end);
859    
860                    return filterLayouts(layouts);
861            }
862    
863            @Override
864            public int getLayoutsCount(
865                            long groupId, boolean privateLayout, long parentLayoutId)
866                    throws SystemException {
867    
868                    return layoutPersistence.filterCountByG_P_P(
869                            groupId, privateLayout, parentLayoutId);
870            }
871    
872            @Override
873            public int getLayoutsCount(
874                            long groupId, boolean privateLayout, long parentLayoutId,
875                            int priority) throws SystemException {
876    
877                    return layoutPersistence.filterCountByG_P_P_LtP(
878                                    groupId, privateLayout, parentLayoutId, priority);
879            }
880    
881            @Override
882            public String[] getTempFileEntryNames(long groupId, String tempFolderName)
883                    throws PortalException, SystemException {
884    
885                    GroupPermissionUtil.check(
886                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
887    
888                    return TempFileUtil.getTempFileEntryNames(
889                            groupId, getUserId(),
890                            DigesterUtil.digestHex(Digester.SHA_256, tempFolderName));
891            }
892    
893            /**
894             * Imports the layouts from the byte array.
895             *
896             * @param  groupId the primary key of the group
897             * @param  privateLayout whether the layout is private to the group
898             * @param  parameterMap the mapping of parameters indicating which
899             *         information will be imported. For information on the keys used in
900             *         the map see {@link
901             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
902             * @param  bytes the byte array with the data
903             * @throws PortalException if a group with the primary key could not be
904             *         found, if the group did not have permission to manage the
905             *         layouts, or if some other portal exception occurred
906             * @throws SystemException if a system exception occurred
907             * @see    com.liferay.portal.lar.LayoutImporter
908             */
909            @Override
910            public void importLayouts(
911                            long groupId, boolean privateLayout,
912                            Map<String, String[]> parameterMap, byte[] bytes)
913                    throws PortalException, SystemException {
914    
915                    GroupPermissionUtil.check(
916                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
917    
918                    layoutLocalService.importLayouts(
919                            getUserId(), groupId, privateLayout, parameterMap, bytes);
920            }
921    
922            /**
923             * Imports the layouts from the file.
924             *
925             * @param  groupId the primary key of the group
926             * @param  privateLayout whether the layout is private to the group
927             * @param  parameterMap the mapping of parameters indicating which
928             *         information will be imported. For information on the keys used in
929             *         the map see {@link
930             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
931             * @param  file the LAR file with the data
932             * @throws PortalException if a group with the primary key could not be
933             *         found, if the group did not have permission to manage the layouts
934             *         and publish, or if some other portal exception occurred
935             * @throws SystemException if a system exception occurred
936             * @see    com.liferay.portal.lar.LayoutImporter
937             */
938            @Override
939            public void importLayouts(
940                            long groupId, boolean privateLayout,
941                            Map<String, String[]> parameterMap, File file)
942                    throws PortalException, SystemException {
943    
944                    GroupPermissionUtil.check(
945                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
946    
947                    layoutLocalService.importLayouts(
948                            getUserId(), groupId, privateLayout, parameterMap, file);
949            }
950    
951            /**
952             * Imports the layouts from the input stream.
953             *
954             * @param  groupId the primary key of the group
955             * @param  privateLayout whether the layout is private to the group
956             * @param  parameterMap the mapping of parameters indicating which
957             *         information will be imported. For information on the keys used in
958             *         the map see {@link
959             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
960             * @param  is the input stream
961             * @throws PortalException if a group with the primary key could not be
962             *         found, if the group did not have permission to manage the
963             *         layouts, or if some other portal exception occurred
964             * @throws SystemException if a system exception occurred
965             * @see    com.liferay.portal.lar.LayoutImporter
966             */
967            @Override
968            public void importLayouts(
969                            long groupId, boolean privateLayout,
970                            Map<String, String[]> parameterMap, InputStream is)
971                    throws PortalException, SystemException {
972    
973                    GroupPermissionUtil.check(
974                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
975    
976                    layoutLocalService.importLayouts(
977                            getUserId(), groupId, privateLayout, parameterMap, is);
978            }
979    
980            @Override
981            public long importLayoutsInBackground(
982                            String taskName, long groupId, boolean privateLayout,
983                            Map<String, String[]> parameterMap, File file)
984                    throws PortalException, SystemException {
985    
986                    GroupPermissionUtil.check(
987                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
988    
989                    return layoutLocalService.importLayoutsInBackground(
990                            getUserId(), taskName, groupId, privateLayout, parameterMap, file);
991            }
992    
993            @Override
994            public long importLayoutsInBackground(
995                            String taskName, long groupId, boolean privateLayout,
996                            Map<String, String[]> parameterMap, InputStream inputStream)
997                    throws PortalException, SystemException {
998    
999                    GroupPermissionUtil.check(
1000                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1001    
1002                    return layoutLocalService.importLayoutsInBackground(
1003                            getUserId(), taskName, groupId, privateLayout, parameterMap,
1004                            inputStream);
1005            }
1006    
1007            /**
1008             * Imports the portlet information (categories, permissions, ... etc.) from
1009             * the file.
1010             *
1011             * @param  plid the primary key of the layout
1012             * @param  groupId the primary key of the group
1013             * @param  portletId the primary key of the portlet
1014             * @param  parameterMap the mapping of parameters indicating which
1015             *         information will be imported. For information on the keys used in
1016             *         the map see {@link
1017             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
1018             * @param  file the LAR file with the data
1019             * @throws PortalException if a group, layout, or portlet with the primary
1020             *         key could not be found, or if the group did not have permission
1021             *         to manage the layouts
1022             * @throws SystemException if a system exception occurred
1023             */
1024            @Override
1025            public void importPortletInfo(
1026                            long plid, long groupId, String portletId,
1027                            Map<String, String[]> parameterMap, File file)
1028                    throws PortalException, SystemException {
1029    
1030                    GroupPermissionUtil.check(
1031                            getPermissionChecker(), groupId,
1032                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1033    
1034                    layoutLocalService.importPortletInfo(
1035                            getUserId(), plid, groupId, portletId, parameterMap, file);
1036            }
1037    
1038            /**
1039             * Imports the portlet information (categories, permissions, ... etc.) from
1040             * the input stream.
1041             *
1042             * @param  plid the primary key of the layout
1043             * @param  groupId the primary key of the group
1044             * @param  portletId the primary key of the portlet
1045             * @param  parameterMap the mapping of parameters indicating which
1046             *         information will be imported. For information on the keys used in
1047             *         the map see {@link
1048             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}.
1049             * @param  is the input stream
1050             * @throws PortalException if a group, portlet, or layout with the primary
1051             *         key could not be found or if the group did not have permission to
1052             *         manage the layouts
1053             * @throws SystemException if a system exception occurred
1054             */
1055            @Override
1056            public void importPortletInfo(
1057                            long plid, long groupId, String portletId,
1058                            Map<String, String[]> parameterMap, InputStream is)
1059                    throws PortalException, SystemException {
1060    
1061                    GroupPermissionUtil.check(
1062                            getPermissionChecker(), groupId,
1063                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1064    
1065                    layoutLocalService.importPortletInfo(
1066                            getUserId(), plid, groupId, portletId, parameterMap, is);
1067            }
1068    
1069            @Override
1070            public void importPortletInfo(
1071                            String portletId, Map<String, String[]> parameterMap, File file)
1072                    throws PortalException, SystemException {
1073    
1074                    User user = userPersistence.findByPrimaryKey(getUserId());
1075    
1076                    Group companyGroup = groupLocalService.getCompanyGroup(
1077                            user.getCompanyId());
1078    
1079                    GroupPermissionUtil.check(
1080                            getPermissionChecker(), companyGroup.getGroupId(),
1081                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1082    
1083                    layoutLocalService.importPortletInfo(
1084                            getUserId(), portletId, parameterMap, file);
1085            }
1086    
1087            @Override
1088            public void importPortletInfo(
1089                            String portletId, Map<String, String[]> parameterMap,
1090                            InputStream is)
1091                    throws PortalException, SystemException {
1092    
1093                    User user = userPersistence.findByPrimaryKey(getUserId());
1094    
1095                    Group companyGroup = groupLocalService.getCompanyGroup(
1096                            user.getCompanyId());
1097    
1098                    GroupPermissionUtil.check(
1099                            getPermissionChecker(), companyGroup.getGroupId(),
1100                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1101    
1102                    layoutLocalService.importPortletInfo(
1103                            getUserId(), portletId, parameterMap, is);
1104            }
1105    
1106            @Override
1107            public long importPortletInfoInBackground(
1108                            String taskName, long plid, long groupId, String portletId,
1109                            Map<String, String[]> parameterMap, File file)
1110                    throws PortalException, SystemException {
1111    
1112                    GroupPermissionUtil.check(
1113                            getPermissionChecker(), groupId,
1114                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1115    
1116                    return layoutLocalService.importPortletInfoInBackground(
1117                            getUserId(), taskName, plid, groupId, portletId, parameterMap,
1118                            file);
1119            }
1120    
1121            @Override
1122            public long importPortletInfoInBackground(
1123                            String taskName, long plid, long groupId, String portletId,
1124                            Map<String, String[]> parameterMap, InputStream is)
1125                    throws PortalException, SystemException {
1126    
1127                    GroupPermissionUtil.check(
1128                            getPermissionChecker(), groupId,
1129                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1130    
1131                    return layoutLocalService.importPortletInfoInBackground(
1132                            getUserId(), taskName, plid, groupId, portletId, parameterMap, is);
1133            }
1134    
1135            @Override
1136            public void importPortletInfoInBackground(
1137                            String taskName, String portletId,
1138                            Map<String, String[]> parameterMap, File file)
1139                    throws PortalException, SystemException {
1140    
1141                    User user = userPersistence.findByPrimaryKey(getUserId());
1142    
1143                    Group companyGroup = groupLocalService.getCompanyGroup(
1144                            user.getCompanyId());
1145    
1146                    GroupPermissionUtil.check(
1147                            getPermissionChecker(), companyGroup.getGroupId(),
1148                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1149    
1150                    layoutLocalService.importPortletInfoInBackground(
1151                            getUserId(), taskName, portletId, parameterMap, file);
1152            }
1153    
1154            @Override
1155            public void importPortletInfoInBackground(
1156                            String taskName, String portletId,
1157                            Map<String, String[]> parameterMap, InputStream is)
1158                    throws PortalException, SystemException {
1159    
1160                    User user = userPersistence.findByPrimaryKey(getUserId());
1161    
1162                    Group companyGroup = groupLocalService.getCompanyGroup(
1163                            user.getCompanyId());
1164    
1165                    GroupPermissionUtil.check(
1166                            getPermissionChecker(), companyGroup.getGroupId(),
1167                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1168    
1169                    layoutLocalService.importPortletInfoInBackground(
1170                            getUserId(), taskName, portletId, parameterMap, is);
1171            }
1172    
1173            /**
1174             * Schedules a range of layouts to be published.
1175             *
1176             * @param  sourceGroupId the primary key of the source group
1177             * @param  targetGroupId the primary key of the target group
1178             * @param  privateLayout whether the layout is private to the group
1179             * @param  layoutIdMap the layouts considered for publishing, specified by
1180             *         the layout IDs and booleans indicating whether they have children
1181             * @param  parameterMap the mapping of parameters indicating which
1182             *         information will be used. See {@link
1183             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}
1184             * @param  scope the scope of the pages. It can be <code>all-pages</code> or
1185             *         <code>selected-pages</code>.
1186             * @param  startDate the start date
1187             * @param  endDate the end date
1188             * @param  groupName the group name (optionally {@link
1189             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1190             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1191             * @param  cronText the cron text. See {@link
1192             *         com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1193             * @param  schedulerStartDate the scheduler start date
1194             * @param  schedulerEndDate the scheduler end date
1195             * @param  description the scheduler description
1196             * @throws PortalException if the group did not have permission to manage
1197             *         and publish
1198             * @throws SystemException if a system exception occurred
1199             */
1200            @Override
1201            public void schedulePublishToLive(
1202                            long sourceGroupId, long targetGroupId, boolean privateLayout,
1203                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1204                            String scope, Date startDate, Date endDate, String groupName,
1205                            String cronText, Date schedulerStartDate, Date schedulerEndDate,
1206                            String description)
1207                    throws PortalException, SystemException {
1208    
1209                    GroupPermissionUtil.check(
1210                            getPermissionChecker(), targetGroupId, ActionKeys.PUBLISH_STAGING);
1211    
1212                    String jobName = PortalUUIDUtil.generate();
1213    
1214                    Trigger trigger = new CronTrigger(
1215                            jobName, groupName, schedulerStartDate, schedulerEndDate, cronText);
1216    
1217                    String command = StringPool.BLANK;
1218    
1219                    if (scope.equals("all-pages")) {
1220                            command = LayoutsLocalPublisherRequest.COMMAND_ALL_PAGES;
1221                    }
1222                    else if (scope.equals("selected-pages")) {
1223                            command = LayoutsLocalPublisherRequest.COMMAND_SELECTED_PAGES;
1224                    }
1225    
1226                    LayoutsLocalPublisherRequest publisherRequest =
1227                            new LayoutsLocalPublisherRequest(
1228                                    command, getUserId(), sourceGroupId, targetGroupId,
1229                                    privateLayout, layoutIdMap, parameterMap, startDate, endDate);
1230    
1231                    SchedulerEngineHelperUtil.schedule(
1232                            trigger, StorageType.PERSISTED, description,
1233                            DestinationNames.LAYOUTS_LOCAL_PUBLISHER, publisherRequest, 0);
1234            }
1235    
1236            /**
1237             * Schedules a range of layouts to be stored.
1238             *
1239             * @param  sourceGroupId the primary key of the source group
1240             * @param  privateLayout whether the layout is private to the group
1241             * @param  layoutIdMap the layouts considered for publishing, specified by
1242             *         the layout IDs and booleans indicating whether they have children
1243             * @param  parameterMap the mapping of parameters indicating which
1244             *         information will be used. See {@link
1245             *         com.liferay.portal.kernel.lar.PortletDataHandlerKeys}
1246             * @param  remoteAddress the remote address
1247             * @param  remotePort the remote port
1248             * @param  remotePathContext the remote path context
1249             * @param  secureConnection whether the connection is secure
1250             * @param  remoteGroupId the primary key of the remote group
1251             * @param  remotePrivateLayout whether remote group's layout is private
1252             * @param  startDate the start date
1253             * @param  endDate the end date
1254             * @param  groupName the group name. Optionally {@link
1255             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1256             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1257             * @param  cronText the cron text. See {@link
1258             *         com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1259             * @param  schedulerStartDate the scheduler start date
1260             * @param  schedulerEndDate the scheduler end date
1261             * @param  description the scheduler description
1262             * @throws PortalException if a group with the source group primary key was
1263             *         not found or if the group did not have permission to publish
1264             * @throws SystemException if a system exception occurred
1265             */
1266            @Override
1267            public void schedulePublishToRemote(
1268                            long sourceGroupId, boolean privateLayout,
1269                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1270                            String remoteAddress, int remotePort, String remotePathContext,
1271                            boolean secureConnection, long remoteGroupId,
1272                            boolean remotePrivateLayout, Date startDate, Date endDate,
1273                            String groupName, String cronText, Date schedulerStartDate,
1274                            Date schedulerEndDate, String description)
1275                    throws PortalException, SystemException {
1276    
1277                    GroupPermissionUtil.check(
1278                            getPermissionChecker(), sourceGroupId, ActionKeys.PUBLISH_STAGING);
1279    
1280                    LayoutsRemotePublisherRequest publisherRequest =
1281                            new LayoutsRemotePublisherRequest(
1282                                    getUserId(), sourceGroupId, privateLayout, layoutIdMap,
1283                                    parameterMap, remoteAddress, remotePort, remotePathContext,
1284                                    secureConnection, remoteGroupId, remotePrivateLayout, startDate,
1285                                    endDate);
1286    
1287                    String jobName = PortalUUIDUtil.generate();
1288    
1289                    Trigger trigger = new CronTrigger(
1290                            jobName, groupName, schedulerStartDate, schedulerEndDate, cronText);
1291    
1292                    SchedulerEngineHelperUtil.schedule(
1293                            trigger, StorageType.PERSISTED, description,
1294                            DestinationNames.LAYOUTS_REMOTE_PUBLISHER, publisherRequest, 0);
1295            }
1296    
1297            /**
1298             * Sets the layouts for the group, replacing and prioritizing all layouts of
1299             * the parent layout.
1300             *
1301             * @param  groupId the primary key of the group
1302             * @param  privateLayout whether the layout is private to the group
1303             * @param  parentLayoutId the primary key of the parent layout
1304             * @param  layoutIds the primary keys of the layouts
1305             * @param  serviceContext the service context to be applied
1306             * @throws PortalException if a group or layout with the primary key could
1307             *         not be found, if the group did not have permission to manage the
1308             *         layouts, if no layouts were specified, if the first layout was
1309             *         not page-able, if the first layout was hidden, or if some other
1310             *         portal exception occurred
1311             * @throws SystemException if a system exception occurred
1312             */
1313            @Override
1314            public void setLayouts(
1315                            long groupId, boolean privateLayout, long parentLayoutId,
1316                            long[] layoutIds, ServiceContext serviceContext)
1317                    throws PortalException, SystemException {
1318    
1319                    GroupPermissionUtil.check(
1320                            getPermissionChecker(), groupId, ActionKeys.UPDATE);
1321    
1322                    layoutLocalService.setLayouts(
1323                            groupId, privateLayout, parentLayoutId, layoutIds, serviceContext);
1324            }
1325    
1326            /**
1327             * Deletes the job from the scheduler's queue.
1328             *
1329             * @param  groupId the primary key of the group
1330             * @param  jobName the job name
1331             * @param  groupName the group name (optionally {@link
1332             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1333             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1334             * @throws PortalException if the group did not permission to manage staging
1335             *         and publish
1336             * @throws SystemException if a system exception occurred
1337             */
1338            @Override
1339            public void unschedulePublishToLive(
1340                            long groupId, String jobName, String groupName)
1341                    throws PortalException, SystemException {
1342    
1343                    GroupPermissionUtil.check(
1344                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1345    
1346                    SchedulerEngineHelperUtil.delete(
1347                            jobName, groupName, StorageType.PERSISTED);
1348            }
1349    
1350            /**
1351             * Deletes the job from the scheduler's persistent queue.
1352             *
1353             * @param  groupId the primary key of the group
1354             * @param  jobName the job name
1355             * @param  groupName the group name (optionally {@link
1356             *         com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}).
1357             *         See {@link com.liferay.portal.kernel.messaging.DestinationNames}.
1358             * @throws PortalException if a group with the primary key could not be
1359             *         found or if the group did not have permission to publish
1360             * @throws SystemException if a system exception occurred
1361             */
1362            @Override
1363            public void unschedulePublishToRemote(
1364                            long groupId, String jobName, String groupName)
1365                    throws PortalException, SystemException {
1366    
1367                    GroupPermissionUtil.check(
1368                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1369    
1370                    SchedulerEngineHelperUtil.delete(
1371                            jobName, groupName, StorageType.PERSISTED);
1372            }
1373    
1374            /**
1375             * Updates the layout with additional parameters.
1376             *
1377             * @param  groupId the primary key of the group
1378             * @param  privateLayout whether the layout is private to the group
1379             * @param  layoutId the primary key of the layout
1380             * @param  parentLayoutId the primary key of the layout's new parent layout
1381             * @param  localeNamesMap the layout's locales and localized names
1382             * @param  localeTitlesMap the layout's locales and localized titles
1383             * @param  descriptionMap the locales and localized descriptions to merge
1384             *         (optionally <code>null</code>)
1385             * @param  keywordsMap the locales and localized keywords to merge
1386             *         (optionally <code>null</code>)
1387             * @param  robotsMap the locales and localized robots to merge (optionally
1388             *         <code>null</code>)
1389             * @param  type the layout's new type (optionally {@link
1390             *         com.liferay.portal.model.LayoutConstants#TYPE_PORTLET})
1391             * @param  hidden whether the layout is hidden
1392             * @param  friendlyURLMap the layout's locales and localized friendly URLs.
1393             *         To see how the URL is normalized when accessed see {@link
1394             *         com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
1395             *         String)}.
1396             * @param  iconImage whether the icon image will be updated
1397             * @param  iconBytes the byte array of the layout's new icon image
1398             * @param  serviceContext the service context to be applied. Can set the
1399             *         modification date and expando bridge attributes for the layout.
1400             * @return the updated layout
1401             * @throws PortalException if a group or layout with the primary key could
1402             *         not be found, if the user did not have permission to update the
1403             *         layout, if a unique friendly URL could not be generated, if a
1404             *         valid parent layout ID to use could not be found, or if the
1405             *         layout parameters were invalid
1406             * @throws SystemException if a system exception occurred
1407             */
1408            @Override
1409            public Layout updateLayout(
1410                            long groupId, boolean privateLayout, long layoutId,
1411                            long parentLayoutId, Map<Locale, String> localeNamesMap,
1412                            Map<Locale, String> localeTitlesMap,
1413                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
1414                            Map<Locale, String> robotsMap, String type, boolean hidden,
1415                            Map<Locale, String> friendlyURLMap, Boolean iconImage,
1416                            byte[] iconBytes, ServiceContext serviceContext)
1417                    throws PortalException, SystemException {
1418    
1419                    LayoutPermissionUtil.check(
1420                            getPermissionChecker(), groupId, privateLayout, layoutId,
1421                            ActionKeys.UPDATE);
1422    
1423                    return layoutLocalService.updateLayout(
1424                            groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap,
1425                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
1426                            hidden, friendlyURLMap, iconImage, iconBytes, serviceContext);
1427            }
1428    
1429            /**
1430             * Updates the layout with additional parameters.
1431             *
1432             * @param      groupId the primary key of the group
1433             * @param      privateLayout whether the layout is private to the group
1434             * @param      layoutId the primary key of the layout
1435             * @param      parentLayoutId the primary key of the layout's new parent
1436             *             layout
1437             * @param      localeNamesMap the layout's locales and localized names
1438             * @param      localeTitlesMap the layout's locales and localized titles
1439             * @param      descriptionMap the locales and localized descriptions to
1440             *             merge (optionally <code>null</code>)
1441             * @param      keywordsMap the locales and localized keywords to merge
1442             *             (optionally <code>null</code>)
1443             * @param      robotsMap the locales and localized robots to merge
1444             *             (optionally <code>null</code>)
1445             * @param      type the layout's new type (optionally {@link
1446             *             com.liferay.portal.model.LayoutConstants#TYPE_PORTLET})
1447             * @param      hidden whether the layout is hidden
1448             * @param      friendlyURL the layout's locales and new friendly URLs. To
1449             *             see how the URL is normalized when accessed, see {@link
1450             *             com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
1451             *             String)}.
1452             * @param      iconImage whether the icon image will be updated
1453             * @param      iconBytes the byte array of the layout's new icon image
1454             * @param      serviceContext the service context to be applied. Can set the
1455             *             modification date and expando bridge attributes for the
1456             *             layout.
1457             * @return     the updated layout
1458             * @throws     PortalException if a group or layout with the primary key
1459             *             could not be found, if the user did not have permission to
1460             *             update the layout, if a unique friendly URL could not be
1461             *             generated, if a valid parent layout ID to use could not be
1462             *             found, or if the layout parameters were invalid
1463             * @throws     SystemException if a system exception occurred
1464             * @deprecated As of 6.2.0, replaced by {@link #updateLayout(long, boolean,
1465             *             long, long, Map, Map, Map, Map, Map, String, boolean, Map,
1466             *             Boolean, byte[], ServiceContext)}
1467             */
1468            @Override
1469            public Layout updateLayout(
1470                            long groupId, boolean privateLayout, long layoutId,
1471                            long parentLayoutId, Map<Locale, String> localeNamesMap,
1472                            Map<Locale, String> localeTitlesMap,
1473                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
1474                            Map<Locale, String> robotsMap, String type, boolean hidden,
1475                            String friendlyURL, Boolean iconImage, byte[] iconBytes,
1476                            ServiceContext serviceContext)
1477                    throws PortalException, SystemException {
1478    
1479                    LayoutPermissionUtil.check(
1480                            getPermissionChecker(), groupId, privateLayout, layoutId,
1481                            ActionKeys.UPDATE);
1482    
1483                    return layoutLocalService.updateLayout(
1484                            groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap,
1485                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
1486                            hidden, friendlyURL, iconImage, iconBytes, serviceContext);
1487            }
1488    
1489            /**
1490             * Updates the layout replacing its type settings.
1491             *
1492             * @param  groupId the primary key of the group
1493             * @param  privateLayout whether the layout is private to the group
1494             * @param  layoutId the primary key of the layout
1495             * @param  typeSettings the settings to load the unicode properties object.
1496             *         See {@link com.liferay.portal.kernel.util.UnicodeProperties
1497             *         #fastLoad(String)}.
1498             * @return the updated layout
1499             * @throws PortalException if a matching layout could not be found or if the
1500             *         user did not have permission to update the layout
1501             * @throws SystemException if a system exception occurred
1502             */
1503            @Override
1504            public Layout updateLayout(
1505                            long groupId, boolean privateLayout, long layoutId,
1506                            String typeSettings)
1507                    throws PortalException, SystemException {
1508    
1509                    LayoutPermissionUtil.check(
1510                            getPermissionChecker(), groupId, privateLayout, layoutId,
1511                            ActionKeys.UPDATE);
1512    
1513                    return layoutLocalService.updateLayout(
1514                            groupId, privateLayout, layoutId, typeSettings);
1515            }
1516    
1517            /**
1518             * Updates the look and feel of the layout.
1519             *
1520             * @param  groupId the primary key of the group
1521             * @param  privateLayout whether the layout is private to the group
1522             * @param  layoutId the primary key of the layout
1523             * @param  themeId the primary key of the layout's new theme
1524             * @param  colorSchemeId the primary key of the layout's new color scheme
1525             * @param  css the layout's new CSS
1526             * @param  wapTheme whether the theme is for WAP browsers
1527             * @return the updated layout
1528             * @throws PortalException if a matching layout could not be found, or if
1529             *         the user did not have permission to update the layout and
1530             *         permission to apply the theme
1531             * @throws SystemException if a system exception occurred
1532             */
1533            @Override
1534            public Layout updateLookAndFeel(
1535                            long groupId, boolean privateLayout, long layoutId, String themeId,
1536                            String colorSchemeId, String css, boolean wapTheme)
1537                    throws PortalException, SystemException {
1538    
1539                    LayoutPermissionUtil.check(
1540                            getPermissionChecker(), groupId, privateLayout, layoutId,
1541                            ActionKeys.UPDATE);
1542    
1543                    if (Validator.isNotNull(themeId)) {
1544                            pluginSettingLocalService.checkPermission(
1545                                    getUserId(), themeId, Plugin.TYPE_THEME);
1546                    }
1547    
1548                    return layoutLocalService.updateLookAndFeel(
1549                            groupId, privateLayout, layoutId, themeId, colorSchemeId, css,
1550                            wapTheme);
1551            }
1552    
1553            /**
1554             * Updates the name of the layout matching the group, layout ID, and
1555             * privacy.
1556             *
1557             * @param  groupId the primary key of the group
1558             * @param  privateLayout whether the layout is private to the group
1559             * @param  layoutId the primary key of the layout
1560             * @param  name the layout's new name
1561             * @param  languageId the primary key of the language. For more information
1562             *         see {@link java.util.Locale}.
1563             * @return the updated layout
1564             * @throws PortalException if a matching layout could not be found, if the
1565             *         user did not have permission to update the layout, or if the new
1566             *         name was <code>null</code>
1567             * @throws SystemException if a system exception occurred
1568             */
1569            @Override
1570            public Layout updateName(
1571                            long groupId, boolean privateLayout, long layoutId, String name,
1572                            String languageId)
1573                    throws PortalException, SystemException {
1574    
1575                    LayoutPermissionUtil.check(
1576                            getPermissionChecker(), groupId, privateLayout, layoutId,
1577                            ActionKeys.UPDATE);
1578    
1579                    return layoutLocalService.updateName(
1580                            groupId, privateLayout, layoutId, name, languageId);
1581            }
1582    
1583            /**
1584             * Updates the name of the layout matching the primary key.
1585             *
1586             * @param  plid the primary key of the layout
1587             * @param  name the name to be assigned
1588             * @param  languageId the primary key of the language. For more information
1589             *         see {@link java.util.Locale}.
1590             * @return the updated layout
1591             * @throws PortalException if a layout with the primary key could not be
1592             *         found, or if the user did not have permission to update the
1593             *         layout, or if the name was <code>null</code>
1594             * @throws SystemException if a system exception occurred
1595             */
1596            @Override
1597            public Layout updateName(long plid, String name, String languageId)
1598                    throws PortalException, SystemException {
1599    
1600                    LayoutPermissionUtil.check(
1601                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1602    
1603                    return layoutLocalService.updateName(plid, name, languageId);
1604            }
1605    
1606            /**
1607             * Updates the parent layout ID of the layout matching the group, layout ID,
1608             * and privacy.
1609             *
1610             * @param  groupId the primary key of the group
1611             * @param  privateLayout whether the layout is private to the group
1612             * @param  layoutId the primary key of the layout
1613             * @param  parentLayoutId the primary key to be assigned to the parent
1614             *         layout
1615             * @return the matching layout
1616             * @throws PortalException if a valid parent layout ID to use could not be
1617             *         found, if a matching layout could not be found, or if the user
1618             *         did not have permission to update the layout
1619             * @throws SystemException if a system exception occurred
1620             */
1621            @Override
1622            public Layout updateParentLayoutId(
1623                            long groupId, boolean privateLayout, long layoutId,
1624                            long parentLayoutId)
1625                    throws PortalException, SystemException {
1626    
1627                    LayoutPermissionUtil.check(
1628                            getPermissionChecker(), groupId, privateLayout, layoutId,
1629                            ActionKeys.UPDATE);
1630    
1631                    return layoutLocalService.updateParentLayoutId(
1632                            groupId, privateLayout, layoutId, parentLayoutId);
1633            }
1634    
1635            /**
1636             * Updates the parent layout ID of the layout matching the primary key. If a
1637             * layout matching the parent primary key is found, the layout ID of that
1638             * layout is assigned, otherwise {@link
1639             * com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID} is
1640             * assigned.
1641             *
1642             * @param  plid the primary key of the layout
1643             * @param  parentPlid the primary key of the parent layout
1644             * @return the layout matching the primary key
1645             * @throws PortalException if a layout with the primary key could not be
1646             *         found, if the user did not have permission to update the layout,
1647             *         or if a valid parent layout ID to use could not be found
1648             * @throws SystemException if a system exception occurred
1649             */
1650            @Override
1651            public Layout updateParentLayoutId(long plid, long parentPlid)
1652                    throws PortalException, SystemException {
1653    
1654                    LayoutPermissionUtil.check(
1655                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1656    
1657                    return layoutLocalService.updateParentLayoutId(plid, parentPlid);
1658            }
1659    
1660            @Override
1661            public Layout updateParentLayoutIdAndPriority(
1662                            long plid, long parentPlid, int priority)
1663                    throws PortalException, SystemException {
1664    
1665                    return layoutLocalService.updateParentLayoutIdAndPriority(
1666                            plid, parentPlid, priority);
1667            }
1668    
1669            /**
1670             * Updates the priority of the layout matching the group, layout ID, and
1671             * privacy.
1672             *
1673             * @param  groupId the primary key of the group
1674             * @param  privateLayout whether the layout is private to the group
1675             * @param  layoutId the primary key of the layout
1676             * @param  priority the layout's new priority
1677             * @return the updated layout
1678             * @throws PortalException if a matching layout could not be found or if the
1679             *         user did not have permission to update the layout
1680             * @throws SystemException if a system exception occurred
1681             */
1682            @Override
1683            public Layout updatePriority(
1684                            long groupId, boolean privateLayout, long layoutId, int priority)
1685                    throws PortalException, SystemException {
1686    
1687                    LayoutPermissionUtil.check(
1688                            getPermissionChecker(), groupId, privateLayout, layoutId,
1689                            ActionKeys.UPDATE);
1690    
1691                    return layoutLocalService.updatePriority(
1692                            groupId, privateLayout, layoutId, priority);
1693            }
1694    
1695            /**
1696             * Updates the priority of the layout matching the group, layout ID, and
1697             * privacy, setting the layout's priority based on the priorities of the
1698             * next and previous layouts.
1699             *
1700             * @param  groupId the primary key of the group
1701             * @param  privateLayout whether the layout is private to the group
1702             * @param  layoutId the primary key of the layout
1703             * @param  nextLayoutId the primary key of the next layout
1704             * @param  previousLayoutId the primary key of the previous layout
1705             * @return the updated layout
1706             * @throws PortalException if a matching layout could not be found or if the
1707             *         user did not have permission to update the layout
1708             * @throws SystemException if a system exception occurred
1709             */
1710            @Override
1711            public Layout updatePriority(
1712                            long groupId, boolean privateLayout, long layoutId,
1713                            long nextLayoutId, long previousLayoutId)
1714                    throws PortalException, SystemException {
1715    
1716                    LayoutPermissionUtil.check(
1717                            getPermissionChecker(), groupId, privateLayout, layoutId,
1718                            ActionKeys.UPDATE);
1719    
1720                    return layoutLocalService.updatePriority(
1721                            groupId, privateLayout, layoutId, nextLayoutId, previousLayoutId);
1722            }
1723    
1724            /**
1725             * Updates the priority of the layout matching the primary key.
1726             *
1727             * @param  plid the primary key of the layout
1728             * @param  priority the layout's new priority
1729             * @return the updated layout
1730             * @throws PortalException if a layout with the primary key could not be
1731             *         found
1732             * @throws SystemException if a system exception occurred
1733             */
1734            @Override
1735            public Layout updatePriority(long plid, int priority)
1736                    throws PortalException, SystemException {
1737    
1738                    LayoutPermissionUtil.check(
1739                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1740    
1741                    return layoutLocalService.updatePriority(plid, priority);
1742            }
1743    
1744            @Override
1745            public MissingReferences validateImportLayoutsFile(
1746                            long groupId, boolean privateLayout,
1747                            Map<String, String[]> parameterMap, File file)
1748                    throws PortalException, SystemException {
1749    
1750                    GroupPermissionUtil.check(
1751                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1752    
1753                    return layoutLocalService.validateImportLayoutsFile(
1754                            getUserId(), groupId, privateLayout, parameterMap, file);
1755            }
1756    
1757            @Override
1758            public MissingReferences validateImportLayoutsFile(
1759                            long groupId, boolean privateLayout,
1760                            Map<String, String[]> parameterMap, InputStream inputStream)
1761                    throws PortalException, SystemException {
1762    
1763                    GroupPermissionUtil.check(
1764                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1765    
1766                    return layoutLocalService.validateImportLayoutsFile(
1767                            getUserId(), groupId, privateLayout, parameterMap, inputStream);
1768            }
1769    
1770            @Override
1771            public MissingReferences validateImportPortletInfo(
1772                            long plid, long groupId, String portletId,
1773                            Map<String, String[]> parameterMap, File file)
1774                    throws PortalException, SystemException {
1775    
1776                    PortletPermissionUtil.check(
1777                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
1778    
1779                    return layoutLocalService.validateImportPortletInfo(
1780                            getUserId(), plid, groupId, portletId, parameterMap, file);
1781            }
1782    
1783            @Override
1784            public MissingReferences validateImportPortletInfo(
1785                            long plid, long groupId, String portletId,
1786                            Map<String, String[]> parameterMap, InputStream inputStream)
1787                    throws PortalException, SystemException {
1788    
1789                    PortletPermissionUtil.check(
1790                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
1791    
1792                    return layoutLocalService.validateImportPortletInfo(
1793                            getUserId(), plid, groupId, portletId, parameterMap, inputStream);
1794            }
1795    
1796            protected List<Layout> filterLayouts(List<Layout> layouts)
1797                    throws PortalException, SystemException {
1798    
1799                    List<Layout> filteredLayouts = new ArrayList<Layout>();
1800    
1801                    for (Layout layout : layouts) {
1802                            if (LayoutPermissionUtil.contains(
1803                                            getPermissionChecker(), layout.getPlid(),
1804                                            ActionKeys.VIEW)) {
1805    
1806                                    filteredLayouts.add(layout);
1807                            }
1808                    }
1809    
1810                    return filteredLayouts;
1811            }
1812    
1813    }