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


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

2715 lines
101 KiB
Java

/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.sf.acegisecurity.Authentication;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISInvalidArgumentException;
import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.opencmis.dictionary.CMISObjectVariant;
import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.repo.content.encoding.ContentCharsetFinder;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.Authorization;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.Acl;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
import org.apache.chemistry.opencmis.commons.data.ContentStream;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
import org.apache.chemistry.opencmis.commons.data.ObjectList;
import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.RenditionData;
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
import org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService;
import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
import org.apache.chemistry.opencmis.commons.impl.server.RenditionInfoImpl;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
import org.apache.chemistry.opencmis.commons.server.RenditionInfo;
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* OpenCMIS service implementation
*
* @author florian.mueller
* @author Derek Hulley
* @since 4.0
*/
public class AlfrescoCmisServiceImpl extends AbstractCmisService implements AlfrescoCmisService
{
private static Log logger = LogFactory.getLog(AlfrescoCmisService.class);
private static final QName PARAM_PARENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "parent");
private static final QName PARAM_USERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "username");
private static final String LUCENE_QUERY_CHECKEDOUT = "+@cm\\:workingCopyOwner:${cm:username}";
private static final String LUCENE_QUERY_CHECKEDOUT_IN_FOLDER = "+@cm\\:workingCopyOwner:${cm:username} +PARENT:\"${cm:parent}\"";
private static final String MIN_FILTER = "cmis:name,cmis:baseTypeId,cmis:objectTypeId,"
+ "cmis:createdBy,cmis:creationDate,cmis:lastModifiedBy,cmis:lastModificationDate,"
+ "cmis:contentStreamLength,cmis:contentStreamMimeType,cmis:contentStreamFileName,"
+ "cmis:contentStreamId";
private CMISConnector connector;
private CallContext context;
private Authentication authentication;
private Map<String, CMISNodeInfo> nodeInfoMap;
private Map<String, ObjectInfo> objectInfoMap;
public AlfrescoCmisServiceImpl(CMISConnector connector)
{
this.connector = connector;
nodeInfoMap = new HashMap<String, CMISNodeInfo>();
objectInfoMap = new HashMap<String, ObjectInfo>();
}
@Override
public void beforeCall()
{
AuthenticationUtil.pushAuthentication();
if (authentication != null)
{
// Use the previously-obtained authentication
AuthenticationUtil.setFullAuthentication(authentication);
}
else
{
if (context == null)
{
// Service not opened, yet
return;
}
// Sticky sessions?
if (connector.openHttpSession())
{
// create a session -> set a cookie
// if the CMIS client supports cookies that might help in clustered environments
((HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST)).getSession();
}
// Authenticate
if (authentication != null)
{
// We have already authenticated; just reuse the authentication
AuthenticationUtil.setFullAuthentication(authentication);
}
else
{
// First check if we already are authenticated
if (AuthenticationUtil.getFullyAuthenticatedUser() == null)
{
// We have to go to the repo and authenticate
String user = context.getUsername();
String password = context.getPassword();
Authorization auth = new Authorization(user, password);
if (auth.isTicket())
{
connector.getAuthenticationService().validate(auth.getTicket());
}
else
{
connector.getAuthenticationService().authenticate(auth.getUserName(), auth.getPasswordCharArray());
}
}
this.authentication = AuthenticationUtil.getFullAuthentication();
}
// // TODO: How is the proxy user working.
// // Until we know what it is meant to do, it's not available
// String currentUser = connector.getAuthenticationService().getCurrentUserName();
// String user = context.getUsername();
// String password = context.getPassword();
// if (currentUser != null && currentUser.equals(connector.getProxyUser()))
// {
// if (user != null && user.length() > 0)
// {
// AuthenticationUtil.setFullyAuthenticatedUser(user);
// }
// }
}
}
@Override
public void afterCall()
{
AuthenticationUtil.popAuthentication();
}
@Override
public void open(CallContext context)
{
this.context = context;
}
@Override
public void close()
{
// Put these resources on the transactions
context = null;
authentication = null;
nodeInfoMap.clear();
objectInfoMap.clear();
}
protected CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef)
{
return createNodeInfo(nodeRef, null);
}
protected CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef, VersionHistory versionHistory)
{
CMISNodeInfoImpl result = connector.createNodeInfo(nodeRef, versionHistory);
nodeInfoMap.put(result.getObjectId(), result);
return result;
}
protected CMISNodeInfo createNodeInfo(AssociationRef assocRef)
{
CMISNodeInfoImpl result = connector.createNodeInfo(assocRef);
nodeInfoMap.put(result.getObjectId(), result);
return result;
}
protected CMISNodeInfo getOrCreateNodeInfo(String objectId)
{
CMISNodeInfo result = nodeInfoMap.get(objectId);
if (result == null)
{
result = connector.createNodeInfo(objectId);
nodeInfoMap.put(objectId, result);
}
return result;
}
protected CMISNodeInfo getOrCreateNodeInfo(String objectId, String what)
{
CMISNodeInfo result = getOrCreateNodeInfo(objectId);
if (result instanceof CMISNodeInfoImpl)
{
((CMISNodeInfoImpl) result).checkIfUseful(what);
}
return result;
}
protected CMISNodeInfo getOrCreateFolderInfo(String folderId, String what)
{
CMISNodeInfo result = getOrCreateNodeInfo(folderId);
if (result instanceof CMISNodeInfoImpl)
{
((CMISNodeInfoImpl) result).checkIfFolder(what);
}
return result;
}
protected CMISNodeInfo addNodeInfo(CMISNodeInfo info)
{
nodeInfoMap.put(info.getObjectId(), info);
return info;
}
// --- repository service ---
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension)
{
return Collections.singletonList(connector.getRepositoryInfo());
}
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
return connector.getRepositoryInfo();
}
@Override
public TypeDefinitionList getTypeChildren(
String repositoryId, String typeId, Boolean includePropertyDefinitions,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// convert BigIntegers to int
int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
// set up the result
TypeDefinitionListImpl result = new TypeDefinitionListImpl();
List<TypeDefinition> list = new ArrayList<TypeDefinition>();
result.setList(list);
// get the types from the dictionary
List<TypeDefinitionWrapper> childrenList;
if (typeId == null)
{
childrenList = connector.getOpenCMISDictionaryService().getBaseTypes();
}
else
{
TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
if (tdw == null)
{
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
childrenList = tdw.getChildren();
}
// create result
if (max > 0)
{
int lastIndex = (max + skip > childrenList.size() ? childrenList.size() : max + skip) - 1;
for (int i = skip; i <= lastIndex; i++)
{
list.add(childrenList.get(i).getTypeDefinition(includePropertyDefinitions));
}
}
result.setHasMoreItems(childrenList.size() - skip > result.getList().size());
result.setNumItems(BigInteger.valueOf(childrenList.size()));
return result;
}
@Override
public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// find the type
TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
if (tdw == null)
{
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
// return type definition
return tdw.getTypeDefinition(true);
}
@Override
public List<TypeDefinitionContainer> getTypeDescendants(
String repositoryId, String typeId, BigInteger depth,
Boolean includePropertyDefinitions, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
// check depth
int d = (depth == null ? -1 : depth.intValue());
if (d == 0)
{
throw new CmisInvalidArgumentException("Depth must not be 0!");
}
if (typeId == null)
{
for (TypeDefinitionWrapper tdw : connector.getOpenCMISDictionaryService().getBaseTypes())
{
result.add(getTypesDescendants(d, tdw, includePropertyDefinitions));
}
}
else
{
TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
if (tdw == null)
{
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
if (tdw.getChildren() != null)
{
for (TypeDefinitionWrapper child : tdw.getChildren())
{
result.add(getTypesDescendants(d, child, includePropertyDefinitions));
}
}
}
return result;
}
/**
* Gathers the type descendants tree.
*/
private TypeDefinitionContainer getTypesDescendants(
int depth, TypeDefinitionWrapper tdw, boolean includePropertyDefinitions)
{
TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl();
result.setTypeDefinition(tdw.getTypeDefinition(includePropertyDefinitions));
if (depth != 0)
{
if (tdw.getChildren() != null)
{
result.setChildren(new ArrayList<TypeDefinitionContainer>());
for (TypeDefinitionWrapper tdc : tdw.getChildren())
{
result.getChildren().add(
getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
}
}
}
return result;
}
// --- navigation service ---
@Override
public ObjectInFolderList getChildren(
String repositoryId, String folderId, String filter, String orderBy,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
long start = System.currentTimeMillis();
checkRepositoryId(repositoryId);
// convert BigIntegers to int
int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
ObjectInFolderListImpl result = new ObjectInFolderListImpl();
List<ObjectInFolderData> list = new ArrayList<ObjectInFolderData>();
result.setObjects(list);
// get the children references
NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
// convert orderBy to sortProps
List<Pair<QName, Boolean>> sortProps = null;
if (orderBy != null)
{
sortProps = new ArrayList<Pair<QName, Boolean>>(1);
String[] parts = orderBy.split(",");
int len = parts.length;
final int origLen = len;
if (origLen > 0)
{
int maxSortProps = GetChildrenCannedQuery.MAX_FILTER_SORT_PROPS;
if (len > maxSortProps)
{
if (logger.isDebugEnabled())
{
logger.debug(
"Too many sort properties in 'orderBy' - ignore those above max (max="
+ maxSortProps + ",actual=" + len + ")");
}
len = maxSortProps;
}
for (int i = 0; i < len; i++)
{
String[] sort = parts[i].split(" +");
if (sort.length > 0)
{
PropertyDefinitionWrapper propDef = connector.getOpenCMISDictionaryService()
.findPropertyByQueryName(sort[0]);
if (propDef != null)
{
QName sortProp = null;
if (propDef.getPropertyId().equals(CMISDictionaryModel.PROP_BASE_TYPE_ID))
{
// special-case (see also ALF-13968) - for getChildren, using "cmis:baseTypeId" allows sorting of folders first and vice-versa (cmis:folder <-> cmis:document)
sortProp = GetChildrenCannedQuery.SORT_QNAME_NODE_IS_FOLDER;
}
else
{
sortProp = propDef.getPropertyAccessor().getMappedProperty();
}
if (sortProp != null)
{
boolean sortAsc = (sort.length == 1) || sort[1].equalsIgnoreCase("asc");
sortProps.add(new Pair<QName, Boolean>(sortProp, sortAsc));
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Ignore sort property '" + sort[0] + " - mapping not found");
}
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Ignore sort property '" + sort[0] + " - query name not found");
}
}
}
}
}
if (sortProps.size() < origLen)
{
logger.warn("Sort properties trimmed - either too many and/or not found: \n" + " orig: " + orderBy
+ "\n" + " final: " + sortProps);
}
}
PagingRequest pageRequest = new PagingRequest(skip, max, null);
pageRequest.setRequestTotalCountMax(skip + 10000); // TODO make this optional/configurable
// - affects whether numItems may be returned
PagingResults<FileInfo> pageOfNodeInfos = connector.getFileFolderService().list(
folderNodeRef, true, true,
null, sortProps, pageRequest);
if (max > 0)
{
for (FileInfo child : pageOfNodeInfos.getPage())
{
try
{
// create a child CMIS object
CMISNodeInfo ni = createNodeInfo(child.getNodeRef());
if (getObjectInfo(repositoryId, ni.getObjectId())==null)
{
// ignore invalid children
continue;
}
ObjectData object = connector.createCMISObject(ni, child, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, ni.getObjectId(), includeRelationships);
}
ObjectInFolderDataImpl childData = new ObjectInFolderDataImpl();
childData.setObject(object);
// include path segment
if (includePathSegment)
{
childData.setPathSegment(child.getName());
}
// add it
list.add(childData);
}
catch (InvalidNodeRefException e)
{
// ignore invalid children
}
catch(CmisObjectNotFoundException e)
{
// ignore objects that have not been found (perhaps because their type is unknown to CMIS)
}
}
}
// has more ?
result.setHasMoreItems(pageOfNodeInfos.hasMoreItems());
// total count ?
Pair<Integer, Integer> totalCounts = pageOfNodeInfos.getTotalResultCount();
if (totalCounts != null)
{
Integer totalCountLower = totalCounts.getFirst();
Integer totalCountUpper = totalCounts.getSecond();
if ((totalCountLower != null) && (totalCountLower.equals(totalCountUpper)))
{
result.setNumItems(BigInteger.valueOf(totalCountLower));
}
}
if (logger.isDebugEnabled())
{
logger.debug("getChildren: " + list.size() + " in " + (System.currentTimeMillis() - start) + " msecs");
}
return result;
}
@Override
public List<ObjectInFolderContainer> getDescendants(
String repositoryId, String folderId, BigInteger depth,
String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePathSegment, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
List<ObjectInFolderContainer> result = new ArrayList<ObjectInFolderContainer>();
getDescendantsTree(
repositoryId,
getOrCreateFolderInfo(folderId, "Folder").getNodeRef(),
depth.intValue(),
filter,
includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, false,
result);
return result;
}
@Override
public List<ObjectInFolderContainer> getFolderTree(
String repositoryId, String folderId, BigInteger depth,
String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePathSegment, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
List<ObjectInFolderContainer> result = new ArrayList<ObjectInFolderContainer>();
getDescendantsTree(
repositoryId,
getOrCreateFolderInfo(folderId, "Folder").getNodeRef(),
depth.intValue(),
filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, true,
result);
return result;
}
private void getDescendantsTree(
String repositoryId, NodeRef folderNodeRef, int depth, String filter,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
Boolean includePathSegment, boolean foldersOnly, List<ObjectInFolderContainer> list)
{
// get the children references
List<ChildAssociationRef> childrenList = connector.getNodeService().getChildAssocs(folderNodeRef);
for (ChildAssociationRef child : childrenList)
{
try
{
TypeDefinitionWrapper type = connector.getType(child.getChildRef());
if (type == null)
{
continue;
}
boolean isFolder = (type instanceof FolderTypeDefintionWrapper);
if (foldersOnly && !isFolder)
{
continue;
}
if(isFolder && type.getAlfrescoClass().equals(ContentModel.TYPE_SYSTEM_FOLDER))
{
continue;
}
// create a child CMIS object
ObjectInFolderDataImpl object = new ObjectInFolderDataImpl();
CMISNodeInfo ni = createNodeInfo(child.getChildRef());
object.setObject(connector.createCMISObject(
ni, filter, includeAllowableActions, includeRelationships,
renditionFilter, false, false));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, ni.getObjectId(), includeRelationships);
}
if (includePathSegment)
{
object.setPathSegment(connector.getName(child.getChildRef()));
}
// create the container
ObjectInFolderContainerImpl container = new ObjectInFolderContainerImpl();
container.setObject(object);
if ((depth != 1) && isFolder)
{
container.setChildren(new ArrayList<ObjectInFolderContainer>());
getDescendantsTree(
repositoryId,
child.getChildRef(),
depth - 1, filter, includeAllowableActions,
includeRelationships, renditionFilter, includePathSegment, foldersOnly,
container.getChildren());
}
// add it
list.add(container);
}
catch (InvalidNodeRefException e)
{
// ignore invalid children
}
catch(CmisObjectNotFoundException e)
{
// ignore objects that have not been found (perhaps because their type is unknown to CMIS)
}
}
}
@Override
public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get the node ref
CMISNodeInfo info = getOrCreateFolderInfo(folderId, "Folder");
// the root folder has no parent
if (info.isRootFolder())
{
throw new CmisInvalidArgumentException("Root folder has no parent!");
}
// get the parent
List<CMISNodeInfo> parentInfos = info.getParents();
if (parentInfos.isEmpty())
{
throw new CmisRuntimeException("Folder has no parent and is not the root folder?!");
}
CMISNodeInfo parentInfo = addNodeInfo(parentInfos.get(0));
ObjectData result = connector.createCMISObject(
parentInfo, filter, false, IncludeRelationships.NONE,
CMISConnector.RENDITION_NONE, false, false);
if (context.isObjectInfoRequired())
{
getObjectInfo(
repositoryId,
parentInfo.getObjectId(),
IncludeRelationships.NONE);
}
return result;
}
@Override
public List<ObjectParentData> getObjectParents(
String repositoryId, String objectId, String filter,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
Boolean includeRelativePathSegment, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
List<ObjectParentData> result = new ArrayList<ObjectParentData>();
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships are not filed
if (info.isRelationship())
{
throw new CmisConstraintException("Relationships are not fileable!");
}
if (info.isFolder() && !info.isRootFolder())
{
List<CMISNodeInfo> parentInfos = info.getParents();
if (!parentInfos.isEmpty())
{
CMISNodeInfo parentInfo = addNodeInfo(parentInfos.get(0));
ObjectData object = connector.createCMISObject(
parentInfo, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, object.getId(), includeRelationships);
}
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
objectParent.setObject(object);
// include relative path segment
if (includeRelativePathSegment)
{
objectParent.setRelativePathSegment(info.getName());
}
result.add(objectParent);
}
}
else if (info.isCurrentVersion() || info.isPWC())
{
List<CMISNodeInfo> parentInfos = info.getParents();
for (CMISNodeInfo parentInfo : parentInfos)
{
addNodeInfo(parentInfo);
ObjectData object = connector.createCMISObject(
parentInfo, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, object.getId(), includeRelationships);
}
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
objectParent.setObject(object);
// include relative path segment
if (includeRelativePathSegment)
{
objectParent.setRelativePathSegment(info.getName());
}
result.add(objectParent);
}
}
return result;
}
@Override
public ObjectList getCheckedOutDocs(
String repositoryId, String folderId, String filter, String orderBy,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// convert BigIntegers to int
int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
// prepare query
SearchParameters params = new SearchParameters();
params.setLanguage(SearchService.LANGUAGE_LUCENE);
QueryParameterDefinition usernameDef = new QueryParameterDefImpl(
PARAM_USERNAME,
connector.getDictionaryService().getDataType(DataTypeDefinition.TEXT),
true,
AuthenticationUtil.getFullyAuthenticatedUser());
params.addQueryParameterDefinition(usernameDef);
if (folderId == null)
{
params.setQuery(LUCENE_QUERY_CHECKEDOUT);
params.addStore(connector.getRootStoreRef());
}
else
{
CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder");
params.setQuery(LUCENE_QUERY_CHECKEDOUT_IN_FOLDER);
params.addStore(folderInfo.getNodeRef().getStoreRef());
QueryParameterDefinition parentDef = new QueryParameterDefImpl(
PARAM_PARENT,
connector.getDictionaryService().getDataType(DataTypeDefinition.NODE_REF),
true,
folderInfo.getNodeRef().toString());
params.addQueryParameterDefinition(parentDef);
}
// set up order
if (orderBy != null)
{
String[] parts = orderBy.split(",");
for (int i = 0; i < parts.length; i++)
{
String[] sort = parts[i].split(" +");
if (sort.length < 1)
{
continue;
}
PropertyDefinitionWrapper propDef = connector.getOpenCMISDictionaryService().findPropertyByQueryName(sort[0]);
if (propDef != null)
{
if (propDef.getPropertyDefinition().isOrderable())
{
QName sortProp = propDef.getPropertyAccessor().getMappedProperty();
if (sortProp != null)
{
boolean sortAsc = (sort.length == 1) || sort[1].equalsIgnoreCase("asc");
params.addSort(propDef.getPropertyLuceneBuilder().getLuceneFieldName(), sortAsc);
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Ignore sort property '" + sort[0] + " - mapping not found");
}
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Ignore sort property '" + sort[0] + " - not orderable");
}
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Ignore sort property '" + sort[0] + " - query name not found");
}
}
}
}
// execute query
ResultSet resultSet = null;
List<NodeRef> nodeRefs;
try
{
resultSet = connector.getSearchService().query(params);
nodeRefs = resultSet.getNodeRefs();
}
finally
{
if (resultSet != null)
{
resultSet.close();
}
}
// collect results
ObjectListImpl result = new ObjectListImpl();
List<ObjectData> list = new ArrayList<ObjectData>();
result.setObjects(list);
int skipCounter = skip;
if (max > 0)
{
for (NodeRef nodeRef : nodeRefs)
{
if (skipCounter > 0)
{
skipCounter--;
continue;
}
if (list.size() == max)
{
break;
}
try
{
// create a CMIS object
CMISNodeInfo ni = createNodeInfo(nodeRef);
ObjectData object = connector.createCMISObject(
ni, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, ni.getObjectId(), includeRelationships);
}
// add it
list.add(object);
}
catch (InvalidNodeRefException e)
{
// ignore invalid objects
}
catch(CmisObjectNotFoundException e)
{
// ignore objects that have not been found (perhaps because their type is unknown to CMIS)
}
}
}
// has more ?
result.setHasMoreItems(nodeRefs.size() - skip > list.size());
return result;
}
// --- object service ---
@Override
public String create(
String repositoryId, Properties properties, String folderId, ContentStream contentStream,
VersioningState versioningState, List<String> policies, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// check properties
if (properties == null || properties.getProperties() == null)
{
throw new CmisInvalidArgumentException("Properties must be set!");
}
// get the type
String objectTypeId = connector.getObjectTypeIdProperty(properties);
// find the type
TypeDefinitionWrapper type = connector.getOpenCMISDictionaryService().findType(objectTypeId);
if (type == null)
{
throw new CmisInvalidArgumentException("Type '" + objectTypeId + "' is unknown!");
}
// create object
String newId = null;
switch (type.getBaseTypeId())
{
case CMIS_DOCUMENT:
newId = createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, null,
null, extension);
break;
case CMIS_FOLDER:
newId = createFolder(repositoryId, properties, folderId, policies, null, null, extension);
break;
case CMIS_POLICY:
newId = createPolicy(repositoryId, properties, folderId, policies, null, null, extension);
break;
}
// check new object id
if (newId == null)
{
throw new CmisRuntimeException("Creation failed!");
}
if (context.isObjectInfoRequired())
{
try
{
getObjectInfo(repositoryId, newId, "*", IncludeRelationships.NONE);
}
catch (InvalidNodeRefException e)
{
throw new CmisRuntimeException("Creation failed! New object not found!");
}
}
// return the new object id
return newId;
}
@Override
public String createFolder(String repositoryId, final Properties properties, String folderId,
final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get the parent folder node ref
final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");
// get name and type
final String name = connector.getNameProperty(properties, null);
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);
connector.checkChildObjectType(parentInfo, type.getTypeId());
// run transaction
FileInfo fileInfo = connector.getFileFolderService().create(
parentInfo.getNodeRef(), name, type.getAlfrescoClass());
NodeRef nodeRef = fileInfo.getNodeRef();
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces);
connector.getActivityPoster().postFileFolderAdded(fileInfo);
return nodeRef.toString();
}
private String stripEncoding(String mimeType)
{
String ret = mimeType;
int idx = mimeType.indexOf(";");
if(idx != -1)
{
ret = mimeType.substring(0, idx);
}
return ret;
}
@Override
public String createDocument(
String repositoryId, final Properties properties, String folderId,
final ContentStream contentStream, final VersioningState versioningState, final List<String> policies,
final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get the parent folder node ref
final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");
// get name and type
final String name = connector.getNameProperty(properties, null);
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_DOCUMENT);
connector.checkChildObjectType(parentInfo, type.getTypeId());
DocumentTypeDefinition docType = (DocumentTypeDefinition) type.getTypeDefinition(false);
if ((docType.getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED) && (contentStream != null))
{
throw new CmisConstraintException("This document type does not support content!");
}
if ((docType.getContentStreamAllowed() == ContentStreamAllowed.REQUIRED) && (contentStream == null))
{
throw new CmisConstraintException("This document type does requires content!");
}
if (docType.isVersionable() && (versioningState == VersioningState.NONE))
{
throw new CmisConstraintException("This document type is versionable!");
}
if (!docType.isVersionable() && (versioningState != VersioningState.NONE))
{
throw new CmisConstraintException("This document type is not versionable!");
}
// copy stream to temp file
// OpenCMIS does this for us ....
final File tempFile = copyToTempFile(contentStream);
final Charset encoding = (tempFile == null ? null : getEncoding(tempFile, contentStream.getMimeType()));
FileInfo fileInfo = connector.getFileFolderService().create(
parentInfo.getNodeRef(), name, type.getAlfrescoClass());
NodeRef nodeRef = fileInfo.getNodeRef();
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces);
// handle content
if (contentStream != null)
{
// write content
ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
writer.setMimetype(stripEncoding(contentStream.getMimeType()));
writer.setEncoding(encoding.name());
writer.putContent(tempFile);
}
connector.applyVersioningState(nodeRef, versioningState);
removeTempFile(tempFile);
String objectId = connector.createObjectId(nodeRef);
connector.getActivityPoster().postFileFolderAdded(fileInfo);
return objectId;
}
@Override
public String createDocumentFromSource(
String repositoryId, String sourceId, final Properties properties,
String folderId, final VersioningState versioningState, final List<String> policies, final Acl addAces,
final Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get the parent folder node ref
final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");
// get source
CMISNodeInfo info = getOrCreateNodeInfo(sourceId, "Source");
// check source
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Source object is not a document!");
}
final NodeRef sourceNodeRef = info.getNodeRef();
if (!info.isDocument())
{
throw new CmisConstraintException("Source object is not a document!");
}
// get name and type
final String name = connector.getNameProperty(properties, info.getName());
final TypeDefinitionWrapper type = info.getType();
connector.checkChildObjectType(parentInfo, type.getTypeId());
try
{
FileInfo fileInfo = connector.getFileFolderService().copy(
sourceNodeRef, parentInfo.getNodeRef(), name);
NodeRef nodeRef = fileInfo.getNodeRef();
connector.setProperties(nodeRef, type, properties, new String[] {
PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces);
connector.applyVersioningState(nodeRef, versioningState);
connector.getActivityPoster().postFileFolderAdded(fileInfo);
return connector.createObjectId(nodeRef);
}
catch (FileNotFoundException e)
{
throw new CmisContentAlreadyExistsException("An object with this name already exists!", e);
}
}
@Override
public String createPolicy(
String repositoryId, Properties properties, String folderId, List<String> policies,
Acl addAces, Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get the parent folder
getOrCreateFolderInfo(folderId, "Parent Folder");
String objectTypeId = connector.getObjectTypeIdProperty(properties);
connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_POLICY);
// we should never get here - policies are not creatable!
throw new CmisRuntimeException("Polcies cannot be created!");
}
@Override
public String createRelationship(
String repositoryId, Properties properties, List<String> policies, Acl addAces,
Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get type
String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_RELATIONSHIP);
// get source object
String sourceId = connector.getSourceIdProperty(properties);
CMISNodeInfo sourceInfo = getOrCreateNodeInfo(sourceId, "Source");
if (!sourceInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !sourceInfo.isVariant(CMISObjectVariant.FOLDER))
{
throw new CmisInvalidArgumentException("Source is not the latest version of a document or a folder object!");
}
final NodeRef sourceNodeRef = sourceInfo.getNodeRef();
// get target object
String targetId = connector.getTargetIdProperty(properties);
CMISNodeInfo targetInfo = getOrCreateNodeInfo(targetId, "Target");
if (!targetInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !targetInfo.isVariant(CMISObjectVariant.FOLDER))
{
throw new CmisInvalidArgumentException(
"Target is not the latest version of a document or a folder object!!");
}
final NodeRef targetNodeRef = targetInfo.getNodeRef();
// check policies and ACLs
if ((policies != null) && (!policies.isEmpty()))
{
throw new CmisConstraintException("Relationships are not policy controllable!");
}
if ((addAces != null) && (addAces.getAces() != null) && (!addAces.getAces().isEmpty()))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
if ((removeAces != null) && (removeAces.getAces() != null) && (!removeAces.getAces().isEmpty()))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
// create relationship
// ALF-10085 : disable auditing behaviour for this use case
boolean wasEnabled = connector.disableBehaviour(ContentModel.ASPECT_AUDITABLE, sourceNodeRef); // Lasts for txn
try
{
AssociationRef assocRef = connector.getNodeService().createAssociation(
sourceNodeRef, targetNodeRef, type.getAlfrescoClass());
return CMISConnector.ASSOC_ID_PREFIX + assocRef.getId();
}
finally
{
if(wasEnabled)
{
connector.enableBehaviour(ContentModel.ASPECT_AUDITABLE, sourceNodeRef);
}
}
}
@Override
public void setContentStream(
String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
Holder<String> changeToken, final ContentStream contentStream, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisStreamNotSupportedException("Content can only be set ondocuments!");
}
final NodeRef nodeRef = info.getNodeRef();
if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
{
throw new CmisStreamNotSupportedException("Document type doesn't allow content!");
}
boolean existed = connector.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT) != null;
if (existed && !overwriteFlag)
{
throw new CmisContentAlreadyExistsException("Content already exists!");
}
if ((contentStream == null) || (contentStream.getStream() == null))
{
throw new CmisInvalidArgumentException("No content!");
}
// copy stream to temp file
final File tempFile = copyToTempFile(contentStream);
final Charset encoding = getEncoding(tempFile, contentStream.getMimeType());
try
{
ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
writer.setMimetype(contentStream.getMimeType());
writer.setEncoding(encoding.name());
writer.putContent(tempFile);
}
finally
{
removeTempFile(tempFile);
}
objectId.setValue(connector.createObjectId(nodeRef));
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
}
@Override
public void deleteContentStream(
String repositoryId, Holder<String> objectId, Holder<String> changeToken,
ExtensionsData extension)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisStreamNotSupportedException("Content can only be deleted from ondocuments!");
}
final NodeRef nodeRef = info.getNodeRef();
if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.REQUIRED)
{
throw new CmisInvalidArgumentException("Document type requires content!");
}
connector.getNodeService().setProperty(nodeRef, ContentModel.PROP_CONTENT, null);
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
objectId.setValue(connector.createObjectId(nodeRef));
}
@Override
public void moveObject(
String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get object and source and target parent
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
final NodeRef nodeRef = info.getCurrentNodeNodeRef();
final CMISNodeInfo sourceInfo = getOrCreateFolderInfo(sourceFolderId, "Source Folder");
final CMISNodeInfo targetInfo = getOrCreateFolderInfo(targetFolderId, "Target Folder");
connector.checkChildObjectType(targetInfo, info.getType().getTypeId());
ChildAssociationRef primaryParentRef = connector.getNodeService().getPrimaryParent(nodeRef);
// if this is a primary child node, move it
if (primaryParentRef.getParentRef().equals(sourceInfo.getNodeRef()))
{
connector.getNodeService().moveNode(
nodeRef, targetInfo.getNodeRef(),
primaryParentRef.getTypeQName(), primaryParentRef.getQName());
}
else
{
boolean found = false;
// otherwise, reparent it
for (ChildAssociationRef parent : connector.getNodeService().getParentAssocs(
nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL))
{
if (parent.getParentRef().equals(sourceInfo.getNodeRef()))
{
connector.getNodeService().removeChildAssociation(parent);
connector.getNodeService().addChild(
targetInfo.getNodeRef(), nodeRef,
ContentModel.ASSOC_CONTAINS, parent.getQName());
found = true;
}
}
if (!found)
{
throw new IllegalArgumentException(
new CMISInvalidArgumentException(
"Document is not a child of the source folder that was specified!"));
}
}
}
@Override
public void updateProperties(
String repositoryId, Holder<String> objectId, Holder<String> changeToken,
final Properties properties, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
final CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Relationship properties cannot be updated!");
}
else
{
if (info.isVariant(CMISObjectVariant.VERSION))
{
throw new CmisInvalidArgumentException("Document is not the latest version!");
}
final NodeRef nodeRef = info.getNodeRef();
connector.setProperties(nodeRef, info.getType(), properties, new String[0]);
objectId.setValue(connector.createObjectId(nodeRef));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, objectId.getValue(), "*", IncludeRelationships.NONE);
}
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
}
}
@Override
public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension)
{
deleteObjectOrCancelCheckOut(repositoryId, objectId, allVersions, extension);
}
@Override
public void deleteObjectOrCancelCheckOut(
String repositoryId, final String objectId, final Boolean allVersions,
ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
final CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
do
{
// handle relationships
if (info.isVariant(CMISObjectVariant.ASSOC))
{
AssociationRef assocRef = info.getAssociationRef();
connector.getNodeService().removeAssociation(
assocRef.getSourceRef(),
assocRef.getTargetRef(),
assocRef.getTypeQName());
break; // Reason for do-while
}
NodeRef nodeRef = info.getNodeRef();
// handle PWC
if (info.isVariant(CMISObjectVariant.PWC))
{
connector.getCheckOutCheckInService().cancelCheckout(nodeRef);
break; // Reason for do-while
}
// handle folders
if (info.isFolder())
{
if (connector.getNodeService().getChildAssocs(nodeRef).size() > 0)
{
throw new CmisConstraintException(
"Could not delete folder with at least one child!");
}
connector.deleteNode(nodeRef, false);
break; // Reason for do-while
}
if(info.hasPWC())
{
// is a checked out document. If a delete, don't allow unless checkout is canceled. If a cancel
// checkout, not allowed.
throw new CmisConstraintException(
"Could not delete/cancel checkout on the original checked out document");
}
// handle versions
if (allVersions)
{
NodeRef workingCopy = connector.getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (workingCopy != null)
{
connector.getCheckOutCheckInService().cancelCheckout(workingCopy);
}
}
else if (info.isVariant(CMISObjectVariant.VERSION))
{
Version version = ((CMISNodeInfoImpl) info).getVersion();
connector.getVersionService().deleteVersion(nodeRef, version);
break; // Reason for do-while
}
if (info.isVariant(CMISObjectVariant.VERSION))
{
nodeRef = info.getCurrentNodeNodeRef();
}
// attempt to delete the node
if (allVersions)
{
connector.deleteNode(nodeRef, true);
}
else
{
CMISNodeInfoImpl infoImpl = ((CMISNodeInfoImpl) info);
Version version = infoImpl.getVersion();
if (infoImpl.getVersionHistory().getPredecessor(version) == null)
{
connector.deleteNode(nodeRef, true);
}
else
{
connector.getVersionService().deleteVersion(nodeRef, version);
}
}
}
while (false); // Dodgey, but avoided having to play with too much code during refactor
}
@Override
public FailedToDeleteData deleteTree(
String repositoryId, String folderId, Boolean allVersions,
UnfileObject unfileObjects, final Boolean continueOnFailure, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (!allVersions)
{
throw new CmisInvalidArgumentException("Only allVersions=true supported!");
}
if (unfileObjects == UnfileObject.UNFILE)
{
throw new CmisInvalidArgumentException("Unfiling not supported!");
}
final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
final FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
result.setIds(deleteBranch(folderNodeRef, continueOnFailure));
return result;
}
private List<String> deleteBranch(NodeRef nodeRef, boolean continueOnFailure)
{
List<String> result = new ArrayList<String>();
try
{
// remove children
List<ChildAssociationRef> childrenList = connector.getNodeService().getChildAssocs(nodeRef);
if (childrenList != null)
{
for (ChildAssociationRef child : childrenList)
{
List<String> ftod = deleteBranch(child.getChildRef(), continueOnFailure);
if (!ftod.isEmpty())
{
result.addAll(ftod);
if (!continueOnFailure)
{
return result;
}
}
}
}
// remove not primary parent associations
// TODO: This can be removed once we fix node archival
List<ChildAssociationRef> childAssociations = connector.getNodeService().getParentAssocs(nodeRef);
if (childAssociations != null)
{
for (ChildAssociationRef childAssoc : childAssociations)
{
if (!childAssoc.isPrimary())
{
connector.getNodeService().removeChildAssociation(childAssoc);
}
}
}
// attempt to delete the node
connector.deleteNode(nodeRef, false);
}
catch (Exception e)
{
result.add(nodeRef.toString());
}
return result;
}
@Override
public ObjectData getObject(
String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
Boolean includeAcl, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// create a CMIS object
ObjectData object = connector.createCMISObject(
info, filter, includeAllowableActions, includeRelationships,
renditionFilter, includePolicyIds, includeAcl);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, info.getObjectId(), includeRelationships);
}
return object;
}
@Override
public ObjectData getObjectByPath(
String repositoryId, String path, String filter, Boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
Boolean includeAcl, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// start at the root node
NodeRef rootNodeRef = connector.getRootNodeRef();
if (path.equals("/"))
{
return connector.createCMISObject(createNodeInfo(rootNodeRef), filter, includeAllowableActions,
includeRelationships, renditionFilter, includePolicyIds, includeAcl);
}
else
{
try
{
// resolve path and get the node ref
FileInfo fileInfo = connector.getFileFolderService().resolveNamePath(
rootNodeRef,
Arrays.asList(path.substring(1).split("/")));
CMISNodeInfo info = createNodeInfo(fileInfo.getNodeRef());
ObjectData object = connector.createCMISObject(
info, fileInfo, filter, includeAllowableActions,
includeRelationships, renditionFilter, includePolicyIds, includeAcl);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, info.getObjectId(), includeRelationships);
}
return object;
}
catch (FileNotFoundException e)
{
throw new CmisObjectNotFoundException("Object not found: " + path);
}
}
}
@Override
public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, info.getObjectId(), IncludeRelationships.NONE);
}
if (info.isVariant(CMISObjectVariant.ASSOC))
{
return connector.getAssocProperties(info, filter);
}
else
{
return connector.getNodeProperties(info, filter);
}
}
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
return connector.getAllowableActions(info);
}
@Override
public ContentStream getContentStream(
String repositoryId, String objectId, String streamId, BigInteger offset,
BigInteger length, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships cannot have content
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Object is a relationship and cannot have content!");
}
// now get it
return connector.getContentStream(info, streamId, offset, length);
}
@Override
public List<RenditionData> getRenditions(String repositoryId, String objectId, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (info.isVariant(CMISObjectVariant.ASSOC))
{
return Collections.emptyList();
}
else
{
return connector.getRenditions(info.getNodeRef(), renditionFilter, maxItems, skipCount);
}
}
// --- versioning service ---
@Override
public void checkOut(
String repositoryId, final Holder<String> objectId, ExtensionsData extension,
final Holder<Boolean> contentCopied)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
// Check for current version
if (info.isVariant(CMISObjectVariant.CURRENT_VERSION))
{
// Good
}
else if (info.isVariant(CMISObjectVariant.VERSION))
{
throw new CmisInvalidArgumentException("Can't check out an old version of a document");
}
else {
throw new CmisInvalidArgumentException("Only documents can be checked out! Object was a " + info.getObjectVariant().toString());
}
// get object
final NodeRef nodeRef = info.getNodeRef();
if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable())
{
throw new CmisConstraintException("Document is not versionable!");
}
// check out
NodeRef pwcNodeRef = connector.getCheckOutCheckInService().checkout(nodeRef);
CMISNodeInfo pwcNodeInfo = createNodeInfo(pwcNodeRef);
objectId.setValue(pwcNodeInfo.getObjectId());
if (contentCopied != null)
{
contentCopied.setValue(connector.getFileFolderService().getReader(pwcNodeRef) != null);
}
}
@Override
public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// only accept a PWC
if (!info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisVersioningException("Object is not a PWC!");
}
// get object
final NodeRef nodeRef = info.getNodeRef();
// cancel check out
connector.getCheckOutCheckInService().cancelCheckout(nodeRef);
}
@Override
public void checkIn(
String repositoryId, final Holder<String> objectId, final Boolean major,
final Properties properties, final ContentStream contentStream, final String checkinComment,
final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
// only accept a PWC
if (!info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisVersioningException("Object is not a PWC!");
}
// get object
final NodeRef nodeRef = info.getNodeRef();
final TypeDefinitionWrapper type = info.getType();
// copy stream to temp file
final File tempFile = copyToTempFile(contentStream);
final Charset encoding = (tempFile == null ? null : getEncoding(tempFile, contentStream.getMimeType()));
// check in
// update PWC
connector.setProperties(nodeRef, type, properties,
new String[] { PropertyIds.OBJECT_TYPE_ID });
connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces);
// handle content
if (contentStream != null)
{
// write content
ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
writer.setMimetype(contentStream.getMimeType());
writer.setEncoding(encoding.name());
writer.putContent(tempFile);
}
// check aspect
if (connector.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == false)
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_INITIAL_VERSION, false);
props.put(ContentModel.PROP_AUTO_VERSION, false);
connector.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props);
}
// create version properties
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
versionProperties.put(VersionModel.PROP_VERSION_TYPE, major ? VersionType.MAJOR
: VersionType.MINOR);
if (checkinComment != null)
{
versionProperties.put(VersionModel.PROP_DESCRIPTION, checkinComment);
}
// check in
NodeRef newNodeRef = connector.getCheckOutCheckInService().checkin(nodeRef, versionProperties);
objectId.setValue(connector.createObjectId(newNodeRef));
removeTempFile(tempFile);
}
@Override
public List<ObjectData> getAllVersions(
String repositoryId, String objectId, String versionSeriesId, String filter,
Boolean includeAllowableActions, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (versionSeriesId == null && objectId != null)
{
// it's a browser binding call
versionSeriesId = connector.getCurrentVersionId(objectId);
}
if (versionSeriesId == null)
{
throw new CmisInvalidArgumentException("Object Id or Object Series Id must be set!");
}
List<ObjectData> result = new ArrayList<ObjectData>();
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
{
// the version series id is the id of current version, which is a
// document
throw new CmisInvalidArgumentException("Version Series does not exist!");
}
// get current version and it's history
NodeRef nodeRef = info.getNodeRef();
VersionHistory versionHistory = ((CMISNodeInfoImpl) info).getVersionHistory();
if (versionHistory == null)
{
// add current version
result.add(connector.createCMISObject(info, filter, includeAllowableActions, IncludeRelationships.NONE,
CMISConnector.RENDITION_NONE, false, false));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, info.getObjectId(), IncludeRelationships.NONE);
}
}
else
{
if (info.hasPWC())
{
CMISNodeInfo pwcInfo = createNodeInfo(connector.getCheckOutCheckInService().getWorkingCopy(nodeRef));
result.add(
connector.createCMISObject(
pwcInfo, filter, includeAllowableActions,
IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, pwcInfo.getObjectId(), IncludeRelationships.NONE);
}
}
// convert the version history
for (Version version : versionHistory.getAllVersions())
{
CMISNodeInfo versionInfo = createNodeInfo(version.getFrozenStateNodeRef(), versionHistory);
result.add(
connector.createCMISObject(
versionInfo, filter, includeAllowableActions,
IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, versionInfo.getObjectId(), IncludeRelationships.NONE);
}
}
}
return result;
}
@Override
public ObjectData getObjectOfLatestVersion(
String repositoryId, String objectId, String versionSeriesId,
Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (objectId != null)
{
// it's an AtomPub call
versionSeriesId = connector.getCurrentVersionId(objectId);
}
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
CMISNodeInfo versionInfo = createNodeInfo(((CMISNodeInfoImpl) info).getLatestVersionNodeRef(major));
ObjectData object = connector.createCMISObject(
versionInfo, filter, includeAllowableActions,
includeRelationships, renditionFilter, includePolicyIds, includeAcl);
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, info.getObjectId(), includeRelationships);
}
return object;
}
@Override
public Properties getPropertiesOfLatestVersion(
String repositoryId, String objectId, String versionSeriesId,
Boolean major, String filter, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (objectId != null)
{
// it's an AtomPub call
versionSeriesId = connector.getCurrentVersionId(objectId);
}
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
if (info.isVariant(CMISObjectVariant.ASSOC))
{
return connector.getAssocProperties(info, filter);
}
else
{
CMISNodeInfo versionInfo = createNodeInfo(((CMISNodeInfoImpl) info).getLatestVersionNodeRef(major));
addNodeInfo(versionInfo);
return connector.getNodeProperties(versionInfo, filter);
}
}
// --- multifiling service ---
@Override
public void addObjectToFolder(
String repositoryId, String objectId, String folderId, Boolean allVersions,
ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (!allVersions)
{
throw new CmisInvalidArgumentException("Only allVersions=true supported!");
}
// get node ref
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (!info.isDocument())
{
throw new CmisInvalidArgumentException("Object is not a document!");
}
final NodeRef nodeRef = info.getNodeRef();
// get the folder node ref
final CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder");
connector.checkChildObjectType(folderInfo, info.getType().getTypeId());
final QName name = QName.createQName(
NamespaceService.CONTENT_MODEL_1_0_URI,
QName.createValidLocalName((String) connector.getNodeService().getProperty(nodeRef,
ContentModel.PROP_NAME)));
connector.getNodeService().addChild(
folderInfo.getNodeRef(), nodeRef, ContentModel.ASSOC_CONTAINS, name);
}
@Override
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// get node ref
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (!info.isDocument())
{
throw new CmisInvalidArgumentException("Object is not a document!");
}
final NodeRef nodeRef = info.getNodeRef();
// get the folder node ref
final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
// check primary parent
if (connector.getNodeService().getPrimaryParent(nodeRef).getParentRef().equals(folderNodeRef))
{
throw new CmisConstraintException(
"Unfiling from primary parent folder is not supported! Use deleteObject() instead.");
}
connector.getNodeService().removeChild(folderNodeRef, nodeRef);
}
// --- discovery service ---
@Override
public ObjectList getContentChanges(
String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
return connector.getContentChanges(changeLogToken, maxItems);
}
@Override
public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
if (searchAllVersions.booleanValue())
{
throw new CmisInvalidArgumentException("Search all version is not supported!");
}
return connector.query(
statement, includeAllowableActions, includeRelationships, renditionFilter,
maxItems, skipCount);
}
// --- relationship service ---
@Override
public ObjectList getObjectRelationships(
String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Object is a relationship!");
}
if (info.isVariant(CMISObjectVariant.VERSION))
{
throw new CmisInvalidArgumentException("Object is a document version!");
}
// check if the relationship base type is requested
if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
{
boolean isrt = (includeSubRelationshipTypes == null ? false : includeSubRelationshipTypes.booleanValue());
if (isrt)
{
// all relationships are a direct subtype of the base type in
// Alfresco -> remove filter
typeId = null;
}
else
{
// there are no relationships of the base type in Alfresco ->
// return empty list
ObjectListImpl result = new ObjectListImpl();
result.setHasMoreItems(false);
result.setNumItems(BigInteger.ZERO);
result.setObjects(new ArrayList<ObjectData>());
return result;
}
}
return connector.getObjectRelationships(
info.getNodeRef(), relationshipDirection, typeId, filter, includeAllowableActions,
maxItems, skipCount);
}
// --- policy service ---
@Override
public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
TypeDefinitionWrapper type = info.getType();
if (type == null)
{
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
connector.applyPolicies(info.getNodeRef(), type, Collections.singletonList(policyId));
}
@Override
public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
TypeDefinitionWrapper type = info.getType();
if (type == null)
{
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
throw new CmisConstraintException("Object is not policy controllable!");
}
@Override
public List<ObjectData> getAppliedPolicies(
String repositoryId, String objectId, String filter, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// what kind of object is it?
getOrCreateNodeInfo(objectId, "Object");
// policies are not supported -> return empty list
return Collections.emptyList();
}
// --- ACL service ---
@Override
public Acl applyAcl(
String repositoryId, String objectId, final Acl addAces, final Acl removeAces,
AclPropagation aclPropagation, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
// We are spec compliant if we just let it through and the tck will not fail
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
final NodeRef nodeRef = info.getCurrentNodeNodeRef();
final TypeDefinitionWrapper type = info.getType();
connector.applyACL(nodeRef, type, addAces, removeAces);
return connector.getACL(nodeRef, false);
}
@Override
public Acl applyAcl(String repositoryId, String objectId, final Acl aces, AclPropagation aclPropagation)
{
checkRepositoryId(repositoryId);
// We are spec compliant if we just let it through and the tck will not fail
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
final NodeRef nodeRef = info.getCurrentNodeNodeRef();
final TypeDefinitionWrapper type = info.getType();
connector.applyACL(nodeRef, type, aces);
return connector.getACL(nodeRef, false);
}
@SuppressWarnings("unchecked")
@Override
public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension)
{
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
if (info.isVariant(CMISObjectVariant.ASSOC))
{
return new AccessControlListImpl(Collections.EMPTY_LIST);
}
// get the ACL
return connector.getACL(info.getCurrentNodeNodeRef(), onlyBasicPermissions);
}
// --------------------------------------------------------
/**
* Collects the {@link ObjectInfo} about an object.
*
* (Provided by OpenCMIS, but optimized for Alfresco.)
*/
@Override
public ObjectInfo getObjectInfo(String repositoryId, String objectId)
{
return getObjectInfo(repositoryId, objectId, null, IncludeRelationships.BOTH);
}
protected ObjectInfo getObjectInfo(String repositoryId, String objectId, IncludeRelationships includeRelationships)
{
return getObjectInfo(repositoryId, objectId, null, includeRelationships);
}
protected ObjectInfo getObjectInfo(
String repositoryId, String objectId, String filter,
IncludeRelationships includeRelationships)
{
ObjectInfo info = objectInfoMap.get(objectId);
if (info == null)
{
CMISNodeInfo nodeInfo = getOrCreateNodeInfo(objectId);
if (nodeInfo.getObjectVariant() == CMISObjectVariant.INVALID_ID
|| nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_EXISTING
|| nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_A_CMIS_OBJECT
|| nodeInfo.getObjectVariant() == CMISObjectVariant.PERMISSION_DENIED)
{
info = null;
} else
{
// object info has not been found -> create one
try
{
if (filter == null)
{
filter = MIN_FILTER;
}
else if (!filter.equals("*"))
{
filter = filter + "," + MIN_FILTER;
}
// get the object and its info
ObjectData object = connector.createCMISObject(
nodeInfo, filter, false, includeRelationships, null, false, false);
info = getObjectInfoIntern(repositoryId, object);
// add object info
objectInfoMap.put(objectId, info);
}
catch (Exception e)
{
e.printStackTrace();
info = null;
}
}
}
return info;
}
/**
* Collects the {@link ObjectInfo} about an object.
*
* (Provided by OpenCMIS, but optimized for Alfresco.)
*/
@Override
protected ObjectInfo getObjectInfoIntern(String repositoryId, ObjectData object)
{
// if the object has no properties, stop here
if (object.getProperties() == null || object.getProperties().getProperties() == null)
{
throw new CmisRuntimeException("No properties!");
}
CMISNodeInfo ni = getOrCreateNodeInfo(object.getId());
ObjectInfoImpl info = new ObjectInfoImpl();
// general properties
info.setObject(object);
info.setId(object.getId());
info.setName(ni.getName());
info.setCreatedBy(getStringProperty(object, PropertyIds.CREATED_BY));
info.setCreationDate(getDateTimeProperty(object, PropertyIds.CREATION_DATE));
info.setLastModificationDate(getDateTimeProperty(object, PropertyIds.LAST_MODIFICATION_DATE));
info.setTypeId(getIdProperty(object, PropertyIds.OBJECT_TYPE_ID));
info.setBaseType(object.getBaseTypeId());
if (ni.isRelationship())
{
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(null);
info.setIsCurrentVersion(true);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
// content
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
// parent
info.setHasParent(false);
// policies and relationships
info.setSupportsRelationships(false);
info.setSupportsPolicies(false);
// renditions
info.setRenditionInfos(null);
// relationships
info.setRelationshipSourceIds(null);
info.setRelationshipTargetIds(null);
// global settings
info.setHasAcl(false);
info.setSupportsDescendants(false);
info.setSupportsFolderTree(false);
}
else if (ni.isFolder())
{
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(null);
info.setIsCurrentVersion(true);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
// content
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
// parent
info.setHasParent(!ni.isRootFolder());
// policies and relationships
info.setSupportsRelationships(true);
info.setSupportsPolicies(true);
// renditions
info.setRenditionInfos(null);
// relationships
setRelaionshipsToObjectInfo(object, info);
// global settings
info.setHasAcl(true);
info.setSupportsDescendants(true);
info.setSupportsFolderTree(true);
}
else if (ni.isDocument())
{
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(ni.getCurrentNodeId());
if (ni.isPWC())
{
info.setIsCurrentVersion(false);
info.setWorkingCopyId(ni.getObjectId());
info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
}
else
{
info.setIsCurrentVersion(ni.isCurrentVersion());
if (ni.hasPWC())
{
info.setWorkingCopyId(ni.getCurrentNodeId() + CMISConnector.ID_SEPERATOR
+ CMISConnector.PWC_VERSION_LABEL);
info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
} else
{
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
}
}
// content
String fileName = getStringProperty(object, PropertyIds.CONTENT_STREAM_FILE_NAME);
String mimeType = getStringProperty(object, PropertyIds.CONTENT_STREAM_MIME_TYPE);
String streamId = getIdProperty(object, PropertyIds.CONTENT_STREAM_ID);
BigInteger length = getIntegerProperty(object, PropertyIds.CONTENT_STREAM_LENGTH);
boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
if (hasContent)
{
info.setHasContent(hasContent);
info.setContentType(mimeType);
info.setFileName(fileName);
}
else
{
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
}
// parent
info.setHasParent(ni.isCurrentVersion() || ni.isPWC());
// policies and relationships
info.setSupportsRelationships(true);
info.setSupportsPolicies(true);
// renditions
info.setRenditionInfos(null);
List<RenditionData> renditions = object.getRenditions();
if (renditions != null && renditions.size() > 0)
{
List<RenditionInfo> renditionInfos = new ArrayList<RenditionInfo>();
for (RenditionData rendition : renditions)
{
RenditionInfoImpl renditionInfo = new RenditionInfoImpl();
renditionInfo.setId(rendition.getStreamId());
renditionInfo.setKind(rendition.getKind());
renditionInfo.setContentType(rendition.getMimeType());
renditionInfo.setTitle(rendition.getTitle());
renditionInfo.setLength(rendition.getBigLength());
renditionInfos.add(renditionInfo);
}
info.setRenditionInfos(renditionInfos);
}
// relationships
setRelaionshipsToObjectInfo(object, info);
// global settings
info.setHasAcl(true);
info.setSupportsDescendants(true);
info.setSupportsFolderTree(true);
}
return info;
}
private void setRelaionshipsToObjectInfo(ObjectData object, ObjectInfoImpl info)
{
info.setRelationshipSourceIds(null);
info.setRelationshipTargetIds(null);
List<ObjectData> relationships = object.getRelationships();
if (relationships != null && relationships.size() > 0)
{
List<String> sourceIds = new ArrayList<String>();
List<String> targetIds = new ArrayList<String>();
for (ObjectData relationship : relationships)
{
String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
if (object.getId().equals(sourceId))
{
sourceIds.add(relationship.getId());
}
if (object.getId().equals(targetId))
{
targetIds.add(relationship.getId());
}
}
if (sourceIds.size() > 0)
{
info.setRelationshipSourceIds(sourceIds);
}
if (targetIds.size() > 0)
{
info.setRelationshipTargetIds(targetIds);
}
}
}
// --------------------------------------------------------
private void checkRepositoryId(String repositoryId)
{
if (!connector.getRepositoryId().equals(repositoryId))
{
throw new CmisObjectNotFoundException("Unknown repository '" + repositoryId + "'!");
}
}
private Charset getEncoding(File tempFile, String mimeType)
{
Charset encoding = null;
try
{
InputStream tfis = new BufferedInputStream(new FileInputStream(tempFile));
ContentCharsetFinder charsetFinder = connector.getMimetypeService().getContentCharsetFinder();
encoding = charsetFinder.getCharset(tfis, mimeType);
tfis.close();
} catch (Exception e)
{
throw new CmisStorageException("Unable to read content: " + e.getMessage(), e);
}
return encoding;
}
private File copyToTempFile(ContentStream contentStream)
{
if (contentStream == null)
{
return null;
}
File result = null;
try
{
result = TempFileProvider.createTempFile(contentStream.getStream(), "cmis", "content");
}
catch (Exception e)
{
throw new CmisStorageException("Unable to store content: " + e.getMessage(), e);
}
if ((contentStream.getLength() > -1) && (result == null || contentStream.getLength() != result.length()))
{
removeTempFile(result);
throw new CmisStorageException("Expected " + contentStream.getLength() + " bytes but retrieved " +
(result == null ? -1 :result.length()) + " bytes!");
}
return result;
}
private void removeTempFile(File tempFile)
{
if (tempFile == null)
{
return;
}
try
{
tempFile.delete();
}
catch (Exception e)
{
// ignore - file will be removed by TempFileProvider
}
}
}