Dave Ward fb887123ea Merged V4.1-BUG-FIX to HEAD
44918: Fix for ALF-14850 Opencmis getTotalNumItems doesn't return the correct result when setting MaxItemsPerPage
   - correctly report the max number of items
   44927: ALF-16254 ("Leave Site" behaviour for group based site membership)
   44931: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      44930: Merged V3.4 (3.4.12) to V3.4-BUG-FIX
         44929: Merged V4.1-BUG-FIX to V3.4 (3.4.12)
            42118: ALF-15878 ALF-15741: generate doc and src zip for web-framework-commons and jlan
   44939: Remove svn:mergeinfo
   44985: Merged DEV to V4.1-BUG-FIX
      44981: ALF-17085 : DB2: unexpected index found in database
         Correcting db structure after upgrade from 3.4. Optional statement was added.
   44988: Merged DEV to V4.1-BUG-FIX
      44937: ALF-16756: WebDAV: An error occurs on drag&drop content from local machine to alfresco when inbound move rule configured.
         Add check for content data length during determining existence of content on node.
   44989: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX
      44984: Merged DEV to PATCHES/V4.1.3
         44983: ALF-12425: Can't launch activiti workflow console from Share when external / ntlm / kerberos authentication is used.
         In activiti-admin.get.js generated an absolute URL . Use  url.server + url.context  instead of /alfresco.
      44986: (RECORD ONLY) Merged DEV to PATCHES/V4.1.3
         44937: ALF-16756: WebDAV: An error occurs on drag&drop content from local machine to alfresco when inbound move rule configured.
         Add check for content data length during determining existence of content on node.
      44987: ALF-17331 60k Site Performance: Admin Console | Groups | Browse Groups (include sys groups): Pagination doesn't work correctly
   45008: ALF-17300 - ConcurrentModificationException
   45011: BDE-103 - Timezone test fail when not run from the UK (at least from Maven build)
   45054: Merged from DEV to V4.1-BUG-FIX
     ALF-13312 - If the license does not exist, please specify in the error message
   45055: Fix for ALF-13921. Description of the web project is not updated.
   45063: Slight improvement to test code as part of ALF-15413.
     Changing test code to get companyHome from repositoryHelper rather than Lucene query, which doesn't work on a dev box with ill-configured SOLR/Lucene.
   45170: Merged PATCHES\V4.1.3 to BRANCHES\DEV\V4.1-BUG-FIX
       45161: Fix for     ALF-17341  CLONE - Hyphen not handled correctly in cmis-alfresco search for Aspects/types : " no viable alternative at character 'a' "
   45192: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.1-BUG-FIX:
      45187: (RECORD ONLY) Fix for ALF-16997 Discrepancies between standalone and cluster ehcache config
   45312: Merged V4.0.2 (4.0.2.23-24) to V4.1-BUG-FIX (4.1.4)
      44912: MNT-248 - 4.0.2.22 HOT FIX: Extra version is created saving changes in OpenOffice document via CIFS
      44964: Merged DEV to PATCHES/V4.0.2
         44963: MNT-263 : CLONE - CIFS: Image document version history lost after saving content in Preview on Mac Mountain Lion
         Fix for "Preview" shuffle scenario on Mac Mountain Lion. New ScenarioDoubleRenameShuffle scenario was added for pattern .*\.sb(-[A-Za-z0-9]*){2}. Unit test for correspomding scenario was added.
      45037: Remove PID check from byte range lock list checks. MNT-266.
      45286: MNT-277 - CIFS: Input/output error during saving ods file via OpenOffice. (Linux Specific)
   45319: NORWEGIAN: Translation updates.
   45338: Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      45186: ALF-17303: fix naming mismatch when deploying alfresco-enterprise-repository artifactId to Maven
      45247: Part 2: Better fix for     ALF-16359 Fix SOLR logging in production and other environments
      45265: ALF-17337 Read time out when browsing trash can 
      45298: ALF-17389: Merged: CLOUD1 to V4.1.3
         45082: CLOUD-1139: Cloud feednotifier running on 2 boxes
         - FeedNotifierImpl modified to use reliable lock refresh
         - Added additional debug logging to AbstractUserNotifier just in case we have to prove duplicate entries are still being processed
         - For full debug logging set
            log4j.logger.org.alfresco.repo.activities.feed.FeedNotifier=debug 
         - Happy New Year!
   45355: ALF-17389: Fix build error
   45357: Fix for     ALF-17430  CMIS valid relationships do not check the source and target are valid CMIS docs or folders.
   45363: Merge CLOUD1-BUG-FIX to V4.1-BUG-FIX
     42576 : Job Locking of PostLookup
   45367: Build fix corrections to merge 45363
   45381: ALF-17389 : Implementing Activities Job Lock.
   45416: Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4) RECORD ONLY
      45415: ALF-17389: Merged V4.1-BUG-FIX to V4.1.3 (4.1.3)
         << Previous merge was to the wrong branch >>
         45363: Merge CLOUD1-BUG-FIX to V4.1-BUG-FIX
           42576 : Job Locking of PostLookup
         45367: Build fix corrections to merge 45363
         45381: ALF-17389 : Implementing Activities Job Lock.
   45424: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2013_01_05 to BRANCHES/DEV/V4.1-BUG-FIX:
      45235: ALF-15604 : Oracle: schema reference files missing nvarchar2 column sizes
   45425: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2013_01_05 to BRANCHES/DEV/V4.1-BUG-FIX:
      45236: ALF-15604 : Oracle: schema reference files missing nvarchar2 column sizes
   45480: ALF-17224: There will not be a "pageList" object in the freemarker model if a wiki page does not exist in a site and the wiki dashlet will cause an error on the site
   45482: Fixed ALF-11036, applied the patch, ran the tests.
   45485: ALF-17224: If the wiki page which was configured in the wiki dashlet will be deleted the dashlet will cause an error. The result of the call must be checked.
   45513: MNT-279: Use binary search in cached authority search to cut down search time when a group contains an astronomical number of authorities
   - Experimental fix to cut down on severe profiling hit
   45542: Fix for ALF-17443 - Contributors cannot edit their own discussion reply
   --This line, and th se below, will be ignored--
   M    root/projects/remote-api/source/java/org/alfresco/repo/web/scripts/discussion/ForumPostPut.java
   M    root/projects/remote-api/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionRestApiTest.java
   45550: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      44920: ALF-11315 removed date localisation on blogpost.lib.ftl dates and corrected date format on pubDate within postlist-rss.get.rss.ftl (iso8601 was being used instead of the required RFC822)
      44936: Fix build
      44967: Merged V3.4 to V3.4-BUG-FIX
         44966: Merged PATCHES/V3.4.11 to V3.4 (3.4.12)
            44891: ALF-17339: Merged DEV to V3.4.11 (3.4.11.2)
               44877: MNT-265: possible improvement to Alfresco SQL query?
               -   Add getOneTxnsByCommitTimeDescending function that makes efficient query to find most recent transaction in time range.
            44951: ALF-17325 / MNT-274: Merged HEAD to PATCHES/V3.4.11
               33015: ALF-11837 - Alfresco 4.0 SMTP Inbound does not work with messages without From and To Headers.
      45191: Merged BRANCHES/V3.4 to BRANCHES/DEV/V3.4-BUG-FIX:
         45172: Fixed ALF-16140: Blank filetype icon is displayed for tiff image
      45436: Merged HEAD to BRANCHES/DEV/V3.4-BUG-FIX:
         31107: Google Docs SSL error
             * Fixed SSL required error that has appeared recently.
             * Google seemingly no longer supports non secure access to GDoc API.
             * Default URL's fixed up.
      45547: Merged V3.4 to V3.4-BUG-FIX
         45166: ALF-17339: Merged V3.4.11 (3.4.11.4) to V3.4 (3.4.12)
            45162: Merged DEV to V3.4.11 (3.4.11.4)
               44877: MNT-275 Possible issue with MNT-265 fix
                  - SQL from original HF should have used < rather than <= for upper time limit.
         45230: Merged DEV to V3.4 (3.4.12)
            45203: ALF-16992 : patch.fixAclInheritance is failing on sharedAclsThatDoNotInheritCorrectlyFromThePrimaryParent
            Ignoring of repeated ACL added
         45233: Mark the NFS server as active during startup. ALF-16228.
         45287: ALF-12145 Calendar autocomplete for advanced search form incorrectly handles zeros 
         45380: ALF-17461: There is different size of wcm-bootstrap-context.xml file from installer and archive
         - Replicated changes from ALF-11644 to Bitrock-installed copy of wcm-bootstrap-context.xml 
         45454: ALF-17396, ALF-13805: Merged V4.1-BUG-FIX (4.1.4) to V3.4 (3.4.12)
            Revision: 45452
            Author: kroast
            Date: 16 January 2013 09:59:45
            Message:
            Corrected config check for ALF-16413 - Share asks for Basic-Auth while not needed trying to access RSS feeds (thus breaking SSO).
            ----
            Modified : /alfresco/BRANCHES/DEV/V4.1-BUG-FIX/root/projects/slingshot/source/java/org/alfresco/web/site/servlet/SlingshotFeedController.java
         45491: Merge DEV to V3.4 (V3.4.12)
            45473: ALF-11956: WCM accessibility
            DOJO time picker has been fixed to allow selection of hours and minutes, using keyboard. Missing JavaScript key event handlers have been added.
            CSS class checking has been fixed in 'alfresco.xforms.FocusResolver' in 'xforms.js' to support all versions of IE. Some other minor changes...
         45543: Merged V4.1 to V3.4
            44743: ALF-17533 / ALF-17117: Created article or publication cant be viewed on WQS site
            - Further corrections to locking to avoid deadlocks
            44682: ALF-17512 / ALF-17118 WQS: Impossible to upload document to publications space
               - Only first part to do with the transformation failure has been committed. 
            44653: ALF-17533 / ALF-17117: Created article or publication cant be viewed on WQS site
            - Missed file from previous checkin
            44652: ALF-17533/ ALF-17117: Created article or publication cant be viewed on WQS site
            - Fixes by Dmitry Vaserin
            - Removed unnecessary outer read locks from getRelatedAssets and getRelatedAsset to prevent deadlock
            - Correct markup error when node doesn't have tags
         45546: ALF-17512: Corrections to property names by Pavel
      45548: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY)
         44977: Merged V3.4-BUG-FIX to V3.4
            44936: Fix build
   45553: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      45523: Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX:
         45482: Fixed ALF-11036, applied the patch, ran the tests.
   45557: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      45556: Merged V3.4 to V3.4-BUG-FIX
         45554: Latest translations from Gloria for revision 45205
   45568: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX
      45421: Merged HEAD to PATCHES\V4.1.3
          44243: Merged BRANCHES\DEV\AUTH_BRIDGE to HEAD
              43735: Final part of ALF-14861 	  SOLR to scale for non-admin users in 100k sites and a subgroup of each of 1000 independent groupings with 1000 subgroups
                     ALF-17489  ALF-17456
      45428: ALF-17455 : BM-0013: SOAK01_04: Activities Feed Cleaner query runs for minutes
      45489: ALF-17455 : BM-0013: SOAK01_04: Activities Feed Cleaner query runs for minutes
   45569: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX (RECORD ONLY)
      45564: ALF-17492: WebScript errors must contain useful information 
      - So doth Derek decree
      - Copied in Surf revision 1217 changes as class local to share.war to avoid pulling in any more untested Surf changes
   45591: ALF-17465 (Document "social buttons/actions" not showing in document library page while document is being edited (locked))
   45601: ALF-17433 (Document detail version display incorrect document version when clicking on edit off line)
   45611: ALF-17478 - MailMetadataExtracter does not store all Message-Recipient-Address
   45622: Merged HEAD to BRANCHES/DEV/V4.1-BUG-FIX:
      35614: ALF-17598: CLONE - Add range header support to the webDAV servlet
   45633: ALF-17469: JSON message sent back to a client after a category creation is only partially JSON
   --This line, and th se below, will be ignored--
   M    category.post.json.ftl
   45641: Fix non-ASCII character in source comment
   45649: ALF-17556 (Share not redering URL correctly in description field)
   45650: Manually merged HEAD to BRANCHES/DEV/V4.1-BUG-FIX:
      - Changes to StreamContent from merge of THOR1_SPRINTS to HEAD in r34698
   45651: Merged HEAD to BRANCHES/DEV/V4.1-BUG-FIX:
      45222: ALF-17599: CLONE - Support For HTTP Range Requests in Repository WebScripts
           - Added HttpRangeProcessor.processRange which takes a WebScriptResponse parameter instead of HttpServletResponse
           - Changed HttpRangeProcessor.processSingeRange and HttpRangeProcessor.processMultiRange to accept a generic Object parameter then cast to the appropriate WebScriptResponse or HttpServletResponse
           - Added Javadoc to HttpRangeProcessor.processRange
           - Changed StreamContent.streamContentImpl to add code from BaseDownloadContentServlet which does the work of processing the range header from the request
           - Changed StreamContent.streamContentImpl method signature to accept nodeRef and propertyQName parameters needed for multi-range requests
           - Modified methods which override or call StreamContent.streamContentImpl for new method signature, passing in nodeRef and propertyQName or nulls where appropriate
   45655: Merged DEV to V4.1-BUG-FIX (4.1.4)
      45565: ALF-17503 : Lucene search with skipcount > hits fails when RM is installed
      Return a length=0 if a difference of values (count of finded results and results, that need to skip) is < 0
   45672: ALF-17452 (Status can't be updated with a blank status)
   45682: ALF-17444: Transformation of Outlook files (.msg) doesn't work ootb
   45751: Merged DEV to VC4.1-BUG-FIX (4.1.4)
      45748: ALF-17517: Document does not revert to previous version if certain rule is applied to the parent folder.
      Check node existance on ActionExecuterAbstractBase execution. Add unit test for case when inbound rule executed on node that was checked in.
   45758: ALF-12264: Fixed issue with pooled-tasks for groups with same name across tenants
   45761: Block r45756 from being merged to V4.1-BUG-FIX
   45765: Fix for     ALF-17153    FTS query parser FTSQueryParser is not debuggable
   45810: ALF-17520: Open Document templates are not tranformed properly for thumbnail and preview generation
   45828: Additional fix for     ALF-17153  FTS query parser FTSQueryParser is not debuggable
   45857: ALF-17516 (SHARE: Admin console of users and groups)
   45873: Remove so-called intermittent test category, so that only RepositoryStartupTest remains as a gatekeeper
   45903: ALF-16611 (When opening My Pages filter, a link to the renamed document becomes red)
   45906: ALF-17515: Wrong mimetype name in mimetype-map.xml
      - Changed macroEnabled to macroenabled
   45913: ALF-17462 (In Alfresco explorer invitation to a site does not show the correct options)
   45921: Fix for     ALF-17421  If a property is both multi-valued and multilingual a ClassCastException is thrown when Solr tries to index the property 
   - support multi-valued ML text but not content
   45926: Fix for     ALF-17602    lucene.defaultAnalyserResourceBundleName is not injected anywhere in the spring config
   46024: Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      45585: ALF-17303: alfresco-platform-distribution was not deployed properly to Maven repo
      45621: Removed svn:mergeinfo.  A 1.7 client should do this automatically.
      45669: Fix ALF-17582 - BM-0013: JMeter: Run 02: MT ContentStore caching is not thread safe
      45670: Fix ALF-17589 - BM-0013: JMeter: Run 02: CMISAbstractDictionaryService caching of DictionaryRegistry is not thread safe
      45692: Config option for     ALF-17526  BM-0013: JMeter: Run 02: Improve efficiency of services for SOLRAPIClient.getNodesMetaData 
      - preloading can be controlled + removed incorrect use of the secondary cache that could pull in stale data
      45705: Reverted Config option for     ALF-17526  BM-0013: JMeter: Run 02: Improve efficiency of services for SOLRAPIClient.getNodesMetaData 
      - preloading can be controlled + removed incorrect use of the secondary cache that could pull in stale data
      45716: Fix for ALF-17594 	SolrTracker: CMIS model diff (show 1 repeated diff) => CMIS dictionary re-init x2 (every 15 sec) 
      - only refresh the CMIS dictionary if there was an actual model put
      45755: Extra support to make clear what causes any difference between SOLR reports ALF-17588 	BM-0013: JMeter: Run 02: Deviation was detected in full index check reports for SOLR nodes. 
      - also added RETRY command to retry indexing any nodes that failed with errors.
      45803: Fix for     ALF-17490 Solr indexation problem with certain acls on a customer environment 
      - AclsGet respects the maximum acls requested and does not silently truncate toe 1024
      45829: GERMAN: Translation updates based on EN r45262
      45830: SPANISH: Translation updates based on EN r45262
      45831: FRENCH: Translation updates based on EN r45262
      45832: ITALIAN: Translation updates based on EN r45262
      45833: JAPANESE: Translation updates based on EN r45262
      45834: DUTCH: Translation updates based on EN r45262
      45835: RUSSIAN: Translation updates based on EN r45262
      45836: CHINESE: Translation updates based on EN r45262
      45858: Fix ALF-17634 -on startup FeedNotifier fetches all people slowly
      - switch from GetChildren CQ -> GetPeople CQ
      45859: Fix ALF-17634 -on startup FeedNotifier fetches all people slowly
      - reverse fix for this test ... for now, until we re-implement the deprecated method and fix the test case ;-)
      45951: Fix for     ALF-17687  BM-0013: Soak: Run 02: SolrJSONResultSet must preload nodes 
      - added node preload
      45952: SiteServiceImplTest: Added check that size limiting of results is working (and other minor cleanup)
      45953: Fixed ALF-17702: BM-0013: Soak: Run 02: getCachedChildAuthorities is not caching results 
       - getChildAssocs specifically checks for 'members' associations (was eliminated by code)
       - Cache negative results i.e. when there are no children
      45969: Part fix for     ALF-17526   BM-0013: Soak: Run 02: SOLRAPIClient.getNodesMetaData does N+1 calls to NodeDAO 
      - prependPaths caches nodes for the next layer
      45998: Part 2     ALF-17526   BM-0013: Soak: Run 02: SOLRAPIClient.getNodesMetaData does N+1 calls to NodeDAO 
      - make sure bulk node load works and that assocs are cached
      45999: Alternative implementation for     ALF-17719  BM-0013: Soak: Run 03: Contained authorities cache warmup times are restrictive 
      - bridge table is the default for hasAuthority()  - configurable on AuthorityServiceImpl
      46000: ALF-17574 BM-0013: JMeter: Run 02: Blocked threads on PDFParser.parse 
         - Found two blocking points in PdfBox to do with loading fonts from the class path (this was the main cause) and
           the PDFOperator access to a Synchronised map (identified above by Derek).
         - Note in 1.7.0 of PDFBox generally no font was loaded, but under 1.6.0 it was.
           This may be a bug in 1.7.0
      46001: ALF-17722: Merged V3.4 (3.4.12) to V4.1.3 (4.1.3)
         45629: ALF-17536: Stack Specific: Can't transform pdf to jpg
            - Added TRACE to log env properties using
              log4j.logger.org.alfresco.util.exec.RuntimeExec=trace
         45667: ALF-17536 Can't transform multi page pdf to jpg
            - issue was introduced by ALF-15436 Alfresco 3.4c + Share + TIFF preview only shows the first page
      46018: Merged HEAD to PATCHES/V4.1.3
         41904: Fixes bugs uncovered by JDK 7 upgrade
         - nodeService's interceptors depended on nodeService, resulting in some 'interesting' interceptor ordering in the chain (3 * the normal number in a random order). Now we use a lazy interceptor to break the cycle.
         - When the Content Language was en_GB and an MLText property contained {en_US, en_GB} it would return the en_US one, not taking country codes into account when available
      46023: Follow on to previous check in. Fix up evil cloud sync override of "nodeService" to also not suffer from a cyclic dependency!
   46034: Merged V3.4-BUG-FIX (3.4.13) to V4.1-BUG-FIX (4.1.4)
      45745: Merge V3.4 (3.4.12) to V3.4-BUG-FIX (3.4.13)
         45629: ALF-17536: Stack Specific: Can't transform pdf to jpg
            - Added TRACE to log env properties using
              log4j.logger.org.alfresco.util.exec.RuntimeExec=trace
         45667: ALF-17536 Can't transform multi page pdf to jpg
            - issue was introduced by ALF-15436 Alfresco 3.4c + Share + TIFF preview only shows the first page
         45724: ALF-17533 CLONE - Created article or publication cant be viewed on WQS site
            - Further change required to avoid deadlock
         45743: Correction to AuditComponentTest
            - Test was reporting "Incorrect number of audit entries after failed login expected:<1000> but was:<XXX>"
              where XXX was less than 1000. This was because results was being cleared if all all audit failures were
              not available in the first loop. The results needed to cleared before the first loop rather than in every
              loop. For example an XXX value of 830 would simply indicate that the first loop had received 170 audit
              results and that a second loop was required to get the rest.
      45754: Merged V3.4 (3.4.12) to V3.4-BUG-FIX (3.4.13)
         45747: Correction to AuditComponentTest
            - Okay last commit did not work. Try just waiting a bit longer than a second if we don't have all records.
      45976: Merged DEV to V3.4-BUG-FIX
         45925: ALF-16992 : patch.fixAclInheritance is failing on sharedAclsThatDoNotInheritCorrectlyFromThePrimaryParent
            Added a detection on cyclic loop for "inherits from" field.
   46037: Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      46033: Build fixes
      46032: ALF-17628 (No information is displayed in My Activities and Site Activities dashlets for content creation)
   46095: 
   46100: ALF-17773, ALF-17774, ALF-17775, ALF-17776: Merged V4.0.2 (4.0.2.26) to V4.1-BUG-FIX (4.1.4)
      45469: MNT-280: Merge from HEAD to V4.0.2 (4.0.2.25)
         43617: Fix for     ALF-16795 CMIS 0.8 TCK - load of large content fails
      45875: Merged DEV to V4.0.2 (4.0.2.26)
         45874: MNT-282: Mbean error stemming from cmis create.
         Synchronize initiating ContentStore.
         Add tenant name to object name of ContentStore MBean for preventing overriding of tenant MBeans.
      45904: MNT-285 Content Stream Errors during CMIS load test (Continuation of MNT-280)
         - Added 'advice' above retrying transactions to supply a ReusableContentStream
      45910: MNT-285 Content Stream Errors during CMIS load test (Continuation of MNT-280)
         - Added unit tests - tests both new TempFileProvider method and AlfrescoCmisStreamInterceptor
         - Corrections to interceptor
   46104: ALF-15843: Upgrade swftools back to 0.9.2
   46109: Merged RECORD ONLY V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      46106: Merged V4.1-BUG-FIX (4.1.4) to V4.1.3 (4.1.3)
         46100: ALF-17773, ALF-17774, ALF-17775, ALF-17776: Merged V4.0.2 (4.0.2.26) to V4.1-BUG-FIX (4.1.4)
            45469: MNT-280: Merge from HEAD to V4.0.2 (4.0.2.25)
               43617: Fix for     ALF-16795 CMIS 0.8 TCK - load of large content fails
            45875: Merged DEV to V4.0.2 (4.0.2.26)
               45874: MNT-282: Mbean error stemming from cmis create.
               Synchronize initiating ContentStore.
               Add tenant name to object name of ContentStore MBean for preventing overriding of tenant MBeans.
            45904: MNT-285 Content Stream Errors during CMIS load test (Continuation of MNT-280)
               - Added 'advice' above retrying transactions to supply a ReusableContentStream
            45910: MNT-285 Content Stream Errors during CMIS load test (Continuation of MNT-280)
               - Added unit tests - tests both new TempFileProvider method and AlfrescoCmisStreamInterceptor
               - Corrections to interceptor
      46087: Merge V4.1-BUG-FIX (4.1.4) to V4.1.3 (4.1.3)
         45480: ALF-17224: There will not be a "pageList" object in the freemarker model if a wiki page does not exist in a site and the wiki dashlet will cause an error on the site
   46112: Merged (4.1.3) to V4.1-BUG-FIX (4.1.4)
      46048: ALF-17727 - BM-0013: Soak: Run 03: Site creation leads to contention on sites container
      - disable auditable behaviour on "sites" container (when creating a site)
      46050: ALF-17727 - BM-0013: Soak: Run 03: Site creation leads to contention on sites container
      - disable auditable behaviour on "sites" container (when deleting a site)
      46055: ALF-17729 - BM-0013: Soak: Run 03: ADMRemoteStore optimization to reduce contention on share folders
      - disable auditable behaviour on parent folder (when creating / deleting file)
      46059: Fixed ALF-17756: Thumbnails are being indexed 
       - Add the cm:indexControl aspect to thumbnails at creation time
       - Also prevent timestamp propagation when adding or removing thumbnails
      46077: Following on from rev 46059 (ALF-17756): Fixed up the mock NodeService.createNode call as we now pass in indexControl properties
      46078: Build fix for SiteServiceImplTest.testGroupMembership(SiteServiceImplTest.java:1308)
      46079: Additional fix for out of transaction tests
   46124: Reverse merge
      << Will A. did not intend to commit this >>
      46095: 
   46159: Fixed ALF-16889, Enabled cookie support for /wcs/api/login, independent from SSOAuthenticationFilter, on by default.
   46165: Fix for ALF-17787 - Site Members 'All Members' link should not run query immediately
   46169: Fix for ALF-17787 - Site Members 'All Members' link should not run query immediately - missing file
   46184: Refactoring a test class to use JUnit Rules - as part of attempt to reproduce ALF-17797.
   Using JUnit Rules like this will make it much easier to switch users between test methods.
   Checking in separately from future work as this check-in is a pure refactor.
   46185: ALF-17503 : Lucene search with skipcount > hits fails when RM is installed
      Fix build failures
      - Correct tests which expected -ve number of rows returned in a resultset
   46192: Enhancement to JUnit Rule TemporaryNodes.java as required by fix for ALF-17797.
   This check-in enhances TemporaryNodes to allow for the easy creation of specific named quick files.
   Previously you could only easily create a quick file selected by MIME type.
   Now you can use e.g. 'quickCorrupt.pdf' to get that specific file.
   46194: Fix for ALF-17797. AddFailedThumbnailActionExecuter is failing.
   This check-in adds a test case that reproduces the issue and a fix.
   The fix was to have the AddFailedThumbnailActionExecuter action runAs system.
   This is consistent with the behaviour of the create-thumbnail action itself.
   There is no way via the ActionService to run an action (in this case a compensating action)
   as a nominated user, and therefore I have had to change the implementation of
   AddFailedThumbnailActionExecuter.executeImpl so that it always runs-as system.
   46202: ALF-17644: Document version was increased after canceling editing.
   - Also a better fix for ALF-17167
   46208: ALF-17517 Document does not revert to previous version if certain rule is applied to the parent folder.
      - fix build failures (may still be one left) - Not all actions are node based
   46230: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (4.1.4)
      46227: Filter repository test resources from alfresco.war
   46272: ALF-17841: Upgrade 4.0 --> 4.1.4 ClassCastException from OnPropertyUpdateRuleTrigger
   - Only listen for updates of single-valued content properties and cope with it previously being multi-valued (as can be the case with the devious license property)
   46279: ALF-17810: Imagemagick requires installation of Visual C++ redistributables
   - x86 VC++ 2008 SP1 redistributables now installed to support ImageMagick
   46354: ALF-10569: Reversing r32622 as it was due to an invalid interpretation of a Microsoft spec and should be unnecessary for the correct support of WebDAV 'dead properties'.
   - Correct fix about to be merged in from V3.4-BUG-FIX
   46360: ALF-17697: Create proper source jars, to deploy to Maven repository
   46361: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      45756: ALF-14722: Repeat merge of V4.1-BUG-FIX to V3.4-BUG-FIX - previous merge in r43028 did not bring over all required changes
      42902: Merged DEV to V4.1-BUG-FIX
         42519: ALF-13588: Google Doc failed to authenticate after incorrect password being entered for google account
            Add ability to unregister class behaviours.
            Unregister googledocs behaviours when subsystem stops. 
      45948: Merged DEV/WABSON/V4.1-GOOGLEDOCS-BUG-FIX to DEV/V3.4-BUG_FIX
         45898: ALF-17704 / ALF-16167: 'Edit Offline' checks out document in Google docs
            - Edit in Google Docs action is now decoupled from Edit Offline action
            - The checkout to Google Docs is only performed if a new parameter 'gdc' is set as a paramter when calling the action web script
            - This paramter causes the web script to call a new method checkoutToGoogleDocs() on ScriptNode if the parameter is set
            - The new method simply calls the existing checkout() method after setting a custom property on the transaction
            - The Google Docs policies now check for the presence of this transaction property before sending the document to Google
      45976: ALF-17876: Merged DEV to V3.4-BUG-FIX
         45925: ALF-16992 : patch.fixAclInheritance is failing on sharedAclsThatDoNotInheritCorrectlyFromThePrimaryParent
            Added a detection on cyclic loop for "inherits from" field.
      46041: ALF-17877: Merged DEV to V3.4-BUG-FIX (with corrections)
         46013: ALF-17662 : The deleted via Sharepoint document is not removed from Alfresco but hidden aspect is added for it
         Documents marked with sys:hidden aspect should be invisible through SPP protocol and should be treated as nonexistent.
      46054: ALF-17878 / ALF-17633 add alfresco-mmt.jar in the SDK distribution
      46173: ALF-17879 / ALF-17806: Merged PATCHES/V3.4.10 to V3.4-BUG-FIX
         46099: MNT-293: Merged V4.0-BUG-FIX to PATCHES/V3.4.10
            37969: Fixes for:
            ALF-12772 'Path not found' error in Share if user has no permissions to parent folders in breadcrumb
            ALF-14527 Share - Error to display documents if user has no access to the parent folder
            - Share now correctly supports accessing documents and folders (and details page actions) where the user does not have Read permissions on the parent node.
         46101: MNT-293: AccessDenied using CMIS when user does not have access to parent folder
         - Fix by Vasily
         46125: MNT-293: Correct Kev's logic to do permission checks after resolving a path as system
         46127: Merged V3.4 to PATCHES/V3.4.10
            45743: Correction to AuditComponentTest
               - Test was reporting "Incorrect number of audit entries after failed login expected:<1000> but was:<XXX>"
                 where XXX was less than 1000. This was because results was being cleared if all all audit failures were
                 not available in the first loop. The results needed to cleared before the first loop rather than in every
                 loop. For example an XXX value of 830 would simply indicate that the first loop had received 170 audit
                 results and that a second loop was required to get the rest.  
            45747: Correction to AuditComponentTest
               - Okay last commit did not work. Try just waiting a bit longer than a second if we don't have all records.   
      46195: ALF-17880 / ALF-17378: Web content is not editable after cancelling the Edit Web Content Wizard
      - Fix by Andrey
      46227: Filter repository test resources from alfresco.war
      46324: Merged DEV to V3.4-BUG-FIX (with improvements)
         45602: ALF-10569 / ALF-17519 : SPP is setting residual properties with an unknown name space (urn:schemas-microsoft-com)
         Implemented special case for handling dead webdav properties. New webdav:object aspect was introduced. It is used to 
         store all dead properties that may be set on resource.
      46353: ALF-17881 / ALF-17272: TooManyClauses error due to syntax error in the query generated from UIComponentSelector
      - Fixed typo in Lucene query generation introduced in r20310
   46362: ALF-17876: Re-fix typo introduced in V3.4-BUG-FIX merge
   46363: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      46285: Merged V4.1-BUG-FIX to V3.4-BUG-FIX
         46279: ALF-17810: Imagemagick requires installation of Visual C++ redistributables
         - x86 VC++ 2008 SP1 redistributables now installed to support ImageMagick
      46325: ALF-17863: Merged V4.1-BUG-FIX to V3.4-BUG-FIX
         43649: ALF-16756: WebDAV: An error occurs on drag&drop content from local machine to alfresco when inbound move rule configured. 
         43651: ALF-16756: Fixed typos - I took this code in good faith!
         44988: Merged DEV to V4.1-BUG-FIX
            44937: ALF-16756: WebDAV: An error occurs on drag&drop content from local machine to alfresco when inbound move rule configured.
               Add check for content data length during determining existence of content on node.
   46395: Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      46121: Fixed code warnings
      46123: Further improvements on ALF-17702: BM-0013: Soak: Run 02: getCachedChildAuthorities is not caching result
       - Reduced cache entry size
       - Removed binary sort search for authority entries
       - PS: This is one of the most heavily used code paths in the system
      46153: Merged DEV to V4.1.3 (4.1.3)
         << Lots of other changes in addition to merged code>>
         46093: ALF-16149 : CLONE - User search retrieves all users from the DB regardless of search criteria
            - Re-implemented deprecated method PersonServiceImpl.getPeople(...) to use getPeopleCQ or FTS search
         - Replaced calls to deprecated getPeople with calls to other one where it would end up being called anyway.
         - Fixed PersonServiceTests
         - Fixed GetPeopleCannedQuery to use totalResultCount - tests failed otherwise
         - Added warning to PersonService.getPeopleFilteredByProperty(...) if PROP_FIRSTNAME, PROP_LASTNAME, PROP_USERNAME
           were not being used. This was the one place that 'could' called the deprecated getPeople(...) method with
      	 other properties. Other properties are not included in the search values.
      46178: ALF-17796 - BM-0013: Soak: Run 04: Contention on folder 'user' containing users
      - disable auditable behaviour on parent folders (see also ALF-17729)
      46244: Fix for     ALF-17801   BM-0013: Soak: Run 04: ConcurrentModificationException in AbstractLuceneQueryParser 
      - consistently name anonymous constraints defined on properties
      46265: ALF-17799 - BM-0013: Soak: Run 04: Regular timeouts getting site memberships
      - initial fix: make sure limit cut-off is also applied when processing "groups to expand"
      46286: Fix for     ALF-17801   BM-0013: Soak: Run 04: ConcurrentModificationException in AbstractLuceneQueryParser 
      - build fixes for 
         1) Anonymous over-ridden constraints defined to contain the wrong property definition (no matter)
         2) but above causes name collision on over-ridden anonymous constraints on properties
         3) fix -over ride order to set inherited property definition info before over-ridding the property
      46290: ALF-17799 - BM-0013: Soak: Run 04: Regular timeouts getting site memberships
      - fix SiteActivityTest fallout (and adhere to current API contract)
      46315: ALF-17788: WebSphere: QueryException occurs during the clean startup
      - Corrected regression where FeedNotifier tries to scroll past the end of a result set
      46316: ALF-17702: Fixed regression of MNT-279 fix
      - Avoid sequential search across massive user sets when evaluating ACLs
      46350: Update Maven POM files
       - Upgrade version to 4.1.3
       - Upgrade pdfbox to 1.7.0-alfresco-20130130, to catch up after r46000 fixing ALF-17574
      46370: ALF-17613: Merged V4.0.2 (4.0.2.27) to V4.1.3 (4.1.3)
         46368: MNT-298 HF - Replace file by drag-and-drop over CIFS on Mac OS X and passthru/LDAP-AD gets "is in use" message and deletes the file 
   46421: Fix for ALF-17886. DeleteRenditionActionExecuter Acces is denied.
   With test of course.
   46438: ALF-17622 (Activities with Google Docs are not displayed in My Site Activities and Site Activities dashlets)
   46445: Fix for  ALF-17327 Cannot retrieve documents with a Japanese keyword.
   46457: ALF-17904 (GoogleDocs action doesn't work in doclib view)
   46482: Fix for ALF-17858. NPE in formService webscript.
   46497: Fix for ALF-15371 Instances of java.util.Map interface cannot be accessed in JavaScript
   The fix was to have getDefaultValue(Class) return the map.toString. It was previously returning null.
   46533: ALF-17286: SPP (Cluster specific):Document workspace is not browseable via Share if alfresco.host is pointing to balancer host
    - Ensure that concurrency conditions from AclDAO get propagagedby NodeDAO
   46540: Fix for     ALF-17397  searching based on property value that contains dashes doesn't work in a crossloanguage context using Solr 
   - fixed - also added support for query/index time analysis control for the default cross-language analyser. 
   - Not required to resolve the bug but may be useful to reduce query complexity (e.g. do not generate concatenated tokens for query)
      which could have been used as a work around for this bug if available.
   46546: Merged DEV to V4.1-BUG-FIX
      46494: ALF-17899 TempFileProvider.createTempFile() is not debugable
      Added debug logs.
   46562: ALF-17917: Corrected internationalization of Imap Home folder
   - Unfinished business from ALF-15700
   46563: Fix for ALF-17572 - Grey background in 'Google Docs Theme' when uploading files with IE8
   46564: Fix for ALF-17150 - Edit Online action missing in Share for some mime types (incorrect mimetype for PowerPoint files with SLDM extension)
   46565: ALF-17917: Correction to previous fix
   - Use distinct key spaces.imap_home.childname, because spaces.imapConfig.childname was already being used for other purposes
   46568: Fix for ALF-17757 and ALF-1101
   RSS Dashlet cannot display RSS feed produced by Shareӳ blog / RSS Feed Dashlet unable to read internal Alfesco Share site RSS Feeds
   - Fix implementation from Will Abson
   NOTE: there is a cavet, suggest SSO style config as per ALF-16413 to avoid basic auth pop-up when displaying some feeds.
   46624: removed
   46625: Undo last commit
   46626: Merged V4.1.1 (4.1.1.21) to V4.1-BUG-FIX (4.1.4)
      46602: ALF-17953: Alfresco constantly running full GCs
      - Possible fix to TikaPoweredContentTransformer to make it wrap FileContentReaders as TikaInputStreams which can be cast to Files and appear not to need reading into memory in their entirety in uncompressed form!
      - Fix also required to TikaOfficeDetectParser to avoid it wrapping a TikaInputStream unnecessarily
   46629: RECORD ONLY Merged V4.1.3 (4.1.3) to V4.1-BUG-FIX (4.1.4)
      46622: ALF-17968: Merged V4.0.2 (4.1.1.21) to V4.1.3 (4.1.3)
         46602: ALF-17953: Alfresco constantly running full GCs
         - Possible fix to TikaPoweredContentTransformer to make it wrap FileContentReaders as TikaInputStreams which can be cast to Files and appear not to need reading into memory in their entirety in uncompressed form!
         - Fix also required to TikaOfficeDetectParser to avoid it wrapping a TikaInputStream unnecessarily
         46607: ALF-17953 Alfresco constantly running full GC's - some java.lang.threads holding around 9Gb of memory
            - Added transformation limits to the 8 TikaPoweredContentTransformer based transformers, so that the maxSourceSizeKBytes
              can be set for each transformer and for each source mimetype used by each transformer.
            - maxSourceSizeKBytes set to 40MB for the newer 2007 MS office types (4 char ext).
         46619: ALF-17953 Alfresco constantly running full GC's - some java.lang.threads holding around 9Gb of memory
            - Changed maxSourceSizeKBytes values from 40MB back to -1 for the newer 2007 MS office types (4 char ext).
   46636: Fix for     ALF-13442      Tomcat memory leak warnings occur during the shutdown
   46679: Merged DEV to V4.1-BUG-FIX (4.1.4)
      46659: ALF-17631 : Errors/Exception during stress tests of CMIS GET children
      RetryingTransactionHelper has now ability to handle pre-configured exceptions as retriable in addition to default list of exceptions.
   46683: Merge PATCHES/V4.1.3 to V4.1-BUG-FIX (4.1.4)
      46637: Update the notice.txt and licenses with the latest modifications
   Add Microsoft Visual C++ 2008 Redistributable Package in the notice.txt
   46693: RECORD ONLY Merged V3.4-BUG-FIX (3.4.13) to V4.1-BUG-FIX (4.1.4)
      46692: ALF-17984: Merged V3.4.12 (3.4.12.2) to V3.4-BUG-FIX (3.4.13)
         46680: MNT-307: DEV to V3.4.12 (3.4.12.2)
            46659: ALF-17631 : Errors/Exception during stress tests of CMIS GET children
            RetryingTransactionHelper has now ability to handle pre-configured exceptions as retriable in addition to default list of exceptions.
            - Change to opencmis-context.xml on DEV (based on 4.1.4) was made to cmis-ws-context.xml on V3.4.12
   46694: Merged DEV to V4.1-BUG-FIX (4.1.4)
      46686: ALF-17631 : Errors/Exception during stress tests of CMIS GET children
      Unit test add for RetryingTransactionHelper to test extra exceptions are rertied correctly.
   46724: create-site.css and create-site.js will be included in the header (share-config.xml) therefore there is no reason to include them in the freemarker templates.
   46759: Merged DEV to V4.1-BUG-FIX (4.1.4)
      46734: ALF-17873 Missing versionLabel property after Version2ServiceImpl.restore()
      1. In Version2ServiceImpl.restore() to props Map was added ContentModel.PROP_VERSION_LABEL property.
      2. In VersionServiceImplTest.testRestore() was added the check that ContentModel.PROP_VERSION_LABEL property is correct.
   46760: Merged DEV to V4.1-BUG-FIX (4.1.4)
      46433: ALF-16883: Incorrect message occurred when delete Workspace if document is locked.
      Not possible to change MS Office message - have improved alfresco log message
   46782: ALF-17317 4.0.2.23 HOT FIX: OpenOffice server conversion failed 
   46783: ALF-17546 OOXMLThumbnailContentTransformer is not registered to handle special Office document types, such as templates and macro-enabled variants of document / template 
   46797: Restore missing mergeinfo accidentally removed in r46562
   46799: ALF-17546 OOXMLThumbnailContentTransformer is not registered to handle special Office document types, such as templates and macro-enabled variants of document / template
      - typo in mimetype case
   46916: ALF-17174 pdf2swf supports converting N first pages but alfresco does not support it via the pageLimit 
   46933: ALF-8144: Drastically improving performance using lazy-loaded WorklfowTask properties and path + improved the way share pages workflow-tasks to prevent building full model for unneeded tasks
   46946: ALF-18000: Startup script depends on the working directory where it is run
   - Changed vti.properties to
   vti.server.ssl.keystore=${dir.keystore}/vti.ssl.keystore 
   46995: Improvement related to     ALF-17380   Solr queries running slowly 
   - reader -> acl cache is built on demand (and warmed via authority warming)
   - this will mean it is not eagerly built for the archive store where it would be little used, and could be configured off for this case
   47032: ALF-17804: cmisatom URL (opencmis backed by Apache Chemistry OpenCMIS) does not support External authentication
    - Now it supports all kinds of authentication because it sits behind Alfresco's authentication filters
    - Fix researched by Alex Mukha
   47033: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      46453: ALF-18122 / ALF-17708: Incorrect behavior of "Show/Hide Breadcrumb" button when RM is installed
      - ContentService.getReader() now triggers a transaction retry if content is found to have disappeared under its feet due to eager content cleaning
      46495: ALF-18122 / ALF-17708: Incorrect behavior of "Show/Hide Breadcrumb" button when RM is installed
      - lower impact fix will only throw retryable exception if stream is accessed
      46822: ALF-18123: Merge Dev to V3.4-BUG-FIX
        ALF-17408 : Content is not displayed in imap folder after recovering
      46823: ALF-18124 / ALF-18091: Fix for MNT-311 - authentication challenge not present when users open direct links below /share/proxy/alfresco/cmis/i
      46927: ALF-18124 / ALF-18091: Merged PATCHES/V3.4.10 to V3.4-BUG-FIX
         46925: Merged V3.4-BUG-FIX to PATCHES/V3.4.10 (with correction)
            46823: Fix for MNT-311 - authentication challenge not present when users open direct links below /share/proxy/alfresco/cmis/*/content
      46942: ALF-17990: Fix security descriptors for new FileFolderService isHidden setHidden methods
      47021: ALF-18125: Merged DEV to V3.4-BUG-FIX
         46825: ALF-17681 : Lucene Search queries with PATH doesn't work in tenants
         A JUnit test was implemented to show that the PATH Lucene indexes are not created correctly for tenants. 
         46968: ALF-17681 : Lucene Search queries with PATH doesn't work in tenants
         The creation of PATH indexes is now made in context of multi tenant System user to run the reindexing process correctly in unauthenticated threads.
   47034: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      47030: ALF-16102: Merged PATCHES/V3.4.10 to V3.4-BUG-FIX (RECORD ONLY)
         41755: ALF-16013: Merged V4.1-BUG-FIX to PATCHES/V3.4.10
            41539: ALF-15899: Inbound email does not support multiple recipient folders
               - Fix by Dmitry Vaserin
      47031: ALF-18121: Merged PATCHES/V3.4.11 to V3.4-BUG-FIX
         46978: MNT-320: Merged HEAD to PATCHES/V3.4.11:
            36623: ALF-10243: form-service date-control now allows configuring only to send date-component of date-only formfields (timezone and time-component is reset server-side to prevent unnecesairy timezone-issues)
   47035: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX
      46398: Fix for     ALF-17889   Alfresco failing as constraint in extension model cannot be defined 
      - use the namespace from the containing model and not the over-ridden property.
      46426: Merged BRANCHES/DEV/V4.1-BUG-FIX to PATCHES/V4.1.3:
         46421: Fix for ALF-17886. DeleteRenditionActionExecuter Acces is denied.
      46446: ALF-17864: BM-0013: Soak: Run 05: SiteService.listSites(username, size) performance (=> via listSitesImpl)
      - isAuthorityContained made to prune its search drastically - it caches hits and misses speeding up the search in a deeply nested group hierarchy such as SAP's
      - To avoid huge memory impact with lots of duplicate copies of authority names a pool of authority names is shared across all threads
      - getContainingAuthoritesInZone reinstated for site listing as it warms the same caches as the ACLs
      - Derek's latest tests with the changes applied showed a good speed up
      46501: ALF-17929: BM-0013: Soak: Run 06: /api/sites/{shortname}/memberships/{authorityname} / SiteServiceImpl.getMembersRoleInfo performance poor
      - Possible fix to regression caused by ALF-16254
      - A very inefficient route was being taken towards checking a user's indirect site role
      46502: ALF-17930: BM-0013: Soak: Run 06: ConcurrentModificationException in AuthorityDAOImpl
      - Don't try to mutate the set returned by getContainingAuthorities()
      46503: ALF-17929: BM-0013: Soak: Run 06: /api/sites/{shortname}/memberships/{authorityname} / SiteServiceImpl.getMembersRoleInfo performance poor
      - Further optimizations to prevent unnecessary recursion in AuthorityDAOImpl.listAuthorities()
      46506: ALF-17929: BM-0013: Soak: Run 06: /api/sites/{shortname}/memberships/{authorityname} / SiteServiceImpl.getMembersRoleInfo performance poor
      - Fixed typo producing invalid membership results
      46627: ALF-17967: Error in org.alfresco.repo.workflow.WorkflowServiceImpl.getPooledTasks on StartUp.
      - Logic error in org.alfresco.repo.workflow.WorkflowServiceImpl.getPooledTasks() introduced in ALF-14861 / r45421
      - Rather than fixing the screwy logic (which I think would cause a major performance hit) I'm reinstating the 4.1.2 "cut off after 100 groups" behaviour
      46630: Merged 4.1-BUG-FIX to PATCHES/V4.1.3
         46562: ALF-17917: Corrected internationalization of Imap Home folder
         - Unfinished business from ALF-15700
         46565: ALF-17917: Correction to previous fix
         - Use distinct key spaces.imap_home.childname, because spaces.imapConfig.childname was already being used for other purposes
      46779: ALF-17967: Error in org.alfresco.repo.workflow.WorkflowServiceImpl.getPooledTasks on StartUp.
      - Improved fix that uses the bridge table cache if it is available
      - Groups queried for pooled tasks still limited to 100 by default but can be configured with system.workflow.maxAuthoritiesForPooledTasks
      - Overall number of results can be cut off with system.workflow.maxPooledTasks
      47013: Fix HiddenAspect to NOT use permission-checking NodeService
       - Should fix ALF-17605: CLONE - Severe performance problems with Group ACL checking under stress test 
      47018: (RECORD ONLY) Disabled EmailServiceImplTest.testEmailContributorsAuthority pending ALF-17979
   47036: Merged PATCHES/V4.1.2 to V4.1-BUG-FIX
      46180: Merged DEV to PATCHES/V4.1.2
         46170: MNT-299 : CLONE - Activity feeds get not generated in private sites for added files if username in LDAP-AD contains uppercase letters
            Improved debug logging for Activity Feed and Activity Post DAOs.
   47037: ALF-17973 (Incorrect name (title.single/title.multi) for "cloud target selection" window when RM is installed)
   47042: RM-601 (Copy/Move dialog causes an error in firebug console)
   47047: DE: Translation update based on EN r46507
   47048: SPANISH: Translation update based on EN r46507
   47049: FRENCH: Translation update based on EN r46507
   47050: ITALIAN: Translation update based on EN r46507
   47051: NORWEGIAN: Translation update based on EN r46507
   47052: JAPANESE: Translation update based on EN r46507
   47089: ALF-17089 (Displaying Url Name instead of site Name in Select form)
   47102: New Norwegian translations from Gloria plus Bitrock configuration to enable them
   47110: ALF-10243: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      47105: ALF-18121: Merged PATCHES/V3.4.11 to V3.4-BUG-FIX
         47040: MNT-323: Fixed issue with passing empty due date when starting workflow
         47101: MNT-320: also applied fix to wcmquickstart module
      47109: ALF-18121: Merged PATCHES/V3.4.11 to V3.4-BUG-FIX
         47106: MNT-320: Merged V4.1-BUG-FIX to PATCHES/V3.4.11
            41010: ALF-15697: Not possible to start workflow not specifying the Due Date
               - Regression caused by ALF-10243
   47135: DUTCH: Translation update based on EN r46507
   47137: RUSSIAN: Translation update based on EN r46507
   47138: CHINESE: Translation update based on EN r46507
   47141: Fix for     ALF-17979    EmailServiceImplTest intermittently failing
   47147: Part 2 of    ALF-17979   EmailServiceImplTest intermittently failing 
   - fix related cache to avoid any future issue
   47148: ALF-17804: Fix NPE
   47171: ALF-18060: removing obsolete expensive sorting and preventing too many variable-queries to be performed when listing COMPLETED WorkflowTask


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47186 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2013-02-27 11:56:13 +00:00

2355 lines
107 KiB
Java

/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.version;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import junit.framework.AssertionFailedError;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.version.common.VersionUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionServiceException;
import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
/**
* versionService test class.
*
* @author Roy Wetherall, janv
*/
public class VersionServiceImplTest extends BaseVersionStoreTest
{
private static Log logger = LogFactory.getLog(VersionServiceImplTest.class);
private static final String UPDATED_VALUE_1 = "updatedValue1";
private static final String UPDATED_VALUE_2 = "updatedValue2";
private static final String UPDATED_VALUE_3 = "updatedValue3";
private static final String UPDATED_CONTENT_1 = "updatedContent1";
private static final String UPDATED_CONTENT_2 = "updatedContent2";
private static final String UPDATED_CONTENT_3 = "updatedContent3";
private static final String PWD_A = "passA";
private static final String USER_NAME_A = "userA";
private VersionableAspect versionableAspect;
private List<String> excludedOnUpdateProps;
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
versionableAspect = (VersionableAspect) applicationContext.getBean("versionableAspect");
excludedOnUpdateProps = versionableAspect.getExcludedOnUpdateProps();
}
@Override
protected void onTearDownAfterTransaction() throws Exception
{
super.onTearDownAfterTransaction();
versionableAspect.setExcludedOnUpdateProps(excludedOnUpdateProps);
versionableAspect.afterDictionaryInit();
}
public void testSetup()
{
// NOOP
}
/**
* Tests the creation of the initial version of a versionable node
*/
public void testCreateIntialVersion()
{
NodeRef versionableNode = createNewVersionableNode();
createVersion(versionableNode);
}
/**
* Test creating a version history with many versions from the same workspace
*/
public void testCreateManyVersionsSameWorkspace()
{
NodeRef versionableNode = createNewVersionableNode();
createVersion(versionableNode);
// TODO mess with some of the properties and stuff as you version
createVersion(versionableNode);
// TODO mess with some of the properties and stuff as you version
createVersion(versionableNode);
VersionHistory vh = this.versionService.getVersionHistory(versionableNode);
assertNotNull(vh);
assertEquals(3, vh.getAllVersions().size());
// TODO check list of versions ... !
}
/**
* Tests the creation of multiple versions of a versionable node with null version properties
*/
public void testCreateManyVersionsWithNullVersionProperties()
{
this.versionProperties = null;
NodeRef versionableNode = createNewVersionableNode();
createVersion(versionableNode);
createVersion(versionableNode);
createVersion(versionableNode);
VersionHistory vh = this.versionService.getVersionHistory(versionableNode);
assertNotNull(vh);
assertEquals(3, vh.getAllVersions().size());
}
/**
* Test versioning a non versionable node ie: no version apsect
*/
public void testCreateInitialVersionWhenNotVersionable()
{
NodeRef node = createNewNode(); // not marked as versionable
createVersion(node);
}
// TODO test versioning numberious times with branchs implies by different workspaces
/**
* Test versioning the children of a verionable node
*/
public void testVersioningChildren()
{
NodeRef versionableNode = createNewVersionableNode();
// Snap shot data
String expectedVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
// Version the node and its children
Collection<Version> versions = this.versionService.createVersion(
versionableNode,
this.versionProperties,
true);
// Check the returned versions are correct
CheckVersionCollection(expectedVersionLabel, beforeVersionTime, versions);
// TODO check the version history is correct
}
/**
* Test versioning many nodes in one go
*/
public void testVersioningManyNodes()
{
NodeRef versionableNode = createNewVersionableNode();
// Snap shot data
String expectedVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
// Version the list of nodes created
Collection<Version> versions = this.versionService.createVersion(
this.versionableNodes.values(),
this.versionProperties);
// Check the returned versions are correct
CheckVersionCollection(expectedVersionLabel, beforeVersionTime, versions);
// TODO check the version histories
}
/**
* Helper method to check the validity of the list of newly created versions.
*
* @param beforeVersionTime the time before the versions where created
* @param versions the collection of version objects
*/
private void CheckVersionCollection(String expectedVersionLabel, long beforeVersionTime, Collection<Version> versions)
{
for (Version version : versions)
{
// Get the frozen id from the version
String frozenNodeId = null;
// Switch VersionStore depending on configured impl
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
{
// V2 version store (eg. workspace://version2Store)
frozenNodeId = ((NodeRef)version.getVersionProperty(Version2Model.PROP_FROZEN_NODE_REF)).getId();
}
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
{
// Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
frozenNodeId = (String)version.getVersionProperty(VersionModel.PROP_FROZEN_NODE_ID);
}
assertNotNull("Unable to retrieve the frozen node id from the created version.", frozenNodeId);
// Get the origional node ref (based on the forzen node)
NodeRef originalNodeRef = this.versionableNodes.get(frozenNodeId);
assertNotNull("The versionable node ref that relates to the frozen node id can not be found.", originalNodeRef);
// Check the new version
checkNewVersion(beforeVersionTime, expectedVersionLabel, version, originalNodeRef);
}
}
private void CheckVersionHistory(VersionHistory vh, List<Version> expectedVersions)
{
if (vh == null)
{
assertNull(expectedVersions);
}
else
{
Iterator<Version> itr = expectedVersions.iterator();
for (Version version : vh.getAllVersions())
{
Version expectedVersion = itr.next();
assertEquals(version.getVersionLabel(), expectedVersion.getVersionLabel());
assertEquals(version.getFrozenStateNodeRef(), expectedVersion.getFrozenStateNodeRef());
}
assertFalse(itr.hasNext());
}
}
/**
* Tests the version history
*/
public void testNoVersionHistory()
{
NodeRef nodeRef = createNewVersionableNode();
VersionHistory vh = this.versionService.getVersionHistory(nodeRef);
assertNull(vh);
}
/**
* Tests getVersionHistory when all the entries in the version history
* are from the same workspace.
*/
public void testGetVersionHistorySameWorkspace()
{
NodeRef versionableNode = createNewVersionableNode();
Version version1 = addToVersionHistory(versionableNode, null);
Version version2 = addToVersionHistory(versionableNode, version1);
Version version3 = addToVersionHistory(versionableNode, version2);
Version version4 = addToVersionHistory(versionableNode, version3);
addToVersionHistory(versionableNode, version4);
}
/**
* Same as testGetVersionHistorySameWorkspace except that the order of
* of db ids is mixed up and a comparator is need to fix it (MNT-226).
*/
public void testIdsOutOfOrder()
{
if (versionService instanceof Version2ServiceImpl)
{
setOutOfOrderIdsVersionService("org.alfresco.repo.version.common.VersionLabelComparator");
testGetVersionHistorySameWorkspace();
}
}
/**
* Same as testIdsOutOfOrder but without the comparator so should fail.
*/
public void testIdsOutOfOrderFails()
{
if (versionService instanceof Version2ServiceImpl)
{
try
{
setOutOfOrderIdsVersionService("");
testGetVersionHistorySameWorkspace();
fail("Expected this to fail");
}
catch (AssertionFailedError e)
{
System.out.print("A test failed as EXPECTED: "+e.getMessage());
}
}
}
/**
* Sets the versionService to be one that has is db ids out of order
* so would normally have versions displayed in the wrong order.
* @param versionComparatorClass name of class to correct the situation.
*/
private void setOutOfOrderIdsVersionService(String versionComparatorClass)
{
Version2ServiceImpl versionService = new Version2ServiceImpl()
{
@Override
protected List<Version> getAllVersions(NodeRef versionHistoryRef)
{
List<Version> versions = super.getAllVersions(versionHistoryRef);
if (versions.size() > 1)
{
// Make sure the order changes
List<Version> copy = new ArrayList<Version>(versions);
do
{
Collections.shuffle(versions);
} while (versions.equals(copy));
}
return versions;
}
};
versionService.setNodeService(nodeService);
versionService.setDbNodeService(dbNodeService); // mtAwareNodeService
versionService.setSearcher(versionSearchService);
versionService.setDictionaryService(dictionaryService);
versionService.setPolicyComponent(policyComponent);
versionService.setPolicyBehaviourFilter(policyBehaviourFilter);
versionService.setPermissionService(permissionService);
versionService.setOnlyUseDeprecatedV1(false);
versionService.setVersionMigrator(versionMigrator);
versionService.setVersionComparatorClass(versionComparatorClass);
versionService.initialise();
setVersionService(versionService);
}
/**
* Adds another version to the version history then checks that getVersionHistory is returning
* the correct data.
*
* @param versionableNode the versionable node reference
* @param parentVersion the parent version
*/
private Version addToVersionHistory(NodeRef versionableNode, Version parentVersion)
{
Version createdVersion = createVersion(versionableNode);
VersionHistory vh = this.versionService.getVersionHistory(versionableNode);
assertNotNull("The version history should not be null since we know we have versioned this node.", vh);
if (parentVersion == null)
{
// Check the root is the newly created version
Version root = vh.getRootVersion();
assertNotNull(
"The root version should never be null, since every version history ust have a root version.",
root);
assertEquals(createdVersion.getVersionLabel(), root.getVersionLabel());
}
// Get the version from the version history
Version version = vh.getVersion(createdVersion.getVersionLabel());
assertNotNull(version);
assertEquals(createdVersion.getVersionLabel(), version.getVersionLabel());
// Check that the version is a leaf node of the version history (since it is newly created)
Collection<Version> suc = vh.getSuccessors(version);
assertNotNull(suc);
assertEquals(0, suc.size());
// Check that the predessor is the passed parent version (if root version should be null)
Version pre = vh.getPredecessor(version);
if (parentVersion == null)
{
assertNull(pre);
}
else
{
assertNotNull(pre);
assertEquals(parentVersion.getVersionLabel(), pre.getVersionLabel());
}
if (parentVersion != null)
{
// Check that the successors of the parent are the created version
Collection<Version> parentSuc = vh.getSuccessors(parentVersion);
assertNotNull(parentSuc);
assertEquals(1, parentSuc.size());
Version tempVersion = (Version)parentSuc.toArray()[0];
assertEquals(version.getVersionLabel(), tempVersion.getVersionLabel());
}
return createdVersion;
}
/**
* Test revert
*/
@SuppressWarnings("unused")
public void testRevert()
{
// Create a versionable node
NodeRef versionableNode = createNewVersionableNode();
// Store the node details for later
Set<QName> origAspects = this.dbNodeService.getAspects(versionableNode);
// Create the initial version
Version version1 = createVersion(versionableNode);
// Check the history is correct
VersionHistory history = versionService.getVersionHistory(versionableNode);
assertEquals(version1.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version1.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(1, history.getAllVersions().size());
Version[] versions = history.getAllVersions().toArray(new Version[1]);
assertEquals("0.1", versions[0].getVersionLabel());
assertEquals("0.1", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Change the property and content values
this.dbNodeService.setProperty(versionableNode, PROP_1, UPDATED_VALUE_1);
this.dbNodeService.setProperty(versionableNode, PROP_2, null);
ContentWriter contentWriter = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_1);
// Change the aspects on the node
this.dbNodeService.addAspect(versionableNode, ApplicationModel.ASPECT_SIMPLE_WORKFLOW, null);
// Store the node details for later
Set<QName> origAspects2 = this.dbNodeService.getAspects(versionableNode);
// Record this as a new version
Version version2 = createVersion(versionableNode);
// Check we're now seeing both versions in the history
history = versionService.getVersionHistory(versionableNode);
assertEquals(version2.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version2.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(2, history.getAllVersions().size());
versions = history.getAllVersions().toArray(new Version[2]);
assertEquals("0.2", versions[0].getVersionLabel());
assertEquals("0.1", versions[1].getVersionLabel());
assertEquals("0.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Change the property and content values
this.dbNodeService.setProperty(versionableNode, PROP_1, UPDATED_VALUE_2);
this.dbNodeService.setProperty(versionableNode, PROP_2, UPDATED_VALUE_3);
this.dbNodeService.setProperty(versionableNode, PROP_3, null);
ContentWriter contentWriter2 = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter2);
contentWriter2.putContent(UPDATED_CONTENT_2);
String versionLabel = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
// Revert to the previous version, which will loose these changes
this.versionService.revert(versionableNode);
// Check that the version label is unchanged
assertEquals(versionLabel, this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Check that the properties have been reverted
assertEquals(UPDATED_VALUE_1, this.dbNodeService.getProperty(versionableNode, PROP_1));
assertNull(this.dbNodeService.getProperty(versionableNode, PROP_2));
assertEquals(VALUE_3, this.dbNodeService.getProperty(versionableNode, PROP_3));
// Check that the content has been reverted
ContentReader contentReader1 = this.contentService.getReader(versionableNode, ContentModel.PROP_CONTENT);
assertNotNull(contentReader1);
assertEquals(UPDATED_CONTENT_1, contentReader1.getContentString());
// Check that the aspects have been reverted correctly
Set<QName> aspects1 = this.dbNodeService.getAspects(versionableNode);
assertEquals(aspects1.size(), origAspects2.size());
// Check that the history is back how it was
history = versionService.getVersionHistory(versionableNode);
assertEquals(version2.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version2.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(2, history.getAllVersions().size());
versions = history.getAllVersions().toArray(new Version[2]);
assertEquals("0.2", versions[0].getVersionLabel());
assertEquals("0.1", versions[1].getVersionLabel());
assertEquals("0.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
assertEquals("0.2", history.getHeadVersion().getVersionLabel());
// Revert to the first version
this.versionService.revert(versionableNode, version1);
// Check that the version label is correct
assertEquals(versionLabel, this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Check that the properties are correct
assertEquals(VALUE_1, this.dbNodeService.getProperty(versionableNode, PROP_1));
assertEquals(VALUE_2, this.dbNodeService.getProperty(versionableNode, PROP_2));
assertEquals(VALUE_3, this.dbNodeService.getProperty(versionableNode, PROP_3));
// Check that the content is correct
ContentReader contentReader2 = this.contentService.getReader(versionableNode, ContentModel.PROP_CONTENT);
assertNotNull(contentReader2);
assertEquals(TEST_CONTENT, contentReader2.getContentString());
// Check that the aspects have been reverted correctly
Set<QName> aspects2 = this.dbNodeService.getAspects(versionableNode);
assertEquals(aspects2.size(), origAspects.size());
// Check that the version label is still the same
assertEquals(versionLabel, this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Check the history still has 2 versions
// The head version remains as 0.2, but version on the node is 0.1
history = versionService.getVersionHistory(versionableNode);
assertEquals(version2.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version2.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(2, history.getAllVersions().size());
versions = history.getAllVersions().toArray(new Version[2]);
assertEquals("0.2", versions[0].getVersionLabel());
assertEquals("0.1", versions[1].getVersionLabel());
// Head is 0.2, but the node is at 0.1
assertEquals("0.2", history.getHeadVersion().getVersionLabel());
// TODO Shouldn't the node now be at 0.1 not 0.2?
//assertEquals("0.1", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
}
/**
* Test reverting a node that has comments, see ALF-13129
*/
public void testRevertWithComments()
{
NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, PROP_1, "I am before version");
Version version1 = createVersion(versionableNode);
this.dbNodeService.setProperty(versionableNode, PROP_1, "I am after version 1");
VersionHistory vh = this.versionService.getVersionHistory(versionableNode);
assertNotNull(vh);
assertEquals(1, vh.getAllVersions().size());
// Create a new version
Version version2 = createVersion(versionableNode);
//Test a revert with no comments
this.versionService.revert(versionableNode, version1);
assertEquals("I am before version", this.dbNodeService.getProperty(versionableNode, PROP_1));
createComment(versionableNode, "my comment", "Do great work", false);
assertTrue(nodeService.hasAspect(versionableNode, ForumModel.ASPECT_DISCUSSABLE));
assertEquals(1, this.dbNodeService.getProperty(versionableNode, ForumModel.PROP_COMMENT_COUNT));
// Create a new version
this.dbNodeService.setProperty(versionableNode, PROP_1, "I am version 3");
Version version3 = createVersion(versionableNode);
this.dbNodeService.setProperty(versionableNode, PROP_1, "I am after version 3");
createComment(versionableNode, "v3", "Great version", false);
assertEquals(2, this.dbNodeService.getProperty(versionableNode, ForumModel.PROP_COMMENT_COUNT));
//Revert to a version that has comments.
this.versionService.revert(versionableNode, version3);
assertTrue(nodeService.hasAspect(versionableNode, ForumModel.ASPECT_DISCUSSABLE));
assertEquals("I am version 3", this.dbNodeService.getProperty(versionableNode, PROP_1));
}
/**
* This method was taken from the CommmentServiceImpl on the cloud branch
*
* TODO: When this is merged to HEAD, please remove this method and use the one in CommmentServiceImpl
*/
private NodeRef createComment(final NodeRef discussableNode, String title, String comment, boolean suppressRollups)
{
if(comment == null)
{
throw new IllegalArgumentException("Must provide a non-null comment");
}
// There is no CommentService, so we have to create the node structure by hand.
// This is what happens within e.g. comment.put.json.js when comments are submitted via the REST API.
if (!nodeService.hasAspect(discussableNode, ForumModel.ASPECT_DISCUSSABLE))
{
nodeService.addAspect(discussableNode, ForumModel.ASPECT_DISCUSSABLE, null);
}
if (!nodeService.hasAspect(discussableNode, ForumModel.ASPECT_COMMENTS_ROLLUP) && !suppressRollups)
{
nodeService.addAspect(discussableNode, ForumModel.ASPECT_COMMENTS_ROLLUP, null);
}
// Forum node is created automatically by DiscussableAspect behaviour.
NodeRef forumNode = nodeService.getChildAssocs(discussableNode, ForumModel.ASSOC_DISCUSSION, QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussion")).get(0).getChildRef();
final List<ChildAssociationRef> existingTopics = nodeService.getChildAssocs(forumNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Comments"));
NodeRef topicNode = null;
if (existingTopics.isEmpty())
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
props.put(ContentModel.PROP_NAME, "Comments");
topicNode = nodeService.createNode(forumNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Comments"), ForumModel.TYPE_TOPIC, props).getChildRef();
}
else
{
topicNode = existingTopics.get(0).getChildRef();
}
NodeRef postNode = nodeService.createNode(topicNode, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, ForumModel.TYPE_POST).getChildRef();
nodeService.setProperty(postNode, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
nodeService.setProperty(postNode, ContentModel.PROP_TITLE, title);
ContentWriter writer = contentService.getWriter(postNode, ContentModel.PROP_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
writer.setEncoding("UTF-8");
writer.putContent(comment);
return postNode;
}
/**
* Test reverting from Share
*/
@SuppressWarnings("unused")
public void testScriptNodeRevert()
{
CheckOutCheckInService checkOutCheckIn =
(CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
// Create a versionable node
NodeRef versionableNode = createNewVersionableNode();
NodeRef checkedOut = checkOutCheckIn.checkout(versionableNode);
Version versionC1 = createVersion(checkedOut);
// Create a new, first proper version
ContentWriter contentWriter = this.contentService.getWriter(checkedOut, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_1);
nodeService.setProperty(checkedOut, PROP_1, VALUE_1);
checkOutCheckIn.checkin(checkedOut, null, contentWriter.getContentUrl(), false);
Version version1 = createVersion(versionableNode);
checkedOut = checkOutCheckIn.checkout(versionableNode);
// Create another new version
contentWriter = this.contentService.getWriter(checkedOut, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_2);
nodeService.setProperty(checkedOut, PROP_1, VALUE_2);
checkOutCheckIn.checkin(checkedOut, null, contentWriter.getContentUrl(), false);
Version version2 = createVersion(versionableNode);
checkedOut = checkOutCheckIn.checkout(versionableNode);
// Check we're now up to two versions
// (The version created on the working copy doesn't count)
VersionHistory history = versionService.getVersionHistory(versionableNode);
assertEquals(version2.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version2.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(2, history.getAllVersions().size());
Version[] versions = history.getAllVersions().toArray(new Version[2]);
assertEquals("0.2", versions[0].getVersionLabel());
assertEquals("0.1", versions[1].getVersionLabel());
// Add yet another version
contentWriter = this.contentService.getWriter(checkedOut, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_3);
nodeService.setProperty(checkedOut, PROP_1, VALUE_3);
checkOutCheckIn.checkin(checkedOut, null, contentWriter.getContentUrl(), false);
Version version3 = createVersion(versionableNode);
// Verify that the version labels are as we expect them to be
history = versionService.getVersionHistory(versionableNode);
assertEquals(version3.getVersionLabel(), history.getHeadVersion().getVersionLabel());
assertEquals(version3.getVersionedNodeRef(), history.getHeadVersion().getVersionedNodeRef());
assertEquals(3, history.getAllVersions().size());
versions = history.getAllVersions().toArray(new Version[3]);
assertEquals("0.3", versions[0].getVersionLabel());
assertEquals("0.2", versions[1].getVersionLabel());
assertEquals("0.1", versions[2].getVersionLabel());
// Create a ScriptNode as used in Share
ServiceRegistry services = applicationContext.getBean(ServiceRegistry.class);
ScriptNode scriptNode = new ScriptNode(versionableNode, services);
assertEquals("0.3", nodeService.getProperty(scriptNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL));
assertEquals(VALUE_3, nodeService.getProperty(scriptNode.getNodeRef(), PROP_1));
// Revert to version2
// The content and properties will be the same as on Version 2, but we'll
// actually be given a new version number for it
ScriptNode newNode = scriptNode.revert("History", false, version2.getVersionLabel());
ContentReader contentReader = this.contentService.getReader(newNode.getNodeRef(), ContentModel.PROP_CONTENT);
assertNotNull(contentReader);
assertEquals(UPDATED_CONTENT_2, contentReader.getContentString());
assertEquals(VALUE_2, nodeService.getProperty(newNode.getNodeRef(), PROP_1));
// Will be a new version though - TODO Is this correct?
assertEquals("0.4", nodeService.getProperty(newNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL));
// Revert to version1
newNode = scriptNode.revert("History", false, version1.getVersionLabel());
contentReader = this.contentService.getReader(newNode.getNodeRef(), ContentModel.PROP_CONTENT);
assertNotNull(contentReader);
assertEquals(UPDATED_CONTENT_1, contentReader.getContentString());
assertEquals(VALUE_1, nodeService.getProperty(newNode.getNodeRef(), PROP_1));
// Will be a new version though - TODO Is this correct?
assertEquals("0.5", nodeService.getProperty(newNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL));
// All done
setComplete();
try
{
endTransaction();
}
catch(Throwable e)
{
fail("Transaction failed: " + e);
}
}
/**
* Test restore
*/
public void testRestore()
{
// Try and restore a node without any version history
try
{
this.versionService.restore(
new NodeRef(this.testStoreRef, "123"),
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode"));
fail("An exception should have been raised since this node has no version history.");
}
catch (VersionServiceException exception)
{
// We where expecting this exception
}
// Create a versionable node
NodeRef versionableNode = createNewVersionableNode();
// It isn't currently versionable
assertEquals(null, versionService.getVersionHistory(versionableNode));
// Store the node details for later
Set<QName> origAspects = this.dbNodeService.getAspects(versionableNode);
// Try and restore the node (won't be allowed as it already exists!)
try
{
this.versionService.restore(
versionableNode,
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode"));
fail("An exception should have been raised since this node exists and you can't restore a node that exists.");
}
catch (VersionServiceException exception)
{
// We where expecting this exception
}
// Version it twice
this.versionService.createVersion(versionableNode, null);
this.versionService.createVersion(versionableNode, null);
// Check we're now have a version history
VersionHistory history = versionService.getVersionHistory(versionableNode);
assertEquals("0.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
assertEquals("0.2", history.getHeadVersion().getVersionLabel());
assertEquals(2, history.getAllVersions().size());
// Delete the node
this.dbNodeService.deleteNode(versionableNode);
assertFalse(this.dbNodeService.exists(versionableNode));
// You can still get the history of the node even though it's deleted
history = versionService.getVersionHistory(versionableNode);
assertEquals("0.2", history.getHeadVersion().getVersionLabel());
assertEquals(2, history.getAllVersions().size());
// Try and restore the node
NodeRef restoredNode = this.versionService.restore(
versionableNode,
this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode"));
assertNotNull(restoredNode);
assertTrue(this.dbNodeService.exists(restoredNode));
// Check that the properties are correct
assertEquals(VALUE_1, this.dbNodeService.getProperty(restoredNode, PROP_1));
assertEquals(VALUE_2, this.dbNodeService.getProperty(restoredNode, PROP_2));
assertEquals(VALUE_3, this.dbNodeService.getProperty(restoredNode, PROP_3));
// Check that the content is correct
ContentReader contentReader2 = this.contentService.getReader(restoredNode, ContentModel.PROP_CONTENT);
assertNotNull(contentReader2);
assertEquals(TEST_CONTENT, contentReader2.getContentString());
// Check that the ContentModel.PROP_VERSION_LABEL property is correct
String versionLabel = (String)this.dbNodeService.getProperty(restoredNode, ContentModel.PROP_VERSION_LABEL);
assertNotNull(versionLabel);
assertEquals("0.2", versionLabel);
// Check that the aspects have been reverted correctly
Set<QName> aspects2 = this.dbNodeService.getAspects(restoredNode);
assertEquals(aspects2.size(), origAspects.size());
// Check the version is back to what it was
history = versionService.getVersionHistory(restoredNode);
assertEquals("0.2", history.getHeadVersion().getVersionLabel());
assertEquals(2, history.getAllVersions().size());
Version[] versions = history.getAllVersions().toArray(new Version[2]);
assertEquals("0.2", versions[0].getVersionLabel());
assertEquals("0.1", versions[1].getVersionLabel());
// TODO Shouldn't these point to the restored node?
//assertEquals(restoredNode, versions[0].getFrozenStateNodeRef());
//assertEquals(restoredNode, versions[1].getFrozenStateNodeRef());
// TODO Should we really be having reference to version store
// as the frozen state noderef?
assertEquals(VersionService.VERSION_STORE_PROTOCOL, versions[0].getFrozenStateNodeRef().getStoreRef().getProtocol());
assertEquals(VersionService.VERSION_STORE_PROTOCOL, versions[1].getFrozenStateNodeRef().getStoreRef().getProtocol());
}
/**
* Test deleteVersionHistory
*/
public void testDeleteVersionHistory()
{
// Create a versionable node
NodeRef versionableNode = createNewVersionableNode();
// Check that there is no version history
VersionHistory versionHistory1 = this.versionService.getVersionHistory(versionableNode);
assertNull(versionHistory1);
// Create a couple of versions
createVersion(versionableNode);
Version version1 = createVersion(versionableNode);
// Check that the version label is correct on the versionable node
String versionLabel1 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertNotNull(versionLabel1);
assertEquals(version1.getVersionLabel(), versionLabel1);
// Check that the version history has been created correctly
VersionHistory versionHistory2 = this.versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory2);
assertEquals(2, versionHistory2.getAllVersions().size());
// Delete the version history
this.versionService.deleteVersionHistory(versionableNode);
// Check that there is no version history available for the node
VersionHistory versionHistory3 = this.versionService.getVersionHistory(versionableNode);
assertNull(versionHistory3);
// Check that the current version property on the versionable node is no longer set
String versionLabel2 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertNull(versionLabel2);
// Create a couple of versions
createVersion(versionableNode);
Version version2 = createVersion(versionableNode);
// Check that the version history is correct
VersionHistory versionHistory4 = this.versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory4);
assertEquals(2, versionHistory4.getAllVersions().size());
// Check that the version label is correct on the versionable node
String versionLabel3 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertNotNull(versionLabel3);
assertEquals(version2.getVersionLabel(), versionLabel3);
}
/**
* Test deleteVersion
*/
public void testDeleteVersion()
{
// Use 1.0, 2.0 etc for the main part
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
// Create a versionable node
NodeRef versionableNode = createNewVersionableNode();
// Check that there is no version history
VersionHistory versionHistory = this.versionService.getVersionHistory(versionableNode);
CheckVersionHistory(versionHistory, null);
// Check that the current version property on the versionable node is not set
String versionLabel = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertNull(versionLabel);
// Check that there is no current version
Version version = this.versionService.getCurrentVersion(versionableNode);
assertNull(version);
// Create a couple of versions
Version version1 = createVersion(versionableNode);
Version version2 = createVersion(versionableNode);
// Check that the version label is correct on the versionable node
String versionLabel1 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertEquals("first version label", "2.0", versionLabel1);
assertEquals(version2.getVersionLabel(), versionLabel1);
// Check the version history
List<Version> expectedVersions = new ArrayList<Version>(2);
expectedVersions.add(version2); // 2.0
expectedVersions.add(version1); // 1.0
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(2, versionHistory.getAllVersions().size());
CheckVersionHistory(versionHistory, expectedVersions);
// Check the versions on the history
Version[] versions = versionHistory.getAllVersions().toArray(new Version[2]);
assertEquals("2.0", versions[0].getVersionLabel());
assertEquals("1.0", versions[1].getVersionLabel());
// Check current version
Version currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version2.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version2.getFrozenStateNodeRef());
// Create a couple more versions
Version version3 = createVersion(versionableNode); // 3.0
Version version4 = createVersion(versionableNode); // 4.0
// Check that the version label is correct on the versionable node
String versionLabel4 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertEquals("4.0", versionLabel4);
assertEquals(version4.getVersionLabel(), versionLabel4);
// Check the version history
expectedVersions = new ArrayList<Version>(4);
expectedVersions.add(version4);
expectedVersions.add(version3);
expectedVersions.add(version2);
expectedVersions.add(version1);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(4, versionHistory.getAllVersions().size());
CheckVersionHistory(versionHistory, expectedVersions);
// Check current version
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version4.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version4.getFrozenStateNodeRef());
assertEquals("4.0", currentVersion.getVersionLabel());
// Delete version 3.0
this.versionService.deleteVersion(versionableNode, version3);
// Delete version 1.0
this.versionService.deleteVersion(versionableNode, version1);
// Check the version history
expectedVersions = new ArrayList<Version>(2);
expectedVersions.add(version4);
expectedVersions.add(version2);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(2, versionHistory.getAllVersions().size());
CheckVersionHistory(versionHistory, expectedVersions);
// Check current version is unchanged
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version4.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version4.getFrozenStateNodeRef());
// Delete version 4
this.versionService.deleteVersion(versionableNode, version4);
// Check the version history size
expectedVersions = new ArrayList<Version>(1);
expectedVersions.add(version2);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(1, versionHistory.getAllVersions().size());
CheckVersionHistory(versionHistory, expectedVersions);
// Check current version has changed to version 2.0
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version2.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version2.getFrozenStateNodeRef());
// Create a new version. As 3.0 and 4.0 have been deleted, will be 3.0 again
Version version3n = createVersion(versionableNode);
// Check the version history size
expectedVersions = new ArrayList<Version>(2);
expectedVersions.add(version3n);
expectedVersions.add(version2);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(2, versionHistory.getAllVersions().size());
CheckVersionHistory(versionHistory, expectedVersions);
// Check current version has changed to version 3.0
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version3n.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version3n.getFrozenStateNodeRef());
assertEquals("3.0", currentVersion.getVersionLabel());
// Create versions 3.1 and 3.2
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
Version version31 = createVersion(versionableNode);
Version version32 = createVersion(versionableNode);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(4, versionHistory.getAllVersions().size());
expectedVersions = new ArrayList<Version>(2);
expectedVersions.add(version32);
expectedVersions.add(version31);
expectedVersions.add(version3n);
expectedVersions.add(version2);
CheckVersionHistory(versionHistory, expectedVersions);
// Check the current version is now 3.2
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version32.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version32.getFrozenStateNodeRef());
assertEquals("3.2", currentVersion.getVersionLabel());
// Delete version 3.1
versionService.deleteVersion(versionableNode, version31);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(3, versionHistory.getAllVersions().size());
expectedVersions.remove(version31);
CheckVersionHistory(versionHistory, expectedVersions);
// Current version is still 3.2
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version32.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version32.getFrozenStateNodeRef());
// Delete version 3.2
versionService.deleteVersion(versionableNode, version32);
versionHistory = this.versionService.getVersionHistory(versionableNode);
assertEquals(2, versionHistory.getAllVersions().size());
expectedVersions.remove(version32);
CheckVersionHistory(versionHistory, expectedVersions);
// Check current version is back to 3.0
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version3n.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version3n.getFrozenStateNodeRef());
assertEquals("3.0", currentVersion.getVersionLabel());
// Delete version 2.0
this.versionService.deleteVersion(versionableNode, version2);
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(currentVersion.getVersionLabel(), version3n.getVersionLabel());
assertEquals(currentVersion.getFrozenStateNodeRef(), version3n.getFrozenStateNodeRef());
// Delete version 3.0 (our last version)
this.versionService.deleteVersion(versionableNode, version3n);
// Check the version history is empty
versionHistory = this.versionService.getVersionHistory(versionableNode);
CheckVersionHistory(versionHistory, null);
// Check that the current version property on the versionable node is no longer set
versionLabel = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
assertNull(versionLabel);
// Check that there is no current version
version = this.versionService.getCurrentVersion(versionableNode);
assertNull(version);
}
public void testAutoVersionOnInitialVersionOn()
{
// Create a versionable node
final NodeRef versionableNode = createNewVersionableNode();
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Check that the initial version has not been created
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
// Add some content
ContentWriter contentWriter = contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_1);
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testAutoVersionOff()
{
// Create a versionable node
final NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION, false);
setComplete();
endTransaction();
// The initial version should have been created now
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Add some content
ContentWriter contentWriter = contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_1);
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testInitialVersionOff()
{
// Create node (this node has some content)
HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_INITIAL_VERSION, false);
HashMap<QName, Serializable> props2 = new HashMap<QName, Serializable>();
props2.put(ContentModel.PROP_NAME, "test.txt");
final NodeRef nodeRef = this.dbNodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode2"),
TEST_TYPE_QNAME,
props2).getChildRef();
this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props);
setComplete();
endTransaction();
// The initial version should NOT have been created
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNull(versionHistory);
return null;
}
});
}
public void testAddVersionableAspectWithNoVersionType()
{
// No version-type specified when adding the aspect
NodeRef nodeRef = createNodeWithVersionType(null);
setComplete();
endTransaction();
assertCorrectVersionLabel(nodeRef, "1.0");
}
public void testAddVersionableAspectWithMinorVersionType()
{
// MINOR version-type specified when adding the aspect
NodeRef nodeRef = createNodeWithVersionType(VersionType.MINOR);
setComplete();
endTransaction();
assertCorrectVersionLabel(nodeRef, "0.1");
}
public void testAddVersionableAspectWithMajorVersionType()
{
// MAJOR version-type specified when adding the aspect
NodeRef nodeRef = createNodeWithVersionType(VersionType.MAJOR);
setComplete();
endTransaction();
assertCorrectVersionLabel(nodeRef, "1.0");
}
private void assertCorrectVersionLabel(final NodeRef nodeRef, final String versionLabel)
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Check that the version history has been created
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
Version version = versionService.getCurrentVersion(nodeRef);
assertEquals("Wrong version label", versionLabel, version.getVersionLabel());
return null;
}
});
}
private NodeRef createNodeWithVersionType(VersionType versionType)
{
HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, "test.txt");
final NodeRef nodeRef = dbNodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode"),
TEST_TYPE_QNAME,
props).getChildRef();
HashMap<QName, Serializable> aspectProps = new HashMap<QName, Serializable>();
if (versionType != null)
{
aspectProps.put(ContentModel.PROP_VERSION_TYPE, versionType);
}
dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, aspectProps);
return nodeRef;
}
public void testAddRemoveVersionableAspect()
{
HashMap<QName, Serializable> props2 = new HashMap<QName, Serializable>();
props2.put(ContentModel.PROP_NAME, "test.txt");
final NodeRef nodeRef = this.dbNodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode2"),
TEST_TYPE_QNAME,
props2).getChildRef();
this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Check that the version history has been created
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
// Remove the versionable aspect
dbNodeService.removeAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Check that the version history has been removed
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNull(versionHistory);
// Re-add the versionable aspect
dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Check that the version history has been created
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testAutoRemovalOfVersionHistory()
{
StoreRef spacesStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
NodeRef root = this.dbNodeService.getRootNode(spacesStoreRef);
HashMap<QName, Serializable> props2 = new HashMap<QName, Serializable>();
props2.put(ContentModel.PROP_NAME, "test-" + GUID.generate() + ".txt");
final NodeRef nodeRef = this.dbNodeService.createNode(
root,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode2"),
ContentModel.TYPE_CONTENT,
props2).getChildRef();
this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
// Delete the node
dbNodeService.deleteNode(nodeRef);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Get the archived noderef
NodeRef archivedNodeRef = nodeArchiveService.getArchivedNode(nodeRef);
// The archived noderef should still have a link to the version history
VersionHistory versionHistory = versionService.getVersionHistory(archivedNodeRef);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
// Delete the node for good
dbNodeService.deleteNode(archivedNodeRef);
return null;
}
});
txnHelper.doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Get the archived noderef
NodeRef archivedNodeRef = nodeArchiveService.getArchivedNode(nodeRef);
// Check that the version histories have been deleted
VersionHistory versionHistory12 = versionService.getVersionHistory(nodeRef);
assertNull(versionHistory12);
VersionHistory versionHistory23 = versionService.getVersionHistory(archivedNodeRef);
assertNull(versionHistory23);
return null;
}
});
}
public void testAutoVersionOnUpdatePropsOnly()
{
// test auto-version props on
final NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 1");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
return null;
}
});
//Checking whether VersionModel.PROP_VERSION_TYPE set to MINOR type after update node properties
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "test description");
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
VersionType vType = (VersionType) versionHistory.getHeadVersion().getVersionProperty(VersionModel.PROP_VERSION_TYPE);
assertNotNull("Is not setted the version type", vType);
assertEquals(vType, VersionType.MINOR);
return null;
}
});
// test auto-version props off
startNewTransaction();
final NodeRef versionableNode2 = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode2, ContentModel.PROP_AUTO_VERSION_PROPS, false);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode2);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode2, ContentModel.PROP_AUTHOR, "ano author 2");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode2);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testAutoVersionOnUpdatePropsOnlyWithExcludes()
{
// test auto-version props on - without any excludes
final NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 1");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 1");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
// Check version labels, should be 0.2 and 0.1 as property changes
// are minor updates, and we had no initial label set
Version[] versions = versionHistory.getAllVersions().toArray(new Version[2]);
assertEquals("1.1", versions[0].getVersionLabel());
assertEquals("1.0", versions[1].getVersionLabel());
return null;
}
});
List<String> excludedOnUpdateProps = new ArrayList<String>(1);
NamespaceService namespaceService = (NamespaceService) applicationContext.getBean("namespaceService");
excludedOnUpdateProps.add(ContentModel.PROP_AUTHOR.toPrefixString(namespaceService));
versionableAspect.setExcludedOnUpdateProps(excludedOnUpdateProps);
versionableAspect.afterDictionaryInit();
// test auto-version props on - with an excluded prop change
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 2");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 2");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
// (The property changes were excluded so there should have been no changes)
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
return null;
}
});
//Checking whether VersionModel.PROP_VERSION_TYPE set to MINOR type after update node properties
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
VersionType vType = (VersionType) versionHistory.getHeadVersion().getVersionProperty(VersionModel.PROP_VERSION_TYPE);
assertNotNull("Is not setted the version type", vType);
assertEquals(vType, VersionType.MINOR);
return null;
}
});
// test auto-version props on - with a non-excluded prop change
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 3");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
// (We should have gained one more)
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(3, versionHistory.getAllVersions().size());
// Check the versions,
Version[] versions = versionHistory.getAllVersions().toArray(new Version[3]);
assertEquals("1.2", versions[0].getVersionLabel());
assertEquals("1.1", versions[1].getVersionLabel());
assertEquals("1.0", versions[2].getVersionLabel());
return null;
}
});
// Delete version 0.2, auto changes won't affect this
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
Version[] versions = versionHistory.getAllVersions().toArray(new Version[3]);
Version v = versions[1];
assertEquals("1.1", v.getVersionLabel());
versionService.deleteVersion(versionableNode, v);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
// Check the versions, will now have a gap
Version[] versions = versionHistory.getAllVersions().toArray(new Version[2]);
assertEquals("1.2", versions[0].getVersionLabel());
assertEquals("1.0", versions[1].getVersionLabel());
return null;
}
});
// Delete the head version, will revert back to 0.1
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
Version v = versionService.getCurrentVersion(versionableNode);
assertEquals("1.2", v.getVersionLabel());
versionService.deleteVersion(versionableNode, v);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
// Check the version
Version[] versions = versionHistory.getAllVersions().toArray(new Version[1]);
assertEquals("1.0", versions[0].getVersionLabel());
return null;
}
});
}
public void testAutoVersionWithPropsOnRevert()
{
// test auto-version props on - without any excludes
final NodeRef versionableNode = createNewVersionableNode();
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true);
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 0");
nodeService.setProperty(versionableNode, PROP_1, VALUE_1);
// Force it to be 2.0
Map<String,Serializable> vprops = new HashMap<String, Serializable>();
vprops.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
versionService.createVersion(versionableNode, vprops);
versionService.createVersion(versionableNode, vprops);
// Check it's 2.0
assertEquals("2.0", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Zap 1.0
versionService.deleteVersion(versionableNode,
versionService.getVersionHistory(versionableNode).getVersion("1.0"));
// Ready to test
setComplete();
endTransaction();
// Check the first version is now 2.0
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
assertEquals("2.0", versionHistory.getHeadVersion().getVersionLabel());
assertEquals("2.0", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
return null;
}
});
// Create a few more versions
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 2");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 2");
nodeService.setProperty(versionableNode, PROP_1, VALUE_2);
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 3");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 3");
nodeService.setProperty(versionableNode, PROP_1, VALUE_3);
return null;
}
});
// Check the history is correct
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(3, versionHistory.getAllVersions().size());
assertEquals("2.2", versionHistory.getHeadVersion().getVersionLabel());
assertEquals("2.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Check the version
Version[] versions = versionHistory.getAllVersions().toArray(new Version[3]);
assertEquals("2.2", versions[0].getVersionLabel());
assertEquals("2.1", versions[1].getVersionLabel());
assertEquals("2.0", versions[2].getVersionLabel());
return null;
}
});
// Delete the middle version
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
Version v21 = versionHistory.getVersion("2.1");
versionService.deleteVersion(versionableNode, v21);
return null;
}
});
// Check the history now
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
assertEquals("2.2", versionHistory.getHeadVersion().getVersionLabel());
assertEquals("2.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// Check the version
Version[] versions = versionHistory.getAllVersions().toArray(new Version[2]);
assertEquals("2.2", versions[0].getVersionLabel());
assertEquals("2.0", versions[1].getVersionLabel());
return null;
}
});
// Revert to V2.0
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
Version v20 = versionHistory.getVersion("2.0");
versionService.revert(versionableNode, v20);
return null;
}
});
// Check things went back as expected
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Still has two in the version history
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
Version[] versions = versionHistory.getAllVersions().toArray(new Version[2]);
assertEquals("2.2", versions[0].getVersionLabel());
assertEquals("2.0", versions[1].getVersionLabel());
// Head version is still 2.2
assertEquals("2.2", versionHistory.getHeadVersion().getVersionLabel());
// But the node is back at 2.0
// TODO Shouldn't the node be at 2.0 now, not 2.2?
//assertEquals("2.0", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
assertEquals("2.2", nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL));
// And the properties show it has gone back
assertEquals(VALUE_1, nodeService.getProperty(versionableNode, PROP_1));
assertEquals("description 0", nodeService.getProperty(versionableNode, ContentModel.PROP_DESCRIPTION));
return null;
}
});
}
public void testALF5618()
{
final NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true);
setComplete();
endTransaction();
final String lockToken = "opaquelocktoken:" + versionableNode.getId() + ":admin";
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testAR807()
{
QName prop = QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "intProp");
ChildAssociationRef childAssociation =
nodeService.createNode(this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "integerTest"),
TEST_TYPE_QNAME);
NodeRef newNode = childAssociation.getChildRef();
nodeService.setProperty(newNode, prop, 1);
Object editionCode = nodeService.getProperty(newNode, prop);
assertEquals(editionCode.getClass(), Integer.class);
Map<String, Serializable> versionProps = new HashMap<String, Serializable>(1);
versionProps.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
Version version = versionService.createVersion(newNode, versionProps);
NodeRef versionNodeRef = version.getFrozenStateNodeRef();
assertNotNull(versionNodeRef);
Object editionCodeArchive = nodeService.getProperty(versionNodeRef, prop);
assertEquals(editionCodeArchive.getClass(), Integer.class);
}
/**
* Check read permission for the frozen node
*/
public void testHasPermission()
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
if(!authenticationDAO.userExists(USER_NAME_A))
{
authenticationService.createAuthentication(USER_NAME_A, PWD_A.toCharArray());
}
permissionService.setPermission(rootNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true);
permissionService.setInheritParentPermissions(rootNodeRef, true);
// Create a new versionable node
NodeRef versionableNode = createNewVersionableNode();
// Create a new version
Version version = createVersion(versionableNode, versionProperties);
NodeRef versionNodeRef = version.getFrozenStateNodeRef();
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(versionNodeRef, PermissionService.READ));
AuthenticationUtil.setFullyAuthenticatedUser(USER_NAME_A);
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(versionNodeRef, PermissionService.READ));
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
permissionService.setInheritParentPermissions(versionableNode, false);
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(versionNodeRef, PermissionService.READ));
AuthenticationUtil.setFullyAuthenticatedUser(USER_NAME_A);
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(versionNodeRef, PermissionService.READ));
}
public void testALF_3962()
{
NodeRef versionableNode = createNode(true, QName.createQName("http://www.alfresco.org/model/action/1.0", "action"));
// create some versions of content without version label policy
createVersion(versionableNode);
createVersion(versionableNode);
createVersion(versionableNode);
// create some more versions and force them to have same frozen modified date
Version ver = createVersion(versionableNode);
Date frozenModifiedDate = ver.getFrozenModifiedDate();
ver = createVersion(versionableNode);
NodeRef versionNodeRef = VersionUtil.convertNodeRef(ver.getFrozenStateNodeRef());
this.dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIED, frozenModifiedDate);
ver = createVersion(versionableNode);
versionNodeRef = VersionUtil.convertNodeRef(ver.getFrozenStateNodeRef());
this.dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIED, frozenModifiedDate);
// corrupt versions
Collection<Version> versions = versionService.getVersionHistory(versionableNode).getAllVersions();
List<Version> oldVersions = new ArrayList<Version>(versions.size());
for (Version version : versions)
{
// update version with corrupted label
versionNodeRef = VersionUtil.convertNodeRef(version.getFrozenStateNodeRef());
this.dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_VERSION_LABEL, "0");
// cache results
oldVersions.add(version);
}
this.nodeService.setProperty(versionableNode, ContentModel.PROP_VERSION_LABEL, "0");
// should correct version labels
versionService.createVersion(versionableNode, this.versionProperties);
versions = versionService.getVersionHistory(versionableNode).getAllVersions();
List<Version> newVersions = new ArrayList<Version>(versions.size());
for (Version version : versions)
{
assertFalse(version.getVersionLabel().equals("0"));
newVersions.add(version);
}
// check live node
assertFalse(this.nodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL).toString().equals("0"));
//check order
for (int i = 0; i < oldVersions.size(); i++)
{
Version oldVersion = oldVersions.get(i);
Version newVersion = newVersions.get(i + 1);
assertEquals(oldVersion.getFrozenModifiedDate(), newVersion.getFrozenModifiedDate());
assertEquals(oldVersion.getVersionLabel(), newVersion.getVersionLabel());
String nodeDbidKey = ContentModel.PROP_NODE_DBID.getLocalName();
assertEquals(oldVersion.getVersionProperty(nodeDbidKey), newVersion.getVersionProperty(nodeDbidKey));
String nodeUuidKey = ContentModel.PROP_NODE_UUID.getLocalName();
assertEquals(oldVersion.getVersionProperty(nodeUuidKey), newVersion.getVersionProperty(nodeUuidKey));
}
}
/**
* Ensure that versioning actions don't alter the auditable
* aspect properties on the original nodes
*/
public void testVersioningAndAuditable() throws Exception {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
if(!authenticationDAO.userExists(USER_NAME_A))
{
authenticationService.createAuthentication(USER_NAME_A, PWD_A.toCharArray());
}
// Create a node as the "A" user
NodeRef nodeA = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
@Override
public NodeRef doWork() throws Exception
{
return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(USER_NAME_A);
NodeRef a = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName("{test}NodeForA"),
ContentModel.TYPE_CONTENT
).getChildRef();
nodeService.addAspect(a, ContentModel.ASPECT_AUDITABLE, null);
return a;
}
}
);
}
}, USER_NAME_A
);
// Check that it's owned by A
assertEquals(USER_NAME_A, nodeService.getProperty(nodeA, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(nodeA, ContentModel.PROP_MODIFIER));
assertEquals(false, nodeService.hasAspect(nodeA, ContentModel.ASPECT_VERSIONABLE));
// Now enable it for versioning, as Admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
versionService.createVersion(nodeA, null);
// Ensure it's still owned by A
assertEquals(USER_NAME_A, nodeService.getProperty(nodeA, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(nodeA, ContentModel.PROP_MODIFIER));
assertEquals(true, nodeService.hasAspect(nodeA, ContentModel.ASPECT_VERSIONABLE));
}
public void testEnsureVersioningEnabled() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
if(!authenticationDAO.userExists(USER_NAME_A))
{
authenticationService.createAuthentication(USER_NAME_A, PWD_A.toCharArray());
}
// Create 3 nodes in the 3 different states
AuthenticationUtil.setFullyAuthenticatedUser(USER_NAME_A);
NodeRef none = nodeService.createNode(
rootNodeRef, ContentModel.ASSOC_CONTAINS,
QName.createQName("{test}None"),
ContentModel.TYPE_CONTENT
).getChildRef();
nodeService.addAspect(none, ContentModel.ASPECT_AUDITABLE, null);
NodeRef aspect = nodeService.createNode(
rootNodeRef, ContentModel.ASSOC_CONTAINS,
QName.createQName("{test}None"),
ContentModel.TYPE_CONTENT
).getChildRef();
nodeService.addAspect(aspect, ContentModel.ASPECT_AUDITABLE, null);
nodeService.addAspect(aspect, ContentModel.ASPECT_VERSIONABLE, null);
nodeService.setProperty(aspect, ContentModel.PROP_AUTO_VERSION, Boolean.FALSE);
nodeService.setProperty(aspect, ContentModel.PROP_AUTO_VERSION_PROPS, Boolean.TRUE);
NodeRef versioned = nodeService.createNode(
rootNodeRef, ContentModel.ASSOC_CONTAINS,
QName.createQName("{test}None"),
ContentModel.TYPE_CONTENT
).getChildRef();
nodeService.addAspect(versioned, ContentModel.ASPECT_AUDITABLE, null);
nodeService.addAspect(versioned, ContentModel.ASPECT_VERSIONABLE, null);
nodeService.setProperty(versioned, ContentModel.PROP_AUTO_VERSION, Boolean.TRUE);
nodeService.setProperty(versioned, ContentModel.PROP_AUTO_VERSION_PROPS, Boolean.FALSE);
versionService.createVersion(versioned, null);
// Check their state
assertEquals(false, nodeService.hasAspect(none, ContentModel.ASPECT_VERSIONABLE));
assertEquals(true, nodeService.hasAspect(aspect, ContentModel.ASPECT_VERSIONABLE));
assertEquals(true, nodeService.hasAspect(versioned, ContentModel.ASPECT_VERSIONABLE));
assertNull(versionService.getVersionHistory(none));
assertNull(versionService.getVersionHistory(aspect));
assertNotNull(versionService.getVersionHistory(versioned));
assertEquals(USER_NAME_A, nodeService.getProperty(none, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(none, ContentModel.PROP_MODIFIER));
assertEquals(USER_NAME_A, nodeService.getProperty(aspect, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(aspect, ContentModel.PROP_MODIFIER));
assertEquals(USER_NAME_A, nodeService.getProperty(versioned, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(versioned, ContentModel.PROP_MODIFIER));
// If we turn on the aspect, what with?
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_TITLE, "This shouldn't be set by the method");
props.put(ContentModel.PROP_AUTO_VERSION, Boolean.TRUE);
// Now call ensureVersioningEnabled for each
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
versionService.ensureVersioningEnabled(none, props);
versionService.ensureVersioningEnabled(aspect, props);
versionService.ensureVersioningEnabled(versioned, props);
// And finally check their state:
// None will have the aspect applied, along with both properties
assertEquals(true, nodeService.hasAspect(none, ContentModel.ASPECT_VERSIONABLE));
assertEquals(Boolean.TRUE, nodeService.getProperty(none, ContentModel.PROP_AUTO_VERSION));
assertEquals(Boolean.TRUE, nodeService.getProperty(none, ContentModel.PROP_AUTO_VERSION_PROPS));
assertEquals(null, nodeService.getProperty(none, ContentModel.PROP_TITLE));
// Aspect won't have altered it's props
assertEquals(true, nodeService.hasAspect(aspect, ContentModel.ASPECT_VERSIONABLE));
assertEquals(Boolean.FALSE, nodeService.getProperty(aspect, ContentModel.PROP_AUTO_VERSION));
assertEquals(Boolean.TRUE, nodeService.getProperty(aspect, ContentModel.PROP_AUTO_VERSION_PROPS));
assertEquals(null, nodeService.getProperty(aspect, ContentModel.PROP_TITLE));
// Versioned won't have altered it's props
assertEquals(true, nodeService.hasAspect(versioned, ContentModel.ASPECT_VERSIONABLE));
assertEquals(Boolean.TRUE, nodeService.getProperty(versioned, ContentModel.PROP_AUTO_VERSION));
assertEquals(Boolean.FALSE, nodeService.getProperty(versioned, ContentModel.PROP_AUTO_VERSION_PROPS));
assertEquals(null, nodeService.getProperty(versioned, ContentModel.PROP_TITLE));
// Alll will have a version history now
assertNotNull(versionService.getVersionHistory(none));
assertNotNull(versionService.getVersionHistory(aspect));
assertNotNull(versionService.getVersionHistory(versioned));
// The auditable properties won't have changed
assertEquals(USER_NAME_A, nodeService.getProperty(none, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(none, ContentModel.PROP_MODIFIER));
assertEquals(USER_NAME_A, nodeService.getProperty(aspect, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(aspect, ContentModel.PROP_MODIFIER));
assertEquals(USER_NAME_A, nodeService.getProperty(versioned, ContentModel.PROP_CREATOR));
assertEquals(USER_NAME_A, nodeService.getProperty(versioned, ContentModel.PROP_MODIFIER));
}
/*
* It should be possible to create a version for a locked node, see ALF-16540
*/
public void testVersionLockedNode()
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// create versionable node and ensure it has the necessary aspect
NodeRef versionableNode = createNewVersionableNode();
assertEquals(true, nodeService.hasAspect(versionableNode, ContentModel.ASPECT_VERSIONABLE));
// add lockable aspect and write lock the node
dbNodeService.addAspect(versionableNode, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
assertEquals(true, nodeService.hasAspect(versionableNode, ContentModel.ASPECT_LOCKABLE));
checkOutCheckInService.checkout(versionableNode);
// try to create a version
createVersion(versionableNode);
VersionHistory vh = versionService.getVersionHistory(versionableNode);
assertEquals(1, vh.getAllVersions().size());
return null;
}
});
}
public static void main(String ... args)
{
try
{
doMain(args);
System.exit(1);
}
catch (Throwable e)
{
logger.error(e);
System.exit(1);
}
}
private static void doMain(String ... args)
{
if (args.length != 1)
{
System.out.println("Usage: VersionServiceImplTest fileCount");
System.exit(1);
}
int fileCount = Integer.parseInt(args[0]);
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
final FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
final NodeService nodeService = serviceRegistry.getNodeService();
final VersionService versionService = serviceRegistry.getVersionService();
final AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
authenticationComponent.setSystemUserAsCurrentUser();
// TEMP - for migration testing - force V1 store (override repository property)
final Version2ServiceImpl version2ServiceImpl = (Version2ServiceImpl)ctx.getBean("versionService");
version2ServiceImpl.setOnlyUseDeprecatedV1(true);
System.out.println("Using: " + versionService.getVersionStoreReference());
// Create a new store
StoreRef storeRef = new StoreRef("test", "VersionServiceImplTest-main-"+System.currentTimeMillis());
if (!nodeService.exists(storeRef))
{
nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
}
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
// Create a folder
NodeRef folderNodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("test", "versionMain"),
ContentModel.TYPE_FOLDER).getChildRef();
// Now load the folder with the prescribed number of documents
int count = 0;
long start = System.currentTimeMillis();
long lastReport = start;
for (int i = 0; i < fileCount; i++)
{
fileFolderService.create(folderNodeRef, "file-" + i, ContentModel.TYPE_CONTENT);
count++;
// Report every 10s
long now = System.currentTimeMillis();
if (now - lastReport > 10000L)
{
long delta = (now - start);
double average = (double) delta / (double) count;
System.out.println(
"File Creation: \n" +
" Count: " + count + " of " + fileCount + "\n" +
" Average (ms): " + average);
lastReport = now;
}
}
// Get all the children again
List<FileInfo> files = fileFolderService.listFiles(folderNodeRef);
// Version each one
count = 0;
start = System.currentTimeMillis();
lastReport = start;
for (FileInfo fileInfo : files)
{
NodeRef nodeRef = fileInfo.getNodeRef();
versionService.createVersion(nodeRef, null);
count++;
// Report every 10s
long now = System.currentTimeMillis();
if (now - lastReport > 10000L)
{
long delta = (now - start);
double average = (double) delta / (double) count;
System.out.println(
"Version: \n" +
" Count: " + count + " of " + fileCount + "\n" +
" Average (ms): " + average);
lastReport = now;
}
}
System.out.println("Finished: " + fileCount);
}
}