mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +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
1116 lines
36 KiB
Java
1116 lines
36 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.webdav;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.InetAddress;
|
|
import java.net.MalformedURLException;
|
|
import java.net.NetworkInterface;
|
|
import java.net.URL;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.StringTokenizer;
|
|
import java.util.regex.Pattern;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import org.alfresco.jlan.util.IPAddress;
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.lock.LockUtils;
|
|
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
|
import org.alfresco.repo.policy.BehaviourFilter;
|
|
import org.alfresco.repo.tenant.TenantService;
|
|
import org.alfresco.service.ServiceRegistry;
|
|
import org.alfresco.service.cmr.action.ActionService;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.lock.LockService;
|
|
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.CopyService;
|
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
import org.alfresco.service.cmr.search.SearchService;
|
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
|
import org.alfresco.service.cmr.security.PermissionService;
|
|
import org.alfresco.service.cmr.site.SiteInfo;
|
|
import org.alfresco.service.cmr.site.SiteService;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.util.EqualsHelper;
|
|
import org.alfresco.util.Pair;
|
|
import org.apache.commons.lang.NotImplementedException;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.springframework.extensions.surf.util.URLDecoder;
|
|
import org.springframework.extensions.surf.util.URLEncoder;
|
|
import org.springframework.util.StringUtils;
|
|
import org.xml.sax.helpers.AttributesImpl;
|
|
|
|
/**
|
|
* WebDAV Protocol Helper Class
|
|
*
|
|
* <p>Provides helper methods for repository access using the WebDAV protocol.
|
|
*
|
|
* @author GKSpencer
|
|
*/
|
|
public class WebDAVHelper
|
|
{
|
|
// Constants
|
|
|
|
public static final String BEAN_NAME = "webDAVHelper";
|
|
|
|
private static final String HTTPS_SCHEME = "https://";
|
|
private static final String HTTP_SCHEME = "http://";
|
|
|
|
|
|
// Path seperator
|
|
public static final String PathSeperator = "/";
|
|
public static final char PathSeperatorChar = '/';
|
|
public static final String EMPTY_SITE_ID = "";
|
|
|
|
// Logging
|
|
private static Log logger = LogFactory.getLog("org.alfresco.webdav.protocol");
|
|
|
|
// Service registry TODO: eliminate this - not dependency injection!
|
|
private ServiceRegistry m_serviceRegistry;
|
|
|
|
// Services
|
|
private NodeService m_nodeService;
|
|
private FileFolderService m_fileFolderService;
|
|
private SearchService m_searchService;
|
|
private NamespaceService m_namespaceService;
|
|
private DictionaryService m_dictionaryService;
|
|
private MimetypeService m_mimetypeService;
|
|
private WebDAVLockService m_lockService;
|
|
private ActionService m_actionService;
|
|
private AuthenticationService m_authService;
|
|
private PermissionService m_permissionService;
|
|
private TenantService m_tenantService;
|
|
private HiddenAspect m_hiddenAspect;
|
|
|
|
// pattern is tested against full path after it has been lower cased.
|
|
private Pattern m_renameShufflePattern = Pattern.compile("(.*/\\..*)|(.*[a-f0-9]{8}+$)|(.*\\.tmp$)|(.*\\.wbk$)|(.*\\.bak$)|(.*\\~$)");
|
|
|
|
// Empty XML attribute list
|
|
|
|
private final AttributesImpl m_nullAttribs = new AttributesImpl();
|
|
|
|
private BehaviourFilter m_policyBehaviourFilter;
|
|
|
|
private String m_urlPathPrefix;
|
|
|
|
/**
|
|
* Set the regular expression that will be applied to filenames during renames
|
|
* to detect whether clients are performing a renaming shuffle - common during
|
|
* file saving on various clients.
|
|
* <p/>
|
|
* <bALF-3856, ALF-7079, MNT-181</b>
|
|
*
|
|
* @param renameShufflePattern a regular expression filename match
|
|
*/
|
|
public void setRenameShufflePattern(Pattern renameShufflePattern)
|
|
{
|
|
this.m_renameShufflePattern = renameShufflePattern;
|
|
}
|
|
|
|
/**
|
|
* @return Return the authentication service
|
|
*/
|
|
public final AuthenticationService getAuthenticationService()
|
|
{
|
|
return m_authService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the service registry
|
|
*/
|
|
public final ServiceRegistry getServiceRegistry()
|
|
{
|
|
// TODO: eliminate this - not dependency injection!
|
|
return m_serviceRegistry;
|
|
}
|
|
|
|
/**
|
|
* @return Return the node service
|
|
*/
|
|
public final NodeService getNodeService()
|
|
{
|
|
return m_nodeService;
|
|
}
|
|
|
|
public FileFolderService getFileFolderService()
|
|
{
|
|
return m_fileFolderService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the search service
|
|
*/
|
|
public final SearchService getSearchService()
|
|
{
|
|
return m_searchService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the namespace service
|
|
*/
|
|
public final NamespaceService getNamespaceService()
|
|
{
|
|
return m_namespaceService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the dictionary service
|
|
*/
|
|
public final DictionaryService getDictionaryService()
|
|
{
|
|
return m_dictionaryService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the mimetype service
|
|
*/
|
|
public final MimetypeService getMimetypeService()
|
|
{
|
|
return m_mimetypeService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the lock service
|
|
*/
|
|
public final WebDAVLockService getLockService()
|
|
{
|
|
return m_lockService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the action service
|
|
*/
|
|
public final ActionService getActionService()
|
|
{
|
|
return m_actionService;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return Return the permission service
|
|
*/
|
|
public final PermissionService getPermissionService()
|
|
{
|
|
return m_permissionService;
|
|
}
|
|
|
|
/**
|
|
* @return the hidden aspect bean
|
|
*/
|
|
public final HiddenAspect getHiddenAspect()
|
|
{
|
|
return m_hiddenAspect;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the {@link TenantService} held by the helper.
|
|
*
|
|
* @return TenantService
|
|
*/
|
|
public TenantService getTenantService()
|
|
{
|
|
return m_tenantService;
|
|
}
|
|
|
|
/**
|
|
* @return Return the copy service
|
|
*/
|
|
public final CopyService getCopyService()
|
|
{
|
|
return getServiceRegistry().getCopyService();
|
|
}
|
|
|
|
public void setTenantService(TenantService tenantService)
|
|
{
|
|
this.m_tenantService = tenantService;
|
|
}
|
|
|
|
/**
|
|
* @param serviceRegistry the service registry
|
|
*/
|
|
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
|
{
|
|
this.m_serviceRegistry = serviceRegistry;
|
|
}
|
|
|
|
/**
|
|
* @param nodeService the node service
|
|
*/
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.m_nodeService = nodeService;
|
|
}
|
|
|
|
/**
|
|
* @param fileFolderService the fileFolder service
|
|
*/
|
|
public void setFileFolderService(FileFolderService fileFolderService)
|
|
{
|
|
this.m_fileFolderService = fileFolderService;
|
|
}
|
|
|
|
/**
|
|
* @param searchService the search service
|
|
*/
|
|
public void setSearchService(SearchService searchService)
|
|
{
|
|
this.m_searchService = searchService;
|
|
}
|
|
|
|
/**
|
|
* @param namespaceService the namespace service
|
|
*/
|
|
public void setNamespaceService(NamespaceService namespaceService)
|
|
{
|
|
this.m_namespaceService = namespaceService;
|
|
}
|
|
|
|
/**
|
|
* @param dictionaryService the dictionary service
|
|
*/
|
|
public void setDictionaryService(DictionaryService dictionaryService)
|
|
{
|
|
this.m_dictionaryService = dictionaryService;
|
|
}
|
|
|
|
/**
|
|
* @param mimetypeService the mimetype service
|
|
*/
|
|
public void setMimetypeService(MimetypeService mimetypeService)
|
|
{
|
|
this.m_mimetypeService = mimetypeService;
|
|
}
|
|
|
|
/**
|
|
* @param lockService the lock service
|
|
*/
|
|
public void setLockService(WebDAVLockService lockService)
|
|
{
|
|
this.m_lockService = lockService;
|
|
}
|
|
|
|
/**
|
|
* @param actionService the action service
|
|
*/
|
|
public void setActionService(ActionService actionService)
|
|
{
|
|
this.m_actionService = actionService;
|
|
}
|
|
|
|
/**
|
|
* @param authService the authentication service
|
|
*/
|
|
public void setAuthenticationService(AuthenticationService authService)
|
|
{
|
|
this.m_authService = authService;
|
|
}
|
|
|
|
/**
|
|
* @param permissionService the permission service
|
|
*/
|
|
public void setPermissionService(PermissionService permissionService)
|
|
{
|
|
this.m_permissionService = permissionService;
|
|
}
|
|
|
|
/**
|
|
* @param hiddenAspect the hiddenAspect to set
|
|
*/
|
|
public void setHiddenAspect(HiddenAspect hiddenAspect)
|
|
{
|
|
this.m_hiddenAspect = hiddenAspect;
|
|
}
|
|
|
|
|
|
public BehaviourFilter getPolicyBehaviourFilter()
|
|
{
|
|
return m_policyBehaviourFilter;
|
|
}
|
|
|
|
public void setPolicyBehaviourFilter(BehaviourFilter behaviourFilter)
|
|
{
|
|
m_policyBehaviourFilter = behaviourFilter;
|
|
}
|
|
|
|
/**
|
|
* Checks a new path in a move operation to detect whether clients are starting a renaming shuffle - common during
|
|
* file saving on various clients.
|
|
* <p/>
|
|
* <b>ALF-3856, ALF-7079, MNT-181</b>
|
|
*/
|
|
public boolean isRenameShuffle(String newPath)
|
|
{
|
|
return m_renameShufflePattern.matcher(newPath.toLowerCase()).matches();
|
|
}
|
|
|
|
/**
|
|
* Split the path into seperate directory path and file name strings.
|
|
* If the path is not empty, then there will always be an entry for the filename
|
|
*
|
|
* @param path Full path string.
|
|
* @return Returns a String[2] with the folder path and file path.
|
|
*/
|
|
public final String[] splitPath(String path)
|
|
{
|
|
if (path == null)
|
|
throw new IllegalArgumentException("path may not be null");
|
|
|
|
// Create an array of strings to hold the path and file name strings
|
|
String[] pathStr = new String[] {"", ""};
|
|
|
|
// Check if the path has a trailing seperator, if so then there is no file name.
|
|
|
|
int pos = path.lastIndexOf(PathSeperatorChar);
|
|
if (pos == -1 || pos == (path.length() - 1))
|
|
{
|
|
// Set the path string in the returned string array
|
|
pathStr[1] = path;
|
|
}
|
|
else
|
|
{
|
|
pathStr[0] = path.substring(0, pos);
|
|
pathStr[1] = path.substring(pos + 1);
|
|
}
|
|
// Return the path strings
|
|
return pathStr;
|
|
}
|
|
|
|
/**
|
|
* Split the path into all the component directories and filename
|
|
*
|
|
* @param path the string to split
|
|
* @return an array of all the path components
|
|
*/
|
|
public final List<String> splitAllPaths(String path)
|
|
{
|
|
if (path == null || path.length() == 0)
|
|
{
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
// split the path
|
|
StringTokenizer token = new StringTokenizer(path, PathSeperator);
|
|
List<String> results = new ArrayList<String>(10);
|
|
while (token.hasMoreTokens())
|
|
{
|
|
results.add(token.nextToken());
|
|
}
|
|
return results;
|
|
}
|
|
|
|
public String getURLForPath(HttpServletRequest request, String path, boolean isCollection)
|
|
{
|
|
return getURLForPath(request, path, isCollection, null);
|
|
}
|
|
|
|
public String getURLForPath(HttpServletRequest request, String path, boolean isCollection, String userAgent)
|
|
{
|
|
String urlPathPrefix = getUrlPathPrefix(request);
|
|
StringBuilder urlStr = new StringBuilder(urlPathPrefix);
|
|
|
|
if (path.equals(WebDAV.RootPath) == false)
|
|
{
|
|
// split the path and URL encode each path element
|
|
for (StringTokenizer t = new StringTokenizer(path, PathSeperator); t.hasMoreTokens(); /**/)
|
|
{
|
|
urlStr.append( WebDAVHelper.encodeURL(t.nextToken(), userAgent) );
|
|
if (t.hasMoreTokens())
|
|
{
|
|
urlStr.append(PathSeperator);
|
|
}
|
|
}
|
|
}
|
|
|
|
// If the URL is to a collection add a trailing slash
|
|
if (isCollection && urlStr.charAt( urlStr.length() - 1) != PathSeperatorChar)
|
|
{
|
|
urlStr.append( PathSeperator);
|
|
}
|
|
|
|
logger.debug("getURLForPath() path:" + path + " => url:" + urlStr);
|
|
|
|
// Return the URL string
|
|
return urlStr.toString();
|
|
}
|
|
|
|
/**
|
|
* Get the file info for the given paths
|
|
*
|
|
* @param rootNodeRef the acting webdav root
|
|
* @param path the path to search for
|
|
* @param servletPath the base servlet path, which may be null or empty
|
|
* @return Return the file info for the path
|
|
* @throws FileNotFoundException
|
|
* if the path doesn't refer to a valid node
|
|
*/
|
|
public final FileInfo getNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException
|
|
{
|
|
if (rootNodeRef == null)
|
|
{
|
|
throw new IllegalArgumentException("Root node may not be null");
|
|
}
|
|
else if (path == null)
|
|
{
|
|
throw new IllegalArgumentException("Path may not be null");
|
|
}
|
|
|
|
FileFolderService fileFolderService = getFileFolderService();
|
|
// Check for the root path
|
|
if ( path.length() == 0 || path.equals(PathSeperator) || EqualsHelper.nullSafeEquals(path, servletPath))
|
|
{
|
|
return fileFolderService.getFileInfo(rootNodeRef);
|
|
}
|
|
|
|
// Remove the servlet path from the path, assuming it hasn't already been done
|
|
if (servletPath != null && servletPath.length() > 0)
|
|
{
|
|
// Need to ensure we don't strip /alfresco from a site of /alfresco_name/
|
|
String comparePath = servletPath + "/";
|
|
if (path.startsWith(comparePath))
|
|
{
|
|
// Strip the servlet path from the relative path
|
|
path = path.substring(servletPath.length());
|
|
}
|
|
}
|
|
|
|
// split the paths up
|
|
List<String> splitPath = splitAllPaths(path);
|
|
|
|
// find it
|
|
FileInfo fileInfo = m_fileFolderService.resolveNamePath(rootNodeRef, splitPath);
|
|
|
|
// done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Fetched node for path: \n" +
|
|
" root: " + rootNodeRef + "\n" +
|
|
" path: " + path + "\n" +
|
|
" servlet path: " + servletPath + "\n" +
|
|
" result: " + fileInfo);
|
|
}
|
|
return fileInfo;
|
|
}
|
|
|
|
public final FileInfo getParentNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException
|
|
{
|
|
if (rootNodeRef == null)
|
|
{
|
|
throw new IllegalArgumentException("Root node may not be null");
|
|
}
|
|
else if (path == null)
|
|
{
|
|
throw new IllegalArgumentException("Path may not be null");
|
|
}
|
|
// shorten the path
|
|
String[] paths = splitPath(path);
|
|
return getNodeForPath(rootNodeRef, paths[0], servletPath);
|
|
}
|
|
|
|
/**
|
|
* Return the relative path for the node walking back to the specified root node
|
|
*
|
|
* @param rootNodeRef the root below which the path will be valid
|
|
* @param nodeRef the node's path to get
|
|
* @return Returns string of form <b>/A/B/C</b> where C represents the from node and
|
|
*/
|
|
public final String getPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException
|
|
{
|
|
// Check if the nodes are valid, or equal
|
|
if (rootNodeRef == null || nodeRef == null)
|
|
throw new IllegalArgumentException("Invalid node(s) in getPathFromNode call");
|
|
|
|
// short cut if the path node is the root node
|
|
if (rootNodeRef.equals(nodeRef))
|
|
return "";
|
|
|
|
FileFolderService fileFolderService = getFileFolderService();
|
|
|
|
// get the path elements
|
|
List<FileInfo> pathInfos = fileFolderService.getNamePath(rootNodeRef, nodeRef);
|
|
|
|
// build the path string
|
|
StringBuilder sb = new StringBuilder(pathInfos.size() * 20);
|
|
for (FileInfo fileInfo : pathInfos)
|
|
{
|
|
sb.append(WebDAVHelper.PathSeperatorChar);
|
|
sb.append(fileInfo.getName());
|
|
}
|
|
// done
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Build name path for node: \n" +
|
|
" root: " + rootNodeRef + "\n" +
|
|
" target: " + nodeRef + "\n" +
|
|
" path: " + sb);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public List<FileInfo> getChildren(FileInfo fileInfo) throws WebDAVServerException
|
|
{
|
|
return m_fileFolderService.list(fileInfo.getNodeRef());
|
|
}
|
|
|
|
/**
|
|
* Make an ETag value for a node using the GUID and modify date/time
|
|
*/
|
|
public final String makeETag(FileInfo nodeInfo)
|
|
{
|
|
// Get the modify date/time property for the node
|
|
|
|
StringBuilder etag = new StringBuilder();
|
|
makeETagString(nodeInfo, etag);
|
|
return etag.toString();
|
|
}
|
|
|
|
/**
|
|
* Make an ETag value for a node using the GUID and modify date/time
|
|
*/
|
|
public final String makeQuotedETag(FileInfo nodeInfo)
|
|
{
|
|
StringBuilder etag = new StringBuilder();
|
|
|
|
etag.append("\"");
|
|
makeETagString(nodeInfo, etag);
|
|
etag.append("\"");
|
|
return etag.toString();
|
|
}
|
|
|
|
/**
|
|
* Make an ETag value for a node using the GUID and modify date/time
|
|
*/
|
|
protected final void makeETagString(FileInfo nodeInfo, StringBuilder etag)
|
|
{
|
|
// Get the modify date/time property for the node
|
|
|
|
Object modVal = nodeInfo.getProperties().get(ContentModel.PROP_MODIFIED);
|
|
|
|
etag.append(nodeInfo.getNodeRef().getId());
|
|
|
|
if ( modVal != null)
|
|
{
|
|
etag.append("_");
|
|
etag.append(DefaultTypeConverter.INSTANCE.longValue(modVal));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return Return the null XML attribute list
|
|
*/
|
|
public final AttributesImpl getNullAttributes()
|
|
{
|
|
return m_nullAttribs;
|
|
}
|
|
|
|
/**
|
|
* Encodes the given string to valid URL format
|
|
*
|
|
* @param s the String to convert
|
|
*/
|
|
public final static String encodeURL(String s)
|
|
{
|
|
return encodeURL(s, null);
|
|
}
|
|
|
|
public final static String encodeURL(String s, String userAgent)
|
|
{
|
|
try
|
|
{
|
|
if (userAgent != null && (userAgent.startsWith(WebDAV.AGENT_MICROSOFT_DATA_ACCESS_INTERNET_PUBLISHING_PROVIDER_DAV)
|
|
|| userAgent.contains(WebDAV.AGENT_INTERNET_EXPLORER)))
|
|
{
|
|
return encodeUrlReservedSymbols(s);
|
|
}
|
|
else
|
|
{
|
|
return URLEncoder.encode(s);
|
|
}
|
|
}
|
|
catch (UnsupportedEncodingException err)
|
|
{
|
|
throw new RuntimeException(err);
|
|
}
|
|
}
|
|
|
|
public final static String decodeURL(String s)
|
|
{
|
|
return URLDecoder.decode(s);
|
|
}
|
|
|
|
/**
|
|
* Encodes the given string to valid HTML format
|
|
*
|
|
* @param string the String to convert
|
|
*/
|
|
public final static String encodeHTML(String string)
|
|
{
|
|
if (string == null)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
StringBuilder sb = null; //create on demand
|
|
String enc;
|
|
char c;
|
|
for (int i = 0; i < string.length(); i++)
|
|
{
|
|
enc = null;
|
|
c = string.charAt(i);
|
|
switch (c)
|
|
{
|
|
case '"': enc = """; break; //"
|
|
case '&': enc = "&"; break; //&
|
|
case '<': enc = "<"; break; //<
|
|
case '>': enc = ">"; break; //>
|
|
|
|
//misc
|
|
case '\u20AC': enc = "€"; break;
|
|
case '\u00AB': enc = "«"; break;
|
|
case '\u00BB': enc = "»"; break;
|
|
case '\u00A0': enc = " "; break;
|
|
|
|
default:
|
|
if (((int)c) >= 0x80)
|
|
{
|
|
//encode all non basic latin characters
|
|
enc = "&#" + ((int)c) + ";";
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (enc != null)
|
|
{
|
|
if (sb == null)
|
|
{
|
|
String soFar = string.substring(0, i);
|
|
sb = new StringBuilder(i + 8);
|
|
sb.append(soFar);
|
|
}
|
|
sb.append(enc);
|
|
}
|
|
else
|
|
{
|
|
if (sb != null)
|
|
{
|
|
sb.append(c);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sb == null)
|
|
{
|
|
return string;
|
|
}
|
|
else
|
|
{
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ALF-5333: Microsoft clients use ISO-8859-1 to decode WebDAV responses
|
|
* so this method should only be used for Microsoft user agents.
|
|
*
|
|
* @param string
|
|
* @return The encoded string for Microsoft clients
|
|
* @throws UnsupportedEncodingException
|
|
*/
|
|
public final static String encodeUrlReservedSymbols(String string) throws UnsupportedEncodingException
|
|
{
|
|
if (string == null)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
StringBuilder sb = null; // create on demand
|
|
String enc;
|
|
char c;
|
|
for (int i = 0; i < string.length(); i++)
|
|
{
|
|
enc = null;
|
|
c = string.charAt(i);
|
|
switch (c)
|
|
{
|
|
// reserved
|
|
case ';': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '/': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '?': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case ':': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '@': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '&': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '=': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '+': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
|
|
// unsafe
|
|
case '\"': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '#': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '%': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '>': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
case '<': enc = URLEncoder.encode(String.valueOf(c)); break;
|
|
default: break;
|
|
}
|
|
|
|
if (enc != null)
|
|
{
|
|
if (sb == null)
|
|
{
|
|
String soFar = string.substring(0, i);
|
|
sb = new StringBuilder(i + 8);
|
|
sb.append(soFar);
|
|
}
|
|
sb.append(enc);
|
|
}
|
|
else
|
|
{
|
|
if (sb != null)
|
|
{
|
|
sb.append(c);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sb == null)
|
|
{
|
|
return string;
|
|
}
|
|
else
|
|
{
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
public String determineSiteId(WebDAVMethod method)
|
|
{
|
|
SiteService siteService = getServiceRegistry().getSiteService();
|
|
String siteId;
|
|
try
|
|
{
|
|
FileInfo fileInfo = getNodeForPath(method.getRootNodeRef(), method.getPath(), method.getServletPath());
|
|
SiteInfo siteInfo = siteService.getSite(fileInfo.getNodeRef());
|
|
if (siteInfo != null)
|
|
{
|
|
siteId = siteInfo.getShortName();
|
|
}
|
|
else
|
|
{
|
|
throw new RuntimeException("Node is not contained by a site: " + method.getPath());
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
siteId = EMPTY_SITE_ID;
|
|
}
|
|
return siteId;
|
|
}
|
|
|
|
public String determineTenantDomain(WebDAVMethod method)
|
|
{
|
|
TenantService tenantService = getTenantService();
|
|
String tenantDomain = tenantService.getCurrentUserDomain();
|
|
if (tenantDomain == null)
|
|
{
|
|
return TenantService.DEFAULT_DOMAIN;
|
|
}
|
|
return tenantDomain;
|
|
}
|
|
|
|
/**
|
|
* Extract the destination path for MOVE or COPY commands from the
|
|
* supplied destination URL header.
|
|
*
|
|
* @param servletPath Path prefix of the WebDAV servlet.
|
|
* @param destURL The Destination header.
|
|
* @return The path to move/copy the file to.
|
|
*/
|
|
public String getDestinationPath(String contextPath, String servletPath, String destURL)
|
|
{
|
|
if (destURL != null && destURL.length() > 0)
|
|
{
|
|
int offset = -1;
|
|
|
|
if (destURL.startsWith(HTTP_SCHEME))
|
|
{
|
|
// Set the offset to the start of the host name
|
|
offset = HTTP_SCHEME.length();
|
|
}
|
|
else if (destURL.startsWith(HTTPS_SCHEME))
|
|
{
|
|
// Set the offset to the start of the host name
|
|
offset = HTTPS_SCHEME.length();
|
|
}
|
|
|
|
// Strip the start of the path if not a relative path
|
|
|
|
if (offset != -1)
|
|
{
|
|
offset = destURL.indexOf(WebDAV.PathSeperator, offset);
|
|
if (offset != -1)
|
|
{
|
|
// Strip the host from the beginning
|
|
String strPath = destURL.substring(offset);
|
|
|
|
// If it starts with /contextPath/servletPath/ (e.g. /alfresco/webdav/path/to/file) - then
|
|
// strip the servlet path from the start of the path.
|
|
String pathPrefix = contextPath + servletPath + WebDAV.PathSeperator;
|
|
if (strPath.startsWith(pathPrefix))
|
|
{
|
|
strPath = strPath.substring(pathPrefix.length());
|
|
}
|
|
|
|
return WebDAV.decodeURL(strPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Unable to get the path.
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Check that the destination path is on this server and is a valid WebDAV
|
|
* path for this server
|
|
*
|
|
* @param request The request made against the WebDAV server.
|
|
* @param urlStr String
|
|
* @exception WebDAVServerException
|
|
*/
|
|
public void checkDestinationURL(HttpServletRequest request, String urlStr) throws WebDAVServerException
|
|
{
|
|
try
|
|
{
|
|
// Parse the URL
|
|
|
|
URL url = new URL(urlStr);
|
|
|
|
// Check if the path is on this WebDAV server
|
|
|
|
boolean localPath = true;
|
|
|
|
if (url.getPort() != -1 && url.getPort() != request.getServerPort())
|
|
{
|
|
// Debug
|
|
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Destination path, different server port");
|
|
|
|
localPath = false;
|
|
}
|
|
else if (url.getHost().equalsIgnoreCase(request.getServerName()) == false
|
|
&& url.getHost().equals(request.getLocalAddr()) == false)
|
|
{
|
|
// The target host may contain a domain or be specified as a numeric IP address
|
|
|
|
String targetHost = url.getHost();
|
|
|
|
if ( IPAddress.isNumericAddress( targetHost) == false)
|
|
{
|
|
String localHost = request.getServerName();
|
|
|
|
int pos = targetHost.indexOf( ".");
|
|
if ( pos != -1)
|
|
targetHost = targetHost.substring( 0, pos);
|
|
|
|
pos = localHost.indexOf( ".");
|
|
if ( pos != -1)
|
|
localHost = localHost.substring( 0, pos);
|
|
|
|
// compare the host names
|
|
|
|
if ( targetHost.equalsIgnoreCase( localHost) == false)
|
|
localPath = false;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
// Check if the target IP address is a local address
|
|
|
|
InetAddress targetAddr = InetAddress.getByName( targetHost);
|
|
if ( NetworkInterface.getByInetAddress( targetAddr) == null)
|
|
localPath = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// DEBUG
|
|
|
|
if ( logger.isDebugEnabled())
|
|
logger.debug("Failed to check target IP address, " + targetHost);
|
|
|
|
localPath = false;
|
|
}
|
|
}
|
|
|
|
// Debug
|
|
|
|
if (localPath == false && logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Destination path, different server name/address");
|
|
logger.debug(" URL host=" + url.getHost() + ", ServerName=" + request.getServerName() + ", localAddr=" + request.getLocalAddr());
|
|
}
|
|
}
|
|
else if (!url.getPath().startsWith(getUrlPathPrefix(request)))
|
|
{
|
|
// Debug
|
|
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Destination path, different serlet path");
|
|
|
|
localPath = false;
|
|
}
|
|
|
|
// If the URL does not refer to this WebDAV server throw an
|
|
// exception
|
|
|
|
if (localPath != true)
|
|
throw new WebDAVServerException(HttpServletResponse.SC_BAD_GATEWAY);
|
|
}
|
|
catch (MalformedURLException ex)
|
|
{
|
|
// Debug
|
|
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Bad destination path, " + urlStr);
|
|
|
|
throw new WebDAVServerException(HttpServletResponse.SC_BAD_GATEWAY);
|
|
}
|
|
}
|
|
|
|
|
|
public void setUrlPathPrefix(String urlPathPrefix)
|
|
{
|
|
m_urlPathPrefix = urlPathPrefix;
|
|
}
|
|
|
|
public String getUrlPathPrefix(HttpServletRequest request)
|
|
{
|
|
StringBuilder urlStr = null;
|
|
if (StringUtils.hasText(m_urlPathPrefix))
|
|
{
|
|
// A specific prefix has been configured in, so use it.
|
|
urlStr = new StringBuilder(m_urlPathPrefix);
|
|
}
|
|
else
|
|
{
|
|
// Extract the path prefix from the request, using the servlet path as a guide.
|
|
// e.g. "/preamble/servlet-mapping/folder/file.txt"
|
|
// with a servlet path of "/servlet-mapping"
|
|
// would result in a path prefix of "/preamble/servlet-mapping" being discovered.
|
|
urlStr = new StringBuilder(request.getRequestURI());
|
|
String servletPath = request.getServletPath();
|
|
|
|
int rootPos = urlStr.indexOf(servletPath);
|
|
if (rootPos != -1)
|
|
{
|
|
urlStr.setLength(rootPos + servletPath.length());
|
|
}
|
|
}
|
|
|
|
// Ensure the prefix ends in the path separator.
|
|
if (urlStr.charAt(urlStr.length() - 1) != PathSeperatorChar)
|
|
{
|
|
urlStr.append(PathSeperator);
|
|
}
|
|
|
|
return urlStr.toString();
|
|
}
|
|
|
|
public String getRepositoryPath(HttpServletRequest request)
|
|
{
|
|
// Try and get the path
|
|
|
|
String strPath = null;
|
|
|
|
try
|
|
{
|
|
strPath = WebDAVHelper.decodeURL(request.getRequestURI());
|
|
}
|
|
catch (Exception ex) {}
|
|
|
|
// Find the servlet path and trim from the request path
|
|
|
|
String servletPath = request.getServletPath();
|
|
|
|
int rootPos = strPath.indexOf(servletPath);
|
|
if ( rootPos != -1)
|
|
{
|
|
strPath = strPath.substring( rootPos);
|
|
}
|
|
|
|
// If we failed to get the path from the request try and get the path from the servlet path
|
|
|
|
if (strPath == null)
|
|
{
|
|
strPath = request.getServletPath();
|
|
}
|
|
|
|
if (strPath == null || strPath.length() == 0)
|
|
{
|
|
// If we still have not got a path then default to the root directory
|
|
strPath = WebDAV.RootPath;
|
|
}
|
|
else if (strPath.startsWith(request.getServletPath()))
|
|
{
|
|
// Check if the path starts with the base servlet path
|
|
int len = request.getServletPath().length();
|
|
|
|
if (strPath.length() > len)
|
|
{
|
|
strPath = strPath.substring(len);
|
|
}
|
|
else
|
|
{
|
|
strPath = WebDAV.RootPath;
|
|
}
|
|
}
|
|
|
|
// Make sure there are no trailing slashes
|
|
|
|
if (strPath.length() > 1 && strPath.endsWith(WebDAV.PathSeperator))
|
|
{
|
|
strPath = strPath.substring(0, strPath.length() - 1);
|
|
}
|
|
|
|
// Return the path
|
|
|
|
return strPath;
|
|
}
|
|
|
|
/**
|
|
* Indicates if the node is unlocked or the current user has a WRITE_LOCK<p>
|
|
*
|
|
* @see LockService#isLockedAndReadOnly(NodeRef)
|
|
*
|
|
* @param nodeRef the node reference
|
|
*/
|
|
public boolean isLockedAndReadOnly(final NodeRef nodeRef)
|
|
{
|
|
return LockUtils.isLockedAndReadOnly(nodeRef, m_serviceRegistry.getLockService());
|
|
}
|
|
}
|