mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
25384: ALF-5352 - user usages - re-apply r19862 (ALF-713 fix) that was lost (probably due to merge conflict) 25440: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25232: ALF-4300: DB2: Review schema (eg. VARCHAR columns) with respect to multi-byte support (when using DB2 / UTF-8) 25371: ALF-4300: DB2: Review schema (eg. VARCHAR columns) with respect to multi-byte support (when using DB2 / UTF-8) - All VARCHAR fields quadrupled for DB2 relative to MySQL to support UTF-8 character sets - ‘varchar-field-sizes-quadruple-increasing.sql’ introduced by patch - Minor conflict anticipated on AlfrescoSchemaUpdate-2.1-A--to--2.2-ACL.sql; ensure larger column size is kept. - Schema number now at 4201. 25444: Fix ALF-6689: WQS: Incorrect work of email field on contact page Fix ALF-7058: WQS: Blog article page of custom type gives an error 25447: Fix ALF-5198: WQS: Error while Name field filled with more than 70 characters or special characters 25506: ALF-6281: Actions for folder do not work (Quickr connector plug-in) 25534: ALF-646: Alfresco Logo isn't displayed in SPP Open window 25590: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25582: ALF-6282: Incorrect behavior of Propertiesa - Add "Created", "Modified" and "Label" tags to document/folder entries in AlfrescoAtomBasedFeedServiceImpl.createEntry() 25595: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25592:ALF-7194: Saving a Excel file with CIFS reset permissions. - Copy value of "Inherit Parent Space Permissions" flag to the new node in ContentDiskDriver.cloneNode() method. 25635: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25574: ALF-6288: Action 'Send Link' is not worked 25616: ALF-6288: Action 'Send Link' is not worked - AlfrescoQuickrPathHelper.getNodePath() method was modified to return full node path, e.g. "/Company Home/Sites/TestSite/documentLibrary/test.odt". - AlfrescoQuickrPathHelper.removeSlashesAndRoot(String value) method was renamed to AlfrescoQuickrPathHelper.resolveNodePath(String path, boolean isRelative). 25638: Merged DEV/TEMPORARY to V3.4-BUG-FIX (with feedback from Gary) 25376: ALF-684: Ftp requests to the IPv6 resolved hostname are failing The ftp.ipv6.enabled property was removed, and a ServerSocket is opened without InetAddress parameter. It allows Java to determine if a IPv6 is used and bind "::" any local address to the server socket. It allows to connect to the Alfresco FTP using both IPv4 and IPv6 addresses regardless to server OS. 25639: ALF-5115: Removed circular dependency from non-continuous builds - No need to use -f continuous.xml anymore when building enterprise or community - Added assemble-command-extras stub to community build.xml, overridden by enterprise build.xml and called by continuous.xml 25699: MERGE DEV to V3.4-BUG-FIX ALF-5745 : AVMTemplateNode d:date properties are wrong. 25770: Investigation tests for ALF-6904: Wrong behaviour when overriding a constraint in content model 25774: Fixed ALF-7193: XAM Connector: xam.archive.nodePropertiesToWrite must not make properties mandatory - The property had to be set to null - achievable because it is MLText - Added full d:mltext expansion - Added double checks for nulls creeping in 25851: Fixed ALF-7381: OOM when Debug logging on ReferenceCountingReadOnlyIndexReaderFactory - Use a WeakHashMap 25853: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25852: ALF-6373: Preview isn't generated for content added by quickr Added AlfrescoQuickrDocumentHelper.getMimeType(NodeRef fileRef) method that resolves the mime type using the node name. Set the mime type of nodes created in AlfrescoDocumentServiceImpl and AlfrescoAtomBasedFeedServiceImpl. 25860: Resolve ALF-7286: CMIS UP link for document doesn't contain all parents 25866: Fix for ALF-6312 - moved configuration to the correct file to be picked up by Spring Surf 25870: Merged DEV/TEMPORARY to V3.4-BUG-FIX 25840: ALF-6279: Failed to save properties in Symphony documents. AlfrescoDocumentServiceImpl.setDocType() method was modified to check for existence of document type in provided ClbDraft object. 25908: Set 3.4.2 revision 25931: Fix for ALF-6565: Explorer UI allows duplication of Replication targets which in effects breaks Alfresco 25987: DOC-238: Sharepoint (VTI) Protocol Configuration Documentation is outdated - have added comments in the properties file to indicate what they do 25994: WQS: Added a little more information to the log message when a 404 is returned 26003: ALF-7663: NPEs when using PermissionService with AVM stores - added unit tests for regression testing - no longer an issue 26004: ALF-7662: AVM permissions - access denied exception when trying to create file in a layered directory, when no explicit permissions set (on root dir node) - test passes on 3.4.2 - updated test to reflect 2.1 state 26011: ALF-6372 Now when the package manager adds items to a package it does not mark the items as modified. 26026: ALF-6350: Add support for Ideographic Space to the Full Text Search - - added full set of Unicode characters for letters and digits (0x0000 - 0xFFFF) - added fill set of Unicode whitespace - class to generate Unicode types -> ranges - upgraded antlr to 3.3. (required to resolve 3.2 bug) - fixed Lexer and parser test - much still depends on the tokeniser .... 26048: Fix for ALF-7507 - Manage Deleted Items - Recover All Icon Missing 26050: Fixed failing tests WorkflowFormProcessorTest and TaskFormProcessorTest. 26068: Resolve ALF-7342 - dynamic Models - unable to add new properties to an aspect if the aspect is a mandatory aspect of another aspect 26082: WQS: Improved debug-level logging to track WQS-to-repo interaction better. 26094: Some formatting 26095: Fixed ALF-7531: alfresco.jgroups.bind_interface is not taken into account - Added 'bind_interface' property to TCP config - Value injected into system properties: alfresco.jgroups.bind_interface 26130: Fix for CIFS multitenancy not working. ALF-6816. Need to search the global share list for admin named pipe shares. 26131: Fix for CIFS cut/paste write-protected error. ALF-1822 26132: Solairs/NFS ReadDir issue, cannot list folder more than once. ALF-5386 Search resume id/cookie value of zero has special meaning for NFS. 26133: Changed FTP return status for MKD command to 257, for RFC compliance. ALF-7501. 26136: Fix for FTP CWD-MKD-CWD sequence failing. ALF-7530 Trim filesystem path to make sure there is no trailing backslash. 26144: Merged V3.4 to V3.4-BUG-FIX 25890: Fix for ALF-5796 - It's impossible to add tag in Japanese language (IE specific) 25891: Fixes: ALF-7363 (updated JA translation) 25894: Fixed Legal and License url in About dialog 25896: ALF-6476 -translation on Transfer Target configuration 25899: First cut of French transfer properties. Mostly English! but has 3 lines of French. 25900: Fix for ALF-6916: More Deployment Reports action causes an error 25901: Fixes: ALF-6847 (Italian Translation) 25902: Fixes: ALF-6861 (incorrectly encoded German character) 25904: Fixes: ALF-6755 (translation quoting error) 25911: Fixes: ALF-6478 - French translation correction 25913: Fixes: ALF-6334 and ALF-6477 (Profile Edit style issues - makes mark up consistent, clears floats to allow for foreign languages being a tad more verbose than English and adjusts padding to help input boxes line up. 25914: Help URL for 3.4 enterprise docs 25915: Updates TinyMCE translation as requested in ALF-6486. 25916: Updated support URL in readme 25917: Fixes: ALF-6482, wrong word order in FR has been corrected. 25919: Fixes: ALF-6655 updated to allow enough space for verbose languages (e.g. FR, ES) 25925: Fix for ALF-6885: alfresco-enterprise-3.4.0.zip package has 2 issues with apply_amps.sh 25936: ALF-6469 - transfer folders internationalized 25941: Merged BRANCHES/DEV/dwebster/ to BRANCHES/V3.4: 25939: Latest JA update from Translators, received: 2011-02-28 25943: Merged BRANCHES/DEV/dwebster/ to BRANCHES/V3.4: 25942: Language updates for property string changes and additions between 3.4.0 and 3.4.1 25946: ALF-7191: Generate duplicate _en resource bundles, using location of _fr bundles as a guide for ALL bundles under alfresco and share WEB-INF/classes 25947: ALF-7191: Reverse accidentally committed changes to WebDAV in 25946! 25949: Fixes: ALF-6521 and ALF-6493 (Site discussion's handling of tags with special characters in them) 25950: Fixes: ALF-6489 - encodes the content's name to make it safe for a URL. 25951: Fixes: ALF-6487 Adjusts styling for rename panel 25954: ALF-7191 - Generate _en bundles for all message bundles for Explorer and Share - using known location of message bundles 25956: Allow a bit of leeway with audit timing during delete tests 25957: Fixed ALF-7341: Upload performance degradation when uploading contents to folders with content rules applied. - Action executions were being recorded by the ActionTrackingService for all actions - Post-commit updates of the action node was reducing performance - Added 'trackStatus' to ActionExecuter, ActionDefinition and Action - Default 'trackStatus' is false; exceptions: 'replicationActionExecutor' and 'commit-transfer' - Adjusted tests accordingly - General cleanup around modifications 25964: ALF-5625 - When viewing properties in version history hitting close results in loop 25970: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/V3.4: 25967: Fix ALF-7440: WQS: commons-pool library has been upgraded, but WQS build properties have not been changed accordingly 25971: ALF-7441: Help URLs pointing to new doc system (1 of 2) 25972: ALF-7441: Help URLs pointing to new doc system (2 of 2) 25974: Reverted rev 25964 - as fix is scheduled for 3.4.2 25979: Disabling intermittent failing unit test. ALF-7443 logged. 25980: Merged V3.4-BUG-FIX to V3.4 25978: ALF-7394 - Alfresco Network dashlet, now Alfresco Support information 26014: ALF-7087 - Cannot override webscript files in case of using jboss 5.1GA 26024: ALF-7466 - Links do not appear correctly in the management Console (RM) 26036: ALF-6403: Merged V3.4 to V3.4 (lost revision) 25627: Fixes ALF-7222: Updated linux installer window height (with taller image to hide additonal background) 26039: Fix intermittent failures in InviteServiceTest.tearDown() 26040: Fix intermittent failures in InviteServiceTest.setUp() 26043: Sync up run-junit-test with junit macros so that it can be used to run unit tests in an enterprise environment (e.g. DB2 / Oracle) 26044: Possibly fix intermittent TransferServiceImplTest failures by using org.alfresco.repo.transaction.RetryingTransactionInterceptor 26052: Do not wait indefinitely for a heartbeat in HeartBeatTest. A broken heartbeat would cause the build to hang forever! 26056: Merged V3.4-TEAM to V3.4 26053: Added in loop to wait for asynchronous post-failure auditing (ALF-3055) 26077: Upped LOGFILSIZ to avoid failures in unit tests with large transactions on DB2 26084: Avoid intermittent test failures in AbstractTestFormRestApi by using retrying transactions 26096: Correction to DB2 drop / create commands 26097: Fixes: ALF-7102, typo in property string. 26100: Merged V3.4-TEAM to V3.4 25985: Another cycle of fixing installer from Win builds. Still waiting for official fix from Bitrock. 26067: Fixes for installer builds on Windows 26102: Attempt to avoid intermittent failures in TaggingServiceImplTest by upping wait time 26109: Another go at executing the db2 creation statements synchronously through db2cmd 26111: ALF-6764 - Copyright year on Share login page out of date 26127: Merged V3.4-TEAM to V3.4 26120: Fix postgres.bki on Win builds 26142: Merged PATCHES/V3.4.0 to V3.4 25999: ALF-7377: Validate and reject partial WebDAV requests sometimes produced by NetDrive 26145: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 26143: Merged PATCHES/V3.4.0 to V3.4 26005: Merged V3.4-BUG-FIX to PATCHES/V3.4.0 26002: ALF-7282 Updated NodeListConverter so that it now implements the method revert(Object, ProcessDefinition) 26153: Fix for CIFS concurrent folder listing returns wrong list of files. ALF-6385. Synchronize the VirtualCircuit.allocateSearchSlot() method and put a marker object in the allocated slot so it does not get reused before the real search is put into the slot. 26156: Merged /BRANCHES/DEV/BELARUS/V3.3-2010_12_20 to BRANCHES/DEV/V3.4-BUG-FIX: 24902: ALF-5985: Users with an apostrophe in their username cannot cancel their own workflow no action button shown 26177: ALF-6686 - DOCLIB - add 'add-default-resource' as enhancement. 26181: Fix for ALF-7179 - NPE on Check in action when define lockable aspect as mandatory. 26182: ALF-3145 - Caller of CopyBehaviorCallback.getCopyProperties should ensure modifiability of properties map - Copy Service was already done. Merged similar changes to CopyBehaviourCallback. 26185: ALF-7238 - Value for $fieldHtmlId changes after metadata refresh 26196: Fixed ALF-3383: range slider does not honor xs:fractionDigits 26202: ALF-6947: RM LOV Constraint values are not returned in alphabetic order * RM list of values are now shown in the UI as ordered * this can be overridden in the constrant definition but isn't exposed in the admin UI 26206: Fixed ALF-6538 "My Tasks Dashlet needs to use Page URL" (code contribution from Jeff Potts) 26211: Fixed ALF-1289 "Search for groups on "Add Group" form works incorrectly" 26213: Fixes ALF-6697: Updates to flash and html uploaders to prevent files named with (Windows) illegal characters from being uploaded 26220: Fixed CopyServicePolicies javadoc 26221: Fixed ALF-4926: Incorrect behavior of update and move rule for the same folder - Pulled rule-specific code out of FileFolderService - Added detection for new nodes and renamed nodes in current transaction - New nodes will only fire inbound properties, renamed nodes won't fire outbound, etc - Added in coverage tests: - testCheckThatModifyNameDoesNotTriggerInboundRule - testCheckThatModifyNameDoesNotTriggerOutboundRule - testUpdateAndMoveRuleOnSameFolder - Requires regression tests of ALF-4846 and rule-based test cases - Inbound, update and outbound have to be respected for all clients 26222: Confirmed 3.4 fix presence for ALF-5001: cm:name uniqueness check can fail if the property is not set - Unit test the condition - Checked that code now uses the node UUID as a cm:name substitute 26228: Test fix after rev 25770 for ALF-6904 26232: Fixes ALF-6697: Improved error handling for HTML uploader 26236: Fixes ALF-6697: Re-use forms validation logic 26237: Build fix for lexer tests (character encoding issues on build box + using unfixed antlr test environment for one test) 26244: Merged BRANCHES/DEV/BELARUS/V3.3-2011_01_18 to BRANCHES/DEV/V3.4-BUG-FIX: (with modifications) 25071: ALF-1846: Workflow validation is not perfomed when tasks progression are requested 26259: Fix for ALF-7520: Upgrading from "old permission model" to "new permission model" (DmPermissionsPatch) - include generic patch to fix up permission inheritance issues Probable work around for ALF-7453: ACL Propagation issue for large number of users/ACLs 26276: Unit test fix for ALF-4926: Incorrect behavior of update and move rule for the same folder - Content update trigger now ignores nodes that are created in the same transaction 26277: Fix for ALF-7636, the onLoggedOut function was being called directly rather than an event being triggered, which made it impossible for plugins to use the event. 26278: Fix ALF-7568: Thumbnails should not go into the trash can - For 3.4: Just the content model setting for cm:thumbnail - Relates to TEAM rev 25038 26283: If we're not doing action tracking during execution and completion, then don't do the pending step either (ALF-7341) 26284: ALF-5998 - German language pack error in Explorer - Incorrect layout of Manage Task button in My tasks component in alfresco explorer 26285: Hopefully avoid intermittent failures caused by either slow machines (by ensuring locks are held during slow execution), and fixing up the action tracking parts of the test (broken by ALF-7341 changes) 26286: ALF-5889 - Italian translation errors in Explorer and Share - Aspects 26299: Fixed ALF-6289 "Contributor is absent in Permissions section at the details page" 26305: ALF-7264 - Improve error messages when there are no valid email addresses to send an email too (avoids a null pointer, instead gives a helpful one), and also a provisional fix for @localhost email validation (pending a proper fix via VALIDATOR-292) 26308: ALF-6073 - *.docx document is displayed on all views (Document List portlet) 26309: ALF-7532 - Content Rule on RM site (other than Folder) creates 'GUID' folder in Share Note: Fixed on Team, but along with many other unrelated fixes; hence not merged directly. 26311: Fixed ALF-7162: Bulk import NPE 26317: ALF-5560 - Incorrect behaviour on import. RM FilePlan now tolerates (but does not render) non-RM content which was causing the original issue. 26318: Fixes ALF-7321: Ensure that WCM and Share groups don't appear as options in Repository web-client start workflow wizard for group and pooled review workflows 26327: Merged V3.4 to V3.4-BUG-FIX 26158: Merged DEV/TEMPORARY to V3.4 26154: ALF-7571: Create Web Project wizard - Step 3 Superfluous “cellpadding” elements were removed. Missing space was added. 26164: ALF-6885: Changed svn:eol-style from native to LF for all .sh scripts 26165: Merged V3.4-TEAM to V3.4 26161: Fix full installer. 26178: Merged DEV/TEMPORARY to V3.4 26172: ALF-7601: 3.4.1 SDK WebServiceSamples multiple problems Configuration properties for WebServiceSamples was moved to correct place. Dependency to SDK AlfrescoEmbedded was added to classpath. It is required for FileCopyUtils from Spring which is used in WebServiceSamples. 26190: Reversed 26165 / 26161 - breaks installer building 26192: Convert TaggingServiceImplTest to use retrying transactions! 26194: ALF-7045: AVM upgrade - re-implement AVM "rename duplicates" patch as a DB upgrade script 26195: Update installer overlay files 26197: Final installer updates - built and tested on OSX 26199: Allow relocatable data for postgres - part2 26204: Attempt to avoid intermittent unit test failures in RecordsManagementAuditServiceImplTest by adding some Thread.sleep() calls to allow for asynchronous audit behaviour 26207: Set site notification to false on install (ALF-6181) 26212: Merged DEV to V3.4 26203: ALF-7605 PostgreSQL: Upgrade from 2.1.7 to 3.4.1 is failing - constraint "alf_access_control_entry_acl_id_key" does not exist 1. The statements which are drop constraints, marked as optional 2. The alter statements with new constraint names were added 26245: Added OOo port number configuration 26256: Fixes ALF-7679: Remove webscript-framework-config-custom.xml file 26270: License updates from Ashutosh 26274: Fix intermittent unit test failure with retrying transaction 26275: Possible fix to intermittent test failure. 26295: Reduce scope of retrying transaction, in a hope of fixing TaggingServiceImplTest.testOnStartupJob() 26303: And the prize for the largest number of retrying transactions in a single unit test goes to... 26307: Fixes: ALF-7704: Japanese language option not appearing in dropdown box on log in page. 26314: Another defensive sleep() in RecordsManagementAuditServiceImplTest 26325: Moved defensive sleep() in RecordsManagementAuditServiceImplTest 26329: Resolved merge issue in TaggingServiceImplTest 26332: ALF-7499: DOD5015 PublishUpdatesJob is not resilient to missing nodes 26337: Build fix - Added checks for new "sorted" parameter on ListOfValuesConstraint 26338: ALF-6004 - Verisonable aspect applied to content in Web Quick Start does not result in version information being exposed 26341: ALF-5394 Fixed issue where pooled actors (users not groups) were not working properly. 26352: Removed svn:mergeinfo 26357: ALF-5369: Disposition errors when importing FilePlan which includes custom event * missing events are now created with the information available * prevents exception when browsing imported file plan * TODO make sure sufficient information is stored in the export file so that events missing can be correctly recreated 26358: Found and fixed javascript error/bug when date-picker was used in form w read-only="true" 26360: Fixed ALF-5980 "Language pack errors in Share - Incorrect layout on Manage permissions page" 26362: Fixed ALF-5894 "Italian language pack in Share - Incorrect layout of My Profile dashlet" 26367: MERGE SWIFT to V3.4 BUG-FIX for ALF-5125 word offfice 2007 creates permanent temporary files on 3.2.2.1, and possible wrong ownership 26001 26081 26208 26216 26261 26315 26339 26370: MERGE DEV To V3.4-BUG FIX 26342 : ALF-5125 - word office 2007 creates permanent temporary files on 3.2.2.1, and possible wrong ownership 26382: Using predefined statics and neatening 26387: ALF-4101: Blog Archive filter has duplicate dates 26396: Fix for ALF-7834: CLONE -ACL Propagation issue for large number of users/ACLs - final part of fix for locking ACL changes (avoid simultaneous changes to the ACEs associated with an ACL) 26397: ALF-7823 - CIFS shuffle looses "mime type" of attachment. ALF-7670 - MS Word 2003 'Save As' to CIFS in a folder with a rule 'extract common metadata' does NOT extract the metadata 26398: Fixed ALF-6384 "Share - 'Insert Image Library' function in WIKI not working properly in IE8" 26407: Merged V3.4-2010_11_29 to V3.4-BUG-FIX 24159: ALF-413: Incorrect notification is displayed on Manage deleted items page when deleting an item that is already recovered 26412: Fix for ALF-4400: Share Search - Not Finding Document When Search Uses More Than One Tag in the Search Criteria - added TAG field - UI no longer has to do ugly query build and TAG is part of the default macro - Fixed unreported AND OR precedence issue and added grouping 26424: Fix for ALF-7795: Greater than (>) operator does not work with untokenised String properties in CMIS Query - fixed with issues will be resolved in SOLR/SWIFT - any term starting with { (used to encode locale) will be excluded from the range. - range queries not supported for urls .... 26449: Fixed ALF-5385 "Unable to edit groups on ts.alfresco.com" 26454: Fix for ALF-7852: Query consuming all heap and receiving an OOM exception - missing close on TermDocs and TermPositions 26460: ALF-634, ALF-7103 Externalized the JBPM Config location, so it can now be set as a property in repository.properties. 26470: Fixed ALF-7744: Ensure that new options.limit gets set when updating RSS feed results 26479: ALF-6533 - GROUP_EVERYONE is a special group, so when looking up the members to send an email, we need to call a different authority service method to get everyone 26484: ALF-7715 - Switch from the old Ant ZipFile to the new Commons Compress one, which supports the new file encoding zip extension 26488: ALF-7192 - Invitation code should support subtypes of Site in addition 26489: ALF-7192 - Update the Browse Bean and Site Aspect policy to support subtypes of Site 26493: ALF-7192 - When handling permissions and roles on sites, allow for sites which are a subtype of the default site type, rather than only supporting SiteModel.TYPE_SITE. (Unit test to follow) 26499: Fixes ALF-6415: Ensure that labels on installer radio buttons doesn't flow outside the window 26511: Merged DEV to V3.4-BUG-FIX 26406: ALF-7680: Check out of document allows users to create Working-Copy into Spaces where they do not have write access - Unit tests for ALF-7680 and ETHREEOH-535 were added. 26442: ALF-7680: Check out of document allows users to create Working-Copy into Spaces where they do not have write access - If destination folder for working copy is the same as the parent folder of the source node then working copy should be created even if the user has no permissions to create children in the parent of the source node. The following logic was added for Check Out operation to apply it: - if the target folder node is the same as the parent folder of the source document then working copy is created using 'System' user - if the target folder is a different parent, then working copy is created using current user. 26515: Partially fixes ALF-5774: Set correct Japanese date formatting on Repo Web Client summary panels 26529: Fix for ALF-6722 MT: Cancel workflow button isn't available for tenant users 26533: Fixed ALF-6563: Can't properly expose categories or associations on AWE forms 26534: Added correct source files for jbpm-jpdl-3.3.1 26535: Updated disabled testAsynchronousTaskExecutes as part of investigation into ALF-6405 26537: Fixed ALF-7927: Script error on Step 3 of Create Web Project Wizard - IE6/IE7 26540: ALF-7192 - Add unit test for custom site type 26559: Merged DEV to V3.4-BUG-FIX 26547: ALF-7528 : JSF - Edit online with Office 2010 causes the document mimetype to be lost - PutMethod was modified to use only guessed mime type for documents and completely ignore the Content-Type header from client. 26560: Fixes ALF-7931: Ensure checkboxes render correctly in IE6 for forms and replication job 26565: ALF-7232 - remove temporary (unit test) debug from log4j.properties 26566: Add a couple more site service checks for roles 26568: Fixes: ALF-7950 - escaped apostrophe 26576: Fix for: ALF-7996: Error when applying patch.fixAclInheritance - removed having clause for nasty where clause - hopefully optimised out .... 26580: Fixed ALF-7915 "Cannot delete rules created with check-in perform action." 26591: ALF-7995 - Repo tier web script get dataLists returns rule folder. Also fixed incorrect folder path rendering on non-Site rules page and removed reference to non-existent file. 26598: Add notes on if Transformers can be converted to Tika or not, and if not why 26601: Fixed ALF-7804: XAM: Long paths cause 'org.snia.xam.InvalidArgumentException' when XAM aspect is applied - Path-generation truncates the first characters to leave only 512 in the path - Added catch and WARN on failure to write properties to XSet (rather than fail) - Added log4j config for XAM 26603: Fixes: ALF-868 - IE Bug. 26604: Fixes: ALF-6486 - L10N bug in width of TinyMCE's dropdown lists not accommodating longer phrases in other languages. Width is now fluid 26606: Fixes: ALF-7397 - Removed repeated chars in JA dates that include long names for days of the week. 26611: Upgrade POI and Tika for ALF-7959 26612: Add test file from ALF-7959, tweaked to include the "Quick" text, and with the original user details munged 26613: Fix up unit tests after Tika upgrade for ALF-7959 26618: ALF-7959 - Convert the Outlook MSG text converter to using Tika, which fixes encoding problems 26628: Merged PATCHES/V3.1.2 to V3.4-BUG-FIX 26626: Merged DEV/TEMPORARY to PATCHES/V3.1.2 26400: ALF-607: Rules not firing on subspaces Execute RuleServiceImpl. getRules(), RuleServiceImpl. getOwningNodeRef(Rule) and RuleServiceImpl. getOwningNodeRef(Action) methods from System User. 26630: Merged HEAD to V3.4-BUG-FIX 26620: Modified to allow for multiple mime-types for Alfresco 3.3+. Related to ALF-4027. 26629: ALF-4027: Kofax Binaries corresponding to 26620 26650: Merged SWIFT to V3.4-BUG-FIX 26093: Workaround to the fact that the Solr classpath has got too large to include on a Windows command line! (32K) 26683: ALF-8045: VersionableAspect now properly resolves the namespaces of the QNames registered with excludedOnUpdateProps 26684: Resolve ALF-7515: CMIS operation getObjectRelationships() is not spec compliant 26689: Change the status code for the CIFS Trans2QueryPath response when the file does not exist. Possible fix for ALF-6727. 26691: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26681: ALF-1871: FileLink and FolderLink items do not appear in WebDav Modify PropFindMethod to show file/folder links and return href of original node. Modify GetMethod to allow browser deal with file/folder links. 26692: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26558: ALF-7910: It's impossible to delete folder with accentuated letter via IMAP from Outlook 2010 Call "AlfrescoImapFolder sourceNode = getFolder(user, oldMailboxName);" before decoding oldMailboxName in ImapServiceImpl.renameMailbox() method. Update JavaDoc in AlfrescoImapService. Add testRenameAccentedMailbox() test. 26693: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26544: ALF-7911: Cannot contribute via IMAP if another user with only Consumer permissions has logged in first Dynamically check readOnly in AlfrescoImapFolder.isReadOnly() method. 26694: Merged DEV/TEMPORARY to V3.4-BUG-FIX (with corrections) 26343: ALF-6945 Failed Kerberos SSO auth returns HTML web page with wrong text/plain MIME type Setting content-type to text/html added for page used for failed Kerberos and NTLM authentications. 26695: Resolve ALF-7538: CMIS AtomPub: Not possible to retrieve associations defined via an Aspect. 26696: ALF-6132: Correction to handling of optional elements by Pavel 26701: Fixes ALF-8064: Ensure Windows installer respects manual service startup selection 26706: Resolve ALF-7759: MTOM is not enabled for all CMIS Web Services 26713: Resolve ALF-7994: Custom behavior is not triggered when creating content via CMIS 26717: Resolve ALF-6848: CMIS Rest: Properties Filter Parameter incorrectly functioning. 26720: Fix ALF-7977: Webform validation on change is always passing 26726: ALF-7086: Root folder has wrong Allowable Actions 26727: Resolve ALF-6266: Incorrect exception thrown when deleting a non-existing document (web-services binding) 26728: WQS: Performance enhancements. Local max throughput increased from 11 PIs/sec to 24 PIs/sec with 15 concurrent users (CPU utilization dropped from 100% to 70%) 26729: ALF-8045: Fix VersionServiceImplTest 26735: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26725: ALF-3919 : WCM - JSF does not return an appropriate warning when creating content with ' ; ' character 1. The AVMNodeConverter class was modified to allow ';' character usage in web content names. 26736: Merged V3.4 to V3.4-BUG-FIX 26411: Fixes: ALF-7292 and ALF-7289, removes "· " from after Web and before Alfresco. 26413: Fixes: ALF-7765 - ensures naming consistency 26414: Fixes: ALF-7697 - Rewording the URL help text on the create site dialogue 26417: Fixes: ALF-7414, confused and hardcoded date-formatting & date formatting translations fixed. 26610: Fix for: ALF-8007: Lucene index not coherent or not up to date or we can not rely on it to check that a working copy exist. 26739: ALF-8085 - DMDeploymentTarget uses System.out 26748: ALF-7929: Script error on Web Form Details window - IE6/ IE7 - Fix up to CHK-10095 reviewed by Kev 26749: ALF-7557: Display full paths of categories in Explorer (reviewed by Kev) 26751: ALF-8079: NPE in ContentDiskDriver 26754: Fixes: ALF-2984. parseInt octal bug, so forcing dec. 26761: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 26760: Merged V3.4-BUG-FIX to V3.4 26759: Merged V3.4-BUG-FIX to V3.4 (3.4.2) 26762: ALF-8028 ResultSet not closed in TransferServiceImpl2 try...finally pattern was added to search operation. 26764: Further fixes to teh patch for: ALF-7834: CLONE -ACL Propagation issue for large number of users/ACLs 26765: ALF-634, ALF-7103: Possible fix to JBPM regressions introduced by r26460 26788: Further fixes to the patch for: ALF-7834: CLONE -ACL Propagation issue for large number of users/ACLs - fix type that would have missed a minor error (for unused shared ACLs) 26815: ALF-5500: Support site subtypes in SPP 26863: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26853: ALF-3792: Copy Access Should Be More Restrictive Checking permissions for “Copy” was added action. Security settings for FileFolderService.copy operations were made more strict for Alfresco and RM. 26890: Merged HEAD to V3.4-BUG-FIX 26856: Fixed ClientInfo is null in sessionLoggedOn event. JLAN-121. 26867: Fix for wildcard search handling returning dot and dot-dot file entries. ALF-4960. 26868: Fix for wildcard search handling returning dot and dot-dot file entries, repo filesystem. ALF-4960. 26888: CIFS path broken when ß (German sz) char is in folder name. ALF-7186. 26909: AVMRepository: add missing error info - report store name (if not found) 26934: Fixed ALF-6532: Upload new version fails in Share (checkout) when using ContentStoreSelector - Includes investigative tests from DEV rev 26902 - Fixed safeCopyContent to cater for first-time setting of property where content is already in new store (copy operations) - Tested XAM use-case as well 26996: Fix for ALF-8229. patch.webSiteAddModerated upgrade error. Trivial fix sanctioned for check-in on 3.4.2 by SteveR. 26997: Undoing accidental check-in of eclipse project files changes. 27045: Change to CIFS session setup exception processing as per ALF-229. 27069: ALF-3871: Global properties now visible through JMX 27108: Merged PATCHES/V3.3.3 to V3.4-BUG-FIX 27107: ALF-8388: Merged PATCHES/V3.3.4 to PATCHES/V3.3.3 26894: ALF-7237: Further diagnostics for maxChecks and maxCheckTime 27110: Merge DEV to V3.4-BUG-FIX 26859 : ALF-6546 - JCR export fails when node has a null property value 27116: ALF-8190 - Minor version labels non-intuitive now the minor version will start at 0.1 rather than 1.0 27121: Fixed ALF-8307: Audit query template in 3.4.0 should quote key values for application and username 27332: Follow on test corrections from the fix to ALF-8190. 27508: Merge Dev to V3.4-BUG-FIX 27153 : ALF-5496 Commenting on a Space creates an Empty Folder via CIFS 27575: Merged DEV/TEMPORARY to V3.4-BUG-FIX 27070: ALF-4954: when cookies are disabled, Share enters into a loop, Explorer outputs a java.lang.NullPointerException exception, Firefox 1. SSOAuthenticationFilter and login page for Share application was modified to handle lack of cookies in a manner web-client do that. 27586: Ignore default build directory for virtual server 27587: Fix for ALF-8188: Share - Search returns no result when using special characters - not really a bug .... added implementation to support \u0000 style encoding in the parser but not the impl 27590: Merged DEV to V3.4-BUG-FIX 27147: ALF-7979 : Metadata extracters should log a warning/error when type conversion of field values fails 1. Adding additional logging for type conversion failure during metadata extraction. - Additionally removed some false TODOs and fixed generics in class 27593: Fix for: ALF-7827: CMIS Contains does not support TEXT, ALL, d:content etc as would be expected - added to match Alfresco FTS 27595: Fix for: ALF-8073: Property value not stored in Lucene index if stored=true and tokenized=false - if stored is selected the value will be stored in the plain property entry 27599: Merged V3.3 to V3.4-BUG-FIX 27130: Merged DEV/TEMPORARY to V3.3 27129: ALF-8141: Using the copy/move action causes the Path QName to change to 'copy' or 'move' MoveActionExecuter: Remove PARAM_ASSOC_TYPE_QNAME and PARAM_ASSOC_QNAME(Also remove it from classes that use them). Use FileFolderService for move operation. CopyActionExecuter: Remove PARAM_ASSOC_TYPE_QNAME and PARAM_ASSOC_QNAME(Also remove it from classes that use them). Use CopyService with original assocTypeQName and assocQName(Don't use FileFolderService here because it doesn't respect deep copy flag). 27155: ALF-8141: Fix up unit tests plus RESTful calls to RuleService 27601: Fix up unit tests following merge of ALF-8141 27604: Fix for ALF-7738: Hyphen not handled correctly in cmis-alfresco search for Aspects/types : " no viable alternative at character 'a' " - query names are now escaped where required 27613: Upgrade Tika and POI for ALF-7978 27618: ALF-1813 Fixed security issue where tasks could be edited by a user who did not have acess tot he task. 27637: Merged DEV/TEMPORARY to V3.4-BUG-FIX 26965: ALF-8258: sharedLockTokens property duplicated many times Changed LockInfo.sharedLockTokens from LinkedList to HashSet because in RFC "Lock token URIs MUST be unique across all resources for all time.", and therefore sharedLockTokens should contain non-repeatable values. 27662: ALF-8549: activities.getFeedControls() does not return a scriptable object in Javascript - also fix REST call (/api/activities/feed/controls) to return JSON 27663: Perf improvement: cache User Feed Controls (for generator job run) - note: activity feed controls are not currently exposed via Share UI 27668: ALF-8413: Share Feed Generator on Oracle generates NPE (when commenting in repo view) - fix NPE (note: in general Share does not post activities outside of site context + feed generator is currently based on site members) 27669: ALF-8549: activities.getFeedControls() does not return a scriptable object in Javascript - quick test fix for PostgreSQL (follow-on from r27662) 27697: ALF-8581: User activities are displayed twice in My Activities dashlet (in cluster env) - add cluster job lock service (SLNG-770) 27776: ALF-8581: Reverted changes to FeedGeneratorJob 27806: Merged DEV to V3.4-BUG-FIX 27793: ALF-8351 : JBPM Tables in Oracle missing index on Foreign Keys leading to table Locks 1. Sql script that creates indexes for foreign keys in jbpm tables was implemented. This script synchronizes jbpm indexes with mysql version. Merge changes: Changed 4.0 references to 3.4; Incremented schema number. 27808: Fixed ALF-7510: Share - Workflow 'due date' field date validation doesn't work properly 27811: Fixed ALF-6179: WebDAV has problems if username contains spaces 27812: Partial fix for ALF-7032: Alfresco doesn't escape special XML characters in AtomPub 27815: Switched to use ?xml instead of ?html in partial fix for ALF-7032: Alfresco doesn't escape special XML characters in AtomPub 27825: ALF-8489 Fixed issue by removing inappropriate 'requiredApprovePercent' field. 27852: Fix for ALF-7845 index.recovery.mode=AUTO doesn't rebuild avm index - applied provided patch 27857: Fix for ALF-868: Large Table Data causes TinyMCE to drop below Alfresco Footer in Web Form - IE7 only 27860: Fixes: ALF-2199 Errors in CSS files. 27866: Fixes: ALF-1327 - truncation issues in the calendar. 27881: Fixes bug in Chrome introduced with r27866 27898: CIFS on Windows fails to start under certain conditions. ALF-8723 27901: Merged DEV to V3.4-BUG-FIX 27891: ALF-7421: An opensolaris NFS client cannot see folders renamed using the web UI after two minutes. NFS server cache updating policy handler was implemented: - NfsServerNodeMonitor.java’ – new policy handler for NFS server; - NFSServerBean.java’ was modified to configure implemented node monitor with NFS server instance during server start up; - file-servers.properties’ was expanded with new properties for new node monitor which allows controlling node monitor 'enabled' state; - file-servers-context.xml’ was expanded with bean configuration for new node monitor and with configuration for NFS server bean to accept newly configured node monitor bean; - ShareDetailsHash.java’ was modified to externalize hashtable of the cache; - NFSServer.java’ was modified to externalize its cache for public access 27902: ALF-8744 - Untransalted strings in Recent shapshot 27903: Fixes: ALF-5717 Issues with non i18n/L10N Data List form fields. 27922: Fixes: ALF-8726 by back porting some Team usability fixes. *Do Not Merge* 27923: Fixes: ALF-8429 - Replaces hard coded English tooltip with a pre-existing i18n string. 27929: Fixed ALF-8768: Wrong path in comment for wcm-bootstrap-context.xml 27938: Partial Fix for: ALF-8720: Adds missing spaces. 27940: Merged V3.3 to V3.4-BUG-FIX 27851: Fix for ALF-8476:CLONE -Query consuming all heap and receiving an OOM exception - actually fixes stack overflow with skipTo when there are lots of deleted docs in an index in a row (<10000 on the default settings) ---- Modified : /alfresco/BRANCHES/DEV/V3.4-BUG-FIX Modified : /alfresco/BRANCHES/DEV/V3.4-BUG-FIX/root/projects/repository/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneTest.java Modified : /alfresco/BRANCHES/DEV/V3.4-BUG-FIX/root/projects/repository/source/java/org/alfresco/repo/search/impl/lucene/FilterIndexReaderByStringId.java 27942: Merged V3.4 to V3.4-BUG-FIX 26772: Fix for ALF-7843 - Created via SPP all-day event displays incorrectly 26775: Fix for ALF-3374 - Reverting a file in workflow causes a Successful error message 26778: Fix message Failed to find I18N message key: reset_categories for locale: en_US 26781: Fix for ALF-6488 - LangPack FR - [Site's Wiki] Renaming a wiki's page - special chars handling 26783: Fixed ALF-7421: An opensolaris NFS client cannot see folders renamed using the web UI after two minutes. - De-Hibernate DAO refactor missed implementing 'system.enableTimestampPropagation' - Set 'system.enableTimestampPropagation=true' in alfresco-global.properties - Timestamps will be written to immediate parent folder and will therefore not drop out of the filestate cache after 2 min 26785: Services-layer fix for ALF-8036. Incorrect permissions copied when copying folder with permissions from one site to another. UI will have to make changes in the UI layer in order to use new Services methods, thus completing the fix. This check-in adds support in the SiteService for moving and copying site-contained nodes. New move/copy methods are available in the Java Foundation API and in the JavaScript API which mimic the signatures of those in the NodeService and CopyService respectively. These methods simply delegate to the back-end services and so behaviours should be the same as before if they are used in place of the node and copy service methods. With one exception: The SiteService wrapper methods detect when the relocated node has been copied/moved between two different Share sites and clears permissions from the relocated node (and its primary descendants) that refer to the previous site. This has not been implemented using policies/behaviours as we can't bind the behaviour to any particular content class. Nodes of any type could be copied/moved between sites. 26787: Removed erroneous import from StreamContent - incorrect dependency on de.schlichtherle.io.FileOutputStream 26803: Fixes: ALF-8138, adds a i18n property for a ToDo list's attachment title. 26806: Fixed ALF-8154: Shorten the node path as prefix-only path - Use Path.toPrefixString instead of Path.toString - Provides improved fix for ALF-7804 26824: Fixed ALF-7012: WCM - Schema error "xs:enumeration full" select button group shows "Please select..." 26832: UI-layer fix component for ALF-8036 and a refactoring of the Services-layer fix component. Rather than add various facade methods to the SiteService for all the copy & move variants in NodeService, CopyService, FileFolderService etc, I have added a single new method to the SiteService cleanSitePermissions(). This removes all out-of-date site permissions after a node has been moved or copied to a new site. Also changed the slingshot action webscripts for move-to and copy-to to call this cleanUp method. 26838: Rewording a misleading code comment. Related to ALF-8036 changes. 26847: ALF-6727: File server protocols don't report the read only attribute for folders unless new configuration setting filesystem.setReadOnlyFlagOnFolders is true - Default is false - On windows, the read only attribute doesn't mean the folder is read only - it means "this folder has been customized - please fetch a desktop.ini". - This results in poor performance for non-admin users due to lots of secondary fetches for configuration information. - See the bug for more details. 26855: ALF-6727: Missing files from last check in 26858: Merged V3.4-TEAM to V3.4 26841: Fix for ALF-1044. (Searching for groups whose names contain regex reserved chars.) The fix was to add [] as reserved chars to the RegEx SimpleLanguageDef. Thanks AndyH. 26860: ALF-7101 and ALF-7866 - don't show the rules options to collaborators, as they shouldn't be able to create/manage rules 26861: Merged DEV/TEMPORARY to V3.4 (with corrections) 26157: ALF-1544: Server won't start on JBoss: Unable to resolve drag and drop application as a file, class path resource [alfresco/desktop/Alfresco.exe] DesktopAction uses Resource’s InputStream for drug-n-drop files representation. 26870: ALF-6727: Fix up ContentDiskDriverTest 26898: Fix ALF-8219: Deploying WQS in the same container as Alfresco causes startup to stall 26899: Possible installer build fix - uncomment project.readmeFile - set failifexecutionfails="true" on installer build targets so we know if installer building failed! 26900: ALF-8180: The installer shouldn't randomly delete a directory called tomcat that it didn't create - Fix provided by Bitrock 26919: Backing out 3 changes related to ALF-8036 due to uncertainty over fix approach. I'm reverse-merging revisions 26785, 26832 and 26838 out of this 3.4.2 branch. The fix version for ALF-8036 has been changed to 3.4.3 and so we don't want an unfinished fix on 3.4.2. In fact, this fix may be finished, but there is some uncertainty now over the approach to adopt (strip permissions vs. prevert copying of permissions). This fix will go to Team and 3.4.3 instead. 26932: Fixed a couple of non-unicode French characters that were messing up my scripts and: Merged BRANCHES/DEV/dwebster/ to BRANCHES/V3.4: 26911: Latest updates from translators (based on rev26710) 26944: ALF-3569 - Alfresco repository CIFS driver not setting timestamps. 26952: Finishes the completeness tests & fixes several L10N bugs. 26972: Fixes ALF-8272: Alfresco cannot be started after fresh install 26980: ALF-8287 - All buttons are disabled on Data Lists page. 27039: Merged BRANCHES/DEV/dwebsterV34 to BRANCHES/V3.4: - Update from Translators (based on r26837). 27059: Merged PATCHES/V3.4.1 to V3.4 26959: ALF-8261: 3.4 JSF performance regression introduced by WebProjectServiceImpl.hasWebProjectsRoot() (ALF-3085) 27020: ALF-8281: CLONE -'Move To' operation for categories, folders and records doesn't work ESCALATION 27061: Merged PATCHES/V3.3.4 to V3.4 27032: ALF-8289: Merged DEV to PATCHES/V3.3.4 27028: ALF-8289: Occasionally, web form complains of missing required fields when the fields are indeed populated 27068: Merged DEV to V3.4 27067: ALF-3774 : Unable to disable listening on port 7500 (JGroups) 1. DummyProtocol was changed to rewrite default configuration. This changes turn off diagnostic probing for DummyChannel. 27071: Fixed ALF-8363: BadSqlGrammarException during patch.fixAclInheritance on Oracle - Using '... = true' does not work for Oracle. - Replaced with parameterClass="boolean" and #trueOrFalse# - Tested against limited dataset so some condition paths might be missed. 27083: ALF-8124: Corrected ${} placeholders in Japanese installer strings 27088: Fixed ALF-8377: Generic KeywordSearch is not resilient to stale Lucene indexes - Cleaned up PersonSearchTest - Added exists check to KeywordSearch - Rationalized related bean declarations 27113: Fixed ALF-1322 "Creating user with username containing spaces works incorrectly" 27127: ALF-8346 - 'Complete event' button for folders is disabled in IE 27136: Installer string updates from Gloria 27173: Fix for: ALF-7834: CLONE - ACL Propagation issue for large number of users/ACLs - manually fix up the cache when changing inheritance 27503: Fix for ALF-8345 - Extra icons on the form of adding translation without content(IE specific) 27504: Fix for ALF-6917 - A system error happens when user attempted press toggle 'Version History' 27505: ALF-6215 - French Language pack - It's incorrect layout in Document List component 27509: ALF-8451: Port AVM-rename-dupes.sql to DB2 and SQL Server 27511: ALF-7165: User with contributor role cannot view content 27512: Installer string updates from Gloria - Corrections to msgid Installer.ReadmeFile.View 27557: case sensitivity issues with terminfo database building from Windows 27563: Merged DEV to V3.4 27558: ALF-8408: Impossible to upload a new file by contributor to subspace when rule is applied to subspaces Retrieving of rule was surrounded in RunAs(System username) block. It allows to retrieve rule node and its actions if user has no read permissions to rule node and to rule's actions. JUnit test "PermissionsForPropagatedRules_ALF_8408" was added. 27602: Fix for ALF-5625 - When viewing properties in version history hitting close results in loop (V3.4.2) 27622: ALF-5607: Remove bundled postgres data directory on installation abort on Linux 27639: Fix for ALF-6488 - Decode HTML content before creating page url argument for wiki 27647: Fix for ALF-8552 27672: ALF-8553: PatchService didn't recurse on dependents of already applied patches - Hence patch ordering was wrong on V3.4 upgrade 27684: ALF-8553, ALF-8602: set batchMaxQueryRange on patch.fixNameCrcValues-2 to avoid OOM 27687: Merge DEV to V3.4 27674 : ALF-8453 CIFS Failed to save versionable MS Word content as collaborator 27690: Merged DEV/TEMPORARY to V3.4 27688: ALF-7822 : AVM projects unavailable after upgrade to 3.4.1 script was modified to prevent data corruption 27775: Fixes ALF-8654: Add removed quotes back into .po files 27805: ALF-2935: Properly control RMI port in Bitrock installer - order repository-properties before shared-properties so that you can specify the port in alfresco-global.properties if you want to - include a tokenized alfresco-shared.properties in the WCM installation files 27807: Merged V3.4-TEAM to V3.4 27756: ALF-8207 - ALL LANG - Themes are not translated 27840: ALF-8687: No items display for series when opening it from library list 27853: Fixes: ALF-7465 - Removes some of the differences between the Add Event and Remove Event dialogues & reuses existing TagLibrary component to avoid conflicts. 27856: ALF-8687: No items display for series when opening it from library list. Slight refactor to better match non-RM doclib code. 27871: Fixes ALF-8124: Ensure Spanish locale for installer shows product name correctly 27932: Fixes ALF-5519: alfresco-enterprise-wcmqs-3.3.3.zip does not contain awe.war - Added awe.war to WQS zip file 27944: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 26766: Merged V3.4-BUG-FIX to V3.4 26761: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 26760: Merged V3.4-BUG-FIX to V3.4 26759: Merged V3.4-BUG-FIX to V3.4 (3.4.2) 26762: ALF-8028 ResultSet not closed in TransferServiceImpl2 try...finally pattern was added to search operation. 26764: Further fixes to the patch for: ALF-7834: CLONE -ACL Propagation issue for large number of users/ACLs 26765: ALF-634, ALF-7103: Possible fix to JBPM regressions introduced by r26460 26831: Merged V3.4-BUG-FIX to V3.4 26788: Further fixes to the patch for: ALF-7834: CLONE -ACL Propagation issue for large number of users/ACLs - fix type that would have missed a minor error (for unused shared ACLs) 27016: Merged V3.4-BUG-FIX to V3.4 26996: Fix for ALF-8229. patch.webSiteAddModerated upgrade error Trivial fix sanctioned for check-in on 3.4.2 by SteveR 26997: Undoing accidental check-in of eclipse project files changes 27859: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/V3.4: 27857: Fix for ALF-868: Large Table Data causes TinyMCE to drop below Alfresco Footer in Web Form - IE7 only git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@27948 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
3043 lines
143 KiB
Java
3043 lines
143 KiB
Java
/*
|
|
* Copyright (C) 2005-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.node;
|
|
|
|
import java.io.InputStream;
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.transaction.UserTransaction;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.content.MimetypeMap;
|
|
import org.alfresco.repo.dictionary.DictionaryComponent;
|
|
import org.alfresco.repo.dictionary.DictionaryDAO;
|
|
import org.alfresco.repo.dictionary.M2Model;
|
|
import org.alfresco.repo.node.integrity.IntegrityChecker;
|
|
import org.alfresco.repo.policy.JavaBehaviour;
|
|
import org.alfresco.repo.policy.PolicyComponent;
|
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
|
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.ContentData;
|
|
import org.alfresco.service.cmr.repository.CyclicChildRelationshipException;
|
|
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
|
import org.alfresco.service.cmr.repository.MLText;
|
|
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.repository.datatype.TypeConversionException;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
import org.alfresco.service.transaction.TransactionService;
|
|
import org.alfresco.util.BaseSpringTest;
|
|
import org.alfresco.util.GUID;
|
|
import org.hibernate.dialect.DB2Dialect;
|
|
import org.hibernate.dialect.Dialect;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.extensions.surf.util.I18NUtil;
|
|
|
|
/**
|
|
* Provides a base set of tests of the various {@link org.alfresco.service.cmr.repository.NodeService}
|
|
* implementations.
|
|
* <p>
|
|
* To test a specific incarnation of the service, the methods {@link #getStoreService()} and
|
|
* {@link #getNodeService()} must be implemented.
|
|
*
|
|
* @see #nodeService
|
|
* @see #rootNodeRef
|
|
* @see #buildNodeGraph()
|
|
*
|
|
* @author Derek Hulley
|
|
*/
|
|
@SuppressWarnings("unused") /* its just a test */
|
|
public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|
{
|
|
public static final String NAMESPACE = "http://www.alfresco.org/test/BaseNodeServiceTest";
|
|
public static final String TEST_PREFIX = "test";
|
|
|
|
public static final String DEFAULT_VALUE = "defaultValue";
|
|
public static final String NOT_DEFAULT_VALUE = "notDefaultValue";
|
|
|
|
public static final QName TYPE_QNAME_TEST_CONTENT = QName.createQName(NAMESPACE, "content");
|
|
public static final QName TYPE_QNAME_TEST_MANY_PROPERTIES = QName.createQName(NAMESPACE, "many-properties");
|
|
public static final QName TYPE_QNAME_TEST_MANY_ML_PROPERTIES = QName.createQName(NAMESPACE, "many-ml-properties");
|
|
public static final QName TYPE_QNAME_EXTENDED_CONTENT = QName.createQName(NAMESPACE, "extendedcontent");
|
|
public static final QName ASPECT_QNAME_TEST_TITLED = QName.createQName(NAMESPACE, "titled");
|
|
public static final QName ASPECT_QNAME_TEST_MARKER = QName.createQName(NAMESPACE, "marker");
|
|
public static final QName ASPECT_QNAME_TEST_MARKER2 = QName.createQName(NAMESPACE, "marker2");
|
|
public static final QName ASPECT_QNAME_MANDATORY = QName.createQName(NAMESPACE, "mandatoryaspect");
|
|
public static final QName ASPECT_QNAME_WITH_DEFAULT_VALUE = QName.createQName(NAMESPACE, "withDefaultValue");
|
|
public static final QName PROP_QNAME_TEST_TITLE = QName.createQName(NAMESPACE, "title");
|
|
public static final QName PROP_QNAME_TEST_DESCRIPTION = QName.createQName(NAMESPACE, "description");
|
|
public static final QName PROP_QNAME_TEST_CONTENT = QName.createQName(NAMESPACE, "content");
|
|
public static final QName PROP_QNAME_BOOLEAN_VALUE = QName.createQName(NAMESPACE, "booleanValue");
|
|
public static final QName PROP_QNAME_INTEGER_VALUE = QName.createQName(NAMESPACE, "integerValue");
|
|
public static final QName PROP_QNAME_LONG_VALUE = QName.createQName(NAMESPACE, "longValue");
|
|
public static final QName PROP_QNAME_FLOAT_VALUE = QName.createQName(NAMESPACE, "floatValue");
|
|
public static final QName PROP_QNAME_DOUBLE_VALUE = QName.createQName(NAMESPACE, "doubleValue");
|
|
public static final QName PROP_QNAME_STRING_VALUE = QName.createQName(NAMESPACE, "stringValue");
|
|
public static final QName PROP_QNAME_ML_TEXT_VALUE = QName.createQName(NAMESPACE, "mlTextValue");
|
|
public static final QName PROP_QNAME_DATE_VALUE = QName.createQName(NAMESPACE, "dateValue");
|
|
public static final QName PROP_QNAME_SERIALIZABLE_VALUE = QName.createQName(NAMESPACE, "serializableValue");
|
|
public static final QName PROP_QNAME_NODEREF_VALUE = QName.createQName(NAMESPACE, "nodeRefValue");
|
|
public static final QName PROP_QNAME_QNAME_VALUE = QName.createQName(NAMESPACE, "qnameValue");
|
|
public static final QName PROP_QNAME_CONTENT_VALUE = QName.createQName(NAMESPACE, "contentValue");
|
|
public static final QName PROP_QNAME_PATH_VALUE = QName.createQName(NAMESPACE, "pathValue");
|
|
public static final QName PROP_QNAME_CATEGORY_VALUE = QName.createQName(NAMESPACE, "categoryValue");
|
|
public static final QName PROP_QNAME_LOCALE_VALUE = QName.createQName(NAMESPACE, "localeValue");
|
|
public static final QName PROP_QNAME_NULL_VALUE = QName.createQName(NAMESPACE, "nullValue");
|
|
public static final QName PROP_QNAME_MULTI_VALUE = QName.createQName(NAMESPACE, "multiValue");
|
|
public static final QName PROP_QNAME_PERIOD_VALUE = QName.createQName(NAMESPACE, "periodValue");
|
|
public static final QName PROP_QNAME_MULTI_ML_VALUE = QName.createQName(NAMESPACE, "multiMLValue");
|
|
public static final QName PROP_QNAME_MARKER_PROP = QName.createQName(NAMESPACE, "markerProp");
|
|
public static final QName PROP_QNAME_PROP1 = QName.createQName(NAMESPACE, "prop1");
|
|
public static final QName PROP_QNAME_PROP2 = QName.createQName(NAMESPACE, "prop2");
|
|
public static final QName ASSOC_TYPE_QNAME_TEST_CHILDREN = ContentModel.ASSOC_CHILDREN;
|
|
public static final QName ASSOC_TYPE_QNAME_TEST_CONTAINS = ContentModel.ASSOC_CONTAINS;
|
|
public static final QName ASSOC_TYPE_QNAME_TEST_NEXT = QName.createQName(NAMESPACE, "next");
|
|
|
|
public static final QName ASPECT_WITH_ASSOCIATIONS = QName.createQName(NAMESPACE, "withAssociations");
|
|
public static final QName ASSOC_ASPECT_CHILD_ASSOC = QName.createQName(NAMESPACE, "aspect-child-assoc");
|
|
public static final QName ASSOC_ASPECT_NORMAL_ASSOC = QName.createQName(NAMESPACE, "aspect-normal-assoc");
|
|
|
|
public static final QName ASPECT_WITH_ASSOCIATIONS_EXTRA = QName.createQName(NAMESPACE, "withAssociationsExtra");
|
|
public static final QName ASSOC_ASPECT_CHILD_ASSOC_01 = QName.createQName(NAMESPACE, "aspect-child-assoc-01");
|
|
public static final QName ASSOC_ASPECT_CHILD_ASSOC_02 = QName.createQName(NAMESPACE, "aspect-child-assoc-02");
|
|
public static final QName ASSOC_ASPECT_NORMAL_ASSOC_01 = QName.createQName(NAMESPACE, "aspect-normal-assoc-01");
|
|
public static final QName ASSOC_ASPECT_NORMAL_ASSOC_02 = QName.createQName(NAMESPACE, "aspect-normal-assoc-02");
|
|
|
|
public static final QName TYPE_QNAME_TEST_MULTIPLE_TESTER = QName.createQName(NAMESPACE, "multiple-tester");
|
|
public static final QName PROP_QNAME_STRING_PROP_SINGLE = QName.createQName(NAMESPACE, "stringprop-single");
|
|
public static final QName PROP_QNAME_STRING_PROP_MULTIPLE = QName.createQName(NAMESPACE, "stringprop-multiple");
|
|
public static final QName PROP_QNAME_ANY_PROP_SINGLE = QName.createQName(NAMESPACE, "anyprop-single");
|
|
public static final QName PROP_QNAME_ANY_PROP_MULTIPLE = QName.createQName(NAMESPACE, "anyprop-multiple");
|
|
|
|
protected PolicyComponent policyComponent;
|
|
protected DictionaryService dictionaryService;
|
|
protected TransactionService transactionService;
|
|
protected RetryingTransactionHelper retryingTransactionHelper;
|
|
protected AuthenticationComponent authenticationComponent;
|
|
protected NodeService nodeService;
|
|
protected Dialect dialect;
|
|
/** populated during setup */
|
|
protected NodeRef rootNodeRef;
|
|
private NodeRef cat;
|
|
|
|
@Override
|
|
protected void onSetUpInTransaction() throws Exception
|
|
{
|
|
super.onSetUpInTransaction();
|
|
|
|
dialect = (Dialect) applicationContext.getBean("dialect");
|
|
|
|
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
|
retryingTransactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper");
|
|
policyComponent = (PolicyComponent) applicationContext.getBean("policyComponent");
|
|
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
|
|
|
authenticationComponent.setSystemUserAsCurrentUser();
|
|
|
|
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
|
|
// load the system model
|
|
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
|
|
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
|
|
assertNotNull(modelStream);
|
|
M2Model model = M2Model.createModel(modelStream);
|
|
dictionaryDao.putModel(model);
|
|
// load the test model
|
|
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
|
|
assertNotNull(modelStream);
|
|
model = M2Model.createModel(modelStream);
|
|
dictionaryDao.putModel(model);
|
|
|
|
DictionaryComponent dictionary = new DictionaryComponent();
|
|
dictionary.setDictionaryDAO(dictionaryDao);
|
|
dictionaryService = loadModel(applicationContext);
|
|
|
|
nodeService = getNodeService();
|
|
|
|
// create a first store directly
|
|
StoreRef storeRef = nodeService.createStore(
|
|
StoreRef.PROTOCOL_WORKSPACE,
|
|
"Test_" + System.currentTimeMillis());
|
|
rootNodeRef = nodeService.getRootNode(storeRef);
|
|
|
|
StoreRef catStoreRef = nodeService.createStore(
|
|
StoreRef.PROTOCOL_WORKSPACE,
|
|
"Test_cat_" + System.currentTimeMillis());
|
|
NodeRef catRootNodeRef = nodeService.getRootNode(catStoreRef);
|
|
|
|
cat = nodeService.createNode(catRootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}cat"), ContentModel.TYPE_CATEGORY).getChildRef();
|
|
|
|
// downgrade integrity checks
|
|
IntegrityChecker.setWarnInTransaction();
|
|
}
|
|
|
|
@Override
|
|
protected void onTearDownInTransaction() throws Exception
|
|
{
|
|
try
|
|
{
|
|
authenticationComponent.clearCurrentSecurityContext();
|
|
}
|
|
catch (Throwable e)
|
|
{
|
|
// do nothing
|
|
}
|
|
super.onTearDownInTransaction();
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Loads the test model required for building the node graphs
|
|
*/
|
|
public static DictionaryService loadModel(ApplicationContext applicationContext)
|
|
{
|
|
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
|
|
// load the system model
|
|
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
|
|
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
|
|
assertNotNull(modelStream);
|
|
M2Model model = M2Model.createModel(modelStream);
|
|
dictionaryDao.putModel(model);
|
|
// load the test model
|
|
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
|
|
assertNotNull(modelStream);
|
|
model = M2Model.createModel(modelStream);
|
|
dictionaryDao.putModel(model);
|
|
|
|
DictionaryComponent dictionary = new DictionaryComponent();
|
|
dictionary.setDictionaryDAO(dictionaryDao);
|
|
// done
|
|
return dictionary;
|
|
}
|
|
|
|
/**
|
|
* Usually just implemented by fetching the bean directly from the bean factory,
|
|
* for example:
|
|
* <p>
|
|
* <pre>
|
|
* return (NodeService) applicationContext.getBean("dbNodeService");
|
|
* </pre>
|
|
* The <tt>NodeService<tt> returned must support cascade deletion.
|
|
*
|
|
* @return Returns the implementation of <code>NodeService</code> to be
|
|
* used for this test. It must have transaction demarcation.
|
|
*/
|
|
protected abstract NodeService getNodeService();
|
|
|
|
public void testSetUp() throws Exception
|
|
{
|
|
assertNotNull("StoreService not set", nodeService);
|
|
assertNotNull("NodeService not set", nodeService);
|
|
assertNotNull("rootNodeRef not created", rootNodeRef);
|
|
}
|
|
|
|
/**
|
|
* @see #buildNodeGraph(NodeService, NodeRef)
|
|
*/
|
|
public Map<QName, ChildAssociationRef> buildNodeGraph() throws Exception
|
|
{
|
|
return BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
|
}
|
|
|
|
/**
|
|
* Builds a graph of child associations as follows:
|
|
* <pre>
|
|
* Level 0: root
|
|
* Level 1: root_p_n1 root_p_n2
|
|
* Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5 n1_n8
|
|
* Level 3: n3_p_n6 n4_n6 n5_p_n7
|
|
* Level 4: n6_p_n8 n7_n8
|
|
* </pre>
|
|
* <p>
|
|
* <ul>
|
|
* <li>Apart from the root node having the root aspect, node 6 (<b>n6</b>) also has the
|
|
* root aspect.</li>
|
|
* <li><b>n3</b> has properties <code>animal = monkey</code> and
|
|
* <code>reference = <b>n2</b>.toString()</code>.</li>
|
|
* <li>All nodes are of type {@link ContentModel#TYPE_CONTAINER container}
|
|
* with the exception of <b>n8</b>, which is of type {@link #TYPE_QNAME_TEST_CONTENT test:content}</li>
|
|
* </ul>
|
|
* <p>
|
|
* The namespace URI for all associations is <b>{@link BaseNodeServiceTest#NAMESPACE}</b>.
|
|
* <p>
|
|
* The naming convention is:
|
|
* <pre>
|
|
* n2_p_n5
|
|
* n4_n5
|
|
* where
|
|
* n5 is the node number of the node
|
|
* n2 is the primary parent node number
|
|
* n4 is any other non-primary parent
|
|
* </pre>
|
|
* <p>
|
|
* The session is flushed to ensure that persistence occurs correctly. It is
|
|
* cleared to ensure that fetches against the created data are correct.
|
|
*
|
|
* @return Returns a map <code>ChildAssocRef</code> instances keyed by qualified assoc name
|
|
*/
|
|
public static Map<QName, ChildAssociationRef> buildNodeGraph(
|
|
NodeService nodeService,
|
|
NodeRef rootNodeRef) throws Exception
|
|
{
|
|
String ns = BaseNodeServiceTest.NAMESPACE;
|
|
QName qname = null;
|
|
ChildAssociationRef assoc = null;
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
|
Map<QName, ChildAssociationRef> ret = new HashMap<QName, ChildAssociationRef>(13);
|
|
|
|
// LEVEL 0
|
|
|
|
// LEVEL 1
|
|
qname = QName.createQName(ns, "root_p_n1");
|
|
assoc = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n1 = assoc.getChildRef();
|
|
|
|
qname = QName.createQName(ns, "root_p_n2");
|
|
assoc = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n2 = assoc.getChildRef();
|
|
|
|
// LEVEL 2
|
|
|
|
properties.clear();
|
|
properties.put(QName.createQName(ns, "animal"), "monkey");
|
|
properties.put(QName.createQName(ns, "UPPERANIMAL"), "MONKEY");
|
|
properties.put(QName.createQName(ns, "reference"), n2.toString());
|
|
properties.put(QName.createQName(ns, "text1"), "bun");
|
|
properties.put(QName.createQName(ns, "text2"), "cake");
|
|
properties.put(QName.createQName(ns, "text3"), "biscuit");
|
|
properties.put(QName.createQName(ns, "text12"), "bun, cake");
|
|
properties.put(QName.createQName(ns, "text13"), "bun, biscuit");
|
|
properties.put(QName.createQName(ns, "text23"), "cake, biscuit");
|
|
properties.put(QName.createQName(ns, "text123"), "bun, cake, biscuit");
|
|
ArrayList<String> slist = new ArrayList<String>();
|
|
slist.add("first");
|
|
slist.add("second");
|
|
slist.add("third");
|
|
|
|
properties.put(QName.createQName(ns, "mvp"), slist);
|
|
|
|
ArrayList<Integer> ilist = new ArrayList<Integer>();
|
|
ilist.add(new Integer(1));
|
|
ilist.add(new Integer(2));
|
|
ilist.add(new Integer(3));
|
|
|
|
properties.put(QName.createQName(ns, "mvi"), ilist);
|
|
|
|
qname = QName.createQName(ns, "n1_p_n3");
|
|
assoc = nodeService.createNode(n1, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER, properties);
|
|
ret.put(qname, assoc);
|
|
NodeRef n3 = assoc.getChildRef();
|
|
|
|
qname = QName.createQName(ns, "n2_p_n4");
|
|
assoc = nodeService.createNode(n2, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n4 = assoc.getChildRef();
|
|
|
|
qname = QName.createQName(ns, "n1_n4");
|
|
assoc = nodeService.addChild(n1, n4, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
|
|
ret.put(qname, assoc);
|
|
|
|
qname = QName.createQName(ns, "n2_p_n5");
|
|
assoc = nodeService.createNode(n2, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n5 = assoc.getChildRef();
|
|
|
|
// LEVEL 3
|
|
qname = QName.createQName(ns, "n3_p_n6");
|
|
assoc = nodeService.createNode(n3, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n6 = assoc.getChildRef();
|
|
nodeService.addAspect(n6,
|
|
ContentModel.ASPECT_ROOT,
|
|
Collections.<QName, Serializable>emptyMap());
|
|
|
|
qname = QName.createQName(ns, "n4_n6");
|
|
assoc = nodeService.addChild(n4, n6, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
|
|
ret.put(qname, assoc);
|
|
|
|
qname = QName.createQName(ns, "n5_p_n7");
|
|
assoc = nodeService.createNode(n5, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
|
|
ret.put(qname, assoc);
|
|
NodeRef n7 = assoc.getChildRef();
|
|
|
|
// LEVEL 4
|
|
properties.clear();
|
|
properties.put(PROP_QNAME_TEST_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
|
|
properties.put(PROP_QNAME_TEST_TITLE, "node8");
|
|
qname = QName.createQName(ns, "n6_p_n8");
|
|
assoc = nodeService.createNode(n6, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname, TYPE_QNAME_TEST_CONTENT, properties);
|
|
ret.put(qname, assoc);
|
|
NodeRef n8 = assoc.getChildRef();
|
|
|
|
qname = QName.createQName(ns, "n7_n8");
|
|
assoc = nodeService.addChild(n7, n8, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
|
|
ret.put(qname, assoc);
|
|
|
|
qname = QName.createQName(ns, "n1_n8");
|
|
assoc = nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
|
|
ret.put(qname, assoc);
|
|
|
|
// // flush and clear
|
|
// getSession().flush();
|
|
// getSession().clear();
|
|
|
|
// done
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* @return Returns a reference to the created store
|
|
*/
|
|
private StoreRef createStore() throws Exception
|
|
{
|
|
StoreRef storeRef = nodeService.createStore(
|
|
StoreRef.PROTOCOL_WORKSPACE,
|
|
getName() + "_" + System.nanoTime());
|
|
assertNotNull("No reference returned", storeRef);
|
|
// done
|
|
return storeRef;
|
|
}
|
|
|
|
public void testCreateStore() throws Exception
|
|
{
|
|
StoreRef storeRef = createStore();
|
|
|
|
// check that it exists
|
|
assertTrue("NodeService reports that store doesn't exist", nodeService.exists(storeRef));
|
|
|
|
// get the root node
|
|
NodeRef storeRootNode = nodeService.getRootNode(storeRef);
|
|
// make sure that it has the root aspect
|
|
boolean isRoot = nodeService.hasAspect(storeRootNode, ContentModel.ASPECT_ROOT);
|
|
assertTrue("Root node of store does not have root aspect", isRoot);
|
|
// and is of the correct type
|
|
QName rootType = nodeService.getType(storeRootNode);
|
|
assertEquals("Store root node of incorrect type", ContentModel.TYPE_STOREROOT, rootType);
|
|
}
|
|
|
|
public void testGetStores() throws Exception
|
|
{
|
|
StoreRef storeRef = createStore();
|
|
|
|
// get all stores
|
|
List<StoreRef> storeRefs = nodeService.getStores();
|
|
|
|
// check that the store ref is present
|
|
assertTrue("New store not present is list of stores", storeRefs.contains(storeRef));
|
|
}
|
|
|
|
public void testDeleteStore() throws Exception
|
|
{
|
|
StoreRef storeRef = createStore();
|
|
// get all stores
|
|
List<StoreRef> storeRefs = nodeService.getStores();
|
|
// check that the store ref is present
|
|
assertTrue("New store not present in list of stores", storeRefs.contains(storeRef));
|
|
// Delete it
|
|
nodeService.deleteStore(storeRef);
|
|
storeRefs = nodeService.getStores();
|
|
assertFalse("Deleted store should not present in list of stores", storeRefs.contains(storeRef));
|
|
// Now make sure that none of the stores have the "deleted" protocol
|
|
for (StoreRef retrievedStoreRef : storeRefs)
|
|
{
|
|
if (retrievedStoreRef.getProtocol().equals(StoreRef.PROTOCOL_DELETED))
|
|
{
|
|
fail("NodeService should not have returned 'deleted' stores." + storeRefs);
|
|
}
|
|
}
|
|
|
|
// Commit to ensure all is well
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
public void testExists() throws Exception
|
|
{
|
|
StoreRef storeRef = createStore();
|
|
boolean exists = nodeService.exists(storeRef);
|
|
assertEquals("Exists failed", true, exists);
|
|
// create bogus ref
|
|
StoreRef bogusRef = new StoreRef("What", "the");
|
|
exists = nodeService.exists(bogusRef);
|
|
assertEquals("Exists failed", false, exists);
|
|
}
|
|
|
|
public void testGetRootNode() throws Exception
|
|
{
|
|
StoreRef storeRef = createStore();
|
|
// get the root node
|
|
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
|
assertNotNull("No root node reference returned", rootNodeRef);
|
|
// get the root node again
|
|
NodeRef rootNodeRefCheck = nodeService.getRootNode(storeRef);
|
|
assertEquals("Root nodes returned different refs", rootNodeRef, rootNodeRefCheck);
|
|
}
|
|
|
|
public void testCreateNode() throws Exception
|
|
{
|
|
ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
assertEquals("Assoc type qname not set", ASSOC_TYPE_QNAME_TEST_CHILDREN, assocRef.getTypeQName());
|
|
assertEquals("Assoc qname not set", QName.createQName("pathA"), assocRef.getQName());
|
|
NodeRef childRef = assocRef.getChildRef();
|
|
QName checkType = nodeService.getType(childRef);
|
|
assertEquals("Child node type incorrect", ContentModel.TYPE_CONTAINER, checkType);
|
|
}
|
|
|
|
public void testCreateWithTooLongPathLocalname() throws Exception
|
|
{
|
|
try
|
|
{
|
|
ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("Recognize that VSEPR theory states that nonbonded electrons (lone "
|
|
+ "pairs) exert strong electrostatic repulsive forces against the bonded pairs "
|
|
+ "of electrons and, as a result, the electron pairs arrange themselves as far "
|
|
+ "apart as possible in order to minimize the repulsive forces"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
fail("Expected too-long QName localname to have been kicked out as illegal argument.");
|
|
}
|
|
catch (IllegalArgumentException e)
|
|
{
|
|
// Expected
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Tests node creation with a pre-determined {@link ContentModel#PROP_NODE_UUID uuid}.
|
|
*/
|
|
public void testCreateNodeWithId() throws Exception
|
|
{
|
|
String uuid = GUID.generate();
|
|
// create a node with an explicit UUID
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
properties.put(ContentModel.PROP_NODE_UUID, uuid);
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER,
|
|
properties);
|
|
// check it
|
|
NodeRef expectedNodeRef = new NodeRef(rootNodeRef.getStoreRef(), uuid);
|
|
NodeRef checkNodeRef = assocRef.getChildRef();
|
|
assertEquals("Failed to create node with a chosen ID", expectedNodeRef, checkNodeRef);
|
|
}
|
|
|
|
public void testGetType() throws Exception
|
|
{
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
// get the type
|
|
QName type = nodeService.getType(nodeRef);
|
|
assertEquals("Type mismatch", ContentModel.TYPE_CONTAINER, type);
|
|
}
|
|
|
|
public void testSetType() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("setTypeTest"),
|
|
TYPE_QNAME_TEST_CONTENT).getChildRef();
|
|
assertEquals(TYPE_QNAME_TEST_CONTENT, this.nodeService.getType(nodeRef));
|
|
|
|
assertNull(this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP1));
|
|
|
|
// Now change the type
|
|
this.nodeService.setType(nodeRef, TYPE_QNAME_EXTENDED_CONTENT);
|
|
assertEquals(TYPE_QNAME_EXTENDED_CONTENT, this.nodeService.getType(nodeRef));
|
|
|
|
// Check new defaults
|
|
Serializable defaultValue = this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertNotNull("No default property value assigned", defaultValue);
|
|
assertEquals(DEFAULT_VALUE, defaultValue);
|
|
}
|
|
|
|
/**
|
|
* Fills the given property map with some values according to the property definitions on the given class
|
|
*/
|
|
protected void fillProperties(QName qname, Map<QName, Serializable> properties)
|
|
{
|
|
ClassDefinition classDef = dictionaryService.getClass(qname);
|
|
if (classDef == null)
|
|
{
|
|
throw new RuntimeException("No such class: " + qname);
|
|
}
|
|
Map<QName,PropertyDefinition> propertyDefs = classDef.getProperties();
|
|
// make up a property value for each property
|
|
for (Map.Entry<QName, PropertyDefinition> entry : propertyDefs.entrySet())
|
|
{
|
|
QName propertyQName = entry.getKey();
|
|
QName propertyTypeQName = entry.getValue().getDataType().getName();
|
|
// Get the property type
|
|
Serializable value = null;
|
|
if (propertyTypeQName.equals(DataTypeDefinition.CONTENT))
|
|
{
|
|
value = new ContentData(null, MimetypeMap.EXTENSION_BINARY, 0L, "UTF-8");
|
|
}
|
|
else if (propertyTypeQName.equals(DataTypeDefinition.LOCALE))
|
|
{
|
|
value = Locale.CHINESE;
|
|
}
|
|
else if (propertyTypeQName.equals(DataTypeDefinition.BOOLEAN))
|
|
{
|
|
value = Boolean.TRUE;
|
|
}
|
|
else if (propertyTypeQName.equals(DataTypeDefinition.PATH))
|
|
{
|
|
value = new Path();
|
|
}
|
|
else if (propertyTypeQName.equals(DataTypeDefinition.QNAME))
|
|
{
|
|
value = TYPE_QNAME_EXTENDED_CONTENT;
|
|
}
|
|
else if (propertyTypeQName.equals(DataTypeDefinition.CATEGORY) || propertyTypeQName.equals(DataTypeDefinition.NODE_REF))
|
|
{
|
|
value = new NodeRef("workspace://SpacesStore/12345");
|
|
}
|
|
else
|
|
{
|
|
value = new Long(System.currentTimeMillis());
|
|
}
|
|
// add it
|
|
properties.put(propertyQName, value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks that aspects can be added, removed and queried. Failure to detect
|
|
* inadequate properties is also checked.
|
|
*/
|
|
public void testAspects() throws Exception
|
|
{
|
|
// create a regular base node
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "test-container"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
// add the titled aspect to the node, but don't supply any properties
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(20);
|
|
nodeService.addAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED, properties);
|
|
|
|
// get the properties required for the aspect
|
|
fillProperties(BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED, properties);
|
|
// get the node properties before
|
|
Map<QName, Serializable> propertiesBefore = nodeService.getProperties(nodeRef);
|
|
// add the aspect
|
|
nodeService.addAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED, properties);
|
|
// get the properties after and check
|
|
Map<QName, Serializable> propertiesAfter = nodeService.getProperties(nodeRef);
|
|
assertEquals("Aspect properties not added",
|
|
propertiesBefore.size() + 2,
|
|
propertiesAfter.size());
|
|
|
|
// check that we know that the aspect is present
|
|
Set<QName> aspects = nodeService.getAspects(nodeRef);
|
|
assertTrue("Titled aspect not present",
|
|
aspects.contains(BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED));
|
|
|
|
// check that hasAspect works
|
|
boolean hasAspect = nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
assertTrue("Aspect not confirmed to be on node", hasAspect);
|
|
|
|
// remove the aspect
|
|
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
hasAspect = nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
assertFalse("Aspect not removed from node", hasAspect);
|
|
|
|
// check that the associated properties were removed
|
|
propertiesAfter = nodeService.getProperties(nodeRef);
|
|
assertEquals("Aspect properties not removed",
|
|
propertiesBefore.size(),
|
|
propertiesAfter.size());
|
|
}
|
|
|
|
public void testAspectsAddedAutomatically() throws Exception
|
|
{
|
|
// Add the test:titled properties
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(20);
|
|
fillProperties(BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED, properties);
|
|
// Create a regular base node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "test-container"),
|
|
ContentModel.TYPE_CONTAINER,
|
|
properties).getChildRef();
|
|
// Ensure that the aspect was automatically added
|
|
assertTrue("Aspect not automatically added during 'createNode'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED));
|
|
|
|
// Remove the aspect and test using setProperties
|
|
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
properties = nodeService.getProperties(nodeRef);
|
|
assertFalse("test:titled properties not removed",
|
|
properties.containsKey(BaseNodeServiceTest.PROP_QNAME_TEST_TITLE));
|
|
assertFalse("test:titled properties not removed",
|
|
properties.containsKey(BaseNodeServiceTest.PROP_QNAME_TEST_DESCRIPTION));
|
|
properties.put(BaseNodeServiceTest.PROP_QNAME_TEST_DESCRIPTION, "A description");
|
|
nodeService.setProperties(nodeRef, properties);
|
|
assertTrue("Aspect not automatically added during 'setProperties'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED));
|
|
|
|
// Remove the aspect and test using addProperties
|
|
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
properties = new HashMap<QName, Serializable>(5);
|
|
properties.put(BaseNodeServiceTest.PROP_QNAME_TEST_DESCRIPTION, "A description");
|
|
nodeService.addProperties(nodeRef, properties);
|
|
assertTrue("Aspect not automatically added during 'addProperties'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED));
|
|
|
|
// Remove the aspect and test using setProperty
|
|
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED);
|
|
nodeService.setProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_TEST_DESCRIPTION, "A description");
|
|
assertTrue("Aspect not automatically added during 'setProperty'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED));
|
|
|
|
// Check that aspects with further mandatory aspects are added properly
|
|
nodeService.setProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_MARKER_PROP, "Marker value");
|
|
assertTrue("Aspect not automatically added during 'setProperty'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_MARKER));
|
|
assertTrue("Aspect not automatically added during 'setProperty' (second-level)",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_QNAME_TEST_MARKER2));
|
|
|
|
// Check that child association creation adds the aspect to the parent
|
|
NodeRef childNodeRef = nodeService.createNode(
|
|
nodeRef,
|
|
BaseNodeServiceTest.ASSOC_ASPECT_CHILD_ASSOC,
|
|
BaseNodeServiceTest.ASSOC_ASPECT_CHILD_ASSOC,
|
|
ContentModel.TYPE_CMOBJECT).getChildRef();
|
|
assertTrue("Aspect not automatically added by child association during 'createNode'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS));
|
|
assertFalse("Unexpected 'aspect' added by child association during 'createNode'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASSOC_ASPECT_CHILD_ASSOC));
|
|
|
|
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS);
|
|
assertFalse("Child node should have been deleted", nodeService.exists(childNodeRef));
|
|
|
|
// Check that normal association creation adds the aspect to the source
|
|
nodeService.createAssociation(nodeRef, rootNodeRef, BaseNodeServiceTest.ASSOC_ASPECT_NORMAL_ASSOC);
|
|
assertTrue("Aspect not automatically added by peer association during 'createAssociation'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS));
|
|
assertFalse("Unexpected aspect added by peer association during 'createAssociation'",
|
|
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASSOC_ASPECT_NORMAL_ASSOC));
|
|
}
|
|
|
|
public void testAspectRemoval() throws Exception
|
|
{
|
|
// Create a node to add the aspect to
|
|
NodeRef sourceNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemoval-source"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
// Create a target for the associations
|
|
NodeRef targetNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemoval-target"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
// Add the aspect to the source
|
|
nodeService.addAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS, null);
|
|
// Make the associations
|
|
nodeService.addChild(
|
|
sourceNodeRef,
|
|
targetNodeRef,
|
|
ASSOC_ASPECT_CHILD_ASSOC,
|
|
QName.createQName(NAMESPACE, "aspect-child"));
|
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC);
|
|
|
|
// Check that the correct associations are present
|
|
assertEquals("Expected exactly one child",
|
|
1, nodeService.getChildAssocs(sourceNodeRef).size());
|
|
assertEquals("Expected exactly one target",
|
|
1, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
|
|
|
// Now remove the aspect
|
|
nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS);
|
|
|
|
// Check that the associations were removed
|
|
assertEquals("Expected exactly zero child",
|
|
0, nodeService.getChildAssocs(sourceNodeRef).size());
|
|
assertEquals("Expected exactly zero target",
|
|
0, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
|
|
|
// Force different cleanup queries:
|
|
// ALF-5308: SQL error when changing name for record / folder with dispostion schedule applied
|
|
nodeService.addAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS_EXTRA, null);
|
|
// Make the associations
|
|
nodeService.addChild(
|
|
sourceNodeRef,
|
|
targetNodeRef,
|
|
ASSOC_ASPECT_CHILD_ASSOC_01,
|
|
QName.createQName(NAMESPACE, "aspect-child-01"));
|
|
nodeService.addChild(
|
|
sourceNodeRef,
|
|
targetNodeRef,
|
|
ASSOC_ASPECT_CHILD_ASSOC_02,
|
|
QName.createQName(NAMESPACE, "aspect-child-02"));
|
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC_01);
|
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC_02);
|
|
nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS_EXTRA);
|
|
}
|
|
|
|
/**
|
|
* Test {@link https://issues.alfresco.com/jira/browse/ALFCOM-2299 ALFCOM-2299}
|
|
*/
|
|
public void testAspectRemovalCascadeDelete() throws Exception
|
|
{
|
|
// Create a node to add the aspect to
|
|
NodeRef sourceNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemovalCascadeDelete"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
// Add the aspect to the source node and add a child using an association defined on the aspect
|
|
nodeService.addAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS, null);
|
|
NodeRef targetNodeRef = nodeService.createNode(
|
|
sourceNodeRef,
|
|
ASSOC_ASPECT_CHILD_ASSOC,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemovalCascadeDelete"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
assertTrue("Child node must exist", nodeService.exists(targetNodeRef));
|
|
// Now remove the aspect from the source node and check that the target node was cascade-deleted
|
|
nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS);
|
|
assertFalse("Child node must have been cascade-deleted", nodeService.exists(targetNodeRef));
|
|
|
|
// Commit for good measure
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
private static final QName ASPECT_QNAME_TEST_RENDERED = QName.createQName(NAMESPACE, "rendered");
|
|
private static final QName ASSOC_TYPE_QNAME_TEST_RENDITION = QName.createQName(NAMESPACE, "rendition-page");
|
|
private static final QName TYPE_QNAME_TEST_RENDITION_PAGE = QName.createQName(NAMESPACE, "rendition-page");
|
|
private static final QName PROP_QNAME_TEST_RENDITION_PAGE_CONTENT = QName.createQName(NAMESPACE, "rendition-page-content");
|
|
public void testAspectWithChildAssociationsCreationAndRetrieval() throws Exception
|
|
{
|
|
// Create a folder. This is like the user's home folder, say.
|
|
NodeRef folderNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ContentModel.ASSOC_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "UserX-" + GUID.generate()),
|
|
ContentModel.TYPE_FOLDER).getChildRef();
|
|
// Create a document. This is the actual document uploaded by the user.
|
|
NodeRef fileNodeRef = nodeService.createNode(
|
|
folderNodeRef,
|
|
ContentModel.ASSOC_CONTAINS,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "Uploaded.pdf"),
|
|
ContentModel.TYPE_FOLDER).getChildRef();
|
|
// So, thus far, this is exactly what you have. Now for the bit to add some renditions.
|
|
// First, we can make some content data pages - spoofed, of course
|
|
List<ContentData> renditionContentPages = new ArrayList<ContentData>(20);
|
|
// This loop is where you will, outside of the transaction, push the page content into the repo
|
|
for(int i = 0; i < 100; i++)
|
|
{
|
|
ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_PDF, 10245, "UTF-8");
|
|
renditionContentPages.add(contentData);
|
|
}
|
|
|
|
nodeService.addAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED, null);
|
|
int pageNumber = 0;
|
|
for (ContentData renditionContentPage : renditionContentPages)
|
|
{
|
|
pageNumber++;
|
|
QName renditionQName = makePageAssocName(pageNumber);
|
|
Map<QName, Serializable> properties = Collections.singletonMap(
|
|
PROP_QNAME_TEST_RENDITION_PAGE_CONTENT,
|
|
(Serializable) renditionContentPage);
|
|
nodeService.createNode(
|
|
fileNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
|
renditionQName,
|
|
TYPE_QNAME_TEST_RENDITION_PAGE,
|
|
properties);
|
|
}
|
|
|
|
// That's it for uploading. Now we retrieve them.
|
|
if (!nodeService.hasAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED))
|
|
{
|
|
// Jump to the original rendition retrieval code
|
|
return;
|
|
}
|
|
// It has the aspect, so it's the new model
|
|
List<ChildAssociationRef> fetchedRenditionChildAssocs = nodeService.getChildAssocs(
|
|
fileNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
assertEquals(
|
|
"We didn't get the correct number of pages back",
|
|
renditionContentPages.size(),
|
|
fetchedRenditionChildAssocs.size());
|
|
// Get page ... 5. This is to prove that they are ordered.
|
|
ChildAssociationRef fetchedRenditionChildAssoc5 = fetchedRenditionChildAssocs.get(4);
|
|
QName page5QName = makePageAssocName(5);
|
|
assertEquals(
|
|
"Local name of page 5 assoc is not correct",
|
|
page5QName,
|
|
fetchedRenditionChildAssoc5.getQName());
|
|
// Now retrieve page 5 using the NodeService
|
|
List<ChildAssociationRef> fetchedRenditionChildAssocsPage5 = nodeService.getChildAssocs(
|
|
fileNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
|
page5QName);
|
|
assertEquals("Expected exactly one result", 1, fetchedRenditionChildAssocsPage5.size());
|
|
assertEquals("Targeted page retrieval was not correct",
|
|
page5QName,
|
|
fetchedRenditionChildAssocsPage5.get(0).getQName());
|
|
}
|
|
private static final int MAX_RENDITION_PAGES = 100;
|
|
private static QName makePageAssocName(int pageNumber)
|
|
{
|
|
if (pageNumber > MAX_RENDITION_PAGES)
|
|
{
|
|
throw new IllegalArgumentException("Rendition page number may not exceed " + MAX_RENDITION_PAGES);
|
|
}
|
|
String pageLocalName = String.format("renditionpage%05d", pageNumber);
|
|
QName renditionQName = QName.createQName(NAMESPACE, pageLocalName);
|
|
return renditionQName;
|
|
}
|
|
|
|
public void testCreateNodeNoProperties() throws Exception
|
|
{
|
|
// flush to ensure that the pure JDBC query will work
|
|
ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("path1"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
assertTrue(nodeService.exists(nodeRef));
|
|
}
|
|
|
|
public void testLargeStrings() throws Exception
|
|
{
|
|
StringBuilder sb = new StringBuilder(2056);
|
|
for (int i = 0; i < 1024; i++)
|
|
{
|
|
if (dialect instanceof DB2Dialect)
|
|
{
|
|
sb.append("A"); // pending ALF-4300
|
|
}
|
|
else
|
|
{
|
|
sb.append("\u1234");
|
|
}
|
|
}
|
|
String longString = sb.toString();
|
|
int len = longString.length();
|
|
|
|
// Create a normal node
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
// fill properties
|
|
fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
|
|
fillProperties(ASPECT_QNAME_TEST_TITLED, properties);
|
|
|
|
// create node for real
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("MyContent"),
|
|
TYPE_QNAME_TEST_CONTENT,
|
|
properties).getChildRef();
|
|
|
|
// Modify name using the long string
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, longString);
|
|
}
|
|
|
|
/**
|
|
* @see #ASPECT_QNAME_TEST_TITLED
|
|
*/
|
|
public void testCreateNodeWithProperties() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
// fill properties
|
|
fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
|
|
fillProperties(ASPECT_QNAME_TEST_TITLED, properties);
|
|
|
|
// create node for real
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("MyContent"),
|
|
TYPE_QNAME_TEST_CONTENT,
|
|
properties);
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
// check that the titled aspect is present
|
|
assertTrue("Titled aspect not present",
|
|
nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_TITLED));
|
|
}
|
|
|
|
public void testCascadeDelete() throws Exception
|
|
{
|
|
// build the node and commit the node graph
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
|
|
NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
|
|
NodeRef n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n7Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n5_p_n7")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// control checks
|
|
assertTrue("n6 not present", nodeService.exists(n6Ref));
|
|
assertTrue("n8 not present", nodeService.exists(n8Ref));
|
|
assertTrue("n8 exists failure", nodeService.exists(n8Ref));
|
|
assertEquals("n6 primary parent association not present on n3", 1, countChildrenOfNode(n3Ref));
|
|
assertEquals("n6 secondary parent association not present on n4", 1, countChildrenOfNode(n4Ref));
|
|
assertEquals("n8 secondary parent association not present on n7", 1, countChildrenOfNode(n7Ref));
|
|
|
|
// delete n6
|
|
nodeService.deleteNode(n6Ref);
|
|
|
|
// ensure that we can't see cascaded nodes in-transaction
|
|
assertFalse("n8 not cascade deleted in-transaction", nodeService.exists(n8Ref));
|
|
|
|
// commit to check
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
assertFalse("n6 not directly deleted", nodeService.exists(n6Ref));
|
|
assertFalse("n8 not cascade deleted", nodeService.exists(n8Ref));
|
|
assertEquals("n6 primary parent association not removed from n3", 0, countChildrenOfNode(n3Ref));
|
|
assertEquals("n6 secondary parent association not removed from n4", 0, countChildrenOfNode(n4Ref));
|
|
assertEquals("n8 secondary parent association not removed from n7", 0, countChildrenOfNode(n7Ref));
|
|
}
|
|
|
|
public static class BadOnDeleteNodePolicy implements
|
|
NodeServicePolicies.OnDeleteNodePolicy,
|
|
NodeServicePolicies.BeforeDeleteNodePolicy
|
|
{
|
|
private NodeService nodeService;
|
|
private List<NodeRef> deletedNodeRefs;
|
|
private List<NodeRef> beforeDeleteNodeRefs;
|
|
|
|
private boolean onDeleteCreateChild = true;
|
|
private boolean beforeDeleteCreateChild = true;
|
|
|
|
public BadOnDeleteNodePolicy(NodeService nodeService,
|
|
List<NodeRef> beforeDeleteNodeRefs,
|
|
List<NodeRef> deletedNodeRefs)
|
|
{
|
|
|
|
|
|
this.nodeService = nodeService;
|
|
this.beforeDeleteNodeRefs = beforeDeleteNodeRefs;
|
|
this.deletedNodeRefs = deletedNodeRefs;
|
|
}
|
|
|
|
public void beforeDeleteNode(NodeRef nodeRef)
|
|
{
|
|
// add the child to the list
|
|
beforeDeleteNodeRefs.add(nodeRef);
|
|
|
|
if(beforeDeleteCreateChild)
|
|
{
|
|
System.out.println("before delete node - add child.");
|
|
// add a new child to the child, i.e. just before it is deleted
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
nodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pre-delete new child"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
// set some child node properties
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_BOOLEAN_VALUE, "true");
|
|
// add an aspect to the child
|
|
nodeService.addAspect(nodeRef, ASPECT_QNAME_TEST_TITLED, null);
|
|
}
|
|
|
|
}
|
|
|
|
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isArchivedNode)
|
|
{
|
|
// add the child to the list
|
|
deletedNodeRefs.add(childAssocRef.getChildRef());
|
|
|
|
if(onDeleteCreateChild)
|
|
{
|
|
System.out.println("on delete node - add sibling.");
|
|
// now perform some nasties on the node's parent, i.e. add a new child
|
|
NodeRef parentRef = childAssocRef.getParentRef();
|
|
NodeRef childRef = childAssocRef.getChildRef();
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("post-delete new child"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
}
|
|
}
|
|
|
|
private void setOnDeleteCreateChild(boolean onDeleteCreateChild)
|
|
{
|
|
this.onDeleteCreateChild = onDeleteCreateChild;
|
|
}
|
|
|
|
private boolean isOnDeleteCreateChild()
|
|
{
|
|
return onDeleteCreateChild;
|
|
}
|
|
|
|
private void setBeforeDeleteCreateChild(boolean beforeDeleteCreateChild)
|
|
{
|
|
this.beforeDeleteCreateChild = beforeDeleteCreateChild;
|
|
}
|
|
|
|
private boolean isBeforeDeleteCreateChild()
|
|
{
|
|
return beforeDeleteCreateChild;
|
|
}
|
|
|
|
}
|
|
|
|
public void testDelete() throws Exception
|
|
{
|
|
final List<NodeRef> beforeDeleteNodeRefs = new ArrayList<NodeRef>(5);
|
|
final List<NodeRef> deletedNodeRefs = new ArrayList<NodeRef>(5);
|
|
|
|
BadOnDeleteNodePolicy nasty = new BadOnDeleteNodePolicy(nodeService, beforeDeleteNodeRefs, deletedNodeRefs);
|
|
nasty.setOnDeleteCreateChild(false);
|
|
nasty.setBeforeDeleteCreateChild(false);
|
|
NodeServicePolicies.OnDeleteNodePolicy policy = nasty;
|
|
|
|
// bind to listen to the deletion of a node
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "onDeleteNode"));
|
|
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "beforeDeleteNode"));
|
|
|
|
// build the node and commit the node graph
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
|
|
NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
|
|
NodeRef n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// delete n1
|
|
nodeService.deleteNode(n1Ref);
|
|
assertFalse("Node not directly deleted", nodeService.exists(n1Ref));
|
|
assertFalse("Node not cascade deleted", nodeService.exists(n3Ref));
|
|
assertTrue("Node incorrectly cascade deleted", nodeService.exists(n4Ref));
|
|
assertFalse("Node not cascade deleted", nodeService.exists(n6Ref));
|
|
assertFalse("Node not cascade deleted", nodeService.exists(n8Ref));
|
|
|
|
// check before delete delete policy has been called
|
|
assertTrue("n1Ref before delete policy not called", beforeDeleteNodeRefs.contains(n1Ref));
|
|
assertTrue("n3Ref before delete policy not called", beforeDeleteNodeRefs.contains(n3Ref));
|
|
assertTrue("n6Ref before delete policy not called", beforeDeleteNodeRefs.contains(n6Ref));
|
|
assertTrue("n8Ref before delete policy not called", beforeDeleteNodeRefs.contains(n8Ref));
|
|
|
|
// check delete policy has been called
|
|
assertTrue("n1Ref delete policy not called", deletedNodeRefs.contains(n1Ref));
|
|
assertTrue("n3Ref delete policy not called", deletedNodeRefs.contains(n3Ref));
|
|
assertTrue("n6Ref delete policy not called", deletedNodeRefs.contains(n6Ref));
|
|
assertTrue("n8Ref delete policy not called", deletedNodeRefs.contains(n8Ref));
|
|
|
|
// commit to check
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
/**
|
|
* This test is similar to the test above but onDelete does nasty stuff such as
|
|
* creating siblings of the soon to be deleted children.
|
|
*
|
|
* In particular, it verifies that we don't get stuck in an infinite loop.
|
|
* @throws Exception
|
|
*/
|
|
public void testDeleteWithBadlyBehavedOnDeletePolicies() throws Exception
|
|
{
|
|
final List<NodeRef> beforeDeleteNodeRefs = new ArrayList<NodeRef>(5);
|
|
final List<NodeRef> deletedNodeRefs = new ArrayList<NodeRef>(5);
|
|
BadOnDeleteNodePolicy nasty = new BadOnDeleteNodePolicy(nodeService, beforeDeleteNodeRefs, deletedNodeRefs);
|
|
|
|
try
|
|
{
|
|
nasty.setOnDeleteCreateChild(true);
|
|
nasty.setBeforeDeleteCreateChild(false);
|
|
NodeServicePolicies.OnDeleteNodePolicy policy = nasty;
|
|
|
|
// bind to listen to the deletion of a node
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "onDeleteNode"));
|
|
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "beforeDeleteNode"));
|
|
|
|
// build the node and commit the node graph
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
|
|
NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
|
|
NodeRef n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// delete n1
|
|
nodeService.deleteNode(n1Ref);
|
|
|
|
fail("test has not detected orphan children");
|
|
|
|
// commit to check
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// We expect to get here with this test.
|
|
//e.printStackTrace();
|
|
}
|
|
finally
|
|
{
|
|
// turn off nasty policy - may upset other tests
|
|
nasty.setOnDeleteCreateChild(false);
|
|
nasty.setBeforeDeleteCreateChild(false);
|
|
}
|
|
}
|
|
/**
|
|
* This test is similar to the test above but beforeDelete does nasty stuff such as
|
|
* creating children of the soon to be deleted children.
|
|
*
|
|
* In particular, it verifies that we don't get stuck in an infinite loop.
|
|
* @throws Exception
|
|
*/
|
|
public void testDeleteWithBadlyBehavedBeforeDeletePolicies() throws Exception
|
|
{
|
|
final List<NodeRef> beforeDeleteNodeRefs = new ArrayList<NodeRef>(5);
|
|
final List<NodeRef> deletedNodeRefs = new ArrayList<NodeRef>(5);
|
|
BadOnDeleteNodePolicy nasty = new BadOnDeleteNodePolicy(nodeService, beforeDeleteNodeRefs, deletedNodeRefs);
|
|
|
|
try
|
|
{
|
|
nasty.setOnDeleteCreateChild(false);
|
|
nasty.setBeforeDeleteCreateChild(true);
|
|
NodeServicePolicies.OnDeleteNodePolicy policy = nasty;
|
|
|
|
// bind to listen to the deletion of a node
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "onDeleteNode"));
|
|
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "beforeDeleteNode"));
|
|
|
|
// build the node and commit the node graph
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
|
|
NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
|
|
NodeRef n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// delete n1
|
|
nodeService.deleteNode(n1Ref);
|
|
|
|
fail("test has not detected orphan children");
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// We expect to get here with this test.
|
|
//e.printStackTrace();
|
|
}
|
|
finally
|
|
{
|
|
// turn off nasty policy - may upset other tests
|
|
nasty.setOnDeleteCreateChild(false);
|
|
nasty.setBeforeDeleteCreateChild(false);
|
|
}
|
|
}
|
|
|
|
private int countChildrenOfNode(NodeRef nodeRef)
|
|
{
|
|
List<ChildAssociationRef> children = nodeService.getChildAssocs(nodeRef);
|
|
return children.size();
|
|
}
|
|
|
|
public void testAddBogusChild() throws Exception
|
|
{
|
|
// create a bogus reference
|
|
NodeRef bogusChildRef = new NodeRef(rootNodeRef.getStoreRef(), "BOGUS");
|
|
try
|
|
{
|
|
nodeService.addChild(rootNodeRef, bogusChildRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("BOGUS_PATH"));
|
|
fail("Failed to detect invalid child node reference");
|
|
}
|
|
catch (InvalidNodeRefException e)
|
|
{
|
|
// expected
|
|
}
|
|
}
|
|
|
|
public void testAddChild() throws Exception
|
|
{
|
|
NodeRef childNodeRef1 = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("C1"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
int count = countChildrenOfNode(rootNodeRef);
|
|
assertEquals("Root children count incorrect", 1, count);
|
|
NodeRef childNodeRef2 = nodeService.createNode(
|
|
childNodeRef1,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("C2"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
count = countChildrenOfNode(rootNodeRef);
|
|
assertEquals("Root children count incorrect", 1, count);
|
|
// associate the two nodes
|
|
nodeService.addChild(
|
|
rootNodeRef,
|
|
childNodeRef2,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathB"));
|
|
// there should now be 2 child assocs on the root
|
|
int countAfter = countChildrenOfNode(rootNodeRef);
|
|
assertEquals("Root children count incorrect", 2, countAfter);
|
|
|
|
// now attempt to create a cyclical relationship
|
|
try
|
|
{
|
|
nodeService.addChild(
|
|
childNodeRef1,
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("backToRoot"));
|
|
fail("Failed to detect cyclic child relationship during addition of child");
|
|
}
|
|
catch (CyclicChildRelationshipException e)
|
|
{
|
|
// expected
|
|
}
|
|
}
|
|
|
|
public void testRemoveSpecificChild() throws Exception
|
|
{
|
|
ChildAssociationRef pathPrimaryRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef parentRef = pathPrimaryRef.getParentRef();
|
|
ChildAssociationRef pathARef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
ChildAssociationRef pathBRef = nodeService.addChild(
|
|
parentRef,
|
|
pathARef.getChildRef(),
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathB"));
|
|
ChildAssociationRef pathCRef = nodeService.addChild(
|
|
parentRef,
|
|
pathARef.getChildRef(),
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathC"));
|
|
|
|
// remove the path B association
|
|
boolean removedB = nodeService.removeChildAssociation(pathBRef);
|
|
assertTrue("Association was not removed", removedB);
|
|
removedB = nodeService.removeChildAssociation(pathBRef);
|
|
assertFalse("Non-existent association was apparently removed", removedB);
|
|
|
|
// remove the path C association
|
|
boolean removedC = nodeService.removeChildAssociation(pathCRef);
|
|
assertTrue("Association was not removed", removedC);
|
|
removedC = nodeService.removeSeconaryChildAssociation(pathCRef);
|
|
assertFalse("Non-existent association was apparently removed", removedC);
|
|
|
|
// Now verify that primary associations are caught
|
|
try
|
|
{
|
|
nodeService.removeSeconaryChildAssociation(pathPrimaryRef);
|
|
fail("Primary association not detected");
|
|
}
|
|
catch (IllegalArgumentException e)
|
|
{
|
|
// Expected
|
|
}
|
|
}
|
|
|
|
public void testRemoveChildByRef() throws Exception
|
|
{
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
ChildAssociationRef pathARef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef childARef = pathARef.getChildRef();
|
|
AssociationRef pathDRef = nodeService.createAssociation(
|
|
parentRef, childARef, ASSOC_TYPE_QNAME_TEST_NEXT);
|
|
// remove the child - this must cascade
|
|
nodeService.removeChild(parentRef, childARef);
|
|
|
|
assertFalse("Primary child not deleted", nodeService.exists(childARef));
|
|
assertEquals("Child assocs not removed",
|
|
0, nodeService.getChildAssocs(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
new RegexQNamePattern(".*", "path*")).size());
|
|
assertEquals("Node assoc not removed",
|
|
0, nodeService.getTargetAssocs(parentRef, RegexQNamePattern.MATCH_ALL).size());
|
|
}
|
|
|
|
public enum TestEnum
|
|
{
|
|
TEST_ONE,
|
|
TEST_TWO
|
|
}
|
|
|
|
public void testProperties() throws Exception
|
|
{
|
|
// create a node to play with
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("playThing"),
|
|
ContentModel.TYPE_CONTAINER);
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
|
|
QName qnameProperty1 = QName.createQName("PROPERTY1");
|
|
String valueProperty1 = "VALUE1";
|
|
QName qnameProperty2 = QName.createQName("PROPERTY2");
|
|
String valueProperty2 = "VALUE2";
|
|
QName qnameProperty3 = QName.createQName("PROPERTY3");
|
|
QName qnameProperty4 = QName.createQName("PROPERTY4");
|
|
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
properties.put(qnameProperty1, valueProperty1);
|
|
// add some properties to the root node
|
|
nodeService.setProperties(nodeRef, properties);
|
|
// set a single property
|
|
nodeService.setProperty(nodeRef, qnameProperty2, valueProperty2);
|
|
// set a null property
|
|
nodeService.setProperty(nodeRef, qnameProperty3, null);
|
|
// set an enum property
|
|
nodeService.setProperty(nodeRef, qnameProperty4, TestEnum.TEST_ONE);
|
|
|
|
// force a flush
|
|
getSession().flush();
|
|
getSession().clear();
|
|
|
|
// now get them back
|
|
Map<QName, Serializable> checkMap = nodeService.getProperties(nodeRef);
|
|
assertNotNull("Properties were not set/retrieved", checkMap);
|
|
assertNotNull("Name property not set automatically", checkMap.get(ContentModel.PROP_NAME));
|
|
assertEquals("Name property to set to ID of node", nodeRef.getId(), checkMap.get(ContentModel.PROP_NAME));
|
|
assertEquals("Property value incorrect", valueProperty1, checkMap.get(qnameProperty1));
|
|
assertEquals("Property value incorrect", valueProperty2, checkMap.get(qnameProperty2));
|
|
assertTrue("Null property not persisted", checkMap.containsKey(qnameProperty3));
|
|
assertNull("Null value not persisted correctly", checkMap.get(qnameProperty3));
|
|
assertEquals("Enum property not retrieved", TestEnum.TEST_ONE, checkMap.get(qnameProperty4));
|
|
|
|
// get a single property direct from the node
|
|
Serializable valueCheck = nodeService.getProperty(nodeRef, qnameProperty2);
|
|
assertNotNull("Property value not set", valueCheck);
|
|
assertEquals("Property value incorrect", "VALUE2", valueCheck);
|
|
|
|
// Remove a property
|
|
nodeService.removeProperty(nodeRef, qnameProperty2);
|
|
valueCheck = nodeService.getProperty(nodeRef, qnameProperty2);
|
|
assertNull("Property not removed", valueCheck);
|
|
|
|
// set the property value to null
|
|
try
|
|
{
|
|
nodeService.setProperty(nodeRef, qnameProperty2, null);
|
|
}
|
|
catch (IllegalArgumentException e)
|
|
{
|
|
fail("Null property values are allowed");
|
|
}
|
|
// try setting null value as part of complete set
|
|
try
|
|
{
|
|
properties = nodeService.getProperties(nodeRef);
|
|
properties.put(qnameProperty1, null);
|
|
nodeService.setProperties(nodeRef, properties);
|
|
}
|
|
catch (IllegalArgumentException e)
|
|
{
|
|
fail("Null property values are allowed in the map");
|
|
}
|
|
}
|
|
|
|
public void testAddProperties() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef);
|
|
// Add an aspect with a default value
|
|
nodeService.addAspect(rootNodeRef, ASPECT_QNAME_TEST_TITLED, null);
|
|
assertNull("Expected null property", nodeService.getProperty(rootNodeRef, PROP_QNAME_TEST_TITLE));
|
|
assertNull("Expected null property", nodeService.getProperty(rootNodeRef, PROP_QNAME_TEST_DESCRIPTION));
|
|
|
|
// Now add a map of two properties and check
|
|
Map<QName, Serializable> addProperties = new HashMap<QName, Serializable>(11);
|
|
addProperties.put(PROP_QNAME_TEST_TITLE, "Title");
|
|
addProperties.put(PROP_QNAME_TEST_DESCRIPTION, "Description");
|
|
nodeService.addProperties(rootNodeRef, addProperties);
|
|
|
|
// Check
|
|
Map<QName, Serializable> checkProperties = nodeService.getProperties(rootNodeRef);
|
|
assertEquals("Title", checkProperties.get(PROP_QNAME_TEST_TITLE));
|
|
assertEquals("Description", checkProperties.get(PROP_QNAME_TEST_DESCRIPTION));
|
|
}
|
|
|
|
public void testDefaultPropertyOverride_AddAspect() throws Exception
|
|
{
|
|
Serializable nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNull("Property should not be present", nullValue);
|
|
|
|
String valueOverride = "VALUE_OVERRIDE";
|
|
Map<QName, Serializable> properties = Collections.singletonMap(PROP_QNAME_PROP2, (Serializable)valueOverride);
|
|
nodeService.addAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE, properties);
|
|
|
|
Serializable checkValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertEquals("Property should not be defaulted", valueOverride, checkValue);
|
|
}
|
|
|
|
public void testDefaultPropertyOverride_CreateNode() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_EXTENDED_CONTENT).getChildRef();
|
|
|
|
Serializable checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertEquals("Property should be defaulted", DEFAULT_VALUE, checkValue);
|
|
|
|
String valueOverride = "VALUE_OVERRIDE";
|
|
Map<QName, Serializable> properties = Collections.singletonMap(PROP_QNAME_PROP1, (Serializable)valueOverride);
|
|
nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_EXTENDED_CONTENT,
|
|
properties).getChildRef();
|
|
|
|
checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertEquals("Property should not be defaulted", valueOverride, checkValue);
|
|
}
|
|
|
|
public void testDefaultPropertyOverride_SpecializeWithoutProperty() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTENT).getChildRef();
|
|
|
|
Serializable checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertNull("Property should not exist", checkValue);
|
|
|
|
// Specialize the type
|
|
nodeService.setType(nodeRef, TYPE_QNAME_EXTENDED_CONTENT);
|
|
|
|
checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertEquals("Property should be defaulted", DEFAULT_VALUE, checkValue);
|
|
}
|
|
|
|
public void testDefaultPropertyOverride_SpecializeWithProperty() throws Exception
|
|
{
|
|
String valueOverride = "VALUE_OVERRIDE";
|
|
Map<QName, Serializable> properties = Collections.singletonMap(PROP_QNAME_PROP1, (Serializable)valueOverride);
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTENT,
|
|
properties).getChildRef();
|
|
|
|
Serializable checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertEquals("Property should not be defaulted", valueOverride, checkValue);
|
|
|
|
// Specialize the type
|
|
nodeService.setType(nodeRef, TYPE_QNAME_EXTENDED_CONTENT);
|
|
|
|
checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
|
|
assertEquals("Property should *still* not be defaulted", valueOverride, checkValue);
|
|
}
|
|
|
|
public void testRemoveProperty() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef);
|
|
// Add an aspect with a default value
|
|
nodeService.addAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE, null);
|
|
// Get the default value
|
|
Serializable defaultValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNotNull("No default property value assigned", defaultValue);
|
|
assertEquals("Property should be defaulted", DEFAULT_VALUE, defaultValue);
|
|
// Now apply the original node properties which didn't contain the value
|
|
nodeService.setProperties(rootNodeRef, properties);
|
|
// Ensure that it is now null
|
|
Serializable nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNull("Property was not removed", nullValue);
|
|
|
|
// Remove the property by removing the aspect
|
|
nodeService.removeAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE);
|
|
nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNull("Property was not removed", nullValue);
|
|
|
|
// Do the same, but explicitly set the value to null
|
|
nodeService.addAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE, null);
|
|
defaultValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNotNull("No default property value assigned", defaultValue);
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_PROP2, null);
|
|
nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNull("Property was not removed", nullValue);
|
|
|
|
// Now remove the property directly
|
|
nodeService.removeAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE);
|
|
nodeService.addAspect(rootNodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE, null);
|
|
defaultValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNotNull("No default property value assigned", defaultValue);
|
|
nodeService.removeProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2);
|
|
assertNull("Property was not removed", nullValue);
|
|
}
|
|
|
|
/**
|
|
* Makes a read-only transaction and then looks for a property using a non-existent QName.
|
|
* The QName persistence must not lazily create QNameEntity instances for queries.
|
|
*/
|
|
public void testGetUnknownProperty() throws Exception
|
|
{
|
|
// commit to keep the root node
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
RetryingTransactionCallback<NodeRef> createCallback = new RetryingTransactionCallback<NodeRef>()
|
|
{
|
|
public NodeRef execute() throws Throwable
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
return nodeRef;
|
|
}
|
|
};
|
|
final NodeRef nodeRef = retryingTransactionHelper.doInTransaction(createCallback, false, true);
|
|
|
|
RetryingTransactionCallback<Object> testCallback = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute() throws Throwable
|
|
{
|
|
QName ficticiousQName = QName.createQName(GUID.generate(), GUID.generate());
|
|
Serializable value = nodeService.getProperty(nodeRef, ficticiousQName);
|
|
assertNull("Didn't expect a value back", value);
|
|
return null;
|
|
}
|
|
};
|
|
retryingTransactionHelper.doInTransaction(testCallback, true, true);
|
|
}
|
|
|
|
/**
|
|
* Ensures that the type you get out of a <b>d:any</b> property is the type that you
|
|
* put in.
|
|
*/
|
|
public void testSerializableProperties() throws Exception
|
|
{
|
|
ContentData contentData = new ContentData(null, null, 0L, null);
|
|
QName qname = PROP_QNAME_CONTENT_VALUE;
|
|
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(17);
|
|
properties.put(PROP_QNAME_CONTENT_VALUE, contentData);
|
|
properties.put(PROP_QNAME_SERIALIZABLE_VALUE, qname);
|
|
// create node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTAINER,
|
|
properties).getChildRef();
|
|
// persist
|
|
flushAndClear();
|
|
|
|
// get the properties back
|
|
Map<QName, Serializable> checkProperties = nodeService.getProperties(nodeRef);
|
|
Serializable checkPropertyContentData = checkProperties.get(PROP_QNAME_CONTENT_VALUE);
|
|
Serializable checkPropertyQname = checkProperties.get(PROP_QNAME_SERIALIZABLE_VALUE);
|
|
assertTrue("Serialization/deserialization of ContentData failed", checkPropertyContentData instanceof ContentData);
|
|
assertTrue("Serialization/deserialization failed", checkPropertyQname instanceof QName);
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public void testMultiProp() throws Exception
|
|
{
|
|
QName undeclaredPropQName = QName.createQName(NAMESPACE, getName());
|
|
// create node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MULTIPLE_TESTER).getChildRef();
|
|
ArrayList<Serializable> values = new ArrayList<Serializable>(1);
|
|
values.add("ABC");
|
|
values.add("DEF");
|
|
// test allowable conditions
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_SINGLE, "ABC");
|
|
// nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_SINGLE, values); -- should fail
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_MULTIPLE, "ABC");
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_MULTIPLE, values);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_SINGLE, "ABC");
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_SINGLE, values);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE, "ABC");
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE, values);
|
|
nodeService.setProperty(nodeRef, undeclaredPropQName, "ABC");
|
|
nodeService.setProperty(nodeRef, undeclaredPropQName, values);
|
|
|
|
// commit as we will be breaking the transaction in the next test
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
UserTransaction txn = transactionService.getUserTransaction();
|
|
try
|
|
{
|
|
txn.begin();
|
|
// this should fail as we are passing multiple values into a non-any that is multiple=false
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_SINGLE, values);
|
|
}
|
|
catch (DictionaryException e)
|
|
{
|
|
// expected
|
|
}
|
|
finally
|
|
{
|
|
try { txn.rollback(); } catch (Throwable e) {}
|
|
}
|
|
|
|
txn = transactionService.getUserTransaction();
|
|
try
|
|
{
|
|
txn.begin();
|
|
// Check that multi-valued d:mltext can be collections of MLText
|
|
values.clear();
|
|
values.add(new MLText("ABC"));
|
|
values.add(new MLText("DEF"));
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, values);
|
|
List<Serializable> checkValues = (List<Serializable>) nodeService.getProperty(
|
|
nodeRef, PROP_QNAME_MULTI_ML_VALUE);
|
|
assertEquals("Expected 2 MLText values back", 2, checkValues.size());
|
|
assertTrue("Incorrect type in collection", checkValues.get(0) instanceof MLText);
|
|
assertTrue("Incorrect type in collection", checkValues.get(1) instanceof MLText);
|
|
|
|
// Check that multi-valued d:any properties can be collections of collections (empty)
|
|
// We put ArrayLists and HashSets into the Collection of d:any, so that is exactly what should come out
|
|
values.clear();
|
|
ArrayList<Serializable> arrayListVal = new ArrayList<Serializable>(2);
|
|
HashSet<Serializable> hashSetVal = new HashSet<Serializable>(2);
|
|
values.add(arrayListVal);
|
|
values.add(hashSetVal);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE, values);
|
|
checkValues = (List<Serializable>) nodeService.getProperty(
|
|
nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE);
|
|
assertEquals("Expected 2 Collection values back", 2, checkValues.size());
|
|
assertTrue("Incorrect type in collection", checkValues.get(0) instanceof ArrayList); // ArrayList in - ArrayList out
|
|
assertTrue("Incorrect type in collection", checkValues.get(1) instanceof HashSet); // HashSet in - HashSet out
|
|
|
|
// Check that multi-valued d:any properties can be collections of collections (with values)
|
|
// We put ArrayLists and HashSets into the Collection of d:any, so that is exactly what should come out
|
|
arrayListVal.add("ONE");
|
|
arrayListVal.add("TWO");
|
|
hashSetVal.add("ONE");
|
|
hashSetVal.add("TWO");
|
|
values.clear();
|
|
values.add(arrayListVal);
|
|
values.add(hashSetVal);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE, values);
|
|
checkValues = (List<Serializable>) nodeService.getProperty(
|
|
nodeRef, PROP_QNAME_ANY_PROP_MULTIPLE);
|
|
assertEquals("Expected 2 Collection values back", 2, checkValues.size());
|
|
assertTrue("Incorrect type in collection", checkValues.get(0) instanceof ArrayList); // ArrayList in - ArrayList out
|
|
assertTrue("Incorrect type in collection", checkValues.get(1) instanceof HashSet); // HashSet in - HashSet out
|
|
assertEquals("First collection incorrect", 2, ((Collection)checkValues.get(0)).size());
|
|
assertEquals("Second collection incorrect", 2, ((Collection)checkValues.get(1)).size());
|
|
}
|
|
catch (DictionaryException e)
|
|
{
|
|
// expected
|
|
}
|
|
finally
|
|
{
|
|
try { txn.rollback(); } catch (Throwable e) {}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Apply any changes to the PROP_QNAME_XXX_VALUE used for checking the following:
|
|
* <pre>
|
|
properties.put(PROP_QNAME_BOOLEAN_VALUE, true);
|
|
properties.put(PROP_QNAME_INTEGER_VALUE, 123);
|
|
properties.put(PROP_QNAME_LONG_VALUE, 123L);
|
|
properties.put(PROP_QNAME_FLOAT_VALUE, 123.0F);
|
|
properties.put(PROP_QNAME_DOUBLE_VALUE, 123.0);
|
|
properties.put(PROP_QNAME_STRING_VALUE, "123.0");
|
|
properties.put(PROP_QNAME_ML_TEXT_VALUE, new MLText("This is ML text in the default language"));
|
|
properties.put(PROP_QNAME_DATE_VALUE, new Date());
|
|
properties.put(PROP_QNAME_SERIALIZABLE_VALUE, "456");
|
|
properties.put(PROP_QNAME_NODEREF_VALUE, rootNodeRef);
|
|
properties.put(PROP_QNAME_QNAME_VALUE, TYPE_QNAME_TEST_CONTENT);
|
|
properties.put(PROP_QNAME_PATH_VALUE, pathProperty);
|
|
properties.put(PROP_QNAME_CONTENT_VALUE, new ContentData("url", "text/plain", 88L, "UTF-8"));
|
|
properties.put(PROP_QNAME_CATEGORY_VALUE, cat);
|
|
properties.put(PROP_QNAME_LOCALE_VALUE, Locale.CHINESE);
|
|
properties.put(PROP_QNAME_NULL_VALUE, null);
|
|
properties.put(PROP_QNAME_MULTI_VALUE, listProperty);
|
|
</pre>
|
|
*/
|
|
protected void getExpectedPropertyValues(Map<QName, Serializable> checkProperties)
|
|
{
|
|
// Do nothing with them by default
|
|
}
|
|
|
|
/**
|
|
* Checks that the 'check' values all match the 'expected' values
|
|
*/
|
|
private void checkProperties(Map<QName, Serializable> checkProperties, Map<QName, Serializable> expectedProperties)
|
|
{
|
|
for (QName qname : expectedProperties.keySet())
|
|
{
|
|
Serializable value = expectedProperties.get(qname);
|
|
Serializable checkValue = checkProperties.get(qname);
|
|
assertEquals("Property mismatch - " + qname, value, checkValue);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check that properties go in and come out in the correct format.
|
|
* @see #getCheckPropertyValues(Map)
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public void testPropertyTypes() throws Exception
|
|
{
|
|
ArrayList<String> listProperty = new ArrayList<String>(2);
|
|
listProperty.add("ABC");
|
|
listProperty.add("DEF");
|
|
|
|
Path pathProperty = new Path();
|
|
pathProperty.append(new Path.SelfElement()).append(new Path.AttributeElement(TYPE_QNAME_TEST_CONTENT));
|
|
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(17);
|
|
properties.put(PROP_QNAME_BOOLEAN_VALUE, true);
|
|
properties.put(PROP_QNAME_INTEGER_VALUE, 123);
|
|
properties.put(PROP_QNAME_LONG_VALUE, 123L);
|
|
properties.put(PROP_QNAME_FLOAT_VALUE, 123.0F);
|
|
properties.put(PROP_QNAME_DOUBLE_VALUE, 123.0);
|
|
properties.put(PROP_QNAME_STRING_VALUE, "123.0");
|
|
properties.put(PROP_QNAME_ML_TEXT_VALUE, new MLText("This is ML text in the default language"));
|
|
properties.put(PROP_QNAME_DATE_VALUE, new Date());
|
|
properties.put(PROP_QNAME_SERIALIZABLE_VALUE, "456");
|
|
properties.put(PROP_QNAME_NODEREF_VALUE, rootNodeRef);
|
|
properties.put(PROP_QNAME_QNAME_VALUE, TYPE_QNAME_TEST_CONTENT);
|
|
properties.put(PROP_QNAME_PATH_VALUE, pathProperty);
|
|
properties.put(PROP_QNAME_CONTENT_VALUE, new ContentData("url", "text/plain", 88L, "UTF-8"));
|
|
properties.put(PROP_QNAME_CATEGORY_VALUE, cat);
|
|
properties.put(PROP_QNAME_LOCALE_VALUE, Locale.CHINESE);
|
|
properties.put(PROP_QNAME_NULL_VALUE, null);
|
|
properties.put(PROP_QNAME_MULTI_VALUE, listProperty);
|
|
properties.put(PROP_QNAME_PERIOD_VALUE, "period|1");
|
|
// Get the check values
|
|
Map<QName, Serializable> expectedProperties = new HashMap<QName, Serializable>(properties);
|
|
getExpectedPropertyValues(expectedProperties);
|
|
|
|
// create a new node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MANY_PROPERTIES,
|
|
properties).getChildRef();
|
|
|
|
// get the properties back
|
|
Map<QName, Serializable> checkProperties = nodeService.getProperties(nodeRef);
|
|
// Check
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// check multi-valued properties are created where necessary
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, "GHI");
|
|
Serializable checkProperty = nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertTrue("Property not converted to a Collection", checkProperty instanceof Collection);
|
|
assertTrue("Collection doesn't contain value", ((Collection)checkProperty).contains("GHI"));
|
|
}
|
|
|
|
public void testPropertyLocaleBehaviour() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(17);
|
|
properties.put(PROP_QNAME_BOOLEAN_VALUE, true);
|
|
properties.put(PROP_QNAME_INTEGER_VALUE, 123);
|
|
properties.put(PROP_QNAME_LONG_VALUE, 123L);
|
|
properties.put(PROP_QNAME_FLOAT_VALUE, 123.0F);
|
|
properties.put(PROP_QNAME_DOUBLE_VALUE, 123.0);
|
|
properties.put(PROP_QNAME_STRING_VALUE, "123.0");
|
|
properties.put(PROP_QNAME_ML_TEXT_VALUE, new MLText("This is ML text in the default language"));
|
|
properties.put(PROP_QNAME_DATE_VALUE, new Date());
|
|
// Get the check values
|
|
Map<QName, Serializable> expectedProperties = new HashMap<QName, Serializable>(properties);
|
|
getExpectedPropertyValues(expectedProperties);
|
|
|
|
Locale.setDefault(Locale.JAPANESE);
|
|
|
|
// create a new node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MANY_PROPERTIES,
|
|
properties).getChildRef();
|
|
|
|
// Check the properties again
|
|
Map<QName, Serializable> checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.US);
|
|
nodeService.setProperties(nodeRef, properties);
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.UK);
|
|
nodeService.setProperties(nodeRef, properties);
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.US);
|
|
nodeService.addProperties(nodeRef, properties);
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.UK);
|
|
nodeService.addProperties(nodeRef, properties);
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.US);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_DATE_VALUE, properties.get(PROP_QNAME_DATE_VALUE));
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
// Change the locale and set the properties again
|
|
I18NUtil.setLocale(Locale.UK);
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_DATE_VALUE, properties.get(PROP_QNAME_DATE_VALUE));
|
|
|
|
// Check the properties again
|
|
checkProperties = nodeService.getProperties(nodeRef);
|
|
checkProperties(checkProperties, expectedProperties);
|
|
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
/**
|
|
* Checks that empty collections can be persisted
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public void testEmptyCollections() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MANY_PROPERTIES).getChildRef();
|
|
|
|
List<String> filledCollection = new ArrayList<String>(2);
|
|
filledCollection.add("ABC");
|
|
filledCollection.add("DEF");
|
|
List<String> emptyCollection = Collections.emptyList();
|
|
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) filledCollection);
|
|
List<String> checkFilledCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertEquals("Filled collection didn't come back with correct values", filledCollection, checkFilledCollection);
|
|
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) emptyCollection);
|
|
List<String> checkEmptyCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertEquals("Empty collection didn't come back with correct values", emptyCollection, checkEmptyCollection);
|
|
|
|
// Check that a null value is returned as null
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, null);
|
|
List<String> checkNullCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertNull("Null property should stay null", checkNullCollection);
|
|
}
|
|
|
|
/**
|
|
* Checks that large collections can be persisted
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public void testBigCollections() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MANY_PROPERTIES).getChildRef();
|
|
|
|
for (int inc = 0; inc < 5; inc++)
|
|
{
|
|
System.out.println("----------------------------------------------");
|
|
int collectionSize = (int) Math.pow(10, inc);
|
|
List<String> largeCollection = new ArrayList<String>(collectionSize);
|
|
for (int i = 0; i < collectionSize; i++)
|
|
{
|
|
largeCollection.add(String.format("Large-collection-value-%05d", i));
|
|
}
|
|
List<String> emptyCollection = Collections.emptyList();
|
|
|
|
long t1 = System.nanoTime();
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) largeCollection);
|
|
double tDelta = (double)(System.nanoTime() - t1)/1E6;
|
|
System.out.println("Setting " + collectionSize + " multi-valued property took: " + tDelta + "ms");
|
|
// Now get it back
|
|
t1 = System.nanoTime();
|
|
List<String> checkLargeCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
tDelta = (double)(System.nanoTime() - t1)/1E6;
|
|
System.out.println("First fetch of " + collectionSize + " multi-valued property took: " + tDelta + "ms");
|
|
assertEquals("Large collection didn't come back with correct values", largeCollection, checkLargeCollection);
|
|
|
|
// Get it back again
|
|
t1 = System.nanoTime();
|
|
checkLargeCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
tDelta = (double)(System.nanoTime() - t1)/1E6;
|
|
System.out.println("Second fetch of " + collectionSize + " multi-valued property took: " + tDelta + "ms");
|
|
|
|
// Add a value
|
|
largeCollection.add("First addition");
|
|
t1 = System.nanoTime();
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) largeCollection);
|
|
tDelta = (double)(System.nanoTime() - t1)/1E6;
|
|
System.out.println("Re-setting " + largeCollection.size() + " multi-valued property took: " + tDelta + "ms");
|
|
|
|
// Add another value
|
|
largeCollection.add("Second addition");
|
|
t1 = System.nanoTime();
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) largeCollection);
|
|
tDelta = (double)(System.nanoTime() - t1)/1E6;
|
|
System.out.println("Re-setting " + largeCollection.size() + " multi-valued property took: " + tDelta + "ms");
|
|
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, (Serializable) emptyCollection);
|
|
List<String> checkEmptyCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertEquals("Empty collection didn't come back with correct values", emptyCollection, checkEmptyCollection);
|
|
|
|
// Check that a null value is returned as null
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_VALUE, null);
|
|
List<String> checkNullCollection = (List<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_VALUE);
|
|
assertNull("Null property should stay null", checkNullCollection);
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public void testMultiValueMLTextProperties() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
TYPE_QNAME_TEST_MANY_ML_PROPERTIES).getChildRef();
|
|
|
|
// Create MLText properties and add to a collection
|
|
List<MLText> mlTextCollection = new ArrayList<MLText>(2);
|
|
MLText mlText0 = new MLText();
|
|
mlText0.addValue(Locale.ENGLISH, "Hello");
|
|
mlText0.addValue(Locale.FRENCH, "Bonjour");
|
|
mlTextCollection.add(mlText0);
|
|
MLText mlText1 = new MLText();
|
|
mlText1.addValue(Locale.ENGLISH, "Bye bye");
|
|
mlText1.addValue(Locale.FRENCH, "Au revoir");
|
|
mlTextCollection.add(mlText1);
|
|
|
|
nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) mlTextCollection);
|
|
Collection<MLText> mlTextCollectionCheck = (Collection<MLText>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
|
|
assertEquals("MLText collection didn't come back correctly.", mlTextCollection, mlTextCollectionCheck);
|
|
}
|
|
|
|
/**
|
|
* Ensures that d:any types are handled correctly when adding values
|
|
*/
|
|
public void testMultivaluedSerializable() throws Exception
|
|
{
|
|
ArrayList<String> listProp = new ArrayList<String>();
|
|
|
|
listProp.clear();
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_MULTIPLE, (Serializable) listProp));
|
|
listProp.add("ONE");
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_MULTIPLE, (Serializable) listProp));
|
|
listProp.add("TWO");
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_MULTIPLE, (Serializable) listProp));
|
|
|
|
listProp.clear();
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_SINGLE, (Serializable) listProp));
|
|
listProp.add("ONE");
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_SINGLE, (Serializable) listProp));
|
|
listProp.add("TWO");
|
|
nodeService.addProperties(
|
|
rootNodeRef,
|
|
Collections.singletonMap(PROP_QNAME_ANY_PROP_SINGLE, (Serializable) listProp));
|
|
}
|
|
|
|
/**
|
|
* Checks that the {@link ContentModel#ASPECT_REFERENCEABLE referencable} properties
|
|
* are present
|
|
*/
|
|
public void testGetReferencableProperties() throws Exception
|
|
{
|
|
// check individual property retrieval
|
|
Serializable wsProtocol = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_PROTOCOL);
|
|
Serializable wsIdentifier = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_IDENTIFIER);
|
|
Serializable nodeUuid = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_UUID);
|
|
Serializable nodeDbId = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID);
|
|
|
|
assertNotNull("Workspace Protocol property not present", wsProtocol);
|
|
assertNotNull("Workspace Identifier property not present", wsIdentifier);
|
|
assertNotNull("Node UUID property not present", nodeUuid);
|
|
assertNotNull("Node DB ID property not present", nodeDbId);
|
|
|
|
assertEquals("Workspace Protocol property incorrect", rootNodeRef.getStoreRef().getProtocol(), wsProtocol);
|
|
assertEquals("Workspace Identifier property incorrect", rootNodeRef.getStoreRef().getIdentifier(), wsIdentifier);
|
|
assertEquals("Node UUID property incorrect", rootNodeRef.getId(), nodeUuid);
|
|
|
|
// check mass property retrieval
|
|
Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef);
|
|
assertTrue("Workspace Protocol property not present in map", properties.containsKey(ContentModel.PROP_STORE_PROTOCOL));
|
|
assertTrue("Workspace Identifier property not present in map", properties.containsKey(ContentModel.PROP_STORE_IDENTIFIER));
|
|
assertTrue("Node UUID property not present in map", properties.containsKey(ContentModel.PROP_NODE_UUID));
|
|
assertTrue("Node DB ID property not present in map", properties.containsKey(ContentModel.PROP_NODE_DBID));
|
|
}
|
|
|
|
public void testReferencePropertySet() throws Exception
|
|
{
|
|
Serializable nodeDbId = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID);
|
|
// Now set it
|
|
nodeService.setProperty(rootNodeRef, ContentModel.PROP_NODE_DBID, new Long(-1));
|
|
Serializable nodeDbIdCheck = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID);
|
|
assertEquals("Cannot set Node DB ID", nodeDbId, nodeDbIdCheck);
|
|
}
|
|
|
|
public void testGetParentAssocs() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
ChildAssociationRef n3pn6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6"));
|
|
ChildAssociationRef n5pn7Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n5_p_n7"));
|
|
ChildAssociationRef n6pn8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
|
|
ChildAssociationRef n7n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n7_n8"));
|
|
// get a child node's parents
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(n8Ref);
|
|
assertEquals("Incorrect number of parents", 3, parentAssocs.size());
|
|
assertTrue("Expected assoc not found", parentAssocs.contains(n6pn8Ref));
|
|
assertTrue("Expected assoc not found", parentAssocs.contains(n7n8Ref));
|
|
|
|
// check that we can retrieve the primary parent
|
|
ChildAssociationRef primaryParentAssocCheck = nodeService.getPrimaryParent(n8Ref);
|
|
assertEquals("Primary parent assoc not retrieved", n6pn8Ref, primaryParentAssocCheck);
|
|
|
|
// check that the root node returns a null primary parent
|
|
ChildAssociationRef rootNodePrimaryAssoc = nodeService.getPrimaryParent(rootNodeRef);
|
|
assertNull("Expected null primary parent for root node", rootNodePrimaryAssoc.getParentRef());
|
|
|
|
// get the parent associations based on pattern
|
|
List<ChildAssociationRef> parentAssocRefsByQName = nodeService.getParentAssocs(
|
|
n8Ref,
|
|
RegexQNamePattern.MATCH_ALL,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "n7_n8"));
|
|
assertEquals("Expected to get exactly one match", 1, parentAssocRefsByQName.size());
|
|
|
|
// get the parent association based on type pattern
|
|
List<ChildAssociationRef> childAssocRefsByTypeQName = nodeService.getChildAssocs(
|
|
n8Ref,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
}
|
|
|
|
public void testGetChildAssocs() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
|
|
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
|
|
ChildAssociationRef n1n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n4"));
|
|
ChildAssociationRef n1n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n8"));
|
|
|
|
// get the parent node's children
|
|
List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(n1Ref);
|
|
assertEquals("Incorrect number of children", 3, childAssocRefs.size());
|
|
// checks that the order of the children is correct
|
|
assertEquals("First child added to n1 was primary to n3: Order of refs is wrong",
|
|
n1pn3Ref, childAssocRefs.get(0));
|
|
assertEquals("Second child added to n1 was to n4: Order of refs is wrong",
|
|
n1n4Ref, childAssocRefs.get(1));
|
|
// now set the child ordering explicitly - change the order
|
|
nodeService.setChildAssociationIndex(n1pn3Ref, 2);
|
|
nodeService.setChildAssociationIndex(n1n8Ref, 1);
|
|
nodeService.setChildAssociationIndex(n1n4Ref, 0);
|
|
|
|
// repeat
|
|
childAssocRefs = nodeService.getChildAssocs(n1Ref);
|
|
assertEquals("Order of refs is wrong", n1pn3Ref, childAssocRefs.get(2));
|
|
assertEquals("Order of refs is wrong", n1n8Ref, childAssocRefs.get(1));
|
|
assertEquals("Order of refs is wrong", n1n4Ref, childAssocRefs.get(0));
|
|
|
|
// get the child associations based on pattern
|
|
List<ChildAssociationRef> childAssocRefsByQName = nodeService.getChildAssocs(
|
|
n1Ref,
|
|
RegexQNamePattern.MATCH_ALL,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3"));
|
|
assertEquals("Expected to get exactly one match", 1, childAssocRefsByQName.size());
|
|
|
|
// get the child association based on type pattern
|
|
List<ChildAssociationRef> childAssocRefsByTypeQName = nodeService.getChildAssocs(
|
|
n1Ref,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
}
|
|
|
|
public void testDuplicateChildAssocCleanup() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
|
|
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
|
|
// Recreate the association from n1 to n3 i.e. duplicate it
|
|
QName assocQName = QName.createQName(BaseNodeServiceTest.NAMESPACE, "dup");
|
|
ChildAssociationRef dup1 = nodeService.addChild(
|
|
n1pn3Ref.getParentRef(),
|
|
n1pn3Ref.getChildRef(),
|
|
n1pn3Ref.getTypeQName(),
|
|
assocQName);
|
|
ChildAssociationRef dup2 = nodeService.addChild(
|
|
n1pn3Ref.getParentRef(),
|
|
n1pn3Ref.getChildRef(),
|
|
n1pn3Ref.getTypeQName(),
|
|
assocQName);
|
|
assertEquals("Duplicate not created", dup1, dup2);
|
|
List<ChildAssociationRef> dupAssocs = nodeService.getChildAssocs(n1pn3Ref.getParentRef(), n1pn3Ref.getTypeQName(), assocQName);
|
|
assertEquals("Expected duplicates", 2, dupAssocs.size());
|
|
// Now delete the specific association
|
|
nodeService.removeChildAssociation(dup1);
|
|
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
public void testGetChildAssocsByChildType() throws Exception
|
|
{
|
|
/*
|
|
* Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5 n1_n8
|
|
* Containers: n1, n3, n4
|
|
* Files: n8
|
|
*/
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n6_p_n8")).getChildRef();
|
|
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
|
|
ChildAssociationRef n1n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n4"));
|
|
ChildAssociationRef n1n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n8"));
|
|
|
|
// Get N1's container children
|
|
List<ChildAssociationRef> childAssocRefsContainers = nodeService.getChildAssocs(
|
|
n1Ref,
|
|
Collections.singleton(ContentModel.TYPE_CONTAINER));
|
|
assertEquals("Incorrect number of cm:container children", 2, childAssocRefsContainers.size());
|
|
assertTrue("Expected assoc not found", childAssocRefsContainers.contains(n1pn3Ref));
|
|
assertTrue("Expected assoc not found", childAssocRefsContainers.contains(n1n4Ref));
|
|
// Get N1's container children
|
|
List<ChildAssociationRef> childAssocRefsFiles = nodeService.getChildAssocs(
|
|
n1Ref,
|
|
Collections.singleton(BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT));
|
|
assertEquals("Incorrect number of test:content children", 1, childAssocRefsFiles.size());
|
|
assertTrue("Expected assoc not found", childAssocRefsFiles.contains(n1n8Ref));
|
|
}
|
|
|
|
public static class MovePolicyTester implements NodeServicePolicies.OnMoveNodePolicy
|
|
{
|
|
public List<ChildAssociationRef> policyAssocRefs = new ArrayList<ChildAssociationRef>(2);
|
|
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
|
{
|
|
policyAssocRefs.add(oldChildAssocRef);
|
|
policyAssocRefs.add(newChildAssocRef);
|
|
}
|
|
};
|
|
|
|
|
|
public void testMoveNode() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
ChildAssociationRef n2pn4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4"));
|
|
ChildAssociationRef n5pn7Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n5_p_n7"));
|
|
ChildAssociationRef n6pn8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
|
|
NodeRef n4Ref = n2pn4Ref.getChildRef();
|
|
NodeRef n5Ref = n5pn7Ref.getParentRef();
|
|
NodeRef n6Ref = n6pn8Ref.getParentRef();
|
|
NodeRef n8Ref = n6pn8Ref.getChildRef();
|
|
|
|
MovePolicyTester policy = new MovePolicyTester();
|
|
// bind to listen to the deletion of a node
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"),
|
|
policy,
|
|
new JavaBehaviour(policy, "onMoveNode"));
|
|
|
|
// move n8 to n5
|
|
ChildAssociationRef assocRef = nodeService.moveNode(
|
|
n8Ref,
|
|
n5Ref,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "n5_p_n8"));
|
|
|
|
// check that the move policy was fired
|
|
assertEquals("Move policy not fired", 2, policy.policyAssocRefs.size());
|
|
|
|
// check that n6 is no longer the parent
|
|
List<ChildAssociationRef> n6ChildRefs = nodeService.getChildAssocs(
|
|
n6Ref,
|
|
RegexQNamePattern.MATCH_ALL, QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
|
|
assertEquals("Primary child assoc is still present", 0, n6ChildRefs.size());
|
|
// check that n5 is the parent
|
|
ChildAssociationRef checkRef = nodeService.getPrimaryParent(n8Ref);
|
|
assertEquals("Primary assoc incorrent", assocRef, checkRef);
|
|
|
|
// check that cyclic associations are disallowed
|
|
try
|
|
{
|
|
// n6 is a non-primary child of n4. Move n4 into n6
|
|
nodeService.moveNode(
|
|
n4Ref,
|
|
n6Ref,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n4"));
|
|
fail("Failed to detect cyclic relationship during move");
|
|
}
|
|
catch (CyclicChildRelationshipException e)
|
|
{
|
|
// expected
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates a named association between two nodes
|
|
*
|
|
* @return Returns an array of [source real NodeRef][target reference NodeRef][assoc name String]
|
|
*/
|
|
private AssociationRef createAssociation() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
|
|
fillProperties(ASPECT_QNAME_TEST_TITLED, properties);
|
|
|
|
ChildAssociationRef childAssocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(null, "N1"),
|
|
TYPE_QNAME_TEST_CONTENT,
|
|
properties);
|
|
NodeRef sourceRef = childAssocRef.getChildRef();
|
|
childAssocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(null, "N2"),
|
|
TYPE_QNAME_TEST_CONTENT,
|
|
properties);
|
|
NodeRef targetRef = childAssocRef.getChildRef();
|
|
|
|
AssociationRef assocRef = nodeService.createAssociation(
|
|
sourceRef,
|
|
targetRef,
|
|
ASSOC_TYPE_QNAME_TEST_NEXT);
|
|
// done
|
|
return assocRef;
|
|
}
|
|
|
|
public void testDuplicateAssociationDetection() throws Exception
|
|
{
|
|
AssociationRef assocRef = createAssociation();
|
|
NodeRef sourceRef = assocRef.getSourceRef();
|
|
NodeRef targetRef = assocRef.getTargetRef();
|
|
QName qname = assocRef.getTypeQName();
|
|
try
|
|
{
|
|
// attempt repeat
|
|
nodeService.createAssociation(sourceRef, targetRef, qname);
|
|
fail("Duplicate assocation not detected");
|
|
}
|
|
catch (AssociationExistsException e)
|
|
{
|
|
// expected
|
|
}
|
|
}
|
|
|
|
public void testCreateAndRemoveAssociation() throws Exception
|
|
{
|
|
AssociationRef assocRef = createAssociation();
|
|
NodeRef sourceRef = assocRef.getSourceRef();
|
|
|
|
// create another
|
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
|
fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
|
|
fillProperties(ASPECT_QNAME_TEST_TITLED, properties);
|
|
ChildAssociationRef childAssocRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(null, "N3"),
|
|
TYPE_QNAME_TEST_CONTENT,
|
|
properties);
|
|
NodeRef anotherTargetRef = childAssocRef.getChildRef();
|
|
AssociationRef anotherAssocRef = nodeService.createAssociation(
|
|
sourceRef,
|
|
anotherTargetRef,
|
|
ASSOC_TYPE_QNAME_TEST_NEXT);
|
|
Long anotherAssocId = anotherAssocRef.getId();
|
|
assertNotNull("Created association does not have an ID", anotherAssocId);
|
|
AssociationRef anotherAssocRefCheck = nodeService.getAssoc(anotherAssocId);
|
|
assertEquals("Assoc fetched by ID is incorrect.", anotherAssocRef, anotherAssocRefCheck);
|
|
|
|
// remove assocs
|
|
List<AssociationRef> assocs = nodeService.getTargetAssocs(sourceRef, ASSOC_TYPE_QNAME_TEST_NEXT);
|
|
for (AssociationRef assoc : assocs)
|
|
{
|
|
nodeService.removeAssociation(
|
|
assoc.getSourceRef(),
|
|
assoc.getTargetRef(),
|
|
assoc.getTypeQName());
|
|
}
|
|
}
|
|
|
|
public void testGetTargetAssocs() throws Exception
|
|
{
|
|
AssociationRef assocRef = createAssociation();
|
|
NodeRef sourceRef = assocRef.getSourceRef();
|
|
NodeRef targetRef = assocRef.getTargetRef();
|
|
QName qname = assocRef.getTypeQName();
|
|
// get the target assocs
|
|
List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(sourceRef, qname);
|
|
assertEquals("Incorrect number of targets", 1, targetAssocs.size());
|
|
assertTrue("Target not found", targetAssocs.contains(assocRef));
|
|
|
|
// Check that IDs are present
|
|
for (AssociationRef targetAssoc : targetAssocs)
|
|
{
|
|
assertNotNull("Association does not have ID", targetAssoc.getId());
|
|
}
|
|
}
|
|
|
|
public void testGetSourceAssocs() throws Exception
|
|
{
|
|
AssociationRef assocRef = createAssociation();
|
|
NodeRef sourceRef = assocRef.getSourceRef();
|
|
NodeRef targetRef = assocRef.getTargetRef();
|
|
QName qname = assocRef.getTypeQName();
|
|
// get the source assocs
|
|
List<AssociationRef> sourceAssocs = nodeService.getSourceAssocs(targetRef, qname);
|
|
assertEquals("Incorrect number of source assocs", 1, sourceAssocs.size());
|
|
assertTrue("Source not found", sourceAssocs.contains(assocRef));
|
|
|
|
// Check that IDs are present
|
|
for (AssociationRef sourceAssoc : sourceAssocs)
|
|
{
|
|
assertNotNull("Association does not have ID", sourceAssoc.getId());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @see #buildNodeGraph()
|
|
*/
|
|
public void testGetPath() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n6_p_n8")).getChildRef();
|
|
|
|
// get the primary node path for n8
|
|
Path path = nodeService.getPath(n8Ref);
|
|
assertEquals("Primary path incorrect",
|
|
"/{" + BaseNodeServiceTest.NAMESPACE + "}root_p_n1/{" + BaseNodeServiceTest.NAMESPACE + "}n1_p_n3/{" + BaseNodeServiceTest.NAMESPACE + "}n3_p_n6/{" + BaseNodeServiceTest.NAMESPACE + "}n6_p_n8",
|
|
path.toString());
|
|
}
|
|
|
|
/**
|
|
* @see #buildNodeGraph()
|
|
*/
|
|
public void testGetPaths() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// get all paths for the root node
|
|
Collection<Path> paths = nodeService.getPaths(rootNodeRef, false);
|
|
assertEquals("Root node must have exactly 1 path", 1, paths.size());
|
|
Path rootPath = paths.toArray(new Path[1])[0];
|
|
assertNotNull("Root node path must have 1 element", rootPath.last());
|
|
assertEquals("Root node path must have 1 element", rootPath.first(), rootPath.last());
|
|
|
|
// get all paths for n8
|
|
paths = nodeService.getPaths(n8Ref, false);
|
|
assertEquals("Incorrect path count", 6, paths.size()); // n6 is a root as well
|
|
// check that each path element has parent node ref, qname and child node ref
|
|
for (Path path : paths)
|
|
{
|
|
// get the path elements
|
|
for (Path.Element element : path)
|
|
{
|
|
assertTrue("Path element of incorrect type", element instanceof Path.ChildAssocElement);
|
|
Path.ChildAssocElement childAssocElement = (Path.ChildAssocElement) element;
|
|
ChildAssociationRef ref = childAssocElement.getRef();
|
|
if (childAssocElement != path.first())
|
|
{
|
|
// for all but the first element, the parent and assoc qname must be set
|
|
assertNotNull("Parent node ref not set", ref.getParentRef());
|
|
assertNotNull("QName not set", ref.getQName());
|
|
}
|
|
// all associations must have a child ref
|
|
assertNotNull("Child node ref not set", ref.getChildRef());
|
|
}
|
|
}
|
|
|
|
// get primary path for n8
|
|
paths = nodeService.getPaths(n8Ref, true);
|
|
assertEquals("Incorrect path count", 1, paths.size());
|
|
|
|
// check that a cyclic path is detected - make n6_n1
|
|
try
|
|
{
|
|
nodeService.addChild(n6Ref, n1Ref, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("n6_n1"));
|
|
nodeService.getPaths(n6Ref, false);
|
|
fail("Cyclic relationship not detected");
|
|
}
|
|
catch (CyclicChildRelationshipException e)
|
|
{
|
|
// expected
|
|
}
|
|
catch (StackOverflowError e)
|
|
{
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
public void testPrimaryPathCascadeDelete() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
|
|
NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
|
|
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
|
|
|
|
// delete n1
|
|
nodeService.deleteNode(n1Ref);
|
|
// check that the rest disappeared
|
|
assertFalse("n6 not cascade deleted", nodeService.exists(n6Ref));
|
|
assertFalse("n8 not cascade deleted", nodeService.exists(n8Ref));
|
|
}
|
|
|
|
/**
|
|
* Test that default values are set when nodes are created and aspects applied
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
public void testDefaultValues() throws Exception
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("testDefaultValues"),
|
|
TYPE_QNAME_EXTENDED_CONTENT).getChildRef();
|
|
assertEquals(DEFAULT_VALUE, this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP1));
|
|
this.nodeService.addAspect(nodeRef, ASPECT_QNAME_WITH_DEFAULT_VALUE, null);
|
|
assertEquals(DEFAULT_VALUE, this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP2));
|
|
|
|
// Ensure that default values do not overrite already set values
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
|
props.put(PROP_QNAME_PROP1, NOT_DEFAULT_VALUE);
|
|
NodeRef nodeRef2 = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("testDefaultValues"),
|
|
TYPE_QNAME_EXTENDED_CONTENT,
|
|
props).getChildRef();
|
|
assertEquals(NOT_DEFAULT_VALUE, this.nodeService.getProperty(nodeRef2, PROP_QNAME_PROP1));
|
|
Map<QName, Serializable> prop2 = new HashMap<QName, Serializable>(1);
|
|
prop2.put(PROP_QNAME_PROP2, NOT_DEFAULT_VALUE);
|
|
this.nodeService.addAspect(nodeRef2, ASPECT_QNAME_WITH_DEFAULT_VALUE, prop2);
|
|
assertEquals(NOT_DEFAULT_VALUE, this.nodeService.getProperty(nodeRef2, PROP_QNAME_PROP2));
|
|
|
|
}
|
|
|
|
public void testMandatoryAspects()
|
|
{
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("testDefaultValues"),
|
|
TYPE_QNAME_TEST_CONTENT).getChildRef();
|
|
|
|
// Check that the required mandatory aspects have been applied
|
|
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_TITLED));
|
|
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_QNAME_MANDATORY));
|
|
|
|
// Add an aspect with dependacies
|
|
this.nodeService.addAspect(nodeRef, ASPECT_QNAME_TEST_MARKER, null);
|
|
|
|
// Check that the dependant aspect has been applied
|
|
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_MARKER));
|
|
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_MARKER2));
|
|
}
|
|
|
|
private void garbageCollect() throws Exception
|
|
{
|
|
// garbage collect and wait
|
|
for (int i = 0; i < 50; i++)
|
|
{
|
|
Runtime.getRuntime().gc();
|
|
synchronized(this)
|
|
{
|
|
this.wait(20);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void reportFlushPerformance(
|
|
String msg,
|
|
Map<QName, ChildAssociationRef> lastNodeGraph,
|
|
int testCount,
|
|
long startBytes,
|
|
long startTime) throws Exception
|
|
{
|
|
long endTime = System.nanoTime();
|
|
double deltaTime = (double)(endTime - startTime)/1000000000D;
|
|
System.out.println(msg + "\n" +
|
|
" Build and flushed " + testCount + " node graphs: \n" +
|
|
" total time: " + deltaTime + "s \n" +
|
|
" average: " + (double)testCount/deltaTime + " graphs/s");
|
|
|
|
garbageCollect();
|
|
long endBytes = Runtime.getRuntime().freeMemory();
|
|
double diffBytes = (double)(startBytes - endBytes);
|
|
System.out.println(
|
|
" total bytes: " + diffBytes/1024D/1024D + " MB \n" +
|
|
" average: " + (double)diffBytes/testCount/1024D + " kb/graph");
|
|
|
|
|
|
int assocsPerGraph = lastNodeGraph.size();
|
|
int nodesPerGraph = 0;
|
|
for (ChildAssociationRef assoc : lastNodeGraph.values())
|
|
{
|
|
if (assoc.getQName().toString().contains("_p_"))
|
|
{
|
|
nodesPerGraph++;
|
|
}
|
|
}
|
|
int totalAssocs = assocsPerGraph * testCount;
|
|
int totalNodes = nodesPerGraph * testCount;
|
|
System.out.println(
|
|
" assocs per graph: " + assocsPerGraph + "\n" +
|
|
" nodes per graph: " + nodesPerGraph + "\n" +
|
|
" total nodes: " + totalNodes + "\n" +
|
|
" total assocs: " + totalAssocs);
|
|
}
|
|
|
|
/**
|
|
* Check that the duplicate child name is detected and thrown correctly
|
|
*/
|
|
public void testDuplicateCatch() throws Exception
|
|
{
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
ChildAssociationRef pathARef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTENT);
|
|
// no issue with this
|
|
ChildAssociationRef pathBRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("pathB"),
|
|
ContentModel.TYPE_CONTENT);
|
|
// there should be no issue with a duplicate association names any more
|
|
ChildAssociationRef pathBDuplicateRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("pathB"),
|
|
ContentModel.TYPE_CONTENT);
|
|
// Now create nodes with duplicate cm:name properties
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(5);
|
|
props.put(ContentModel.PROP_NAME, "ABC");
|
|
ChildAssociationRef pathAbcRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("ABC"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
try
|
|
{
|
|
// now check that the duplicate is detected with attention to being case-insensitive
|
|
props.put(ContentModel.PROP_NAME, "abc");
|
|
ChildAssociationRef pathAbcDuplicateRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("ABC-duplicate"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
fail("Failed to throw duplicate child name exception");
|
|
}
|
|
catch (DuplicateChildNodeNameException e)
|
|
{
|
|
// expected
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create some nodes that have the same <b>cm:name</b> but use associations that don't
|
|
* enforce uniqueness.
|
|
*/
|
|
public void testNonDuplicateAssocsWithSuppliedName() throws Throwable
|
|
{
|
|
Map<QName, Serializable> properties = Collections.singletonMap(ContentModel.PROP_NAME, (Serializable) getName());
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
ChildAssociationRef pathARef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTENT,
|
|
properties);
|
|
ChildAssociationRef pathBRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("pathB"),
|
|
ContentModel.TYPE_CONTENT,
|
|
properties);
|
|
}
|
|
|
|
/**
|
|
* Create some nodes that have the no <b>cm:name</b> and use associations that enforce uniqueness.
|
|
* <p/>
|
|
* ALF-5001: cm:name uniqueness check can fail if the property is not set
|
|
*/
|
|
public void testDuplicateAssocsWithoutSuppliedName() throws Throwable
|
|
{
|
|
Map<QName, Serializable> properties = Collections.emptyMap();
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
ChildAssociationRef pathARef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("pathA"),
|
|
ContentModel.TYPE_CONTENT,
|
|
properties);
|
|
// Add the node to the same parent again
|
|
try
|
|
{
|
|
ChildAssociationRef pathBRef = nodeService.addChild(
|
|
parentRef,
|
|
pathARef.getChildRef(),
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("pathB"));
|
|
fail("Re-added node to parent when cm:name was not set; it should have failed.");
|
|
}
|
|
catch (DuplicateChildNodeNameException e)
|
|
{
|
|
// Expected
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks that the unique constraint doesn't break delete and create within the same
|
|
* transaction.
|
|
*/
|
|
public void testDeleteAndAddSameName() throws Exception
|
|
{
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
// create node ABC
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(5);
|
|
props.put(ContentModel.PROP_NAME, "ABC");
|
|
ChildAssociationRef pathAbcRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("ABC"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
NodeRef abcRef = pathAbcRef.getChildRef();
|
|
// delete ABC
|
|
nodeService.deleteNode(abcRef);
|
|
// create it again
|
|
pathAbcRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("ABC"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
// there should not be any failure when doing this in the same transaction
|
|
}
|
|
|
|
public void testGetByName() throws Exception
|
|
{
|
|
NodeRef parentRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName("parent_child"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
// create node ABC
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(5);
|
|
props.put(ContentModel.PROP_NAME, "ABC");
|
|
ChildAssociationRef pathAbcRef = nodeService.createNode(
|
|
parentRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("ABC"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
NodeRef abcRef = pathAbcRef.getChildRef();
|
|
// create node DEF
|
|
props.put(ContentModel.PROP_NAME, "DEF");
|
|
ChildAssociationRef pathDefRef = nodeService.createNode(
|
|
abcRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("DEF"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
NodeRef defRef = pathDefRef.getChildRef();
|
|
// create node KLM
|
|
props.put(ContentModel.PROP_NAME, "KLM");
|
|
ChildAssociationRef pathKlmRef = nodeService.createNode(
|
|
abcRef,
|
|
ASSOC_TYPE_QNAME_TEST_CONTAINS,
|
|
QName.createQName("KLM"),
|
|
ContentModel.TYPE_CONTENT,
|
|
props);
|
|
NodeRef klmRef = pathDefRef.getChildRef();
|
|
|
|
// now browse down using the node service
|
|
NodeRef checkAbcRef = nodeService.getChildByName(parentRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, "abc");
|
|
assertNotNull("Second level, named node 'ABC' not found", checkAbcRef);
|
|
assertEquals(abcRef, checkAbcRef);
|
|
NodeRef checkDefRef = nodeService.getChildByName(checkAbcRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, "def");
|
|
assertNotNull("Third level, named node 'DEF' not found", checkDefRef);
|
|
assertEquals(defRef, checkDefRef);
|
|
// check that we get null where not present
|
|
NodeRef checkHijRef = nodeService.getChildByName(checkAbcRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, "hij");
|
|
assertNull("Third level, named node 'HIJ' should not have been found", checkHijRef);
|
|
|
|
// Now search for multiple names
|
|
List<String> namesList = Arrays.asList("ABC", "DEF", "HIJ", "KLM");
|
|
List<ChildAssociationRef> childAssocRefs = nodeService.getChildrenByName(checkAbcRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, namesList);
|
|
assertEquals("Expected exactly 2 results", 2, childAssocRefs.size());
|
|
assertTrue("Expected result not included", childAssocRefs.contains(pathDefRef));
|
|
assertTrue("Expected result not included", childAssocRefs.contains(pathKlmRef));
|
|
}
|
|
|
|
public void testLocalizedAspect() throws Exception
|
|
{
|
|
nodeService.addAspect(
|
|
rootNodeRef,
|
|
ContentModel.ASPECT_LOCALIZED,
|
|
Collections.<QName, Serializable>singletonMap(ContentModel.PROP_LOCALE, Locale.CANADA_FRENCH));
|
|
// commit to check
|
|
setComplete();
|
|
endTransaction();
|
|
}
|
|
|
|
public static boolean behaviourExecuted = false;
|
|
|
|
public void testAR1303() throws Exception
|
|
{
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
|
props.put(ContentModel.PROP_NAME, "test.txt");
|
|
|
|
NodeRef nodeRef = this.nodeService.createNode(
|
|
this.rootNodeRef,
|
|
ContentModel.ASSOC_CHILDREN,
|
|
ContentModel.ASSOC_CHILDREN,
|
|
ContentModel.TYPE_CONTENT,
|
|
props).getChildRef();
|
|
|
|
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
|
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, "my description");
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, "my title");
|
|
|
|
JavaBehaviour behaviour = new JavaBehaviour(this, "onUpdateProperties");
|
|
PolicyComponent policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent");
|
|
policyComponent.bindClassBehaviour(
|
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
|
ContentModel.ASPECT_TITLED,
|
|
behaviour);
|
|
|
|
behaviourExecuted = false;
|
|
|
|
// Update the title property and check that the behaviour has been fired
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, "changed title");
|
|
assertTrue("The onUpdateProperties behaviour has not been fired.", behaviourExecuted);
|
|
}
|
|
|
|
public void onUpdateProperties(
|
|
NodeRef nodeRef,
|
|
Map<QName, Serializable> before,
|
|
Map<QName, Serializable> after)
|
|
{
|
|
behaviourExecuted = true;
|
|
assertFalse(before.get(ContentModel.PROP_TITLE).toString().equals(after.get(ContentModel.PROP_TITLE).toString()));
|
|
|
|
System.out.print("Before values: ");
|
|
for (Map.Entry<QName, Serializable> entry : before.entrySet())
|
|
{
|
|
System.out.println(entry.getKey().toString() + " : " + entry.getValue().toString());
|
|
}
|
|
System.out.print("\nAfter values: ");
|
|
for (Map.Entry<QName, Serializable> entry : after.entrySet())
|
|
{
|
|
System.out.println(entry.getKey().toString() + " : " + entry.getValue().toString());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks that unconvertable property values cannot be persisted.
|
|
*/
|
|
public void testAR782() throws Exception
|
|
{
|
|
Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef);
|
|
// Set usr:accountExpiryDate correctly
|
|
properties.put(ContentModel.PROP_ACCOUNT_EXPIRY_DATE, new Date());
|
|
nodeService.setProperties(rootNodeRef, properties);
|
|
try
|
|
{
|
|
// Set usr:accountExpiryDate using something that can't be converted to a Date
|
|
properties.put(ContentModel.PROP_ACCOUNT_EXPIRY_DATE, "blah");
|
|
nodeService.setProperties(rootNodeRef, properties);
|
|
fail("Failed to catch type conversion issue early.");
|
|
}
|
|
catch (TypeConversionException e)
|
|
{
|
|
// Expected
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper test class for {@link BaseNodeServiceTest#testAR1414()}.
|
|
*/
|
|
private static class AR1414Blob implements Serializable
|
|
{
|
|
private static final long serialVersionUID = 5616094206968290908L;
|
|
int i = 0;
|
|
}
|
|
|
|
/**
|
|
* Check that Serializable properties do not remain connected to the L1 session
|
|
*/
|
|
public void testAR1414() throws Exception
|
|
{
|
|
AR1414Blob blob = new AR1414Blob();
|
|
|
|
QName propertyQName = QName.createQName(NAMESPACE, "testAR1414Prop");
|
|
nodeService.setProperty(rootNodeRef, propertyQName, blob);
|
|
// Modify our original blob
|
|
blob.i = 100;
|
|
// Get the property
|
|
AR1414Blob checkBlob = (AR1414Blob) nodeService.getProperty(rootNodeRef, propertyQName);
|
|
assertNotNull(checkBlob);
|
|
assertEquals("Blob was modified while persisted", 0, checkBlob.i);
|
|
}
|
|
}
|