mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
43628: Fix for ALF-16299 - On full user profile, in the 'Sites' tab, the site descriptions are not aligned when a long site description is provided. 43639: ALF-16701: use newly released Spring Surf 1.2.0-M1 rather than a SNAPSHOT 43644: ALF-16527: webscript person.lib.ftl does not include all attributes for users out of the box. - added missing organizationId attribute. 43649: ALF-16756: WebDAV: An error occurs on drag&drop content from local machine to alfresco when inbound move rule configured. 43651: ALF-16756: Fixed typos - I took this code in good faith! 43659: ALF-16006: MT: Document Library is absent after upgrade from 3.4.x to 4.1.x (eg. 3.4.10 -> 4.1.1) - More patch dependencies required 43666: ALF-16833 / MNT-187: Fixed regression in inbound rule firing caused by the fix to ALF-14744 - Inbound rules were not firing for newly created content nodes that had null content properties (e.g. dataListItems) - Now the ALF-14744 fix has been revised so that inbound rules are only not fired for new nodes with zero-length content, as possibly created by the OSX / Windows 7 WebDAV clients during an upload, and only if policy.content.update.ignoreEmpty=true (the default) - OnContentUpdateRuleTrigger removed. Now all content property updates are handled by OnPropertyUpdateRuleTrigger so that we can have this subtle treatment of 'empty' content properties. - Reverted ALF-14744 changes to RuleServiceCoverageTest and added new tests for 'empty' content and ASPECT_NO_CONTENT - Updated RuleTriggerTest in line with changes 43675: Merged V4.1 to V4.1-BUG-FIX 43674: Merged PATCHES/V4.1.1 to V4.1 43673: Merged V3.4-BUG-FIX to PATCHES/V4.1.1 43672: ALF-16834, ALF-16833, MNT-187: Fix unit test failures and 'fine tune' logic to handle multiple updates within a single transaction creating a node 43676: ALF-12324: Can't delete site with WQS content - Don't try to add nodes to the publish queue on site deletion 43689: Fix for ALF-14207 - cm:link not correctly handled in Share's doclist when users don't have permission 43690: Fix for ALF-16538 - Wrong label on change group permission message 43696: ALF-16348 (Inconsistent error message when latest manager leaves a site) 43719: ALF-16031: "CMISChangeLog does not log Created events" 43720: ALF-14137: "When calling CMIS getAllVersions method using the OpenCMIS Browser the PreparedStatement is executed multiple times" 43722: ALF-16352: Re-instated manage permissions action to document list view 43745: Fix for ALF-15351. ContentModelFormProcessor had a TODO to handle associations defined on aspects other than those aspects already on the node for which a form is being submitted. I've added code that, when an association is added to a node, will check if the association is defined on any aspect in the system and if it is, it will let the association be created. 43757: ALF-16171: If a password for admin user is specified with a space in the end during the installation Alfresco startup fails - Added validation that will not allow the specified password to contain leading to trailing white space 43760: Fixed ALF-16317 "Labels not displaying full text when creating a rule on a folder with IE8" part 2 43769: Fix for ALF-13461. Merged PATCHES/V3.4.8 to BRANCHES/DEV/V4.1-BUG-FIX: 43344: MNT-162: Merged DEV to PATCHES/V3.4.8 43254: MNT-162: CLONE - Hidden folder "Comments" is available to searching - Removed last '/' from COMMENT_QNAMEPATH constant. 43770: ALF-15616: Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3) 43768: Merged Dev to V3.4-BUG-FIX (3.4.12) 43743: ALF-11956: WCM accessibility The problem with absence of initial focus on the first Web form element has been resolved in 'alfresco.xforms.XForm._loadHandler()'. This method creates all controls, defined in the form. 'alfresco.xforms.FocusResolver._findControl()' has been renamed to a public-like method ('alfresco.xforms.FocusResolver.findControl()'). Also it has been modified to introduce a possibility of searching elements, using root XForms widgets container. Some other minor fixes. 43772: Fixed ALF-16497 "Selected Items drop down box is expanded to the right in IE9" 43787: Merged in Philippe's fix for ALF-16313:unmakeTranslation() called on pivot language gives exception 43794: ALF-16155: "Notification digest accumulates and is repeatedly sent if 1 or more notification email fails" 43805: ALF-16212: Fixes double encoding issue. 43835: Fixed ALF-13595: Patches third party library date.js to prevent infinite loop. 43836: ALF-16480: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX 43252: MNT-166: Document lock not removed after the lock expiry date has been reached - Changed evaluator "evaluator.doclib.metadata.isLocked" to use "evaluator.doclib.indicator.nodeLocked" and "evaluator.doclib.indicator.lockOwner" evaluator. 43253: MNT-165: "Cancel Editing" does not completely remove lock from document - Added documentLibrary cancel editing action for locked documents. 43300: MNT-171: Merged V4.1-BUG-FIX to PATCHES/V4.1.1 (modified) 43096: Fix for ALF-16283 - When document is checked out, 'Edit Online' and 'Upload New Version' options should not be visible on the original document. 43311: MNT-165: "Cancel Editing" does not completely remove lock from document - Fix for page refresh problem when cancel editing on details page 43421: MNT-186: 4.1.1.7 HF: Webscipt error on doclib page, containing locked by other users files - Change evaluator.doclib.metadata.isLocked to break circular dependency 43755: MNT-202: Upload New Version not available for a document that has been edited offline - Upload New Version is now available if editable by user (respecting locks, type of checkout, etc). 43844: ALF-16696: Merged DEV to V4.1-BUG-FIX 43734: Share nodebrowser is unable to access node of a document with MS residual properties - Use localname if no prefix is registered for a namespace uri 43864: Fixed ALF-16320 "Properties side panel collapses after editing properties in document preview window with IE8" 43866: Fixed ALF-16320 "Properties side panel collapses after editing properties in document preview window with IE8" part 2 - Checking using YAHOO.util.Event.getTarget instead 43867: Fixed ALF-16276 "'"Web View' dahslet displays 2 scrollbars in IE8." 43872: Merged V4.1 to V4.1-BUG-FIX 43622: ALF-16757: Sharepoint doesn't work correct with SSO - Fix by Pavel 43633: Latest translations from Gloria (r43623) 43636: Merged PATCHES/V4.1.1 to V4.1 43301: ALF-16811 / MNT-173: SOLR tracking spending too long evaluating paths - Too much time was being spent fetching the individual nodes in each path and there could be potentially thousands - Now we traverse all the ancestor parent associations in the cache before switching shared cache reads off, then bulk load them in one shot! 43303: ALF-16812 / MNT-174: "dictionaryDAO.init() called, yet no namespace registry for domain" after node rejoins cluster - namespaceRegistryCache is secondary to the clustered dictionaryRegistryCache, so can be a non-clustered cache. Synchronization and thread locals already in use so still thread safe. - dictionaryDAO.init() now has sole responsibility of establishing the NamespaceRegistry threadlocal within its locks, so no more risk of cyclic dependencies, race conditions, partial initialization, or registries dropping out of the cache - To avoid being confused by the 'consistent read' behaviour of a transactional cache, DictionaryDAOImpl now reads / writes directly to a shared cache. Again locks and thread locals still used so still thread safe 43334: ALF-16812 / MNT-174: Fixed failing unit tests - Because DictionaryDAOImpl now reads directly from the shared cache we need to reset it on initialization to avoid problems in multi-context unit tests 43337: ALF-16811 / MNT-173: Fix test failure. Cope with IDs of deleted nodes in getCachedAncestors() 43356: ALF-16811 / MNT-173: If we are disabling shared cache reads for the transaction, convert all existing reads and updates to avoid 'consistent read' behaviour giving us a potentially out of date node already accessed - Existing read buckets are simply thrown away - Updates are converted to removes to avoid any assumptions about existing shared cache content - New entries are left alone as they haven't come from the shared cache anyway 43410: ALF-16813 / MNT-185: Web Scripts are being endlessly re-registering in clustered environment - Due to 'consistent read' behaviour of transactional cache - As accesses are regulated by RW locks we can read straight through to the shared cache instead 43565: ALF-16814 / MNT-190: Bmlab Solr Node 2 threw unhandled NullPointerException (and possibly made solr unresponsive) - Added missing return statement 43646: ALF-15755: Rationalization of WebDAVMethod.checkNode() 43681: Merged HEAD to V4.1 43656: Fix for ALF-16683 CMIS: cannot navigate to original document was created through CMIS with CHECKED OUT version state. 43698: Latest Russian translations from Gloria 43838: ALF-16875: Merged V4.1-BUG-FIX to V4.1 43836: ALF-16480: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX 43252: MNT-166: Document lock not removed after the lock expiry date has been reached - Changed evaluator "evaluator.doclib.metadata.isLocked" to use "evaluator.doclib.indicator.nodeLocked" and "evaluator.doclib.indicator.lockOwner" evaluator. 43253: MNT-165: "Cancel Editing" does not completely remove lock from document - Added documentLibrary cancel editing action for locked documents. 43300: MNT-171: Merged V4.1-BUG-FIX to PATCHES/V4.1.1 (modified) 43096: Fix for ALF-16283 - When document is checked out, 'Edit Online' and 'Upload New Version' options should not be visible on the original document. 43311: MNT-165: "Cancel Editing" does not completely remove lock from document - Fix for page refresh problem when cancel editing on details page 43421: MNT-186: 4.1.1.7 HF: Webscipt error on doclib page, containing locked by other users files - Change evaluator.doclib.metadata.isLocked to break circular dependency 43755: ALF-16890 / MNT-202: Upload New Version not available for a document that has been edited offline - Upload New Version is now available if editable by user (respecting locks, type of checkout, etc). 43868: Reverse merging r43838 - Merge in wrong direction introducing duplicate fragment into share-documentlibrary-config.xml 43871: ALF-16890: Merged PATCHES/V4.1.1 to V4.1 43755: MNT-202: Upload New Version not available for a document that has been edited offline - Upload New Version is now available if editable by user (respecting locks, type of checkout, etc). 43873: Merged V4.1 to V4.1-BUG-FIX (RECORD ONLY) 43602: ALF-16254: Merged V4.1-BUG-FIX to V4.1 43598: Merged HEAD to BRANCHES/DEV/V4.1-BUG-FIX 41906: ALF-11378: REST API has been modified to return extra information about a user whether s/he belongs to a group or not. 43612: ALF-16598: Merged V4.1-BUG-FIX to V4.1 43252: MNT-166: Document lock not removed after the lock expiry date has been reached - Changed evaluator "evaluator.doclib.metadata.isLocked" to use "evaluator.doclib.indicator.nodeLocked" and "evaluator.doclib.indicator.lockOwner" evaluator. 43254: MNT-165: "Cancel Editing" does not completely remove lock from document - Added documentLibrary cancel editing action for locked documents. 43300: MNT-171: Merged V4.1-BUG-FIX to PATCHES/V4.1.1 (modified) 43096: Fix for ALF-16283 - When document is checked out, 'Edit Online' and 'Upload New Version' options should not be visible on the original document. 43311: MNT-165: "Cancel Editing" does not completely remove lock from document - Fix for page refresh problem when cancel editing on details page 43421: MNT-186: 4.1.1.7 HF: Webscipt error on doclib page, containing locked by other users files - Change evaluator.doclib.metadata.isLocked to break circular dependency 43615: ALF-16794: Merged V4.1-BUG-FIX to V4.1 43478: MNT-181: Now WebDAV will ALWAYS preserve the original metadata and versions of ANY node that is temporarily 'moved out' in ANY kind of 'shuffle' operation - To make the source node temporarily invisible to WebDAV the client specific HIDDEN aspect features are used - WebDAVHelper.isRenameShuffle() method introduced, to parallel ALF-3856 CIFS fix and using similar system.webdav.renameShufflePattern global property to detect the start of a shuffle - WebDAVHelper converted to use proper dependency injection - CopyMethod has become a simple subclass of MoveMethod as all the hidden aspect munging is done by it - DeleteMethod now preserves hidden nodes - PropFindMethod now ignores hidden nodes - Listing methods will hide hidden nodes from WebDAV 43483: MNT-181: Corrected typo 43523: MNT-181: Corrections - WebDAVLockService.unlock() made 'harmless' to call on already-unlocked nodes - Delete method hides rather than deletes versioned nodes and working copes in case it is called by OSX Finder during a 'replace' operation 43524: MNT-181: Correction - PutMethod now 'unhides' hidden nodes and behaves as though it created them 43570: MNT-181: More corrections researched by Valery - Don't treat all moves to temporary locations as copies - just those from non-temporary locations. Avoids initial upload leaving lots of hidden files around. - Only copy the content, not the whole node including aspects to avoid versioning temporary files! - Don't version on changes to sys:clientVisibilityMask - avoids 'double versioning' - Recognize Mac .TemporaryItems folder and ._ files as temporary 43586: MNT-181: Final correction researched by Valery - Corrected system.webdav.renameShufflePattern so that it matches .TemporaryItems folder and ._ files as a full match 43616: ALF-15755: Merged V4.1-BUG-FIX to V4.1 43591: ALF-16772: If the WebDAV path of a document exceeds 255 characters, documents opened in MSOffice cannot be saved back - Interpret null nodeLockToken as not locked. 43629: Merged V4.1-BUG-FIX to V4.1 (4.1.2) 43498: Fix for ALF-16648 - Alfresco Enterprise artifacts in artifacts.alfresco.com do not provide POM files / dependencies declarations: Merged HEAD to V4.1-BUG-FIX (4.1.2) 43380: -- added site content for alfresco-platform-distribution POM 43379: -- added site documentation for alfresco-platform-distribution POM 43378: -- added site documentation for alfresco-platform-distribution POM -- deployed site for 4.2.b Community at https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-platform-distribution/latest/index.html -- created repository for Enterprise docs and added url in the appropriate edition properties 43273: Use property to define POI version 42966: ALF-14353 - Added platform distribution POM to standard maven-deploy procedure 42965: ALF-14353 - added alfresco-platform-distribution to provide a Maven release descriptor (dependencyManagement) per each Community / Enterprise release -- moved maven-ant-tasks not to be in the runtime lib -- added platform distribution pom in the SDK folder -- updated maven.xml to deploy filter and deploy the appropriate platform-distribution POM per each releae -- in maven.xml moved configure-release and configure-snapshot goals to maven-env-prerequisites -- updated sdk readme to explain the presence of alfresco-platform-distribution POM 42912: -- updated README header on the POM specifying it's NOT usable to build Alfresco -- make a clear reference to the POMs that get deployed by pom-experimental.xml being usable for development 42842: ALF-14353: Fix artifactId alfresco-jlan -> alfresco-jlan-embed 41883: ALF-14353 - fixed multiple Maven build issues. Now mvn clean install -f pom-experimental.xml works fine. Also deployed Spring Surf 1.2.0-SNAPSHOT so proper Surf version is retrieved 41882: added pre-requisites to build POMs successfully with mvn clean install -f pom-experimental.xml 43634: Merged V4.1-BUG-FIX to V4.1 43386: ALF-13091: Prevent bean post processor propagation to child application contexts. Remove Jsr250BeanPostPorcessor from the CXF configuration, to prevent strange interaction with component scanning. 43641: Merged V4.1-BUG-FIX to V4.1 (4.1.2) 43639: ALF-16701: use newly released Spring Surf 1.2.0-M1 in POM files rather than a SNAPSHOT 43645: Merged V4.1-BUG-FIX to V4.1 43644: ALF-16527: webscript person.lib.ftl does not include all attributes for users out of the box. - added missing organizationId attribute. 43660: Merged V4.1-BUG-FIX to V4.1 43659: ALF-16006: MT: Document Library is absent after upgrade from 3.4.x to 4.1.x (eg. 3.4.10 -> 4.1.1) - More patch dependencies required 43669: Merged V4.1-BUG-FIX to V4.1 43666: ALF-16833 / MNT-187: Fixed regression in inbound rule firing caused by the fix to ALF-14744 - Inbound rules were not firing for newly created content nodes that had null content properties (e.g. dataListItems) - Now the ALF-14744 fix has been revised so that inbound rules are only not fired for new nodes with zero-length content, as possibly created by the OSX / Windows 7 WebDAV clients during an upload, and only if policy.content.update.ignoreEmpty=true (the default) - OnContentUpdateRuleTrigger removed. Now all content property updates are handled by OnPropertyUpdateRuleTrigger so that we can have this subtle treatment of 'empty' content properties. - Reverted ALF-14744 changes to RuleServiceCoverageTest and added new tests for 'empty' content and ASPECT_NO_CONTENT - Updated RuleTriggerTest in line with changes 43697: Merged V4.1-BUG-FIX to V4.1 43689: Fix for ALF-14207 - cm:link not correctly handled in Share's doclist when users don't have permission 43761: Merged V4.1-BUG-FIX to V4.1 43760: Fixed ALF-16317 "Labels not displaying full text when creating a rule on a folder with IE8" part 2 43796: Merged V4.1-BUG-FIX to V4.1 43795: Fix for ALF-16254 - "Leave Site" behaviour for group based site membership: Blah, Blah, Blah! 43883: Fix for ALF-12711. Separated preparation of email message from sending of email message as described in analysis in JIRA. Did not merge the fix provided as MailActionExecuter.java.diff but reimplemented a fix based on that. 43888: ALF-16781: Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3) 43887: ALF-16898 CLONE - Transformation Server history shows incorrect transformation "To" type for images - ImageTransformActionExecuter ("Transform and Copy Image") re-factored to use ContentService rather than hard coded to ImageMagick 43900: Merged V4.1 to V4.1-BUG-FIX 43898: Merged PATCHES/V4.1.1 to V4.1 43708: ALF-16903 / MNT-203: ACL changes not propagated between two non clustered Alfresco instances hitting same Solr and Database - Although SOLRTrackingComponentImpl was not trusting the cache when tracking node transactions, it was still trusting the cache for ACL change sets - This mean that when the SOLR node is using an Alfresco out of the cluster (which we are supposed to support) it could see stale ACLs - Fixed this by using the same strategy we use in AbstractNodeDAO - Now the main acl CRUD cache is set to ignore the shared cache during SOLR tracking - All secondary ACL caches are keyed by ACL ID AND version, so it prevents the possibility of retrieving a stale cached ACL for an old version 43713: ALF-16903 / MNT-203: ACL changes not propagated between two non clustered Alfresco instances hitting same Solr and Database - Fix test failures - deleteAccessControlEntries must 'touch' all the ACLs it affects to keep caches valid - createAccessControlList should return the newly-versioned ACL 43736: ALF-16904 / MNT-204: Index showing no progress on Solr server - SAP's tracking thread got stuck indefinitely waiting on a content response after sending a request, probably due to some misbehaving proxy or balancer - Now we make it possible to recover from this - A new alfresco.socketTimeout parameter is now supported in solrcore.properties - It specifies the number of milliseconds SOLR will wait before giving up waiting for data on an HTTP connection - The default is still zero which means wait indefinitely 43759: ALF-16904 / MNT-204: Fixed compilation error 43899: Merged PATCHES/V4.1.1 to V4.1 (RECORD ONLY) 43667: Merged V4.1-BUG-FIX to PATCHES/V4.1.1 43666: ALF-16833 / MNT-187: Fixed regression in inbound rule firing caused by the fix to ALF-14744 - Inbound rules were not firing for newly created content nodes that had null content properties (e.g. dataListItems) - Now the ALF-14744 fix has been revised so that inbound rules are only not fired for new nodes with zero-length content, as possibly created by the OSX / Windows 7 WebDAV clients during an upload, and only if policy.content.update.ignoreEmpty=true (the default) - OnContentUpdateRuleTrigger removed. Now all content property updates are handled by OnPropertyUpdateRuleTrigger so that we can have this subtle treatment of 'empty' content properties. - Reverted ALF-14744 changes to RuleServiceCoverageTest and added new tests for 'empty' content and ASPECT_NO_CONTENT - Updated RuleTriggerTest in line with changes 43901: Merged V3.4-BUG-FIX to V4.1-BUG-FIX 43571: Merged DEV to V3.4-BUG-FIX 43569: ALF-16222: It's impossible to delete a file/message via IMAP using Microsoft Entourage 2008 in MacOSX 10.8 fixed: UID failed.Existing file or folder error on attempt to delete file if deleted items already contains file with the same name. modified: AttachmentExtractor modified to avoid code dublication. 43599: Fix for ALF-16505 - Discussion topics are sorted in ascending order (oldest first and newest last) when selecting 'All topics' 43610: Merged Dev to V3.4-BUGFIX (3.4.12) 43416: ALF-16470: SPP:Meeting recurent events are displayed incorrect in share calendar in all tabs (Day, Week, Month) Incorrect lucene query to search for events (it was search for events ONLY after fromDate, that gets from browser query. And recursive events, that have startDate before browser's query date, wasn't included into summary query for search for events. Start date is incorrect and is sets two times. Interval for month of end date is to small. Recursive event, that was started in previous month, and ends in current month, isn't included into result of search. For events, that ends on next date after start date, displays (view by month) only start date. 43625: ALF-11817: Cope with incomplete lock token headers from Microsoft-WebDAV-MiniRedir without the enclosing <> by just consuming the whole string 43670: ALF-11817: Prevent auto-hidden dot underscore files from reappearing on a put by checking for a shuffle path before 'unhiding' 43746: Merged DEV to V3.4-BUG-FIX (with corrections) 43692: ALF-16808 Webdav: Two versions of document have been added after the document has been rewritten once more via drag and drop action. 1. Checked whether the current content property is empty. 2. Disabled the versionable aspect. 3. Added the new content to the node. 43763: Fix for ALF-14828 - Incorrect behavior on delete action (WCMQS site) 43771: Fix for ALF-12752 - Custom form appearance parameters not accounted for causing ovverlapped textareas xforms changing their height 43773: Merged DEV to V3.4-BUG-FIX (3.4.12) 42010: ALF-14040: Event start/end time displays incorrect on MS Outlook Calendar and Calendar of created Meeting workspace 1) Send a date for "Site Calendar" dashlet in ISO-8601 format (like in v4.1.1), then after transformation to client's time zone it is displayed correct 2) For "My Calendar" dashlet we need to take into account that if the event is "all day event", then date should be used without time zone transformation 43804: ALF-12326 HomeFolderProviderSynchronizer fails to move any user space which has a rule configured on it 43837: Fixes ALF-12145: Date.js patches merged to 3.4 Merged BRANCHES/DEV/V4.0-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX: 36202: ALF-13483: Japanese: Incorrect date handle in a date Input filed Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX: 43835: Fixed ALF-13595: Patches third party library date.js to prevent infinite loop. 43839: ALF-16869: Merged PATCHES/V3.4.8 to V3.4-BUG-FIX 43344: MNT-162: Merged DEV to PATCHES/V3.4.8 43254: MNT-162: CLONE - Hidden folder "Comments" is available to searching - Removed last '/' from COMMENT_QNAMEPATH constant. 43902: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY) 43177: Merged DEV to V3.4-BUG-FIX 43087: ALF-16474: Records Management groups were not deleted after removing RM site - Delete Records Management groups on ASPECT_RECORDS_MANAGEMENT_ROOT delete - Backport of RM-190 from RM 2.0 43228: ALF-16266: Merged HEAD to V3.4-BUG-FIX 32846: Fixes: ALF-10519: Issues with translation of roles. 31413: Fixes: ALF-10519 - Internationalises the role names for the repo browser's manage permissions page & makes these available to other pages through common.properties 43229: ALF-16266: Fix conflict data left in the properties file. 43624: ALF-11817: Merged PATCHES/V4.0.2 to V3.4-BUG-FIX 43587: Merged BRANCHES/V4.1-BUG-FIX to PATCHES/V4.0.2 42363: ALF-16213: renaming versioned file results in file being deleted. 43478: MNT-181: Now WebDAV will ALWAYS preserve the original metadata and versions of ANY node that is temporarily 'moved out' in ANY kind of 'shuffle' operation - To make the source node temporarily invisible to WebDAV the client specific HIDDEN aspect features are used - WebDAVHelper.isRenameShuffle() method introduced, to parallel ALF-3856 CIFS fix and using similar system.webdav.renameShufflePattern global property to detect the start of a shuffle - WebDAVHelper converted to use proper dependency injection - CopyMethod has become a simple subclass of MoveMethod as all the hidden aspect munging is done by it - DeleteMethod now preserves hidden nodes - PropFindMethod now ignores hidden nodes - Listing methods will hide hidden nodes from WebDAV 43483: MNT-181: Corrected typo 43523: MNT-181: Corrections - WebDAVLockService.unlock() made 'harmless' to call on already-unlocked nodes - Delete method hides rather than deletes versioned nodes and working copies in case it is called by OSX Finder during a 'replace' operation 43524: MNT-181: Correction - PutMethod now 'unhides' hidden nodes and behaves as though it created them 43570: MNT-181: More corrections researched by Valery - Don't treat all moves to temporary locations as copies - just those from non-temporary locations. Avoids initial upload leaving lots of hidden files around. - Only copy the content, not the whole node including aspects to avoid versioning temporary files! - Don't version on changes to sys:clientVisibilityMask - avoids 'double versioning' - Recognize Mac .TemporaryItems folder and ._ files as temporary 43586: MNT-181: Final correction researched by Valery - Corrected system.webdav.renameShufflePattern so that it matches .TemporaryItems folder and ._ files as a full match 43671: ALF-16834: Merged V4.1-BUG-FIX to V3.4-BUG-FIX 43666: ALF-16833 / MNT-187: Fixed regression in inbound rule firing caused by the fix to ALF-14744 - Inbound rules were not firing for newly created content nodes that had null content properties (e.g. dataListItems) - Now the ALF-14744 fix has been revised so that inbound rules are only not fired for new nodes with zero-length content, as possibly created by the OSX / Windows 7 WebDAV clients during an upload, and only if policy.content.update.ignoreEmpty=true (the default) - OnContentUpdateRuleTrigger removed. Now all content property updates are handled by OnPropertyUpdateRuleTrigger so that we can have this subtle treatment of 'empty' content properties. - Reverted ALF-14744 changes to RuleServiceCoverageTest and added new tests for 'empty' content and ASPECT_NO_CONTENT - Updated RuleTriggerTest in line with changes 43842: Merged V4.0-BUG-FIX to V3.4-BUG-FIX 33387: ALF-12492 - Email with empty subject sent to Alfresco by SMTP cause Null pointer Exception 43843: ALF-16717: Merged V4.1-BUG-FIX to V3.4-BUG-FIX 43314: ALF-16575 - Email server does not accept email where Subject ends with a period git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43914 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
1013 lines
42 KiB
Java
1013 lines
42 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.model.ml;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import org.alfresco.error.AlfrescoRuntimeException;
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.node.MLPropertyInterceptor;
|
|
import org.alfresco.repo.policy.BehaviourFilter;
|
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
|
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
|
import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
|
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
|
|
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
|
import org.alfresco.service.cmr.model.FileExistsException;
|
|
import org.alfresco.service.cmr.model.FileFolderService;
|
|
import org.alfresco.service.cmr.model.FileInfo;
|
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.ContentData;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.repository.StoreRef;
|
|
import org.alfresco.service.cmr.security.PermissionService;
|
|
import org.alfresco.service.cmr.version.VersionService;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
import org.alfresco.util.EqualsHelper;
|
|
import org.alfresco.util.PropertyMap;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.springframework.dao.ConcurrencyFailureException;
|
|
import org.springframework.extensions.surf.util.I18NUtil;
|
|
|
|
/**
|
|
* Multilingual support implementation.
|
|
* <p>
|
|
* The basic structure supported is that of a hidden container of type
|
|
* <b>cm:mlContainer</b> containing one or more secondary children of
|
|
* type <b>cm:mlDocument</b>. One of these will have a matching locale
|
|
* and is referred to as the <i>pivot translation</i>. It is also possible
|
|
* to have several transient <b>cm:emptyTranslation</b> instances that
|
|
* live and die with the container until they get their own content.
|
|
* <p>
|
|
* It is not possible to guarantee that there is always a pivot translation
|
|
* available in the set of sibling translations. The strategy is to hide
|
|
* all translations when there isn't a pivot translation available. A
|
|
* background task should be cleaning up the empty or invalid <b>cm:mlContainer</b>
|
|
* instances.
|
|
*
|
|
* @author Derek Hulley
|
|
* @author Philippe Dubois
|
|
* @author Yannick Pignot
|
|
*/
|
|
public class MultilingualContentServiceImpl implements MultilingualContentService
|
|
{
|
|
private static final QName QNAME_ASSOC_ML_ROOT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "multilingualRoot");
|
|
private static final String KEY_ML_CONTAINERS_TO_DELETE = "MultilingualContentServiceImpl.mlContainersToDelete";
|
|
|
|
private static Log logger = LogFactory.getLog(MultilingualContentServiceImpl.class);
|
|
|
|
private NodeService nodeService;
|
|
private PermissionService permissionService;
|
|
private ContentFilterLanguagesService contentFilterLanguagesService;
|
|
private FileFolderService fileFolderService;
|
|
private VersionService versionService;
|
|
|
|
private BehaviourFilter policyBehaviourFilter;
|
|
private final MLContainerCleaner mlContainerCleaner;
|
|
|
|
public MultilingualContentServiceImpl()
|
|
{
|
|
mlContainerCleaner = new MLContainerCleaner();
|
|
}
|
|
|
|
/**
|
|
* @return Returns a reference to the node that will hold all the <b>cm:mlContainer</b> nodes.
|
|
*/
|
|
private NodeRef getMLContainerRoot()
|
|
{
|
|
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
|
List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(
|
|
rootNodeRef,
|
|
ContentModel.ASSOC_CHILDREN,
|
|
QNAME_ASSOC_ML_ROOT);
|
|
if (assocRefs.size() != 1)
|
|
{
|
|
throw new AlfrescoRuntimeException(
|
|
"Unable to find bootstrap location for ML Root using query: " + QNAME_ASSOC_ML_ROOT);
|
|
}
|
|
NodeRef mlRootNodeRef = assocRefs.get(0).getChildRef();
|
|
// Done
|
|
return mlRootNodeRef;
|
|
}
|
|
|
|
private static final QName QNAME_ML_CONTAINER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlContainer");
|
|
private static final QName QNAME_ML_TRANSLATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlTranslation");
|
|
/**
|
|
* @return Returns a new <b>cm:mlContainer</b>
|
|
*/
|
|
private NodeRef makeMLContainer()
|
|
{
|
|
NodeRef mlContainerRootNodeRef = getMLContainerRoot();
|
|
// Create the container
|
|
PropertyMap versionProperties = new PropertyMap();
|
|
//versionProperties.put(ContentModel.PROP_AUTO_VERSION, Boolean.FALSE);
|
|
//versionProperties.put(ContentModel.PROP_INITIAL_VERSION, Boolean.FALSE);
|
|
ChildAssociationRef assocRef = nodeService.createNode(
|
|
mlContainerRootNodeRef,
|
|
ContentModel.ASSOC_CHILDREN,
|
|
QNAME_ML_CONTAINER,
|
|
ContentModel.TYPE_MULTILINGUAL_CONTAINER,
|
|
versionProperties);
|
|
NodeRef mlContainerNodeRef = assocRef.getChildRef();
|
|
// TODO: Examine the usage of versioning - why is autoversioning on and used in the UI?
|
|
// The model makes the container versionable by default, but why?
|
|
nodeService.addAspect(mlContainerNodeRef, ContentModel.ASPECT_VERSIONABLE, versionProperties);
|
|
// Set the permissions to allow anything by anyone
|
|
permissionService.setPermission(
|
|
mlContainerNodeRef,
|
|
PermissionService.ALL_AUTHORITIES,
|
|
PermissionService.ALL_PERMISSIONS, true);
|
|
permissionService.setPermission(
|
|
mlContainerNodeRef,
|
|
AuthenticationUtil.getGuestUserName(),
|
|
PermissionService.ALL_PERMISSIONS, true);
|
|
// Done
|
|
return mlContainerNodeRef;
|
|
}
|
|
|
|
/**
|
|
* Get the ML Container of the given node, allowing null
|
|
* @param mlDocumentNodeRef the translation
|
|
* @param allowNull true if a null value may be returned
|
|
* @return Returns the <b>cm:mlContainer</b> or null if there isn't one
|
|
* @throws AlfrescoRuntimeException if there is no container
|
|
*/
|
|
private NodeRef getMLContainer(NodeRef mlDocumentNodeRef, boolean allowNull)
|
|
{
|
|
NodeRef mlContainerNodeRef = null;
|
|
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(
|
|
mlDocumentNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
if (parentAssocRefs.size() == 0)
|
|
{
|
|
if (!allowNull)
|
|
{
|
|
throw new AlfrescoRuntimeException(
|
|
"No multilingual container exists for document node: " + mlDocumentNodeRef);
|
|
}
|
|
mlContainerNodeRef = null;
|
|
}
|
|
else if (parentAssocRefs.size() >= 1)
|
|
{
|
|
// Just get it
|
|
ChildAssociationRef toKeepAssocRef = parentAssocRefs.get(0);
|
|
mlContainerNodeRef = toKeepAssocRef.getParentRef();
|
|
}
|
|
// Done
|
|
return mlContainerNodeRef;
|
|
}
|
|
|
|
/**
|
|
* Retrieve or create a <b>cm:mlDocument</b> container for the given node, which must have the
|
|
* <b>cm:mlDocument</b> already applied.
|
|
*
|
|
* @param mlDocumentNodeRef an existing <b>cm:mlDocument</b>
|
|
* @param allowCreate <tt>true</tt> if a <b>cm:mlContainer</b> must be created if on doesn't exist,
|
|
* otherwise <tt>false</tt> if a parent <b>cm:mlContainer</b> is expected to exist.
|
|
* @return Returns the <b>cm:mlContainer</b> parent
|
|
*/
|
|
private NodeRef getOrCreateMLContainer(NodeRef mlDocumentNodeRef, boolean allowCreate)
|
|
{
|
|
if (!nodeService.hasAspect(mlDocumentNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
|
{
|
|
throw new IllegalArgumentException(
|
|
"Node must have aspect " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " applied");
|
|
}
|
|
// Now check if a parent mlContainer exists
|
|
NodeRef mlContainerNodeRef = null;
|
|
boolean createAssociation = false;
|
|
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(
|
|
mlDocumentNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
if (parentAssocRefs.size() == 0)
|
|
{
|
|
if (allowCreate)
|
|
{
|
|
// Create a ML container
|
|
mlContainerNodeRef = makeMLContainer();
|
|
createAssociation = true;
|
|
}
|
|
else
|
|
{
|
|
throw new AlfrescoRuntimeException("No multilingual container exists for document node: " + mlDocumentNodeRef);
|
|
}
|
|
}
|
|
else if (parentAssocRefs.size() == 1)
|
|
{
|
|
// Just get it
|
|
ChildAssociationRef toKeepAssocRef = parentAssocRefs.get(0);
|
|
mlContainerNodeRef = toKeepAssocRef.getParentRef();
|
|
}
|
|
else if (parentAssocRefs.size() > 1)
|
|
{
|
|
// This is a problem - destroy all but the first
|
|
logger.warn("Cleaning up multiple multilingual containers on node: " + mlDocumentNodeRef);
|
|
ChildAssociationRef toKeepAssocRef = parentAssocRefs.get(0);
|
|
mlContainerNodeRef = toKeepAssocRef.getParentRef();
|
|
// Remove all the associations to the container
|
|
boolean first = true;
|
|
for (ChildAssociationRef assocRef : parentAssocRefs)
|
|
{
|
|
if (first)
|
|
{
|
|
first = false;
|
|
continue;
|
|
}
|
|
nodeService.removeChildAssociation(assocRef);
|
|
}
|
|
}
|
|
// Associate the translation with the container
|
|
if (createAssociation)
|
|
{
|
|
nodeService.addChild(
|
|
mlContainerNodeRef,
|
|
mlDocumentNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
QNAME_ML_TRANSLATION);
|
|
}
|
|
// done
|
|
return mlContainerNodeRef;
|
|
}
|
|
|
|
private NodeRef makeTranslationImpl(NodeRef mlContainerNodeRef, NodeRef contentNodeRef, Locale locale)
|
|
{
|
|
// Previous versions of the document are not compatible with the versioning requirements
|
|
// dictated by the aspects about to be added. A version has to be forced if the aspect
|
|
// already exists.
|
|
// https://issues.alfresco.com/jira/browse/ETHREEOH-1657
|
|
boolean forceNewVersion = nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE);
|
|
// Add the aspect using the given locale, of necessary
|
|
if (!nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
|
{
|
|
PropertyMap properties = new PropertyMap();
|
|
properties.put(ContentModel.PROP_LOCALE, locale);
|
|
nodeService.addAspect(contentNodeRef, ContentModel.ASPECT_LOCALIZED, properties);
|
|
nodeService.addAspect(contentNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT, null);
|
|
}
|
|
else
|
|
{
|
|
// The aspect is present, so just ensure that the locale is correct
|
|
nodeService.setProperty(contentNodeRef, ContentModel.PROP_LOCALE, locale);
|
|
}
|
|
|
|
if (forceNewVersion)
|
|
{
|
|
versionService.createVersion(contentNodeRef, null);
|
|
}
|
|
|
|
// Do we make use of an existing container?
|
|
if (mlContainerNodeRef == null)
|
|
{
|
|
// Make one
|
|
mlContainerNodeRef = getOrCreateMLContainer(contentNodeRef, true);
|
|
|
|
Serializable containerFunctionalName = nodeService.getProperty(contentNodeRef, ContentModel.PROP_NAME);
|
|
|
|
// set the pivot language and the functional name
|
|
nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE, locale);
|
|
nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_NAME, containerFunctionalName);
|
|
}
|
|
else
|
|
{
|
|
// ALF-2200: Create the translation as the same type as the pivot
|
|
NodeRef pivotNodeRef = this.getPivotTranslation(mlContainerNodeRef);
|
|
if (pivotNodeRef != null && !pivotNodeRef.equals(contentNodeRef))
|
|
{
|
|
QName pivotNodeType = nodeService.getType(pivotNodeRef);
|
|
QName contentNodeType = nodeService.getType(contentNodeRef);
|
|
if (!pivotNodeType.equals(contentNodeType))
|
|
{
|
|
nodeService.setType(contentNodeRef, pivotNodeType);
|
|
}
|
|
}
|
|
|
|
// Check that the language is not duplicated
|
|
Map<Locale, NodeRef> existingLanguages = this.getTranslations(mlContainerNodeRef);
|
|
if (existingLanguages.containsKey(locale))
|
|
{
|
|
throw new AlfrescoRuntimeException("Duplicate locale in document pool: " + locale);
|
|
}
|
|
|
|
// Use the existing container
|
|
nodeService.addChild(
|
|
mlContainerNodeRef,
|
|
contentNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
QNAME_ML_TRANSLATION);
|
|
}
|
|
|
|
// Make sure that we don't delete the container if it was previously scheduled for pre-commit deletion.
|
|
// This arises when editions are going to be created
|
|
TransactionalResourceHelper.getSet(KEY_ML_CONTAINERS_TO_DELETE).remove(mlContainerNodeRef);
|
|
|
|
// done
|
|
return mlContainerNodeRef;
|
|
}
|
|
|
|
private boolean isPivotTranslation(NodeRef contentNodeRef)
|
|
{
|
|
Locale locale = (Locale) nodeService.getProperty(contentNodeRef, ContentModel.PROP_LOCALE);
|
|
// Get the container
|
|
NodeRef containerNodeRef = getOrCreateMLContainer(contentNodeRef, false);
|
|
Locale containerLocale = (Locale) nodeService.getProperty(containerNodeRef, ContentModel.PROP_LOCALE);
|
|
boolean isPivot = EqualsHelper.nullSafeEquals(locale, containerLocale);
|
|
// Done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Node " + (isPivot ? "is" : "is not") + " pivot: " + contentNodeRef);
|
|
}
|
|
return isPivot;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public boolean isTranslation(NodeRef contentNodeRef)
|
|
{
|
|
if (!nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
|
{
|
|
// It doesn't have the aspect, so it isn't a translation
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Document is not multilingual: " + contentNodeRef);
|
|
}
|
|
return false;
|
|
}
|
|
// Are there any associated translations
|
|
Map<Locale, NodeRef> translations = getTranslations(contentNodeRef);
|
|
if (translations.size() > 0)
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Document is a translation: " + contentNodeRef);
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Document is not a translation: " + contentNodeRef);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public void makeTranslation(NodeRef contentNodeRef, Locale locale)
|
|
{
|
|
NodeRef mlContainerNodeRef = makeTranslationImpl(null, contentNodeRef, locale);
|
|
// done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Made a translation: \n" +
|
|
" content: " + contentNodeRef + "\n" +
|
|
" locale: " + locale + "\n" +
|
|
" container: " + mlContainerNodeRef);
|
|
}
|
|
}
|
|
|
|
|
|
/** @inheritDoc */
|
|
public void deleteTranslationContainer(NodeRef mlContainerNodeRef)
|
|
{
|
|
if (!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerNodeRef)))
|
|
{
|
|
throw new IllegalArgumentException(
|
|
"Node type must be " + ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
}
|
|
|
|
// get the translations
|
|
Map<Locale, NodeRef> translations = this.getTranslations(mlContainerNodeRef);
|
|
|
|
// remember the number of childs
|
|
int translationCount = translations.size();
|
|
|
|
// remove the translations
|
|
for(NodeRef translationToRemove : translations.values())
|
|
{
|
|
if (!nodeService.exists(translationToRemove))
|
|
{
|
|
// We've just queried for these
|
|
throw new ConcurrencyFailureException("Translation has been deleted externally: " + translationToRemove);
|
|
}
|
|
nodeService.deleteNode(translationToRemove);
|
|
}
|
|
|
|
// Keep track of the container for pre-commit deletion
|
|
TransactionalResourceHelper.getSet(KEY_ML_CONTAINERS_TO_DELETE).add(mlContainerNodeRef);
|
|
AlfrescoTransactionSupport.bindListener(mlContainerCleaner);
|
|
|
|
// done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("ML container removed: \n" +
|
|
" Container: " + mlContainerNodeRef + "\n" +
|
|
" Number of translations: " + translationCount);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Does the work of making the translation a simple node again. No parent-child relationships
|
|
* are modified and the pivot-container logic is not done here.
|
|
*
|
|
* @param translationNodeRef a translation
|
|
*/
|
|
private void unmakeTranslationSimple(NodeRef translationNodeRef)
|
|
{
|
|
try
|
|
{
|
|
this.policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
|
{
|
|
nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
|
nodeService.addAspect(translationNodeRef, ContentModel.ASPECT_TEMPORARY, null);
|
|
}
|
|
else
|
|
{
|
|
if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
|
{
|
|
nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
|
}
|
|
}
|
|
List<ChildAssociationRef> assocRefs = nodeService.getParentAssocs(
|
|
translationNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
if (assocRefs.size() != 1)
|
|
{
|
|
throw new AlfrescoRuntimeException(
|
|
"Unable to remove ASSOC_MULTILINGUAL_CHILD on : " + translationNodeRef.toString());
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
}
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public void unmakeTranslation(NodeRef translationNodeRef)
|
|
{
|
|
if ((nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) ||
|
|
nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) &&
|
|
isPivotTranslation(translationNodeRef))
|
|
{
|
|
NodeRef containerNodeRef = getMLContainer(translationNodeRef, true);
|
|
// We have not cleaned up all other translations
|
|
// Mark the container for deletion
|
|
TransactionalResourceHelper.getSet(KEY_ML_CONTAINERS_TO_DELETE).add(containerNodeRef);
|
|
AlfrescoTransactionSupport.bindListener(mlContainerCleaner);
|
|
}
|
|
// Turns the document from a translation into a normal document by removing MLDocument aspect
|
|
unmakeTranslationSimple(translationNodeRef);
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public void addTranslation(NodeRef newTranslationNodeRef, NodeRef translationOfNodeRef, Locale locale)
|
|
{
|
|
// Get the container
|
|
NodeRef mlContainerNodeRef = null;
|
|
|
|
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(translationOfNodeRef)))
|
|
{
|
|
mlContainerNodeRef = translationOfNodeRef;
|
|
}
|
|
else
|
|
{
|
|
mlContainerNodeRef = getOrCreateMLContainer(translationOfNodeRef, false);
|
|
}
|
|
|
|
// Use the existing container to make the new content into a translation
|
|
makeTranslationImpl(mlContainerNodeRef, newTranslationNodeRef, locale);
|
|
// done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Added a translation: \n" +
|
|
" Translation of: " + translationOfNodeRef + "\n" +
|
|
" New translation: " + newTranslationNodeRef + "\n" +
|
|
" Locale: " + locale);
|
|
}
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public NodeRef getTranslationContainer(NodeRef translationNodeRef)
|
|
{
|
|
NodeRef mlContainerNodeRef = getOrCreateMLContainer(translationNodeRef, false);
|
|
// done
|
|
return mlContainerNodeRef;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public Map<Locale, NodeRef> getTranslations(NodeRef translationOfNodeRef)
|
|
{
|
|
NodeRef mlContainerNodeRef = null;
|
|
// Were we given the translation or the container
|
|
QName typeQName = nodeService.getType(translationOfNodeRef);
|
|
if (typeQName.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
|
|
{
|
|
// We have the container
|
|
mlContainerNodeRef = translationOfNodeRef;
|
|
}
|
|
else
|
|
{
|
|
// Get the container
|
|
mlContainerNodeRef = getOrCreateMLContainer(translationOfNodeRef, false);
|
|
}
|
|
// Get all the children
|
|
List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(
|
|
mlContainerNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
RegexQNamePattern.MATCH_ALL);
|
|
// Iterate over them and build the map
|
|
Map<Locale, NodeRef> nodeRefsByLocale = new HashMap<Locale, NodeRef>(13);
|
|
for (ChildAssociationRef assocRef : assocRefs)
|
|
{
|
|
NodeRef nodeRef = assocRef.getChildRef();
|
|
// Get the locale
|
|
Locale locale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
|
|
// Map it
|
|
nodeRefsByLocale.put(locale, nodeRef);
|
|
}
|
|
// Done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Found all translations: \n" +
|
|
" Node: " + translationOfNodeRef + " (type " + typeQName + ")\n" +
|
|
" Map: " + nodeRefsByLocale);
|
|
}
|
|
return nodeRefsByLocale;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public NodeRef getTranslationForLocale(NodeRef translationNodeRef, Locale locale)
|
|
{
|
|
// Get all the translations
|
|
Map<Locale, NodeRef> nodeRefsByLocale = getTranslations(translationNodeRef);
|
|
// Get the closest matching locale
|
|
Set<Locale> locales = nodeRefsByLocale.keySet();
|
|
Locale nearestLocale = I18NUtil.getNearestLocale(locale, locales);
|
|
NodeRef nearestNodeRef = nodeRefsByLocale.get(nearestLocale);
|
|
if (nearestNodeRef == null)
|
|
{
|
|
// There is no translation for the locale, so get the pivot translation
|
|
nearestNodeRef = getPivotTranslation(translationNodeRef);
|
|
if (nearestNodeRef == null)
|
|
{
|
|
// There is no pivot translation, so just use the given node
|
|
nearestNodeRef = translationNodeRef;
|
|
}
|
|
}
|
|
// Done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Found nearest locale: \n" +
|
|
" Given node: " + translationNodeRef + "\n" +
|
|
" Given locale: " + locale + "\n" +
|
|
" Found node: " + nearestNodeRef + "\n" +
|
|
" Found locale: " + nearestLocale);
|
|
}
|
|
return nearestNodeRef;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public List<Locale> getMissingTranslations(NodeRef localizedNodeRef, boolean addThisNodeLocale)
|
|
{
|
|
List<Locale> foundLocales = new ArrayList<Locale>(getTranslations(localizedNodeRef).keySet());
|
|
List<String> foundLanguages = new ArrayList<String>();
|
|
|
|
|
|
// transform locales into languages codes
|
|
for(Locale locale : foundLocales)
|
|
{
|
|
foundLanguages.add(locale.getLanguage());
|
|
}
|
|
|
|
// add the locale of the given node if required
|
|
if(addThisNodeLocale)
|
|
{
|
|
Locale localeNode = (Locale) nodeService.getProperty(localizedNodeRef, ContentModel.PROP_LOCALE);
|
|
|
|
if(localeNode != null)
|
|
{
|
|
foundLanguages.remove(localeNode.toString());
|
|
}
|
|
else
|
|
{
|
|
logger.warn("No locale found for the node " + localizedNodeRef);
|
|
}
|
|
}
|
|
|
|
List<String> missingLanguages = null;
|
|
|
|
if(foundLanguages.size() == 0)
|
|
{
|
|
// The given node is the only one available translation and it must
|
|
// be return.
|
|
// MissingLanguages become the entire list pf languages.
|
|
missingLanguages = contentFilterLanguagesService.getFilterLanguages();
|
|
}
|
|
else
|
|
{
|
|
// get the missing languages form the list of content filter languages
|
|
missingLanguages = contentFilterLanguagesService.getMissingLanguages(foundLanguages);
|
|
}
|
|
// construct a list of locales
|
|
List<Locale> missingLocales = new ArrayList<Locale>(missingLanguages.size() + 1);
|
|
|
|
for(String lang : missingLanguages)
|
|
{
|
|
missingLocales.add(I18NUtil.parseLocale(lang));
|
|
}
|
|
|
|
return missingLocales;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
public NodeRef getPivotTranslation(NodeRef nodeRef)
|
|
{
|
|
Locale containerLocale = null;
|
|
if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
|
{
|
|
NodeRef container = getTranslationContainer(nodeRef);
|
|
containerLocale = (Locale) nodeService.getProperty(container, ContentModel.PROP_LOCALE);
|
|
}
|
|
else if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(nodeRef)))
|
|
{
|
|
containerLocale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
|
|
}
|
|
else
|
|
{
|
|
logger.warn("The node is not multilingual " + nodeRef);
|
|
}
|
|
// Get all the translations
|
|
Map<Locale, NodeRef> nodeRefsByLocale = getTranslations(nodeRef);
|
|
// Get the closest matching locale
|
|
Set<Locale> locales = nodeRefsByLocale.keySet();
|
|
Locale nearestLocale = I18NUtil.getNearestLocale(containerLocale, locales);
|
|
if (nearestLocale == null)
|
|
{
|
|
// There is no pivot translation
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
return nodeRefsByLocale.get(nearestLocale);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public NodeRef addEmptyTranslation(NodeRef translationOfNodeRef, String name, Locale locale)
|
|
{
|
|
boolean hasMLAspect = nodeService.hasAspect(translationOfNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
|
boolean isMLContainer = nodeService.getType(translationOfNodeRef).equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
|
|
if (hasMLAspect || isMLContainer)
|
|
{
|
|
// Get the pivot translation
|
|
NodeRef pivotTranslationNodeRef = getPivotTranslation(translationOfNodeRef);
|
|
if (pivotTranslationNodeRef != null)
|
|
{
|
|
// We found a pivot translation, so use it
|
|
translationOfNodeRef = pivotTranslationNodeRef;
|
|
}
|
|
else
|
|
{
|
|
// We use the given translation
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new IllegalArgumentException(
|
|
"Node must have aspect " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + ": \n" +
|
|
" Translation: " + translationOfNodeRef + "\n" +
|
|
" Locale: " + locale);
|
|
}
|
|
|
|
FileInfo translationOfFileInfo = fileFolderService.getFileInfo(translationOfNodeRef);
|
|
String translationOfName = translationOfFileInfo.getName();
|
|
// If name is null, supply one
|
|
if (name == null)
|
|
{
|
|
name = translationOfName;
|
|
}
|
|
// If there is a name clash, add the locale to the main portion of the filename
|
|
if (name.equalsIgnoreCase(translationOfName))
|
|
{
|
|
String localeStr = locale.toString();
|
|
if (localeStr.endsWith("_"))
|
|
{
|
|
localeStr = localeStr.substring(0, localeStr.length() - 1);
|
|
}
|
|
String rawName;
|
|
String extension;
|
|
int index = name.lastIndexOf('.');
|
|
if (index > 0)
|
|
{
|
|
rawName = name.substring(0, index);
|
|
extension = "." + name.substring(index + 1);
|
|
}
|
|
else
|
|
{
|
|
rawName = name;
|
|
extension = ""; // No extension
|
|
}
|
|
name = rawName + "_" + localeStr + extension;
|
|
}
|
|
|
|
// Create the document in the space of the node of reference
|
|
NodeRef parentNodeRef = nodeService.getPrimaryParent(translationOfNodeRef).getParentRef();
|
|
|
|
// Create the empty translation.
|
|
// ALF-2200: Create the translation as the same type as the pivot
|
|
QName newTranslationType = nodeService.getType(translationOfNodeRef);
|
|
NodeRef newTranslationNodeRef = fileFolderService.create(
|
|
parentNodeRef,
|
|
name,
|
|
newTranslationType).getNodeRef();
|
|
|
|
// add the translation to the container
|
|
addTranslation(newTranslationNodeRef, translationOfNodeRef, locale);
|
|
|
|
// Although the content is spoofed from the pivot translation, it isn't done for all services
|
|
// TODO: Fix http://issues.alfresco.com/browse/AR-1487
|
|
ContentData translationOfContentData = (ContentData) nodeService.getProperty(translationOfNodeRef, ContentModel.PROP_CONTENT);
|
|
if (translationOfContentData != null)
|
|
{
|
|
ContentData newTranslationContentData = new ContentData(
|
|
null,
|
|
translationOfContentData.getMimetype(),
|
|
translationOfContentData.getSize(),
|
|
translationOfContentData.getEncoding(),
|
|
translationOfContentData.getLocale());
|
|
nodeService.setProperty(newTranslationNodeRef, ContentModel.PROP_CONTENT, newTranslationContentData);
|
|
}
|
|
|
|
// set it empty
|
|
nodeService.addAspect(newTranslationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION, null);
|
|
// Initially, the file should be temporary. This will be changed as soon as some content is added.
|
|
nodeService.addAspect(newTranslationNodeRef, ContentModel.ASPECT_TEMPORARY, null);
|
|
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Added an empty translation: \n" +
|
|
" Translation of: " + translationOfNodeRef + "\n" +
|
|
" New translation: " + newTranslationNodeRef + "\n" +
|
|
" Locale: " + locale);
|
|
}
|
|
|
|
return newTranslationNodeRef;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public NodeRef copyTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef, String prefixName) throws Exception
|
|
{
|
|
// There is no need for the properties interceptor here
|
|
boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
|
|
|
|
if(!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerNodeRef)))
|
|
{
|
|
throw new IllegalArgumentException(
|
|
"Node type must be " + ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
}
|
|
|
|
// if the container has no translation: nothing to do
|
|
if(nodeService.getChildAssocs(mlContainerNodeRef, ContentModel.ASSOC_MULTILINGUAL_CHILD, RegexQNamePattern.MATCH_ALL).size() < 1)
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("MLContainer has no translation " + mlContainerNodeRef);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
// keep a reference to the containing space before copy
|
|
NodeRef spaceBefore = nodeService.getPrimaryParent(getPivotTranslation(mlContainerNodeRef)).getParentRef();
|
|
|
|
if(spaceBefore.equals(newParentRef))
|
|
{
|
|
throw new AlfrescoRuntimeException(
|
|
"Impossible to copy the mlContainer, source folder is the same as the destination container.");
|
|
}
|
|
|
|
// get the pivot translation and its locale
|
|
NodeRef pivotNodeRef = getPivotTranslation(mlContainerNodeRef);
|
|
Locale pivotLocale = (Locale) nodeService.getProperty(pivotNodeRef, ContentModel.PROP_LOCALE);
|
|
String pivotName = prefixName + (String) nodeService.getProperty(pivotNodeRef, ContentModel.PROP_NAME);
|
|
|
|
if(prefixName == null)
|
|
{
|
|
prefixName = "";
|
|
}
|
|
|
|
NodeRef pivotCopyNodeRef = null;
|
|
|
|
pivotCopyNodeRef = fileFolderService.copy(pivotNodeRef, newParentRef, pivotName).getNodeRef();
|
|
|
|
// make the new pivot multilingual
|
|
this.makeTranslation(pivotCopyNodeRef, pivotLocale);
|
|
|
|
// get a reference to the new mlContainer
|
|
NodeRef newMLContainerNodeRef = getMLContainer(pivotCopyNodeRef, false);
|
|
|
|
// copy each other translation and make them multilingual too
|
|
for(Map.Entry<Locale, NodeRef> entry : getTranslations(mlContainerNodeRef).entrySet())
|
|
{
|
|
Locale translationLocale = entry.getKey();
|
|
NodeRef translationNodeRef = entry.getValue();
|
|
|
|
String name = prefixName + (String) nodeService.getProperty(translationNodeRef, ContentModel.PROP_NAME);
|
|
|
|
if(!translationNodeRef.equals(pivotNodeRef))
|
|
{
|
|
if(nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
|
{
|
|
// Turn off any empty translation policy behaviours to enabled the copy.
|
|
this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
|
this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
|
|
|
try
|
|
{
|
|
// copy the translation
|
|
NodeRef copyNodeRef = fileFolderService.copy(translationNodeRef, newParentRef, name).getNodeRef();
|
|
|
|
// Add it to the newMLContainer
|
|
nodeService.addChild(
|
|
newMLContainerNodeRef,
|
|
copyNodeRef,
|
|
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
|
QNAME_ML_TRANSLATION);
|
|
|
|
// Add the ML aspects back
|
|
nodeService.addAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT, null);
|
|
nodeService.addAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION, null);
|
|
}
|
|
finally
|
|
{
|
|
this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
|
this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// copy the translation
|
|
NodeRef copyNodeRef = fileFolderService.copy(translationNodeRef, newParentRef, name).getNodeRef();
|
|
|
|
// add it to the mlContainer
|
|
this.addTranslation(copyNodeRef, newMLContainerNodeRef, translationLocale);
|
|
// set its locale property
|
|
nodeService.setProperty(copyNodeRef, ContentModel.PROP_LOCALE, translationLocale);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// the pivot is already created
|
|
}
|
|
}
|
|
|
|
// The rest of the transaction can have properties modified
|
|
MLPropertyInterceptor.setMLAware(wasMLAware);
|
|
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("MLContainer copied: \n" +
|
|
" Copy of : " + mlContainerNodeRef + "(translations located in " + spaceBefore + ") \n" +
|
|
" Copy : " + newMLContainerNodeRef + "(translations located in " + newParentRef + ") \n");
|
|
}
|
|
|
|
return newMLContainerNodeRef;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public void moveTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef) throws FileExistsException, FileNotFoundException
|
|
{
|
|
if(!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerNodeRef)))
|
|
{
|
|
throw new IllegalArgumentException(
|
|
"Node type must be " + ContentModel.TYPE_MULTILINGUAL_CONTAINER);
|
|
}
|
|
|
|
// if the container has no translation: nothing to do
|
|
if(nodeService.getChildAssocs(mlContainerNodeRef, ContentModel.ASSOC_MULTILINGUAL_CHILD, RegexQNamePattern.MATCH_ALL).size() < 1)
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("MLContainer has no translation " + mlContainerNodeRef);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// keep a reference to the containing space before moving
|
|
NodeRef spaceBefore = nodeService.getPrimaryParent(getPivotTranslation(mlContainerNodeRef)).getParentRef();
|
|
|
|
if(spaceBefore.equals(newParentRef))
|
|
{
|
|
// nothing to do
|
|
return;
|
|
}
|
|
|
|
// move each translation
|
|
for(NodeRef translationToMove : getTranslations(mlContainerNodeRef).values())
|
|
{
|
|
fileFolderService.move(translationToMove, newParentRef, null);
|
|
}
|
|
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("MLContainer moved: \n" +
|
|
" Old location of " + mlContainerNodeRef + " : " + spaceBefore + ") \n" +
|
|
" New location of " + mlContainerNodeRef + " : " + newParentRef + ")");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cleans up any <b>ml:container</b> types that are empty or have lost their pivot translation
|
|
*
|
|
* @author Derek Hulley
|
|
* @since 4.1.1
|
|
*/
|
|
private class MLContainerCleaner extends TransactionListenerAdapter
|
|
{
|
|
@Override
|
|
public void beforeCommit(boolean readOnly)
|
|
{
|
|
if (readOnly)
|
|
{
|
|
return; // Don't ever expect to be here
|
|
}
|
|
Set<NodeRef> mlContainerNodeRefs = TransactionalResourceHelper.getSet(KEY_ML_CONTAINERS_TO_DELETE);
|
|
for (NodeRef mlContainerNodeRef : mlContainerNodeRefs)
|
|
{
|
|
// Just delete it.
|
|
// Any remaining translations will be cleaned up
|
|
nodeService.deleteNode(mlContainerNodeRef);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.nodeService = nodeService;
|
|
}
|
|
|
|
public void setPermissionService(PermissionService permissionService)
|
|
{
|
|
this.permissionService = permissionService;
|
|
}
|
|
|
|
public void setContentFilterLanguagesService(ContentFilterLanguagesService contentFilterLanguagesService)
|
|
{
|
|
this.contentFilterLanguagesService = contentFilterLanguagesService;
|
|
}
|
|
|
|
public void setFileFolderService(FileFolderService fileFolderService)
|
|
{
|
|
this.fileFolderService = fileFolderService;
|
|
}
|
|
|
|
public void setVersionService(VersionService versionService)
|
|
{
|
|
this.versionService = versionService;
|
|
}
|
|
|
|
public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
|
|
{
|
|
this.policyBehaviourFilter = policyBehaviourFilter;
|
|
}
|
|
} |