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.portlet.dynamicdatamapping.service.impl; 016 017 import com.liferay.portal.kernel.exception.PortalException; 018 import com.liferay.portal.kernel.util.ListUtil; 019 import com.liferay.portal.kernel.util.OrderByComparator; 020 import com.liferay.portal.security.permission.ActionKeys; 021 import com.liferay.portal.security.permission.PermissionChecker; 022 import com.liferay.portal.service.ServiceContext; 023 import com.liferay.portlet.dynamicdatamapping.model.DDMForm; 024 import com.liferay.portlet.dynamicdatamapping.model.DDMStructure; 025 import com.liferay.portlet.dynamicdatamapping.service.base.DDMStructureServiceBaseImpl; 026 import com.liferay.portlet.dynamicdatamapping.service.permission.DDMPermission; 027 import com.liferay.portlet.dynamicdatamapping.service.permission.DDMStructurePermission; 028 import com.liferay.portlet.dynamicdatamapping.util.DDMDisplay; 029 import com.liferay.portlet.dynamicdatamapping.util.DDMUtil; 030 031 import java.util.Iterator; 032 import java.util.List; 033 import java.util.Locale; 034 import java.util.Map; 035 036 /** 037 * Provides the remote service for accessing, adding, deleting, and updating 038 * dynamic data mapping (DDM) structures. Its methods include permission checks. 039 * 040 * @author Brian Wing Shun Chan 041 * @author Bruno Basto 042 * @author Marcellus Tavares 043 * @see com.liferay.portlet.dynamicdatamapping.service.impl.DDMStructureLocalServiceImpl 044 */ 045 public class DDMStructureServiceImpl extends DDMStructureServiceBaseImpl { 046 047 @Override 048 public DDMStructure addStructure( 049 long userId, long groupId, long classNameId, 050 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, 051 DDMForm ddmForm, ServiceContext serviceContext) 052 throws PortalException { 053 054 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 055 056 DDMPermission.check( 057 getPermissionChecker(), serviceContext.getScopeGroupId(), 058 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 059 060 return ddmStructureLocalService.addStructure( 061 getUserId(), groupId, classNameId, nameMap, descriptionMap, ddmForm, 062 serviceContext); 063 } 064 065 /** 066 * Adds a structure referencing a default parent structure, using the portal 067 * property <code>dynamic.data.lists.storage.type</code> storage type and 068 * default structure type. 069 * 070 * @param userId the primary key of the structure's creator/owner 071 * @param groupId the primary key of the group 072 * @param classNameId the primary key of the class name for the 073 * structure's related model 074 * @param nameMap the structure's locales and localized names 075 * @param descriptionMap the structure's locales and localized 076 * descriptions 077 * @param xsd the structure's XML schema definition 078 * @param serviceContext the service context to be applied. Can set the 079 * UUID, creation date, modification date, guest permissions, 080 * and group permissions for the structure. 081 * @return the structure 082 * @throws PortalException if a user with the primary key could not be 083 * found, if the user did not have permission to add the 084 * structure, if the XSD was not well-formed, or if a portal 085 * exception occurred 086 * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long, 087 * long, Map, Map, DDMForm, ServiceContext)} 088 */ 089 @Deprecated 090 @Override 091 public DDMStructure addStructure( 092 long userId, long groupId, long classNameId, 093 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, 094 String xsd, ServiceContext serviceContext) 095 throws PortalException { 096 097 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 098 099 DDMPermission.check( 100 getPermissionChecker(), serviceContext.getScopeGroupId(), 101 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 102 103 return ddmStructureLocalService.addStructure( 104 getUserId(), groupId, classNameId, nameMap, descriptionMap, xsd, 105 serviceContext); 106 } 107 108 @Override 109 public DDMStructure addStructure( 110 long groupId, long parentStructureId, long classNameId, 111 String structureKey, Map<Locale, String> nameMap, 112 Map<Locale, String> descriptionMap, DDMForm ddmForm, 113 String storageType, int type, ServiceContext serviceContext) 114 throws PortalException { 115 116 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 117 118 DDMPermission.check( 119 getPermissionChecker(), serviceContext.getScopeGroupId(), 120 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 121 122 return ddmStructureLocalService.addStructure( 123 getUserId(), groupId, parentStructureId, classNameId, structureKey, 124 nameMap, descriptionMap, ddmForm, storageType, type, 125 serviceContext); 126 } 127 128 /** 129 * Adds a structure referencing its parent structure. 130 * 131 * @param groupId the primary key of the group 132 * @param parentStructureId the primary key of the parent structure 133 * (optionally {@link 134 * com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants#DEFAULT_PARENT_STRUCTURE_ID}) 135 * @param classNameId the primary key of the class name for the 136 * structure's related model 137 * @param structureKey the unique string identifying the structure 138 * (optionally <code>null</code>) 139 * @param nameMap the structure's locales and localized names 140 * @param descriptionMap the structure's locales and localized 141 * descriptions 142 * @param xsd the structure's XML schema definition 143 * @param storageType the structure's storage type. It can be "xml" or 144 * "expando". For more information, see {@link 145 * com.liferay.portlet.dynamicdatamapping.storage.StorageType}. 146 * @param type the structure's type. For more information, see {@link 147 * com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}. 148 * @param serviceContext the service context to be applied. Can set the 149 * UUID, creation date, modification date, guest permissions, 150 * and group permissions for the structure. 151 * @return the structure 152 * @throws PortalException if the user did not have permission to add 153 * the structure, if the XSD is not well formed, or if a portal 154 * exception occurred 155 * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long, 156 * long, String, Map, Map, DDMForm, String, int, 157 * ServiceContext)} 158 */ 159 @Deprecated 160 @Override 161 public DDMStructure addStructure( 162 long groupId, long parentStructureId, long classNameId, 163 String structureKey, Map<Locale, String> nameMap, 164 Map<Locale, String> descriptionMap, String xsd, String storageType, 165 int type, ServiceContext serviceContext) 166 throws PortalException { 167 168 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 169 170 DDMPermission.check( 171 getPermissionChecker(), serviceContext.getScopeGroupId(), 172 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 173 174 return ddmStructureLocalService.addStructure( 175 getUserId(), groupId, parentStructureId, classNameId, structureKey, 176 nameMap, descriptionMap, xsd, storageType, type, serviceContext); 177 } 178 179 @Override 180 public DDMStructure addStructure( 181 long userId, long groupId, String parentStructureKey, 182 long classNameId, String structureKey, Map<Locale, String> nameMap, 183 Map<Locale, String> descriptionMap, DDMForm ddmForm, 184 String storageType, int type, ServiceContext serviceContext) 185 throws PortalException { 186 187 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 188 189 DDMPermission.check( 190 getPermissionChecker(), serviceContext.getScopeGroupId(), 191 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 192 193 return ddmStructureLocalService.addStructure( 194 userId, groupId, parentStructureKey, classNameId, structureKey, 195 nameMap, descriptionMap, ddmForm, storageType, type, 196 serviceContext); 197 } 198 199 /** 200 * Adds a structure referencing the parent structure by its structure key. 201 * In case the parent structure is not found, it uses the default parent 202 * structure ID. 203 * 204 * @param userId the primary key of the structure's creator/owner 205 * @param groupId the primary key of the group 206 * @param parentStructureKey the unique string identifying the 207 * structure 208 * @param classNameId the primary key of the class name for the 209 * structure's related model 210 * @param structureKey unique string identifying the structure 211 * (optionally <code>null</code>) 212 * @param nameMap the structure's locales and localized names 213 * @param descriptionMap the structure's locales and localized 214 * descriptions 215 * @param xsd the XML schema definition of the structure 216 * @param storageType the storage type of the structure. It can be XML 217 * or expando. For more information, see {@link 218 * com.liferay.portlet.dynamicdatamapping.storage.StorageType}. 219 * @param type the structure's type. For more information, see {@link 220 * com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}. 221 * @param serviceContext the service context to be applied. Must have 222 * the <code>ddmResource</code> attribute to check permissions. 223 * Can set the UUID, creation date, modification date, guest 224 * permissions, and group permissions for the structure. 225 * @return the structure 226 * @throws PortalException if a user with the primary key could not be 227 * found, if the user did not have permission to add the 228 * structure, if the XSD was not well-formed, or if a portal 229 * exception occurred 230 * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long, 231 * String, long, String, Map, Map, DDMForm, String, int, 232 * ServiceContext)} 233 */ 234 @Deprecated 235 @Override 236 public DDMStructure addStructure( 237 long userId, long groupId, String parentStructureKey, 238 long classNameId, String structureKey, Map<Locale, String> nameMap, 239 Map<Locale, String> descriptionMap, String xsd, String storageType, 240 int type, ServiceContext serviceContext) 241 throws PortalException { 242 243 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 244 245 DDMPermission.check( 246 getPermissionChecker(), serviceContext.getScopeGroupId(), 247 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 248 249 return ddmStructureLocalService.addStructure( 250 userId, groupId, parentStructureKey, classNameId, structureKey, 251 nameMap, descriptionMap, xsd, storageType, type, serviceContext); 252 } 253 254 /** 255 * Copies a structure, creating a new structure with all the values 256 * extracted from the original one. The new structure supports a new name 257 * and description. 258 * 259 * @param structureId the primary key of the structure to be copied 260 * @param nameMap the new structure's locales and localized names 261 * @param descriptionMap the new structure's locales and localized 262 * descriptions 263 * @param serviceContext the service context to be applied. Can set the 264 * UUID, creation date, modification date, guest permissions, and 265 * group permissions for the structure. 266 * @return the new structure 267 * @throws PortalException if the user did not have permission to add the 268 * structure or if a portal exception occurred 269 */ 270 @Override 271 public DDMStructure copyStructure( 272 long structureId, Map<Locale, String> nameMap, 273 Map<Locale, String> descriptionMap, ServiceContext serviceContext) 274 throws PortalException { 275 276 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 277 278 DDMPermission.check( 279 getPermissionChecker(), serviceContext.getScopeGroupId(), 280 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 281 282 return ddmStructureLocalService.copyStructure( 283 getUserId(), structureId, nameMap, descriptionMap, serviceContext); 284 } 285 286 @Override 287 public DDMStructure copyStructure( 288 long structureId, ServiceContext serviceContext) 289 throws PortalException { 290 291 DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); 292 293 DDMPermission.check( 294 getPermissionChecker(), serviceContext.getScopeGroupId(), 295 ddmDisplay.getResourceName(), ddmDisplay.getAddStructureActionId()); 296 297 return ddmStructureLocalService.copyStructure( 298 getUserId(), structureId, serviceContext); 299 } 300 301 /** 302 * Deletes the structure and its resources. 303 * 304 * <p> 305 * Before deleting the structure, the system verifies whether the structure 306 * is required by another entity. If it is needed, an exception is thrown. 307 * </p> 308 * 309 * @param structureId the primary key of the structure to be deleted 310 * @throws PortalException if the user did not have permission to delete the 311 * structure or if a portal exception occurred 312 */ 313 @Override 314 public void deleteStructure(long structureId) throws PortalException { 315 DDMStructurePermission.check( 316 getPermissionChecker(), structureId, ActionKeys.DELETE); 317 318 ddmStructureLocalService.deleteStructure(structureId); 319 } 320 321 /** 322 * Returns the structure matching the class name ID, structure key, and 323 * group. 324 * 325 * @param groupId the primary key of the group 326 * @param classNameId the primary key of the class name for the structure's 327 * related model 328 * @param structureKey the unique string identifying the structure 329 * @return the matching structure, or <code>null</code> if a matching 330 * structure could not be found 331 * @throws PortalException if the user did not have permission to view the 332 * structure or if a portal exception occurred 333 */ 334 @Override 335 public DDMStructure fetchStructure( 336 long groupId, long classNameId, String structureKey) 337 throws PortalException { 338 339 DDMStructure ddmStructure = ddmStructurePersistence.fetchByG_C_S( 340 groupId, classNameId, structureKey); 341 342 if (ddmStructure != null) { 343 DDMStructurePermission.check( 344 getPermissionChecker(), ddmStructure, ActionKeys.VIEW); 345 } 346 347 return ddmStructure; 348 } 349 350 @Override 351 public List<DDMStructure> getJournalFolderStructures( 352 long[] groupIds, long journalFolderId, int restrictionType) 353 throws PortalException { 354 355 return filterStructures( 356 ddmStructureLocalService.getJournalFolderStructures( 357 groupIds, journalFolderId, restrictionType)); 358 } 359 360 /** 361 * Returns the structure with the ID. 362 * 363 * @param structureId the primary key of the structure 364 * @return the structure with the ID 365 * @throws PortalException if the user did not have permission to view the 366 * structure or if a structure with the ID could not be found 367 */ 368 @Override 369 public DDMStructure getStructure(long structureId) throws PortalException { 370 DDMStructurePermission.check( 371 getPermissionChecker(), structureId, ActionKeys.VIEW); 372 373 return ddmStructurePersistence.findByPrimaryKey(structureId); 374 } 375 376 /** 377 * Returns the structure matching the class name ID, structure key, and 378 * group. 379 * 380 * @param groupId the primary key of the structure's group 381 * @param classNameId the primary key of the class name for the structure's 382 * related model 383 * @param structureKey the unique string identifying the structure 384 * @return the matching structure 385 * @throws PortalException if the user did not have permission to view the 386 * structure or if a matching structure could not be found 387 */ 388 @Override 389 public DDMStructure getStructure( 390 long groupId, long classNameId, String structureKey) 391 throws PortalException { 392 393 DDMStructurePermission.check( 394 getPermissionChecker(), groupId, classNameId, structureKey, 395 ActionKeys.VIEW); 396 397 return ddmStructureLocalService.getStructure( 398 groupId, classNameId, structureKey); 399 } 400 401 /** 402 * Returns the structure matching the class name ID, structure key, and 403 * group, optionally searching ancestor sites (that have sharing enabled) 404 * and global scoped sites. 405 * 406 * <p> 407 * This method first searches in the group. If the structure is still not 408 * found and <code>includeAncestorStructures</code> is set to 409 * <code>true</code>, this method searches the group's ancestor sites (that 410 * have sharing enabled) and lastly searches global scoped sites. 411 * </p> 412 * 413 * @param groupId the primary key of the structure's group 414 * @param classNameId the primary key of the class name for the structure's 415 * related model 416 * @param structureKey the unique string identifying the structure 417 * @param includeAncestorStructures whether to include ancestor sites (that 418 * have sharing enabled) and include global scoped sites in the 419 * search 420 * @return the matching structure 421 * @throws PortalException if the user did not have permission to view the 422 * structure or if a matching structure could not be found 423 */ 424 @Override 425 public DDMStructure getStructure( 426 long groupId, long classNameId, String structureKey, 427 boolean includeAncestorStructures) 428 throws PortalException { 429 430 DDMStructurePermission.check( 431 getPermissionChecker(), groupId, classNameId, structureKey, 432 ActionKeys.VIEW); 433 434 return ddmStructureLocalService.getStructure( 435 groupId, classNameId, structureKey, includeAncestorStructures); 436 } 437 438 /** 439 * Returns all the structures in the group that the user has permission to 440 * view. 441 * 442 * @param groupId the primary key of the group 443 * @return the structures in the group that the user has permission to view 444 */ 445 @Override 446 public List<DDMStructure> getStructures(long groupId) { 447 return ddmStructurePersistence.filterFindByGroupId(groupId); 448 } 449 450 /** 451 * Returns all the structures in the groups that the user has permission to 452 * view. 453 * 454 * @param groupIds the primary key of the groups 455 * @return the structures in the groups that the user has permission to view 456 */ 457 @Override 458 public List<DDMStructure> getStructures(long[] groupIds) { 459 return ddmStructurePersistence.filterFindByGroupId(groupIds); 460 } 461 462 /** 463 * Returns all the structures matching the groups and class name ID that the 464 * user has permission to view. 465 * 466 * @param groupIds the primary keys of the groups 467 * @param classNameId the primary key of the class name for the structure's 468 * related model 469 * @return the structures matching the groups and class name ID that the 470 * user has permission to view 471 */ 472 @Override 473 public List<DDMStructure> getStructures(long[] groupIds, long classNameId) { 474 return ddmStructurePersistence.filterFindByG_C(groupIds, classNameId); 475 } 476 477 @Override 478 public List<DDMStructure> getStructures( 479 long[] groupIds, long classNameId, int start, int end) { 480 481 return ddmStructurePersistence.filterFindByG_C( 482 groupIds, classNameId, start, end); 483 } 484 485 /** 486 * Returns an ordered range of all the structures matching the groups and 487 * class name IDs, and matching the keywords in the structure names and 488 * descriptions. 489 * 490 * <p> 491 * Useful when paginating results. Returns a maximum of <code>end - 492 * start</code> instances. <code>start</code> and <code>end</code> are not 493 * primary keys, they are indexes in the result set. Thus, <code>0</code> 494 * refers to the first result in the set. Setting both <code>start</code> 495 * and <code>end</code> to {@link 496 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 497 * result set. 498 * </p> 499 * 500 * @param companyId the primary key of the structure's company 501 * @param groupIds the primary keys of the groups 502 * @param classNameIds the primary keys of the class names of the models 503 * the structures are related to 504 * @param keywords the keywords (space separated), which may occur in the 505 * structure's name or description (optionally <code>null</code>) 506 * @param start the lower bound of the range of structures to return 507 * @param end the upper bound of the range of structures to return (not 508 * inclusive) 509 * @param orderByComparator the comparator to order the structures 510 * (optionally <code>null</code>) 511 * @return the range of matching structures ordered by the comparator 512 */ 513 @Override 514 public List<DDMStructure> search( 515 long companyId, long[] groupIds, long[] classNameIds, String keywords, 516 int start, int end, OrderByComparator<DDMStructure> orderByComparator) { 517 518 return ddmStructureFinder.filterFindByKeywords( 519 companyId, groupIds, classNameIds, keywords, start, end, 520 orderByComparator); 521 } 522 523 /** 524 * Returns an ordered range of all the structures matching the groups, class 525 * name IDs, name keyword, description keyword, storage type, and type. 526 * 527 * <p> 528 * Useful when paginating results. Returns a maximum of <code>end - 529 * start</code> instances. <code>start</code> and <code>end</code> are not 530 * primary keys, they are indexes in the result set. Thus, <code>0</code> 531 * refers to the first result in the set. Setting both <code>start</code> 532 * and <code>end</code> to {@link 533 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 534 * result set. 535 * </p> 536 * 537 * @param companyId the primary key of the structure's company 538 * @param groupIds the primary keys of the groups 539 * @param classNameIds the primary keys of the class names of the models 540 * the structures are related to 541 * @param name the name keywords 542 * @param description the description keywords 543 * @param storageType the structure's storage type. It can be "xml" or 544 * "expando". For more information, see {@link 545 * com.liferay.portlet.dynamicdatamapping.storage.StorageType}. 546 * @param type the structure's type. For more information, see {@link 547 * com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}. 548 * @param andOperator whether every field must match its keywords, or just 549 * one field 550 * @param start the lower bound of the range of structures to return 551 * @param end the upper bound of the range of structures to return (not 552 * inclusive) 553 * @param orderByComparator the comparator to order the structures 554 * (optionally <code>null</code>) 555 * @return the range of matching structures ordered by the comparator 556 */ 557 @Override 558 public List<DDMStructure> search( 559 long companyId, long[] groupIds, long[] classNameIds, String name, 560 String description, String storageType, int type, boolean andOperator, 561 int start, int end, OrderByComparator<DDMStructure> orderByComparator) { 562 563 return ddmStructureFinder.filterFindByC_G_C_N_D_S_T( 564 companyId, groupIds, classNameIds, name, description, storageType, 565 type, andOperator, start, end, orderByComparator); 566 } 567 568 /** 569 * Returns the number of structures matching the groups and class name IDs, 570 * and matching the keywords in the structure names and descriptions. 571 * 572 * @param companyId the primary key of the structure's company 573 * @param groupIds the primary keys of the groups 574 * @param classNameIds the primary keys of the class names of the models 575 * the structures are related to 576 * @param keywords the keywords (space separated), which may occur in the 577 * structure's name or description (optionally <code>null</code>) 578 * @return the number of matching structures 579 */ 580 @Override 581 public int searchCount( 582 long companyId, long[] groupIds, long[] classNameIds, String keywords) { 583 584 return ddmStructureFinder.filterCountByKeywords( 585 companyId, groupIds, classNameIds, keywords); 586 } 587 588 /** 589 * Returns the number of structures matching the groups, class name IDs, 590 * name keyword, description keyword, storage type, and type 591 * 592 * @param companyId the primary key of the structure's company 593 * @param groupIds the primary keys of the groups 594 * @param classNameIds the primary keys of the class names of the models 595 * the structure's are related to 596 * @param name the name keywords 597 * @param description the description keywords 598 * @param storageType the structure's storage type. It can be "xml" or 599 * "expando". For more information, see {@link 600 * com.liferay.portlet.dynamicdatamapping.storage.StorageType}. 601 * @param type the structure's type. For more information, see {@link 602 * com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}. 603 * @param andOperator whether every field must match its keywords, or just 604 * one field 605 * @return the number of matching structures 606 */ 607 @Override 608 public int searchCount( 609 long companyId, long[] groupIds, long[] classNameIds, String name, 610 String description, String storageType, int type, boolean andOperator) { 611 612 return ddmStructureFinder.filterCountByC_G_C_N_D_S_T( 613 companyId, groupIds, classNameIds, name, description, storageType, 614 type, andOperator); 615 } 616 617 @Override 618 public DDMStructure updateStructure( 619 long groupId, long parentStructureId, long classNameId, 620 String structureKey, Map<Locale, String> nameMap, 621 Map<Locale, String> descriptionMap, DDMForm ddmForm, 622 ServiceContext serviceContext) 623 throws PortalException { 624 625 DDMStructurePermission.check( 626 getPermissionChecker(), groupId, classNameId, structureKey, 627 ActionKeys.UPDATE); 628 629 return ddmStructureLocalService.updateStructure( 630 groupId, parentStructureId, classNameId, structureKey, nameMap, 631 descriptionMap, ddmForm, serviceContext); 632 } 633 634 /** 635 * Updates the structure matching the class name ID, structure key, and 636 * group, replacing its old parent structure, name map, description map, and 637 * XSD with new ones. 638 * 639 * @param groupId the primary key of the group 640 * @param parentStructureId the primary key of the new parent structure 641 * @param classNameId the primary key of the class name for the 642 * structure's related model 643 * @param structureKey the unique string identifying the structure 644 * @param nameMap the structure's new locales and localized names 645 * @param descriptionMap the structure's new locales and localized 646 * description 647 * @param definition the structure's new XML schema definition 648 * @param serviceContext the service context to be applied. Can set the 649 * modification date. 650 * @return the updated structure 651 * @throws PortalException if the user did not have permission to update 652 * the structure or if a portal exception occurred 653 * @deprecated As of 7.0.0, replaced by {@link #updateStructure(long, long, 654 * long, String, Map, Map, DDMForm, ServiceContext)} 655 */ 656 @Deprecated 657 @Override 658 public DDMStructure updateStructure( 659 long groupId, long parentStructureId, long classNameId, 660 String structureKey, Map<Locale, String> nameMap, 661 Map<Locale, String> descriptionMap, String definition, 662 ServiceContext serviceContext) 663 throws PortalException { 664 665 DDMStructurePermission.check( 666 getPermissionChecker(), groupId, classNameId, structureKey, 667 ActionKeys.UPDATE); 668 669 return ddmStructureLocalService.updateStructure( 670 groupId, parentStructureId, classNameId, structureKey, nameMap, 671 descriptionMap, definition, serviceContext); 672 } 673 674 @Override 675 public DDMStructure updateStructure( 676 long structureId, long parentStructureId, 677 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, 678 DDMForm ddmForm, ServiceContext serviceContext) 679 throws PortalException { 680 681 DDMStructurePermission.check( 682 getPermissionChecker(), structureId, ActionKeys.UPDATE); 683 684 return ddmStructureLocalService.updateStructure( 685 structureId, parentStructureId, nameMap, descriptionMap, ddmForm, 686 serviceContext); 687 } 688 689 /** 690 * Updates the structure matching the structure ID, replacing the old parent 691 * structure ID, name map, description map, and XSD with the new values. 692 * 693 * @param structureId the primary key of the structure 694 * @param parentStructureId the new parent structure primary key 695 * @param nameMap the structure's new locales and localized names 696 * @param descriptionMap the structure's new locales and localized 697 * description 698 * @param definition the new XML schema definition of the structure 699 * @param serviceContext the service context to be applied. Can set the 700 * modification date. 701 * @return the updated structure 702 * @throws PortalException if the user did not have permission to update 703 * the structure or if a portal exception occurred 704 * @deprecated As of 7.0.0, replaced by {@link #updateStructure(long, long, 705 * Map, Map, DDMForm, ServiceContext)} 706 */ 707 @Deprecated 708 @Override 709 public DDMStructure updateStructure( 710 long structureId, long parentStructureId, 711 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, 712 String definition, ServiceContext serviceContext) 713 throws PortalException { 714 715 DDMStructurePermission.check( 716 getPermissionChecker(), structureId, ActionKeys.UPDATE); 717 718 return ddmStructureLocalService.updateStructure( 719 structureId, parentStructureId, nameMap, descriptionMap, definition, 720 serviceContext); 721 } 722 723 protected List<DDMStructure> filterStructures(List<DDMStructure> structures) 724 throws PortalException { 725 726 PermissionChecker permissionChecker = getPermissionChecker(); 727 728 structures = ListUtil.copy(structures); 729 730 Iterator<DDMStructure> itr = structures.iterator(); 731 732 while (itr.hasNext()) { 733 DDMStructure structure = itr.next(); 734 735 if (!DDMStructurePermission.contains( 736 permissionChecker, structure, ActionKeys.VIEW)) { 737 738 itr.remove(); 739 } 740 } 741 742 return structures; 743 } 744 745 }