Merged V3.4-TEAM to HEAD

26804: Fixed line endings and removed sundry svn:mime-type properties after merge rev 26779
   26805: Merged BRANCHES/V3.4/ to BRANCHES/V3.4-TEAM:
      26803: Fixes: ALF-8138, adds a i18n property for a ToDo list's attachment title.
   26817: Fixes: ALF-7813 - Mini Calendar now highlights all events rather than only the ones valid for the current view.
   26821: Fixed ALF-7889: Auditable data should not change during archive and restore
    - NodeService archive (private method) and restore (public method) switch off cm:auditable behaviour
    - This is system-wide and not configurable
   26823: ALF-8152 - Simple view: incorrect file type icon
   26826: GDoc: Collections are now being correctly created in GDoc when document is checked out
   
   26829: Change initial load event back to onContentReady to keep Firefox & Firebug happy.
   26830: ALF-8151 - Filetype icon or is incorrectly displayed at the Content I'm editing dashlet. (Copied mappings across from alfresco.js)
   26833: Fixed ALF-8060 "Collaborator can't edit created links by other users"
   26836: Fix for ALF-8126
   26837: Fixes ALF-8124: Override default BitRock NLS readme strings
   26840: Fixed ALF-8127 "Inconsistence between Create and Edit user page"
   26841: Fix for ALF-1044. (Searching for groups whose names contain regex reserved chars.)
     The fix was to add [] as reserved chars to the RegEx SimpleLanguageDef. Thanks AndyH.
   26844: Fixed ALF-8000, ALF-7997, ALF-8108 and ALF-7721. Partial fix for ALF-8156. All these issues relate to admin console form configuration.
   26845: Fix for ALF-8181 - Admin console - sometimes displays the 'previous' tool, one step behind mouse click
   26854: Fixed ALF-8179: The new HTML email templates are bootstrapped with a mimetype of text/html they should be text/plain as they are freemarker files. Being plain text allows the content to be edited without TinyMCE corrupting the raw source. I also made all the templates inline editable.
   
   NOTE: To see these changes you must start with a clean database as these changes are only applied during initial bootstrap.
   26865: Merged V3.4-BUG-FIX to V3.4-TEAM
      26864: ALF-8025: JMX forms will no longer persist invalid values and subsystem auto-start errors are non-fatal
         - Errors on bootstrap subsystem startup are logged and absorbed. So should still always be possible to bring the server up to a level where its configuration can be corrected
         - The JMX setAttributes() method, which sets multiple attributes at once, is now handled differently from an individual setAttribute()
         - It attempts to restart the subsystem with the new properties. If successful these are persisted and a reload message is broadcast across the cluster. If unsuccessful it rolls back to the old properties and restarts the subsystem with those. Then the error is passed on to the caller.
         - Unit tested through JMX by AuthenticationChainTest
   26871: Refactor of fix to ALF-7888 to address clarified/extended requirements.
     After discussions with various engineers & the product manager, it has been agreed that sites should not appear in the recycle bin as they cannot be recovered from there. This is not a change to existing behaviour.
     However, formerly sites were only hard-deleted if deleted via the SiteService & remained archivable via the Explorer client and presumably other protocols such as CIFS.
     Now sites will by default not be deletable at all. So any attempt to delete a site via Explorer, CIFS etc will fail with an exception. This is achieved with a policy/behaviour on Site deletion.
     But that behaviour is disabled within the SiteService.deleteSite thus allowing deletion (and hard deletion at that) via that service only.
     End result is that admins can't accidentally delete sites as most interfaces prevent it and Share allows it after the normal warning dialogs.
   
     Had to tweak the SiteLoadPatch to delete a site via the SiteService rather than the NodeService.
   26873: Merged BRANCHES/V3.4 to BRANCHES/V3.4-TEAM:
      26860: ALF-7101 and ALF-7866 - don't show the rules options to collaborators, as they shouldn't be able to create/manage rules
   26874: Previous check-in (svn r. 26871 for ALF-7888) slightly broke the sample site for Team.
   Refactored the SiteLoadPatch to fix that.
   26875: ALF-7835 - args["itemTitle"] and args["page"] are already decoded, so don't try to decodeURIComponent them a second time when building the activity feed, otherwise it'll fail with special characters
   26893: Fixed ALF-7821 & ALF-7967 by making the OpenOffice read-only as it's all pre-installed for Team and shouldn't be editable. Also removed the (Subsystem) from the OpenOffice label.
   
   Also updated forms to remove the 'operations' button and move back to a Save/Cancel button as since Dave's changes to setAttributes() all the logic (including rollback of invalid properties) is now handled, meaning we no longer have to call the start() operation on the MBean.
   26901: Merged V3.4 to V3.4-TEAM
      26900: ALF-8180: The installer shouldn't randomly delete a directory called tomcat that it didn't create
         - Fix provided by Bitrock
   26905: Fix for ALF-8207 - Themes are not translated (not resolving title ids)
   26910: Fixed ALF-8206 "ES - Layout dashlets"
   26913: ALF-7838 - When paging the comments, do the reverse ordering before we page, rather than after
   26920: More on ALF-7004. The notification templates (used in the send email action of a rule) now follow the look and feel of the mockups Linton did originally.
   
   For this to work the MailActionExcecuter action needed the shareUrl, as all other email sending processes go through this action they no longer need to pass the shareUrl in. There was some inconsistency in how the URL was structured (sometimes with a trailing slash, sometimes not) so this has been cleaned up, which did mean more template updates.
   
   As before, this will require a clean database to see the updated templates.
   26921: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/V3.4-TEAM:
      26349: ALF-6062 - Add sorting by display name to the Group REST APIs that support paging
      26375: ALF-6062 - Make sorting of groups in the rest API case insensitive.
      26376: Correct long-incorrect indent and style stuff (at Gav's request)
      26402: ALF-6062 - Paging and Sorting (Case Insensitive) for the Groups REST APIs
      26423: ALF-6062 - Support sorting and paging of the child authorities and users of a group in the REST API, where previously only child groups were sortable and pageable
   26924: Some of ALF-8223: Added form config for GoogleDocs properties currently present on MBean
   26931: ALF-8092 - Convert the archived nodes webscript to the new style paging, which fixes an array index issue
   26933: Fixed ALF-8156: Too many detailed options for filesystem configuration in Admin Console
   
   Also made the position of 'enabled' properties consistent i.e. the first thing in the form/section.
   26937: Build fix for FeedCleanerTest. Also a refactoring of the Site deletion prevention behaviour for ALF-7888.
   This pattern should now be reusable outside the site service.
   
   I took my BeforeDeleteNode behaviour off the st:site node type. It was registered in SiteAspect.java.
   This was causing the test case failure as when I disabled behaviours on a site node before deletion, I was
   disabling all behaviours, including the necessary FeedCleaner behaviour.
   
   Added new aspect cm:undeletable
   Sites now have cm:undeletable as a mandatory aspect
   
   The BeforeDeleteNode behaviour that was attached to sites is now attached to cm:undeletable in UndeletableAspect.java
   
   site-services-context.xml defines an undeletableAspect bean which registers the behaviour on cm:undeletable.
   This could perhaps be moved into the NodeService. Will discuss on Monday.
   
   26938: Fixes ALF-8196: Ensure that WebView title bar link is updated as soon as its set
   26940: Fix for ALF-8036. Incorrect permissions copied when copying folder with permissions from one site to another.
     Permissions on nodes held within share sites are now cleaned after a move or a copy to a different share site.
     Cleaning in this context means permissions relating to the old site are removed and permission inheritance is turned on again. In this way the relocated nodes will look like they have just been uploaded, as requested in the issue comments.
     A new method in the SiteService stack (cleanSitePermissions) is used to initiate this clean-up from the move-to, copy-to slingshot webscripts.
     This is delegated to a new class/bean SitesPermissionCleaner which encapsulates the clean-up operation.
     The cleanup must be recursive as there could be nodes anywhere within the relocated tree which have permissions directly set on them. The tree is walked using nodeDAOs for efficiency. The cleanup is performed with aclDAOs, again for efficiency.
   
     This fix was developed on 3.4.2, but was backed out of there and is now checked in (effectively for the first time) on Team. This check-in will need to be merged to 3.4.3 at some point.
   26941: Updating svn properties on root associated with check-in 26940 for ALF-8036.
   Sorry. I forgot to check these in a moment ago.
   
   26949: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/V3.4-TEAM:
      26945: ALF-3554 / ALF-8257 - Adding rules to a node applies a marker aspect, so update the Rules Service to remove this when all removes are deleted.
   26950: Fix failing tests caused by r26920. Now that we rely on the Mail Action Executor to set the share URL for the templates, it's no longer available at the mock level when not calling the MailActionExecutor. Switch to a different model variable to check
   26954: ALF-8232 - Paging controls in doclib can overlay on top of sorting controls at 1024 screen res when 8+ pages are present
   26955: Follow-up to r26954 (ALF-8232). Remove local i18n messages for Links component.
   26956: Fixed ALF-8223 "Google integration needs Admin Console to configure options"
   26963: Fixed ALF-8223 "Google integration needs Admin Console to configure options"
   26964: Fixed ALF-8226 "ES FR DE Site pages in Customise Site to be spaced"
   - tested in FF3.5, SF3 & IE6,7,8
   26966: Added missing theme ID string
   26968: Merged V3.4-BUG-FIX to V3.4-TEAM
      26967: Fix for ALF-8259 - Static Asset Cache use of the /res resource servlet has overwritten the cachecontrol values set by the filter.
   26969: Moving the cm:undeletable aspect out of the SiteService and into the NodeService. Loosely related to ALF-7888.
   The cm:deletable aspect has been renamed to sys:undeletable.
   The class which registers the default behaviour, UndeletableAspect, has been moved into repo/node.
   Various minor changes in model files & spring config required.
   26970: ALF-8267 - Data Lists: search for user should not require minimum characters
   26971: Fixed ALF-8280 "ALL LANG - conversor pdf2swf - untranslated"
   26976: ALF-8271 - "Repository" appears as a destination when creating/editing linked rules in Doc Library.
   Rules picker now switches available modes based on whether Repository browsing is allowed or not. Removed reference to non-existent file. Also made rules picker sensitive to changing picker mode or site.
   26977: Fixes: ALF-7812: Adds support for multiday events.
   26978: Fixes: ALF-6107 - Fixes Tab order isses with Add event form.
   26979: Fix for ALF-8264. My Tasks incorrect capitalization.
   26991: ALF-8276 - "Select" dialog when adding items to workflow shows more information than in should
   26992: Fix for ALF-8288 - ES - Typo in serach result and also variable doesn't seem to work. Translation error, corrupted {0} strings pattern.
   26993: ALF-8148 - Details page Permissions incorrectly shows No privileges
   26994: Follow-up to r26993 (ALF-8148) for folders.
   26995: ALF-8265 - Data Lists: inconsistent capitalization; tooltip text is wordy
   26998: Fixes ALF-8091: Decode page URLs when removing dynamic welcome dashlets
   27000: Merged V3.4-BUG-FIX to V3.4-TEAM
      26999: Update to correct latest spring-webscripts-api jar
   27001: Fixes: ALF-8119 (IE8 bugs) & ALF-8118 - Clears event data from form.
   27005: Fixes: ALF-8168 - JSON encoding issue in Calendar API
   27025: Slight tweak to login dialog for iOS user usability
   27026: Fixes ALF-7764: Remove fade effect on title bar actions in IE to ensure correct image rendering
   27035: ALF-8314 - Document Library: Comment displays poorly when first word of comment is short.
   27040: Fix for ALF-8126 - Incorrect title of Transformer ImageMagick - missed labels
   27076: Merged V3.4-BUG-FIX to V3.4-TEAM
      26668: Fixes ALF-7920: Updated Linux/OSX config to add support for missing TIFF files in ImageMagic (dependant upon r26667 in ALF-BINARIES)
   27084: Merged V3.4 to V3.4-TEAM
      27083: ALF-8124: Corrected ${} placeholders in Japanese installer strings
   27091: Merged V3.4 to V3.4-TEAM
      26834: Fixes ALF-7904, ALF-8063: BitRock config updates
   27093: Fix for ALF-8308. Cannot like a folder that has rules defined for it.
     Added a necessary fix which prevents the exception being thrown.
   27094: Fixed ALF-8223: Google integration needs Admin Console to configure options.
   
   Also fixed a couple of other strings broken in a previous commit.
   27102: Further fix for ALF-8223: Google integration needs Admin Console to configure options. Removed application name to leave just enabled checkbox, username and password fields.
   27105: Fixed ALF-8277 & ALF-8253: Tooltips are not translated
   
   The JMX attribute description is no longer returned by the form processor as 99% of the time they don't contain anything useful and they are not localised.
   27106: Fix for ALF-8321: Cancel workflows move it to trashcan
   27115: ALF-7826, ALF-7949, ALF-8180, ALF-7904, ALF-8063: Reconciled project-team.xml with changes in project.xml
   27118: Merged V3.4-BUG-FIX to V3.4-TEAM
      26669: Fixes ALF-7987: Ensure rollback directories are removed on uninstall
   27119: ALF-8128: Propagate Team project name into Linux installer builder
   27137: Merged V3.4 to V3.4-TEAM
      27136: Installer string updates from Gloria
   27140: Temporary workaround to prevent rules running on cm:rating nodes (which happened for 'liked' folders ALF-8308 & ALF-8382)
   
   27162: Fixed ALF-8427 "Language packs: It's impossible to view any version of the wiki page if it contains native characters"
   27166: Updates to the invitation email templates following delivery of new l10n files.
   These changes were 'hand-merged' due to missing styling markup in the delivered l10n files.
   The new files had all styling markup removed.
   
   For the record, here's what I did:
   
   I compared the new and old files foreach {de, es, fr, it, ja} and found that all changes were short, simple and easy to merge.
   So I pasted in the main content div from the new l10n files, leaving all other styling markup (meaning css) unchanged.
   For the record, here's what diff says changed in this check-in:
   
   DE
   53c53
   <                                              
   ---
   > 
   55c55
   <                                              hat Sie eingeladen, als ${args["inviteeSiteRole"]} an der Site  ${args["siteName"]} teilzunehmen.</p>
   ---
   >                                              hat Sie eingeladen, mit der Rolle ${args["inviteeSiteRole"]} an der Site <b>${args["siteName"]}</b> teilzunehmen.</p>
   62,63c62,63
   <                                              <br />Benutzername: ${args["inviteeUserName"]}
   <                                              <br />Passwort: ${args["inviteeGenPassword"]}
   ---
   >                                              <br />Benutzername: <b>${args["inviteeUserName"]}</b>
   >                                              <br />Passwort: <b>${args["inviteeGenPassword"]}</b>
   66c66
   <                                              <p>Wir legen Ihnen nahe, das Passwort bei der ersten Anmeldung zu ändern.
   ---
   >                                              <p><b>Wir legen Ihnen nahe, das Passwort bei der ersten Anmeldung zu ändern.</b><br />
   
   ES
   52,53c52,53
   <                                              <p>Hola ${inviteePerson.properties["cm:firstName"]!""}:</p>
   <                                              
   ---
   >                                              <p>Hola, ${inviteePerson.properties["cm:firstName"]!""}:</p>
   > 
   55c55
   <                                              le ha invitado a unirse al sitio ${args["siteName"]} con el rol de ${args["inviteeSiteRole"]}.</p>
   ---
   >                                              le ha invitado a unirse al sitio <b>${args["siteName"]}</b> con el rol de ${args["inviteeSiteRole"]}.</p>
   62,63c62,63
   <                                              <br />Nombre de usuario: ${args["inviteeUserName"]}
   <                                              <br />Contraseña: ${args["inviteeGenPassword"]}
   ---
   >                                              <br />Nombre de usuario: <b>${args["inviteeUserName"]}</b>
   >                                              <br />Contraseña: <b>${args["inviteeGenPassword"]}</b>
   66,67c66,67
   <                                              <p>Le recomendamos que cambie la contraseña la primera vez que inicie una sesión.
   <                                              Para hacerlo, vaya a <b>Mi Perfil</b> y seleccione <b>Cambiar contraseña</b>.</p>
   ---
   >                                              <p><b>Le recomendamos que cambie la contraseña la primera vez que inicie sesión.</b><br />
   >                                              Para hacerlo, vaya a <b>Mi perfil</b> y seleccione <b>Cambiar contraseña</b>.</p>
   
   FR
   53c53
   <                                              
   ---
   > 
   55c55
   <                                              vous invite à rejoindre le site ${args["siteName"]} avec un rôle de ${args["inviteeSiteRole"]}.</p>
   ---
   >                                              vous invite à rejoindre le site <b>${args["siteName"]}</b> avec un rôle de ${args["inviteeSiteRole"]}.</p>
   62,63c62,63
   <                                              <br />Nom d'utilisateur : ${args["inviteeUserName"]}
   <                                              <br />Mot de passe : ${args["inviteeGenPassword"]}
   ---
   >                                              <br />Nom d'utilisateur : <b>${args["inviteeUserName"]}</b>
   >                                              <br />Mot de passe : <b>${args["inviteeGenPassword"]}</b>
   66c66
   <                                              <p>Nous vous conseillons vivement de modifier votre mot de passe lors de votre première connexion.
   ---
   >                                              <p><b>Nous vous conseillons vivement de modifier votre mot de passe lors de votre première connexion.</b><br />
   70c70
   <                                              <p>Si vous souhaitez décliner l'invitation de ${inviterPerson.properties["cm:firstName"]!""} cliquez sur ce lien :<br />
   ---
   >                                              <p>Si vous souhaitez décliner l'invitation de ${inviterPerson.properties["cm:firstName"]!""}’, cliquez sur ce lien :<br />
   
   
   IT
   53c53
   <                                              
   ---
   > 
   55c55
   <                                              ti ha  inviatato a partecipare al sito ${args["siteName"]} con il ruolo di ${args["inviteeSiteRole"]}.</p>
   ---
   >                                              sei stato inviatato a partecipare al sito <b>${args["siteName"]}</b> con il ruolo di ${args["inviteeSiteRole"]}.</p>
   57c57
   <                                              <p>Fare clic sul collegamento per accettare l’invito dell'${inviterPerson.properties["cm:firstName"]!""}':<br />
   ---
   >                                              <p>Fare clic sul collegamento per accettare ${inviterPerson.properties["cm:firstName"]!""}'s l'invito:<br />
   62,63c62,63
   <                                              <br />Nome utente: ${args["inviteeUserName"]}
   <                                              <br />Password: ${args["inviteeGenPassword"]}
   ---
   >                                              <br />Nome utente: <b>${args["inviteeUserName"]}</b>
   >                                              <br />Password: <b>${args["inviteeGenPassword"]}</b>
   66c66
   <                                              <p>Si consiglia di cambiare la password quando si effettua l'eccesso per la prima volta.
   ---
   >                                              <p><b>Si consiglia di cambiare la password quando si effettua l'eccesso per la prima volta.</b><br />
   70c70
   <                                              <p>Per rifiutare l’invito dell’${inviterPerson.properties["cm:firstName"]!""}, fare clic su questo collegamento:<br />
   ---
   >                                              <p>Per rifiutare ${inviterPerson.properties["cm:firstName"]!""}’s l'invito, fare clic su questo collegamento:<br />
   
   
   JA
   53c53
   <                                              
   ---
   > 
   55c55
   <                                              ????${args["siteName"]} ??????${args["inviteeSiteRole"]}?????????????????????</p>
   ---
   >                                              ????<b>${args["siteName"]}</b> ????? ${args["inviteeSiteRole"]} ????????????????????</p>
   62,63c62,63
   <                                              <br />????: ${args["inviteeUserName"]}
   <                                              <br />?????: ${args["inviteeGenPassword"]}
   ---
   >                                              <br />????: <b>${args["inviteeUserName"]}</b>
   >                                              <br />?????: <b>${args["inviteeGenPassword"]}</b>
   66c66
   <                                              <p>?????????????????????????????
   ---
   >                                              <p><b>?????????????????????????????</b><br />
   
   27172: Fixed ALF-7856 "Team: DocLib action displaying incorrect tooltip text"
   27339: ALF-8330 - ALL LANG - "Assigned To" in Data List created displays untranslated
   27340: Fixes Encoding issue in L10N files.
   27471: Fix for ALF-8150 - check for visibility before applying focus to element for IE.
   27499: Drop one and two of updates from translators based on rev26820
   27501: ALF-8151 - Filetype icon or is incorrectly displayed at the Content I'm editing dashlet
   27507: ALF-8478: Default repeat interval for activity email notifications should be 1 day
   27520: Fixed ALF-8329 "Consumer can add comments to files, folders, links and blogs"
   27527: Fixes ALF-8409: Ensure that UTF-8 encoded characters in file names can be uploaded to folders (that may also contain UTF-8 encoded characters) via DND in FireFox 3.6
   27531: Merged V3.4-BUG-FIX to V3.4-TEAM
      27525: Merged V3.4 to V3.4-BUG-FIX
         27120: Resolve ALF-8187: Transaction retries of CMIS webscripts failing
   27543: Fixed ALF-8464 "Start Workflow: Search for groups still requires minimum 1 character"
   27562: Merged V3.4-BUG-FIX to V3.4-TEAM
      27560: Fix for ALF-8434 - AVMRemoteStore not setting UTF-8 response encoding for some methods
   27572: Fixes: ALF-7596 - Config values not being correctly read in FTL
   27573: Fixed ALF-8504: Non-admin users are warned about license expiry too soon
    - ALF-8502 Adjust admin warning period from 30 to 21 days
    - ALF-7259 RTEAM 33: RepoAdmin Web Script to report Red/Amber/Green
   27592: Fixes: ALF-8444 - JA properties file in incorrect location.
   27594: ALF-8508 - Document Library: Google Docs actions not correct
   27596: Fixed ALF-8484	"Consumer and Contributor should not be able to choose button "Revert" of the document"
   27598: Annotated properties file to indicate which text is exposed to the UI and therefore needs translating. Needed for: ALF-8442
   27615: Fix for ALF-8501 - License warning box needs to be toned down in colour
   27616: Tweak for IE
   27617: Fixes: ALF-8423 - string missed in earlier merge
   27619: ALF-7904: Synchronize alfresco-customteam-settings.xml with alfresco-customstack-postgres-settings.xml!
   27625: ALF-7518 - Update Team Help and Tutorial URLs once finalised. * DO NOT MERGE *
   Note: version.edition cannot be used as a placeholder due to the mismatch between "edition=Enterprise" and help URL containing "team"
   27626: Change default value for "useTitle" to true for Site DocLib
   27648: Fix for ALF-8552
   27649: Fixed ALF-8495: Alfresco Logo is incorrectly displayed in notify user letter
   
   Usual note with these checkins applies, clean database will be required to see the updated templates.
   27650: Fixed ALF-8425: Select Tags button is missing at the Edit Properties page for msg files
   27664: Issue checking in XSLX Google Docs (related to ALF-8580)
   
   27667: ALF-7518 - Update Team Help and Tutorial URLs once finalised
   New tutorial URL for Share, now hosted within main docs system; uh-tutorial.html topic page.
   27683: Merged BRANCHES/DEV/dwebsterTeam to BRANCHES/V3.4-TEAM:
      27675: DE: Drop 3 & 4 for Team translations based on r27552
      27676: ES: Drop 3 & 4 for Team translations based on r27552
      27677: FR: Drop 3 & 4 for Team translations based on r27552
      27678: IT: Drop 3 & 4 for Team translations based on r27552
      27679: JA: Drop 3 & 4 for Team translations based on r27552
      27680: L10N updates to system-messages.properties (for License messages exposed to UI)
   27686: Fixes: ALF-8266
   27694: Change related to ALF-8556. Sometimes Google Docs cannot be checked out.
   This change was suggested by Roy. cm:failedThumbnail nodes were deleted onUpdateProperties. Now they are only deleted if there are no locks preventing their deletion (e.g. due to being checked out.)
   27710: Fixed ALF-7721: There are no field rescrtictions on 'Edit: Fileservers' form and ALF-8558: There is no pattern for Username field in Google Docs
   27711: ALF-8590 - Check Out for some documents is not working
   ALF-8591 - CheckIn form Google docs for some documents is not working
   
   Google Docs-specific filter code added to Manage Aspects UI to remove "gd:googleEditable from the list of addable aspects unless the file's mimetype is supported (i.e. txt, doc, xls, ppt). Google Docs enabled ootb in team-config.
   27713: GDoc - Fix for checkout of .odt files (see ALF-8599)
   
   27723: Added back theme name string that was removed in rev 26971
   27740: Updates from Gloria following bundle completeness analysis.
   27755: Removed extra unused Japanese translation files.
   27756: ALF-8207 - ALL LANG - Themes are not translated
   27759: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/V3.4-TEAM:
      27758: Merged BRANCHES/V3.4 to BRANCHES/DEV/V3.4-BUG-FIX:
           27757: Fix for ALF-8430.
   27761: JA Updates from Gloria following bundle completeness analysis.
   27767: Fixes: ALF-8279 - reloads translation Gloria sent.
   27768: ALF-8213 - Manage My Subscription link now directs to team.alfresco.com - tooltip from label added
   27769: Fixes ALF-8652: Add removed quotes and revert translations back to correct language
   27770: Fixes: ALF-8228: Column widening needed
   27771: Initial commit of these translated files from Gloria.
   27772: ALF-8555 - Incorrect behavior of enabling Google docs (Really: Forms get submitted twice in certain circumstances)
   27773: ALF-8329 - Consumer can add comments to files, folders, links and blogs
   Fixed: 8. Open details page for file and try to add comment --> comment added successfully;
   27774: Spanish Gender Changes following review from Gloria.
   27779: Final fixes from L10N completeness check.
   27792: Remove debugging code from r27772
   27804: ALF-8207 - ALL LANG - SpringSurf issue with default theme definition
   27826: Manually reverts (to a version prior to r27683) a file in each language that was incorrectly supplied in English, and ensures they match the current EN properties.
   27827: Fixes: ALF-8210
   27843: Fix for ALF-8449 - ALL LANG - site themes are not translated (Customise Site page)
   27873: Merged V3.4 to V3.4-TEAM:
      27871: Fixes ALF-8124: Ensure Spanish locale for installer shows product name correctly
   27883: Implementation of ALF-8737 Support for thumbnailing/previewing of additional mimetypes (Adobe). Also video/audio playbac
   k.
   
   This check in enables thumbnails for Adobe Photoshop, recent Adobe Illustrator files and previews for Adobe Photoshop, recent Adobe Illustrator files
   as well as metadata extraction for Adobe Illustrator files (PDF-based formats).
   
   It also enables video playback of .m4v files, where the browser supports it.
   I have also added placeholder icons for .m4v files.
   Adobe Photoshop (.psd) files are handled by ImageMagick. However our existing ImageMagick-based content transformer excludes most mimetypes that don't start with "image/". By allowing "application/photoshop" to be accepted, that transformer
    will now perform thumbnails and previews.
   Recent Adobe Illustrator file formats are pdf files and so can use the PDF transformers/extractors i.e. PDFRenderer and 
   PDFBox and pdf2swf.
   I have added a new complex transformer for .ai files which uses the existing PDF/ImageMagick component transformers.
   
   New JUnit test cases for these transforms.
   
   As part of testing, we discovered that IE9 will not play mp3s of mimetype == audio/x-mpeg, only audio/mpeg.
   The latter is the correct mimetype, the former is out of date, but Alfresco was using the former. So we've updated that MIME type in various places in the code.
   27888: Google Docs 
     - Updated client google doc api jars
     - Fixes ALF-8592: Incorrect behavior on permissions for Google docs
   
   27894: Minor fixes for iOS:
   . overflow content shown by default in dashlets
   . doclib long filenames no longer cause screen to resize
   . ipad css overrides
   . YUI dialogs no longer jump around the page during text entry input
   27904: Minor fixes for iOS usability:
   . Drag&drop doclist help removed for mobile devices
   . Create New DataList shows list as full height (not scrollable)
   . Removed default webkit inner shadow from input fields
   27915: Minor fixes for iOS usability: Forced scrollbar appearance on overflowed div elements


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@27939 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2011-05-20 13:30:26 +00:00
parent eebcfd38fd
commit 6ebc200a0e
89 changed files with 10039 additions and 708 deletions

View File

@@ -18,6 +18,10 @@
*/
package org.alfresco.repo.security.authority.script;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
public interface Authority
{
public enum ScriptAuthorityType { GROUP, USER };
@@ -26,4 +30,51 @@ public interface Authority
public String getFullName();
public String getDisplayName();
/**
* Does case insensitive sorting of ScriptGroups and ScriptUsers.
*/
public static class AuthorityComparator implements Comparator<Authority>
{
private Map<Authority,String> nameCache;
private String sortBy;
public AuthorityComparator(String sortBy)
{
this.sortBy = sortBy;
this.nameCache = new HashMap<Authority, String>();
}
@Override
public int compare(Authority g1, Authority g2)
{
return get(g1).compareTo( get(g2) );
}
private String get(Authority g)
{
String v = nameCache.get(g);
if(v == null)
{
// Get the value from the group
if("displayName".equals(sortBy))
{
v = g.getDisplayName();
}
else if("shortName".equals(sortBy))
{
v = g.getShortName();
}
else
{
v = g.getFullName();
}
// Lower case it for case insensitive search
v = v.toLowerCase();
// Cache it
nameCache.put(g, v);
}
return v;
}
}
}

View File

@@ -27,6 +27,8 @@ import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.security.authority.UnknownAuthorityException;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.util.PagingDetails;
/**
* Script object representing the authority service.
*
@@ -61,9 +63,23 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
/**
* Search the root groups, those without a parent group.
*
* @param maxItems Maximum number of items returned.
* @param skipCount number of items to skip.
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] searchRootGroupsInZone(String displayNamePattern, String zone, int maxItems, int skipCount)
{
return searchRootGroupsInZone(displayNamePattern, zone, new PagingDetails(maxItems, skipCount), null);
}
/**
* Search the root groups, those without a parent group.
*
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] searchRootGroupsInZone(String displayNamePattern, String zone, PagingDetails paging, String sortBy)
{
Set<String> authorities;
try {
@@ -74,9 +90,9 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
{
authorities = Collections.emptySet();
}
return makeScriptGroups(authorities, maxItems, skipCount, authorityService);
return makeScriptGroups(authorities, paging, sortBy, authorityService);
}
/**
* Search the root groups, those without a parent group.
* @return The root groups (empty if there are no root groups)
@@ -101,16 +117,26 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
*/
public ScriptGroup[] getAllRootGroups(int maxItems, int skipCount)
{
Set<String> authorities;
try{
authorities = authorityService.getAllRootAuthorities(AuthorityType.GROUP);
}
return getAllRootGroups(new PagingDetails(maxItems, skipCount));
}
/**
* Search the root groups, those without a parent group. Searches in all zones.
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] getAllRootGroups(PagingDetails paging)
{
Set<String> authorities;
try{
authorities = authorityService.getAllRootAuthorities(AuthorityType.GROUP);
}
catch(UnknownAuthorityException e)
{
authorities = Collections.emptySet();
}
return makeScriptGroups(authorities, maxItems, skipCount, authorityService);
}
return makeScriptGroups(authorities, paging, authorityService);
}
/**
* Get the root groups, those without a parent group.
* @param zone zone to search in.
@@ -124,6 +150,8 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
/**
* Get the root groups, those without a parent group.
* @param zone zone to search in.
* @param maxItems Maximum number of items returned.
* @param skipCount number of items to skip.
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] getAllRootGroupsInZone(String zone, int maxItems, int skipCount)
@@ -138,9 +166,31 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
authorities = Collections.emptySet();
}
return makeScriptGroups(authorities, maxItems, skipCount, authorityService);
return makeScriptGroups(authorities, new PagingDetails(maxItems, skipCount), null, authorityService);
}
/**
* Get the root groups, those without a parent group.
* @param zone zone to search in.
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] getAllRootGroupsInZone(String zone, PagingDetails paging, String sortBy)
{
Set<String> authorities;
try
{
authorities= authorityService.getAllRootAuthoritiesInZone(zone, AuthorityType.GROUP);
}
catch(UnknownAuthorityException e)
{
authorities = Collections.emptySet();
}
return makeScriptGroups(authorities, paging, sortBy, authorityService);
}
/**
* Get a group given its short name
* @param shortName, the shortName of the group
@@ -208,7 +258,7 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
{
return searchGroupsInZone(shortNameFilter, zone, -1, -1);
}
/**
* Search for groups in a specific zone
* Includes paging parameters to limit size of results returned.
@@ -220,6 +270,21 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
* @return the groups matching the query
*/
public ScriptGroup[] searchGroupsInZone(String shortNameFilter, String zone, int maxItems, int skipCount)
{
return searchGroupsInZone(shortNameFilter, zone, new PagingDetails(maxItems, skipCount), null);
}
/**
* Search for groups in a specific zone
* Includes paging parameters to limit size of results returned.
*
* @param shortNameFilter partial match on shortName (* and ?) work. If empty then matches everything.
* @param zone zone to search in.
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return the groups matching the query
*/
public ScriptGroup[] searchGroupsInZone(String shortNameFilter, String zone, PagingDetails paging, String sortBy)
{
String filter = shortNameFilter;
@@ -240,8 +305,6 @@ public class ScriptAuthorityService extends BaseScopableProcessorExtension
// Return an empty set if unrecognised authority.
authorities = Collections.emptySet();
}
return makeScriptGroups(authorities, maxItems, skipCount, authorityService);
return makeScriptGroups(authorities, paging, sortBy, authorityService);
}
}

