- 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
>>
>>
> 

_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to