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