Dave Ward 4ef5672f4a Merged V3.4 to HEAD
23336: Created a branch for 3.4 Enterprise releases
   23344: replaced some un-neccessary non latin chars in variable name.
   23347: Fix ALF-3200 - add a policy to Sites, which stops renames occuring (renames breaks things as the name is used in various association patterns). Includes unit tests
   23349: Merged BRANCHES/DEV/BELARUS/HEAD-2010_03_30 to BRANCHES/V3.4
   20198: ALF-2176: Incorrect pagination for resources on Advanced Workflow Wizard
   The javascript onkeyup event was changed to onkeypress event in UIDataPager. 
   It prevents a form submission before js action.
   23351: ALF-5109 transfer service : replace content results in "orphans exist" failure.
   23352: New (currently disabled) unit test to check that multiple threads writing to different properties via the node service on the same node don't loose updates. Test disabled pending caching fix
   Also tweak the tagging multi threaded test (currently disabled) to make it try a few more tags in parallel
   23366: Audit method interceptor switches to pass-through if the server is read-only (ALF-5424)
   23375: Fixed ALF-2825 "Display problem on Rules page when rule has a long description" & more
   - ALF-2825 "Display problem on Rules page when rule has a long description"
   - Made drag and drop adjust the "empty space" to the dragged elements height
   - $html alias was missing on linked to folder page after a previous merge
   23376: Fix for  ALF-5401: CMIS: When specifying "cmis:objectTypeId=Dyz" in the WHERE clause, nodes of subtypes of x:yz are also returned
   - now only returns the specific type
   - unit test included
   23377: Merged V3.3-BUG-FIX to V3.4
      23353: Merged DEV-TEMPORARY to V3.3-BUG-FIX
         20930: Fix ALF-2564 "MS office addin does not work with kerberos and cifs". Also added to Excel and PowerPoint add-ins (supplied fix was for Word only).
   
   Also updated help URLs to Enterprise.
   23378: Fix ALF-4786: Update the Web Editor Help URL for 3.4 Enterprise Beta and Enterprise
   23380: Fixes:
   - ALF-5431	WQS: latest blog article component throws an exception if the description field is empty
   - ALF-5426	Using double-quotes in either the title or description of an asset collection causes an error
   23381: Fixed ALF-4702 "The 'Most Recently Completed Task' area should also include a Completed By: label"
   23382: Made sure "empty list message" gets padding in object-finder's "list" mode
   23383: WQS: Merged CSS fix from HEAD
   
   $ svn merge https://svn.alfresco.com/repos/enterprise/alfresco/HEAD
   --- Merging r23336 through r23382 into '.':
   23384: Fix for: ALF-3164 rename LuceneQueryLanguageSPI.executQuery(..) to executeQuery
   23385: Fix for ALF-5166: After restore of indexes - AUTO hangs
   - bulk deletes are now handled as such during index tracking and rebuild (as they are normally)
   23388: Merged V3.3-BUG-FIX to V3.4
      23387: Merged V3.3 to V3.3-BUG-FIX
         23370: Fix ALF-5277: Excel 2007 xlsx icon not displayed in Alfresco Explorer.
            Re-Merged V2.1 to V3.3
               6464: Added Office 2007 document mimetypes and icons
         23386: Fix ALF-5427: ALF-2639 causes Edit Online button in Share to only handle http not https
   23389: Fixes:
   - ALF-5211	Error on search with wildcards
   23390: Fixed ALF-4835 "Incorrect behaviour of Cancel action"
   23392: Partly fixed ALF-4678 "Incorrect workflow details if creator or assgnee was deleted"
   - If the assignee has been deleted the username is still displayed (but only as text and not as a link)
   23394: Fix for ALF-2780 - Share/Surf don't invalidate Alfresco tickets
   23396: Removed direct System.err output in ArchiveContentTransformer
   23399: Fix ALF-4321: use of Ajax technology in share leeds to a stuck interface as ajax code does not handle end of sessions cases when using CAS (external) authentication
   23402: Fixed ALF-5456: IP address change can cause read-write errors on startup
    - Simply avoid writing in a read-only transaction
   23411: Added web-tier cluster sample config (ALF-3873 related)
   23412: Fixes ALF-5373: Duplicate date displayed at end of summer time.
   23413: Fixes: ALF-4924 by displaying more data about an event in the Dashlets if the event doesn't finish on the same day, or is an all day event.
   23415: Merged V3.3-BUG-FIX to V3.4
      23414: Fix for ALF-5414 - IE6 specific fixes
   23417: Added a unit test to JbpmEngineTest while investigating ALF-1557. Test is commented out/disabled as it relies on a specific process definition that might be added to the list of available process definitions int he main app.
   23418: Fix for ALF-5451 - Typo in webclient.properties
   23420: Merged V3.3-BUG-FIX to V3.4
      23419: Fix for ALF-4533 - corrected list of email templates shown - other issues mentioned CNR
   23422: Fixes: ALF-5374 - add support for displaying events that span multiple months.
   23424: Fixes: ALF-2989 - Incorrect sideId reference in URL for event in Site Calendar Dashlet
   Adds support for displaying events that start in the past but finish in the future (previously only events that start in the future were shown)
   23425: Fix for ALF-5256 - Change Password link under user's name pulldown in 3.4 shows when using AD authentication
   23441: Fixes: ALF-5267 - CSS Background colour for current day was getting lost in the Month View, due to a style overriding it with a paler colour that wasn't much of a contrast to the usual colour.
   23442: Fixed bug ALF-4988 and also fixed several disabled unit tests.
   23444: Re-enabled and fixed some failing/disabled tests in AbstractRenderingEngineTest.
   23447: Temp comment out new TransferServiceImplTest with greek paths.
   23459: Fixed failing RenditionServiceIntegrationTest.testRenditionPlacement()
   23461: ALF-5224: Edit Online action doesn't work for invited coordinator
   
   23462: Fixing failing test RenditionServiceIntegrationTest.testRenditionPlacement().
   23468: Merged V3.3-BUG-FIX to V3.4
      23463: Merged V3.3 to V3.3-BUG-FIX
         23323: Fixed PostgreSQL upgrade from V3.2.2 to V3.3.4 (Addresses ALF-5344)
   23472: Fixed ALF-5408: SQL Server missing ON DELETE CASCADE declarations
   23479: ALF-2643 - Deployment Service does not protect itself from poorly implemented custom DeploymentTargets
   23489: Fix for ALF-4214 allowing generation of Thumbnails using RuntimeExecutableTransformationOptions. Note that this fix does not pass any execution options specified in the thumbnail definition to the content transformer, instead default transformation options are used.
   To fix this we will either need to define a new RenderingEngine type or modify the ReformatRenderingEngine to become aware of RuntimeExecutableTransformationOptions.
   23492: Fixed ALF-5550: DB2: Unable to insert values into alf_string_value
   23506: Merged V3.3-BUG-FIX to V3.4
      23500: Merged V3.3 to V3.3-BUG-FIX
         23499: Additional change after fix for ALF-5403 to ensure Session is not created before login page auth is successfully processed
   23507: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23504: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
           23297: Fixed ALF-5146: Share - Content model issue with 'dot' in a property name
   
   Also added tests for a property with a dot in the name to the FDK.
   23508: Fixed ALF-5559: Permission interceptors can fail if Lucene returns invalid NodeRefs
    - Problem is present when the 'unfilteredFor' property is added to 'afterAcl' bean
    - Reproduced specific issue with unit tests and found several other failures
    - Currently only affects installations that include the DOD5015 module
   23512: Fixed ALF-5192: Pivot translation isn't changed after modifying
   23513: Merged DEV to V3.4
     23511 : ALF-4200 IMAP - LSUB failed. Access Denied
   23516: Added a test to test_renditionService.js to confirm RenditionService.render() is working properly.
   23519: Merged V3.3-BUG-FIX to V3.4
      23518: Merged V3.3 to V3.3-BUG-FIX
         23517: Fix for ALF-5552 - Search based javascript APIs now handle missing nodes returned from search indexes.
   23521: Fixed ALF-5529 "Incorrect behavior of tab stop indexes at Edit Metadata page for images"
   - ...also makes date text selection work for date field after tabbing to it, enter strokes trigger help and calendar, focus outline being displayed on icon and focus being returned after calender select  
   - ...also fixed bug in advanced search form for date range (the hidden field was never set if from/to values were cleared)
   23526: Fixed ALF-4299: NodeService: review comment vs code for setting unique name on child assoc
   23530: Fix for ALF-5482: "Some patches are not being executed during an upgrade"
   23531: ALF-5272: Update rule works incorrecly
   
   23539: Partial fix for ALF-439: "My Completed Tasks" dashlet doesn't scale in the presence of large numbers of completed tasks
   
   Added ability to limit the result set size of a workflow task query so it can be used by the UI to limit the number of completed tasks shown in the dashlet.
   23542: ALF-4993 : prevent transfer to self.
   23544: Updated to latest revision, following updates required for ALF-4655 (IE8 CSS issues)
   23546: Fixed ALF-5501 "W3C : Incorrect tab stop indexes at Start workflow page"
   - Alfresco.util.createYUIButton now also handles enter keys when menu is used
   - Fixed bug when forms are loaded using ajax (the help toggle didn't work)
   23547: Made keyboard events possible in advanced search menu
   23549: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_06 to BRANCHES/V3.4:
      23210: ALF-4378: Lotus Quickr connector does not work with IBM Lotus Symphony
   23550: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_21 to BRANCHES/V3.4:
      23443: ALF-5098: SPP Module creates documents using the wrong mimetype (Octet Stream)
   23551: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_21 to BRANCHES/V3.4:
      23474: ALF-5490: The Subsystems configuration folder does not seem to be read when Alfresco is deployed to later versions of JBoss
   23552: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_21 to BRANCHES/V3.4:
      23543: ALF-5402: mailService bean should not set username or password properties when mail.smtp.auth is false
   23554: Fix ALF-5170 - when you don't have permission to change a user's password (either because you're not an admin, or you mis-typed your own password), give a friendly message rather than an error stacktrace
   23558: Fixed ALF-5513 "Incorrect behavior of tab stop indexes at Create Site page"
   23559: Fixed ALF-5136 "My Tasks dashlet: Incorrect capitalization on mouseover text"
   23561: Fixes: ALF-4569 - Removes universal override of input width box and switches the editor form panel to adjust it's width based on content rather than window size.
   Fixes: ALF-4570 - Adds an override for the CSS 'top' property of the form dialogue to ensure it's always below the ribbon. (Was being set automatically by the YUI widget.panel call)
   23569: Fixes: ALF-5606 - Ribbon wasn't resizing correctly after the form events.
   23571: Improvements to missing page and general server 500 error handling in Share.
   23572: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23570: Resolve ALF-5355: ClassCastException on server side when calling SCORE() predicate (web services binding)
   23573: Fix for ALF-4840: Create Job button is enabled when Start Date isn't specified
   23580: ALF-3586 Verified that RenderingEngine Actions are not displayed as available actions in Share and Exporer. Now publicAction defaults to false for all RenderingEngine actions, so future RenderingEngines should be hidden in the UI by default.
   23582: Fixed (Explorer) ALF-439 "My Completed Tasks" dashlet doesn't scale in the presence of large numbers of completed tasks
   23584: DateTime analysis related fixes:
       Fix for: (ALF-4056) Content with DateTime property with the time set to 00:00:00.000 will not be found in lucene search when search is run from 00:00:00 to 23:59:29 for the same date.
          - bug generating range query start queries
       Fix tests and test models
       CMIS and normal query tests all run with the date and  datetime analysers configured for datetime properties
       Fixed unreported issue with CMIS range queries for dates when using the date time analyser
   23585: Fixed ALF-5372 "JavaScript error on Groups management dialog with IE8 : document.getElementById is null"
   23590: MERGED V3.3 to V3.4
   23545: Fixes: ALF-6568 - Broken images caused by missing URL Rewrite rule. Updated existing rules from ** to (.*) following earlier bug fix.
   23591: Probable fix for ALF-4440. Renditions are not updated for working copy.
     As suggested in the issue, we have relaxed the restriction such that working copies now have their renditions updated in the normal way. Therefore, updates to draft (working copies) in Quickr should now cause (asynchronous) updates to any webpreview and doclib thumbnails in the normal way.
     As part of this change, we have also changed the behaviour so that renditions are no longer copied when a node is copied. This is relevant as when a document is checked out, a copy is made (the working copy). In order to avoid potential problems with copied rendition children being updated separately from the rendition children on the original copy, we no longer copy renditions - they will be regenerated separately for the working copies.
   
   This fix needs to be verified by a tester who has access to a running Alfresco-Quickr integration module.
   23592: ALF-4350 Fix for SiteService.updateSite() regarding Site Visibility change
     site:siteVisibility is a d:text property and is treated as a String in all places apart from within updateSite where a Java enum is written into the db. This seems to cause a problem on the DB specified in the issue.
   23608: Merge from V3.3-BUG-FIX to V3.4
      23606 Dmitry/Erik's fix for ALF-1052. Webpreview of swf files.
   23610: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23579: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
           23576: Merged BRANCHES/DEV/BELARUS/V3.3-BUG-FIX-2010_06_24 to BRANCHES/V3.3:
                20998: ALF-3764: Filepicker be able to select URLs
                
      23609: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_06 to BRANCHES/DEV/V3.3-BUG-FIX:
           23158: ALF-1838: Need to support relative url for WCM TinyMCE Filepicker.
   
   Also fixes ALF-866 (cloned version of ALF-1838).
   23612: Fix for ALF-3677: Editing inline html content
   23615: Resolve ALF-5044: Alfresco 3.4 fails to start on Webshere 7 with org.alfresco.service.cmr.repository.MLText ClassNotFoundException
   23621: Merged V3.3-BUG-FIX to V3.4
      23620: Merged V3.3 to V3.3-BUG-FIX
         23619: Fix for ALF-1537 - Presentation Tier JS processor now correctly outputs different messages for when scripts:
                a) load incorrectly, i.e. error resolving imports or import syntax error "Failed to load script..."
                b) runtime execution error "Failed to execute script..."
                 
                Performance improvements
                Cache test delay fix
   23625: Fix ALF-629 - Allow the thread pool size to increase to the maximum when the queue starts to fill up, rather than only when it gets full (which is rarely will, as we want a very large queue size to avoid dropping work)
   23626: Fix for ALF-906: "Impossible to create web project if rule with Copy action was applied"
      o ensure that WCM web projects do not inherit DM rules
   23632: ALF-906: "Impossible to create web project if rule with Copy action was applied"
     - added missing file
   23635: Merge DEV to V3.4
       23627 : ALF-4947 - EML files not showing up in folder list
   23636: Reverse merged HEAD to V3.4
      23195: Temp comment out of ImapMessageTest (The test or the code is not wrong but the IMAP server is not running in the automated build.)
   23637: Merged V3.3-BUG-FIX to V3.4 (RECORD ONLY)
      23314: Merge from V3.3 to V3.3-BUG-FIX
         r 23311: Further fix for ALF-3991. Renditions/thumbnails cause update to modifier property.
         This is a reimplementation of r 23290 which was checked in on HEAD earlier.
         The RenditionService has been refactored between 3.3 and 3.4 and straight merges are not always possible.
      23355: Merged DEV/V3.3-DOCLIB-PORTLET to V3.3-BUG-FIX
         20814: Share host portlet detection and portlet action URL template and associated client-side constants. Latest SpringSurf libs to bring branch up-to-date.
         20995: DocLib Portlet checkpoint: URL encoding fixes, CSS fixes, Portlet URL links generators as client-side JavaScript & Freemarker macro. "My Document Libraries" landing page.
         21008: DocLib Portlet: Login page recognizes portlet mode, replaces input boxes with message "Please login via your portal.". When portlet mode detected, JSESSIONID cookie for path=/share is removed to prevent ALF-3749. URL encoding fixes. CSS fixes. Reverted patch to YUI history module.
         21047: DocLib Portlet: Site title shown on all Site pages for better usability. More CSS fixes to replace some default Liferay overrides.
         21078: DocLib Portlet: User profile links related to DocLib are not rendered if in portlet mode. Client-side generated links all now use one central function.
         21106: DocLib Portlet: Fix missing alias
         21152: DocLib Portlet: Missed a URL translation step on Rules page and default path render. URL encoding fix for file highlight parameter (double encoding issue). Fix for IE7 "empty DIV" bug relating to panel resizer & footer placement.
         21171: DocLib Portlet: Fix missing Freemarker macro include
         21435: Fix variable alias typo ($userProfile on details page for locked document)
         21698: *RECORD ONLY* New portal distribution zip target (to create alfresco-enterprise-war-3.3-portal.zip) and draft README.txt file. * DO NOT MERGE *
         21712: *RECORD ONLY* Updated README.txt  * DO NOT MERGE *
         22600: DocLib Portlet: New "Site constrained" portlet added where site is configured via portlet preferences. Removed CMIS portlet.
         23023: Fix Share DocLib Portlet CSS issues for Liferay 6. YUI Buttons back to normal. Background now set as white. Login page no longer sets background colo(u)r of body tag. Toolbar separator styling fix.
         23050: Fix "My Document Libraries" page template mapping & css tweak
      23522: Merged V3.3 to V3.3-BUGFIX
         23346: Brought WebQS module in (including build process but not installer elements yet)
      23524: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
         23371: "Simply" added wcmqs to installer
      23567: Merged HEAD to BRANCHES/DEV/V3.3-BUG-FIX:
         22837: Resolve ALF-5042: Default root folder path '/Company Home' not found
         22845: Fix regression from resolving ALF-5042 (Default root folder path '/Company Home' not found)
      23596: Merged HEAD to BRANCHES/DEV/V3.3-BUG-FIX:
         20636: ALF-3157 - Conflict between IMAP and Audit
         20638: ALF-3157 - Conflict between IMAP and Audit
           - part II update the auditConfig.xml
      23634: Merged V3.3 to V3.3-BUG-FIX
         23259: Merged HEAD to V3.3
            23256: Fix ALF-4573: Start Workflow action is absent for edited document and working copy in Share
         23391: ALF-5367: Copy dlls into tomcat/bin as appropriate.
         23485: Merged V3.4 to V3.3 (fix backported for V3.3.x lines)
            23472: Fixed ALF-5408: SQL Server missing ON DELETE CASCADE declarations
         23535: Merged V3.4 to V3.3 (complements 23517: ALF-5552)
            23508: Fixed ALF-5559: Permission interceptors can fail if Lucene returns invalid NodeRefs
         23586: MERGED V3.4 to V3.3
            22864: Fix for ALF-5005: "Create and edit functions on AWE become "confused""
            23042: Fix ALF-5127: Impossible to create an article/blog (WCMQS) [Must clear panel hideEvent handler if manually hiding a YUI panel]
            23561: Fixes: ALF-4569 - Removes universal override of input width box and switches the editor form panel to adjust it's width based on content rather than window size. 
                Fixes: ALF-4570 - Adds an override for the CSS 'top' property of the form dialogue to ensure it's always below the ribbon. (Was being set automatically by the YUI widget.panel call)
            23569: Fixes: ALF-5606 - Ribbon wasn't resizing correctly after the form events.
         23630: Backport of installer
         23631: Added 64-bit & deployment installers
   23639: Fix for ALF-5670: "Repository fails to start when applying patch.wcmRuleInheritance if WCM is not enabled "
      - removed patch, replaced with check in WebPorjectServiceImpl.getWebProjectsRoot instead
   23640: Merged V3.3-BUG-FIX to V3.4
      23199: Over-ride the spring config and bring up the IMAP server in the unit test start-up.
      23235: Merged V3.3 to V3.3 BUG FIX
         23226 : RECORD ONLY fix up of unit test
      23315: (RECORD ONLY) Merge from V3.3 to V3.3-BUG-FIX
        r 23312: Adding explicit test case for ALF-3991.
        r 23313: Adding some new test classes to the convenience suite AllRenditionTests.java
      23423: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
         - ALF-5027: When node has been created and checked out in same transaction (e.g. via CMIS or Quickr) content rules will fail
      23460: Added better logging of errors when mapping NFS users to Alfresco users.
         Use database node id counter field value as the file id. Part of ALF-4883 and ALF-5386.
      23587: MERGED V3.3 to V3.3-BUG-FIX 
         22864: Fix for ALF-5005: "Create and edit functions on AWE become "confused"" 
         23042: Fix ALF-5127: Impossible to create an article/blog (WCMQS) [Must clear panel hideEvent handler if manually hiding a YUI panel] 
         23545: Fixes: ALF-4568 - Broken images caused by missing URL Rewrite rule. Updated existing rules from ** to (.*) following earlier bug fix.
         23561: Fixes: ALF-4569 - Removes universal override of input width box and switches the editor form panel to adjust it's width based on content rather than window size. 
         Fixes: ALF-4570 - Adds an override for the CSS 'top' property of the form dialogue to ensure it's always below the ribbon. (Was being set automatically by the YUI widget.panel call) 
         23569: Fixes: ALF-5606 - Ribbon wasn't resizing correctly after the form events.
      23616: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
         23614: Fix ALF-5627: Transfer Service not processing deleted nodes correctly. Causing NullPointerException in receiver.
   23643: Speed up AuditMethodInterceptor when it is not used
    - Check path matching early in interceptor
   23644: Merged V3.3-BUG-FIX to V3.4
      23638: ALF-2731 - hash collision in TransactionBehaviorQueue
      23642: Merged V3.3 to V3.3-BUG-FIX
         23261: Fix for ALF-3385 - NullPointerException printed when new browser session opens to /alfresco/faces/jsp/dialog/container.jsp#
         23291: Fix ALF-5189: JSF - Links to different spaces in my Company Home are not diplayed in MS Office Add-in
         23295: Fix for ALF-481 - handle both missing surname and givenname from LDAP sync in Explorer client
         23296: Fix for ALF-1881 - Alfresco doesn't have protection against double clicking (merge of port from 2.2)
         23302: Fix for ALF-284 - Incorrect behaviour of radio buttons on Check Out page
         23311: Further fix for ALF-3991. Renditions/thumbnails cause update to modifier property.
            This is a reimplementation of r 23290 which was checked in on HEAD earlier.
            The RenditionService has been refactored between 3.3 and 3.4 and straight merges are not always possible.
         23312: Adding explicit test case for ALF-3991.
            This is a separate check-in to 23311 a moment ago as I want to merge this test class through to HEAD but I do not want to merge 23311 to HEAD.
         23313: Adding some new test classes to the convenience suite AllRenditionTests.java
         23325: Fix for ALF-2098 - Incorrect work of Close button inside of created group
         23327: Fix for ALF-5383 - Wiki html page viewer does not render indentation properly
         23328: Merged BRANCHES/DEV/BELARUS/V3.3-BUG-FIX-2010_06_24 to V3.3 
            21094: Workaround provided in issue description can be used as fix because of folowing code: 
               - Object[] params = new Object[] {action, approveFolderName, Utils.encode(approveStepName)}; 
               - out.write(Utils.encode(MessageFormat.format(actionPattern, params)));
               - Utils.encode method is called twice when generating output. One of this call can be removed as unnecessary.
         23337: Fixed ALF-26 "Audit Tool: Event filter doesn't work"
            - Commented out ui controls for "Event" & "Property" log-filters (which is implemented in the REST API but NOT in RecordsManagementAuditServiceImpl and therefore didn't work)
         23342: Resolve ALF-4703: Share Unable to Edit Metadata more than Once with Auditing Enabled
            - if audit internal is enabled, then category service methods missing audit tags fail (also, there's an audit service method missing a tag too)
         23354: Fixed ALF-5026: Change XAM property names to XAM standards
            - Global prefix: xam.archive.globalPropertiesPrefix=vnd.com.alfresco.
            - Node property prefix: xam.archive.nodePropertiesPrefix=xam.archive.node.
            - e.g.'vnd.com.alfresco.xam.archive.node.cm:created'
         23357: ALF-4745: Removed tomcat bundles as these were incomplete and 32/64 bit specific. Installation docs already updated.
         23401: Fixed ALF-4659 (ALF-4652): Configurable XAM Bindings
            - Added property: xam.archive.bindingPropertiesPattern=vnd\\.com\\.alfresco\\..*
            - Properties are non-binding unless they match pattern defined
            - Content property (vnd.com.alfresco.content) is always binding
         23410: Merged DEV/BELARUS/V3.3-BUG-FIX-2010_10_04 to V3.3
            23162: ALF-4934 Problem creating a folder using CIFS with permissions Contributor
         23467: ALF-2762 : Customer-provided fix to 3.2R-SQLServer-Microsoft JDBC driver issue
            1. Support of Microsoft JDBC driver was implemented.
            2. Classpath was updated (jtds driver was removed Microsoft jdbc driver was added).
         23471: Forget to remove old jdbc driver
         23473: Fixed compile error after merge
         23483: Removed MS SQL JDBC driver following rev 23467 fixing ALF-2762
         23484: Re-added JTDS driver following rev 23471 fixing ALF-2762
         23491: Merge DEV to V3.3
            23486 : ALF-5389 - If we contribute via IMAP in outlook or outlook express,an EML file, which has embedded images and attachments, has not his body content indexed
         23537: Fix to RM module since changes to action service config.
         23545: Fixes: ALF-6568 - Broken images caused by missing URL Rewrite rule. Updated existing rules from ** to (.*) following earlier bug fix.
         23566: Fixed ALF-5545: XAM connector xam.archive.node.* properties not set
         23623: Merged PATCHES/V3.3.3 to V3.3
            23622: ALF-5611: Fix calendar page by bracketing freemarker default operator to avoid any ambiguity. See http://freemarker.sourceforge.net/docs/dgui_template_exp.html#dgui_template_exp_precedence
         23624: Merged BRANCHES/DEV/BELARUS/V3.3-2010_11_10 to BRANCHES/V3.3:
            23602: ALF-5517: Webdav "supportedlock" propfind request fails if locking enabled
   23646: Merged V3.3-BUG-FIX to V3.4
      23430: Merged V3.3 to V3.3-BUG-FIX
         23429: Merged PATCHES/V3.2.0 to V3.3
            23428: ALF-5141: Further refinement of transaction limiting behaviour
               - Once accepted a transaction will be retried until it succeeds or the retry limit is exceeded. No limiting of retries by time as otherwise likelihood of any transaction succeeding under load is small
               - Default web transaction threshold is now 20 seconds to avoid problems on non-loaded systems
               - Record stack traces of tracked transactions to help debug slow transactions
      23645: (RECORD ONLY) Merged V3.3 to V3.3-BUG-FIX
         23515: Merged PATCHES/V3.2.0 to V3.3
            23514: ALF-5554: Merged HEAD to V3.2.0
               23153: When updating tag scopes following system shutdown/restore, be smarter about quickly skipping tag scopes that another (new) thread is currently working on
               23283: More debugging level logging for tagging updates, to help identify the problem with periodic multi-threaded test failures on bamboo
         23564: ALF-5600: Merged V3.4 to V3.3
            23424: Fixes: ALF-2989 - Incorrect sideId reference in URL for event in Site Calendar Dashlet
               Adds support for displaying events that start in the past but finish in the future (previously only events that start in the future were shown)
   23648: Update Tika + dependencies (including PDFBox to 1.3.1, and a slightly newer POI). Fixes ALF-5645 and ALF-5646
   23649: ALF-5648 - When rendering word to html in body contents only mode, don't include the xml definition
   23653: Performance improvements:
    - reduce calls to servlet container getResource() method during REST heavy apps
    - improve audit interceptor (Derek supplied 1st part of improvements in rev 23643)
   
   Overall 20% improvement since performance issues noted a few days ago.
   Share multi-user read tests with x20 users.
   Performance is now slightly better than previous record from 3.4 on 5/7/10.
   
   ENT 3.4.0E 11/11/10
   10 users x5 rep, 10sec so - time 3rd run
   - 80ms,
   20 users x5 rep, 10sec so - time 2rd run
   - 168ms
   
   ENT 3.4.0E 15/11/10 (after performance tweaks)
   10 users x5 rep, 10sec so - time 3rd run
   - 55ms
   20 users x5 rep, 10sec so - time 2rd run
   - 125ms
   23655: Add more tests for name and role filtering when listing site membership (Related to ALF-5314)
   23656: Fix for ALF-5674: The association picker control allows content nodes with children to be navigated
   23657: Fix ALF-5314 - expose the siteService flag of collapseGroups from listMembers to the listMembers method on the site object itself, and make use of this when searching for people who are site members in Share
   23658: Follow-up to r23644: Add reference to validation.js in Enterprise overlay file
   23659: Fix for ALF-906: "Impossible to create web project if rule with Copy action was applied"
      - moved add aspect to createWebProject method
   23660: Fixes ALF-3783: When searching in Advanced Search, russian letters are encoded incorrectly.
   Mootools replaced with uncompressed source copy with annotated modifications. Then YUICompressed at build-time to generate mootools-v1.11.js
   23663: Fixed ALF-5462 "The workflow details doesn't/can't display the group the current task is assigned to when it is pooled and not claimed"
   23665: Fixed ALF-4556 "Error occurs on search by wildcards"
   23667: Push the logging log4j definition bean out into another context file, included from core-services-context.xml (rather than being defined directly in it). This allows you to write a unit test without the main context, but still with our log4j settings
   23668: Tweak DynamicallySizedThreadPoolExecutor logging, and have log4j settings used by DynamicallySizedThreadPoolExecutorTest even if the full repo context isn't loaded
   23670: Fix ALF-5609: Incorrect behavior of messages mimetype for Share and Quickr connector
   23671: Merged /BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
     23666 (record-only): Fixes ALF-5691: TransferService: Multi-byte characters are not encoded correctly
   23673: RM Audit:
     - ALF-5307: Audit doesn't work for RMA
     - Buttons on audit console now reflect the current state and are initialised correctly when the console is first shown.
     - ALF-5616: Start and stop date are not being set correctly
   
   23675: Fix for ALF-5244: Issues with selectmany.ftl control
   
   Option and label separators can now be configured like selectone, the control now also shows the label (when present) not the raw value in view mode. Also fixed a couple of selection bugs.
   23677: Merged V3.3-BUG-FIX to V3.4
      23676: Fix ALF-4035: Properties with underscores are not displayed in datalists
   23678: Fix transformationOptionOverrides related warnings for the includeEmbedded, by converting the string to boolean before setting the bean property if needed
   23679: Fixes: ALF-5595 - updated files to reflect supported language packs & added the file to the enterprise overlays build/clean targets
   23680: If thumbnailing cannot be performed either due to no transformer existing, or the transformer being unavailable, deliver more helpful log messages than before (but at the same priority). Related to ALF-5158
   23685: Fixed ALF-4744 "Selectable resources aren't limited to the current site in case workflow is started from details page"
   - added "item.location.parent.nodeRef" in remote-api slingshot webscript
   23686: Merged BRANCHES/DEV/BELARUS/V3.4-2010_11_11 to BRANCHES/V3.4:
      23672: ALF-5597: Nodref is a mandatory parameter notification pops up when Sites is selected (Quickr connector v 8.1.1.175).
   23688: ALF-5405: Strange behavior with long names
   
   - Now if at NodeService enters invalid QName will occur IllegalArgumentException  instead of DuplicateChildNodeNameException
   - Method QName createValidLocalName(   ) is override
   - It is added jUnit test
   Such behavior allows to avoid an undesirable situation
   
   23693: Fixing bug introduced when fixing ALF-5529 (r23546)
   - Enter key & mouse click events from Alfresco.util.useAsButton returned different parameters to the same callback, now fixed
   23698: Use the smaller netcdf jar to avoid SFLJ warnings
   23699: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
     23697 (record-only): Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
        23695: Fixed bug exposed after fixing ALF-5699. Parsing of MLText properties out of the transfer snapshot file was incorrect, and that was causing multi-lingual property values to be duplicated
   23700: ALF-3084 Checking out documents no longer updates the modifier/modified date.
   23702: Fixes ALF-5671: TransferService: BeforeStartInboundTransferPolicy now being fired *after* the transfer lock has been taken
   23703: Fixes: ALF-5633 - Date string not localisable in Blog Archives list
   23710: Fix for ALF-4678: Incorrect workflow details if creator or assignee was deleted
   23715: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
     23713 (record-only): Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
       23709: ALF-5699: Fix NPE in ManifestIntegrationTest
   23719: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23717: Fix for ALF-5703: Error when creating a folder within a container using Webscript
   23720: Merged BRANCHES/DEV/BELARUS/V3.4-2010_11_11 to BRANCHES/V3.4:
      23669: ALF-4357: Bitrock Installer: Remote JMX connections fail
   23721: ALF-3044: Audit log is incorrect when trying to filed it as record
   
   23722: ALF-5405: Strange behavior with long names
   
   Code justify in according to coding conventions: 
   - 4 spaces for a tab 
   - Braces on new new line 
   - 120 char line lengths 
   
   23723: Declare all Share UI support webscripts as "internal" lifecycle
   23724: Remove unnecessary css include from RM-audit component
   23729: Fixed ALF-5087 "My Sites Dashlet does not persist the filter setting for All Sites | Sites | Favorite Sites etc"
   - Filter is now persisted as property
   - Calls to get sites & preferences was implemented both server and client side, now client only. 
   - Cell renderers has been refactored from inline to member methods
   - Native button/dropdown are hidden until yui components is created to avoid ui jumping around...
   - ...which also causes the annoying "gap" when resizing which now has been fixed for both My Tasks & My Sites
   23730: ALF-2598 - temp disable Imap Cache - will murder performance but pass unit tests.
   23732: Fix to output of error message in doc summary and image dashlet
   23733: Performance tweak
   23736: Merged V3.3-BUG-FIX to V3.4
      23735: *RECORD ONLY* Merged V3.3 to V3.3-BUG-FIX
         23734: Merged V3.4 to V3.3
            23731: Fixes for ALF-3098 and ALF-3097
                   - Share - Security check on Personal Dashboard - only the owning user can view a user dashboard page
                   - Share - Security issue on Customize Site Dashboard - private and moderated site dashboard pages no longer visible to non-members, customise site and dashboard pages only accessible to SiteManager
   23739: A bit more logging to try to spot why bamboo is different, and add another test
   23741: ALF-4947 - EML files not showing up in folder list
   23749: Fixed formatting: Removed tabs (ALF-5405 fix follow-up)
   23750: Fix unit test (ALF-5405) to check for expected exception
   23751: Prepare for ALF-5575: Remove redundant cache config entries and fix typos
   23753: Fixed ALF-5087 "My Sites Dashlet does not persist the filter setting for All Sites | Sites | Favorite Sites etc" part 2
   - My Tasks dashlets second toolbar became a bit to high, now fixed
   23754: Fixed ALF-2975 "Layout is broken for Audit in IE"
   23755: Work around the fact that some JVMs fail to properly implement the ThreadPoolExecutor specification, and consequently sometimes kill off threads that are in the core pool. Tests now look for either the specification required behaviour, or the broken behaviour
   23756: Change to test code for DynamicallySizedThreadPoolExecuter. Removed unecessary assert which fails on some OSes. Nick B.
   23763: Clean-up login template controller script
   23764: Fixing a typo in test include/exclude spec which meant that WebScriptTestSuite was not being run.
   23766: Fixed ALF-3823 "Share: RSS feed can't be read: http://cds-srv.sun.com:8700/rss/update/public/sunalert_update.xml - ok with other RSS client."
   23768: Add new unit test for international category names. Shows that english, spanish  and french works fine, but that there's something a little iffy with japenses
   23773: Fix for ALF-5240: Something odd happens in My Content page on adding comment
   23785: Fix for ALF-1728: User with administrative rights can paste content into staging.
   23788: Method naming fix (ALF-5405 follow-up)
   23793: Merge from V3.3-BUG-FIX to V3.4
     r. 23791 Fix for failing test cases SiteServiceTest and InviteServiceTest.
              I have used susbsystem bean overriding to turn off emails on the MailActionExecuter bean.
   23800: Fix for ALF-5569: Error trying to change discussion's name
   23805: Add a pure nodeService test for the Japanese write/read issue in ALF-5594. This test will almost certainly break on some db flavour builds on panda, but we want to know which systems are affected (before commenting it out pending the fix)
   23806: ALF-5087 "My Sites Dashlet does not persist the filter setting for All Sites | Sites | Favorite Sites etc" part 2
   - Now provides default filter if not set
   23810: Merged from V3.3-BUG-FIX to V3.4 (RECORD ONLY)
   23809: Merged from V3.3 to V3.3-BUG-FIX 
      23790: Fixed ALF-3823 "Share: RSS feed can't be read: http://cds-srv.sun.com:8700/rss/update/public/sunalert_update.xml - ok with other RSS client."
   23818: Merge from V3.3-BUG-FIX to V3.4
     r. 23817: Further fix for InviteServiceTest failing tests.
   23825: ALF-3066: Google docs - Document not deleted when checked in
   
   23826: Prevent 'nodeOwner' cache invalidation during node creation
   23827: Prevent cache case flip-flopping on encoding strings
   23828: Removed some TODO notes
   23829: Single minor format
   23830: Generics warnings
   23831: Added 60s timeout on mutable node-related caches (ALF-5575)
   23832: Trimming on cache invalidation during put
   23833: Fixed ALF-5575: Enable ConcurrentNodeServiceTest.testMultiThreadedNodePropertiesWrites
    - Prevent read txns from adding stale data to caches while writes are in progress
    - Added cache tests for mutable caches and read-only transactions
   23834: Fixed ALF-5763: Corrected capitalization.
   23838: Corrected an overzealous method rename refactor in QName to not throw a null-ptr-exception.
   23839: Merge from V3.3-BUG-FIX to V3.4
     r.23837: Reimplementation of the build fix for InviteServiceTest. This one won't send emails.
   23840: Merge from V3.3-BUG-FIX to V3.4
     r.23837 Reimplementation of the build fix for InviteServiceTest. This one won't send emails.
   This check-in is merge properties on root. Couldn't check in previously (23839).
   23843: Added debug output for failing workflow REST API test as it works fine on my local machine.
   23852: Fix for ALF-5664: Aspect Mandatory Aspect leads to failed to find property/association definition for property/association
   23856: Added explicit failure for dangling test transactions
   23858: Fix ALF-4277: Link with a long description is displayed incorrectly
   23861: Fail on dangling transactions
   23869: Added system property 'system.cache.disableMutableSharedCaches' (false by default)
    - Equivalent to disabling Hibernate L2 cache
    - Can be used as a diagnostic feature to quickly check for cache problems
   23871: Merged DEV/TEMPORARY to V3.4
      23759: ALF-4357: Bitrock Installer: Remote JMX connections fail
         1. Default RMI bind to all interfaces via alfresco.rmi.services.host 
         2. New property alfresco.rmi.services.external.host with default value ${localname}. This represents the externally-resolvable host name of the RMI server that should be published in the stubs. 
         3. jmxUrl gets a hostname from sysAdminParams
      23770: ALF-4357: Bitrock Installer: Remote JMX connections fail
         Additional jmx.remote.rmi.server.socket.factory configuration for ConnectorServerFactoryBean
      23781: ALF-4357: Bitrock Installer: Remote JMX connections fail
         Configuration of alfresco-virtserver-context for use a alfresco.rmi.services.external.host property
      23783: ALF-4357: Bitrock Installer: Remote JMX connections fail
         Configuration of alfresco-virtserver-context for use a alfresco.rmi.services.external.host property
   23879: Fixed ALF-4687 "Folder with name 'null' is created in the site space"
   23882: Merged V3.3 to V3.4
      23860: Improved fix for ALF-5448 
             - Pickers no longer return hasChildren information. This reduces the number of getChildAssoc() calls required from N+1 to 1. 
             - Cleaned up and improved hasChildren() methods on ScriptNode and BaseContentNode. 
             - Fixed up Share pickers to not expect hasChildren info
   Fix for ALF-5848 - object picker now allows navigation down into cm:category objects
   23884: When testing the Replication Service and the underlying Transfer Service blows up, tidy up the transactions before reporting the problem. This allows all the tests to run even if some are failing (which they currently are, due to a TransferService regression)
   23888: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
     23886 (record-only): Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
       23883: Fixes ALF-5759: WQS: Attempt to copy a website section fails
   23890: Fixes for date time 
    ALF-695: Date time tokeniser will include all parts of date and time - even when searching with just date - so lenient dates fail
    Fixed CMIS date ranges (with unit test)
    Other unreported date-time fixes
   23892: Upgrade Tika and POI, so we get lower memory parsing of .xlsx files (switches from DOM based to SAX based). Custom build containing TIKA-521
   23893: Fix for ALF-466: Impossible to 'remove' association in a workflow (Explorer client)
   23894: Merged V3.3-BUG-FIX to 3.4
      23872: Merged V3.3 to V3.3-BUG-FIX
         23868: Merged PATCHES/V3.3 to V3.3
            23848: (RECORD ONLY) Merged DEV/TEMPORARY to PATCHES/V3.3.3
               23847: ALF-5448 Cannot upload attachments to data lists (https://issues.alfresco.com/jira/browse/ALF-5448)
                  Additional property hasChildren and corresponding getter method was added to ScriptNode and BaseContentNode.
            23860: (RECORD ONLY) Improved fix for ALF-5448
               - Pickers no longer return hasChildren information. This reduces the number of getChildAssoc() calls required from N+1 to 1.
               - Cleaned up and improved hasChildren() methods on ScriptNode and BaseContentNode.
               - Fixed up Share pickers to not expect hasChildren info
            23863: Fix PolicyTest
   23899: When trying to figure out the encoding of a piece of text, if the current guesser doesn't know, try Tika before giving up and going for the default. (ALF-2534)
   Also adds some more tests for encoding detection
   23908: ALF-5435: Declare as record action is missing for emails
   
   23914: Merged V3.3-BUG-FIX to V3.4
      23913: Fix ALF-3067: Script error at the 'View Details' for record
   23916: Fix ALF-3173: Favorite sites a user is not a member of cannot be removed from the Sites dropdown.
   23918: Fix up transfer unit tests and wcm quickstart following ALF-5575
   23925: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23911: Fix for ALF-5621: "Long-running patches can result in a database connection closed exception"
           - added requiresTransaction flag to patch-services-context
           - refactoring to allow a patch to be called with no enclosing transaction if requiresTransaction == false
     23915: Fix for ALF-5621: "Long-running patches can result in a database connection closed exception"
          - added missing file
   23928: Merged V3.3-BUG-FIX to V3.4 
      23927: Fix for ALF-5867 - Forms dependencies (CSS and JS) not getting loaded by Forms UI
   23932: Merging from V3.3-BUG-FIX to V3.4
   r23903: ALF-5385 Now paging is enabled on groups GET REST API. Also fixed an issue where GroupsTest.testSearchGroups() was failing.
   23933: Follow-up fix to r23908
   23940: Fix for ALF-5880
   23944: Merged V3.3-BUG-FIX to V3.4
      23943: Fix ALF-5316: Event isn't removed after re-scheduling disposition. Also fixes tree not updating when new containers are created.
   23950: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      23942: Fix for ALF-5783: Not possible to override the output path pattern anymore when a webform is edited for a specific website
   23951: Backing out previous change as the solution needs re-implementing for the 3.4 branch
   23954: Merged V3.3-BUG-FIX to V3.4
   23953: Fixed ALF-2830FOR "REVIEW: In mytasks(panel) webscript, "Task Done" button hidden in French" part 2
   23949: Fixed ALF-2830 "FOR REVIEW: In mytasks(panel) webscript, "Task Done" button hidden in French"
      * Removed hardcoded width
   
   23955: When the Text to PDF content transformer is reading in the text file, pay attention to the encoding of the file when constructing the InputStreamReader. Also includes a disabled unit test, which seems to show up a PDFBox bug. (ALF-2534)
   23960: Merged DEV/BELARUS/V3.4-2010_11_11 to V3.4
      23910: WCM: upgrade / re-index can fail on 3.4 if link validation (now removed) was previously being used
      - Incremented schema number as well
   23963: Merged V3.3-BUG-FIX to V3.4
   23962: (RECORD-ONLY) Merged V3.3 to V3.3-BUG-FIX
      23961: Fixed ALF-5686 "Incorrect behaviour of "All" filter in "My Tasks" dashlet"
   
   23967: Merged V3.3-BUG-FIX to V3.3
     - 23966: DOCLIB: Tags are not displayed
     
   23969: Removed case sensitivity for UTF-8 encoding
   23972: Fix for ALF-5798: "Quartz 1.7.3 and higher phones home"
      - added a flag to quartz.properties to stop the phone home
   23975: ALF-5346 Added a unit test to AlfrescoJavaScriptIntegrationTest.
   23980: Merged: From V3.3-BUG-FIX to V3.4
      23979: Merged From V3.3 to V3.3-BUG-FIX
         23970: Fixes: ALF-5858 (Javascript error caused by files 404'ing) - URLRewriting bug introduced in r23545
   23986: Fix for ALF-4646: Workflow REST API webscripts do not have sufficient documentation
   23992: Enhanced the select controls to allow a default, initial selection to be specified either in component binding properties or on the URL. The value is ignored if a value is already set for the property.
   
   To use this feature use the new "defaultValueContextProperty" control parameter, for example:
   
   <field id="ws:language"> 
      <control template="/org/alfresco/components/form/controls/selectone.ftl">
         <control-param name="options">en|English,fr|French,de|German,es|Spanish,it|Italian</control-param>
         <control-param name="defaultValueContextProperty">localeId</control-param>
      </control>
   </field>
   23993: Building blocks for ALF-5084. A new ActionConditionEvaluator for has-child.
   23997: Fix ALF-5731: Saving a doc from Office 2003 via WebDAV fails
   24003: BatchProcessor always calls afterProcess now (as per Javadoc)
   24004: Undid rev 23827: Prevent cache case flip-flopping on encoding strings
   24006: Merged V3.3-BUG-FIX to V3.4
      24005: Fix ALF-4368: Share - File menu not loading properly on IE
   24010: Merged V3.3-BUG-FIX to V3.4
      24009: *RECORD ONLY* Fix ALF-3155: Site Calendar dashboard works incorrectly
   24015: Merged V3.3-BUG-FIX to V3.4
      24014: Merged V3.3 to V3.3-BUG-FIX
         24013: Fix for ALF-5897 - AWE - HTTP authentication requested when page loaded - AWE login fails 
   24018: Avoid a NullPointerException if the action lacks a noderef
   24024: ALF-4066: Creating RM Folders via IMAP in email client throws errors
   
   - Adding a folder to a category now automatically downcast the folder to a record folder
   
   24026: Fix ALF-5567: TinyMCE language fails to load custom language in forms engine. Also code standards for some related code.
   24028: Fix for ALF-5788: Outlook 2003: event isn't deleted in Share if it was deleted in Outlook
   24032: Fixes ALF-5885: Inserting document to wiki page causes an error
   24048: Fix for ALF-5897 - updated surf.xml to set correct user factory
   24051: Removed 'Delete All Items' from trashcan dialog' (part of ALF-1990)
   24052: Fixed ALF-1990: Trashcan "Delete All Items" button might not delete all items
    - Pulls back all items for batch-processing
    - Fixes bug but needs enhancement to use pageable node query
   24056: Fixed SAIL-367 "REfactor header.css to avoid needing a ie8.css"
   24057: Fix for ALF-5620 sitePreset filter in siteService.listSites not working
   24068: Merged V3.3-BUG-FIX to V3.4
      24067: *RECORD ONLY* Fix ALF-5973: Web QuickStart module breaks Share DocLib since Portlet merges
   24069: Merged BRANCHES/DEV/BELARUS/V3.4-2010_11_11 to BRANCHES/V3.4:
      24045: ALF-5781: Non-recurrent event is displayed with "Recurring" label
   24090: Fixed ALF-4972 "Custom workflow is not sorted in workflow list"
   - now ignoring case and falls back to name if title isn't present
   24097: Fix for ALF-5802 - comment based discussions removed from repository search results.
   24098: Add user/permissions related copy test. Currently disabled as something relating to ALF-5288 seems to be wrong
   24099: Fix for ALF-5976: Email Notify Templates not being picked up in Share Rules Send Email UI (requires server restart)
   
   The allowable values of parameter constraints were indeed being cached, I have added a new property on BaseParameterConstraint which allows the caching to be turned off as follows:
   
   <property name="cacheAllowableValues" value="false" />
   24100: ALF-4357: Fix random unit test failures due to RMI registry lookup
   - Implement equals() and hashCode() methods in HostConfigurableSocketFactory!
   - Don't ask me how many hours I wasted on this!
   24102: Further ALF-1990: Removed redundant permission check and fixed tests to check failure reports properly
   24103: Encoding DAO returns uppercase values; internally, DB was always using lowercase
   24104: More put and set trimming to avoid cache remove calls
   24105: Fixed unit test to explicitly recognisable UTF-8 characters
    - Tika was interpreting lame text as ISO-8859-1
    - EncodingDAO case-sensitivity fix got past first failure and onto second, thus obfuscating the root cause
   24114: Fix for ALF-2309: "FTP server can retrieve and overwrite files already moved away from current folder"
      - node paths were inconsistent for moveNode. Fixed them to be consistent.
   24115: Fix failing unit test. In WorkflowTestSuite, shut down the application context used by the other tests before starting JBPMEngineUnitTest. Also reset the WorkflowTaskInstance singleton.
   24123: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      24122: (RECORD ONLY) Fix for ALF-5710: It is impossible to create category in RM with FDK installed
   24126: Fixes: ALF-4775: UI Spelling mistake corrections
   24140: ALF-170: The user has all rights for audit once "Access Audit" capability is added to him
   
     - Capabilities added to the underlying audit service blocking access to audit functions as expected
     - TODO UI still needs updating
     - TODO export fn still needs isolating
   
   24142: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4:
      24141: (RECORD ONLY) Build fix
   24144: Removed tabs
   24145: Fixed test to use 'system' user after permissions were tightened around RM audit (ALF-170)
   24146: Correctly disable a supposedly disabled test, pending a proper fix for the underlying issue (ALF-5288)
   24154: Merged V3.3-BUG-FIX to V3.4
      24152: Merged V3.3 to V3.3-BUG-FIX
         24151: Merged V3.3.3 to V3.3
            24150: Further fix for links list issue identified in ALF-5966
   24163: Fix for ALF-5954 - username uri encoding
   24164: Put tearDown deletes in transaction
   24174: Added 3rd-party license
   24180: 
   24186: Fix for ALF-438: Error appears after adding a content to space where content rule 'Check Out in the current space' was created.
   24187: ALF-5400: Merged V3.3 to V3.4
      23650: Switch off transaction limiting for now, pending further investigation
   24191: MERGED V3.3-BUG-FIX to V3.4
     23864:Merge BRANCHES/DEV/BELARUS/V3.3-2010_10_22 to V3.3_BUG_FIX
       23229 : ALF-5239 WebDAV shows incorrect creation date
     23652 : ALF-4902 - MS Word 2003 stuck and exception org.alfresco.jlan.server.filesys.AccessDeniedException: Get file information
   24192: Performance and scalability improvements related to thread blocking in FreeMarker related classes
    - replacement of single ObjectWrapper related class with threadlocal version
    - replacement of MRU cache implementation (synchronized) with concurrent version
   24193: Removed svn:mergeinfo again.  Please read: https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Merging_Guide
   24194: Merged V3.3-BUG-FIX to V3.4
      24138: Fix bootstrap ordering so that modules can override Enterprise-only beans (ALF-6010)
      24139: Fixed ALF-6010: Content URL recognition errors during bootstrap re-indexing
      24170: XAM: Removed more hacks (ALF-6010)
   24196: Test refactoring as part of investigation into ALF-5969.
   JodConverter-based transformation/extraction tests now pass if OOo is not available on the machine running the test.
   Also some minor refactoring of the temporary node tidy-up code.
   And I've enabled these tests in the build.
   24197: Merge V3.3-BUG-FIX to V3.4
     23742 : Merge DEV to V3.3_BUG_FIX
       23738 : ALF-5520 - IMAP metadata extractor fails to extract dates spanned on two lines
     23865 : Merge V3.3-BUG-FIX-2010_07_13 to V3.3_BUG_FIX
       21263 : ALF-2880: Share - Exception when making a site "moderated".
     23866 : Merge V3.3-BUG-FIX-2010_09_20 to V3.3_BUG_FIX
       22634 : ALF-3859 Module Management Tool stops applying amps if one amp fails when using the -directory option.
     24031 : ALF-5553 - Email preview style lost on Outlook 2007
     24085 : ALF-5928 - Undeclared email can't be copied
     24092 : Fix unit test following change for ALF-3859
     24169 : ALF-5919 - Error on start Alfresco page in read-only mode (NTLM specific)
   24198: Merged V3.3-BUG-FIX to V3.4
      23758: (RECORD ONLY) Merged V3.4 to V3.3-BUG-FIX
      23787: ContentStoreCleaner exits silenty if it can't get the job lock
      23906: Fixed ALF-5119 (ALF-4652): Prevent lock and archive removal until retention period has passed
      23934: (RECORD ONLY) Merged V3.3 to V3.3-BUG-FIX
      24002: CreateNodeRuleTrigger was not doing anything when cm:noContent aspect was added
   24201: Merged V3.3-BUG-FIX to V3.4
      24172: Orphan cleanup code is more sensitive to unsupported URLs (helps ALF-5533)
      24173: Part 1 of ALF-5533: XAM orphan cleanup after rollback or retention job cleanup
      24175: Part 2 of ALF-5533: XAM orphan cleanup after rollback or retention job cleanup
   24210: Merged V3.3-BUG-FIX to V3.4
     23956 : Merged DEV TO V3.3_BUG_FIX 
       ALF-4546 : Moving a secondary child node using a file protocol adapter (such as CIFS) moves the primary child node
   24214: When the tagging service updates the tag scope values in the background, don't fire behaviours for the change as it's an internal system task. Adds a unit test for this, and for general permissions + tagging for ALF-5504
   24217: Put deletes into transaction in tearDown()
   24218: Merge V3.3-BUG-FIX to V3.4
     24017 : ALF-5647 : Empty 'addressee(s)' metadata in share when a mail rfc822 is pushed using IMAP
     24027 : ALF-4647 - missed check in from 24017
     Merged DEV/BELARUS/V3.3-BUG-FIX-2010_11_09 to V3.3_BUG_FIX 
       24086: ALF-5495 - IMAP encoding bug: pushing-poping a message with Content-Transfer-Encoding: 8bit to IMAP server corrupts encoding
     Merged BELARUS/V3.3-BUG-FIX-2010_11_09 to V3.3-BUF_FIX
       24121 : ALF-5647 - Empty 'addressee(s)' metadata in share when a mail rfc822 is pushed using IMAP
   24219: removed file that should not have been added.
   24220: Fix ALF-5568: Shortcoming of export/import mechanism
   24221: Patched build of JodConverter. Hopefully this will help with ALF-5969.
   I have added logging during JodConverter init and during soffice process init.
   24222: Fix typo in message bundle whilst investigating ALF-5650
   24223: Null pointer exception in ImapFolderSecurityInterceptor
   24224: Fix for ALF-219. Impossible to transform from .html to .pdf for empty files
     This was due to a bug within JooConverter - the Community Edition 3rd party lib for OOo connection.
     It handles zero-length files a little unpredictably, producing NullPointers, unreadable PDF docs and someties crashing the soffice process depending on input.
     OOo seems to do a good job itself with empty files, so OOo is not the problem.
   
     I have added a workaround whereby for zero-length files that are going to OOo via JooConverter for transformation, instead of using OOo
     we use Apache PDFBox to produce an empty PDF file.
   
   24225: Excluding **OOoTest from the JUnit test patterns as they are causing the build to hang.
   They work fine on my machine. Honest! Will investigate more closely on Windows OS next week.
   24226: Added an impl comment about a potential future pdfbox improvement.
   24229: Fixes: ALF-5991 - Removed space to fix JDK specific issues w/ string.
   24231: Custom build of JodConverter.
     Added logging to WindowsProcessManager.
     Removed an unnecessary executor.shutDown() call from ManagedOfficeProcess.
   24232: Completed fix for ALF-5802 - comments filtered for document library items as well as repository items
   24233: Removed svn:mergeinfo on root
   24235: Merge V3.3_BUG-FIX to V3.4
     24234 : ALF-5844 - Defining the Lockable aspect as mandatory causes UnsupportedOperationException when checking out content
   24236: Fix for ALF-3941: SSO Share with CAS - external-auth and SSOAuthenticationFilter
   - SSOAuthenticationFilter uses Kerberos example condition - its name has been changed so you have to rename it into scope.
   - Added supporting comments to both sections
   24240: Fixed ALF-5999: Alfresco 3.4 startup fails with XAM connector module
    - Enterprise modules were not being built (Kofax and XAM)
    - Added release version number to AMP files as well as XAM jar
   24241: Merged V3.3-BUG-FIX to V3.4
      24077: ALF-5471 part 1: 'authorityMigration' patch can report 'Node does not exist'
      24078: ALF-5471 part 2: 'authorityMigration' patch can report 'Node does not exist'
   24243: Fixed ALF-6028 "Impossible to reject invitation due to script error"
   24244: Merged V3.3-BUG-FIX to V3.4
      24242: Fix ALF-5608: Script error after 'Edit' on My Spaces List Dashlet. Also fix "More actions..." link going to wrong details page.
   24247: temp commit of imap message test - will be reinstated soon
   24251: Fix ALF-5992: Language pack errors in Share - It's impossible to delete group with native chars in names (IE specific)
   24265: Merged V3.3-BUG-FIX to V3.4 (RECORD ONLY)
      23744: Merge V3.4 to V3.3_BUG_FIX
         23513 : Merge DEV to V3.4
            ALF-4200 IMAP - LSUB Failed. AccessDenied.
      23758: Merged V3.4 to V3.3-BUG-FIX
         23688: ALF-5405: Strange behavior with long names
         23722: ALF-5405: Strange behavior with long names
         23749: Fixed formatting: Removed tabs (ALF-5405 fix follow-up)
         23750: Fix unit test (ALF-5405) to check for expected exception
      24120: ALF-5997: Merged V3.4 to V3.3-BUG-FIX
         23551: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_21 to BRANCHES/V3.4:
            23474: ALF-5490: The Subsystems configuration folder does not seem to be read when Alfresco is deployed to later versions of JBoss
      24124: ALF-5988: Merged HEAD to V3.3-BUG-FIX
         23231: Merged DEV/TEMPORARY to HEAD
            23227: ALF-5271 : Win7+Kerberos+Spp problem
               1. Vti-context.xml was updated for sharepoint module to allow jetty support requests with total size of headers up to 8k.
      24177: ALF-5178: Merged V3.4 to V3.3-BUG-FIX
         24070: Merged DEV/BELARUS/V3.4-2010_11_11 to V3.4
            24011: ALF-5618: Webdav with MAC OS X problems - Locking / unlocking creates new versions
               1. WebDAV locking properties was added to excluded in VersionableAspect
               2. Appropriate JUnit test created.
         24101: Disabled test and reopened ALF-5618
         24117: Fixed test inter-dependencies on 'excludedOnUpdateProps' for ALF-5618
      24259: Merged V3.3 to V3.3-BUG-FIX
         23747: ALF-5696: Merged V3.4 to V3.3
            23585: Fixed ALF-5372 "JavaScript error on Groups management dialog with IE8 : document.getElementById is null"
         24132: Disable intermittent failing unit test
         24148: ALF-6007: Merged HEAD to V3.3
            23049: Fixed ALF-5099: Error when trying to go back in Create Web Content Wizard (only with certain XSDs)
   24266: Merged V3.3-BUG-FIX to V3.4
      23761: ALF-5358: Invalid JavaBean property 'blockedSenders' being accessed!
         - renamed List versions of setAllowedSenders and setBlockedSenders
      23769: Fixing typo in build.xml that means WebScriptTestSuite was not being run.
      23844: Fix for ALF-1084, ALF-5792 - handling of character encoding as specified in XML file header when missing from response headers. Fixes issue with non-ascii characters in RSS feeds in Share.
      23878: Build fix. InvitationTest.
         Minimally refactored a test case to disable email sending properly.
      23895: Backported fix from rev 23838 - QName refactor causes null-ptr-exception from Upload Content dialog in Explorer.
      23917: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX:
         23912: Fixes ALF-5878: WQS: Alfresco sessions ramping up rapidly
      23921: Fix for ALF-5826 - Infinite loop while closing "Manage Multilingual Content" dialog.
      23924: Merged V3.3-BUG-FIX-2010_10_04 to V3.3-BUG-FIX
         23416: ALF-5301: TinyMCE is replacing carriage return with white spaces.
      23979: Merged V3.3 to V3.3-BUG-FIX:
         23970: Fixes: ALF-5858 (Javascript error caused by files 404'ing) - URLRewriting bug introduced in r23545
      24001: Merged BRANCHES/DEV/BELARUS/V3.3-2010_11_10 to BRANCHES/DEV/V3.3-BUG-FIX:
         23971: ALF-1948: Deleting a freshly created file doesn't remove it from a user sandbox 
                 - also minor formatting & extra tests
      24007: Merged BRANCHES/DEV/BELARUS/V3.3-2010_11_10 to BRANCHES/DEV/V3.3-BUG-FIX:
         23971: ALF-1948: (commit mergeinfo !)
      24055: ALF-5897: Updated surf.xml to set correct User Factory
      24108: Fix CIFS memory pool leak, in IPC$ processing. ALF-483.
      24129: ALF-5458 Adding paging support to Groups REST APIs.
      24156: ALF-5663 - Deadlock during StatusTemplate lookup in AbstractWebScript (already present in V3.4)
      24181: Added catch block for access denied error in store file processing, returns a 451 error to the FTP client. Part of ALF-6020.
      24182: Convert open content for write errors to an access denied exception, fix for FTP NPE and will also be handled by CIFS protocol code. ALF-6020.
      24252: Fixed ALF-5677: Extremely long launch of the Alfresco server with connector V1.2
         - Avoid any ContentReader interaction (incl. exists checks) when 'lucene.maxAtomicTransformationTime=0'
         - Prevents slow XAM-based XSet operations from slowing reindexing
         - As a side-effect, text/plain content is now treated the same as transformable content when the transformation time is 0
      24255: Check URL support and read-only state in afterRollback cleanup of orphaned content URLs (ALF-5677)
      24256: Neatened code
      24257: Fixed integrity checking when properties have been removed from model
      24258: Helper DEBUG for diagnosing ALF-5677 and future XAM issues
      24260: Merged V3.3 to V3.3-BUG-FIX (RECORD ONLY)
         23707: Merged V3.3-BUG-FIX to V3.3
            23596: Merged HEAD to BRANCHES/DEV/V3.3-BUG-FIX:
               20636: ALF-3157 - Conflict between IMAP and Audit
               20638: ALF-3157 - Conflict between IMAP and Audit
                  - part II update the auditConfig.xml
         23946: Merged V3.3-BUG-FIX to V3.3
            23942: Fix for ALF-5783: Not possible to override the output path pattern anymore when a webform is edited for a specific website
      24261: Merged V3.3 to V3.3-BUG-FIX
         23650: Switch off transaction limiting for now, pending further investigation
         23706: Merged PATCHES/V3.3.3 to V3.3
            23704: ALF-5720: Merged V3.3-BUG-FIX to PATCHES/V3.3.3
               23609: Merged BRANCHES/DEV/BELARUS/HEAD_2010_10_06 to BRANCHES/DEV/V3.3-BUG-FIX:
                  23158: ALF-1838: Need to support relative url for WCM TinyMCE Filepicker.
                     Also fixes ALF-866 & ALF-5420
         23708: Merged DEV/TEMPORARY to V3.3
            22697: ALF-4809: The confirmation step to Revert action implementation. New dialog.
         23970: ALF-5858 (Javascript error caused by files 404'ing) - URLRewriting bug introduced in r23545
         23998: Add tomcat bundles
         24053: ALF-5897: Updated surf config to set correct user factory
         24061: Merged V3.2 to V3.3
            19170: Fixed ALF-730: MLText is not fully carried during cut-paste or copy-paste
               - Fetching of properties for copy now uses 'mlAwareNodeService'
         24130: Ensure mysql symlinks created
         24131: ALF-5930: Correct bogus configuration template for Quickr
      24262: Stress test code for ALF-5025: Support background processing of archiving
   24267: Reverting partial merge of build script changes
   24268: Removed svn:mergeinfo on root
   24270: Merged V3.3 to V3.4
      24269: Merge fallout: rename of ASPECT_MAILED to ASPECT_EMAILED
   24271: Merge fallout: fix compilation error (masked by a crashed Eclipse)
   24275: FTP command input buffer resizes on overflow (up to a maximum of 64K), allow long paths in commands. ALF-210.
   24281: Performance improvements relating to WebScripts, Surf, FreeMarker and Apache HTTP synchronization under heavy multi-threaded load.
   24282: Merged V3.3 to V3.4
      24279: Fix for ALF-6025 - increased cluster cache size for webScriptsRegisteryCache
   24284: Fix for ALF-5723: Sharepoint Protocol doesn't seem to work in 3.4.a and 3.4.b with NTLM passthru
   24285: Unit test fallout from merge.  Removed NPE-causing mailActionExecutor member
   24286: Reinstate ImapMessageTest (a required bug fix was incorrectly removed by merge 22725)
   24288: Fix for ALF-4282 Site Contributor can't create datalist until Site Manager creates new one.
     The first user who views the data lists page for a Share site kicks off the lazy creation of the necessary
     site container node. In fact it creates the container, sets its cm:description to "Data Lists" and saves
     that ScriptNode. See parse-args.lib.js circa line 144.
     However if that user is not a Site Manager then they do not have permissions to create the container and
     an exception is thrown which results in a disabled 'New List' button.
     In fact, the creation of the container node was already being run as system. But the Site.save() call was not and
     that was the call that was producing a permissions exception.
     In order to run the whole thing as system (which is not available in the JS layer), I have extracted the JavaScript
     logic into a new Java-layer method createAndSaveContainer(...) and JS now makes that one call.
   24289: Fixed misleading javadoc comment relating to ALF-4282
   24290: Merged BRANCHES/DEV/BELARUS/V3.4-2010_11_29 to BRANCHES/V3.4: 
      24238: ALF-5556 : Items disappear from document library after changing its name
   
   Also added new unit test to verify that site containers can not be renamed.
   24295: Fixes ALF-4290: Installer text errors
   24302: Fixes for dependencies for the SDK.
   24305: Added logging to JodConverterSharedInstance (Alfresco's JodC-facing class)
   Re-enabled the JodC-related test classes - these may break the build.
   Set logging in JodC to DEBUG
   24307: Removing a debug statement which is verbose and unhelpful at a high frequency.
   24310: Merged BRANCHES/V3.3 to BRANCHES/V3.4:
      24283: Fix for ALF-2232: "Collaborator actions in CIFS(Share) are incorrect"
   24311: Fix for ALF-2232: "Collaborator actions in CIFS(Share) are incorrect"
     - missed root dir and import
   24313: ALF-3044: Audit log is incorrect when trying to filed it as record
   
   24315: Merged BRANCHES/V3.3 to BRANCHES/V3.4:
      24314: If the repo is running in read only mode, skip the periodic Tag Scope sweep and update (ALF-6067)
   24317: Disabled the OOoJodC tests again as I should have some info to proceed while we get a good build on this plan.
   "You put your left leg in..."
   24319: Moved logging of soffice file permissions to before the attempt to start JodConverter.
   24321: 
   24323: Changing the use of File.createTempFile to TempFileProvider.createTempFile mostly in test code.
     None of these temporary files are needed for longer than a few seconds.
     By using our own TempFileProvider there will be a chance that our tempFileCleaner will delete temporary files.
     Derek pointed out that there are a lot of such temporary files in our build server's temp dir.
   24330: Data generation for perf. tests: Ensure content is written to file
   24333: Merged V3.4-2010_11_29 to V3.4
      24237: ALF-5829: Cannot upload files to Records Managemennt site using WebDav from Mac OS X.
             Return "403 Forbidden" status if WebDAVMethod.execute() fails with AccessDeniedException.
   24339: Fixed a bug where task properties were not being updated when task was transitioned.
   24340: Fixed a bug where task properties were not being updated when task was transitioned.
   24349: turn off debug logging
   24351: ALF-3584 Cleaning up SDK list of libs.   (I think there may be a limit on the size somewhere)
   24355: Tika update to better support encrypted PDFs (ALF-6040)
   24357: Turned off JodConverter hanging tests again.
   I won't turn these back on again now. Apologies for all the disruption.
   I have a basis on which to address the hanging issue on my own machine now.
   24359: Add code to probe intermittent test failure.
   24368: Patched build of JodConverter.
     This changes jodconverter's OfficeUtils.toUrl(File) method so that it uses Alfresco's mechanism for
     creating OpenOffice URIs.
   24371: Fix for ALF-5563: Sorting documents with multiple locales
   - d:text now uses the .no_locale field for sorting using the user's locale collation
   24372: Turning the jodconverter-related logging down from 'debug' to 'info' by default.
   24373: Merged V3.3 to V3.4 (Missed merge)
      21907: ALF-4401: Web services not working on Websphere 7 (ever?)
         - Added in Sun SAAJ and JAXP reference implementations to shared library in order to make CXF work
         - Removed old Sun SAAJ libraries as these are embedded into JDK 1.6
   24376: ALF-2761: RM adds rma:record to IMAP messages in non RM folders
   
   24378: When copying content, reset the auditable properties. 
   This makes the person doing the copy the creator/modifier, and resets the created/modified at times to now. Avoids the issue of being able to copy a node but then not edit it. Fixes ALF-5288
   24381: Fixed ALF-6002 "Share links and images break when saving html content"
   - Editor content was never persisted to hidden textarea after non "keyup" events, such as embedding links & images
   - Also added tinymce's src files when running alfresco in debug mode
   24383: Fix for ALF-5967 - reset the SpringMVC View Resolvers when the Surf Refresh Object Registry cmd is used.
   24385: Merged BRANCHES/V3.3 to BRANCHES/V3.4
      24384: Merged PATCHES/V3.3.4 to BRANCHES/V3.3
         24382: Fixed ALF-6087 "Wiki: all buttons are disabled in IE" by quoting "delete" (as it is a reserved js word)
   
   24386: Fix for ALF-1339: Share - Posts in discussions can be edited and deleted by any members
   24389: Merged V3.3 to V3.4
      24388: Fix ALF-6128: Upload/recall documents with apostrophe/accent via Alfresco Office plugin
   24395: Fix for ALF-6009: Workflow "View More Actions" link incorrect when first char of site URL is numeric
   24398: Merged DEV-TEMPORARY to V3.4
      24320: Fix ALF-4868: An error occurs, while adding content to space with "has-tag" rule
   24401: More code to probe intermittent IMAP test failure.
   24402: Fix for performance degredation related to ALF-3823.
   RSS feed processing in JavaScript relies on Rhino impl of regex - this is extreemly slow as Rhino regex is by far the slowest component of the library.
   Switched code to use the Java Regex libraries to improve performance and reduce memory usage.
   
   Time to process 4 small rss feeds while running in the profiler:
   Using Rhino regex: 6670ms (required ~3500MB of temp RAM)
   Using Java regex:  1550ms (required ~30MB of temp RAM)
   24404: Merge V3.3 to V3.4 (RECORD ONLY)
     24403 : Merge V3.4 to V3.3
         ALF-5539
   24415: Merged BRANCHES/V3.3 to BRANCHES/V3.4:
      24306: ALF-5987: AVM - AVMNodeDAOIbatis.getRootNodeByID does not seem to handle nulls properly
   24416: Merged BRANCHES/V3.3 to BRANCHES/V3.4: 
       24306: ALF-5987: AVM - AVMNodeDAOIbatis.getRootNodeByID does not seem to handle nulls properly (add logger)
   24420: Merge from V3.3-BUG-FIX to V3.4
     V3.3-BUG-FIX r.24419
       V3.3 r.24418 Fix for ALF-6075. Running out of /tmp space on the server is causing uploads to fail.
   24453: Fixed ALF-6116 "Incorrect behavior of sites filter" 
   - Made rest calls sequential rather than parallell
   24455: Merged BRANCHES/V3.3 to BRANCHES/V3.4:
      24454: AVMStoreDAOIbatis auto-unboxing NPE (see also ALF-5987)
   24456: Resolve ALF-5875 - RM Constraint cannot be used for custom models (via RecordsManagementAdminService)
   24462: Merge V3.3 to V3.4 (RECORD ONLY)
     24460 : Merge HEAD to V3.3
       22680 : ALF-4015 Benchmark broken
   24467: Remove unused labels as part of ALF-6092
   24470: Merged V3.3 to V3.4
      24469: Fix for ALF-6006 - reworking of Share site-index initialisation to use "lazy" dashboard filter.
              - ensures user dashboard is available without having to enter Share via the default index page.
   24473: ALF-6105 - Upgrade from 2.2 to 3.4.0.R1.86 fails with Custom attributes found - will require custom migration patch: [.href]
   24474: Possible fix for ALF-5969. JodConverter.
     I noticed that SuspendableThreadPoolExecutor.available (a non-volatile, non-synchonized accessed boolean)
     is being updated by multiple threads and there may be stale reads of this field by some threads.
     I apply this fix in hope more than expectation that it will fix the JodC problems we're seeing.
   24489: Fix MT startup (Failed to init namespaceRegistry)
   - see also ALF-6029
   24491: ALF-6058: Quickr module doesnot not work.
   
   Checkin comments:
   
   Doesn't broadcast ContextRefreshedEvent and ContextClosedEvents for subsystem context parent.
   Add corresponding unit test: SubsystemsTest.testALF6058().
   
   24494: Merged BRANCHES/V3.3 to BRANCHES/V3.4:
      24298: ALF-6043: AVM orphan reaper - handle concurrent node delete (WCM cluster)
   24499: ALF-5917 Added a property that allows switching off of email notifications for Nominated invitations.
   24500: Merge 3.3 to 3.4:
   24493: Fix for Mac OS X CIFS logon problem, change UID to start at one as zero has special meaning, plus other minor fixes. JLAN-112.
   24501: Merged (and fixed) DEV/BELARUS/V3.4-2010_12_14 to V3.4
   + fixed hard bean reference to injection
   + tested with index test running with continual back up
   24502: Merged (and fixed) DEV/BELARUS/V3.4-2010_12_14 to V3.4 (missed merge info)
   + fixed hard bean reference to injection
   + tested with index test running with continual back up
   24503: ALF-6113 - Don't include non-standard {music} namespace properties when extracting metadata from MP3s. (Don't merge to HEAD)
   To be fixed fully with ALF-6170 via defining an audio content model
   24504: ALF-4373: It's impossible to upload record if any record was previously frozen
   
   24506: Fixes ALF-6181: Add default site notification e-mail settings to global properties
   24511: ALF-5769 - Failed to signal transition from workflow "Expired content in 'Test'" task when click "Task Done"
   24512: Fix for ALF-6100 - Incorrect behaviour of preview content in Share - Websphere specific.
   24522: Merged V3.3 to V3.4
      24521: Fix for ALF-5065 - Share - Missing notify_user_email template
   24523: Fix for ALF-6171: Access Denied error in Alfresco Exporer when in Read-only mode (Websphere)
   24534: Merged V3.3 to V3.4
      24447: Support for ALF-5533 and ALF-5023: Make ContentStore.delete behaviour consistent w.r.t. true/false return value
      24472: Code for ALF-5023: Allow the retention schedule to be extended for XAM nodes
      24515: Fixed ALF-5023: Allow the retention schedule to be extended for XAM nodes
      24533: Minor XAM changes that mainly affect the QA tasks
   24541: ALF-6029 - MT: cannot "Show Folders" in Afresco Share
   24550: Fix for ALF-6088: Categories are unavailable at the Server B after deleting category at the Server A
   - category service handles invalid node refs correctly
   24551: Merge V3.3 to V3.4 (RECORD ONLY)
      24547: Fixed ALF-6188 "Object finder does not allow select users in the singleSelect mode"
      24549: Fixed ALF-6188 "Object finder does not allow select users in the singleSelect mode" part 2 (typo)
   
   24558: Merge V3.3 to V3.4
     24557 : Merge DEV to V3.3
        24527 : ALF-4724 ftp server and list.
   24559: Removed svn:mergeinfo on root
   24561: 
   24564: Fix for ALF-3727: Custom permissions aren't visible in Explorer UI
   - the default Alfresco permission model (or the one associated with the permission model dao is loaded first
   - all other models will be loaded in any order unless specific bean dependencies are added (if ordering is important you need to add it via Spring) 
   - there is no collision detection :-)
   24582: Merged V3.3 to V3.4
      24578: Fix for ALF-4729 and ALF-6048 - Unable to access Share [or Explorer] through NTLM SSO on Safari
   24583: Oracle build fix: ALF-4223: Oracle: testTaskInstanceGet in WorkflowRestAPiTest is only failing on Oracle build plan
   - work around for oracle null === ""
   24588: Committing installer updates for DDraper, fixes: ALF-6096 & ALF-6019
   24602: Build fix for RM permission model loading - collateral damage for R 24564
   24606: Merged BRANCHES/DEV to BRANCHES/V3.4:
      24563: ALF-6063: Alfresco 3.4.0.RC1.86 fails to connect to virtualization server
   24607: Merged V3.3 to V3.4
       24605: Fix for ALF-5552: Many REST API scripts are not resilient to stale Lucene indexes
   24608: ALF-5555: It is impossible to edit review date from record's details page
   
   Implementation of changable "Edit Review Date" date for properties view.
   The structure of dod5015 properties was undefined. An asynchronous call to web script has been added for preservation of the entered date.
   
   24615: Fixes: ALF-6254 - Typo in Dashlets properties file
   24620: Removed RC1 from label
   24623: Installer updates to use new binary versions for SWFTools (0.9.1) and Apache Tomcat (6.0.29)
   24624: Add line break.
   24627: Fix execute permissions for OOo
   24630: Tweak AVM test
   24634: Update root pseudo folder timestamps when new stores are added so NFS clients see the update. ALF-5197.
   24637: RM Caveats - split service/component
   - related to rmEntryVoter (ALF-5875 & ALF-6231)
   24661: ALF-6303: fix typo in upg script


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@26789 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2011-04-11 14:24:38 +00:00

7854 lines
342 KiB
Java

/*
* Copyright (C) 2009-2010 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.transfer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import javax.transaction.UserTransaction;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockType;
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.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.transfer.TransferCallback;
import org.alfresco.service.cmr.transfer.TransferDefinition;
import org.alfresco.service.cmr.transfer.TransferEvent;
import org.alfresco.service.cmr.transfer.TransferEventBegin;
import org.alfresco.service.cmr.transfer.TransferEventReport;
import org.alfresco.service.cmr.transfer.TransferException;
import org.alfresco.service.cmr.transfer.TransferReceiver;
import org.alfresco.service.cmr.transfer.TransferService;
import org.alfresco.service.cmr.transfer.TransferTarget;
import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.BaseAlfrescoSpringTest;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
import org.alfresco.util.PropertyMap;
import org.alfresco.util.TempFileProvider;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.util.ResourceUtils;
/**
* Unit test for TransferServiceImpl
*
* Contains some integration tests for the transfer service
*
* @author Mark Rogers
*/
@SuppressWarnings("deprecation")
public class TransferServiceImplTest extends BaseAlfrescoSpringTest
{
private TransferService transferService;
private ContentService contentService;
private TransferServiceImpl2 transferServiceImpl;
private SearchService searchService;
private TransactionService transactionService;
private TransferReceiver receiver;
private TransferManifestNodeFactory transferManifestNodeFactory;
private PermissionService permissionService;
private LockService lockService;
private PersonService personService;
private DescriptorService descriptorService;
private CopyService copyService;
String COMPANY_HOME_XPATH_QUERY = "/{http://www.alfresco.org/model/application/1.0}company_home";
String GUEST_HOME_XPATH_QUERY = "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/application/1.0}guest_home";
String REPO_ID_A = "RepoIdA";
String REPO_ID_B;
String REPO_ID_C = "RepoIdC";
@Override
public void runBare() throws Throwable
{
preventTransaction();
super.runBare();
}
/**
* Called during the transaction setup
*/
protected void onSetUp() throws Exception
{
// Catch transactions left dangling by inadequate transaction handling during test failures
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
fail("Dangling transaction at start of test.");
}
super.onSetUp();
// Get the required services
this.transferService = (TransferService)this.applicationContext.getBean("TransferService");
this.contentService = (ContentService)this.applicationContext.getBean("ContentService");
this.transferServiceImpl = (TransferServiceImpl2)this.applicationContext.getBean("transferService2");
this.searchService = (SearchService)this.applicationContext.getBean("SearchService");
this.transactionService = (TransactionService)this.applicationContext.getBean("TransactionService");
this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
this.contentService = (ContentService) this.applicationContext.getBean("contentService");
this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
this.actionService = (ActionService)this.applicationContext.getBean("actionService");
this.permissionService = (PermissionService)this.applicationContext.getBean("permissionService");
this.receiver = (TransferReceiver)this.applicationContext.getBean("transferReceiver");
this.transferManifestNodeFactory = (TransferManifestNodeFactory)this.applicationContext.getBean("transferManifestNodeFactory");
this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent");
this.lockService = (LockService) this.applicationContext.getBean("lockService");
this.personService = (PersonService)this.applicationContext.getBean("PersonService");
this.descriptorService = (DescriptorService)this.applicationContext.getBean("DescriptorService");
this.copyService = (CopyService)this.applicationContext.getBean("CopyService");
REPO_ID_B = descriptorService.getCurrentRepositoryDescriptor().getId();
authenticationComponent.setSystemUserAsCurrentUser();
setTransactionDefinition(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));
assertNotNull("receiver is null", this.receiver);
}
/**
* Test create target.
*
* @throws Exception
*/
public void testCreateTarget() throws Exception
{
String name = "name";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
startNewTransaction();
try
{
/**
* Now go ahead and create our first transfer target
*/
TransferTarget ret = transferService.createAndSaveTransferTarget(name, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
assertNotNull("return value is null", ret);
assertNotNull("node ref is null", ret.getNodeRef());
//titled aspect
assertEquals("name not equal", ret.getName(), name);
assertEquals("title not equal", ret.getTitle(), title);
assertEquals("description not equal", ret.getDescription(), description);
// endpoint
assertEquals("endpointProtocol not equal", ret.getEndpointProtocol(), endpointProtocol);
assertEquals("endpointHost not equal", ret.getEndpointHost(), endpointHost);
assertEquals("endpointPort not equal", ret.getEndpointPort(), endpointPort);
assertEquals("endpointPath not equal", ret.getEndpointPath(), endpointPath);
// authentication
assertEquals("username not equal", ret.getUsername(), username);
char[] password2 = ret.getPassword();
assertEquals(password.length, password2.length);
for(int i = 0; i < password.length; i++)
{
if(password[i] != password2[i])
{
fail("password not equal:" + new String(password) + new String(password2));
}
}
/**
* Negative test - try to create a transfer target with a name that's already used.
*/
transferService.createAndSaveTransferTarget(name, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
fail("duplicate name not detected");
}
catch (TransferException e)
{
// expect to go here
}
finally
{
endTransaction();
}
}
/**
* Test create target via in memory data object.
*
* @throws Exception
*/
public void testCreateTargetSyntax2() throws Exception
{
String name = "nameSyntax2";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
startNewTransaction();
try
{
/**
* Now go ahead and create our first transfer target
*/
TransferTarget newValue = transferService.createTransferTarget(name);
newValue.setDescription(description);
newValue.setEndpointHost(endpointHost);
newValue.setEndpointPort(endpointPort);
newValue.setEndpointPath(endpointPath);
newValue.setEndpointProtocol(endpointProtocol);
newValue.setPassword(password);
newValue.setTitle(title);
newValue.setUsername(username);
TransferTarget ret = transferService.saveTransferTarget(newValue);
assertNotNull("return value is null", ret);
assertNotNull("node ref is null", ret.getNodeRef());
//titled aspect
assertEquals("name not equal", ret.getName(), name);
assertEquals("title not equal", ret.getTitle(), title);
assertEquals("description not equal", ret.getDescription(), description);
// endpoint
assertEquals("endpointProtocol not equal", ret.getEndpointProtocol(), endpointProtocol);
assertEquals("endpointHost not equal", ret.getEndpointHost(), endpointHost);
assertEquals("endpointPort not equal", ret.getEndpointPort(), endpointPort);
assertEquals("endpointPath not equal", ret.getEndpointPath(), endpointPath);
// authentication
assertEquals("username not equal", ret.getUsername(), username);
char[] password2 = ret.getPassword();
assertEquals(password.length, password2.length);
for(int i = 0; i < password.length; i++)
{
if(password[i] != password2[i])
{
fail("password not equal:" + new String(password) + new String(password2));
}
}
/**
* Negative test - try to create a transfer target with a name that's already used.
*/
transferService.createAndSaveTransferTarget(name, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
fail("duplicate name not detected");
}
catch (TransferException e)
{
// expect to go here
}
finally
{
endTransaction();
}
}
/**
* Test of Get TransferTargets
*
* @throws Exception
*/
public void testGetTransferTargets() throws Exception
{
String nameA = "nameA";
String nameB = "nameB";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
startNewTransaction();
try
{
/**
* Now go ahead and create our first transfer target
*/
TransferTarget targetA = transferService.createAndSaveTransferTarget(nameA, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
TransferTarget targetB = transferService.createAndSaveTransferTarget(nameB, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
Set<TransferTarget> targets = transferService.getTransferTargets();
assertTrue("targets is empty", targets.size() > 0);
assertTrue("didn't find target A", targets.contains(targetA) );
assertTrue("didn't find target B", targets.contains(targetB));
for(TransferTarget target : targets)
{
System.out.println("found target: " + target.getName());
}
}
finally
{
endTransaction();
}
}
/**
* Test of Get All Transfer Targets By Group
*/
//TODO Test not complete - can't yet put targets in different groups
public void testGetAllTransferTargetsByGroup() throws Exception
{
String getMe = "getMe";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
startNewTransaction();
try
{
/**
* Now go ahead and create our first transfer target
*/
transferService.createAndSaveTransferTarget(getMe, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
Set<TransferTarget> targets = transferService.getTransferTargets("Default Group");
assertTrue("targets is empty", targets.size() > 0);
/**
* Negative test - group does not exist
*/
targets = transferService.getTransferTargets("Rubbish");
assertTrue("targets is empty", targets.size() > 0);
fail("group does not exist");
}
catch (TransferException te)
{
// expect to go here
}
finally
{
endTransaction();
}
}
/**
*
*/
public void testUpdateTransferTarget() throws Exception
{
startNewTransaction();
try
{
String updateMe = "updateMe";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
/**
* Create our transfer target
*/
TransferTarget target = transferService.createAndSaveTransferTarget(updateMe, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
/*
* Now update with exactly the same values.
*/
TransferTarget update1 = transferService.saveTransferTarget(target);
assertNotNull("return value is null", update1);
assertNotNull("node ref is null", update1.getNodeRef());
//titled aspect
assertEquals("name not equal", update1.getName(), updateMe);
assertEquals("title not equal", update1.getTitle(), title);
assertEquals("description not equal", update1.getDescription(), description);
// endpoint
assertEquals("endpointProtocol not equal", update1.getEndpointProtocol(), endpointProtocol);
assertEquals("endpointHost not equal", update1.getEndpointHost(), endpointHost);
assertEquals("endpointPort not equal", update1.getEndpointPort(), endpointPort);
assertEquals("endpointPath not equal", update1.getEndpointPath(), endpointPath);
// authentication
assertEquals("username not equal", update1.getUsername(), username);
char[] pass = update1.getPassword();
assertEquals(password.length, pass.length);
for(int i = 0; i < password.length; i++)
{
if(password[i] != pass[i])
{
fail("password not equal:" + new String(password) + new String(pass));
}
}
/**
* Now update with different values
*/
String title2 = "Two";
String description2 = "descriptionTwo";
String endpointProtocol2 = "https";
String endpointHost2 = "1.0.0.127";
int endpointPort2 = 4040;
String endpointPath2 = "custard";
String username2 = "admin_two";
char[] password2 = "two".toCharArray();
target.setDescription(description2);
target.setTitle(title2);
target.setEndpointHost(endpointHost2);
target.setEndpointPath(endpointPath2);
target.setEndpointPort(endpointPort2);
target.setEndpointProtocol(endpointProtocol2);
target.setPassword(password2);
target.setUsername(username2);
TransferTarget update2 = transferService.saveTransferTarget(target);
assertNotNull("return value is null", update2);
assertNotNull("node ref is null", update2.getNodeRef());
//titled aspect
assertEquals("name not equal", update2.getName(), updateMe);
assertEquals("title not equal", update2.getTitle(), title2);
assertEquals("description not equal", update2.getDescription(), description2);
// endpoint
assertEquals("endpointProtocol not equal", update2.getEndpointProtocol(), endpointProtocol2);
assertEquals("endpointHost not equal", update2.getEndpointHost(), endpointHost2);
assertEquals("endpointPort not equal", update2.getEndpointPort(), endpointPort2);
assertEquals("endpointPath not equal", update2.getEndpointPath(), endpointPath2);
// authentication
assertEquals("username not equal", update2.getUsername(), username2);
pass = update2.getPassword();
assertEquals(password2.length, pass.length);
for(int i = 0; i < pass.length; i++)
{
if(pass[i] != password2[i])
{
fail("password not equal:" + new String(pass) + new String(password2));
}
}
}
finally
{
endTransaction();
}
}
/**
*
*/
public void testDeleteTransferTarget() throws Exception
{
startNewTransaction();
try
{
String deleteMe = "deleteMe";
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
/**
* Now go ahead and create our first transfer target
*/
transferService.createAndSaveTransferTarget(deleteMe, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
transferService.deleteTransferTarget(deleteMe);
/**
* Negative test - try to delete the transfer target we deleted above.
*/
try
{
transferService.deleteTransferTarget(deleteMe);
fail("duplicate name not detected");
}
catch (TransferException e)
{
// expect to go here
}
/**
* Negative test - try to delete a transfer target that has never existed
*/
try
{
transferService.deleteTransferTarget("rubbish");
fail("rubbish deleted");
}
catch (TransferException e)
{
// expect to go here
}
}
finally
{
endTransaction();
}
}
public void testEnableTransferTarget() throws Exception
{
startNewTransaction();
try
{
String targetName = "enableMe";
/**
* Now go ahead and create our first transfer target
*/
TransferTarget enableMe = createTransferTarget(targetName);
try
{
/**
* Check a new target is enabled
*/
TransferTarget target = transferService.getTransferTarget(targetName);
assertTrue("new target is not enabled", enableMe.isEnabled());
/**
* Diasble the target
*/
transferService.enableTransferTarget(targetName, false);
target = transferService.getTransferTarget(targetName);
assertFalse("target is not disabled", target.isEnabled());
/**
* Now re-enable the target
*/
transferService.enableTransferTarget(targetName, true);
target = transferService.getTransferTarget(targetName);
assertTrue("re-enabled target is not enabled", target.isEnabled());
}
finally
{
transferService.deleteTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
}
/**
* Test the transfer method by sending one node (CRUD).
*
* Step 1: Create a new node (No content)
* transfer
*
* Step 2: Update Node title property
* transfer
*
* Step 3: Update Content property (add content)
* transfer
*
* Step 4: Transfer again
* transfer (Should transfer but not request the content item)
*
* Step 5: Update Content property (update content)
*
* Step 6: Delete the node
*
* Step 7: Negative test : transfer no nodes
* transfer (should throw exception)
*
* Step 8: Negative test : transfer to a disabled transfer target
* transfer (should throw exception)
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testTransferOneNode() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello World";
String CONTENT_UPDATE_STRING = "Foo Bar";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Fake Repository Id
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferOneNode";
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, name);
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
transferService.enableTransferTarget(targetName, true);
}
finally
{
endTransaction();
}
logger.debug("First transfer - create new node (no content yet)");
startNewTransaction();
try
{
/**
* Step 1: Transfer our node which has no content
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check the modified time of the destination node is the same as the source node.
Date destModifiedDate = (Date)nodeService.getProperty(destNodeRef, ContentModel.PROP_MODIFIED);
Date srcModifiedDate = (Date)nodeService.getProperty(contentNodeRef, ContentModel.PROP_MODIFIED);
logger.debug("srcModifiedDate : " + srcModifiedDate + " destModifiedDate : " + destModifiedDate);
assertTrue("dest modified date is not correct", destModifiedDate.compareTo(srcModifiedDate)== 0);
Date destCreatedDate = (Date)nodeService.getProperty(destNodeRef, ContentModel.PROP_CREATED);
Date srcCreatedDate = (Date)nodeService.getProperty(contentNodeRef, ContentModel.PROP_CREATED);
logger.debug("srcCreatedDate : " + srcCreatedDate + " destCreatedDate : " + destCreatedDate);
assertTrue("dest created date is not correct", destCreatedDate.compareTo(srcCreatedDate)== 0);
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
// Now set up the next test which is to change the title
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE_UPDATED);
}
finally
{
endTransaction();
}
logger.debug("Second transfer - update title property (no content yet)");
startNewTransaction();
try
{
/**
* Step 2:
* Transfer our node again - so this is an update of the title property
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE_UPDATED);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check the modified time of the destination node is the same as the source node.
Date destModifiedDate = (Date)nodeService.getProperty(destNodeRef, ContentModel.PROP_MODIFIED);
Date srcModifiedDate = (Date)nodeService.getProperty(contentNodeRef, ContentModel.PROP_MODIFIED);
logger.debug("srcModifiedDate : " + srcModifiedDate + " destModifiedDate : " + destModifiedDate);
assertTrue("after update, modified date is not correct", destModifiedDate.compareTo(srcModifiedDate) == 0);
Date destCreatedDate = (Date)nodeService.getProperty(destNodeRef, ContentModel.PROP_CREATED);
Date srcCreatedDate = (Date)nodeService.getProperty(contentNodeRef, ContentModel.PROP_CREATED);
logger.debug("srcCreatedDate : " + srcCreatedDate + " destCreatedDate : " + destCreatedDate);
assertTrue("after update, created date is not correct", destCreatedDate.compareTo(srcCreatedDate)== 0);
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 3 - update to add content
*/
startNewTransaction();
try
{
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
logger.debug("Transfer again - this is an update to add new content");
startNewTransaction();
try
{
/**
* Step 3:
* Transfer our node again - so this is an update
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(destNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("reader is null", reader);
String contentStr = reader.getContentString();
assertEquals("Content is wrong", contentStr, CONTENT_STRING);
}
finally
{
endTransaction();
}
/**
* Step 4:
* Now transfer nothing - content items do not need to be transferred since its already on
* the destination.
*/
logger.debug("Transfer again - with no new content");
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node still exists and in particular that the old content is still there
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE_UPDATED);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
ContentReader reader = contentService.getReader(destNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("reader is null", reader);
String contentStr = reader.getContentString();
assertEquals("Content is wrong", contentStr, CONTENT_STRING);
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 5 - update content through transfer
*/
startNewTransaction();
try
{
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_UPDATE_STRING);
}
finally
{
endTransaction();
}
logger.debug("Transfer again - this is an update to add new content");
startNewTransaction();
try
{
/**
* Step 3:
* Transfer our node again - so this is an update
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(destNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("reader is null", reader);
String contentStr = reader.getContentString();
assertEquals("Content is wrong", CONTENT_UPDATE_STRING, contentStr);
}
finally
{
endTransaction();
}
/**
* Step 6
* Delete the node through transfer of the archive node
*/
logger.debug("Transfer again - to delete a node through transferring an archive node");
startNewTransaction();
try
{
nodeService.deleteNode(contentNodeRef);
}
finally
{
endTransaction();
}
NodeRef deletedContentNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, contentNodeRef.getId());
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(deletedContentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertFalse("dest node still exists", nodeService.exists(destNodeRef));
}
finally
{
endTransaction();
}
/**
* Step 7
* Negative test transfer nothing
*/
logger.debug("Transfer again - with no content - should throw exception");
try
{
TransferDefinition definition = new TransferDefinition();
transferService.transfer(targetName, definition);
fail("exception not thrown");
}
catch(TransferException te)
{
// expect to go here
}
/**
* Step 7: Negative test : transfer to a disabled transfer target
* transfer (should throw exception)
*/
logger.debug("Transfer again - with no content - should throw exception");
try
{
transferService.enableTransferTarget(targetName, false);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(deletedContentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
fail("target not enabled exception not thrown");
}
catch(TransferException te)
{
// expect to go here
assertTrue("check contents of exception message", te.getCause().getMessage().contains("enabled"));
}
}
/**
* Test the transfer method w.r.t. moving a node.
*
* Step 1.
* Move by changing the parent's node ref.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testMoveNode() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Fake Repository Id
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferMoveNode";
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef parentNodeRef;
NodeRef destNodeRef;
NodeRef moveToNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef newParent = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
parentNodeRef = newParent.getChildRef();
nodeService.setProperty(parentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(parentNodeRef, ContentModel.PROP_NAME, name);
ChildAssociationRef child = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("TransferOneNode"), ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, "TransferOneNode");
ChildAssociationRef moveTo = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("moveTo"), ContentModel.TYPE_FOLDER);
moveToNodeRef = moveTo.getChildRef();
nodeService.setProperty(moveToNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(moveToNodeRef, ContentModel.PROP_NAME, "moveTo");
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
transferService.enableTransferTarget(targetName, true);
}
finally
{
endTransaction();
}
logger.debug("First transfer - create new node (no content yet)");
startNewTransaction();
try
{
/**
* Step 0: Transfer our node which has no content
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(parentNodeRef);
nodes.add(contentNodeRef);
nodes.add(moveToNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
NodeRef destParentNodeRef = testNodeFactory.getMappedNodeRef(parentNodeRef);
ChildAssociationRef destParent = nodeService.getPrimaryParent(destNodeRef);
assertEquals("parent node ref not correct prior to test", destParentNodeRef, destParent.getParentRef());
}
finally
{
endTransaction();
}
/**
* Step 1: Move a node through transfer
* Move the destination node
* transfer (Should transfer the destination node back)
*/
logger.debug("Transfer again with moved node");
startNewTransaction();
try
{
// Move the node up one level on the destination.
nodeService.moveNode(contentNodeRef, moveToNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("testOneNode"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
NodeRef destParentNodeRef = testNodeFactory.getMappedNodeRef(moveToNodeRef);
ChildAssociationRef destParent = nodeService.getPrimaryParent(destNodeRef);
assertEquals("node not moved", destParentNodeRef, destParent.getParentRef());
}
finally
{
endTransaction();
}
} // test move node
/**
* Test the transfer method by sending a graph of nodes.
*
* This is a unit test so it does some shenanigans to send to he same instance of alfresco.
*/
public void testManyNodes() throws Exception
{
setDefaultRollback(false);
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
final String CONTENT_TITLE = "ContentTitle";
final String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
final String CONTENT_NAME = "Demo Node 1";
final Locale CONTENT_LOCALE = Locale.GERMAN;
final String CONTENT_STRING = "The quick brown fox";
final Set<NodeRef>nodes = new HashSet<NodeRef>();
final String targetName = "testManyNodes";
class TestContext
{
TransferTarget transferMe;
NodeRef nodeA = null;
NodeRef nodeB = null;
NodeRef nodeAA = null;
NodeRef nodeAB = null;
NodeRef nodeABA = null;
NodeRef nodeABB = null;
NodeRef nodeABC = null;
};
/**
* Unit test kludge to transfer from guest home to company home
*/
final UnitTestTransferManifestNodeFactory testNodeFactory = unitTestKludgeToTransferGuestHomeToCompanyHome();
TransferTarget transferMe;
RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
{
@Override
public TestContext execute() throws Throwable
{
TestContext ctx = new TestContext();
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String guid = GUID.generate();
/**
* Create a tree
* ManyNodesRoot
* AC (Content Node)
* A (Folder)
* --AA
* --AB (Folder)
* ----ABA (Folder)
* -------- 100+ nodes
* ----ABB
* ----ABC
* B
*/
ChildAssociationRef child;
child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(guid), ContentModel.TYPE_FOLDER);
NodeRef testRootNode = child.getChildRef();
nodeService.setProperty(testRootNode , ContentModel.PROP_TITLE, guid);
nodeService.setProperty(testRootNode , ContentModel.PROP_NAME, guid);
nodes.add(testRootNode);
child = nodeService.createNode(testRootNode, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeAC"), ContentModel.TYPE_CONTENT);
NodeRef nodeAC = child.getChildRef();
nodeService.setProperty(nodeAC , ContentModel.PROP_TITLE, CONTENT_TITLE + "AC");
nodeService.setProperty(nodeAC , ContentModel.PROP_NAME, "DemoNodeAC");
{
ContentWriter writer = contentService.getWriter(nodeAC , ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodes.add(nodeAC);
}
child = nodeService.createNode(testRootNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeA"), ContentModel.TYPE_FOLDER);
ctx.nodeA = child.getChildRef();
nodeService.setProperty(ctx.nodeA , ContentModel.PROP_TITLE, "TestNodeA");
nodeService.setProperty(ctx.nodeA , ContentModel.PROP_NAME, "TestNodeA");
nodes.add(ctx.nodeA);
child = nodeService.createNode(testRootNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeB"), ContentModel.TYPE_FOLDER);
ctx.nodeB = child.getChildRef();
nodeService.setProperty(ctx.nodeB , ContentModel.PROP_TITLE, "TestNodeB");
nodeService.setProperty(ctx.nodeB , ContentModel.PROP_NAME, "TestNodeB");
nodes.add(ctx.nodeB);
child = nodeService.createNode(ctx.nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeAA"), ContentModel.TYPE_FOLDER);
ctx.nodeAA = child.getChildRef();
nodeService.setProperty(ctx.nodeAA , ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeAA , ContentModel.PROP_NAME, "DemoNodeAA" );
nodes.add(ctx.nodeAA);
child = nodeService.createNode(ctx.nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeAB"), ContentModel.TYPE_FOLDER);
ctx.nodeAB = child.getChildRef();
nodeService.setProperty(ctx.nodeAB , ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeAB , ContentModel.PROP_NAME, "DemoNodeAB" );
nodes.add(ctx.nodeAB);
child = nodeService.createNode(ctx.nodeAB, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeABA"), ContentModel.TYPE_FOLDER);
ctx.nodeABA = child.getChildRef();
nodeService.setProperty(ctx.nodeABA , ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeABA , ContentModel.PROP_NAME, "DemoNodeABA" );
nodes.add(ctx.nodeABA);
child = nodeService.createNode(ctx.nodeAB, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeABB"), ContentModel.TYPE_FOLDER);
ctx.nodeABB = child.getChildRef();
nodeService.setProperty(ctx.nodeABB , ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeABB , ContentModel.PROP_NAME, "DemoNodeABB" );
nodes.add(ctx.nodeABB);
child = nodeService.createNode(ctx.nodeAB, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeABC"), ContentModel.TYPE_FOLDER);
ctx.nodeABC = child.getChildRef();
nodeService.setProperty(ctx.nodeABC , ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeABC , ContentModel.PROP_NAME, "DemoNodeABC" );
nodes.add(ctx.nodeABC);
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
ctx.transferMe = createTransferTarget(targetName);
}
else
{
ctx.transferMe = transferService.getTransferTarget(targetName);
}
return ctx;
}
};
final TestContext testContext = tran.doInTransaction(setupCB);
RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
return null;
}
};
tran.doInTransaction(transferCB);
RetryingTransactionCallback<Void> checkTransferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
NodeRef destNodeA;
NodeRef destNodeB;
NodeRef destNodeAA;
NodeRef destNodeAB;
NodeRef destNodeABA;
NodeRef destNodeABB;
NodeRef destNodeABC;
// Now validate that the target node exists and has similar properties to the source
destNodeA = testNodeFactory.getMappedNodeRef(testContext.nodeA);
assertFalse("unit test stuffed up - comparing with self", destNodeA.equals(testContext.transferMe.getNodeRef()));
assertTrue("dest node ref A does not exist", nodeService.exists(destNodeA));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeA, ContentModel.PROP_TITLE), "TestNodeA");
assertEquals("type is wrong", nodeService.getType(testContext.nodeA), nodeService.getType(destNodeA));
destNodeB = testNodeFactory.getMappedNodeRef(testContext.nodeB);
assertTrue("dest node B does not exist", nodeService.exists(destNodeB));
destNodeAA = testNodeFactory.getMappedNodeRef(testContext.nodeAA);
assertTrue("dest node AA ref does not exist", nodeService.exists(destNodeAA));
destNodeAB = testNodeFactory.getMappedNodeRef(testContext.nodeAB);
assertTrue("dest node AB ref does not exist", nodeService.exists(destNodeAB));
destNodeABA = testNodeFactory.getMappedNodeRef(testContext.nodeABA);
assertTrue("dest node ABA ref does not exist", nodeService.exists(destNodeABA));
destNodeABB = testNodeFactory.getMappedNodeRef(testContext.nodeABB);
assertTrue("dest node ABB ref does not exist", nodeService.exists(destNodeABB));
destNodeABC = testNodeFactory.getMappedNodeRef(testContext.nodeABC);
assertTrue("dest node ABC ref does not exist", nodeService.exists(destNodeABC));
return null;
}
};
tran.doInTransaction(checkTransferCB);
/**
* Update a single node (NodeAB) from the middle of the tree
*/
RetryingTransactionCallback<Void> updateSingleNodeCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
nodeService.setProperty(testContext.nodeAB , ContentModel.PROP_TITLE, CONTENT_TITLE_UPDATED);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>toUpdate = new HashSet<NodeRef>();
toUpdate.add(testContext.nodeAB);
definition.setNodes(toUpdate);
transferService.transfer(targetName, definition);
return null;
}
};
tran.doInTransaction(updateSingleNodeCB);
/**
* Now generate a large number of nodes
*/
RetryingTransactionCallback<Void> generateLotsOfNodesCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
for(int i = 0; i < 100; i++)
{
ChildAssociationRef child = nodeService.createNode(testContext.nodeABA, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate() + i), ContentModel.TYPE_CONTENT);
NodeRef nodeX = child.getChildRef();
nodeService.setProperty(nodeX , ContentModel.PROP_TITLE, CONTENT_TITLE + i);
nodeService.setProperty(nodeX , ContentModel.PROP_NAME, CONTENT_NAME +i);
nodes.add(nodeX);
ContentWriter writer = contentService.getWriter(nodeX, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING + i);
}
return null;
}
};
tran.doInTransaction(generateLotsOfNodesCB);
/**
* Transfer our transfer target nodes
*/
tran.doInTransaction(transferCB);
} // end many nodes
/**
* Test the path based update.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testPathBasedUpdate() throws Exception
{
setDefaultRollback(false);
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
String CONTENT_NAME = GUID.generate();
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = GUID.generate();
NodeRef contentNodeRef;
NodeRef newContentNodeRef;
QName TEST_QNAME = QName.createQName(CONTENT_NAME);
NodeRef guestHome;
ChildAssociationRef child;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will transfer. Its path is what is important
*/
child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, TEST_QNAME, ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, CONTENT_NAME);
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
createTransferTarget(targetName);
}
else
{
transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(contentNodeRef));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
/**
* Now delete the content node and re-create another one with the old path
*/
nodeService.deleteNode(contentNodeRef);
child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, TEST_QNAME, ContentModel.TYPE_CONTENT);
newContentNodeRef = child.getChildRef();
nodeService.setProperty(newContentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE_UPDATED);
/**
* Transfer our node which is a new node (so will not exist on the back end) with a path that already has a node.
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(newContentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef oldDestNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
NodeRef newDestNodeRef = testNodeFactory.getMappedNodeRef(newContentNodeRef);
// Now validate that the target node does not exist - it should have
// been updated by path.
assertFalse("unit test stuffed up - comparing with self", oldDestNodeRef.equals(newDestNodeRef));
assertFalse("new dest node ref exists", nodeService.exists(newDestNodeRef));
assertTrue("old dest node does not exists", nodeService.exists(oldDestNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(oldDestNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE_UPDATED);
// assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
}
finally
{
endTransaction();
}
} // Path based update
/**
* Test the transfer method when it is running async.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testAsyncCallback() throws Exception
{
final int MAX_SLEEPS = 5;
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
/**
* Unit test kludge to transfer from guest home to company home
*/
final UnitTestTransferManifestNodeFactory testNodeFactory = unitTestKludgeToTransferGuestHomeToCompanyHome();
/**
* This needs to be committed before we can call transfer asycnc.
*/
final String CONTENT_TITLE = "ContentTitle";
final String CONTENT_NAME_A = "Demo Node A";
final String CONTENT_NAME_B = "Demo Node B";
final Locale CONTENT_LOCALE = Locale.GERMAN;
final String CONTENT_STRING = "Hello";
final String targetName = "testAsyncCallback";
class TestContext
{
TransferTarget transferMe;
NodeRef nodeRefA = null;
NodeRef nodeRefB = null;
};
RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
{
@Override
public TestContext execute() throws Throwable
{
TestContext ctx = new TestContext();
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
final NodeRef guestHome = guestHomeResult.getNodeRef(0);
ctx.nodeRefA = nodeService.getChildByName(guestHome, ContentModel.ASSOC_CONTAINS, CONTENT_NAME_A);
if(ctx.nodeRefA == null)
{
/**
* Create a test node that we will read and write
*/
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
ctx.nodeRefA = child.getChildRef();
nodeService.setProperty(ctx.nodeRefA, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeRefA, ContentModel.PROP_NAME, CONTENT_NAME_A);
ContentWriter writer = contentService.getWriter(ctx.nodeRefA, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
ctx.nodeRefB = nodeService.getChildByName(guestHome, ContentModel.ASSOC_CONTAINS, CONTENT_NAME_B);
if(ctx.nodeRefB == null)
{
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
ctx.nodeRefB = child.getChildRef();
nodeService.setProperty(ctx.nodeRefB, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.nodeRefB, ContentModel.PROP_NAME, CONTENT_NAME_B);
ContentWriter writer = contentService.getWriter(ctx.nodeRefB, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
createTransferTarget(targetName);
}
else
{
transferService.getTransferTarget(targetName);
}
return ctx;
}
};
final TestContext testContext = tran.doInTransaction(setupCB);
RetryingTransactionCallback<List<TransferEvent>> transferCB = new RetryingTransactionCallback<List<TransferEvent>>() {
@Override
public List<TransferEvent> execute() throws Throwable
{
List<TransferEvent>transferReport = new ArrayList<TransferEvent>(50);
TestTransferCallback callback = new TestTransferCallback();
Set<TransferCallback> callbacks = new HashSet<TransferCallback>();
callbacks.add(callback);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(testContext.nodeRefA);
nodes.add(testContext.nodeRefB);
definition.setNodes(nodes);
transferService.transferAsync(targetName, definition, callbacks);
logger.debug("transfer async has returned");
/**
* Need to poll the transfer events here until callback receives the last event
*/
Queue<TransferEvent> events = callback.getEvents();
int sleepCount = MAX_SLEEPS;
boolean ended = false;
TransferEvent event = events.poll();
while (!ended)
{
logger.debug("polling loop:" + sleepCount);
while(event != null)
{
/**
* Got an event - reset the sleep counter
*/
sleepCount = MAX_SLEEPS;
logger.debug("Got an event" + event.toString());
/**
* Squirrel away the event for analysis later
*/
transferReport.add(event);
/**
* If we read the last record which will either be SUCCESS or ERROR then we we have finished
*/
if(event.isLast())
{
logger.debug("got last event");
ended = true;
}
/**
* Try to get the next event
*/
event = events.poll();
}
if(event == null && !ended)
{
if(sleepCount <= 0)
{
fail("timed out without receiving last event");
ended = true;
}
else
{
/**
* No content - go to sleep to wait for some more
*/
if(sleepCount-- > 0)
{
// Sleep for 5 second
Thread.sleep(5000);
}
}
/**
* Try to get the next event
*/
event = events.poll();
}
}
return transferReport;
}
};
/**
* The transfer report is a plain report of the transfer - no async shenanigans to worry about
*/
final List<TransferEvent>transferReport = tran.doInTransaction(transferCB);
/**
* Now validate the transferReport
*/
assertTrue("transfer report is too small", transferReport.size() > 2);
assertTrue("transfer report does not start with START", transferReport.get(0).getTransferState().equals(TransferEvent.TransferState.START));
boolean success = false;
for(TransferEvent event : transferReport)
{
if(event.getTransferState() == TransferEvent.TransferState.SUCCESS)
{
success = true;
}
}
assertTrue("transfer report does not contain SUCCESS", success);
} // test async callback
/**
* Test the transfer cancel method when it is running async.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testAsyncCancel() throws Exception
{
int MAX_SLEEPS = 5;
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
* This needs to be committed before we can call transfer asycnc.
*/
String CONTENT_TITLE = "ContentTitle";
String CONTENT_NAME_A = "Demo Node A";
String CONTENT_NAME_B = "Demo Node B";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
NodeRef nodeRefA = null;
NodeRef nodeRefB = null;
String targetName = "testAsyncCallback";
{
UserTransaction trx = transactionService.getNonPropagatingUserTransaction();
trx.begin();
try
{
nodeRefA = nodeService.getChildByName(guestHome, ContentModel.ASSOC_CONTAINS, CONTENT_NAME_A);
if(nodeRefA == null)
{
/**
* Create a test node that we will read and write
*/
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
nodeRefA = child.getChildRef();
nodeService.setProperty(nodeRefA, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(nodeRefA, ContentModel.PROP_NAME, CONTENT_NAME_A);
ContentWriter writer = contentService.getWriter(nodeRefA, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
nodeRefB = nodeService.getChildByName(guestHome, ContentModel.ASSOC_CONTAINS, CONTENT_NAME_B);
if(nodeRefB == null)
{
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
nodeRefB = child.getChildRef();
nodeService.setProperty(nodeRefB, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(nodeRefB, ContentModel.PROP_NAME, CONTENT_NAME_B);
ContentWriter writer = contentService.getWriter(nodeRefB, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
createTransferTarget(targetName);
}
else
{
transferService.getTransferTarget(targetName);
}
}
finally
{
int status = trx.getStatus();
trx.commit();
}
}
/**
* The transfer report is a plain report of the transfer - no async shenanigans to worry about
*/
List<TransferEvent>transferReport = new ArrayList<TransferEvent>(50);
startNewTransaction();
try
{
/**
* Call the transferAsync method.
*/
{
/**
* The poison callback will cancel the transfer after
* the begin
*/
TransferCallback poison = new TransferCallback()
{
String transferId = null;
public void processEvent(TransferEvent event)
{
logger.debug(event.toString());
if(event instanceof TransferEventBegin)
{
TransferEventBegin beginEvent = (TransferEventBegin)event;
transferId = beginEvent.getTransferId();
transferService.cancelAsync(transferId);
}
}
};
TestTransferCallback callback = new TestTransferCallback();
Set<TransferCallback> callbacks = new HashSet<TransferCallback>();
callbacks.add(callback);
callbacks.add(poison);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(nodeRefA);
nodes.add(nodeRefB);
definition.setNodes(nodes);
transferService.transferAsync(targetName, definition, callbacks);
logger.debug("transfer async has returned");
/**
* Need to poll the transfer events here until callback receives the last event
*/
Queue<TransferEvent> events = callback.getEvents();
int sleepCount = MAX_SLEEPS;
boolean ended = false;
TransferEvent event = events.poll();
while (!ended)
{
logger.debug("polling loop:" + sleepCount);
while(event != null)
{
/**
* Got an event - reset the sleep counter
*/
sleepCount = MAX_SLEEPS;
logger.debug("Got an event" + event.toString());
/**
* Squirrel away the event for analysis later
*/
transferReport.add(event);
/**
* If we read the last record which will either be SUCCESS or ERROR then we we have finished
*/
if(event.isLast())
{
logger.debug("got last event");
ended = true;
}
/**
* Try to get the next event
*/
event = events.poll();
}
if(event == null && !ended)
{
if(sleepCount <= 0)
{
fail("timed out without receiving last event");
ended = true;
}
else
{
/**
* No content - go to sleep to wait for some more
*/
if(sleepCount-- > 0)
{
// Sleep for 5 second
Thread.sleep(5000);
}
}
/**
* Try to get the next event
*/
event = events.poll();
}
}
}
/**
* Now validate the transferReport
*/
assertTrue("transfer report is too small", transferReport.size() > 3);
assertTrue("transfer report does not start with START", transferReport.get(0).getTransferState().equals(TransferEvent.TransferState.START));
assertTrue("transfer report does not end with CANCELLED", transferReport.get(transferReport.size()-1).getTransferState().equals(TransferEvent.TransferState.CANCELLED));
// last event is the transfer report event.
}
finally
{
// UserTransaction trx = transactionService.getNonPropagatingUserTransaction();
// trx.begin();
transferService.deleteTransferTarget(targetName);
// trx.commit();
endTransaction();
}
} // test async cancel
/**
* Test the transfer report.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testTransferReport() throws Exception
{
setDefaultRollback(false);
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
* This needs to be committed before we can call transfer asycnc.
*/
String CONTENT_TITLE = "ContentTitle";
String CONTENT_NAME_A = "Report Node A";
String CONTENT_NAME_B = "Report Node B";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
NodeRef nodeRefA = null;
NodeRef nodeRefB = null;
NodeRef testFolder = null;
String targetName = "testTransferReport";
startNewTransaction();
try
{
{
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
testFolder = child.getChildRef();
nodeService.setProperty(testFolder, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testFolder, ContentModel.PROP_NAME, name);
}
{
/**
* Create a test node that we will read and write
*/
ChildAssociationRef child = nodeService.createNode(testFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
nodeRefA = child.getChildRef();
nodeService.setProperty(nodeRefA, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(nodeRefA, ContentModel.PROP_NAME, CONTENT_NAME_A);
ContentWriter writer = contentService.getWriter(nodeRefA, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
ChildAssociationRef child = nodeService.createNode(testFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate()), ContentModel.TYPE_CONTENT);
nodeRefB = child.getChildRef();
nodeService.setProperty(nodeRefB, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(nodeRefB, ContentModel.PROP_NAME, CONTENT_NAME_B);
ContentWriter writer = contentService.getWriter(nodeRefB, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
createTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
NodeRef transferReport = null;
NodeRef transferDestReport = null;
/**
* Step 1.
* Call the transfer method. to get a failed transfer - orphan nodes exist
*/
setDefaultRollback(true);
startNewTransaction();
try
{
TestTransferCallback callback = new TestTransferCallback();
Set<TransferCallback> callbacks = new HashSet<TransferCallback>();
callbacks.add(callback);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(nodeRefA);
nodes.add(nodeRefB);
// missing the folder node (testFolder)
definition.setNodes(nodes);
// Do the transfer here
try
{
transferService.transfer(targetName, definition, callbacks);
fail("transfer should have failed with an orphan not found exception");
}
catch (TransferException te)
{
logger.debug("deliberatly caught and ignored exception");
}
// Can't dirty read transfer report here
boolean foundSourceReport = false;
boolean foundDestReport = false;
for(TransferEvent event : callback.getEvents())
{
if(event instanceof TransferEventReport)
{
TransferEventReport reportEvent = (TransferEventReport)event;
switch (reportEvent.getReportType())
{
case DESTINATION:
foundDestReport = true;
transferDestReport = reportEvent.getNodeRef();
assertNotNull("dest transfer nodeId null", transferDestReport);
break;
case SOURCE:
foundSourceReport = true;
transferReport = reportEvent.getNodeRef();
break;
}
}
}
assertTrue("source report not found", foundSourceReport);
assertTrue("dest report not found", foundDestReport);
}
finally
{
endTransaction();
}
setDefaultRollback(false);
/**
* Now validate the client side error transfer report against the xsd file
*/
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
assertNotNull("transfer reader is null", reader);
assertEquals("client report mimetype not set", reader.getMimetype(), MimetypeMap.MIMETYPE_XML);
String name = (String)nodeService.getProperty(transferReport, ContentModel.PROP_NAME);
assertTrue("client report does not end with .xml", name.endsWith(".xml"));
logger.debug("This report should have failed");
if(logger.isDebugEnabled())
{
dumpToSystemOut(transferReport);
}
// Now validate the client side transfer report against the XSD
Source transferReportSource = new StreamSource(reader.getContentInputStream());
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/report/TransferReport2.xsd";
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
Validator validator = schema.newValidator();
try
{
validator.validate(transferReportSource);
}
catch (Exception e)
{
fail(e.getMessage() );
}
}
finally
{
endTransaction();
}
/**
* Step 2
* Call the transfer method to get a good success transfer report
*/
startNewTransaction();
try
{
{
TestTransferCallback callback = new TestTransferCallback();
Set<TransferCallback> callbacks = new HashSet<TransferCallback>();
callbacks.add(callback);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(nodeRefA);
nodes.add(nodeRefB);
nodes.add(testFolder);
definition.setNodes(nodes);
transferReport = transferService.transfer(targetName, definition, callbacks);
assertNotNull("transfer report is null", transferReport);
// Can't dirty read transfer report here
boolean foundSourceReport = false;
boolean foundDestReport = false;
for(TransferEvent event : callback.getEvents())
{
if(event instanceof TransferEventReport)
{
TransferEventReport reportEvent = (TransferEventReport)event;
switch (reportEvent.getReportType())
{
case DESTINATION:
foundDestReport = true;
transferDestReport = reportEvent.getNodeRef();
assertNotNull("dest transfer nodeId null", transferDestReport);
assertFalse("dest transfer nodeId not correct", transferReport.equals(transferDestReport));
break;
case SOURCE:
foundSourceReport = true;
assertEquals("source transfer nodeId not correct", transferReport, reportEvent.getNodeRef());
break;
}
}
}
assertTrue("source report not found", foundSourceReport);
assertTrue("dest report not found", foundDestReport);
}
}
finally
{
endTransaction();
}
/**
* Now validate the client side transfer report against the xsd file
*/
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
assertNotNull("transfer reader is null", reader);
logger.debug("This report should succeed");
if(logger.isDebugEnabled())
{
dumpToSystemOut(transferReport);
}
// Now validate the client side transfer report against the XSD
Source transferReportSource = new StreamSource(reader.getContentInputStream());
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/report/TransferReport2.xsd";
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
Validator validator = schema.newValidator();
try
{
validator.validate(transferReportSource);
}
catch (Exception e)
{
fail(e.getMessage() );
}
}
finally
{
endTransaction();
}
/**
* Now validate the destination side transfer report against its xsd file
*/
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(transferDestReport, ContentModel.PROP_CONTENT);
assertNotNull("transfer reader is null", reader);
assertEquals("dest report mimetype not set", reader.getMimetype(), MimetypeMap.MIMETYPE_XML);
String name = (String)nodeService.getProperty(transferReport, ContentModel.PROP_NAME);
assertTrue("dest report does not end with .xml", name.endsWith(".xml"));
if(logger.isDebugEnabled())
{
dumpToSystemOut(transferDestReport);
}
// Now validate the destination side transfer report against the XSD
Source transferReportSource = new StreamSource(reader.getContentInputStream());
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/reportd/TransferDestinationReport.xsd";
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
Validator validator = schema.newValidator();
try
{
validator.validate(transferReportSource);
}
catch (Exception e)
{
fail("Destination Transfer Report " + e.getMessage() );
}
}
finally
{
endTransaction();
}
/**
* Now validate all transfer reports.
*/
startNewTransaction();
try
{
String query = "TYPE:\"trx:transferReportDest\"";
ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE, query);
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/reportd/TransferDestinationReport.xsd";
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
Validator validator = schema.newValidator();
for(ResultSetRow result : results)
{
NodeRef reportNode = result.getNodeRef();
logger.debug("validating reportNode " + reportNode);
// Now validate the destination side transfer report against the XSD
ContentReader reader = contentService.getReader(reportNode, ContentModel.PROP_CONTENT);
assertNotNull("transfer reader is null", reader);
if (reader.getMimetype().equals(MimetypeMap.MIMETYPE_XML))
{
Source transferReportSource = new StreamSource(reader.getContentInputStream());
try
{
validator.validate(transferReportSource);
}
catch (Exception e)
{
fail("Destination Transfer Report reportNode:" + reportNode + " message :" + e.getMessage() );
}
}
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
logger.debug("now delete the target:" + targetName);
transferService.deleteTransferTarget(targetName);
}
finally
{
endTransaction();
}
} // test transfer report
private void dumpToSystemOut(NodeRef nodeRef) throws IOException
{
ContentReader reader2 = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
assertNotNull("transfer reader is null", reader2);
InputStream is = reader2.getContentInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = br.readLine();
while(s != null)
{
System.out.println(s);
s = br.readLine();
}
}
private UnitTestTransferManifestNodeFactory unitTestKludgeToTransferGuestHomeToCompanyHome()
{
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
return testNodeFactory;
}
/**
* Test the transfer method with regard to big content.
*
* This test takes a long time to run and is by default not run in the overnight build.
*
* Turn it on by turning debug logging on for this class or by changing the "runTest" value;
*/
public void testTransferOneNodeWithBigContent() throws Exception
{
/**
* This test takes a long time to run - so switch it on and off here.
*/
boolean runTest = false;
if(runTest || logger.isDebugEnabled())
{
final String CONTENT_TITLE = "ContentTitle";
final String CONTENT_NAME = "BigContent";
final Locale CONTENT_LOCALE = Locale.UK;
logger.debug("testTransferOneNodeWithBigContent starting");
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
/**
* Unit test kludge to transfer from guest home to company home
*/
final UnitTestTransferManifestNodeFactory testNodeFactory = unitTestKludgeToTransferGuestHomeToCompanyHome();
final String targetName = "testTransferOneNodeWithBigContent";
class TestContext
{
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef destNodeRef;
};
RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
{
@Override
public TestContext execute() throws Throwable
{
TestContext ctx = new TestContext();
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet result = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, result.length());
NodeRef guestHome = result.getNodeRef(0);
System.out.println("Guest home:" + guestHome);
assertNotNull(guestHome);
ctx.contentNodeRef = nodeService.getChildByName(guestHome, ContentModel.ASSOC_CONTAINS, CONTENT_NAME);
if(ctx.contentNodeRef == null)
{
/**
* Create a test node that we will read and write
*/
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(CONTENT_NAME), ContentModel.TYPE_CONTENT);
File tempFile = TempFileProvider.createTempFile("test", ".dat");
FileWriter fw = new FileWriter(tempFile);
for(int i = 0; i < 100000000; i++)
{
fw.write("hello world this is my text, I wonder how much text I can transfer?" + i);
}
System.out.println("Temp File Size is:" + tempFile.length());
fw.close();
ctx.contentNodeRef = child.getChildRef();
ContentWriter writer = contentService.getWriter(ctx.contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.setMimetype("application/data");
writer.putContent(tempFile);
tempFile.delete();
nodeService.setProperty(ctx.contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(ctx.contentNodeRef, ContentModel.PROP_NAME, CONTENT_NAME);
}
if(!transferService.targetExists(targetName))
{
createTransferTarget(targetName);
}
return ctx;
}
};
final TestContext testContext = tran.doInTransaction(setupCB);
RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(testContext.contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
return null;
}
};
RetryingTransactionCallback<Void> finishCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
NodeRef oldDestNodeRef = testNodeFactory.getMappedNodeRef(testContext.contentNodeRef);
ContentReader source = contentService.getReader(testContext.contentNodeRef, ContentModel.PROP_CONTENT);
ContentReader destination = contentService.getReader(oldDestNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("source is null", source);
assertNotNull("destination is null", destination);
assertEquals("size different", source.getSize(), destination.getSize());
/**
* Now get rid of the transferred node so that the test can run again.
*/
nodeService.deleteNode(oldDestNodeRef);
return null;
}
};
/**
* This is the test
*/
tran.doInTransaction(transferCB);
tran.doInTransaction(finishCB);
}
else
{
System.out.println("test supressed");
}
} // test big content
/**
* Test the transfer method behaviour with respect to sync folders - sending a complete set
* of nodes and implying delete from the absence of an association.
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*
* Tree of nodes
*
* A1
* | |
* A2 A3 (Content Node)
* |
* A4 A5 (Content Node)
*
* Test steps -
* 1 add A1
* transfer(sync)
* 2 add A2, A3, A4, A5
* transfer(sync)
* 3 remove A2
* transfer(sync) A4 and A5 should cascade delete on source
* 4 remove A3
* transfer(sync)
* 5 add back A3 - new node ref
* transfer(sync)
* 6 add A2, A4, A5
* transfer(sync)
* 7 test delete and restore of a single node
* remove A3 .
* transfer
* restore node A3
* transfer
* 8 test delete and restore of a tree of nodes
* remove A2 (A4 and A5 should cascade delete on source as well)
* transfer
* restore node A2 (and A4 and A5 cascade restore)
* transfer
*/
public void testTransferSyncNodes() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferSyncNodes";
TransferTarget transferMe;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test nodes A1 through A5 that we will read and write
*/
{
// Node A1
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_CONTENT);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
ContentWriter writer = contentService.getWriter(A4NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
ContentWriter writer = contentService.getWriter(A5NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1. Add Node A1.
*/
startNewTransaction();
try
{
/**
* Transfer Node A with no children
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(A1NodeRef), nodeService.getType(destNodeRef));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 2. Add Node A2, A3, A4, A5.
*/
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertTrue("dest node ref A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node ref A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node ref A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node ref A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 3 - remove folder node A2
*/
startNewTransaction();
try
{
nodeService.deleteNode(A2NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
//nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
//nodes.add(A4NodeRef);
//nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertFalse("dest node ref A2 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node ref A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node ref A4 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertFalse("dest node ref A5 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 4 - remove content node A3
*/
startNewTransaction();
try
{
nodeService.deleteNode(A3NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
//nodes.add(A2NodeRef);
//nodes.add(A3NodeRef);
//nodes.add(A4NodeRef);
//nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertFalse("dest node ref A2 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertFalse("dest node ref A3 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node ref A4 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertFalse("dest node ref A5 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 5. Add back A3.
*/
startNewTransaction();
try
{
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
//nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
//nodes.add(A4NodeRef);
//nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertFalse("dest node ref A2 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node ref A4 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertFalse("dest node ref A5 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 6. add A2, A4, A5
*/
startNewTransaction();
try
{
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_CONTENT);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
ContentWriter writer = contentService.getWriter(A4NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
ContentWriter writer = contentService.getWriter(A5NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertTrue("dest node A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 7 - test delete and restore of a single node
* remove A3 .
* transfer
* restore node A3
* transfer
*/
startNewTransaction();
try
{
logger.debug("Step 7 - delete node A3");
nodeService.deleteNode(A3NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
//nodes.add(A3NodeRef); A3 has gone.
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertTrue("dest node ref A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertFalse("dest node ref A3 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node ref A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node ref A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef archivedNode = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, A3NodeRef.getId());
NodeRef newNodeRef = nodeService.restoreNode(archivedNode, A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"));
assertEquals("restored node ref is different", newNodeRef, A3NodeRef);
logger.debug("Step 7 - restore node A3");
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5.
* (So we are seeing what happens to node 3 on the target
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertTrue("dest node ref A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node ref A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node ref A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node ref A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
}
finally
{
endTransaction();
}
/**
* Step 8 - test delete and restore of a tree
* remove A2 (A4, A5) should cascade delete.
* transfer
* restore node A2
* transfer
*/
startNewTransaction();
try
{
nodeService.deleteNode(A2NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
//nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
//nodes.add(A4NodeRef);
//nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertFalse("dest node ref A2 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node ref A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node ref A4 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertFalse("dest node ref A5 has not been deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef archivedNode = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, A2NodeRef.getId());
nodeService.restoreNode(archivedNode, A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer Node A 1-5.
* (So we are seeing what happens to node 2, 4, 5 on the target
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref A1 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertTrue("dest node ref A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node ref A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node ref A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node ref A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
}
finally
{
endTransaction();
}
}
/**
* Test the transfer method behaviour with respect to sync with (local) alien nodes.
*
* So we have Repository A transferring content and Repository B is the local repo that we
* add and delete alien nodes.
*
* In general an alien node will prevent deletion of the parent folders
*
* <pre>
* Tree of nodes
*
* A1
* | | |
* A2 A3 (Content Node) B9 (Alien Content Node)
* |
* A4 A5 B10 (Alien Content Node) A6
* | |
* A7 B11 (Alien Content Node) A8 B12 B13 (Alien Content Node)
* |
* B14
* </pre>
* Test steps -
* <ol>
* <li>add A1, A2, A3, A4, A5, A6, A7, A8
* transfer(sync)</li>
* <li>add Alien node B9. A1 becomes Alien.</li>
* <li>remove alien node B9. A1 becomes non Alien.</li>
* <li>add Alien node B10. A1 and A2 become Alien</li>
* <li>remove Alien node B10. A1 and A2 become non Alien</li>
* <li>add B12 and B14 A6, A2, A1 becomes Alien</li>
* <li>remove B14, B12, A6, A2, A1 remain Alien</li>
* <li>add B13 A6, A2, A1 remains Alien</li>
* <li>remove B13 A6, A2, A1 remains Alien</li>
* <li>remove B12 A6, A2, A1 becomes non Alien.</li>
* <li>add B9 and B10 A1 and A2 become Alien</li>
* <li>remove B10 A2 becomes non alien A1 remains alien.</li>
* <li>Add B11, delete A2
* transfer sync</li>
* (A5, A6, A7 and A8 should be deleted A2 and A4 remain since they contain alien content.)</li>
* </ol>
*/
public void testTransferInvadedByLocalAlienNodes() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.JAPAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Mock the transfer service to be from Repo A
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testSyncWithAlienNodes";
TransferTarget transferMe;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef A6NodeRef;
NodeRef A7NodeRef;
NodeRef A8NodeRef;
NodeRef B9NodeRef;
NodeRef B10NodeRef;
NodeRef B11NodeRef;
NodeRef B12NodeRef;
NodeRef B13NodeRef;
NodeRef B14NodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test nodes A1 through A8 that we will read and write
*/
{
// Node A1
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_FOLDER);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
ContentWriter writer = contentService.getWriter(A5NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A6
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A6"), ContentModel.TYPE_FOLDER);
A6NodeRef = child.getChildRef();
nodeService.setProperty(A6NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A6NodeRef, ContentModel.PROP_NAME, "A6");
}
{
// Node A7
ChildAssociationRef child = nodeService.createNode(A4NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A7"), ContentModel.TYPE_CONTENT);
A7NodeRef = child.getChildRef();
nodeService.setProperty(A7NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A7NodeRef, ContentModel.PROP_NAME, "A7");
ContentWriter writer = contentService.getWriter(A7NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A8
ChildAssociationRef child = nodeService.createNode(A6NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A8"), ContentModel.TYPE_CONTENT);
A8NodeRef = child.getChildRef();
nodeService.setProperty(A8NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A8NodeRef, ContentModel.PROP_NAME, "A8");
ContentWriter writer = contentService.getWriter(A8NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
} else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1. add A1, A2, A3, A4, A5, A6, A7, A8
* transfer(sync)
*/
startNewTransaction();
try
{
/**
* Transfer Nodes A1 through A8
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
nodes.add(A6NodeRef);
nodes.add(A7NodeRef);
nodes.add(A8NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertFalse("unit test stuffed up - comparing with self", A1destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(A1destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(A1NodeRef), nodeService.getType(A1destNodeRef));
assertFalse("A1 is alien", nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 2 add Alien node B9 child of A1(dest). A1(dest) becomes Alien because it contains an alien child.
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B9"), ContentModel.TYPE_CONTENT);
B9NodeRef = child.getChildRef();
nodeService.setProperty(B9NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B9NodeRef, ContentModel.PROP_NAME, "B9");
ContentWriter writer = contentService.getWriter(B9NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
// Check injected transferred aspect.
assertTrue("node A1 is not alien aspect", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
assertTrue("node B9 is not alien", (Boolean)nodeService.hasAspect(B9NodeRef, TransferModel.ASPECT_ALIEN));
// Temp code
List<String> invaders = (List<String>) nodeService.getProperty(A1destNodeRef, TransferModel.PROP_INVADED_BY);
assertTrue("invaders contains local repository Id", invaders.contains(localRepositoryId));
assertFalse("invaders contains REPO_ID_A", invaders.contains(REPO_ID_A));
}
finally
{
endTransaction();
}
/**
* Step 3 remove alien node B9. A1 becomes non Alien.
*/
startNewTransaction();
try
{
logger.debug("delete node B9");
nodeService.deleteNode(B9NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A3destNodeRef = testNodeFactory.getMappedNodeRef(A3NodeRef);
List<String> invaders = (List<String>) nodeService.getProperty(A1destNodeRef, TransferModel.PROP_INVADED_BY);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertFalse("node A1 is still alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A3 is alien", (Boolean)nodeService.hasAspect(A3destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* 4 add Alien node B10 child of A2. A1 and A2 become Alien
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B10"), ContentModel.TYPE_CONTENT);
B10NodeRef = child.getChildRef();
nodeService.setProperty(B10NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B10NodeRef, ContentModel.PROP_NAME, "B10");
ContentWriter writer = contentService.getWriter(B10NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
assertTrue("node A1 is not alien aspect", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien aspect", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* 5 remove Alien node B10. A1 and A2 become non Alien
*/
startNewTransaction();
try
{
logger.debug("delete node B10");
nodeService.deleteNode(B10NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
assertFalse("node A1 is still alien aspect", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A2 is still alien aspect", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 6
* add B12 (child of A6) and B14 A6, A2, A1 becomes Alien
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B12"), ContentModel.TYPE_FOLDER);
B12NodeRef = child.getChildRef();
nodeService.setProperty(B12NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B12NodeRef, ContentModel.PROP_NAME, "B12");
child = nodeService.createNode(B12NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B14"), ContentModel.TYPE_CONTENT);
B14NodeRef = child.getChildRef();
nodeService.setProperty(B14NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B14NodeRef, ContentModel.PROP_NAME, "B14");
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A6 is not alien", (Boolean)nodeService.hasAspect(A6destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node B14 is not alien", (Boolean)nodeService.hasAspect(B14NodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node B12 is not alien", (Boolean)nodeService.hasAspect(B12NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 7
* Delete B14. B12 remains alien
*/
startNewTransaction();
try
{
nodeService.deleteNode(B14NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A6 is not alien", (Boolean)nodeService.hasAspect(A6destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node B12 is not alien", (Boolean)nodeService.hasAspect(B12NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 8
* add B13 A6, A2, A1 remains Alien
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B13"), ContentModel.TYPE_CONTENT);
B13NodeRef = child.getChildRef();
nodeService.setProperty(B13NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B13NodeRef, ContentModel.PROP_NAME, "B13");
ContentWriter writer = contentService.getWriter(B13NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A6 is not alien", (Boolean)nodeService.hasAspect(A6destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 9 remove B13 A6, A2, A1 remains Alien Due to B12
*/
startNewTransaction();
try
{
nodeService.deleteNode(B13NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A6 is not alien", (Boolean)nodeService.hasAspect(A6destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 10 remove B12 A6, A2, A1 becomes non Alien.
*/
startNewTransaction();
try
{
nodeService.deleteNode(B12NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
assertFalse("node A1 is still alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A2 is still alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A6 is still alien", (Boolean)nodeService.hasAspect(A6destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 11 add B9 and B10 A1 and A2 become Alien
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B9"), ContentModel.TYPE_CONTENT);
B9NodeRef = child.getChildRef();
nodeService.setProperty(B9NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B9NodeRef, ContentModel.PROP_NAME, "B9");
ContentWriter writer = contentService.getWriter(B9NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B10"), ContentModel.TYPE_CONTENT);
B10NodeRef = child.getChildRef();
nodeService.setProperty(B10NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B10NodeRef, ContentModel.PROP_NAME, "B10");
writer = contentService.getWriter(B10NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 12 remove B10 A2 becomes non alien A1 remains alien.
*/
startNewTransaction();
try
{
nodeService.deleteNode(B10NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
// BUGBUG
assertTrue("node A1 is still alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A2 is still alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* 13 Add Alien node B11.
*/
logger.debug("Step 12 Add Node B11, Delete A2 and sync");
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A4NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B11"), ContentModel.TYPE_CONTENT);
B11NodeRef = child.getChildRef();
nodeService.setProperty(B11NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B11NodeRef, ContentModel.PROP_NAME, "B11");
ContentWriter writer = contentService.getWriter(B11NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodeService.deleteNode(A2NodeRef);
}
finally
{
endTransaction();
}
/**
* Step 14
* delete A2 (will cascade delete A4, A5, A6, A7, A8
* transfer sync
* (A5, A6, A7, A8 and should be deleted A2 and A4 remain since they contain alien content.)
*/
startNewTransaction();
try
{
// Now validate A1, A2 and A4 are alien
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A4destNodeRef = testNodeFactory.getMappedNodeRef(A4NodeRef);
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 is not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A4 is not alien", (Boolean)nodeService.hasAspect(A4destNodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("test error: node A2 not deleted", nodeService.exists(A2NodeRef));
assertFalse("test error: node A4 not deleted", nodeService.exists(A4NodeRef));
assertFalse("test error: node A5 not deleted", nodeService.exists(A5NodeRef));
assertFalse("test error: node A6 not deleted", nodeService.exists(A6NodeRef));
assertFalse("test error: node A7 not deleted", nodeService.exists(A7NodeRef));
assertFalse("test error: node A8 not deleted", nodeService.exists(A8NodeRef));
assertTrue("test error: node does not exist", nodeService.exists(A3NodeRef));
/**
* Transfer Nodes A1 through A8
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A3destNodeRef = testNodeFactory.getMappedNodeRef(A3NodeRef);
NodeRef A4destNodeRef = testNodeFactory.getMappedNodeRef(A4NodeRef);
NodeRef A5destNodeRef = testNodeFactory.getMappedNodeRef(A5NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
NodeRef A7destNodeRef = testNodeFactory.getMappedNodeRef(A7NodeRef);
NodeRef A8destNodeRef = testNodeFactory.getMappedNodeRef(A8NodeRef);
assertTrue("node A1 not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A4 not alien", (Boolean)nodeService.hasAspect(A4destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node B11 does not exist", nodeService.exists(B11NodeRef));
assertTrue("node A3 deleted", nodeService.exists(A3destNodeRef));
assertFalse("node A5 not deleted", nodeService.exists(A5destNodeRef));
assertFalse("node A6 not deleted", nodeService.exists(A6destNodeRef));
assertFalse("node A7 not deleted", nodeService.exists(A7destNodeRef));
assertFalse("node A8 not deleted", nodeService.exists(A8destNodeRef));
}
finally
{
endTransaction();
}
}
/**
* Test restore of a local node.
* <pre>
* Tree of nodes
* A1 B1
* |
* B2
* |
* B3
* <pre>
* <ol>
* <li>Add B2. A1 is alien.</li>
* <li>Delete B2. A1 not alien</li>
* <li>Restore B2. A1 is alien</li>
* <li>Add B3. A1 is alien</li>
* <li>Delete B2. A1 not alien</li>
* <li>Restore to B1. B2 and B3 not alien.</li>
* </ol>
* @throws Exception
*/
public void testLocalAlienRestore() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.JAPAN;
String CONTENT_STRING = "Hello";
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testRestoreOfAlienNodes";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A0NodeRef;
NodeRef A1NodeRef;
NodeRef B1NodeRef;
NodeRef B2NodeRef;
NodeRef B3NodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test nodes A1 through A8 that we will read and write
*/
{
// Node S0
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A0"), ContentModel.TYPE_FOLDER);
A0NodeRef = child.getChildRef();
nodeService.setProperty(A0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A0NodeRef, ContentModel.PROP_NAME, "A0");
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(A0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Mock the transfer service to be from Repo A
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
pathMap.add(new Pair(nodeService.getPath(A0NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1. add A1
* transfer(sync)
*/
startNewTransaction();
try
{
/**
* Transfer Nodes A1
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertFalse("A1 is alien", nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 2 add Alien node B1 child of A1(dest).
*/
startNewTransaction();
try
{
destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
ChildAssociationRef child = nodeService.createNode(destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B2"), ContentModel.TYPE_FOLDER);
B2NodeRef = child.getChildRef();
nodeService.setProperty(B2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B2NodeRef, ContentModel.PROP_NAME, "B2");
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
// Check injected transferred aspect.
assertTrue("node A1 is not alien aspect", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
assertTrue("node B2 is not alien", (Boolean)nodeService.hasAspect(B2NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 3 remove alien node B2. A1 becomes non Alien.
*/
startNewTransaction();
try
{
logger.debug("delete node B2");
nodeService.deleteNode(B2NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
List<String> invaders = (List<String>) nodeService.getProperty(A1destNodeRef, TransferModel.PROP_INVADED_BY);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertFalse("node A1 is still alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 4 restore alien node B2. A1 becomes Alien again
*/
startNewTransaction();
try
{
logger.debug("restore node B2");
NodeRef B2ArchiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, B2NodeRef.getId());
nodeService.restoreNode(B2ArchiveNodeRef, testNodeFactory.getMappedNodeRef(A1NodeRef), ContentModel.ASSOC_CONTAINS, QName.createQName("B2"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertTrue("node A1 is not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step 5 - add B3
*/
startNewTransaction();
try
{
ChildAssociationRef child = nodeService.createNode(B2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B3"), ContentModel.TYPE_FOLDER);
B3NodeRef = child.getChildRef();
nodeService.setProperty(B3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B3NodeRef, ContentModel.PROP_NAME, "B3");
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("node B3 is not alien", (Boolean)nodeService.hasAspect(B3NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 5 remove alien node B2. A1 becomes non Alien (again).
*/
startNewTransaction();
try
{
logger.debug("delete node B2");
nodeService.deleteNode(B2NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
List<String> invaders = (List<String>) nodeService.getProperty(A1destNodeRef, TransferModel.PROP_INVADED_BY);
assertTrue("dest node ref does not exist", nodeService.exists(A1destNodeRef));
assertFalse("node A1 is still alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertNotNull("repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_REPOSITORY_ID));
assertNotNull("from repository id is null", (String)nodeService.getProperty(A1destNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID));
}
finally
{
endTransaction();
}
/**
* Step6 restore B2 and B3 to B1.
*/
startNewTransaction();
try
{
logger.debug("restore node B2");
NodeRef B2ArchiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, B2NodeRef.getId());
nodeService.restoreNode(B2ArchiveNodeRef, B1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B2"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertFalse("node A1 is still alien", (Boolean)nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("node A2 is still alien", (Boolean)nodeService.hasAspect(B2NodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("node A3 is still alien", (Boolean)nodeService.hasAspect(B3NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
}
/**
* Test the transfer method with regard to permissions on a node.
* <p>
* Step 1:
* Create a node with a single permission
* Inherit:false
* Read, Admin, Allow
* Transfer
* <p>
* Step 2:
* Update it to have several permissions
* Inherit:false
* Read, Everyone, DENY
* Read, Admin, Allow
* <p>
* Step 3:
* Remove a permission
* Inherit:false
* Read, Admin, Allow
* <p>
* Step 4:
* Revert to inherit all permissions
* Inherit:true
* <p>
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testTransferWithPermissions() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our transfer target
*/
String targetName = "testTransferWithPermissions";
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, name);
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
permissionService.setInheritParentPermissions(contentNodeRef, false);
permissionService.setPermission(contentNodeRef, "admin", PermissionService.READ, true);
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1
*/
logger.debug("First transfer - create new node with inheritParent permission off");
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set<AccessPermission> srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set<AccessPermission> destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 2
* Update it to have several permissions
* Inherit:false
* Read, Everyone, DENY
* Read, Admin, Allow
*/
startNewTransaction();
try
{
permissionService.setPermission(contentNodeRef, "EVERYONE", PermissionService.READ, false);
permissionService.setPermission(contentNodeRef, "admin", PermissionService.FULL_CONTROL, true);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set<AccessPermission> srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set<AccessPermission> destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("Step2, permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 3 Remove a permission
*/
startNewTransaction();
try
{
permissionService.deletePermission(contentNodeRef, "admin", PermissionService.FULL_CONTROL);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set<AccessPermission> srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set<AccessPermission> destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 4
* Revert to inherit all permissions
*/
startNewTransaction();
try
{
permissionService.setInheritParentPermissions(contentNodeRef, true);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set<AccessPermission> srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set<AccessPermission> destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertTrue("inherit parent permissions (src) flag is incorrect", srcInherit);
assertTrue("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
if(p.isSetDirectly())
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing:" + p, destPerm.contains(p));
}
}
}
finally
{
endTransaction();
}
}
/**
* Transfer with read only flag
*
* Node tree for this test
* <pre>
* A (Folder)
* | |
* B (Content) C (Folder)
* |
* D (Content)
* </pre>
* Step 1
* transfer Nodes ABCD with read only flag set - content should all be locked on destination
* <p>
* Step 2
* lock B (Content node) as user fred
* transfer (read only) - destination lock should change to Admin
* <p>
* Step 3
* lock C (Folder) as user fred
* transfer (read only) - destination lock should change to Admin
* <p>
* Step 4
* transfer without read only flag - locks should revert from Admin to Fred.
* <p>
* Step 5
* remove locks on A and B - transfer without read only flag - content should all be unlocked.
*/
public void testReadOnlyFlag() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
String CONTENT_NAME = "Demo Node 1";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "The quick brown fox";
Set<NodeRef>nodes = new HashSet<NodeRef>();
String USER_ONE = "TransferServiceImplTest";
String PASSWORD = "Password";
String targetName = "testReadOnlyFlag";
NodeRef nodeA;
NodeRef nodeB;
NodeRef nodeC;
NodeRef nodeD;
ChildAssociationRef child;
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferTarget transferMe;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String guid = GUID.generate();
child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(guid), ContentModel.TYPE_FOLDER);
nodeA = child.getChildRef();
nodeService.setProperty(nodeA , ContentModel.PROP_TITLE, guid);
nodeService.setProperty(nodeA , ContentModel.PROP_NAME, guid);
nodes.add(nodeA);
child = nodeService.createNode(nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeB"), ContentModel.TYPE_CONTENT);
nodeB = child.getChildRef();
nodeService.setProperty(nodeB , ContentModel.PROP_TITLE, CONTENT_TITLE + "B");
nodeService.setProperty(nodeB , ContentModel.PROP_NAME, "DemoNodeB");
{
ContentWriter writer = contentService.getWriter(nodeB , ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodes.add(nodeB);
}
child = nodeService.createNode(nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeC"), ContentModel.TYPE_FOLDER);
nodeC = child.getChildRef();
nodeService.setProperty(nodeC , ContentModel.PROP_TITLE, "TestNodeC");
nodeService.setProperty(nodeC , ContentModel.PROP_NAME, "TestNodeC");
nodes.add(nodeC);
child = nodeService.createNode(nodeC, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeD"), ContentModel.TYPE_CONTENT);
nodeD = child.getChildRef();
nodeService.setProperty(nodeD , ContentModel.PROP_TITLE, CONTENT_TITLE + "D");
nodeService.setProperty(nodeD , ContentModel.PROP_NAME, "DemoNodeD");
{
ContentWriter writer = contentService.getWriter(nodeD , ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodes.add(nodeD);
}
// Create users
createUser(USER_ONE, PASSWORD);
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1.
* transfer Nodes ABCD with read only flag set - content should all be locked on destination
*/
logger.debug("transfer read only - step 1");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
}
finally
{
endTransaction();
}
/**
* Step 2
* lock B (Content node) as user ONE
* transfer (read only) - destination lock should change user to "Admin"
*/
startNewTransaction();
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
lockService.lock(nodeB, LockType.READ_ONLY_LOCK);
}
finally
{
assertEquals("test error: dest node B lock ownership", nodeService.getProperty(nodeB, ContentModel.PROP_LOCK_OWNER), USER_ONE);
AuthenticationUtil.popAuthentication();
endTransaction();
}
logger.debug("transfer read only - step 2");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
// check that the lock owner is no longer USER_ONE
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER)));
}
finally
{
endTransaction();
}
/**
* Step 3
* lock C (Folder node) as user ONE
* transfer (read only) - destination lock should change to Admin
*/
startNewTransaction();
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
lockService.lock(nodeC, LockType.READ_ONLY_LOCK);
}
finally
{
assertEquals("test error: dest node C lock ownership", nodeService.getProperty(nodeC, ContentModel.PROP_LOCK_OWNER), USER_ONE);
AuthenticationUtil.popAuthentication();
endTransaction();
}
logger.debug("transfer read only - step 3");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
// check that the lock owner is no longer USER_ONE for content node B and folder node C
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER)));
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.PROP_LOCK_OWNER)));
}
finally
{
endTransaction();
}
/**
* Step 4
* transfer without read only flag - locks should revert from Admin to USER_ONE.
*/
logger.debug("transfer read only - step 4");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(false); // turn off read-only
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are not locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertFalse("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
assertEquals("dest node B lock ownership", nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER), USER_ONE);
assertEquals("dest node C lock ownership", nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.PROP_LOCK_OWNER), USER_ONE);
}
finally
{
endTransaction();
}
/**
* Step 5
* remove locks on A and B - transfer without read only flag - content should all be unlocked.
*/
logger.debug("transfer read only - step 5");
startNewTransaction();
try
{
lockService.unlock(nodeB);
lockService.unlock(nodeC);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(false); // turn off read-only
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are not locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertFalse("test fail: dest node B is still locked", nodeService.hasAspect(nodeB, ContentModel.ASPECT_LOCKABLE));
assertFalse("test fail: dest node C is still locked", nodeService.hasAspect(nodeC, ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
}
finally
{
endTransaction();
}
} // end test read only flag
/**
* Transfer sync from multiple repos.
*
* This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo.
*
* Multi-repo sync depends upon the following pieces of functionality
* a) transferred nodes are tagged with a trx:transferred aspect containing the originating repository
* id and the from repository id
* b) to support hub and spoke - when syncing don't imply delete nodes that are not "from" the transferring system
*
* * Tree of nodes
* A1
* | |
* A2 A3 (Content Node) B6 (Content Node)
* |
* A4 A5 B7
*
* Step 1
* Hub and Spoke Sync
* create Tree A1...A5
* transfer (sync)
* check the transfered aspects on destination
* create node B6. Fake its transfered aspect to be from Repo B.
* transfer (sync)
*
* Step 2
* Chain Sync
* Create Node A7 "from repo B".
* Change Nodes A1 ... A5 source to be received "from repo B"
* transfer
*
*/
public void testTwoRepoSync() throws Exception
{
/**
* Step 1
* create Tree A1...A6
* transfer (sync)
* check the transfered aspect
* create node B6. Fake its transfered aspect to be from Repo B, Non Alien.
* transfer (sync)
*/
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
String repositoryId = REPO_ID_A;
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferSyncNodes";
TransferTarget transferMe;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef B6NodeRef;
NodeRef A7NodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test nodes A1 through A5 that we will read and write
*/
{
// Node A1
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_CONTENT);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
ContentWriter writer = contentService.getWriter(A4NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
ContentWriter writer = contentService.getWriter(A5NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
/**
* transfer (sync)
* check the transfered aspect
* create node B6. Fake its transfered aspect to be from Repo B, Non Alien.
* transfer (sync)
*/
startNewTransaction();
try
{
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Node B6 - faked transfer from repository B. Child of Destination node A1
NodeRef a1Dest = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertEquals("dest node A1 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A4 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A4 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A5 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A5 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
ChildAssociationRef child = nodeService.createNode(a1Dest, ContentModel.ASSOC_CONTAINS, QName.createQName("B6"), ContentModel.TYPE_CONTENT);
B6NodeRef = child.getChildRef();
nodeService.setProperty(B6NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B6NodeRef, ContentModel.PROP_NAME, "B6");
/**
* The first tranfer was mocked to repository A - this is repository B.
*/
// This is repository B so there's no need to fake it
// nodeService.setProperty(B6NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
// nodeService.setProperty(B6NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
ContentWriter writer = contentService.getWriter(B6NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Does node B6 still exist ?
assertTrue("dest node B6 does not exist", nodeService.exists(B6NodeRef));
assertTrue("B6 not alien", nodeService.hasAspect(B6NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/** Step 2
* Chain Sync
* Change Nodes A1 ... A5 source to be received "from repo B"
* Create Node A7 - Fake it to be received "from repo B"
* transfer
*/
String NEW_TITLE="Chain sync";
startNewTransaction();
try
{
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A1NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A1NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A2NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A2NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A3NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A3NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
/**
* The repository was mocked to repoistory A. This is repository B
*/
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A7"), ContentModel.TYPE_CONTENT);
A7NodeRef = child.getChildRef();
nodeService.setProperty(A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A7NodeRef, ContentModel.PROP_NAME, "A7");
nodeService.setProperty(A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A7NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A7NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
nodes.add(A7NodeRef);
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
try
{
assertTrue("dest node A7 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A7NodeRef)));
assertEquals("dest node A1 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
}
finally
{
endTransaction();
}
} // test two repo sync
/**
* Transfer sync from multiple repos.
*
* This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo.
*
* Trees of nodes
* <pre>
* A1 B1 C1
* | |
* A2/images A2 Dummy/images
* | |
* A3 C3
*
* Destination
* B1
* |
* A2/images
* | |
* C3 A3
* |
* C4
* </pre>
* Step 1. Transfer from A to B.
* Step 2. Transfer from C to B (crossing over on A2Dest)
* Step 3. Invade A3Dest via C4
* Step 4. Delete C4. Sync from C
* Step 5. Delete C3 - A2 dest images folder uninvaded.
*/
public void testMultiRepoTransfer() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = "testMultiRepoTransfer";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef B1NodeRef;
NodeRef C1NodeRef;
NodeRef C2NodeRef;
NodeRef C3NodeRef;
NodeRef C4NodeRef;
NodeRef A3Dummy;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
{
/**
* Node Source - located under guest home
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("images"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, "images");
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "images");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, "A3");
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node C1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C1"), ContentModel.TYPE_FOLDER);
C1NodeRef = child.getChildRef();
nodeService.setProperty(C1NodeRef, ContentModel.PROP_TITLE, "C1");
nodeService.setProperty(C1NodeRef, ContentModel.PROP_NAME, "C1");
}
{
// Node C2/images
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("images"), ContentModel.TYPE_FOLDER);
C2NodeRef = child.getChildRef();
nodeService.setProperty(C2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C2NodeRef, ContentModel.PROP_NAME, "images");
}
{
// Node C3
ChildAssociationRef child = nodeService.createNode(C2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C3"), ContentModel.TYPE_FOLDER);
C3NodeRef = child.getChildRef();
nodeService.setProperty(C3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C3NodeRef, ContentModel.PROP_NAME, "C3");
}
{
// Node A3 (Dummy)
ChildAssociationRef child = nodeService.createNode(C2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
A3Dummy = child.getChildRef();
nodeService.setProperty(A3Dummy, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3Dummy, ContentModel.PROP_NAME, "A3 Dummy");
}
{
// Node C4
ChildAssociationRef child = nodeService.createNode(A3Dummy, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"), ContentModel.TYPE_FOLDER);
C4NodeRef = child.getChildRef();
nodeService.setProperty(C4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C4NodeRef, ContentModel.PROP_NAME, "C4");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
* - Map path from C1 to B1
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map Project A/images to Project B/images
// Map Project C/images to Project A/images
nodeService.getPath(A2NodeRef);
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
pathMap.add(new Pair(nodeService.getPath(C1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
* Now transfer in A's nodes to Repo B
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
// Check that A3 dest is a child of A2Dest which is a child of B1
ChildAssociationRef A3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("A3 dest is connected to the wrong node", A3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef A2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A2NodeRef));
assertEquals("A2 dest is connected to the wrong node", A2Ref.getParentRef(), B1NodeRef);
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
}
finally
{
endTransaction();
}
/**
* Step 2
* Now transfer in C's nodes
* B2 (Owned by A) gets invaded by C
*/
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(C1NodeRef);
nodes.add(C2NodeRef);
nodes.add(C3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
// Check that A3 dest is a child of A2Dest which is a child of B1
// Check that C3 dest is a child of A2Dest
ChildAssociationRef A3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("A3 dest is connected to the wrong node", A3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef C3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("C3 dest is connected to the wrong node", C3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef A2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A2NodeRef));
assertEquals("A2 dest is connected to the wrong node", A2Ref.getParentRef(), B1NodeRef);
assertTrue("A2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("A3 dest is invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("C3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_C);
}
finally
{
endTransaction();
}
/**
* Step 3
* Invade A3Dest via transfer of C4 from C
*/
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(C4NodeRef);
definition.setNodes(nodes);
definition.setSync(false);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
assertTrue("C4 is not an invader", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C4NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("A3 is not an invader", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("C3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_C);
}
finally
{
endTransaction();
}
/**
* Step 4
* Uninvade A3 from C by deleting C4
* Via Sync of A3Dummy (which has the same destination path as A3).
*/
startNewTransaction();
try
{
nodeService.deleteNode(C4NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A3Dummy);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertFalse("dest node C4 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
logger.debug("A3 Dest is " + testNodeFactory.getMappedNodeRef(A3NodeRef));
assertFalse("A3 Dest still invaded by C4", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 5 - repeat the above test with transfer(non sync) rather than transfer(sync)
* Uninvade by deleting C3.
*/
startNewTransaction();
try
{
nodeService.deleteNode(C3NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
NodeRef C3Deleted = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, C3NodeRef.getId());
nodes.add(C3Deleted);
definition.setNodes(nodes);
definition.setSync(false);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node C3 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertFalse("dest node C4 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
assertFalse("A3 still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("A2 still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
} // test multi repo sync
// Utility methods below.
private TransferTarget createTransferTarget(String name)
{
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "MARKR02";
int endpointPort = 7080;
String endpointPath = "/alfresco/service/api/transfer";
String username = "admin";
char[] password = "admin".toCharArray();
/**
* Now go ahead and create our first transfer target
*/
TransferTarget target = transferService.createAndSaveTransferTarget(name, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
return target;
}
/**
* Test the transfer method behaviour with respect to move and alien nodes.
*
* So we have Repository A transferring content and Repository B is the local repo that we
* move alien nodes in and out.
*
* Tree
* <pre>
* B1
* | | |
* C2(p1) C3(p2) A4
* |
* A5
* |
* B6
* </pre>
*
* Step 1: Tansfer in C's nodes to Repo B
*
* Step 2. Transfer in A's nodes to Repo B
*
* Setup tree above. Validat that A2 is child of C2 dest.
* A4 is a child of B1
*
* Step 3. Move A5 from C2 to C3 via transfer.
* C2Dest should stop being invaded by A5, C3Dest should be invaded by A5.
*
* Step 4. Invade A5 by B6. Move from C3 to C2 via transfer.
* C2Dest should be invaded by A and B.
* C3Dest should not be invaded.
*
* Step 5. Move A5 to A4.
* A4 should be invaded by B due to B6 but not by A.
* C2Dest should not be invaded.
*/
public void testMultiRepoTransferMove() throws Exception
{
setDefaultRollback(false);
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = "testMultiRepoTransferMove";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef B1NodeRef;
NodeRef C1NodeRef;
NodeRef C2NodeRef;
NodeRef C3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef B6NodeRef;
NodeRef C2DummyNodeRef;
NodeRef C3DummyNodeRef;
QName C2Path = QName.createQName("p2");
QName C3Path= QName.createQName("p3");
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
{
/**
* Node Source - located under guest home
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node C1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C1"), ContentModel.TYPE_FOLDER);
C1NodeRef = child.getChildRef();
nodeService.setProperty(C1NodeRef, ContentModel.PROP_TITLE, "C1");
nodeService.setProperty(C1NodeRef, ContentModel.PROP_NAME, "C1");
}
{
// Node C2
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2NodeRef = child.getChildRef();
nodeService.setProperty(C2NodeRef, ContentModel.PROP_TITLE, "C2");
nodeService.setProperty(C2NodeRef, ContentModel.PROP_NAME, "C2");
}
{
// Node C3
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3NodeRef = child.getChildRef();
nodeService.setProperty(C3NodeRef, ContentModel.PROP_TITLE, "C3");
nodeService.setProperty(C3NodeRef, ContentModel.PROP_NAME, "C3");
}
{
// Node C2 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2DummyNodeRef = child.getChildRef();
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_NAME, "C2 Dummy");
}
{
// Node C3 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3DummyNodeRef = child.getChildRef();
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_NAME, "C3 Dummy");
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"), ContentModel.TYPE_FOLDER);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, "A4");
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(C2DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_FOLDER);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, "A5");
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
* - Map path from C1 to B1
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map Project A to Project B
// Map Project C to Project B
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
pathMap.add(new Pair(nodeService.getPath(C1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
* Now transfer in C's nodes to Repo B
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(C1NodeRef);
nodes.add(C2NodeRef);
nodes.add(C3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
// Check that C3 dest is a child of B1
ChildAssociationRef C3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C3NodeRef));
assertEquals("A3 dest is connected to the wrong node", C3Ref.getParentRef(), B1NodeRef);
ChildAssociationRef C2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C2NodeRef));
assertEquals("A2 dest is connected to the wrong node", C2Ref.getParentRef(), B1NodeRef);
}
finally
{
endTransaction();
}
mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 2
* Now transfer in A's nodes
* C2 (Dest) gets invaded by A4
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
ChildAssociationRef A5Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A5NodeRef));
assertEquals("A5 dest is connected to the wrong node", A5Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C2NodeRef));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
ChildAssociationRef A4Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A4NodeRef));
assertEquals("A4 dest is connected to the wrong node", A4Ref.getParentRef(), B1NodeRef);
}
finally
{
endTransaction();
}
/**
* Step 3
* Now move A5
* C3 (Dest) gets invaded by A5
*/
startNewTransaction();
try
{
nodeService.moveNode(A5NodeRef, C3DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
// Check that A4 dest is a child of C3Dest which is a child of B1
ChildAssociationRef A5Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A5NodeRef));
assertEquals("A5 dest is connected to the wrong node", A5Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C3NodeRef));
assertTrue("A5 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C2 dest is still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 4 - multi invasion move via transfer service.
* Invade A5 by B6.
* Transfer from C3 back to C2.
*/
startNewTransaction();
try
{
nodeService.moveNode(A5NodeRef, C2DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B6"));
// Node B6
ChildAssociationRef child = nodeService.createNode(testNodeFactory.getMappedNodeRef(A5NodeRef), ContentModel.ASSOC_CONTAINS, QName.createQName("B6"), ContentModel.TYPE_FOLDER);
B6NodeRef = child.getChildRef();
nodeService.setProperty(B6NodeRef, ContentModel.PROP_TITLE, "B6");
nodeService.setProperty(B6NodeRef, ContentModel.PROP_NAME, "B6");
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
// Check that A4 dest is a child of C2Dest which is a child of B1
ChildAssociationRef A5Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A5NodeRef));
ChildAssociationRef B6Ref = nodeService.getPrimaryParent(B6NodeRef);
assertEquals("A5 dest is connected to the wrong node", A5Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C2NodeRef));
assertEquals("B6 connected to the wrong node", B6Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A5NodeRef));
assertTrue("A5 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C3 dest is still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
List<String>invaders = (List<String>)nodeService.getProperty(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.PROP_INVADED_BY);
assertTrue("invaders is too small", invaders.size() > 1);
assertTrue("invaders does not contain REPO A", invaders.contains(REPO_ID_A));
assertTrue("invaders does not contain REPO B", invaders.contains(localRepositoryId));
}
finally
{
endTransaction();
}
/**
* Step 5
* Move
*/
startNewTransaction();
try
{
nodeService.moveNode(A5NodeRef, A4NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
// Check that A5dest is a child of A4Dest which is a child of B1
ChildAssociationRef A5Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A5NodeRef));
assertEquals("A5 dest is connected to the wrong node", A5Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A4NodeRef));
assertTrue("A4 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("A5 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("B6 dest is not invaded", nodeService.hasAspect(B6NodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("C2 dest is still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C3 dest is still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
List<String>invaders = (List<String>)nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_INVADED_BY);
assertTrue("invaders is too big", invaders.size() < 2);
assertFalse("invaders contains REPO A", invaders.contains(REPO_ID_A));
assertTrue("invaders does not contains REPO B", invaders.contains(REPO_ID_B));
}
finally
{
endTransaction();
}
}
/**
* Test the behaviour with regard to copying transferred nodes.
* <p>
* Transfer node read only
* <p>
* Copy transferred node.
* <p>
* New node should not be locked and should not be transferred.
* <p>
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testCopyTransferredNode() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
/**
* Now go ahead and create our transfer target
*/
String targetName = "testCopyTransferredNode";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef B1NodeRef;
NodeRef B2NodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Node Source - located under guest home
*/
{
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, "A2");
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, "A3");
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node B2
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B2"), ContentModel.TYPE_FOLDER);
B2NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B2");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B2");
}
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map Project A to Project B
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
*/
logger.debug("First transfer - ");
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
assertTrue("dest node ref does not exist", nodeService.exists(A2destNodeRef));
/**
* Copy the node A2 Dest
*/
NodeRef copiedNode = copyService.copy(A2destNodeRef, B2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2Copy"));
assertTrue("copied node does not exist", nodeService.exists(copiedNode));
System.out.println("copied node is " + copiedNode);
assertFalse("copied node still has transferred aspect", nodeService.hasAspect(copiedNode, TransferModel.ASPECT_TRANSFERRED));
assertNull("copied node still has from repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_FROM_REPOSITORY_ID));
assertNull("copied node still has original repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_REPOSITORY_ID));
Set<QName> aspects = nodeService.getAspects(copiedNode);
/**
* Copy a chain of transferred nodes - well A2dest and A3dest
*/
copiedNode = copyService.copy(A2destNodeRef, B2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2Copy2"), true);
assertTrue("copied node does not exist", nodeService.exists(copiedNode));
System.out.println("copied node is " + copiedNode);
assertFalse("copied node still has transferred aspect", nodeService.hasAspect(copiedNode, TransferModel.ASPECT_TRANSFERRED));
assertNull("copied node still has from repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_FROM_REPOSITORY_ID));
assertNull("copied node still has original repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_REPOSITORY_ID));
List<ChildAssociationRef> children = nodeService.getChildAssocs(copiedNode);
for(ChildAssociationRef child : children)
{
assertFalse("copied node still has transferred aspect", nodeService.hasAspect(child.getChildRef(), TransferModel.ASPECT_TRANSFERRED));
assertNull("copied node still has from repository id", nodeService.getProperty(child.getChildRef(), TransferModel.PROP_FROM_REPOSITORY_ID));
assertNull("copied node still has original repository id", nodeService.getProperty(child.getChildRef(), TransferModel.PROP_REPOSITORY_ID));
}
}
finally
{
endTransaction();
}
}
/**
* Test the behaviour with respect to copy of alien nodes.
*
* So we have Repository A transferring content and Repository B is the local repo that we
* copy alien nodes in and out. Copied nodes are not "transferred" so they change
* from being "from repository A" to "from the local repository".
*
* Tree
* <pre>
* B1
* | | |
* C2(p1) C3(p2) A4
* |
* A5
* |
* B6
* </pre>
*
* Step 1: Tansfer in C's nodes to Repo B
*
* Step 2. Transfer in A's nodes to Repo B
*
* Setup tree above. Validat that A2 is child of C2 dest.
* A4 is a child of B1
*
* Step 3. Copy A5 from C2 to C3.
* C2Dest should still be invaded by A5
* C3Dest should be invaded by A5(copy 1) which is now a "B" invader.
*
* Step 4. Copy A5 from C2 to A4.
* C2Dest should still be invaded by A5
* A4Dest should be invaded by A5(copy 2) which is now a "B" invader.
*
* Step 5. Invade A5 dest with B6.
* Copy A5(Dest) to B1 (A5 Copy 3)
* B1 should not be invaded.
* A5 Copy 3 not invaded.
* B6 Copy not invaded.
*
* Step 6. Invade A5 dest with B6.
* Copy A5(Dest) to B1 (A5 Copy 3) with children
* B1 should not be invaded.
* A5 Copy 4 not invaded.
* B6 Copy not invaded.
*
*/
public void testCopyAlien() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = "testCopyAlien";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef B1NodeRef;
NodeRef C1NodeRef;
NodeRef C2NodeRef;
NodeRef C3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef B6NodeRef;
NodeRef C2DummyNodeRef;
NodeRef C3DummyNodeRef;
QName C2Path = QName.createQName("p2");
QName C3Path= QName.createQName("p3");
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
{
/**
* Node Source - located under guest home
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node C1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C1"), ContentModel.TYPE_FOLDER);
C1NodeRef = child.getChildRef();
nodeService.setProperty(C1NodeRef, ContentModel.PROP_TITLE, "C1");
nodeService.setProperty(C1NodeRef, ContentModel.PROP_NAME, "C1");
}
{
// Node C2
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2NodeRef = child.getChildRef();
nodeService.setProperty(C2NodeRef, ContentModel.PROP_TITLE, "C2");
nodeService.setProperty(C2NodeRef, ContentModel.PROP_NAME, "C2");
}
{
// Node C3
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3NodeRef = child.getChildRef();
nodeService.setProperty(C3NodeRef, ContentModel.PROP_TITLE, "C3");
nodeService.setProperty(C3NodeRef, ContentModel.PROP_NAME, "C3");
}
{
// Node C2 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2DummyNodeRef = child.getChildRef();
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_NAME, "C2 Dummy");
}
{
// Node C3 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3DummyNodeRef = child.getChildRef();
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_NAME, "C3 Dummy");
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"), ContentModel.TYPE_FOLDER);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, "A4");
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(C2DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_FOLDER);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, "A5");
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
* - Map path from C1 to B1
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map Project A to Project B
// Map Project C to Project B
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
pathMap.add(new Pair(nodeService.getPath(C1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
* Now transfer in C's nodes to Repo B
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(C1NodeRef);
nodes.add(C2NodeRef);
nodes.add(C3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
// Check that C3 dest is a child of B1
ChildAssociationRef C3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C3NodeRef));
assertEquals("A3 dest is connected to the wrong node", C3Ref.getParentRef(), B1NodeRef);
ChildAssociationRef C2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C2NodeRef));
assertEquals("A2 dest is connected to the wrong node", C2Ref.getParentRef(), B1NodeRef);
}
finally
{
endTransaction();
}
mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 2
* Now transfer in A's nodes
* C2 (Dest) gets invaded by A4
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A5 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A5NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
ChildAssociationRef A5Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A5NodeRef));
assertEquals("A5 dest is connected to the wrong node", A5Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C2NodeRef));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
ChildAssociationRef A4Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A4NodeRef));
assertEquals("A4 dest is connected to the wrong node", A4Ref.getParentRef(), B1NodeRef);
}
finally
{
endTransaction();
}
/**
* Step 3. Copy A5 from C2 to C3.
* C2Dest should still be invaded by A5
* C3Dest should be invaded by A5(copy) which is now a "B/local" invader.
*/
startNewTransaction();
try
{
NodeRef copyRef = copyService.copy(testNodeFactory.getMappedNodeRef(A5NodeRef), testNodeFactory.getMappedNodeRef(C3NodeRef), ContentModel.ASSOC_CONTAINS, QName.createQName("A5 Copy 1"));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
assertTrue("A5(copy 1) is not invaded", nodeService.hasAspect(copyRef, TransferModel.ASPECT_ALIEN));
assertTrue("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
List<String> C2invaders = (List<String>) nodeService.getProperty(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.PROP_INVADED_BY);
List<String> C3invaders = (List<String>) nodeService.getProperty(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.PROP_INVADED_BY);
assertTrue("C3 invaders contains local repository Id", C3invaders.contains(localRepositoryId));
assertFalse("C3 invaders contains REPO_ID_A", C3invaders.contains(REPO_ID_A));
assertFalse("C2 invaders contains local repository Id", C2invaders.contains(localRepositoryId));
assertTrue("C2 invaders contains REPO_ID_A", C2invaders.contains(REPO_ID_A));
}
finally
{
endTransaction();
}
/**
* Step 4. Copy A5 from C2 to A4.
* C2Dest should still be invaded by A5
* A4Dest should be invaded by A5(copy 2) which is now a "B" invader.
*/
startNewTransaction();
try
{
NodeRef copyRef = copyService.copy(testNodeFactory.getMappedNodeRef(A5NodeRef), testNodeFactory.getMappedNodeRef(A4NodeRef), ContentModel.ASSOC_CONTAINS, QName.createQName("A5 Copy 2"));
assertTrue("dest node A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
assertTrue("A5(copy 2) is not invaded", nodeService.hasAspect(copyRef, TransferModel.ASPECT_ALIEN));
assertTrue("A4 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
List<String> C2invaders = (List<String>) nodeService.getProperty(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.PROP_INVADED_BY);
List<String> A4invaders = (List<String>) nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_INVADED_BY);
assertTrue("A4 invaders contains local repository Id", A4invaders.contains(localRepositoryId));
assertFalse("C2 invaders contains local repository Id", C2invaders.contains(localRepositoryId));
assertTrue("C2 invaders contains REPO_ID_A", C2invaders.contains(REPO_ID_A));
}
finally
{
endTransaction();
}
/**
* Step 5. Invade A5 dest with B6.
* Copy A5(Dest) to B1 (A5 Copy 3) no children
* B1 should not be invaded.
* A5 Copy 3 not invaded.
* B6 Copy not invaded.
*/
startNewTransaction();
try
{
ChildAssociationRef child = nodeService.createNode(testNodeFactory.getMappedNodeRef(A5NodeRef), ContentModel.ASSOC_CONTAINS, QName.createQName("B6"), ContentModel.TYPE_FOLDER);
B6NodeRef = child.getChildRef();
nodeService.setProperty(B6NodeRef, ContentModel.PROP_TITLE, "B6");
nodeService.setProperty(B6NodeRef, ContentModel.PROP_NAME, "B6");
assertTrue("A4 dest is not invaded prior to test - test error", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.ASPECT_ALIEN));
NodeRef copyRef = copyService.copy(testNodeFactory.getMappedNodeRef(A5NodeRef), B1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5 Copy 3"));
assertFalse("B1 is invaded", nodeService.hasAspect(B1NodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("A5 copy 3 is invaded", nodeService.hasAspect(copyRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 6. Invade A5 dest with B6.
* Copy A5(Dest) to B1 (A5 Copy 3) with children
* B1 should not be invaded.
* A5 Copy 4 not invaded.
* B6 Copy not invaded.
*/
startNewTransaction();
try
{
assertFalse("B1 is invaded prior to test - test error", nodeService.hasAspect(B1NodeRef, TransferModel.ASPECT_ALIEN));
NodeRef copyRef = copyService.copy(testNodeFactory.getMappedNodeRef(A5NodeRef), B1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5 Copy 4"), true);
assertFalse("B1 is invaded", nodeService.hasAspect(B1NodeRef, TransferModel.ASPECT_ALIEN));
assertFalse("A5 copy 4 is invaded", nodeService.hasAspect(copyRef, TransferModel.ASPECT_ALIEN));
List <ChildAssociationRef> refs = nodeService.getChildAssocs(copyRef);
assertTrue("can't find child of A5 copy 4", refs.size() == 1);
for(ChildAssociationRef ref : refs)
{
assertFalse("B6 copy is invaded", nodeService.hasAspect(ref.getChildRef(), TransferModel.ASPECT_ALIEN));
}
}
finally
{
endTransaction();
}
} // copy node
/**
* Test the transfer method with regard to an empty content property. ALF-4865
*
* Step 1: create a node with an empty content property
* transfer
*
* Step 2: add non empty content property
* transfer
*
* Step 3: update from non empty content to empty content property
* transfer
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testEmptyContent() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.ENGLISH;
String CONTENT_ENCODING = "UTF-8";
String CONTENT_STRING = "The quick brown fox jumps over the lazy dog.";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Fake Repository Id
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferEmptyContent";
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef savedDestinationNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node with an empty content that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, name);
ContentData cd = new ContentData(null, null, 0, null);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_CONTENT, cd);
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
transferService.enableTransferTarget(targetName, true);
}
finally
{
endTransaction();
}
SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* Step 1: Transfer our node which has empty content
*/
logger.debug("testEmptyContent : First transfer - create new node (empty content)");
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
assertNull("test setup content reader not null", reader);
Map<QName, Serializable> props = nodeService.getProperties(contentNodeRef);
assertTrue(props.containsKey(ContentModel.PROP_CONTENT));
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
Serializable modifiedDate = nodeService.getProperty(contentNodeRef, ContentModel.PROP_MODIFIED);
if(modifiedDate instanceof Date)
{
logger.debug("srcModified: " + SDF.format(modifiedDate));
}
NodeRef destinationNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
savedDestinationNodeRef = destinationNodeRef;
assertTrue("content node (dest) does not exist", nodeService.exists(destinationNodeRef));
ContentReader reader = contentService.getReader(destinationNodeRef, ContentModel.PROP_CONTENT);
assertNull("content reader not null", reader);
Map<QName, Serializable> props = nodeService.getProperties(destinationNodeRef);
assertTrue(props.containsKey(ContentModel.PROP_CONTENT));
}
finally
{
endTransaction();
}
/**
* Step 2: replace empty content with new content
*/
logger.debug("testEmptyContent : Second transfer - replace empty content with some content");
startNewTransaction();
try
{
Serializable modifiedDate = nodeService.getProperty(contentNodeRef, ContentModel.PROP_MODIFIED);
if(modifiedDate instanceof Date)
{
logger.debug("srcModified: " + SDF.format(modifiedDate));
}
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.setEncoding(CONTENT_ENCODING);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("test setup content reader not null", reader);
Map<QName, Serializable> props = nodeService.getProperties(contentNodeRef);
assertTrue(props.containsKey(ContentModel.PROP_CONTENT));
/**
* Step 2: replace empty content with new content
*/
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef destinationNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertEquals("test error destinationNodeRef not correct", savedDestinationNodeRef, destinationNodeRef);
ContentReader reader = contentService.getReader(destinationNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("content reader is null", reader);
assertTrue("content encoding is wrong", reader.getEncoding().equalsIgnoreCase(CONTENT_ENCODING));
assertEquals("content locale is wrong", reader.getLocale(), CONTENT_LOCALE);
assertTrue("content does not exist", reader.exists());
String contentStr = reader.getContentString();
assertEquals("Content is wrong", contentStr, CONTENT_STRING);
}
finally
{
endTransaction();
}
/**
* Step 3 - transition from a content property having content to one that is empty
*/
logger.debug("testEmptyContent : Third transfer - remove existing content");
startNewTransaction();
try
{
ContentData cd = new ContentData(null, null, 0, null);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_CONTENT, cd);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
assertNull("test setup content reader not null", reader);
Map<QName, Serializable> props = nodeService.getProperties(contentNodeRef);
assertTrue(props.containsKey(ContentModel.PROP_CONTENT));
/**
* Step 3: Transfer our node which has empty content to over-write existing
* content
*/
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
NodeRef destinationNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertTrue("content node (dest) does not exist", nodeService.exists(destinationNodeRef));
ContentReader reader = contentService.getReader(destinationNodeRef, ContentModel.PROP_CONTENT);
assertNull("content reader not null", reader);
Map<QName, Serializable> props = nodeService.getProperties(destinationNodeRef);
assertTrue(props.containsKey(ContentModel.PROP_CONTENT));
}
finally
{
endTransaction();
}
} // end of testEmptyContent
/**
* Test the transfer method with regard to a repeated update of content.by sending one node (CRUD).
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testRepeatUpdateOfContent() throws Exception
{
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
final String CONTENT_TITLE = "ContentTitle";
final Locale CONTENT_LOCALE = Locale.GERMAN;
final String CONTENT_ENCODING = "UTF-8";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Fake Repository Id
*/
final TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
final UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
final List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
final String targetName = "testRepeatUpdateOfContent";
class TestContext
{
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef destNodeRef;
String contentString;
};
RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
{
@Override
public TestContext execute() throws Throwable
{
TestContext testContext = new TestContext();
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_CONTENT);
testContext.contentNodeRef = child.getChildRef();
nodeService.setProperty(testContext.contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.contentNodeRef, ContentModel.PROP_NAME, name);
/**
* Make sure the transfer target exists and is enabled.
*/
if(!transferService.targetExists(targetName))
{
testContext.transferMe = createTransferTarget(targetName);
}
else
{
testContext.transferMe = transferService.getTransferTarget(targetName);
}
transferService.enableTransferTarget(targetName, true);
return testContext;
}
};
final TestContext testContext = tran.doInTransaction(setupCB);
RetryingTransactionCallback<Void> updateContentCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
ContentWriter writer = contentService.getWriter(testContext.contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.setEncoding(CONTENT_ENCODING);
writer.putContent(testContext.contentString);
return null;
}
};
RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(testContext.contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
return null;
}
};
RetryingTransactionCallback<Void> checkTransferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
// Now validate that the target node exists and has similar properties to the source
NodeRef destNodeRef = testNodeFactory.getMappedNodeRef(testContext.contentNodeRef);
ContentReader reader = contentService.getReader(destNodeRef, ContentModel.PROP_CONTENT);
assertNotNull("content reader is null", reader);
assertTrue("content encoding is wrong", reader.getEncoding().equalsIgnoreCase(CONTENT_ENCODING));
assertEquals("content locale is wrong", reader.getLocale(), CONTENT_LOCALE);
assertTrue("content does not exist", reader.exists());
String contentStr = reader.getContentString();
assertEquals("Content is wrong", contentStr, testContext.contentString);
return null;
}
};
/**
* This is the test
*/
for(int i = 0; i < 6 ; i++)
{
logger.debug("testRepeatUpdateContent - iteration:" + i);
testContext.contentString = String.valueOf(i);
tran.doInTransaction(updateContentCB);
tran.doInTransaction(transferCB);
tran.doInTransaction(checkTransferCB);
}
} // test repeat update content
/**
* Test the transfer method with regard to replacing a node. ALF-5109
*
* Step 1: Create a new parent node and child node
* transfer
*
* Step 2: Delete the parent node
* transfer
*
* Step 3: Create new parent child node with same names and assocs.
* transfer
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testReplaceNode() throws Exception
{
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
final String CONTENT_TITLE = "ContentTitle";
final String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
final Locale CONTENT_LOCALE = Locale.GERMAN;
final String CONTENT_STRING = "Hello World";
final String CONTENT_UPDATE_STRING = "Foo Bar";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*
* Fake Repository Id
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
final NodeRef guestHome = guestHomeResult.getNodeRef(0);
final String targetName = "testRepeatUpdateOfContent";
class TestContext
{
TransferTarget transferMe;
NodeRef parentNodeRef;
NodeRef middleNodeRef;
NodeRef childNodeRef;
QName parentName;
QName middleName;
QName childName;
};
RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
{
@Override
public TestContext execute() throws Throwable
{
TestContext testContext = new TestContext();
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
testContext.parentName = QName.createQName(name);
testContext.childName = QName.createQName("Ermintrude");
testContext.middleName = QName.createQName("Matilda");
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, testContext.parentName, ContentModel.TYPE_FOLDER);
testContext.parentNodeRef = child.getChildRef();
logger.debug("parentNodeRef created:" + testContext.parentNodeRef );
nodeService.setProperty(testContext.parentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.parentNodeRef, ContentModel.PROP_NAME, testContext.parentName.getLocalName());
ChildAssociationRef child2 = nodeService.createNode(testContext.parentNodeRef, ContentModel.ASSOC_CONTAINS, testContext.childName, ContentModel.TYPE_FOLDER);
testContext.middleNodeRef = child2.getChildRef();
logger.debug("middleNodeRef created:" + testContext.middleNodeRef );
nodeService.setProperty(testContext.middleNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.middleNodeRef, ContentModel.PROP_NAME, testContext.childName.getLocalName());
ChildAssociationRef child3 = nodeService.createNode(testContext.middleNodeRef, ContentModel.ASSOC_CONTAINS, testContext.childName, ContentModel.TYPE_CONTENT);
testContext.childNodeRef = child3.getChildRef();
logger.debug("childNodeRef created:" + testContext.childNodeRef );
nodeService.setProperty(testContext.childNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.childNodeRef, ContentModel.PROP_NAME, testContext.childName.getLocalName());
/**
* Make sure the transfer target exists and is enabled.
*/
if(!transferService.targetExists(targetName))
{
testContext.transferMe = createTransferTarget(targetName);
}
else
{
testContext.transferMe = transferService.getTransferTarget(targetName);
}
transferService.enableTransferTarget(targetName, true);
return testContext;
}
};
final TestContext testContext = tran.doInTransaction(setupCB);
RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
TransferDefinition definition = new TransferDefinition();
Collection<NodeRef> nodes = new ArrayList<NodeRef>();
nodes.add(testContext.childNodeRef);
nodes.add(testContext.parentNodeRef);
nodes.add(testContext.middleNodeRef);
definition.setSync(true);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
return null;
}
};
RetryingTransactionCallback<Void> checkTransferCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
return null;
}
};
RetryingTransactionCallback<Void> replaceNodesCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
// Delete the old nodes
nodeService.deleteNode(testContext.middleNodeRef);
logger.debug("deleted node");
ChildAssociationRef child2 = nodeService.createNode(testContext.parentNodeRef, ContentModel.ASSOC_CONTAINS, testContext.childName, ContentModel.TYPE_FOLDER);
testContext.middleNodeRef = child2.getChildRef();
logger.debug("middleNodeRef created:" + testContext.middleNodeRef );
nodeService.setProperty(testContext.middleNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.middleNodeRef, ContentModel.PROP_NAME, testContext.childName.getLocalName());
ChildAssociationRef child3 = nodeService.createNode(testContext.middleNodeRef, ContentModel.ASSOC_CONTAINS, testContext.childName, ContentModel.TYPE_CONTENT);
testContext.childNodeRef = child3.getChildRef();
logger.debug("childNodeRef created:" + testContext.childNodeRef );
nodeService.setProperty(testContext.childNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(testContext.childNodeRef, ContentModel.PROP_NAME, testContext.childName.getLocalName());
return null;
}
};
// This is the test
tran.doInTransaction(transferCB);
tran.doInTransaction(replaceNodesCB);
tran.doInTransaction(transferCB);
tran.doInTransaction(checkTransferCB);
} // test replace node
// /**
// * Test the transfer method with regard to obscure paths.
// *
// * This is a unit test so it does some shenanigans to send to he same instance of alfresco.
// */
// public void testHorriblePaths() throws Exception
// {
// setDefaultRollback(false);
//
// final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
//
// final String CONTENT_TITLE = "ContentTitle";
// final String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
// final String CONTENT_NAME = "Demo Node 1";
// final Locale CONTENT_LOCALE = Locale.GERMAN;
// final String CONTENT_STRING = "The quick brown fox";
// final Set<NodeRef>nodes = new HashSet<NodeRef>();
//
// final String targetName = "testManyNodes";
//
// class TestContext
// {
// TransferTarget transferMe;
// NodeRef nodeA = null;
// NodeRef childNode = null;
// };
//
// /**
// * Unit test kludge to transfer from guest home to company home
// */
// final UnitTestTransferManifestNodeFactory testNodeFactory = unitTestKludgeToTransferGuestHomeToCompanyHome();
//
// TransferTarget transferMe;
//
// final QName[] difficult = { QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeB"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"with.dot"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"8332"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"&#~@"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"_-+ )"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"with space"),
// // A, e with accent
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "\u0041\u00E9"),
// // Greek Alpha, Omega
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "\u0391\u03A9")
// };
//
// RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
// {
// @Override
// public TestContext execute() throws Throwable
// {
// TestContext ctx = new TestContext();
//
// /**
// * Get guest home
// */
// String guestHomeQuery = "/app:company_home/app:guest_home";
// ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
// assertEquals("", 1, guestHomeResult.length());
// NodeRef guestHome = guestHomeResult.getNodeRef(0);
//
// /**
// * Create a test node that we will read and write
// */
// String guid = GUID.generate();
//
// /**
// * Create a tree with "difficult" characters in the path
// * ManyNodesRoot
// * A (Folder)
// * ... childNode
// */
// ChildAssociationRef child;
//
// child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(guid), ContentModel.TYPE_FOLDER);
// NodeRef testRootNode = child.getChildRef();
// nodeService.setProperty(testRootNode , ContentModel.PROP_TITLE, guid);
// nodeService.setProperty(testRootNode , ContentModel.PROP_NAME, guid);
// nodes.add(testRootNode);
//
// child = nodeService.createNode(testRootNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeA"), ContentModel.TYPE_FOLDER);
// ctx.nodeA = child.getChildRef();
// nodeService.setProperty(ctx.nodeA , ContentModel.PROP_TITLE, "TestNodeA");
// nodeService.setProperty(ctx.nodeA , ContentModel.PROP_NAME, "TestNodeA");
// nodes.add(ctx.nodeA);
//
// NodeRef current = ctx.nodeA;
//
// for(QName name : difficult)
// {
// child = nodeService.createNode(current, ContentModel.ASSOC_CONTAINS, name, ContentModel.TYPE_FOLDER);
// current = child.getChildRef();
// nodeService.setProperty(current , ContentModel.PROP_TITLE, name);
// nodeService.setProperty(current , ContentModel.PROP_NAME, "testName");
// nodes.add(current);
// }
//
// child = nodeService.createNode(current, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeAC"), ContentModel.TYPE_CONTENT);
// ctx.childNode = child.getChildRef();
// nodeService.setProperty( ctx.childNode , ContentModel.PROP_TITLE, CONTENT_TITLE + "AC");
// nodeService.setProperty( ctx.childNode , ContentModel.PROP_NAME, "DemoNodeAC");
//
// {
// ContentWriter writer = contentService.getWriter( ctx.childNode , ContentModel.PROP_CONTENT, true);
// writer.setLocale(CONTENT_LOCALE);
// writer.putContent(CONTENT_STRING);
// nodes.add( ctx.childNode);
// }
//
//
// /**
// * Now go ahead and create our first transfer target
// */
// if(!transferService.targetExists(targetName))
// {
// ctx.transferMe = createTransferTarget(targetName);
// }
// else
// {
// ctx.transferMe = transferService.getTransferTarget(targetName);
// }
//
// return ctx;
// }
// };
//
// final TestContext testContext = tran.doInTransaction(setupCB);
//
// RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
//
// @Override
// public Void execute() throws Throwable
// {
// TransferDefinition definition = new TransferDefinition();
// definition.setNodes(nodes);
// transferService.transfer(targetName, definition);
//
// return null;
// }
// };
//
// tran.doInTransaction(transferCB);
//
// RetryingTransactionCallback<Void> check1CB = new RetryingTransactionCallback<Void>() {
//
// @Override
// public Void execute() throws Throwable
// {
// NodeRef destChildNode = testNodeFactory.getMappedNodeRef(testContext.childNode);
// assertTrue("dest node does not exist", nodeService.exists(destChildNode));
//
// /**
// * Step through source and dest trees on nodes comparing the path as we go.
// */
// Path srcPath = nodeService.getPath(testContext.childNode);
// Path destPath = nodeService.getPath(destChildNode);
//
// int srcSize = srcPath.size();
// int destSize = destPath.size();
//
// Path dest = destPath.subPath(2, destSize-1);
// Path src = srcPath.subPath(3, srcSize-1);
//
//// System.out.println("src=" + src);
//// System.out.println("dest=" + dest);
// assertEquals("paths are different", src.toString(), dest.toString());
//
// return null;
// }
// };
//
// tran.doInTransaction(check1CB);
//
// RetryingTransactionCallback<Void> updateCB = new RetryingTransactionCallback<Void>() {
//
// @Override
// public Void execute() throws Throwable
// {
//
// return null;
// }
// };
//
// tran.doInTransaction(updateCB);
//
// tran.doInTransaction(transferCB);
//
// RetryingTransactionCallback<Void> check2CB = new RetryingTransactionCallback<Void>() {
//
// @Override
// public Void execute() throws Throwable
// {
// assertTrue("dest node does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(testContext.childNode)));
//
// return null;
// }
// };
// tran.doInTransaction(check2CB);
//
// } // horrible paths
private void createUser(String userName, String password)
{
if (this.authenticationService.authenticationExists(userName) == false)
{
this.authenticationService.createAuthentication(userName, password.toCharArray());
PropertyMap ppOne = new PropertyMap(4);
ppOne.put(ContentModel.PROP_USERNAME, userName);
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
this.personService.createPerson(ppOne);
}
}
private DescriptorService getMockDescriptorService(String repositoryId)
{
DescriptorService descriptorService = mock(DescriptorService.class);
Descriptor descriptor = mock(Descriptor.class);
when(descriptor.getId()).thenReturn(repositoryId);
when(descriptorService.getCurrentRepositoryDescriptor()).thenReturn(descriptor);
return descriptorService;
}
}