[xwiki-users] copy the rigths
How can I copy automatically the rights, set on a page, to another page? Thanks raffo
How can I copy automatically the rights, set on a page, to another page?
something like #set($sourceDoc=$xwiki.getDocument("YourSpace.YourSourceDoc")) #set($targetDoc=$xwiki.getDocument("YourSpace.YourTargetDoc")) #foreach($right in $sourceDoc.getObjects("XWiki.XWikiRights")) #set($entry=$targetDoc.newObject("XWiki.XWikiRights")) $entry.set("groups",$right.get("groups")) $entry.set("userss",$right.get("users")) $entry.set("levels",$right.get("level")) $entry.set("allow",$right.get("allow")) #end ## Here same loop replacing XWiki.XWikiRights by XWiki.XWikiGlobalRights $targetDoc.save() (not tested) Regards, Jerome.
Thanks raffo _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi, the code: Jerome Velociter-2 wrote:
$entry.set("allow",$right.get("allow"))
throws this Exception: java.lang.NumberFormatException: For input string: "Deny"---java.lang.NumberFormatException.forInputString(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.parseInt(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.<init>(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.classes.BooleanClass.fromString(BooleanClass.java:98) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.BaseObject.set(BaseObject.java:204) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.api.Object.set(Object.java:82) $right.get("allow") returns "Deny" and not a number as requested from the method fromString(String value) BooleanClass.java row 98 Can someone help me Raffo -- View this message in context: http://www.nabble.com/copy-the-rigths-tp15003379p15185130.html Sent from the XWiki- Users mailing list archive at Nabble.com.
raffovi wrote:
Hi,
the code:
Jerome Velociter-2 wrote:
$entry.set("allow",$right.get("allow"))
throws this Exception:
java.lang.NumberFormatException: For input string: "Deny"---java.lang.NumberFormatException.forInputString(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.parseInt(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.<init>(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.classes.BooleanClass.fromString(BooleanClass.java:98) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.BaseObject.set(BaseObject.java:204) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.api.Object.set(Object.java:82)
$right.get("allow") returns "Deny" and not a number as requested from the method fromString(String value) BooleanClass.java row 98
Can someone help me Raffo
Try: $right.getProperty("allow").value Sergiu
Thanks a lot, the previous problem is solved but the code that I use to copy the page's rights on another page seems doesn't work. Vector right = doc.getObjects("XWiki.XWikiRights"); for (Object singleObj : right) { Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("groups").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("users").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("level").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("allow").getValue()); } targetDoc.save(); What I do wrong?ù Regards Raffo Sergiu Dumitriu-2 wrote:
raffovi wrote:
Hi,
the code:
Jerome Velociter-2 wrote:
$entry.set("allow",$right.get("allow"))
throws this Exception:
java.lang.NumberFormatException: For input string: "Deny"---java.lang.NumberFormatException.forInputString(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.parseInt(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.<init>(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.classes.BooleanClass.fromString(BooleanClass.java:98) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.BaseObject.set(BaseObject.java:204) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.api.Object.set(Object.java:82)
$right.get("allow") returns "Deny" and not a number as requested from the method fromString(String value) BooleanClass.java row 98
Can someone help me Raffo
Try:
$right.getProperty("allow").value
Sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://www.nabble.com/copy-the-rigths-tp15003379p15201209.html Sent from the XWiki- Users mailing list archive at Nabble.com.
- Don't create the entry Object after each line; you create 4 objects instead of 1 - Don't put all the values in the "groups" property Vector right = doc.getObjects("XWiki.XWikiRights"); for (Object singleObj : right) { Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("groups").getValue()); entry.set("users",singleObj.getProperty("users").getValue()); entry.set("level",singleObj.getProperty("level").getValue()); entry.set("allow",singleObj.getProperty("allow").getValue()); } targetDoc.save(); raffovi wrote:
Thanks a lot,
the previous problem is solved but the code that I use to copy the page's rights on another page seems doesn't work.
Vector right = doc.getObjects("XWiki.XWikiRights"); for (Object singleObj : right) { Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("groups").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("users").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("level").getValue()); Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("allow").getValue()); } targetDoc.save();
What I do wrong?ù
Regards Raffo
Sergiu Dumitriu-2 wrote:
raffovi wrote:
Hi,
the code:
Jerome Velociter-2 wrote:
$entry.set("allow",$right.get("allow"))
throws this Exception:
java.lang.NumberFormatException: For input string: "Deny"---java.lang.NumberFormatException.forInputString(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.parseInt(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---java.lang.Integer.<init>(Unknown Source) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.classes.BooleanClass.fromString(BooleanClass.java:98) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.objects.BaseObject.set(BaseObject.java:204) java.lang.NumberFormatException: For input string: "Deny"---com.xpn.xwiki.api.Object.set(Object.java:82)
$right.get("allow") returns "Deny" and not a number as requested from the method fromString(String value) BooleanClass.java row 98
Can someone help me Raffo Try:
$right.getProperty("allow").value
Sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Sorry I make a mistake writing the mail the used code is: Vector XWikiRights = doc.getObjects("XWiki.XWikiRights"); for (Object singleObj : XWikiRights) { Object entry = targetDoc.newObject("XWiki.XWikiRights"); entry.set("groups",singleObj.getProperty("groups").getValue()); entry.set("users",singleObj.getProperty("users").getValue()); entry.set("level",singleObj.getProperty("level").getValue()); entry.set("allow",singleObj.getProperty("allow").getValue()); } targetDoc.save(); I try to use something like targetDoc.set("groups", singleObj.getProperty("groups").getValue()); withteh same result ... the rights on targetDoc aren't set. Thanks a lot Raffo -- View this message in context: http://www.nabble.com/copy-the-rigths-tp15003379p15213355.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (4)
-
Jerome Velociter -
Raffaele Viola -
raffovi -
Sergiu Dumitriu