Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-16104

Scripting API for object of class XWikiGlobalRights doesn't get the full value of the "groups" property

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Critical
    • None
    • 9.10.1
    • Scripting
    • None
    • Docker, Debian, PostgreSQL
    • Unknown

    Description

      For the object of the classe "XWikiGlobalRights" the scripting API doesn't return the full name of the group if it is a group from global scope.
      For example the API return the value "XWikiAllGroup" but the returned value should be "xwiki:XWiki.XWikiAllGroup" for a global group and "XWiki.XWikiAllGroup" for a local group.
      If I create a new object of the class "XWikiGlobalRights" and I set property "groups" with "xwiki:XWiki.MyGroup" it will create affect the correct global group named "MyGroup".

      Groovy script :

      import com.xpn.xwiki.api.XWiki;
      import ch.qos.logback.classic.Logger;
      import ch.qos.logback.classic.Level;
      import org.xwiki.model.reference.DocumentReference;
      import com.xpn.xwiki.api.Document;
      import com.xpn.xwiki.XWikiException;
      
      def classeXWikiGlobalRights = xwiki.getClass("XWiki.XWikiGlobalRights");
      
      List<String> listeDesWikis;
      
      String txt;
      
      listeDesWikis = xwiki.getWikiNames();
      
      println "List of wikis :"
      for (currentWikiName in listeDesWikis) {
      	println "* ${currentWikiName}";
      	}
      
      for (currentWikiName in listeDesWikis) {
      	println "=Wiki '${currentWikiName}'=";
      	
      	DocumentReference documentReference = new DocumentReference(currentWikiName, ["XWiki"], "XWikiPreferences");
      	try {
      		Document currentWikiDocument = xwiki.getDocument(documentReference);
      		Vector<Object> vectorObject;
      	    vectorObject = currentWikiDocument.getObjects("XWiki.XWikiGlobalRights");
      	    println txt;
      
      		String ligneTitre1, ligneTitre2;
      		ligneTitre1 = "|#";
      		
      		for (prop in classeXWikiGlobalRights.properties){
      			ligneTitre1 =  ligneTitre1 + "|${prop.prettyName}\n(${prop.name})";
      		}
      		
      		println ligneTitre1;
      		
      		int occurence = 0;
      
      		for (currentObject in vectorObject) {
      			String ligne = "|" + occurence;
      			Boolean found = false;
      			
      			for  (prop in classeXWikiGlobalRights.properties){
      				ligne = ligne +  "|" + currentObject.get(prop.name).toString();
      			}
      			println ligne;
      			occurence = occurence + 1;
      		}
      	} catch (XWikiException e){
      		println "Document 'XWikiPreferences' not found for wiki '${currentWikiName}'.";	      
      		println "Exception lors de l'appel de getDocument() : ${e}";
      	}
      }
      

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            Camille_D Camille Desmots
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: