1 13 package org.jahia.content; 14 15 import java.util.*; 16 17 import org.jahia.exceptions.*; 18 import org.jahia.params.*; 19 import org.jahia.services.acl.*; 20 import org.jahia.services.pages.ContentPage; 21 import org.jahia.services.sites.JahiaSite; 22 import org.jahia.services.sites.SiteLanguageSettings; 23 import org.jahia.services.usermanager.*; 24 import org.jahia.services.version.*; 25 import org.jahia.bin.Jahia; 26 import org.jahia.content.events.ContentActivationEvent; 27 import org.jahia.registries.ServicesRegistry; 28 29 35 public abstract class ContentObject extends JahiaObject { 36 37 private static org.apache.log4j.Logger logger = 38 org.apache.log4j.Logger.getLogger(ContentObject.class); 39 40 41 public static final String SHARED_LANGUAGE = "shared"; 42 43 protected ContentObject(ObjectKey objectKey) { 44 super(objectKey); 45 } 46 47 50 protected ContentObject() { 51 52 } 53 54 60 public abstract SortedSet getEntryStates () 61 throws JahiaException ; 62 63 71 public SortedSet getActiveAndStagingEntryStates() 72 throws JahiaException { 73 SortedSet entries = getEntryStates(); 74 SortedSet results = new TreeSet(); 75 Iterator iterator = entries.iterator(); 76 ContentObjectEntryState entryState = null; 77 while ( iterator.hasNext() ){ 78 entryState = (ContentObjectEntryState)iterator.next(); 79 if ( entryState.getWorkflowState() 80 >ContentObjectEntryState.WORKFLOW_STATE_VERSIONED ){ 81 results.add(entryState); 82 } 83 } 84 return results; 85 } 86 87 107 public abstract ArrayList getChilds (JahiaUser user, 108 EntryLoadRequest loadRequest) 109 throws JahiaException; 110 111 127 public abstract ContentObject getParent(JahiaUser user, 128 EntryLoadRequest loadRequest, 129 String operationMode) 130 throws JahiaException; 131 132 133 160 public abstract void markLanguageForDeletion (JahiaUser user, 161 String languageCode, 162 StateModificationContext 163 stateModificationContext) 164 throws JahiaException; 165 166 173 protected abstract void copyEntry (EntryStateable fromEntryState, 174 EntryStateable toEntryState) 175 throws JahiaException; 176 177 187 protected abstract void deleteEntry (EntryStateable deleteEntryState) 188 throws JahiaException; 189 190 219 public RestoreVersionTestResults isValidForRestore(JahiaUser user, 220 String operationMode, 221 ContentObjectEntryState entryState, 222 boolean removeMoreRecentActive, 223 StateModificationContext stateModificationContext) 224 throws JahiaException { 225 RestoreVersionTestResults opResult = new RestoreVersionTestResults(); 226 if (!removeMoreRecentActive) { 227 ContentObjectEntryState resultEntryState = 228 getClosestVersionedEntryState(entryState); 229 if (resultEntryState == null) { 230 opResult.setStatus(RestoreVersionTestResults. 231 FAILED_OPERATION_STATUS); 232 opResult.appendError(new RestoreVersionNodeTestResult( 233 getObjectKey(), 234 entryState.getLanguageCode(), 235 "No entry found found for this version")); 236 } 237 } 238 return opResult; 239 } 240 241 272 public RestoreVersionTestResults restoreVersion (JahiaUser user, 273 String operationMode, 274 ContentObjectEntryState entryState, 275 boolean removeMoreRecentActive, 276 RestoreVersionStateModificationContext stateModificationContext) 277 throws JahiaException { 278 279 RestoreVersionTestResults opResult = new RestoreVersionTestResults(); 280 288 289 ContentObjectEntryState resultEntryState = getClosestVersionedEntryState(entryState); 290 291 ContentObjectEntryState stagingEntryState = null; 294 SortedSet allEntryStates = getEntryStates(); 295 Iterator entryStatesIter = allEntryStates.iterator(); 296 while (entryStatesIter.hasNext()) { 297 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 298 if (curEntryState.getWorkflowState() == ContentObjectEntryState.WORKFLOW_STATE_ACTIVE) { 299 if (curEntryState.getLanguageCode().equals(entryState.getLanguageCode()) || 300 ContentObject.SHARED_LANGUAGE.equals(curEntryState.getLanguageCode())) { 301 302 } 303 } else if (curEntryState.getWorkflowState() >= ContentObjectEntryState.WORKFLOW_STATE_START_STAGING) { 304 if (curEntryState.getLanguageCode().equals(entryState.getLanguageCode()) || 305 ContentObject.SHARED_LANGUAGE.equals(curEntryState.getLanguageCode())) { 306 stagingEntryState = curEntryState; 307 } 308 } 309 } 310 311 boolean markedForDelete = false; 312 boolean isDeleted = this.isDeletedOrDoesNotExist(entryState.getVersionID()); 313 if (removeMoreRecentActive) { 314 if (isDeleted){ 317 markLanguageForDeletion(user, ContentObject.SHARED_LANGUAGE, 319 stateModificationContext); 320 markedForDelete = true; 321 } else if ( resultEntryState == null || (resultEntryState != null && 322 (resultEntryState.getWorkflowState() 323 == EntryLoadRequest.DELETED_WORKFLOW_STATE)) ) { 324 markLanguageForDeletion(user, entryState.getLanguageCode(), 326 stateModificationContext); 327 markedForDelete = true; 328 } 329 } 330 331 if ( markedForDelete || resultEntryState == null ) { 332 return opResult; 333 } 334 if (stagingEntryState != null) { 336 deleteEntry(stagingEntryState); 337 } 338 339 if ( stagingEntryState == null || 340 stagingEntryState.getVersionID() 341 == EntryLoadRequest.DELETED_WORKFLOW_STATE ){ 342 stagingEntryState = new ContentObjectEntryState( 344 ContentObjectEntryState.WORKFLOW_STATE_START_STAGING, 0, 345 entryState.getLanguageCode()); 346 } 347 348 resultEntryState = new ContentObjectEntryState(resultEntryState.getWorkflowState(), 359 resultEntryState.getVersionID(), entryState.getLanguageCode()); 360 stagingEntryState = new ContentObjectEntryState(stagingEntryState.getWorkflowState(), 362 stagingEntryState.getVersionID(),entryState.getLanguageCode()); 363 364 copyEntry(resultEntryState, stagingEntryState); 366 367 return opResult; 368 } 369 370 382 public int getID() { 383 return getObjectKey().getIdInType(); 384 } 385 386 392 public abstract int getDefinitionID(EntryLoadRequest loadRequest); 393 394 400 public abstract ObjectKey getDefinitionKey(EntryLoadRequest loadRequest); 401 402 403 417 public ContentObjectEntryState getClosestVersionedEntryState(ContentObjectEntryState entryState) 418 throws JahiaException { 419 return getClosestVersionedEntryState(entryState,false); 420 } 421 422 436 public ContentObjectEntryState getClosestVersionedEntryState(ContentObjectEntryState entryState, boolean smallerVersionOnly) 437 throws JahiaException { 438 439 if (entryState.getWorkflowState() > 440 ContentObjectEntryState.WORKFLOW_STATE_ACTIVE) { 441 logger.debug( 442 "Invalid workflow state requested when trying to find versioned entry state: " + 443 entryState.getWorkflowState()); 444 return null; 445 } 446 SortedSet entryStates = getEntryStates(); 449 ContentObjectEntryState resultEntryState = null; 450 Iterator entryStatesIter = entryStates.iterator(); 451 452 while (entryStatesIter.hasNext()) { 453 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 454 if (curEntryState.getWorkflowState() <= ContentObjectEntryState.WORKFLOW_STATE_ACTIVE) { 455 if ( smallerVersionOnly && (curEntryState.getVersionID() < entryState.getVersionID()) 456 || !smallerVersionOnly && (curEntryState.getVersionID() <= entryState.getVersionID()) ){ 457 if (curEntryState.getLanguageCode().equals(entryState.getLanguageCode()) || 459 curEntryState.getLanguageCode().equals(ContentObject.SHARED_LANGUAGE) || 460 ContentObject.SHARED_LANGUAGE.equals(entryState.getLanguageCode())) { 461 if (resultEntryState != null) { 462 if (resultEntryState.getVersionID() < curEntryState.getVersionID()) { 464 resultEntryState = curEntryState; 465 } 466 } else { 467 resultEntryState = curEntryState; 468 } 469 } 470 } 471 } 472 473 } 474 return resultEntryState; 475 } 476 477 483 public boolean hasActiveEntries() throws JahiaException { 484 SortedSet entryStates = getEntryStates(); 485 Iterator entryStatesIter = entryStates.iterator(); 486 while (entryStatesIter.hasNext()) { 487 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 488 if ( curEntryState.getWorkflowState() 489 ==ContentObjectEntryState.WORKFLOW_STATE_ACTIVE ){ 490 return true; 491 } 492 } 493 return false; 494 } 495 496 502 public boolean hasActiveOrStagingEntries() throws JahiaException { 503 SortedSet entryStates = getEntryStates(); 504 Iterator entryStatesIter = entryStates.iterator(); 505 while (entryStatesIter.hasNext()) { 506 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 507 if ( curEntryState.getWorkflowState() 508 >=ContentObjectEntryState.WORKFLOW_STATE_ACTIVE ){ 509 return true; 510 } 511 } 512 return false; 513 } 514 515 523 public boolean hasArchiveEntryState(int versionID) throws JahiaException { 524 return hasArchiveEntryState(versionID,false); 525 } 526 527 536 public boolean hasArchiveEntryState(int versionID, 537 boolean notDeletedOnly) throws JahiaException { 538 539 SortedSet entryStates = getEntryStates(); 540 Iterator entryStatesIter = entryStates.iterator(); 541 while (entryStatesIter.hasNext()) { 542 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 543 if ( curEntryState.getWorkflowState()<=ContentObjectEntryState.WORKFLOW_STATE_ACTIVE 544 && curEntryState.getVersionID()<=versionID ){ 545 if ( !notDeletedOnly || 546 (curEntryState.getWorkflowState() != ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED) ){ 547 return true; 548 } 549 } 550 } 551 return false; 552 } 553 554 570 public ArrayList getClosestVersionedEntryStates(int versionID) 571 throws JahiaException { 572 573 574 Map closestInLanguage = new HashMap(); 577 SortedSet entryStates = getEntryStates(); 578 ContentObjectEntryState resultEntryState = null; 579 Iterator entryStatesIter = entryStates.iterator(); 580 while (entryStatesIter.hasNext()) { 581 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStatesIter.next(); 582 if ( ((curEntryState.getWorkflowState() == ContentObjectEntryState.WORKFLOW_STATE_ACTIVE) && 583 (curEntryState.getVersionID() <= versionID)) 584 || 585 ((curEntryState.getWorkflowState() == ContentObjectEntryState.WORKFLOW_STATE_VERSIONED) && 586 (curEntryState.getVersionID() <= versionID)) 587 || 588 ((curEntryState.getWorkflowState() == ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED) && 589 (curEntryState.getVersionID() <= versionID)) 590 ) { 591 592 resultEntryState = (ContentObjectEntryState) closestInLanguage.get(curEntryState.getLanguageCode()); 597 if (resultEntryState != null) { 598 if (resultEntryState.getVersionID() < 600 curEntryState.getVersionID()) { 601 closestInLanguage.put(curEntryState.getLanguageCode(), curEntryState); 602 } 603 } else { 604 closestInLanguage.put(curEntryState.getLanguageCode(), curEntryState); 606 } 607 } 608 609 } 610 ArrayList resultEntryStates = new ArrayList(closestInLanguage.values()); 611 return resultEntryStates; 612 } 613 614 625 public final boolean checkAdminAccess(JahiaUser user) { 626 return checkAccess(user, JahiaBaseACL.ADMIN_RIGHTS, false); 627 } 628 629 public final boolean checkAdminAccess(JahiaUser user,boolean checkChilds) { 630 return checkAccess(user, JahiaBaseACL.ADMIN_RIGHTS,checkChilds); 631 } 632 633 642 public final boolean checkReadAccess(JahiaUser user) { 643 return checkAccess(user, JahiaBaseACL.READ_RIGHTS, false); 644 } 645 646 656 public final boolean checkWriteAccess(JahiaUser user) { 657 return checkAccess(user, JahiaBaseACL.WRITE_RIGHTS, false); 658 } 659 660 public final boolean checkWriteAccess(JahiaUser user,boolean checkChilds) { 661 return checkAccess(user, JahiaBaseACL.WRITE_RIGHTS,checkChilds); 662 } 663 664 public final boolean checkWriteAccess(JahiaUser user,boolean checkChilds,boolean forceChildsRights) { 665 return checkAccess(user, JahiaBaseACL.WRITE_RIGHTS,checkChilds,forceChildsRights); 666 } 667 668 676 public boolean checkAccess(JahiaUser user, int permission, boolean checkChilds) { 677 boolean result = false; 678 try { 679 JahiaBaseACL acl = new JahiaBaseACL(getAclID()); 680 result = acl.getPermission (user, permission); 681 if(!result&& checkChilds) { 682 List childs = getChilds(user, null); 683 for (int i = 0; i < childs.size() && !result; i++) { 684 ContentObject contentObject = (ContentObject) childs.get(i); 685 if(!(contentObject instanceof ContentPage)) 686 result = contentObject.checkAccess(user, permission,checkChilds); 687 } 688 } 689 } catch (JahiaException ex) { 690 logger.debug("Cannot load ACL ID " + getAclID(), ex); 691 } 692 return result; 693 } 694 695 703 public boolean checkAccess(JahiaUser user, int permission, boolean checkChilds,boolean forceChildRights) { 704 boolean result = false; 705 try { 706 JahiaBaseACL acl = getACL(); 707 result = acl.getPermission (user, permission); 708 if(result && forceChildRights) { 709 List childs = getChilds(user, Jahia.getThreadParamBean().getEntryLoadRequest()); 710 for (int i = 0; i < childs.size() && result; i++) { 711 ContentObject contentObject = (ContentObject) childs.get(i); 712 result = contentObject.checkAccess(user, permission,checkChilds,forceChildRights); 713 } 714 } 715 } catch (JahiaException ex) { 716 logger.debug("Cannot load ACL ID " + getAclID(), ex); 717 } 718 return result; 719 } 720 721 739 public boolean willBeCompletelyDeleted(String markDeletedLanguageCode, 740 Set activationLanguageCodes) 741 throws JahiaException { 742 743 if (ContentObject.SHARED_LANGUAGE.equals(markDeletedLanguageCode) ){ 744 return true; 745 } 746 747 Set deactivatedLanguageCodes = new HashSet(); 748 JahiaSite jahiaSite = ServicesRegistry.getInstance().getJahiaSitesService().getSite(getSiteID()); 749 if (jahiaSite != null) { 750 Vector siteLanguageSettings = jahiaSite.getLanguageSettings(); 751 Enumeration siteLanguageSettingsEnum = siteLanguageSettings.elements(); 752 while (siteLanguageSettingsEnum.hasMoreElements() ) { 753 SiteLanguageSettings curSettings = (SiteLanguageSettings) siteLanguageSettingsEnum.nextElement(); 754 if (!curSettings.isActivated()) { 755 deactivatedLanguageCodes.add(curSettings.getCode()); 756 } 757 } 758 } 759 760 SortedSet entryStates = this.getActiveAndStagingEntryStates(); 761 Iterator entryStateIter = entryStates.iterator(); 762 ArrayList stagedEntryStates = new ArrayList(); 763 ArrayList activeEntryStates = new ArrayList(); 764 while (entryStateIter.hasNext()) { 765 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStateIter.next(); 766 if (curEntryState.isActive()) { 767 activeEntryStates.add(curEntryState); 768 } else if (curEntryState.isStaging()) { 769 stagedEntryStates.add(curEntryState); 770 } 771 } 772 773 if ( this.isShared() && markDeletedLanguageCode == null ){ 774 if ( activeEntryStates.size()==0 && stagedEntryStates.size()==0){ 775 return true; 776 } 777 if ( stagedEntryStates.size()==0 ){ 778 return false; 779 } 780 ContentObjectEntryState entry = 781 (ContentObjectEntryState)stagedEntryStates.get(0); 782 return ( entry.getVersionID() == 783 ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ); 784 } 785 786 Set languageCodes = new HashSet(); 787 788 for (int i=0; i<activeEntryStates.size(); i++) 790 { 791 ContentObjectEntryState entryState = (ContentObjectEntryState)activeEntryStates.get(i); 792 languageCodes.add(entryState.getLanguageCode()); 793 } 794 795 for (int i=0; i<stagedEntryStates.size(); i++) 797 { 798 ContentObjectEntryState entryState = (ContentObjectEntryState)stagedEntryStates.get(i); 799 if (entryState.getVersionID() == -1) { 800 if (activationLanguageCodes == null ) { 801 languageCodes.remove(entryState.getLanguageCode()); 802 } else { 803 if (activationLanguageCodes.contains(entryState.getLanguageCode()) || 808 deactivatedLanguageCodes.contains(entryState.getLanguageCode()) ) { 809 languageCodes.remove(entryState.getLanguageCode()); 810 } 811 } 812 } else if ( !languageCodes.contains(entryState.getLanguageCode()) ){ 813 languageCodes.add(entryState.getLanguageCode()); 815 } 816 } 817 818 if (markDeletedLanguageCode != null) { 820 languageCodes.remove(markDeletedLanguageCode); 821 } 822 823 if (languageCodes.size() == 0) { 824 return true; 825 } else { 826 return false; 827 } 828 } 829 830 848 public boolean willAllChildsBeCompletelyDeleted(JahiaUser user, 849 String markDeletedLanguageCode, Set activationLanguageCodes) 850 throws JahiaException { 851 852 ArrayList childs = this.getChilds(user,null); 853 int size = childs.size(); 854 ContentObject contentObject = null; 855 for ( int i=0 ; i<size; i++ ){ 856 contentObject = (ContentObject)childs.get(i); 857 if ( !contentObject.willBeCompletelyDeleted(markDeletedLanguageCode, 858 activationLanguageCodes) ){ 859 return false; 860 } 861 if ( !contentObject.willAllChildsBeCompletelyDeleted(user, 862 markDeletedLanguageCode, activationLanguageCodes) ){ 863 return false; 864 } 865 } 866 return true; 867 } 868 869 878 public Set getStagingLanguages(boolean includingMarkedForDeletion) 879 throws JahiaException { 880 return getStagingLanguages(true,includingMarkedForDeletion); 881 } 882 883 892 public Set getStagingLanguages(boolean withActive, 893 boolean includingMarkedForDeletion) 894 throws JahiaException { 895 Set languageCodes = new HashSet(); 896 SortedSet entryStates = getEntryStates(); 897 Iterator entryStateIter = entryStates.iterator(); 898 while (entryStateIter.hasNext()) { 899 ContentObjectEntryState curEntryState = (ContentObjectEntryState) entryStateIter.next(); 900 if ( (withActive && curEntryState.isActive()) || curEntryState.isStaging()) { 901 languageCodes.add(curEntryState.getLanguageCode()); 902 } 903 } 904 905 if (!includingMarkedForDeletion) { 906 Iterator entryStateIter2 = entryStates.iterator(); 908 while (entryStateIter2.hasNext()) { 909 ContentObjectEntryState curEntryState = ( 910 ContentObjectEntryState) entryStateIter2.next(); 911 if (curEntryState.isStaging() && 912 (curEntryState.getVersionID() == -1)) { 913 languageCodes.remove(curEntryState.getLanguageCode()); 914 } 915 } 916 } 917 918 return languageCodes; 919 } 920 921 931 public ContentObjectEntryState getEntryState(ContentObjectEntryState entryState, 932 boolean smallerVersionOnly, boolean activeOrStaging) throws JahiaException { 933 if ( entryState == null ){ 934 return null; 935 } 936 if (entryState.getWorkflowState() < ContentObjectEntryState.WORKFLOW_STATE_ACTIVE){ 937 return getClosestVersionedEntryState(entryState,smallerVersionOnly); 938 } else { 939 Iterator iterator = this.getActiveAndStagingEntryStates().iterator(); 940 ContentObjectEntryState es = null; 941 ContentObjectEntryState activeEntryState = null; 942 ContentObjectEntryState stagingEntryState = null; 943 while ( iterator.hasNext() ){ 944 es = (ContentObjectEntryState)iterator.next(); 945 if ( es.isActive() && 946 es.getLanguageCode().equals(entryState.getLanguageCode()) ){ 947 activeEntryState = es; 948 } 949 if ( es.isStaging() && 950 es.getLanguageCode().equals(entryState.getLanguageCode()) ){ 951 stagingEntryState = es; 952 } 953 } 954 if ( entryState.isActive() && activeEntryState != null ){ 955 return activeEntryState; 956 } 957 if ( entryState.isStaging() && stagingEntryState != null ){ 958 return stagingEntryState; 959 } 960 if ( entryState.isStaging() && activeOrStaging ){ 961 return activeEntryState; 962 } 963 } 964 return null; 965 } 966 967 974 public int getDeleteVersionID() throws JahiaException { 975 int versionID = -1; 976 SortedSet entryStates = this.getEntryStates(); 977 Iterator iterator = entryStates.iterator(); 978 ContentObjectEntryState curEntryState = null; 979 ContentObjectEntryState resultEntryState = null; 980 while ( iterator.hasNext() ){ 981 curEntryState = (ContentObjectEntryState)iterator.next(); 982 if ( curEntryState.getWorkflowState() 983 == ContentObjectEntryState.WORKFLOW_STATE_ACTIVE ){ 984 return -1; 985 } 986 if ( curEntryState.getWorkflowState() 987 == ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ){ 988 989 if ( resultEntryState == null ){ 990 resultEntryState = curEntryState; 991 } else { 992 if ( resultEntryState.getVersionID() < curEntryState.getVersionID() ){ 993 resultEntryState = curEntryState; 994 } 995 } 996 } 997 } 998 if ( resultEntryState != null ){ 999 versionID = resultEntryState.getVersionID(); 1000 } 1001 return versionID; 1002 } 1003 1004 1011 public boolean isDeletedOrDoesNotExist(int versionID) throws JahiaException{ 1012 1013 ArrayList entryStates = 1014 this.getClosestVersionedEntryStates(versionID); 1015 1016 return isDeletedOrDoesNotExist(entryStates); 1017 } 1018 1019 1024 public boolean isDeletedOrDoesNotExist(Collection entryStates) throws JahiaException{ 1025 ContentObjectEntryState entryState = null; 1026 for ( Iterator it = entryStates.iterator() ; it.hasNext(); ){ 1027 entryState = (ContentObjectEntryState)it.next(); 1028 if ( entryState.getWorkflowState() != 1029 ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ){ 1030 return false; 1031 } 1032 } 1033 return true; 1034 } 1035 1036 1042 public boolean isDeleted(int versionID) throws JahiaException{ 1043 ArrayList entryStates = 1044 this.getClosestVersionedEntryStates(versionID); 1045 return isDeleted(entryStates); 1046 } 1047 1048 1053 public boolean isDeleted(Collection entryStates) throws JahiaException{ 1054 int size = entryStates.size(); 1055 if (size == 0) { 1056 return false; 1057 } 1058 ContentObjectEntryState entryState = null; 1059 for ( Iterator it = entryStates.iterator() ; it.hasNext(); ){ 1060 entryState = (ContentObjectEntryState)it.next(); 1061 if ( entryState.getWorkflowState() != 1062 ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ){ 1063 return false; 1064 } 1065 } 1066 return true; 1067 } 1068 1069 1074 public boolean isMarkedForDelete() throws JahiaException{ 1075 Set entryStates = getActiveAndStagingEntryStates(); 1076 if ( entryStates.isEmpty() ){ 1077 return false; 1078 } 1079 HashMap states = new HashMap(); 1080 Iterator iterator = entryStates.iterator(); 1081 Boolean bool = null; 1082 while ( iterator.hasNext() ){ 1083 ContentObjectEntryState entryState = 1084 (ContentObjectEntryState)iterator.next(); 1085 bool = (Boolean )states.get(entryState.getLanguageCode()); 1086 if ( bool == null || !bool.booleanValue() ){ 1087 if (entryState.getVersionID() != 1088 EntryLoadRequest.DELETED_WORKFLOW_STATE) { 1089 states.put(entryState.getLanguageCode(), Boolean.FALSE); 1090 } else { 1091 states.put(entryState.getLanguageCode(), Boolean.TRUE); 1092 } 1093 } 1094 } 1095 1096 iterator = states.values().iterator(); 1097 while ( iterator.hasNext() ){ 1098 bool = (Boolean )iterator.next(); 1099 if ( !bool.booleanValue() ){ 1100 return false; 1101 } 1102 } 1103 return true; 1104 } 1105 1106 1111 public boolean isMarkedForDelete(String languageCode) throws JahiaException { 1112 if ( languageCode == null ){ 1113 return false; 1114 } 1115 1116 Set entryStates = getActiveAndStagingEntryStates(); 1117 ContentObjectEntryState entryState = null; 1118 Iterator iterator = entryStates.iterator(); 1119 1120 while (iterator.hasNext()) { 1121 entryState = (ContentObjectEntryState) iterator.next(); 1122 if (entryState.isStaging() && (this.isShared() 1123 || languageCode.equals(entryState.getLanguageCode())) 1124 && entryState.getVersionID() == 1125 EntryLoadRequest.DELETED_WORKFLOW_STATE) { 1126 return true; 1127 } 1128 } 1129 return false; 1130 } 1131 1132 1133 1140 public abstract void undoStaging(ParamBean jParams) 1141 throws JahiaException; 1142 1143 1146 public abstract boolean isShared (); 1147 1148 1155 public abstract int getAclID(); 1156 1157 public JahiaBaseACL getACL() throws ACLNotFoundException, JahiaException { 1158 return new JahiaBaseACL(getAclID()); 1159 } 1160 1161 1171 public void fireContentActivationEvent (Set languageCodes, 1172 boolean versioningActive, 1173 JahiaSaveVersion saveVersion, 1174 ParamBean jParams, 1175 StateModificationContext stateModifContext, 1176 ActivationTestResults result) 1177 throws JahiaException { 1178 1179 ContentActivationEvent event = new ContentActivationEvent(this,this.getObjectKey(), 1180 jParams.getUser(),languageCodes,versioningActive,saveVersion,jParams,stateModifContext,result); 1181 1182 ServicesRegistry.getInstance().getJahiaEventService() 1183 .fireContentActivation(event); 1184 1185 } 1186 1187 1192 public abstract int getSiteID(); 1193 1194} 1195 | Popular Tags |