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                    LayoutPermissionUtil.check(
822                            getPermissionChecker(), layout, ActionKeys.VIEW);
823    
824                    return layout.getName(languageId);
825            }
826    
827            /**
828             * Returns the layout references for all the layouts that belong to the
829             * company and belong to the portlet that matches the preferences.
830             *
831             * @param  companyId the primary key of the company
832             * @param  portletId the primary key of the portlet
833             * @param  preferencesKey the portlet's preference key
834             * @param  preferencesValue the portlet's preference value
835             * @return the layout references of the matching layouts
836             */
837            @Override
838            public LayoutReference[] getLayoutReferences(
839                    long companyId, String portletId, String preferencesKey,
840                    String preferencesValue) {
841    
842                    LayoutReference[] layoutReferences = layoutLocalService.getLayouts(
843                            companyId, portletId, preferencesKey, preferencesValue);
844    
845                    List<LayoutReference> filteredLayoutReferences = new ArrayList<>(
846                            layoutReferences.length);
847    
848                    for (LayoutReference layoutReference : layoutReferences) {
849                            try {
850                                    if (LayoutPermissionUtil.contains(
851                                                    getPermissionChecker(),
852                                                    layoutReference.getLayoutSoap().getPlid(),
853                                                    ActionKeys.VIEW)) {
854    
855                                            filteredLayoutReferences.add(layoutReference);
856                                    }
857                            }
858                            catch (PortalException pe) {
859                                    continue;
860                            }
861                    }
862    
863                    return filteredLayoutReferences.toArray(
864                            new LayoutReference[filteredLayoutReferences.size()]);
865            }
866    
867            @Override
868            public List<Layout> getLayouts(long groupId, boolean privateLayout) {
869                    return layoutPersistence.filterFindByG_P(groupId, privateLayout);
870            }
871    
872            @Override
873            public List<Layout> getLayouts(
874                            long groupId, boolean privateLayout, long parentLayoutId)
875                    throws PortalException {
876    
877                    List<Layout> layouts = layoutLocalService.getLayouts(
878                            groupId, privateLayout, parentLayoutId);
879    
880                    return filterLayouts(layouts);
881            }
882    
883            @Override
884            public List<Layout> getLayouts(
885                            long groupId, boolean privateLayout, long parentLayoutId,
886                            boolean incomplete, int start, int end)
887                    throws PortalException {
888    
889                    List<Layout> layouts = layoutLocalService.getLayouts(
890                            groupId, privateLayout, parentLayoutId, incomplete, start, end);
891    
892                    return filterLayouts(layouts);
893            }
894    
895            @Override
896            public int getLayoutsCount(
897                    long groupId, boolean privateLayout, long parentLayoutId) {
898    
899                    return layoutPersistence.filterCountByG_P_P(
900                            groupId, privateLayout, parentLayoutId);
901            }
902    
903            @Override
904            public String[] getTempFileNames(long groupId, String folderName)
905                    throws PortalException {
906    
907                    GroupPermissionUtil.check(
908                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
909    
910                    return TempFileEntryUtil.getTempFileNames(
911                            groupId, getUserId(),
912                            DigesterUtil.digestHex(Digester.SHA_256, folderName));
913            }
914    
915            /**
916             * @deprecated As of 7.0.0, replaced by {@link
917             *             com.liferay.exportimport.kernel.service.ExportImportService#importLayouts(
918             *             ExportImportConfiguration, File)}
919             */
920            @Deprecated
921            @Override
922            public void importLayouts(
923                            ExportImportConfiguration exportImportConfiguration, File file)
924                    throws PortalException {
925    
926                    Map<String, Serializable> settingsMap =
927                            exportImportConfiguration.getSettingsMap();
928    
929                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
930    
931                    GroupPermissionUtil.check(
932                            getPermissionChecker(), targetGroupId,
933                            ActionKeys.EXPORT_IMPORT_LAYOUTS);
934    
935                    layoutLocalService.importLayouts(exportImportConfiguration, file);
936            }
937    
938            /**
939             * @deprecated As of 7.0.0, replaced by {@link
940             *             com.liferay.exportimport.kernel.service.ExportImportService#importLayouts(
941             *             ExportImportConfiguration, InputStream)}
942             */
943            @Deprecated
944            @Override
945            public void importLayouts(
946                            ExportImportConfiguration exportImportConfiguration, InputStream is)
947                    throws PortalException {
948    
949                    Map<String, Serializable> settingsMap =
950                            exportImportConfiguration.getSettingsMap();
951    
952                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
953    
954                    GroupPermissionUtil.check(
955                            getPermissionChecker(), targetGroupId,
956                            ActionKeys.EXPORT_IMPORT_LAYOUTS);
957    
958                    layoutLocalService.importLayouts(exportImportConfiguration, is);
959            }
960    
961            /**
962             * Imports the layouts from the byte array.
963             *
964             * @param      groupId the primary key of the group
965             * @param      privateLayout whether the layout is private to the group
966             * @param      parameterMap the mapping of parameters indicating which
967             *             information will be imported. For information on the keys
968             *             used in the map see {@link
969             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
970             * @param      bytes the byte array with the data
971             * @see        com.liferay.exportimport.kernel.lar.LayoutImporter
972             * @deprecated As of 7.0.0, with no direct replacement
973             */
974            @Deprecated
975            @Override
976            public void importLayouts(
977                            long groupId, boolean privateLayout,
978                            Map<String, String[]> parameterMap, byte[] bytes)
979                    throws PortalException {
980    
981                    GroupPermissionUtil.check(
982                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
983    
984                    layoutLocalService.importLayouts(
985                            getUserId(), groupId, privateLayout, parameterMap, bytes);
986            }
987    
988            /**
989             * Imports the layouts from the file.
990             *
991             * @param      groupId the primary key of the group
992             * @param      privateLayout whether the layout is private to the group
993             * @param      parameterMap the mapping of parameters indicating which
994             *             information will be imported. For information on the keys
995             *             used in the map see {@link
996             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
997             * @param      file the LAR file with the data
998             * @see        com.liferay.exportimport.kernel.lar.LayoutImporter
999             * @deprecated As of 7.0.0, with no direct replacement
1000             */
1001            @Deprecated
1002            @Override
1003            public void importLayouts(
1004                            long groupId, boolean privateLayout,
1005                            Map<String, String[]> parameterMap, File file)
1006                    throws PortalException {
1007    
1008                    GroupPermissionUtil.check(
1009                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1010    
1011                    layoutLocalService.importLayouts(
1012                            getUserId(), groupId, privateLayout, parameterMap, file);
1013            }
1014    
1015            /**
1016             * Imports the layouts from the input stream.
1017             *
1018             * @param      groupId the primary key of the group
1019             * @param      privateLayout whether the layout is private to the group
1020             * @param      parameterMap the mapping of parameters indicating which
1021             *             information will be imported. For information on the keys
1022             *             used in the map see {@link
1023             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1024             * @param      is the input stream
1025             * @see        com.liferay.exportimport.kernel.lar.LayoutImporter
1026             * @deprecated As of 7.0.0, with no direct replacement
1027             */
1028            @Deprecated
1029            @Override
1030            public void importLayouts(
1031                            long groupId, boolean privateLayout,
1032                            Map<String, String[]> parameterMap, InputStream is)
1033                    throws PortalException {
1034    
1035                    GroupPermissionUtil.check(
1036                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1037    
1038                    layoutLocalService.importLayouts(
1039                            getUserId(), groupId, privateLayout, parameterMap, is);
1040            }
1041    
1042            /**
1043             * @deprecated As of 7.0.0, with no direct replacement
1044             */
1045            @Deprecated
1046            @Override
1047            public long importLayoutsInBackground(
1048                            String taskName, long groupId, boolean privateLayout,
1049                            Map<String, String[]> parameterMap, File file)
1050                    throws PortalException {
1051    
1052                    GroupPermissionUtil.check(
1053                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1054    
1055                    return layoutLocalService.importLayoutsInBackground(
1056                            getUserId(), taskName, groupId, privateLayout, parameterMap, file);
1057            }
1058    
1059            /**
1060             * @deprecated As of 7.0.0, with no direct replacement
1061             */
1062            @Deprecated
1063            @Override
1064            public long importLayoutsInBackground(
1065                            String taskName, long groupId, boolean privateLayout,
1066                            Map<String, String[]> parameterMap, InputStream inputStream)
1067                    throws PortalException {
1068    
1069                    GroupPermissionUtil.check(
1070                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1071    
1072                    return layoutLocalService.importLayoutsInBackground(
1073                            getUserId(), taskName, groupId, privateLayout, parameterMap,
1074                            inputStream);
1075            }
1076    
1077            /**
1078             * @deprecated As of 7.0.0, replaced by {@link
1079             *             com.liferay.exportimport.kernel.service.ExportImportService#importPortletInfo(
1080             *             ExportImportConfiguration, File)} (
1081             */
1082            @Deprecated
1083            @Override
1084            public void importPortletInfo(
1085                            ExportImportConfiguration exportImportConfiguration, File file)
1086                    throws PortalException {
1087    
1088                    Map<String, Serializable> settingsMap =
1089                            exportImportConfiguration.getSettingsMap();
1090    
1091                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
1092    
1093                    GroupPermissionUtil.check(
1094                            getPermissionChecker(), targetGroupId,
1095                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1096    
1097                    layoutLocalService.importPortletInfo(exportImportConfiguration, file);
1098            }
1099    
1100            /**
1101             * @deprecated As of 7.0.0, replaced by {@link
1102             *             com.liferay.exportimport.kernel.service.ExportImportService#importPortletInfo(
1103             *             ExportImportConfiguration, InputStream)} (
1104             */
1105            @Deprecated
1106            @Override
1107            public void importPortletInfo(
1108                            ExportImportConfiguration exportImportConfiguration, InputStream is)
1109                    throws PortalException {
1110    
1111                    Map<String, Serializable> settingsMap =
1112                            exportImportConfiguration.getSettingsMap();
1113    
1114                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
1115    
1116                    GroupPermissionUtil.check(
1117                            getPermissionChecker(), targetGroupId,
1118                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1119    
1120                    layoutLocalService.importPortletInfo(exportImportConfiguration, is);
1121            }
1122    
1123            /**
1124             * Imports the portlet information (categories, permissions, ... etc.) from
1125             * the file.
1126             *
1127             * @param      plid the primary key of the layout
1128             * @param      groupId the primary key of the group
1129             * @param      portletId the primary key of the portlet
1130             * @param      parameterMap the mapping of parameters indicating which
1131             *             information will be imported. For information on the keys
1132             *             used in the map see {@link
1133             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1134             * @param      file the LAR file with the data
1135             * @deprecated As of 7.0.0, with no direct replacement
1136             */
1137            @Deprecated
1138            @Override
1139            public void importPortletInfo(
1140                            long plid, long groupId, String portletId,
1141                            Map<String, String[]> parameterMap, File file)
1142                    throws PortalException {
1143    
1144                    GroupPermissionUtil.check(
1145                            getPermissionChecker(), groupId,
1146                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1147    
1148                    layoutLocalService.importPortletInfo(
1149                            getUserId(), plid, groupId, portletId, parameterMap, file);
1150            }
1151    
1152            /**
1153             * Imports the portlet information (categories, permissions, ... etc.) from
1154             * the input stream.
1155             *
1156             * @param      plid the primary key of the layout
1157             * @param      groupId the primary key of the group
1158             * @param      portletId the primary key of the portlet
1159             * @param      parameterMap the mapping of parameters indicating which
1160             *             information will be imported. For information on the keys
1161             *             used in the map see {@link
1162             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1163             * @param      is the input stream
1164             * @deprecated As of 7.0.0, with no direct replacement
1165             */
1166            @Deprecated
1167            @Override
1168            public void importPortletInfo(
1169                            long plid, long groupId, String portletId,
1170                            Map<String, String[]> parameterMap, InputStream is)
1171                    throws PortalException {
1172    
1173                    GroupPermissionUtil.check(
1174                            getPermissionChecker(), groupId,
1175                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1176    
1177                    layoutLocalService.importPortletInfo(
1178                            getUserId(), plid, groupId, portletId, parameterMap, is);
1179            }
1180    
1181            /**
1182             * @deprecated As of 7.0.0, with no direct replacement
1183             */
1184            @Deprecated
1185            @Override
1186            public void importPortletInfo(
1187                            String portletId, Map<String, String[]> parameterMap, File file)
1188                    throws PortalException {
1189    
1190                    User user = userPersistence.findByPrimaryKey(getUserId());
1191    
1192                    Group companyGroup = groupLocalService.getCompanyGroup(
1193                            user.getCompanyId());
1194    
1195                    GroupPermissionUtil.check(
1196                            getPermissionChecker(), companyGroup,
1197                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1198    
1199                    layoutLocalService.importPortletInfo(
1200                            getUserId(), portletId, parameterMap, file);
1201            }
1202    
1203            /**
1204             * @deprecated As of 7.0.0, with no direct replacement
1205             */
1206            @Deprecated
1207            @Override
1208            public void importPortletInfo(
1209                            String portletId, Map<String, String[]> parameterMap,
1210                            InputStream is)
1211                    throws PortalException {
1212    
1213                    User user = userPersistence.findByPrimaryKey(getUserId());
1214    
1215                    Group companyGroup = groupLocalService.getCompanyGroup(
1216                            user.getCompanyId());
1217    
1218                    GroupPermissionUtil.check(
1219                            getPermissionChecker(), companyGroup,
1220                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1221    
1222                    layoutLocalService.importPortletInfo(
1223                            getUserId(), portletId, parameterMap, is);
1224            }
1225    
1226            /**
1227             * @deprecated As of 7.0.0, with no direct replacement
1228             */
1229            @Deprecated
1230            @Override
1231            public long importPortletInfoInBackground(
1232                            String taskName, long plid, long groupId, String portletId,
1233                            Map<String, String[]> parameterMap, File file)
1234                    throws PortalException {
1235    
1236                    GroupPermissionUtil.check(
1237                            getPermissionChecker(), groupId,
1238                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1239    
1240                    return layoutLocalService.importPortletInfoInBackground(
1241                            getUserId(), taskName, plid, groupId, portletId, parameterMap,
1242                            file);
1243            }
1244    
1245            /**
1246             * @deprecated As of 7.0.0, with no direct replacement
1247             */
1248            @Deprecated
1249            @Override
1250            public long importPortletInfoInBackground(
1251                            String taskName, long plid, long groupId, String portletId,
1252                            Map<String, String[]> parameterMap, InputStream is)
1253                    throws PortalException {
1254    
1255                    GroupPermissionUtil.check(
1256                            getPermissionChecker(), groupId,
1257                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1258    
1259                    return layoutLocalService.importPortletInfoInBackground(
1260                            getUserId(), taskName, plid, groupId, portletId, parameterMap, is);
1261            }
1262    
1263            /**
1264             * @deprecated As of 7.0.0, with no direct replacement
1265             */
1266            @Deprecated
1267            @Override
1268            public void importPortletInfoInBackground(
1269                            String taskName, String portletId,
1270                            Map<String, String[]> parameterMap, File file)
1271                    throws PortalException {
1272    
1273                    User user = userPersistence.findByPrimaryKey(getUserId());
1274    
1275                    Group companyGroup = groupLocalService.getCompanyGroup(
1276                            user.getCompanyId());
1277    
1278                    GroupPermissionUtil.check(
1279                            getPermissionChecker(), companyGroup,
1280                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1281    
1282                    layoutLocalService.importPortletInfoInBackground(
1283                            getUserId(), taskName, portletId, parameterMap, file);
1284            }
1285    
1286            /**
1287             * @deprecated As of 7.0.0, with no direct replacement
1288             */
1289            @Deprecated
1290            @Override
1291            public void importPortletInfoInBackground(
1292                            String taskName, String portletId,
1293                            Map<String, String[]> parameterMap, InputStream is)
1294                    throws PortalException {
1295    
1296                    User user = userPersistence.findByPrimaryKey(getUserId());
1297    
1298                    Group companyGroup = groupLocalService.getCompanyGroup(
1299                            user.getCompanyId());
1300    
1301                    GroupPermissionUtil.check(
1302                            getPermissionChecker(), companyGroup,
1303                            ActionKeys.EXPORT_IMPORT_PORTLET_INFO);
1304    
1305                    layoutLocalService.importPortletInfoInBackground(
1306                            getUserId(), taskName, portletId, parameterMap, is);
1307            }
1308    
1309            /**
1310             * Schedules a range of layouts to be published.
1311             *
1312             * @param      sourceGroupId the primary key of the source group
1313             * @param      targetGroupId the primary key of the target group
1314             * @param      privateLayout whether the layout is private to the group
1315             * @param      layoutIds the layouts considered for publishing, specified by
1316             *             the layout IDs
1317             * @param      parameterMap the mapping of parameters indicating which
1318             *             information will be used. See {@link
1319             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1320             * @param      scope the scope of the pages. It can be
1321             *             <code>all-pages</code> or <code>selected-pages</code>.
1322             * @param      startDate the start date
1323             * @param      endDate the end date
1324             * @param      groupName the group name (optionally {@link
1325             *             DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1326             *             DestinationNames}.
1327             * @param      cronText the cron text. See {@link
1328             *             com.liferay.portal.kernel.cal.RecurrenceSerializer
1329             *             #toCronText}
1330             * @param      schedulerStartDate the scheduler start date
1331             * @param      schedulerEndDate the scheduler end date
1332             * @param      description the scheduler description
1333             * @deprecated As of 7.0.0, replaced by {@link #schedulePublishToLive(long,
1334             *             long, boolean, long[], Map, String, String, Date, Date,
1335             *             String)}
1336             */
1337            @Deprecated
1338            @Override
1339            public void schedulePublishToLive(
1340                            long sourceGroupId, long targetGroupId, boolean privateLayout,
1341                            long[] layoutIds, Map<String, String[]> parameterMap, String scope,
1342                            Date startDate, Date endDate, String groupName, String cronText,
1343                            Date schedulerStartDate, Date schedulerEndDate, String description)
1344                    throws PortalException {
1345    
1346                    schedulePublishToLive(
1347                            sourceGroupId, targetGroupId, privateLayout, layoutIds,
1348                            parameterMap, groupName, cronText, schedulerStartDate,
1349                            schedulerEndDate, description);
1350            }
1351    
1352            /**
1353             * Schedules a range of layouts to be published.
1354             *
1355             * @param sourceGroupId the primary key of the source group
1356             * @param targetGroupId the primary key of the target group
1357             * @param privateLayout whether the layout is private to the group
1358             * @param layoutIds the layouts considered for publishing, specified by the
1359             *        layout IDs
1360             * @param parameterMap the mapping of parameters indicating which
1361             *        information will be used. See {@link
1362             *        com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1363             * @param groupName the group name (optionally {@link
1364             *        DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1365             *        DestinationNames}.
1366             * @param cronText the cron text. See {@link
1367             *        com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1368             * @param schedulerStartDate the scheduler start date
1369             * @param schedulerEndDate the scheduler end date
1370             * @param description the scheduler description
1371             */
1372            @Override
1373            public void schedulePublishToLive(
1374                            long sourceGroupId, long targetGroupId, boolean privateLayout,
1375                            long[] layoutIds, Map<String, String[]> parameterMap,
1376                            String groupName, String cronText, Date schedulerStartDate,
1377                            Date schedulerEndDate, String description)
1378                    throws PortalException {
1379    
1380                    GroupPermissionUtil.check(
1381                            getPermissionChecker(), targetGroupId, ActionKeys.PUBLISH_STAGING);
1382    
1383                    Trigger trigger = TriggerFactoryUtil.createTrigger(
1384                            PortalUUIDUtil.generate(), groupName, schedulerStartDate,
1385                            schedulerEndDate, cronText);
1386    
1387                    User user = userPersistence.findByPrimaryKey(getUserId());
1388    
1389                    Map<String, Serializable> publishLayoutLocalSettingsMap =
1390                            ExportImportConfigurationSettingsMapFactory.
1391                                    buildPublishLayoutLocalSettingsMap(
1392                                            user, sourceGroupId, targetGroupId, privateLayout,
1393                                            layoutIds, parameterMap);
1394    
1395                    ExportImportConfiguration exportImportConfiguration =
1396                            exportImportConfigurationLocalService.
1397                                    addDraftExportImportConfiguration(
1398                                            getUserId(), description,
1399                                            ExportImportConfigurationConstants.
1400                                                    TYPE_SCHEDULED_PUBLISH_LAYOUT_LOCAL,
1401                                            publishLayoutLocalSettingsMap);
1402    
1403                    SchedulerEngineHelperUtil.schedule(
1404                            trigger, StorageType.PERSISTED, description,
1405                            DestinationNames.LAYOUTS_LOCAL_PUBLISHER,
1406                            exportImportConfiguration.getExportImportConfigurationId(), 0);
1407            }
1408    
1409            /**
1410             * Schedules a range of layouts to be published.
1411             *
1412             * @param      sourceGroupId the primary key of the source group
1413             * @param      targetGroupId the primary key of the target group
1414             * @param      privateLayout whether the layout is private to the group
1415             * @param      layoutIdMap the layouts considered for publishing, specified
1416             *             by the layout IDs and booleans indicating whether they have
1417             *             children
1418             * @param      parameterMap the mapping of parameters indicating which
1419             *             information will be used. See {@link
1420             *             com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1421             * @param      groupName the group name (optionally {@link
1422             *             DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1423             *             DestinationNames}.
1424             * @param      cronText the cron text. See {@link
1425             *             com.liferay.portal.kernel.cal.RecurrenceSerializer
1426             *             #toCronText}
1427             * @param      schedulerStartDate the scheduler start date
1428             * @param      schedulerEndDate the scheduler end date
1429             * @param      description the scheduler description
1430             * @deprecated As of 7.0.0, replaced by {@link #schedulePublishToLive(long,
1431             *             long, boolean, long[], Map, String, Date, Date, String,
1432             *             String, Date, Date, String)}
1433             */
1434            @Deprecated
1435            @Override
1436            public void schedulePublishToLive(
1437                            long sourceGroupId, long targetGroupId, boolean privateLayout,
1438                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1439                            String scope, Date startDate, Date endDate, String groupName,
1440                            String cronText, Date schedulerStartDate, Date schedulerEndDate,
1441                            String description)
1442                    throws PortalException {
1443    
1444                    schedulePublishToLive(
1445                            sourceGroupId, targetGroupId, privateLayout,
1446                            ExportImportHelperUtil.getLayoutIds(layoutIdMap, targetGroupId),
1447                            parameterMap, groupName, cronText, schedulerStartDate,
1448                            schedulerEndDate, description);
1449            }
1450    
1451            /**
1452             * Schedules a range of layouts to be stored.
1453             *
1454             * @param sourceGroupId the primary key of the source group
1455             * @param privateLayout whether the layout is private to the group
1456             * @param layoutIdMap the layouts considered for publishing, specified by
1457             *        the layout IDs and booleans indicating whether they have children
1458             * @param parameterMap the mapping of parameters indicating which
1459             *        information will be used. See {@link
1460             *        com.liferay.exportimport.kernel.lar.PortletDataHandlerKeys}.
1461             * @param remoteAddress the remote address
1462             * @param remotePort the remote port
1463             * @param remotePathContext the remote path context
1464             * @param secureConnection whether the connection is secure
1465             * @param remoteGroupId the primary key of the remote group
1466             * @param remotePrivateLayout whether remote group's layout is private
1467             * @param startDate the start date
1468             * @param endDate the end date
1469             * @param groupName the group name. Optionally {@link
1470             *        DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1471             *        DestinationNames}.
1472             * @param cronText the cron text. See {@link
1473             *        com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText}
1474             * @param schedulerStartDate the scheduler start date
1475             * @param schedulerEndDate the scheduler end date
1476             * @param description the scheduler description
1477             */
1478            @Override
1479            public void schedulePublishToRemote(
1480                            long sourceGroupId, boolean privateLayout,
1481                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
1482                            String remoteAddress, int remotePort, String remotePathContext,
1483                            boolean secureConnection, long remoteGroupId,
1484                            boolean remotePrivateLayout, Date startDate, Date endDate,
1485                            String groupName, String cronText, Date schedulerStartDate,
1486                            Date schedulerEndDate, String description)
1487                    throws PortalException {
1488    
1489                    GroupPermissionUtil.check(
1490                            getPermissionChecker(), sourceGroupId, ActionKeys.PUBLISH_STAGING);
1491    
1492                    Trigger trigger = TriggerFactoryUtil.createTrigger(
1493                            PortalUUIDUtil.generate(), groupName, schedulerStartDate,
1494                            schedulerEndDate, cronText);
1495    
1496                    User user = userPersistence.findByPrimaryKey(getUserId());
1497    
1498                    Map<String, Serializable> publishLayoutRemoteSettingsMap =
1499                            ExportImportConfigurationSettingsMapFactory.
1500                                    buildPublishLayoutRemoteSettingsMap(
1501                                            getUserId(), sourceGroupId, privateLayout, layoutIdMap,
1502                                            parameterMap, remoteAddress, remotePort, remotePathContext,
1503                                            secureConnection, remoteGroupId, remotePrivateLayout,
1504                                            user.getLocale(), user.getTimeZone());
1505    
1506                    ExportImportConfiguration exportImportConfiguration =
1507                            exportImportConfigurationLocalService.
1508                                    addDraftExportImportConfiguration(
1509                                            getUserId(), description,
1510                                            ExportImportConfigurationConstants.
1511                                                    TYPE_SCHEDULED_PUBLISH_LAYOUT_REMOTE,
1512                                            publishLayoutRemoteSettingsMap);
1513    
1514                    SchedulerEngineHelperUtil.schedule(
1515                            trigger, StorageType.PERSISTED, description,
1516                            DestinationNames.LAYOUTS_REMOTE_PUBLISHER,
1517                            exportImportConfiguration.getExportImportConfigurationId(), 0);
1518            }
1519    
1520            /**
1521             * Sets the layouts for the group, replacing and prioritizing all layouts of
1522             * the parent layout.
1523             *
1524             * @param groupId the primary key of the group
1525             * @param privateLayout whether the layout is private to the group
1526             * @param parentLayoutId the primary key of the parent layout
1527             * @param layoutIds the primary keys of the layouts
1528             * @param serviceContext the service context to be applied
1529             */
1530            @Override
1531            public void setLayouts(
1532                            long groupId, boolean privateLayout, long parentLayoutId,
1533                            long[] layoutIds, ServiceContext serviceContext)
1534                    throws PortalException {
1535    
1536                    GroupPermissionUtil.check(
1537                            getPermissionChecker(), groupId, ActionKeys.UPDATE);
1538    
1539                    layoutLocalService.setLayouts(
1540                            groupId, privateLayout, parentLayoutId, layoutIds, serviceContext);
1541            }
1542    
1543            /**
1544             * Deletes the job from the scheduler's queue.
1545             *
1546             * @param groupId the primary key of the group
1547             * @param jobName the job name
1548             * @param groupName the group name (optionally {@link
1549             *        DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1550             *        DestinationNames}.
1551             */
1552            @Override
1553            public void unschedulePublishToLive(
1554                            long groupId, String jobName, String groupName)
1555                    throws PortalException {
1556    
1557                    GroupPermissionUtil.check(
1558                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1559    
1560                    SchedulerEngineHelperUtil.delete(
1561                            jobName, groupName, StorageType.PERSISTED);
1562            }
1563    
1564            /**
1565             * Deletes the job from the scheduler's persistent queue.
1566             *
1567             * @param groupId the primary key of the group
1568             * @param jobName the job name
1569             * @param groupName the group name (optionally {@link
1570             *        DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). See {@link
1571             *        DestinationNames}.
1572             */
1573            @Override
1574            public void unschedulePublishToRemote(
1575                            long groupId, String jobName, String groupName)
1576                    throws PortalException {
1577    
1578                    GroupPermissionUtil.check(
1579                            getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING);
1580    
1581                    SchedulerEngineHelperUtil.delete(
1582                            jobName, groupName, StorageType.PERSISTED);
1583            }
1584    
1585            @Override
1586            public Layout updateIconImage(long plid, byte[] bytes)
1587                    throws PortalException {
1588    
1589                    LayoutPermissionUtil.check(
1590                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1591    
1592                    return layoutLocalService.updateIconImage(plid, bytes);
1593            }
1594    
1595            /**
1596             * Updates the layout with additional parameters.
1597             *
1598             * @param  groupId the primary key of the group
1599             * @param  privateLayout whether the layout is private to the group
1600             * @param  layoutId the primary key of the layout
1601             * @param  parentLayoutId the primary key of the layout's new parent layout
1602             * @param  localeNamesMap the layout's locales and localized names
1603             * @param  localeTitlesMap the layout's locales and localized titles
1604             * @param  descriptionMap the locales and localized descriptions to merge
1605             *         (optionally <code>null</code>)
1606             * @param  keywordsMap the locales and localized keywords to merge
1607             *         (optionally <code>null</code>)
1608             * @param  robotsMap the locales and localized robots to merge (optionally
1609             *         <code>null</code>)
1610             * @param  type the layout's new type (optionally {@link
1611             *         LayoutConstants#TYPE_PORTLET})
1612             * @param  hidden whether the layout is hidden
1613             * @param  friendlyURLMap the layout's locales and localized friendly URLs.
1614             *         To see how the URL is normalized when accessed see {@link
1615             *         com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize(
1616             *         String)}.
1617             * @param  iconImage whether the icon image will be updated
1618             * @param  iconBytes the byte array of the layout's new icon image
1619             * @param  serviceContext the service context to be applied. Can set the
1620             *         modification date and expando bridge attributes for the layout.
1621             * @return the updated layout
1622             */
1623            @Override
1624            public Layout updateLayout(
1625                            long groupId, boolean privateLayout, long layoutId,
1626                            long parentLayoutId, Map<Locale, String> localeNamesMap,
1627                            Map<Locale, String> localeTitlesMap,
1628                            Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap,
1629                            Map<Locale, String> robotsMap, String type, boolean hidden,
1630                            Map<Locale, String> friendlyURLMap, boolean iconImage,
1631                            byte[] iconBytes, ServiceContext serviceContext)
1632                    throws PortalException {
1633    
1634                    LayoutPermissionUtil.check(
1635                            getPermissionChecker(), groupId, privateLayout, layoutId,
1636                            ActionKeys.UPDATE);
1637    
1638                    return layoutLocalService.updateLayout(
1639                            groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap,
1640                            localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type,
1641                            hidden, friendlyURLMap, iconImage, iconBytes, serviceContext);
1642            }
1643    
1644            /**
1645             * Updates the layout replacing its type settings.
1646             *
1647             * @param  groupId the primary key of the group
1648             * @param  privateLayout whether the layout is private to the group
1649             * @param  layoutId the primary key of the layout
1650             * @param  typeSettings the settings to load the unicode properties object.
1651             *         See {@link com.liferay.portal.kernel.util.UnicodeProperties
1652             *         #fastLoad(String)}.
1653             * @return the updated layout
1654             */
1655            @Override
1656            public Layout updateLayout(
1657                            long groupId, boolean privateLayout, long layoutId,
1658                            String typeSettings)
1659                    throws PortalException {
1660    
1661                    LayoutPermissionUtil.check(
1662                            getPermissionChecker(), groupId, privateLayout, layoutId,
1663                            ActionKeys.UPDATE);
1664    
1665                    return layoutLocalService.updateLayout(
1666                            groupId, privateLayout, layoutId, typeSettings);
1667            }
1668    
1669            /**
1670             * Updates the look and feel of the layout.
1671             *
1672             * @param  groupId the primary key of the group
1673             * @param  privateLayout whether the layout is private to the group
1674             * @param  layoutId the primary key of the layout
1675             * @param  themeId the primary key of the layout's new theme
1676             * @param  colorSchemeId the primary key of the layout's new color scheme
1677             * @param  css the layout's new CSS
1678             * @return the updated layout
1679             */
1680            @Override
1681            public Layout updateLookAndFeel(
1682                            long groupId, boolean privateLayout, long layoutId, String themeId,
1683                            String colorSchemeId, String css)
1684                    throws PortalException {
1685    
1686                    LayoutPermissionUtil.check(
1687                            getPermissionChecker(), groupId, privateLayout, layoutId,
1688                            ActionKeys.UPDATE);
1689    
1690                    if (Validator.isNotNull(themeId)) {
1691                            pluginSettingLocalService.checkPermission(
1692                                    getUserId(), themeId, Plugin.TYPE_THEME);
1693                    }
1694    
1695                    return layoutLocalService.updateLookAndFeel(
1696                            groupId, privateLayout, layoutId, themeId, colorSchemeId, css);
1697            }
1698    
1699            /**
1700             * Updates the name of the layout matching the group, layout ID, and
1701             * privacy.
1702             *
1703             * @param  groupId the primary key of the group
1704             * @param  privateLayout whether the layout is private to the group
1705             * @param  layoutId the primary key of the layout
1706             * @param  name the layout's new name
1707             * @param  languageId the primary key of the language. For more information
1708             *         see {@link Locale}.
1709             * @return the updated layout
1710             */
1711            @Override
1712            public Layout updateName(
1713                            long groupId, boolean privateLayout, long layoutId, String name,
1714                            String languageId)
1715                    throws PortalException {
1716    
1717                    LayoutPermissionUtil.check(
1718                            getPermissionChecker(), groupId, privateLayout, layoutId,
1719                            ActionKeys.UPDATE);
1720    
1721                    return layoutLocalService.updateName(
1722                            groupId, privateLayout, layoutId, name, languageId);
1723            }
1724    
1725            /**
1726             * Updates the name of the layout matching the primary key.
1727             *
1728             * @param  plid the primary key of the layout
1729             * @param  name the name to be assigned
1730             * @param  languageId the primary key of the language. For more information
1731             *         see {@link Locale}.
1732             * @return the updated layout
1733             */
1734            @Override
1735            public Layout updateName(long plid, String name, String languageId)
1736                    throws PortalException {
1737    
1738                    LayoutPermissionUtil.check(
1739                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1740    
1741                    return layoutLocalService.updateName(plid, name, languageId);
1742            }
1743    
1744            /**
1745             * Updates the parent layout ID of the layout matching the group, layout ID,
1746             * and privacy.
1747             *
1748             * @param  groupId the primary key of the group
1749             * @param  privateLayout whether the layout is private to the group
1750             * @param  layoutId the primary key of the layout
1751             * @param  parentLayoutId the primary key to be assigned to the parent
1752             *         layout
1753             * @return the matching layout
1754             */
1755            @Override
1756            public Layout updateParentLayoutId(
1757                            long groupId, boolean privateLayout, long layoutId,
1758                            long parentLayoutId)
1759                    throws PortalException {
1760    
1761                    LayoutPermissionUtil.check(
1762                            getPermissionChecker(), groupId, privateLayout, layoutId,
1763                            ActionKeys.UPDATE);
1764    
1765                    return layoutLocalService.updateParentLayoutId(
1766                            groupId, privateLayout, layoutId, parentLayoutId);
1767            }
1768    
1769            /**
1770             * Updates the parent layout ID of the layout matching the primary key. If a
1771             * layout matching the parent primary key is found, the layout ID of that
1772             * layout is assigned, otherwise {@link
1773             * LayoutConstants#DEFAULT_PARENT_LAYOUT_ID} is assigned.
1774             *
1775             * @param  plid the primary key of the layout
1776             * @param  parentPlid the primary key of the parent layout
1777             * @return the layout matching the primary key
1778             */
1779            @Override
1780            public Layout updateParentLayoutId(long plid, long parentPlid)
1781                    throws PortalException {
1782    
1783                    LayoutPermissionUtil.check(
1784                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1785    
1786                    return layoutLocalService.updateParentLayoutId(plid, parentPlid);
1787            }
1788    
1789            /**
1790             * Updates the parent layout ID and priority of the layout.
1791             *
1792             * @param  plid the primary key of the layout
1793             * @param  parentPlid the primary key of the parent layout
1794             * @param  priority the layout's new priority
1795             * @return the layout matching the primary key
1796             */
1797            @Override
1798            public Layout updateParentLayoutIdAndPriority(
1799                            long plid, long parentPlid, int priority)
1800                    throws PortalException {
1801    
1802                    LayoutPermissionUtil.check(
1803                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1804    
1805                    return layoutLocalService.updateParentLayoutIdAndPriority(
1806                            plid, parentPlid, priority);
1807            }
1808    
1809            /**
1810             * Updates the priority of the layout matching the group, layout ID, and
1811             * privacy.
1812             *
1813             * @param  groupId the primary key of the group
1814             * @param  privateLayout whether the layout is private to the group
1815             * @param  layoutId the primary key of the layout
1816             * @param  priority the layout's new priority
1817             * @return the updated layout
1818             */
1819            @Override
1820            public Layout updatePriority(
1821                            long groupId, boolean privateLayout, long layoutId, int priority)
1822                    throws PortalException {
1823    
1824                    LayoutPermissionUtil.check(
1825                            getPermissionChecker(), groupId, privateLayout, layoutId,
1826                            ActionKeys.UPDATE);
1827    
1828                    return layoutLocalService.updatePriority(
1829                            groupId, privateLayout, layoutId, priority);
1830            }
1831    
1832            /**
1833             * Updates the priority of the layout matching the group, layout ID, and
1834             * privacy, setting the layout's priority based on the priorities of the
1835             * next and previous layouts.
1836             *
1837             * @param  groupId the primary key of the group
1838             * @param  privateLayout whether the layout is private to the group
1839             * @param  layoutId the primary key of the layout
1840             * @param  nextLayoutId the primary key of the next layout
1841             * @param  previousLayoutId the primary key of the previous layout
1842             * @return the updated layout
1843             */
1844            @Override
1845            public Layout updatePriority(
1846                            long groupId, boolean privateLayout, long layoutId,
1847                            long nextLayoutId, long previousLayoutId)
1848                    throws PortalException {
1849    
1850                    LayoutPermissionUtil.check(
1851                            getPermissionChecker(), groupId, privateLayout, layoutId,
1852                            ActionKeys.UPDATE);
1853    
1854                    return layoutLocalService.updatePriority(
1855                            groupId, privateLayout, layoutId, nextLayoutId, previousLayoutId);
1856            }
1857    
1858            /**
1859             * Updates the priority of the layout matching the primary key.
1860             *
1861             * @param  plid the primary key of the layout
1862             * @param  priority the layout's new priority
1863             * @return the updated layout
1864             */
1865            @Override
1866            public Layout updatePriority(long plid, int priority)
1867                    throws PortalException {
1868    
1869                    LayoutPermissionUtil.check(
1870                            getPermissionChecker(), plid, ActionKeys.UPDATE);
1871    
1872                    return layoutLocalService.updatePriority(plid, priority);
1873            }
1874    
1875            /**
1876             * @deprecated As of 7.0.0, replaced by {@link
1877             *             com.liferay.exportimport.kernel.service.ExportImportService#validateImportLayoutsFile(
1878             *             ExportImportConfiguration, File)}
1879             */
1880            @Deprecated
1881            @Override
1882            public MissingReferences validateImportLayoutsFile(
1883                            ExportImportConfiguration exportImportConfiguration, File file)
1884                    throws PortalException {
1885    
1886                    Map<String, Serializable> settingsMap =
1887                            exportImportConfiguration.getSettingsMap();
1888    
1889                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
1890    
1891                    GroupPermissionUtil.check(
1892                            getPermissionChecker(), targetGroupId,
1893                            ActionKeys.EXPORT_IMPORT_LAYOUTS);
1894    
1895                    return layoutLocalService.validateImportLayoutsFile(
1896                            exportImportConfiguration, file);
1897            }
1898    
1899            /**
1900             * @deprecated As of 7.0.0, replaced by {@link
1901             *             com.liferay.exportimport.kernel.service.ExportImportService#validateImportLayoutsFile(
1902             *             ExportImportConfiguration, InputStream)}
1903             */
1904            @Deprecated
1905            @Override
1906            public MissingReferences validateImportLayoutsFile(
1907                            ExportImportConfiguration exportImportConfiguration,
1908                            InputStream inputStream)
1909                    throws PortalException {
1910    
1911                    Map<String, Serializable> settingsMap =
1912                            exportImportConfiguration.getSettingsMap();
1913    
1914                    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
1915    
1916                    GroupPermissionUtil.check(
1917                            getPermissionChecker(), targetGroupId,
1918                            ActionKeys.EXPORT_IMPORT_LAYOUTS);
1919    
1920                    return layoutLocalService.validateImportLayoutsFile(
1921                            exportImportConfiguration, inputStream);
1922            }
1923    
1924            /**
1925             * @deprecated As of 7.0.0, with no direct replacement
1926             */
1927            @Deprecated
1928            @Override
1929            public MissingReferences validateImportLayoutsFile(
1930                            long groupId, boolean privateLayout,
1931                            Map<String, String[]> parameterMap, File file)
1932                    throws PortalException {
1933    
1934                    GroupPermissionUtil.check(
1935                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1936    
1937                    return layoutLocalService.validateImportLayoutsFile(
1938                            getUserId(), groupId, privateLayout, parameterMap, file);
1939            }
1940    
1941            /**
1942             * @deprecated As of 7.0.0, with no direct replacement
1943             */
1944            @Deprecated
1945            @Override
1946            public MissingReferences validateImportLayoutsFile(
1947                            long groupId, boolean privateLayout,
1948                            Map<String, String[]> parameterMap, InputStream inputStream)
1949                    throws PortalException {
1950    
1951                    GroupPermissionUtil.check(
1952                            getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
1953    
1954                    return layoutLocalService.validateImportLayoutsFile(
1955                            getUserId(), groupId, privateLayout, parameterMap, inputStream);
1956            }
1957    
1958            /**
1959             * @deprecated As of 7.0.0, replaced by {@link
1960             *             com.liferay.exportimport.kernel.service.ExportImportService#validateImportPortletInfo(
1961             *             ExportImportConfiguration, File)}
1962             */
1963            @Deprecated
1964            @Override
1965            public MissingReferences validateImportPortletInfo(
1966                            ExportImportConfiguration exportImportConfiguration, File file)
1967                    throws PortalException {
1968    
1969                    Map<String, Serializable> settingsMap =
1970                            exportImportConfiguration.getSettingsMap();
1971    
1972                    long targetPlid = MapUtil.getLong(settingsMap, "targetPlid");
1973                    String portletId = MapUtil.getString(settingsMap, "portletId");
1974    
1975                    PortletPermissionUtil.check(
1976                            getPermissionChecker(), targetPlid, portletId,
1977                            ActionKeys.CONFIGURATION);
1978    
1979                    return layoutLocalService.validateImportPortletInfo(
1980                            exportImportConfiguration, file);
1981            }
1982    
1983            /**
1984             * @deprecated As of 7.0.0, replaced by {@link
1985             *             com.liferay.exportimport.kernel.service.ExportImportService#validateImportPortletInfo(
1986             *             ExportImportConfiguration, InputStream)}
1987             */
1988            @Deprecated
1989            @Override
1990            public MissingReferences validateImportPortletInfo(
1991                            ExportImportConfiguration exportImportConfiguration,
1992                            InputStream inputStream)
1993                    throws PortalException {
1994    
1995                    Map<String, Serializable> settingsMap =
1996                            exportImportConfiguration.getSettingsMap();
1997    
1998                    long targetPlid = MapUtil.getLong(settingsMap, "targetPlid");
1999                    String portletId = MapUtil.getString(settingsMap, "portletId");
2000    
2001                    PortletPermissionUtil.check(
2002                            getPermissionChecker(), targetPlid, portletId,
2003                            ActionKeys.CONFIGURATION);
2004    
2005                    return layoutLocalService.validateImportPortletInfo(
2006                            exportImportConfiguration, inputStream);
2007            }
2008    
2009            /**
2010             * @deprecated As of 7.0.0, with no direct replacement
2011             */
2012            @Deprecated
2013            @Override
2014            public MissingReferences validateImportPortletInfo(
2015                            long plid, long groupId, String portletId,
2016                            Map<String, String[]> parameterMap, File file)
2017                    throws PortalException {
2018    
2019                    PortletPermissionUtil.check(
2020                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
2021    
2022                    return layoutLocalService.validateImportPortletInfo(
2023                            getUserId(), plid, groupId, portletId, parameterMap, file);
2024            }
2025    
2026            /**
2027             * @deprecated As of 7.0.0, with no direct replacement
2028             */
2029            @Deprecated
2030            @Override
2031            public MissingReferences validateImportPortletInfo(
2032                            long plid, long groupId, String portletId,
2033                            Map<String, String[]> parameterMap, InputStream inputStream)
2034                    throws PortalException {
2035    
2036                    PortletPermissionUtil.check(
2037                            getPermissionChecker(), plid, portletId, ActionKeys.CONFIGURATION);
2038    
2039                    return layoutLocalService.validateImportPortletInfo(
2040                            getUserId(), plid, groupId, portletId, parameterMap, inputStream);
2041            }
2042    
2043            protected List<Layout> filterLayouts(List<Layout> layouts)
2044                    throws PortalException {
2045    
2046                    List<Layout> filteredLayouts = new ArrayList<>();
2047    
2048                    for (Layout layout : layouts) {
2049                            if (LayoutPermissionUtil.contains(
2050                                            getPermissionChecker(), layout, ActionKeys.VIEW)) {
2051    
2052                                    filteredLayouts.add(layout);
2053                            }
2054                    }
2055    
2056                    return filteredLayouts;
2057            }
2058    
2059    }