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