001 /** 002 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.service.impl; 016 017 import com.liferay.portal.NoSuchLayoutException; 018 import com.liferay.portal.kernel.cache.ThreadLocalCachable; 019 import com.liferay.portal.kernel.exception.PortalException; 020 import com.liferay.portal.kernel.exception.SystemException; 021 import com.liferay.portal.kernel.messaging.DestinationNames; 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.GetterUtil; 027 import com.liferay.portal.kernel.util.StringPool; 028 import com.liferay.portal.kernel.util.Validator; 029 import com.liferay.portal.kernel.uuid.PortalUUIDUtil; 030 import com.liferay.portal.messaging.LayoutsLocalPublisherRequest; 031 import com.liferay.portal.messaging.LayoutsRemotePublisherRequest; 032 import com.liferay.portal.model.Group; 033 import com.liferay.portal.model.Layout; 034 import com.liferay.portal.model.LayoutConstants; 035 import com.liferay.portal.model.LayoutReference; 036 import com.liferay.portal.model.LayoutTypePortlet; 037 import com.liferay.portal.model.Plugin; 038 import com.liferay.portal.security.permission.ActionKeys; 039 import com.liferay.portal.security.permission.PermissionChecker; 040 import com.liferay.portal.service.ServiceContext; 041 import com.liferay.portal.service.base.LayoutServiceBaseImpl; 042 import com.liferay.portal.service.permission.GroupPermissionUtil; 043 import com.liferay.portal.service.permission.LayoutPermissionUtil; 044 import com.liferay.portal.util.PortletKeys; 045 import com.liferay.portlet.PortletPreferencesFactoryUtil; 046 047 import java.io.File; 048 import java.io.InputStream; 049 050 import java.util.ArrayList; 051 import java.util.Date; 052 import java.util.List; 053 import java.util.Locale; 054 import java.util.Map; 055 056 /** 057 * Provides the remote service for accessing, adding, deleting, exporting, 058 * importing, scheduling publishing of, and updating layouts. Its methods 059 * include permission checks. 060 * 061 * @author Brian Wing Shun Chan 062 * @author Wesley Gong 063 */ 064 public class LayoutServiceImpl extends LayoutServiceBaseImpl { 065 066 /** 067 * Adds a layout with additional parameters. 068 * 069 * <p> 070 * This method handles the creation of the layout including its resources, 071 * metadata, and internal data structures. It is not necessary to make 072 * subsequent calls to any methods to setup default groups, resources, ... 073 * etc. 074 * </p> 075 * 076 * @param groupId the primary key of the group 077 * @param privateLayout whether the layout is private to the group 078 * @param parentLayoutId the primary key of the parent layout (optionally 079 * {@link 080 * com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID}) 081 * @param localeNamesMap the layout's locales and localized names 082 * @param localeTitlesMap the layout's locales and localized titles 083 * @param descriptionMap the layout's locales and localized descriptions 084 * @param keywordsMap the layout's locales and localized keywords 085 * @param robotsMap the layout's locales and localized robots 086 * @param type the layout's type (optionally {@link 087 * com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}). The 088 * possible types can be found in {@link 089 * com.liferay.portal.model.LayoutConstants}. 090 * @param hidden whether the layout is hidden 091 * @param friendlyURL the layout's friendly URL (optionally {@link 092 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PRIVATE_LAYOUT_FRIENDLY_URL} 093 * or {@link 094 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL}). 095 * The default values can be overridden in 096 * <code>portal-ext.properties</code> by specifying new values for 097 * the corresponding properties defined in {@link 098 * com.liferay.portal.util.PropsValues}. To see how the URL is 099 * normalized when accessed see {@link 100 * com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize( 101 * String)}. 102 * @param serviceContext the service context to be applied. Must set the 103 * UUID for the layout. Can set the creation date, modification date 104 * and the expando bridge attributes for the layout. For layouts 105 * that belong to a layout set prototype, an attribute named 106 * 'layoutUpdateable' can be used to specify whether site 107 * administrators can modify this page within their site. 108 * @return the layout 109 * @throws PortalException if a group with the primary key could not be 110 * found, if the group did not have permission to manage the layouts 111 * involved, or if layout values were invalid 112 * @throws SystemException if a system exception occurred 113 */ 114 public Layout addLayout( 115 long groupId, boolean privateLayout, long parentLayoutId, 116 Map<Locale, String> localeNamesMap, 117 Map<Locale, String> localeTitlesMap, 118 Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap, 119 Map<Locale, String> robotsMap, String type, boolean hidden, 120 String friendlyURL, ServiceContext serviceContext) 121 throws PortalException, SystemException { 122 123 PermissionChecker permissionChecker = getPermissionChecker(); 124 125 if (parentLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) { 126 GroupPermissionUtil.check( 127 permissionChecker, groupId, ActionKeys.ADD_LAYOUT); 128 } 129 else { 130 LayoutPermissionUtil.check( 131 permissionChecker, groupId, privateLayout, parentLayoutId, 132 ActionKeys.ADD_LAYOUT); 133 } 134 135 return layoutLocalService.addLayout( 136 getUserId(), groupId, privateLayout, parentLayoutId, localeNamesMap, 137 localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type, 138 hidden, friendlyURL, serviceContext); 139 } 140 141 /** 142 * Adds a layout with single entry maps for name, title, and description to 143 * the default locale. 144 * 145 * <p> 146 * This method handles the creation of the layout including its resources, 147 * metadata, and internal data structures. It is not necessary to make 148 * subsequent calls to any methods to setup default groups, resources, ... 149 * etc. 150 * </p> 151 * 152 * @param groupId the primary key of the group 153 * @param privateLayout whether the layout is private to the group 154 * @param parentLayoutId the primary key of the parent layout (optionally 155 * {@link 156 * com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID}) 157 * @param name Map the layout's locales and localized names 158 * @param title Map the layout's locales and localized titles 159 * @param description Map the layout's locales and localized descriptions 160 * @param type the layout's type (optionally {@link 161 * com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}). The 162 * possible types can be found in {@link 163 * com.liferay.portal.model.LayoutConstants}. 164 * @param hidden whether the layout is hidden 165 * @param friendlyURL the layout's friendly URL (optionally {@link 166 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PRIVATE_LAYOUT_FRIENDLY_URL} 167 * or {@link 168 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL}). 169 * The default values can be overridden in 170 * <code>portal-ext.properties</code> by specifying new values for 171 * the corresponding properties defined in {@link 172 * com.liferay.portal.util.PropsValues}. To see how the URL is 173 * normalized when accessed see {@link 174 * com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize( 175 * String)}. 176 * @param serviceContext the service context to be applied. Must set the 177 * UUID for the layout. Can specify the creation date, modification 178 * date and the expando bridge attributes for the layout. For 179 * layouts that belong to a layout set prototype, an attribute named 180 * 'layoutUpdateable' can be used to specify whether site 181 * administrators can modify this page within their site. 182 * @return the layout 183 * @throws PortalException if a group with the primary key could not be 184 * found, if the group did not have permission to manage the layouts 185 * involved, or if layout values were invalid 186 * @throws SystemException if a system exception occurred 187 */ 188 public Layout addLayout( 189 long groupId, boolean privateLayout, long parentLayoutId, 190 String name, String title, String description, String type, 191 boolean hidden, String friendlyURL, ServiceContext serviceContext) 192 throws PortalException, SystemException { 193 194 PermissionChecker permissionChecker = getPermissionChecker(); 195 196 if (parentLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) { 197 GroupPermissionUtil.check( 198 permissionChecker, groupId, ActionKeys.ADD_LAYOUT); 199 } 200 else { 201 LayoutPermissionUtil.check( 202 permissionChecker, groupId, privateLayout, parentLayoutId, 203 ActionKeys.ADD_LAYOUT); 204 } 205 206 return layoutLocalService.addLayout( 207 getUserId(), groupId, privateLayout, parentLayoutId, name, title, 208 description, type, hidden, friendlyURL, serviceContext); 209 } 210 211 /** 212 * Deletes the layout with the primary key, also deleting the layout's child 213 * layouts, and associated resources. 214 * 215 * @param groupId the primary key of the group 216 * @param privateLayout whether the layout is private to the group 217 * @param layoutId the primary key of the layout 218 * @param serviceContext the service context to be applied 219 * @throws PortalException if the user did not have permission to delete the 220 * layout, if a matching layout could not be found , or if some 221 * other portal exception occurred 222 * @throws SystemException if a system exception occurred 223 */ 224 public void deleteLayout( 225 long groupId, boolean privateLayout, long layoutId, 226 ServiceContext serviceContext) 227 throws PortalException, SystemException { 228 229 LayoutPermissionUtil.check( 230 getPermissionChecker(), groupId, privateLayout, layoutId, 231 ActionKeys.DELETE); 232 233 layoutLocalService.deleteLayout( 234 groupId, privateLayout, layoutId, serviceContext); 235 } 236 237 /** 238 * Deletes the layout with the plid, also deleting the layout's child 239 * layouts, and associated resources. 240 * 241 * @param plid the primary key of the layout 242 * @param serviceContext the service context to be applied 243 * @throws PortalException if the user did not have permission to delete the 244 * layout, if a layout with the primary key could not be found , or 245 * if some other portal exception occurred 246 * @throws SystemException if a system exception occurred 247 */ 248 public void deleteLayout(long plid, ServiceContext serviceContext) 249 throws PortalException, SystemException { 250 251 LayoutPermissionUtil.check( 252 getPermissionChecker(), plid, ActionKeys.DELETE); 253 254 layoutLocalService.deleteLayout(plid, serviceContext); 255 } 256 257 /** 258 * Exports the layouts that match the primary keys and the criteria as a 259 * byte array. 260 * 261 * @param groupId the primary key of the group 262 * @param privateLayout whether the layout is private to the group 263 * @param layoutIds the primary keys of the layouts to be exported 264 * @param parameterMap the mapping of parameters indicating which 265 * information to export. For information on the keys used in the 266 * map see {@link 267 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 268 * @param startDate the export's start date 269 * @param endDate the export's end date 270 * @return the layouts as a byte array 271 * @throws PortalException if a group or any layout with the primary key 272 * could not be found, if the group did not have permission to 273 * manage the layouts, or if some other portal exception occurred 274 * @throws SystemException if a system exception occurred 275 */ 276 public byte[] exportLayouts( 277 long groupId, boolean privateLayout, long[] layoutIds, 278 Map<String, String[]> parameterMap, Date startDate, Date endDate) 279 throws PortalException, SystemException { 280 281 GroupPermissionUtil.check( 282 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 283 284 return layoutLocalService.exportLayouts( 285 groupId, privateLayout, layoutIds, parameterMap, startDate, 286 endDate); 287 } 288 289 /** 290 * Exports all layouts that match the criteria as a byte array. 291 * 292 * @param groupId the primary key of the group 293 * @param privateLayout whether the layout is private to the group 294 * @param parameterMap the mapping of parameters indicating which 295 * information to export. For information on the keys used in the 296 * map see {@link 297 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 298 * @param startDate the export's start date 299 * @param endDate the export's end date 300 * @return the layout as a byte array 301 * @throws PortalException if a group with the primary key could not be 302 * found, if the group did not have permission to manage the 303 * layouts, or if some other portal exception occurred 304 * @throws SystemException if a system exception occurred 305 */ 306 public byte[] exportLayouts( 307 long groupId, boolean privateLayout, 308 Map<String, String[]> parameterMap, Date startDate, Date endDate) 309 throws PortalException, SystemException { 310 311 GroupPermissionUtil.check( 312 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 313 314 return layoutLocalService.exportLayouts( 315 groupId, privateLayout, parameterMap, startDate, endDate); 316 } 317 318 /** 319 * Exports all layouts that match the primary keys and criteria as a file. 320 * 321 * @param groupId the primary key of the group 322 * @param privateLayout whether the layout is private to the group 323 * @param layoutIds the primary keys of the layouts to be exported 324 * (optionally <code>null</code>) 325 * @param parameterMap the mapping of parameters indicating which 326 * information to export. For information on the keys used in the 327 * map see {@link 328 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 329 * @param startDate the export's start date 330 * @param endDate the export's end date 331 * @return the layouts as a File 332 * @throws PortalException if a group or any layout with the primary key 333 * could not be found, it the group did not have permission to 334 * manage the layouts, or if some other portal exception occurred 335 * @throws SystemException if a system exception occurred 336 */ 337 public File exportLayoutsAsFile( 338 long groupId, boolean privateLayout, long[] layoutIds, 339 Map<String, String[]> parameterMap, Date startDate, Date endDate) 340 throws PortalException, SystemException { 341 342 GroupPermissionUtil.check( 343 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 344 345 return layoutLocalService.exportLayoutsAsFile( 346 groupId, privateLayout, layoutIds, parameterMap, startDate, 347 endDate); 348 } 349 350 /** 351 * Exports the portlet information (categories, permissions, ... etc.) as a 352 * byte array. 353 * 354 * @param plid the primary key of the layout 355 * @param groupId the primary key of the group 356 * @param portletId the primary key of the portlet 357 * @param parameterMap the mapping of parameters indicating which 358 * information to export. For information on the keys used in the 359 * map see {@link 360 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 361 * @param startDate the export's start date 362 * @param endDate the export's end date 363 * @return the portlet information as a byte array 364 * @throws PortalException if a layout, group, or portlet with the primary 365 * key could not be found, if the group did not have permission to 366 * manage the layouts involved, or if some other portal exception 367 * occurred 368 * @throws SystemException if a system exception occurred 369 */ 370 public byte[] exportPortletInfo( 371 long plid, long groupId, String portletId, 372 Map<String, String[]> parameterMap, Date startDate, Date endDate) 373 throws PortalException, SystemException { 374 375 Layout layout = layoutLocalService.getLayout(plid); 376 377 GroupPermissionUtil.check( 378 getPermissionChecker(), layout.getGroupId(), 379 ActionKeys.EXPORT_IMPORT_PORTLET_INFO); 380 381 return layoutLocalService.exportPortletInfo( 382 plid, groupId, portletId, parameterMap, startDate, endDate); 383 } 384 385 /** 386 * Exports the portlet information (categories, permissions, ... etc.) as a 387 * file. 388 * 389 * @param plid the primary key of the layout 390 * @param groupId the primary key of the group 391 * @param portletId the primary key of the portlet 392 * @param parameterMap the mapping of parameters indicating which 393 * information to export. For information on the keys used in the 394 * map see {@link 395 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 396 * @param startDate the export's start date 397 * @param endDate the export's end date 398 * @return the portlet information as a file 399 * @throws PortalException if a layout, group, or portlet with the primary 400 * key could not be found, it the group did not have permission to 401 * manage the layouts involved, or if some other portal exception 402 * occurred 403 * @throws SystemException if a system exception occurred 404 */ 405 public File exportPortletInfoAsFile( 406 long plid, long groupId, String portletId, 407 Map<String, String[]> parameterMap, Date startDate, Date endDate) 408 throws PortalException, SystemException { 409 410 Layout layout = layoutLocalService.getLayout(plid); 411 412 GroupPermissionUtil.check( 413 getPermissionChecker(), layout.getGroupId(), 414 ActionKeys.EXPORT_IMPORT_PORTLET_INFO); 415 416 return layoutLocalService.exportPortletInfoAsFile( 417 plid, groupId, portletId, parameterMap, startDate, endDate); 418 } 419 420 /** 421 * Returns all the ancestor layouts of the layout. 422 * 423 * @param plid the primary key of the layout 424 * @return the ancestor layouts of the layout 425 * @throws PortalException if a matching layout could not be found or if a 426 * portal exception occurred 427 * @throws SystemException if a system exception occurred 428 */ 429 public List<Layout> getAncestorLayouts(long plid) 430 throws PortalException, SystemException { 431 432 Layout layout = layoutLocalService.getLayout(plid); 433 434 List<Layout> ancestors = layout.getAncestors(); 435 436 return filterLayouts(ancestors); 437 } 438 439 /** 440 * Returns the primary key of the default layout for the group. 441 * 442 * @param groupId the primary key of the group 443 * @param scopeGroupId the primary key of the scope group. See {@link 444 * com.liferay.portal.service.ServiceContext#getScopeGroupId()}. 445 * @param privateLayout whether the layout is private to the group 446 * @param portletId the primary key of the portlet 447 * @return Returns the primary key of the default layout group; {@link 448 * com.liferay.portal.model.LayoutConstants#DEFAULT_PLID} otherwise 449 * @throws PortalException if a group, layout, or portlet with the primary 450 * key could not be found 451 * @throws SystemException if a system exception occurred 452 */ 453 public long getDefaultPlid( 454 long groupId, long scopeGroupId, boolean privateLayout, 455 String portletId) 456 throws PortalException, SystemException { 457 458 if (groupId <= 0) { 459 return LayoutConstants.DEFAULT_PLID; 460 } 461 462 PermissionChecker permissionChecker = getPermissionChecker(); 463 464 String scopeGroupLayoutUuid = null; 465 466 Group scopeGroup = groupLocalService.getGroup(scopeGroupId); 467 468 if (scopeGroup.isLayout()) { 469 Layout scopeGroupLayout = layoutLocalService.getLayout( 470 scopeGroup.getClassPK()); 471 472 scopeGroupLayoutUuid = scopeGroupLayout.getUuid(); 473 } 474 475 Map<Long, javax.portlet.PortletPreferences> jxPreferencesMap = 476 PortletPreferencesFactoryUtil.getPortletSetupMap( 477 scopeGroup.getCompanyId(), groupId, 478 PortletKeys.PREFS_OWNER_ID_DEFAULT, 479 PortletKeys.PREFS_OWNER_TYPE_LAYOUT, portletId, privateLayout); 480 481 for (Map.Entry<Long, javax.portlet.PortletPreferences> entry : 482 jxPreferencesMap.entrySet()) { 483 484 long plid = entry.getKey(); 485 486 Layout layout = null; 487 488 try { 489 layout = layoutLocalService.getLayout(plid); 490 } 491 catch (NoSuchLayoutException nsle) { 492 continue; 493 } 494 495 if (!LayoutPermissionUtil.contains( 496 permissionChecker, layout, ActionKeys.VIEW)) { 497 498 continue; 499 } 500 501 if (!layout.isTypePortlet()) { 502 continue; 503 } 504 505 LayoutTypePortlet layoutTypePortlet = 506 (LayoutTypePortlet)layout.getLayoutType(); 507 508 if (!layoutTypePortlet.hasPortletId(portletId)) { 509 continue; 510 } 511 512 javax.portlet.PortletPreferences jxPreferences = entry.getValue(); 513 514 String scopeType = GetterUtil.getString( 515 jxPreferences.getValue("lfrScopeType", null)); 516 517 if (scopeGroup.isLayout()) { 518 String scopeLayoutUuid = GetterUtil.getString( 519 jxPreferences.getValue("lfrScopeLayoutUuid", null)); 520 521 if (Validator.isNotNull(scopeType) && 522 Validator.isNotNull(scopeLayoutUuid) && 523 scopeLayoutUuid.equals(scopeGroupLayoutUuid)) { 524 525 return layout.getPlid(); 526 } 527 } 528 else if (scopeGroup.isCompany()) { 529 if (Validator.isNotNull(scopeType) && 530 scopeType.equals("company")) { 531 532 return layout.getPlid(); 533 } 534 } 535 else { 536 if (Validator.isNull(scopeType)) { 537 return layout.getPlid(); 538 } 539 } 540 } 541 542 return LayoutConstants.DEFAULT_PLID; 543 } 544 545 @ThreadLocalCachable 546 public long getDefaultPlid( 547 long groupId, long scopeGroupId, String portletId) 548 throws PortalException, SystemException { 549 550 long plid = getDefaultPlid(groupId, scopeGroupId, false, portletId); 551 552 if (plid == 0) { 553 plid = getDefaultPlid(groupId, scopeGroupId, true, portletId); 554 } 555 556 return plid; 557 } 558 559 /** 560 * Returns the layout matching the UUID, group, and privacy. 561 * 562 * @param uuid the layout's UUID 563 * @param groupId the primary key of the group 564 * @param privateLayout whether the layout is private to the group 565 * @return the matching layout 566 * @throws PortalException if a matching layout could not be found, if the 567 * user did not have permission to view the layout, or if some other 568 * portal exception occurred 569 * @throws SystemException if a system exception occurred 570 */ 571 public Layout getLayoutByUuidAndGroupId( 572 String uuid, long groupId, boolean privateLayout) 573 throws PortalException, SystemException { 574 575 Layout layout = layoutLocalService.getLayoutByUuidAndGroupId( 576 uuid, groupId, privateLayout); 577 578 LayoutPermissionUtil.check( 579 getPermissionChecker(), layout, ActionKeys.VIEW); 580 581 return layout; 582 } 583 584 /** 585 * Returns the name of the layout. 586 * 587 * @param groupId the primary key of the group 588 * @param privateLayout whether the layout is private to the group 589 * @param layoutId the primary key of the layout 590 * @param languageId the primary key of the language. For more information 591 * See {@link java.util.Locale}. 592 * @return the layout's name 593 * @throws PortalException if a matching layout could not be found 594 * @throws SystemException if a system exception occurred 595 */ 596 public String getLayoutName( 597 long groupId, boolean privateLayout, long layoutId, 598 String languageId) 599 throws PortalException, SystemException { 600 601 Layout layout = layoutLocalService.getLayout( 602 groupId, privateLayout, layoutId); 603 604 return layout.getName(languageId); 605 } 606 607 /** 608 * Returns the layout references for all the layouts that belong to the 609 * company and belong to the portlet that matches the preferences. 610 * 611 * @param companyId the primary key of the company 612 * @param portletId the primary key of the portlet 613 * @param preferencesKey the portlet's preference key 614 * @param preferencesValue the portlet's preference value 615 * @return the layout references of the matching layouts 616 * @throws SystemException if a system exception occurred 617 */ 618 public LayoutReference[] getLayoutReferences( 619 long companyId, String portletId, String preferencesKey, 620 String preferencesValue) 621 throws SystemException { 622 623 return layoutLocalService.getLayouts( 624 companyId, portletId, preferencesKey, preferencesValue); 625 } 626 627 public List<Layout> getLayouts(long groupId, boolean privateLayout) 628 throws SystemException { 629 630 return layoutPersistence.filterFindByG_P(groupId, privateLayout); 631 } 632 633 public List<Layout> getLayouts( 634 long groupId, boolean privateLayout, long parentLayoutId) 635 throws SystemException { 636 637 return layoutPersistence.filterFindByG_P_P( 638 groupId, privateLayout, parentLayoutId); 639 } 640 641 public List<Layout> getLayouts( 642 long groupId, boolean privateLayout, long parentLayoutId, 643 boolean incomplete, int start, int end) 644 throws PortalException, SystemException { 645 646 List<Layout> layouts = layoutLocalService.getLayouts( 647 groupId, privateLayout, parentLayoutId, incomplete, start, end); 648 649 return filterLayouts(layouts); 650 } 651 652 /** 653 * Imports the layouts from the byte array. 654 * 655 * @param groupId the primary key of the group 656 * @param privateLayout whether the layout is private to the group 657 * @param parameterMap the mapping of parameters indicating which 658 * information will be imported. For information on the keys used in 659 * the map see {@link 660 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 661 * @param bytes the byte array with the data 662 * @throws PortalException if a group with the primary key could not be 663 * found, if the group did not have permission to manage the 664 * layouts, or if some other portal exception occurred 665 * @throws SystemException if a system exception occurred 666 * @see com.liferay.portal.lar.LayoutImporter 667 */ 668 public void importLayouts( 669 long groupId, boolean privateLayout, 670 Map<String, String[]> parameterMap, byte[] bytes) 671 throws PortalException, SystemException { 672 673 GroupPermissionUtil.check( 674 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 675 676 layoutLocalService.importLayouts( 677 getUserId(), groupId, privateLayout, parameterMap, bytes); 678 } 679 680 /** 681 * Imports the layouts from the file. 682 * 683 * @param groupId the primary key of the group 684 * @param privateLayout whether the layout is private to the group 685 * @param parameterMap the mapping of parameters indicating which 686 * information will be imported. For information on the keys used in 687 * the map see {@link 688 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 689 * @param file the LAR file with the data 690 * @throws PortalException if a group with the primary key could not be 691 * found, if the group did not have permission to manage the layouts 692 * and publish, or if some other portal exception occurred 693 * @throws SystemException if a system exception occurred 694 * @see com.liferay.portal.lar.LayoutImporter 695 */ 696 public void importLayouts( 697 long groupId, boolean privateLayout, 698 Map<String, String[]> parameterMap, File file) 699 throws PortalException, SystemException { 700 701 GroupPermissionUtil.check( 702 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 703 704 layoutLocalService.importLayouts( 705 getUserId(), groupId, privateLayout, parameterMap, file); 706 } 707 708 /** 709 * Imports the layouts from the input stream. 710 * 711 * @param groupId the primary key of the group 712 * @param privateLayout whether the layout is private to the group 713 * @param parameterMap the mapping of parameters indicating which 714 * information will be imported. For information on the keys used in 715 * the map see {@link 716 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 717 * @param is the input stream 718 * @throws PortalException if a group with the primary key could not be 719 * found, if the group did not have permission to manage the 720 * layouts, or if some other portal exception occurred 721 * @throws SystemException if a system exception occurred 722 * @see com.liferay.portal.lar.LayoutImporter 723 */ 724 public void importLayouts( 725 long groupId, boolean privateLayout, 726 Map<String, String[]> parameterMap, InputStream is) 727 throws PortalException, SystemException { 728 729 GroupPermissionUtil.check( 730 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS); 731 732 layoutLocalService.importLayouts( 733 getUserId(), groupId, privateLayout, parameterMap, is); 734 } 735 736 /** 737 * Imports the portlet information (categories, permissions, ... etc.) from 738 * the file. 739 * 740 * @param plid the primary key of the layout 741 * @param groupId the primary key of the group 742 * @param portletId the primary key of the portlet 743 * @param parameterMap the mapping of parameters indicating which 744 * information will be imported. For information on the keys used in 745 * the map see {@link 746 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 747 * @param file the LAR file with the data 748 * @throws PortalException if a group, layout, or portlet with the primary 749 * key could not be found, or if the group did not have permission 750 * to manage the layouts 751 * @throws SystemException if a system exception occurred 752 */ 753 public void importPortletInfo( 754 long plid, long groupId, String portletId, 755 Map<String, String[]> parameterMap, File file) 756 throws PortalException, SystemException { 757 758 GroupPermissionUtil.check( 759 getPermissionChecker(), groupId, 760 ActionKeys.EXPORT_IMPORT_PORTLET_INFO); 761 762 layoutLocalService.importPortletInfo( 763 getUserId(), plid, groupId, portletId, parameterMap, file); 764 } 765 766 /** 767 * Imports the portlet information (categories, permissions, ... etc.) from 768 * the input stream. 769 * 770 * @param plid the primary key of the layout 771 * @param groupId the primary key of the group 772 * @param portletId the primary key of the portlet 773 * @param parameterMap the mapping of parameters indicating which 774 * information will be imported. For information on the keys used in 775 * the map see {@link 776 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys}. 777 * @param is the input stream 778 * @throws PortalException if a group, portlet, or layout with the primary 779 * key could not be found or if the group did not have permission to 780 * manage the layouts 781 * @throws SystemException if a system exception occurred 782 */ 783 public void importPortletInfo( 784 long plid, long groupId, String portletId, 785 Map<String, String[]> parameterMap, InputStream is) 786 throws PortalException, SystemException { 787 788 GroupPermissionUtil.check( 789 getPermissionChecker(), groupId, 790 ActionKeys.EXPORT_IMPORT_PORTLET_INFO); 791 792 layoutLocalService.importPortletInfo( 793 getUserId(), plid, groupId, portletId, parameterMap, is); 794 } 795 796 /** 797 * Schedules a range of layouts to be published. 798 * 799 * @param sourceGroupId the primary key of the source group 800 * @param targetGroupId the primary key of the target group 801 * @param privateLayout whether the layout is private to the group 802 * @param layoutIdMap the layouts considered for publishing, specified by 803 * the layout IDs and booleans indicating whether they have children 804 * @param parameterMap the mapping of parameters indicating which 805 * information will be used. See {@link 806 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys} 807 * @param scope the scope of the pages. It can be <code>all-pages</code> or 808 * <code>selected-pages</code>. 809 * @param startDate the start date 810 * @param endDate the end date 811 * @param groupName the group name (optionally {@link 812 * com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). 813 * See {@link com.liferay.portal.kernel.messaging.DestinationNames}. 814 * @param cronText the cron text. See {@link 815 * com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText} 816 * @param schedulerStartDate the scheduler start date 817 * @param schedulerEndDate the scheduler end date 818 * @param description the scheduler description 819 * @throws PortalException if the group did not have permission to manage 820 * and publish 821 * @throws SystemException if a system exception occurred 822 */ 823 public void schedulePublishToLive( 824 long sourceGroupId, long targetGroupId, boolean privateLayout, 825 Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap, 826 String scope, Date startDate, Date endDate, String groupName, 827 String cronText, Date schedulerStartDate, Date schedulerEndDate, 828 String description) 829 throws PortalException, SystemException { 830 831 GroupPermissionUtil.check( 832 getPermissionChecker(), targetGroupId, ActionKeys.PUBLISH_STAGING); 833 834 String jobName = PortalUUIDUtil.generate(); 835 836 Trigger trigger = new CronTrigger( 837 jobName, groupName, schedulerStartDate, schedulerEndDate, cronText); 838 839 String command = StringPool.BLANK; 840 841 if (scope.equals("all-pages")) { 842 command = LayoutsLocalPublisherRequest.COMMAND_ALL_PAGES; 843 } 844 else if (scope.equals("selected-pages")) { 845 command = LayoutsLocalPublisherRequest.COMMAND_SELECTED_PAGES; 846 } 847 848 LayoutsLocalPublisherRequest publisherRequest = 849 new LayoutsLocalPublisherRequest( 850 command, getUserId(), sourceGroupId, targetGroupId, 851 privateLayout, layoutIdMap, parameterMap, startDate, endDate); 852 853 SchedulerEngineHelperUtil.schedule( 854 trigger, StorageType.PERSISTED, description, 855 DestinationNames.LAYOUTS_LOCAL_PUBLISHER, publisherRequest, 0); 856 } 857 858 /** 859 * Schedules a range of layouts to be stored. 860 * 861 * @param sourceGroupId the primary key of the source group 862 * @param privateLayout whether the layout is private to the group 863 * @param layoutIdMap the layouts considered for publishing, specified by 864 * the layout IDs and booleans indicating whether they have children 865 * @param parameterMap the mapping of parameters indicating which 866 * information will be used. See {@link 867 * com.liferay.portal.kernel.lar.PortletDataHandlerKeys} 868 * @param remoteAddress the remote address 869 * @param remotePort the remote port 870 * @param remotePathContext the remote path context 871 * @param secureConnection whether the connection is secure 872 * @param remoteGroupId the primary key of the remote group 873 * @param remotePrivateLayout whether remote group's layout is private 874 * @param startDate the start date 875 * @param endDate the end date 876 * @param groupName the group name. Optionally {@link 877 * com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). 878 * See {@link com.liferay.portal.kernel.messaging.DestinationNames}. 879 * @param cronText the cron text. See {@link 880 * com.liferay.portal.kernel.cal.RecurrenceSerializer #toCronText} 881 * @param schedulerStartDate the scheduler start date 882 * @param schedulerEndDate the scheduler end date 883 * @param description the scheduler description 884 * @throws PortalException if a group with the source group primary key was 885 * not found or if the group did not have permission to publish 886 * @throws SystemException if a system exception occurred 887 */ 888 public void schedulePublishToRemote( 889 long sourceGroupId, boolean privateLayout, 890 Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap, 891 String remoteAddress, int remotePort, String remotePathContext, 892 boolean secureConnection, long remoteGroupId, 893 boolean remotePrivateLayout, Date startDate, Date endDate, 894 String groupName, String cronText, Date schedulerStartDate, 895 Date schedulerEndDate, String description) 896 throws PortalException, SystemException { 897 898 GroupPermissionUtil.check( 899 getPermissionChecker(), sourceGroupId, ActionKeys.PUBLISH_STAGING); 900 901 LayoutsRemotePublisherRequest publisherRequest = 902 new LayoutsRemotePublisherRequest( 903 getUserId(), sourceGroupId, privateLayout, layoutIdMap, 904 parameterMap, remoteAddress, remotePort, remotePathContext, 905 secureConnection, remoteGroupId, remotePrivateLayout, startDate, 906 endDate); 907 908 String jobName = PortalUUIDUtil.generate(); 909 910 Trigger trigger = new CronTrigger( 911 jobName, groupName, schedulerStartDate, schedulerEndDate, cronText); 912 913 SchedulerEngineHelperUtil.schedule( 914 trigger, StorageType.PERSISTED, description, 915 DestinationNames.LAYOUTS_REMOTE_PUBLISHER, publisherRequest, 0); 916 } 917 918 /** 919 * Sets the layouts for the group, replacing and prioritizing all layouts of 920 * the parent layout. 921 * 922 * @param groupId the primary key of the group 923 * @param privateLayout whether the layout is private to the group 924 * @param parentLayoutId the primary key of the parent layout 925 * @param layoutIds the primary keys of the layouts 926 * @param serviceContext the service context to be applied 927 * @throws PortalException if a group or layout with the primary key could 928 * not be found, if the group did not have permission to manage the 929 * layouts, if no layouts were specified, if the first layout was 930 * not page-able, if the first layout was hidden, or if some other 931 * portal exception occurred 932 * @throws SystemException if a system exception occurred 933 */ 934 public void setLayouts( 935 long groupId, boolean privateLayout, long parentLayoutId, 936 long[] layoutIds, ServiceContext serviceContext) 937 throws PortalException, SystemException { 938 939 GroupPermissionUtil.check( 940 getPermissionChecker(), groupId, ActionKeys.UPDATE); 941 942 layoutLocalService.setLayouts( 943 groupId, privateLayout, parentLayoutId, layoutIds, serviceContext); 944 } 945 946 /** 947 * Deletes the job from the scheduler's queue. 948 * 949 * @param groupId the primary key of the group 950 * @param jobName the job name 951 * @param groupName the group name (optionally {@link 952 * com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). 953 * See {@link com.liferay.portal.kernel.messaging.DestinationNames}. 954 * @throws PortalException if the group did not permission to manage staging 955 * and publish 956 * @throws SystemException if a system exception occurred 957 */ 958 public void unschedulePublishToLive( 959 long groupId, String jobName, String groupName) 960 throws PortalException, SystemException { 961 962 GroupPermissionUtil.check( 963 getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING); 964 965 SchedulerEngineHelperUtil.delete( 966 jobName, groupName, StorageType.PERSISTED); 967 } 968 969 /** 970 * Deletes the job from the scheduler's persistent queue. 971 * 972 * @param groupId the primary key of the group 973 * @param jobName the job name 974 * @param groupName the group name (optionally {@link 975 * com.liferay.portal.kernel.messaging.DestinationNames#LAYOUTS_LOCAL_PUBLISHER}). 976 * See {@link com.liferay.portal.kernel.messaging.DestinationNames}. 977 * @throws PortalException if a group with the primary key could not be 978 * found or if the group did not have permission to publish 979 * @throws SystemException if a system exception occurred 980 */ 981 public void unschedulePublishToRemote( 982 long groupId, String jobName, String groupName) 983 throws PortalException, SystemException { 984 985 GroupPermissionUtil.check( 986 getPermissionChecker(), groupId, ActionKeys.PUBLISH_STAGING); 987 988 SchedulerEngineHelperUtil.delete( 989 jobName, groupName, StorageType.PERSISTED); 990 } 991 992 /** 993 * Updates the layout. 994 * 995 * @param groupId the primary key of the group 996 * @param privateLayout whether the layout is private to the group 997 * @param layoutId the primary key of the layout 998 * @param parentLayoutId the primary key of the layout's new parent layout 999 * @param localeNamesMap the layout's locales and localized names 1000 * @param localeTitlesMap the layout's locales and localized titles 1001 * @param descriptionMap the locales and localized descriptions to merge 1002 * (optionally <code>null</code>) 1003 * @param keywordsMap the locales and localized keywords to merge 1004 * (optionally <code>null</code>) 1005 * @param robotsMap the locales and localized robots to merge (optionally 1006 * <code>null</code>) 1007 * @param type the layout's new type (optionally {@link 1008 * com.liferay.portal.model.LayoutConstants#TYPE_PORTLET}) 1009 * @param hidden whether the layout is hidden 1010 * @param friendlyURL the layout's new friendly URL (optionally {@link 1011 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PRIVATE_LAYOUT_FRIENDLY_URL} 1012 * or {@link 1013 * com.liferay.portal.util.PropsValues#DEFAULT_USER_PRIVATE_LAYOUT_FRIENDLY_URL}). 1014 * The default values can be overridden in 1015 * <code>portal-ext.properties</code> by specifying new values for 1016 * the corresponding properties defined in {@link 1017 * com.liferay.portal.util.PropsValues}. To see how the URL is 1018 * normalized when accessed see {@link 1019 * com.liferay.portal.kernel.util.FriendlyURLNormalizerUtil#normalize( 1020 * String)}. 1021 * @param iconImage whether the icon image will be updated 1022 * @param iconBytes the byte array of the layout's new icon image 1023 * @param serviceContext the service context to be applied. Can set the 1024 * modification date and expando bridge attributes for the layout. 1025 * @return the updated layout 1026 * @throws PortalException if a group or layout with the primary key could 1027 * not be found, if the user did not have permission to update the 1028 * layout, if a unique friendly URL could not be generated, if a 1029 * valid parent layout ID to use could not be found, or if the 1030 * layout parameters were invalid 1031 * @throws SystemException if a system exception occurred 1032 */ 1033 public Layout updateLayout( 1034 long groupId, boolean privateLayout, long layoutId, 1035 long parentLayoutId, Map<Locale, String> localeNamesMap, 1036 Map<Locale, String> localeTitlesMap, 1037 Map<Locale, String> descriptionMap, Map<Locale, String> keywordsMap, 1038 Map<Locale, String> robotsMap, String type, boolean hidden, 1039 String friendlyURL, Boolean iconImage, byte[] iconBytes, 1040 ServiceContext serviceContext) 1041 throws PortalException, SystemException { 1042 1043 LayoutPermissionUtil.check( 1044 getPermissionChecker(), groupId, privateLayout, layoutId, 1045 ActionKeys.UPDATE); 1046 1047 return layoutLocalService.updateLayout( 1048 groupId, privateLayout, layoutId, parentLayoutId, localeNamesMap, 1049 localeTitlesMap, descriptionMap, keywordsMap, robotsMap, type, 1050 hidden, friendlyURL, iconImage, iconBytes, serviceContext); 1051 } 1052 1053 /** 1054 * Updates the layout replacing its type settings. 1055 * 1056 * @param groupId the primary key of the group 1057 * @param privateLayout whether the layout is private to the group 1058 * @param layoutId the primary key of the layout 1059 * @param typeSettings the settings to load the unicode properties object. 1060 * See {@link com.liferay.portal.kernel.util.UnicodeProperties 1061 * #fastLoad(String)}. 1062 * @return the updated layout 1063 * @throws PortalException if a matching layout could not be found or if the 1064 * user did not have permission to update the layout 1065 * @throws SystemException if a system exception occurred 1066 */ 1067 public Layout updateLayout( 1068 long groupId, boolean privateLayout, long layoutId, 1069 String typeSettings) 1070 throws PortalException, SystemException { 1071 1072 LayoutPermissionUtil.check( 1073 getPermissionChecker(), groupId, privateLayout, layoutId, 1074 ActionKeys.UPDATE); 1075 1076 return layoutLocalService.updateLayout( 1077 groupId, privateLayout, layoutId, typeSettings); 1078 } 1079 1080 /** 1081 * Updates the look and feel of the layout. 1082 * 1083 * @param groupId the primary key of the group 1084 * @param privateLayout whether the layout is private to the group 1085 * @param layoutId the primary key of the layout 1086 * @param themeId the primary key of the layout's new theme 1087 * @param colorSchemeId the primary key of the layout's new color scheme 1088 * @param css the layout's new CSS 1089 * @param wapTheme whether the theme is for WAP browsers 1090 * @return the updated layout 1091 * @throws PortalException if a matching layout could not be found, or if 1092 * the user did not have permission to update the layout and 1093 * permission to apply the theme 1094 * @throws SystemException if a system exception occurred 1095 */ 1096 public Layout updateLookAndFeel( 1097 long groupId, boolean privateLayout, long layoutId, String themeId, 1098 String colorSchemeId, String css, boolean wapTheme) 1099 throws PortalException, SystemException { 1100 1101 LayoutPermissionUtil.check( 1102 getPermissionChecker(), groupId, privateLayout, layoutId, 1103 ActionKeys.UPDATE); 1104 1105 if (Validator.isNotNull(themeId)) { 1106 pluginSettingLocalService.checkPermission( 1107 getUserId(), themeId, Plugin.TYPE_THEME); 1108 } 1109 1110 return layoutLocalService.updateLookAndFeel( 1111 groupId, privateLayout, layoutId, themeId, colorSchemeId, css, 1112 wapTheme); 1113 } 1114 1115 /** 1116 * Updates the name of the layout matching the group, layout ID, and 1117 * privacy. 1118 * 1119 * @param groupId the primary key of the group 1120 * @param privateLayout whether the layout is private to the group 1121 * @param layoutId the primary key of the layout 1122 * @param name the layout's new name 1123 * @param languageId the primary key of the language. For more information 1124 * see {@link java.util.Locale}. 1125 * @return the updated layout 1126 * @throws PortalException if a matching layout could not be found, if the 1127 * user did not have permission to update the layout, or if the new 1128 * name was <code>null</code> 1129 * @throws SystemException if a system exception occurred 1130 */ 1131 public Layout updateName( 1132 long groupId, boolean privateLayout, long layoutId, String name, 1133 String languageId) 1134 throws PortalException, SystemException { 1135 1136 LayoutPermissionUtil.check( 1137 getPermissionChecker(), groupId, privateLayout, layoutId, 1138 ActionKeys.UPDATE); 1139 1140 return layoutLocalService.updateName( 1141 groupId, privateLayout, layoutId, name, languageId); 1142 } 1143 1144 /** 1145 * Updates the name of the layout matching the primary key. 1146 * 1147 * @param plid the primary key of the layout 1148 * @param name the name to be assigned 1149 * @param languageId the primary key of the language. For more information 1150 * see {@link java.util.Locale}. 1151 * @return the updated layout 1152 * @throws PortalException if a layout with the primary key could not be 1153 * found, or if the user did not have permission to update the 1154 * layout, or if the name was <code>null</code> 1155 * @throws SystemException if a system exception occurred 1156 */ 1157 public Layout updateName(long plid, String name, String languageId) 1158 throws PortalException, SystemException { 1159 1160 LayoutPermissionUtil.check( 1161 getPermissionChecker(), plid, ActionKeys.UPDATE); 1162 1163 return layoutLocalService.updateName(plid, name, languageId); 1164 } 1165 1166 /** 1167 * Updates the parent layout ID of the layout matching the group, layout ID, 1168 * and privacy. 1169 * 1170 * @param groupId the primary key of the group 1171 * @param privateLayout whether the layout is private to the group 1172 * @param layoutId the primary key of the layout 1173 * @param parentLayoutId the primary key to be assigned to the parent 1174 * layout 1175 * @return the matching layout 1176 * @throws PortalException if a valid parent layout ID to use could not be 1177 * found, if a matching layout could not be found, or if the user 1178 * did not have permission to update the layout 1179 * @throws SystemException if a system exception occurred 1180 */ 1181 public Layout updateParentLayoutId( 1182 long groupId, boolean privateLayout, long layoutId, 1183 long parentLayoutId) 1184 throws PortalException, SystemException { 1185 1186 LayoutPermissionUtil.check( 1187 getPermissionChecker(), groupId, privateLayout, layoutId, 1188 ActionKeys.UPDATE); 1189 1190 return layoutLocalService.updateParentLayoutId( 1191 groupId, privateLayout, layoutId, parentLayoutId); 1192 } 1193 1194 /** 1195 * Updates the parent layout ID of the layout matching the primary key. If a 1196 * layout matching the parent primary key is found, the layout ID of that 1197 * layout is assigned, otherwise {@link 1198 * com.liferay.portal.model.LayoutConstants#DEFAULT_PARENT_LAYOUT_ID} is 1199 * assigned. 1200 * 1201 * @param plid the primary key of the layout 1202 * @param parentPlid the primary key of the parent layout 1203 * @return the layout matching the primary key 1204 * @throws PortalException if a layout with the primary key could not be 1205 * found, if the user did not have permission to update the layout, 1206 * or if a valid parent layout ID to use could not be found 1207 * @throws SystemException if a system exception occurred 1208 */ 1209 public Layout updateParentLayoutId(long plid, long parentPlid) 1210 throws PortalException, SystemException { 1211 1212 LayoutPermissionUtil.check( 1213 getPermissionChecker(), plid, ActionKeys.UPDATE); 1214 1215 return layoutLocalService.updateParentLayoutId(plid, parentPlid); 1216 } 1217 1218 /** 1219 * Updates the priority of the layout matching the group, layout ID, and 1220 * privacy. 1221 * 1222 * @param groupId the primary key of the group 1223 * @param privateLayout whether the layout is private to the group 1224 * @param layoutId the primary key of the layout 1225 * @param priority the layout's new priority 1226 * @return the updated layout 1227 * @throws PortalException if a matching layout could not be found or if the 1228 * user did not have permission to update the layout 1229 * @throws SystemException if a system exception occurred 1230 */ 1231 public Layout updatePriority( 1232 long groupId, boolean privateLayout, long layoutId, int priority) 1233 throws PortalException, SystemException { 1234 1235 LayoutPermissionUtil.check( 1236 getPermissionChecker(), groupId, privateLayout, layoutId, 1237 ActionKeys.UPDATE); 1238 1239 return layoutLocalService.updatePriority( 1240 groupId, privateLayout, layoutId, priority); 1241 } 1242 1243 /** 1244 * Updates the priority of the layout matching the primary key. 1245 * 1246 * @param plid the primary key of the layout 1247 * @param priority the layout's new priority 1248 * @return the updated layout 1249 * @throws PortalException if a layout with the primary key could not be 1250 * found 1251 * @throws SystemException if a system exception occurred 1252 */ 1253 public Layout updatePriority(long plid, int priority) 1254 throws PortalException, SystemException { 1255 1256 LayoutPermissionUtil.check( 1257 getPermissionChecker(), plid, ActionKeys.UPDATE); 1258 1259 return layoutLocalService.updatePriority(plid, priority); 1260 } 1261 1262 protected List<Layout> filterLayouts(List<Layout> layouts) 1263 throws PortalException, SystemException { 1264 1265 List<Layout> filteredLayouts = new ArrayList<Layout>(); 1266 1267 for (Layout layout : layouts) { 1268 if (LayoutPermissionUtil.contains( 1269 getPermissionChecker(), layout.getPlid(), 1270 ActionKeys.VIEW)) { 1271 1272 filteredLayouts.add(layout); 1273 } 1274 } 1275 1276 return filteredLayouts; 1277 } 1278 1279 }