001/* 002 * Copyright 2012 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.linkdirectory.repository; 017 018import java.io.InputStream; 019import java.util.ArrayList; 020import java.util.Date; 021import java.util.List; 022 023import javax.jcr.Node; 024import javax.jcr.NodeIterator; 025import javax.jcr.PathNotFoundException; 026import javax.jcr.RepositoryException; 027import javax.jcr.Value; 028 029import org.apache.commons.lang3.ArrayUtils; 030import org.apache.commons.lang3.StringUtils; 031 032import org.ametys.core.group.GroupIdentity; 033import org.ametys.core.user.UserIdentity; 034import org.ametys.plugins.linkdirectory.Link; 035import org.ametys.plugins.repository.AmetysObject; 036import org.ametys.plugins.repository.AmetysRepositoryException; 037import org.ametys.plugins.repository.MovableAmetysObject; 038import org.ametys.plugins.repository.RepositoryConstants; 039import org.ametys.plugins.repository.RepositoryIntegrityViolationException; 040import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject; 041import org.ametys.plugins.repository.metadata.BinaryMetadata; 042import org.ametys.plugins.repository.metadata.ModifiableBinaryMetadata; 043import org.ametys.plugins.repository.metadata.ModifiableCompositeMetadata; 044import org.ametys.web.repository.SiteAwareAmetysObject; 045import org.ametys.web.repository.site.Site; 046 047/** 048 * Repository implementation of a directory link. 049 */ 050public class DefaultLink extends DefaultTraversableAmetysObject<DefaultLinkFactory> implements Link, SiteAwareAmetysObject, MovableAmetysObject 051{ 052 053 /** Constant for URL property. */ 054 public static final String PROPERTY_URL = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":url"; 055 056 /** Constant for id of provider of dynamic information. */ 057 public static final String PROPERTY_DYNAMIC_INFO_PROVIDER = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":dynamic-information"; 058 059 /** Constant for internal URL property. */ 060 public static final String PROPERTY_INTERNAL_URL = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":internal-url"; 061 062 /** Constant for URL type property. */ 063 public static final String PROPERTY_URLTYPE = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":url-type"; 064 065 /** Constant for title property. */ 066 public static final String PROPERTY_TITLE = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":title"; 067 068 /** Constant for title property. */ 069 public static final String PROPERTY_CONTENT = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":content"; 070 071 /** Constant for URL alternative property. */ 072 public static final String PROPERTY_URL_ALTERNATIVE = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":url-alternative"; 073 074 /** Constant for picture type property. */ 075 public static final String PROPERTY_PICTURE_TYPE = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":picture-type"; 076 077 /** Constant for picture data property. */ 078 public static final String PROPERTY_PICTURE = "picture"; 079 080 /** Constant for picture id property. */ 081 public static final String PROPERTY_PICTURE_ID = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":picture-id"; 082 083 /** Constant for picture glyph property. */ 084 public static final String PROPERTY_PICTURE_GLYPH = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":picture-glyph"; 085 086 /** Constant for picture alternative property. */ 087 public static final String PROPERTY_PICTURE_ALTERNATIVE = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":picture-alternative"; 088 089 /** Constant for themes property. */ 090 public static final String PROPERTY_THEMES = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":themes"; 091 092 /** Constant for grant-any-user property. */ 093 public static final String PROPERTY_GRANT_ANY_USER = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":grant-any-user"; 094 095 /** Constant for granted-users node. */ 096 public static final String NODE_NAME_GRANTED_USERS = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":granted-users"; 097 098 /** Constant for granted-users node. */ 099 public static final String NODE_NAME_GRANTED_USER = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":granted-user"; 100 101 /** Constant for granted-groups node. */ 102 public static final String NODE_NAME_GRANTED_GROUPS = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":granted-groups"; 103 104 /** Constant for granted-group node. */ 105 public static final String NODE_NAME_GRANTED_GROUP = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":granted-group"; 106 107 /** 108 * Create a {@link DefaultLink}. 109 * 110 * @param node the node backing this {@link AmetysObject}. 111 * @param parentPath the parent path in the Ametys hierarchy. 112 * @param factory the {@link DefaultLinkFactory} which creates the 113 * AmetysObject. 114 */ 115 public DefaultLink(Node node, String parentPath, DefaultLinkFactory factory) 116 { 117 super(node, parentPath, factory); 118 } 119 120 @Override 121 public String getUrl() throws AmetysRepositoryException 122 { 123 try 124 { 125 return getNode().getProperty(PROPERTY_URL).getString(); 126 } 127 catch (PathNotFoundException e) 128 { 129 return null; 130 } 131 catch (RepositoryException e) 132 { 133 throw new AmetysRepositoryException("Error getting the URL property.", e); 134 } 135 } 136 137 @Override 138 public void setUrl(LinkType urlType, String url) throws AmetysRepositoryException 139 { 140 try 141 { 142 getNode().setProperty(PROPERTY_URLTYPE, urlType.toString()); 143 getNode().setProperty(PROPERTY_URL, url); 144 } 145 catch (RepositoryException e) 146 { 147 throw new AmetysRepositoryException("Error setting the URL property.", e); 148 } 149 } 150 151 @Override 152 public String getInternalUrl() throws AmetysRepositoryException 153 { 154 try 155 { 156 return getNode().getProperty(PROPERTY_INTERNAL_URL).getString(); 157 } 158 catch (PathNotFoundException e) 159 { 160 return null; 161 } 162 catch (RepositoryException e) 163 { 164 throw new AmetysRepositoryException("Error getting the internal URL property.", e); 165 } 166 } 167 168 @Override 169 public void setInternalUrl(String url) throws AmetysRepositoryException 170 { 171 try 172 { 173 getNode().setProperty(PROPERTY_INTERNAL_URL, url); 174 } 175 catch (RepositoryException e) 176 { 177 throw new AmetysRepositoryException("Error setting the internal URL property.", e); 178 } 179 } 180 181 @Override 182 public LinkType getUrlType() throws AmetysRepositoryException 183 { 184 try 185 { 186 return LinkType.valueOf(getNode().getProperty(PROPERTY_URLTYPE).getString()); 187 } 188 catch (RepositoryException e) 189 { 190 throw new AmetysRepositoryException("Unable to get URL type property", e); 191 } 192 } 193 194 @Override 195 public String getTitle() throws AmetysRepositoryException 196 { 197 try 198 { 199 return getNode().getProperty(PROPERTY_TITLE).getString(); 200 } 201 catch (PathNotFoundException e) 202 { 203 return null; 204 } 205 catch (RepositoryException e) 206 { 207 throw new AmetysRepositoryException("Error getting the title property.", e); 208 } 209 } 210 211 @Override 212 public void setTitle(String title) throws AmetysRepositoryException 213 { 214 try 215 { 216 getNode().setProperty(PROPERTY_TITLE, title); 217 } 218 catch (RepositoryException e) 219 { 220 throw new AmetysRepositoryException("Error setting the title property.", e); 221 } 222 } 223 224 @Override 225 public String getContent() throws AmetysRepositoryException 226 { 227 try 228 { 229 return getNode().getProperty(PROPERTY_CONTENT).getString(); 230 } 231 catch (PathNotFoundException e) 232 { 233 return null; 234 } 235 catch (RepositoryException e) 236 { 237 throw new AmetysRepositoryException("Error getting the content property.", e); 238 } 239 } 240 241 @Override 242 public void setContent(String content) throws AmetysRepositoryException 243 { 244 try 245 { 246 getNode().setProperty(PROPERTY_CONTENT, content); 247 } 248 catch (RepositoryException e) 249 { 250 throw new AmetysRepositoryException("Error setting the content property.", e); 251 } 252 } 253 254 @Override 255 public String getAlternative() throws AmetysRepositoryException 256 { 257 try 258 { 259 return getNode().getProperty(PROPERTY_URL_ALTERNATIVE).getString(); 260 } 261 catch (PathNotFoundException e) 262 { 263 return null; 264 } 265 catch (RepositoryException e) 266 { 267 throw new AmetysRepositoryException("Error getting the alternative property.", e); 268 } 269 } 270 271 @Override 272 public void setAlternative(String alternative) throws AmetysRepositoryException 273 { 274 try 275 { 276 getNode().setProperty(PROPERTY_URL_ALTERNATIVE, alternative); 277 } 278 catch (RepositoryException e) 279 { 280 throw new AmetysRepositoryException("Error setting the alternative property.", e); 281 } 282 } 283 284 @Override 285 public BinaryMetadata getExternalPicture() throws AmetysRepositoryException 286 { 287 return getMetadataHolder().getBinaryMetadata(PROPERTY_PICTURE); 288 } 289 290 @Override 291 public void setExternalPicture(String mimeType, String filename, InputStream stream) throws AmetysRepositoryException 292 { 293 try 294 { 295 removePictureMetas(); 296 297 setPictureType("external"); 298 299 ModifiableCompositeMetadata meta = getMetadataHolder(); 300 ModifiableBinaryMetadata pic = meta.getBinaryMetadata(PROPERTY_PICTURE, true); 301 302 pic.setLastModified(new Date()); 303 pic.setInputStream(stream); 304 pic.setMimeType(mimeType); 305 pic.setFilename(filename); 306 } 307 catch (RepositoryException e) 308 { 309 throw new AmetysRepositoryException("Error setting the external picture property.", e); 310 } 311 } 312 313 @Override 314 public String getResourcePictureId() throws AmetysRepositoryException 315 { 316 try 317 { 318 return getNode().getProperty(PROPERTY_PICTURE_ID).getString(); 319 } 320 catch (PathNotFoundException e) 321 { 322 return null; 323 } 324 catch (RepositoryException e) 325 { 326 throw new AmetysRepositoryException("Error getting the picture ID property.", e); 327 } 328 } 329 330 @Override 331 public void setResourcePicture(String resourceId) throws AmetysRepositoryException 332 { 333 try 334 { 335 removePictureMetas(); 336 337 setPictureType("resource"); 338 339 getNode().setProperty(PROPERTY_PICTURE_ID, resourceId); 340 } 341 catch (RepositoryException e) 342 { 343 throw new AmetysRepositoryException("Error setting the alternative property.", e); 344 } 345 } 346 347 @Override 348 public void setNoPicture() throws AmetysRepositoryException 349 { 350 try 351 { 352 setPictureType(""); 353 354 removePictureMetas(); 355 } 356 catch (RepositoryException e) 357 { 358 throw new AmetysRepositoryException("Error setting the alternative property.", e); 359 } 360 } 361 362 @Override 363 public String getPictureType() throws AmetysRepositoryException 364 { 365 try 366 { 367 return getNode().getProperty(PROPERTY_PICTURE_TYPE).getString(); 368 } 369 catch (RepositoryException e) 370 { 371 throw new AmetysRepositoryException("Error getting the type property.", e); 372 } 373 } 374 375 @Override 376 public void setPictureType(String type) throws AmetysRepositoryException 377 { 378 try 379 { 380 getNode().setProperty(PROPERTY_PICTURE_TYPE, type); 381 } 382 catch (RepositoryException e) 383 { 384 throw new AmetysRepositoryException("Error setting the type property.", e); 385 } 386 } 387 388 public String getPictureGlyph() throws AmetysRepositoryException 389 { 390 try 391 { 392 return getNode().getProperty(PROPERTY_PICTURE_GLYPH).getString(); 393 } 394 catch (RepositoryException e) 395 { 396 throw new AmetysRepositoryException("Error getting the picture glyph property.", e); 397 } 398 } 399 400 public void setPictureGlyph(String glyph) throws AmetysRepositoryException 401 { 402 try 403 { 404 setPictureType("glyph"); 405 406 getNode().setProperty(PROPERTY_PICTURE_GLYPH, glyph); 407 } 408 catch (RepositoryException e) 409 { 410 throw new AmetysRepositoryException("Error setting the picture glyph property.", e); 411 } 412 } 413 414 @Override 415 public String getPictureAlternative() throws AmetysRepositoryException 416 { 417 try 418 { 419 return getNode().getProperty(PROPERTY_PICTURE_ALTERNATIVE).getString(); 420 } 421 catch (PathNotFoundException e) 422 { 423 return null; 424 } 425 catch (RepositoryException e) 426 { 427 throw new AmetysRepositoryException("Error getting the alternative property.", e); 428 } 429 } 430 431 @Override 432 public void setPictureAlternative(String alternative) throws AmetysRepositoryException 433 { 434 try 435 { 436 getNode().setProperty(PROPERTY_PICTURE_ALTERNATIVE, alternative); 437 } 438 catch (RepositoryException e) 439 { 440 throw new AmetysRepositoryException("Error setting the alternative property.", e); 441 } 442 } 443 444 @Override 445 public String[] getThemes() throws AmetysRepositoryException 446 { 447 return _getListFromMetadataName(PROPERTY_THEMES); 448 } 449 450 @Override 451 public void setThemes(String[] themes) throws AmetysRepositoryException 452 { 453 _setListWithMetadataName(themes, PROPERTY_THEMES); 454 } 455 456 @Override 457 public void removeTheme(String themeId) throws AmetysRepositoryException 458 { 459 try 460 { 461 String[] themes = getThemes(); 462 String[] updatedThemes = ArrayUtils.removeElement(themes, themeId); 463 getNode().setProperty(PROPERTY_THEMES, updatedThemes); 464 } 465 catch (RepositoryException e) 466 { 467 throw new AmetysRepositoryException("Error removing theme of id " + themeId, e); 468 } 469 } 470 471 @Override 472 public UserIdentity[] getGrantedUsers() throws AmetysRepositoryException 473 { 474 try 475 { 476 List<UserIdentity> grantedUsers = new ArrayList<>(); 477 478 NodeIterator nodeIt = getGrantedUsersRootNode().getNodes(NODE_NAME_GRANTED_USER); 479 while (nodeIt.hasNext()) 480 { 481 Node grantedUser = (Node) nodeIt.next(); 482 String login = grantedUser.getProperty(RepositoryConstants.NAMESPACE_PREFIX + ":login").getString(); 483 String populationId = grantedUser.getProperty(RepositoryConstants.NAMESPACE_PREFIX + ":population").getString(); 484 485 grantedUsers.add(new UserIdentity(login, populationId)); 486 } 487 return grantedUsers.toArray(new UserIdentity[grantedUsers.size()]); 488 } 489 catch (RepositoryException e) 490 { 491 throw new AmetysRepositoryException("An error occurred while trying to get granted users.", e); 492 } 493 } 494 495 @Override 496 public void setGrantedUsers(UserIdentity[] grantedUsers) throws AmetysRepositoryException 497 { 498 try 499 { 500 Node rootNode = getGrantedUsersRootNode(); 501 rootNode.remove(); 502 503 rootNode = getGrantedUsersRootNode(); 504 for (UserIdentity grantedUser : grantedUsers) 505 { 506 Node userNode = rootNode.addNode(NODE_NAME_GRANTED_USER, "ametys:user"); 507 userNode.setProperty(RepositoryConstants.NAMESPACE_PREFIX + ":login", grantedUser.getLogin()); 508 userNode.setProperty(RepositoryConstants.NAMESPACE_PREFIX + ":population", grantedUser.getPopulationId()); 509 } 510 } 511 catch (RepositoryException e) 512 { 513 throw new AmetysRepositoryException("An error occurred while setting the granted users.", e); 514 } 515 } 516 517 /** 518 * Get the root node for granted users 519 * 520 * @return The granted users root node 521 * @throws RepositoryException if an error occurred 522 */ 523 protected Node getGrantedUsersRootNode() throws RepositoryException 524 { 525 if (!getNode().hasNode(NODE_NAME_GRANTED_USERS)) 526 { 527 getNode().addNode(NODE_NAME_GRANTED_USERS, "ametys:linkGrantedUsers"); 528 } 529 return getNode().getNode(NODE_NAME_GRANTED_USERS); 530 } 531 532 @Override 533 public GroupIdentity[] getGrantedGroups() throws AmetysRepositoryException 534 { 535 try 536 { 537 List<GroupIdentity> grantedGroups = new ArrayList<>(); 538 539 NodeIterator nodeIt = getGrantedGroupsRootNode().getNodes(NODE_NAME_GRANTED_GROUP); 540 while (nodeIt.hasNext()) 541 { 542 Node grantedGroup = (Node) nodeIt.next(); 543 String groupId = grantedGroup.getProperty(RepositoryConstants.NAMESPACE_PREFIX + ":groupId").getString(); 544 String groupDir = grantedGroup.getProperty(RepositoryConstants.NAMESPACE_PREFIX + ":groupDirectory").getString(); 545 546 grantedGroups.add(new GroupIdentity(groupId, groupDir)); 547 } 548 return grantedGroups.toArray(new GroupIdentity[grantedGroups.size()]); 549 } 550 catch (RepositoryException e) 551 { 552 throw new AmetysRepositoryException("An error occurred while trying to get granted groups.", e); 553 } 554 } 555 556 @Override 557 public void setGrantedGroups(GroupIdentity[] grantedGroups) throws AmetysRepositoryException 558 { 559 try 560 { 561 Node rootNode = getGrantedGroupsRootNode(); 562 rootNode.remove(); 563 564 rootNode = getGrantedGroupsRootNode(); 565 for (GroupIdentity grantedGroup : grantedGroups) 566 { 567 Node groupNode = rootNode.addNode(NODE_NAME_GRANTED_GROUP, "ametys:group"); 568 groupNode.setProperty(RepositoryConstants.NAMESPACE_PREFIX + ":groupId", grantedGroup.getId()); 569 groupNode.setProperty(RepositoryConstants.NAMESPACE_PREFIX + ":groupDirectory", grantedGroup.getDirectoryId()); 570 } 571 } 572 catch (RepositoryException e) 573 { 574 throw new AmetysRepositoryException("An error occurred while setting the granted groups.", e); 575 } 576 } 577 578 /** 579 * Get the root node for granted users 580 * 581 * @return The granted users root node 582 * @throws RepositoryException if an error occurred 583 */ 584 protected Node getGrantedGroupsRootNode() throws RepositoryException 585 { 586 if (!getNode().hasNode(NODE_NAME_GRANTED_GROUPS)) 587 { 588 getNode().addNode(NODE_NAME_GRANTED_GROUPS, "ametys:linkGrantedGroups"); 589 } 590 return getNode().getNode(NODE_NAME_GRANTED_GROUPS); 591 } 592 593 @Override 594 public boolean isAllowedAnyUser() throws AmetysRepositoryException 595 { 596 Node node = getNode(); 597 try 598 { 599 return node.hasProperty(PROPERTY_GRANT_ANY_USER) ? getNode().getProperty(PROPERTY_GRANT_ANY_USER).getBoolean() : false; 600 } 601 catch (RepositoryException e) 602 { 603 throw new AmetysRepositoryException("An error occurred while trying to get the 'grant-any-user' property.", e); 604 } 605 } 606 607 @Override 608 public void setGrantAnyUser(boolean grantAnyUser) throws AmetysRepositoryException 609 { 610 try 611 { 612 getNode().setProperty(PROPERTY_GRANT_ANY_USER, grantAnyUser); 613 } 614 catch (RepositoryException e) 615 { 616 throw new AmetysRepositoryException("An error occurred while trying to set the 'grant-any-user' property.", e); 617 } 618 } 619 620 @Override 621 public Site getSite() throws AmetysRepositoryException 622 { 623 AmetysObject parent = getParent(); 624 while (parent != null) 625 { 626 if (parent instanceof Site) 627 { 628 return (Site) parent; 629 } 630 parent = parent.getParent(); 631 } 632 633 return null; 634 } 635 636 @Override 637 public String getSiteName() throws AmetysRepositoryException 638 { 639 return getSite().getName(); 640 } 641 642 /** 643 * Get the theme language. 644 * 645 * @return the theme language. 646 */ 647 public String getLanguage() 648 { 649 return getParent().getParent().getName(); 650 } 651 652 /** 653 * Remove all picture metas (picture ID and picture binary). 654 * 655 * @throws RepositoryException if an error occurs. 656 */ 657 protected void removePictureMetas() throws RepositoryException 658 { 659 getNode().setProperty(PROPERTY_PICTURE_ID, ""); 660 661 ModifiableCompositeMetadata meta = getMetadataHolder(); 662 if (meta.hasMetadata(PROPERTY_PICTURE)) 663 { 664 meta.removeMetadata(PROPERTY_PICTURE); 665 } 666 } 667 668 @Override 669 public void orderBefore(AmetysObject siblingObject) throws AmetysRepositoryException 670 { 671 if (siblingObject instanceof DefaultLink) 672 { 673 DefaultLink sibling = (DefaultLink) siblingObject; 674 sibling.getPath(); 675 Node node = getNode(); 676 String siblingPath = ""; 677 try 678 { 679 siblingPath = sibling.getNode().getPath(); 680 if (siblingPath.contains("/")) 681 { 682 siblingPath = StringUtils.substringAfterLast(siblingPath, "/"); 683 } 684 String path = node.getPath(); 685 if (path.contains("/")) 686 { 687 path = StringUtils.substringAfterLast(path, "/"); 688 } 689 node.getParent().orderBefore(path, siblingPath); 690 } 691 catch (RepositoryException e) 692 { 693 throw new AmetysRepositoryException(String.format("Unable to order link '%s' before link '%s'", this, siblingPath), e); 694 } 695 } 696 else 697 { 698 throw new AmetysRepositoryException("A link can only be moved before another link."); 699 } 700 } 701 702 @Override 703 public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException 704 { 705 if (getParent().equals(newParent)) 706 { 707 try 708 { 709 // Just order current node to the end. 710 Node node = getNode(); 711 String path = node.getPath(); 712 if (path.contains("/")) 713 { 714 path = StringUtils.substringAfterLast(path, "/"); 715 } 716 node.getParent().orderBefore(path, null); 717 } 718 catch (RepositoryException e) 719 { 720 throw new AmetysRepositoryException(String.format("Unable to move link '%s' outside the root link node.", this), e); 721 } 722 } 723 else 724 { 725 throw new AmetysRepositoryException("A link can only be moved before another link."); 726 } 727 } 728 729 @Override 730 public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException 731 { 732 return getParent().equals(newParent); 733 } 734 735 /** 736 * Retrieves the list of values corresponding to the metadata name passed as 737 * parameter 738 * 739 * @param metadataName the name of the metadata to retrieve 740 * @return the list corresponding to the metadata name 741 */ 742 private String[] _getListFromMetadataName(String metadataName) 743 { 744 try 745 { 746 if (getNode().hasProperty(metadataName)) 747 { 748 Value[] values = getNode().getProperty(metadataName).getValues(); 749 750 String[] list = new String[values.length]; 751 752 for (int i = 0; i < values.length; i++) 753 { 754 list[i] = values[i].getString(); 755 } 756 757 return list; 758 } 759 else 760 { 761 return new String[0]; 762 } 763 } 764 catch (RepositoryException e) 765 { 766 throw new AmetysRepositoryException("An error occurred while trying to get the property '" + metadataName + "'.", e); 767 } 768 } 769 770 /** 771 * Sets the list of values to the node corresponding to the metadata name 772 * passed as a parameter 773 * 774 * @param list the list of value to be set 775 * @param metadataName the name of the metadata 776 */ 777 private void _setListWithMetadataName(String[] list, String metadataName) 778 { 779 try 780 { 781 getNode().setProperty(metadataName, list); 782 } 783 catch (RepositoryException e) 784 { 785 throw new AmetysRepositoryException("An error occurred while trying to set the property '" + metadataName + "'.", e); 786 } 787 } 788 789 @Override 790 public String getDynamicInformationProvider() throws AmetysRepositoryException 791 { 792 try 793 { 794 return getNode().getProperty(PROPERTY_DYNAMIC_INFO_PROVIDER).getString(); 795 } 796 catch (PathNotFoundException e) 797 { 798 return null; 799 } 800 catch (RepositoryException e) 801 { 802 throw new AmetysRepositoryException("Error getting the URL property.", e); 803 } 804 } 805 806 @Override 807 public void setDynamicInformationProvider(String providerId) throws AmetysRepositoryException 808 { 809 try 810 { 811 getNode().setProperty(PROPERTY_DYNAMIC_INFO_PROVIDER, providerId); 812 } 813 catch (RepositoryException e) 814 { 815 throw new AmetysRepositoryException("Error setting the URL property.", e); 816 } 817 } 818 819}