View File

@@ -20,14 +20,21 @@ package org.alfresco.repo.security.authority.script;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.util.ModelUtil;
import org.alfresco.util.PagingDetails;
/**
* The Script group is a GROUP authority exposed to the scripting API.
@@ -37,8 +44,8 @@ import org.alfresco.service.cmr.security.AuthorityType;
*/
public class ScriptGroup implements Authority, Serializable
{
private static final long serialVersionUID = 6073732221341647273L;
private transient AuthorityService authorityService;
private static final long serialVersionUID = 6073732221341647273L;
private transient AuthorityService authorityService;
private ScriptAuthorityType authorityType = ScriptAuthorityType.GROUP;
private String shortName;
private String fullName;
@@ -59,200 +66,263 @@ public class ScriptGroup implements Authority, Serializable
displayName = authorityService.getAuthorityDisplayName(fullName);
}
/**
* Delete this group
*/
public void deleteGroup()
{
authorityService.deleteAuthority(fullName);
}
/**
* Delete this group
*/
public void deleteGroup()
{
authorityService.deleteAuthority(fullName);
}
public void setAuthorityType(ScriptAuthorityType authorityType) {
this.authorityType = authorityType;
}
public void setAuthorityType(ScriptAuthorityType authorityType) {
this.authorityType = authorityType;
}
public ScriptAuthorityType getAuthorityType() {
return authorityType;
}
public ScriptAuthorityType getAuthorityType() {
return authorityType;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getShortName() {
return shortName;
}
/**
* Get the short name
*/
public String getShortName() {
return shortName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getFullName() {
return fullName;
}
/**
* Get the full internal name, also known
* as the Authority Name
*/
public String getFullName() {
return fullName;
}
/**
* Change the display name for this group. Need administrator permission to call this method to change a display name.
* @param displayName
*/
public void setDisplayName(String displayName) {
if(this.displayName != null && !this.displayName.equals(displayName))
{
authorityService.setAuthorityDisplayName(fullName, displayName);
}
this.displayName = displayName;
}
/**
* Change the display name for this group. Need administrator permission to call this method to change a display name.
* @param displayName
*/
public void setDisplayName(String displayName) {
if (this.displayName != null && !this.displayName.equals(displayName))
{
authorityService.setAuthorityDisplayName(fullName, displayName);
}
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
public String getDisplayName() {
return displayName;
}
/**
* Get all users contained in this group
* @return
*/
public ScriptUser[] getAllUsers()
{
Set<String> children = authorityService.getContainedAuthorities(AuthorityType.USER, fullName, false);
Set<ScriptUser> users = new LinkedHashSet<ScriptUser>();
for(String authority : children)
{
ScriptUser user = new ScriptUser(authority, authorityService);
users.add(user);
}
return users.toArray(new ScriptUser[users.size()]);
}
/**
* Get all users contained in this group
* @return
*/
public ScriptUser[] getAllUsers()
{
Set<String> children = authorityService.getContainedAuthorities(AuthorityType.USER, fullName, false);
Set<ScriptUser> users = new LinkedHashSet<ScriptUser>();
for (String authority : children)
{
ScriptUser user = new ScriptUser(authority, authorityService);
users.add(user);
}
return users.toArray(new ScriptUser[users.size()]);
}
/**
* Get all sub groups (all decendants)
* @return the descenants of this group
*/
public ScriptGroup[] getAllGroups()
{
Set<String> children = authorityService.getContainedAuthorities(AuthorityType.GROUP, fullName, false);
Set<ScriptGroup> groups = new LinkedHashSet<ScriptGroup>();
for(String authority : children)
{
ScriptGroup group = new ScriptGroup(authority, authorityService);
groups.add(group);
}
return groups.toArray(new ScriptGroup[groups.size()]);
/**
* Get all sub groups (all decendants)
* @return the descenants of this group
*/
public ScriptGroup[] getAllGroups()
{
Set<String> children = authorityService.getContainedAuthorities(AuthorityType.GROUP, fullName, false);
Set<ScriptGroup> groups = new LinkedHashSet<ScriptGroup>();
for (String authority : children)
{
ScriptGroup group = new ScriptGroup(authority, authorityService);
groups.add(group);
}
return groups.toArray(new ScriptGroup[groups.size()]);
}
}
/**
* Get child groups of this group
*/
private ScriptUser[] childUsers;
/**
* Get child groups of this group
*/
private ScriptUser[] childUsers;
private Set<String> getChildAuthorityNames()
{
if (childAuthorityNames == null)
{
childAuthorityNames = authorityService.getContainedAuthorities(null, fullName, true);
}
return childAuthorityNames;
}
private Set<String> getChildNamesOfType(AuthorityType type)
{
Set<String> authorities = getChildAuthorityNames();
Set<String> result = new TreeSet<String>();
for (String authority : authorities)
{
if (AuthorityType.getAuthorityType(authority) == type)
{
result.add(authority);
}
}
return result;
}
/**
* Get child users of this group
*/
public ScriptUser[] getChildUsers()
{
return getChildUsers(new PagingDetails(), null);
}
/**
* Get child users of this group
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
*/
public ScriptUser[] getChildUsers(PagingDetails paging, String sortBy)
{
if (childUsers == null)
{
Set<String> children = getChildNamesOfType(AuthorityType.USER);
Set<ScriptUser> users = new LinkedHashSet<ScriptUser>();
for (String authority : children)
{
ScriptUser user = new ScriptUser(authority, authorityService);
users.add(user);
}
childUsers = users.toArray(new ScriptUser[users.size()]);
}
return makePagedAuthority(paging, sortBy, childUsers);
}
private Set<String> getChildAuthorityNames()
{
if (childAuthorityNames == null)
{
childAuthorityNames = authorityService.getContainedAuthorities(null, fullName, true);
}
return childAuthorityNames;
}
/**
* Get child groups of this group
*/
private ScriptGroup[] childGroups;
public ScriptGroup[] getChildGroups()
{
return getChildGroups(new PagingDetails(), null);
}
private Set<String> getChildNamesOfType(AuthorityType type)
{
Set<String> authorities = getChildAuthorityNames();
Set<String> result = new TreeSet<String>();
for (String authority : authorities)
{
if (AuthorityType.getAuthorityType(authority) == type)
{
result.add(authority);
}
}
return result;
}
public ScriptUser[] getChildUsers()
{
if(childUsers == null)
{
Set<String> children = getChildNamesOfType(AuthorityType.USER);
Set<ScriptUser> users = new LinkedHashSet<ScriptUser>();
for(String authority : children)
{
ScriptUser user = new ScriptUser(authority, authorityService);
users.add(user);
}
childUsers = users.toArray(new ScriptUser[users.size()]);
}
return childUsers;
}
/**
* Get child groups of this group
* @param maxItems Maximum number of groups to return.
* @param skipCount number of groups to skip before returning the first result.
*/
public ScriptGroup[] getChildGroups(int maxItems, int skipCount)
{
return getChildGroups(new PagingDetails(maxItems, skipCount), null);
}
/**
* Get child groups of this group
*/
private ScriptGroup[] childGroups;
public ScriptGroup[] getChildGroups()
{
return getChildGroups(-1, -1);
}
/**
* Get child groups of this group
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
*/
public ScriptGroup[] getChildGroups(PagingDetails paging, String sortBy)
{
if (childGroups == null)
{
Set<String> children = getChildNamesOfType(AuthorityType.GROUP);
Set<ScriptGroup> groups =makeScriptGroups(children);
childGroups = groups.toArray(new ScriptGroup[groups.size()]);
}
return makePagedAuthority(paging, sortBy, childGroups);
}
/**
* Get all the children of this group, regardless of type
*/
public Authority[] getChildAuthorities()
{
return getChildAuthorities(new PagingDetails(), null);
}
/**
* Get all the children of this group, regardless of type
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
*/
public Authority[] getChildAuthorities(PagingDetails paging, String sortBy)
{
Authority[] groups = getChildGroups();
Authority[] users = getChildUsers();
Authority[] ret = new Authority[groups.length + users.length];
System.arraycopy(groups, 0, ret, 0, groups.length);
System.arraycopy(users, 0, ret, groups.length, users.length);
return makePagedAuthority(paging, sortBy, ret);
}
/**
* Get the parents of this this group
*/
private ScriptGroup[] parentCache;
/**
* Get child groups of this group
*/
public ScriptGroup[] getChildGroups(int maxItems, int skipCount)
{
if(childGroups == null)
{
Set<String> children = getChildNamesOfType(AuthorityType.GROUP);
Set<ScriptGroup> groups =makeScriptGroups(children);
childGroups = groups.toArray(new ScriptGroup[groups.size()]);
}
return makePagedGroups(maxItems, skipCount, childGroups);
}
/**
* Get the parents of this this group
*/
private ScriptGroup[] parentCache;
/**
* Get the immediate parents of this group
* @return the immediate parents of this group
*/
public ScriptGroup[] getParentGroups()
{
return getParentGroups(-1, -1);
return getParentGroups(new PagingDetails(), null);
}
/**
* Get the immediate parents of this group
* @return the immediate parents of this group
*/
public ScriptGroup[] getParentGroups(int maxItems, int skipCount)
{
if(parentCache == null)
{
Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, fullName, true);
Set<ScriptGroup> groups = makeScriptGroups(parents);
parentCache = groups.toArray(new ScriptGroup[groups.size()]);
}
return makePagedGroups(maxItems, skipCount, parentCache);
}
private ScriptGroup[] makePagedGroups(int maxItems, int skipCount, ScriptGroup[] groups)
/**
* Get the immediate parents of this group
* @param maxItems Maximum number of groups to return.
* @param skipCount number of groups to skip before returning the first result.
* @return the immediate parents of this group
*/
public ScriptGroup[] getParentGroups(int maxItems, int skipCount)
{
boolean invalidSkipCount = skipCount <1 || skipCount>= groups.length;
skipCount = invalidSkipCount ? 0 : skipCount;
int maxSize = groups.length - skipCount;
boolean invalidMaxItems = maxItems <1 || maxItems>=maxSize;
return getParentGroups(new PagingDetails(maxItems, skipCount), null);
}
if(invalidMaxItems && invalidSkipCount)
{
return groups;
}
maxItems = invalidMaxItems ? maxSize : maxItems;
ScriptGroup[] results = new ScriptGroup[maxItems];
System.arraycopy(groups, skipCount, results, 0, maxItems);
return results;
/**
* Get the immediate parents of this group
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return the immediate parents of this group
*/
public ScriptGroup[] getParentGroups(PagingDetails paging, String sortBy)
{
if (parentCache == null)
{
Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, fullName, true);
Set<ScriptGroup> groups = makeScriptGroups(parents);
parentCache = groups.toArray(new ScriptGroup[groups.size()]);
}
return makePagedAuthority(paging, sortBy, parentCache);
}
private <T extends Authority> T[] makePagedAuthority(PagingDetails paging, String sortBy, T[] groups)
{
// Sort the groups
Arrays.sort(groups, new AuthorityComparator(sortBy));
// Now page
int maxItems = paging.getMaxItems();
int skipCount = paging.getSkipCount();
paging.setTotalItems(groups.length);
return ModelUtil.page(groups, maxItems, skipCount);
}
private Set<ScriptGroup> makeScriptGroups(Set<String> parents)
@@ -260,23 +330,23 @@ public class ScriptGroup implements Authority, Serializable
ArrayList<String> sortedParents = new ArrayList<String>(parents);
Collections.sort(sortedParents);
LinkedHashSet<ScriptGroup> groups = new LinkedHashSet<ScriptGroup>();
for(String authority : sortedParents)
for (String authority : sortedParents)
{
ScriptGroup group = new ScriptGroup(authority, authorityService);
groups.add(group);
ScriptGroup group = new ScriptGroup(authority, authorityService);
groups.add(group);
}
return groups;
}
/**
* Get all the parents of this this group
* @return all the parents of this group
*/
public ScriptGroup[] getAllParentGroups()
{
return getAllParentGroups(-1, -1);
}
/**
* Get all the parents of this this group
* @return all the parents of this group
*/
public ScriptGroup[] getAllParentGroups()
{
return getAllParentGroups(new PagingDetails(), null);
}
/**
* Get all the parents of this this group
@@ -287,38 +357,36 @@ public class ScriptGroup implements Authority, Serializable
*/
public ScriptGroup[] getAllParentGroups(int maxItems, int skipCount)
{
Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, fullName, false);
return makeScriptGroups(parents, maxItems, skipCount, authorityService);
}
return getAllParentGroups(new PagingDetails(maxItems, skipCount), null);
}
/**
* Get all the children of this group, regardless of type
*/
public Authority[] getChildAuthorities()
{
Authority[] groups = getChildGroups();
Authority[] users = getChildUsers();
Authority[] ret = new Authority[groups.length + users.length];
System.arraycopy(groups, 0, ret, 0, groups.length);
System.arraycopy(users, 0, ret, groups.length, users.length);
return ret;
}
/**
* Get all the parents of this this group
*
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return all the parents of this group
*/
public ScriptGroup[] getAllParentGroups(PagingDetails paging, String sortBy)
{
Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, fullName, false);
return makeScriptGroups(parents, paging, sortBy, authorityService);
}
/**
* Is this a root group?
* @return
*/
public boolean isRootGroup()
{
ScriptGroup[] groups = getParentGroups();
return (groups.length == 0);
}
/**
* Is this a root group?
* @return
*/
public boolean isRootGroup()
{
ScriptGroup[] groups = getParentGroups();
return (groups.length == 0);
}
/**
* Is this an admin group?
* @return
*/
/**
* Is this an admin group?
* @return
*/
public boolean isAdminGroup()
{
if (this.isAdmin == null)
@@ -328,119 +396,152 @@ public class ScriptGroup implements Authority, Serializable
return this.isAdmin;
}
/**
* Get the number of users contained within this group.
* @return the number of users contained within this group.
*/
public int getUserCount()
{
return getChildNamesOfType(AuthorityType.USER).size();
}
/**
* Get the number of child groups contained within this group.
* @return the number of child groups contained within this group.
*/
public int getGroupCount()
{
/**
* Get the number of users contained within this group.
* @return the number of users contained within this group.
*/
public int getUserCount()
{
return getChildNamesOfType(AuthorityType.USER).size();
}
/**
* Get the number of child groups contained within this group.
* @return the number of child groups contained within this group.
*/
public int getGroupCount()
{
return getChildNamesOfType(AuthorityType.GROUP).size();
}
/**
* Create a new group as a child of this group.
* @return the new group
*/
public ScriptGroup createGroup(String newShortName, String newDisplayName)
{
String authorityName = authorityService.createAuthority(AuthorityType.GROUP, newShortName, newDisplayName, authorityService.getDefaultZones());
authorityService.addAuthority(fullName, authorityName);
ScriptGroup childGroup = new ScriptGroup(authorityName, authorityService);
clearCaches();
return childGroup;
}
}
/**
* Create a new group as a child of this group.
* @return the new group
*/
public ScriptGroup createGroup(String newShortName, String newDisplayName)
{
String authorityName = authorityService.createAuthority(AuthorityType.GROUP, newShortName, newDisplayName, authorityService.getDefaultZones());
authorityService.addAuthority(fullName, authorityName);
ScriptGroup childGroup = new ScriptGroup(authorityName, authorityService);
clearCaches();
return childGroup;
}
/**
* remove sub group from this group
* @param newShortName the shortName of the sub group to remove from this group.
*/
public void removeGroup(String newShortName)
{
String fullAuthorityName = authorityService.getName(AuthorityType.GROUP, newShortName);
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* remove sub group from this group
* @param newShortName the shortName of the sub group to remove from this group.
*/
public void removeGroup(String newShortName)
{
String fullAuthorityName = authorityService.getName(AuthorityType.GROUP, newShortName);
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* Remove child user from this group
* @param newShortName the shortName of the user to remove from this group.
*/
public void removeUser(String newShortName)
{
String fullAuthorityName = authorityService.getName(AuthorityType.USER, newShortName);
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* Remove child user from this group
* @param newShortName the shortName of the user to remove from this group.
*/
public void removeUser(String newShortName)
{
String fullAuthorityName = authorityService.getName(AuthorityType.USER, newShortName);
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* AddAuthority as a child of this group
* @param fullAuthorityName the full name of the authority to add to this group.
*/
public void addAuthority(String fullAuthorityName)
{
authorityService.addAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* Remove child Authority from this group
* @param fullAuthorityName the full name of the authority to remove from this group.
*/
public void removeAuthority(String fullAuthorityName)
{
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* AddAuthority as a child of this group
* @param fullAuthorityName the full name of the authority to add to this group.
*/
public void addAuthority(String fullAuthorityName)
{
authorityService.addAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* Remove child Authority from this group
* @param fullAuthorityName the full name of the authority to remove from this group.
*/
public void removeAuthority(String fullAuthorityName)
{
authorityService.removeAuthority(fullName, fullAuthorityName);
clearCaches();
}
/**
* clear the caches
*/
private void clearCaches()
{
childUsers = null;
childGroups = null;
childAuthorityNames = null;
}
/**
* clear the caches
*/
private void clearCaches()
{
childUsers = null;
childGroups = null;
childAuthorityNames = null;
}
public static ScriptGroup[] makeScriptGroups(Collection<String> authorities,
int maxItems, int skipCount, AuthorityService authorityService)
PagingDetails paging, AuthorityService authorityService)
{
ArrayList<String> authList = new ArrayList<String>(authorities);
Collections.sort(authList);
int totalItems = authList.size();
if(maxItems<1 || maxItems>totalItems)
return makeScriptGroups(authorities, paging, null, authorityService);
}
public static ScriptGroup[] makeScriptGroups(Collection<String> authorities,
PagingDetails paging, final String sortBy, AuthorityService authorityService)
{
final ArrayList<String> authList = new ArrayList<String>(authorities);
final Map<String,ScriptGroup> scriptGroupCache = new HashMap<String, ScriptGroup>();
// Depending on what we're sorting on, we may
// need to get the details now
if("shortName".equals(sortBy) || "displayName".equals(sortBy))
{
maxItems = totalItems;
for(String authority : authorities)
{
scriptGroupCache.put(authority, new ScriptGroup(authority, authorityService));
}
final AuthorityComparator c2 = new AuthorityComparator(sortBy);
Collections.sort(authList, new Comparator<String>() {
@Override
public int compare(String g1, String g2)
{
ScriptGroup sg1 = scriptGroupCache.get(g1);
ScriptGroup sg2 = scriptGroupCache.get(g2);
return c2.compare(sg1, sg2);
}
});
}
if(skipCount<0)
else
{
skipCount = 0;
// Default is to sort by authority name,
// in lower case, so it's a case insensitive sort
Collections.sort(authList, new Comparator<String>() {
@Override
public int compare(String g1, String g2)
{
return g1.toLowerCase().compareTo( g2.toLowerCase() );
}
});
}
int endPoint = skipCount + maxItems;
if(endPoint > totalItems)
// Do the paging
List<String> paged = ModelUtil.page(authList, paging);
ScriptGroup[] groups = new ScriptGroup[paged.size()];
for (int i=0; i<groups.length; i++)
{
endPoint = totalItems;
}
int size = skipCount > endPoint ? 0 : endPoint - skipCount;
ScriptGroup[] groups = new ScriptGroup[size];
for (int i = skipCount; i < endPoint; i++)
{
String authority = authList.get(i);
ScriptGroup group = new ScriptGroup(authority, authorityService);
groups[i-skipCount] = group;
String authority = paged.get(i);
ScriptGroup group;
if (scriptGroupCache.containsKey(authority))
{
group = scriptGroupCache.get(authority);
}
else
{
group = new ScriptGroup(authority, authorityService);
}
groups[i] = group;
}
return groups;
}
}