RE: [xwiki-users] "Clone" another documents objects when creating a new document
Hello, I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe) $xwiki.copyDocument($sourceDoc, $targetDoc) Jeremie, Bousquet GSE Solution CMO Gemalto Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE Jeremie.Bousquet@gemalto.com www.gemalto.com <http://www.gemalto.com/> ________________________________ From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: vendredi 25 août 2006 12:58 To: xwiki-users@objectweb.org Subject: [xwiki-users] "Clone" another documents objects when creating a new document Hi All, Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document. Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
That seems to do it perfectly, thanks! ________________________________ From: BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com] Sent: 01 September 2006 09:45 To: xwiki-users@objectweb.org Subject: RE: [xwiki-users] "Clone" another documents objects when creating a new document Hello, I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe) $xwiki.copyDocument($sourceDoc, $targetDoc) Jeremie, Bousquet GSE Solution CMO Gemalto Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE Jeremie.Bousquet@gemalto.com www.gemalto.com <http://www.gemalto.com/> ________________________________ From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: vendredi 25 août 2006 12:58 To: xwiki-users@objectweb.org Subject: [xwiki-users] "Clone" another documents objects when creating a new document Hi All, Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document. Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
Attachments don't seem to copy with this method - I get a wrapped exception error: The size of the attachment is around 20k. Comments are fine, as are other objects (at least the one's I've tried). ________________________________ From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: 01 September 2006 10:31 To: xwiki-users@objectweb.org Subject: RE: [xwiki-users] "Clone" another documents objects when creating a new document That seems to do it perfectly, thanks! ________________________________ From: BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com] Sent: 01 September 2006 09:45 To: xwiki-users@objectweb.org Subject: RE: [xwiki-users] "Clone" another documents objects when creating a new document Hello, I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe) $xwiki.copyDocument($sourceDoc, $targetDoc) Jeremie, Bousquet GSE Solution CMO Gemalto Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE Jeremie.Bousquet@gemalto.com www.gemalto.com <http://www.gemalto.com/> ________________________________ From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: vendredi 25 août 2006 12:58 To: xwiki-users@objectweb.org Subject: [xwiki-users] "Clone" another documents objects when creating a new document Hi All, Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document. Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
Jeremie (and Ludovic): I don't know whether this has been fixed yet, but in 0.9.840 if you copy a user's profile page (the one created by XWiki.createUser()) the object copy fails silently (transaction aborted). If your code examines the copied document immediately from the same session, without clearing the cache, it looks right, but after calling $xwiki.flushCache(), or viewing the document from any other session, only an empty template shows, with no XWiki.XWikiUsers object to display and no XWiki.XWikiRights objects. The object copy fails because one of them - the XWikiRights object for XWiki.XWikiAdminGroup, which was created by XWiki.ProtectUserPage() when the user was created - contains a field "levelsye" which is not in the current schema for objects of class XWiki.XWikiRights, which names the field "levels" instead. And it also doesn't matter if the user was created by your wiki instance after installation or if it came built-in with the database installation; the default users are also corrupted this way. I must apologize: I probably should have filed a bug on this, but I didn't. It wasn't initially clear to me what the status of it was, and since the job I was trying to do was my major priority, I didn't take the time to find out. But I think it's two bugs - actually three from the standpoint of the delivered product - because the database load contains the result of one of the errors in the code: - first, the root cause: XWiki.ProtectUserPage creates an XWiki.XWikiRights object with a "groups" field with value "XWiki.XWikiAdmin", a field named "levelsye" with the value from its userRights parameter, and "allow" value of 1. This object cannot be copied to another page, because the "levelsye" field is not in the current schema for XWiki.XWikiRights. - second: the 0.9.2 database upload contains the result of this problem in all of its built-in user profile documents. I had thought that this was the source of the problem, and that all new users simply had the defective rights object copied from one of those, until I discovered the above problem. - finally, the resulting problem that I had when changing XWiki's authentication scheme, which required existing users to be renamed: When the attempt (within XWiki.copyDocument()) to add the new object to the new document fails because of the above, no error indication is given, and the document copy transaction doesn't abort, roll back or return a failure status. Moreover, the cache (at least for the current session) now holds a copy of the new document, composed as expected, so any attempt by the calling page to verify the copy without first flushing the cache seems to succeed. I think I asked whether my characterization of this problem was correct, but didn't get a response. Probably I should simply have filed it as a bug and let the developers correct me if I was wrong. To avoid a problem of this sort in the future, I think that perhaps the best protocol would be that I file it unless someone objects; that would make sure that it was accounted for. brain[sic] -----Original Message----- From: BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com] Sent: Friday, September 01, 2006 3:45 AM To: xwiki-users@objectweb.org Subject: RE: [xwiki-users] "Clone" another documents objects when creating a new document Hello, I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe) $xwiki.copyDocument($sourceDoc, $targetDoc) Jeremie, Bousquet GSE Solution CMO Gemalto Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE Jeremie.Bousquet@gemalto.com <http://www.gemalto.com/> www.gemalto.com _____ From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: vendredi 25 août 2006 12:58 To: xwiki-users@objectweb.org Subject: [xwiki-users] "Clone" another documents objects when creating a new document Hi All, Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document. Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
I slightly remember this problem. I think it is fixed in the recent version of XWiki OR it does not happen if you database was created from a recent one. Have you tried cleaning up the database from any field called "levelsye". Deleting in xwikiproperties and xwikiclassesprop should do it. What we can do is give an SQL script to clean-up the database of this problem and move to 0.9.3 db which the problem fixed. You should indeed file the bug. We should also make sure recent version of XWiki clean up this problem using updateSchema Ludovic THOMAS, BRIAN M (SBCSI) a écrit :
Jeremie (and Ludovic):
I don't know whether this has been fixed yet, but in 0.9.840 if you copy a user's profile page (the one created by XWiki.createUser()) the object copy fails silently (transaction aborted). If your code examines the copied document immediately from the same session, without clearing the cache, it looks right, but after calling $xwiki.flushCache(), or viewing the document from any other session, only an empty template shows, with no XWiki.XWikiUsers object to display and no XWiki.XWikiRights objects.
The object copy fails because one of them - the XWikiRights object for XWiki.XWikiAdminGroup, which was created by XWiki.ProtectUserPage() when the user was created - contains a field "levelsye" which is not in the current schema for objects of class XWiki.XWikiRights, which names the field "levels" instead. And it also doesn't matter if the user was created by your wiki instance after installation or if it came built-in with the database installation; the default users are also corrupted this way.
I must apologize: I probably should have filed a bug on this, but I didn't. It wasn't initially clear to me what the status of it was, and since the job I was trying to do was my major priority, I didn't take the time to find out. But I think it's two bugs - actually three from the standpoint of the delivered product - because the database load contains the result of one of the errors in the code:
- first, the root cause: XWiki.ProtectUserPage creates an XWiki.XWikiRights object with a "groups" field with value "XWiki.XWikiAdmin", a field named "levelsye" with the value from its userRights parameter, and "allow" value of 1. This object cannot be copied to another page, because the "levelsye" field is not in the current schema for XWiki.XWikiRights.
- second: the 0.9.2 database upload contains the result of this problem in all of its built-in user profile documents. I had thought that this was the source of the problem, and that all new users simply had the defective rights object copied from one of those, until I discovered the above problem.
- finally, the resulting problem that I had when changing XWiki's authentication scheme, which required existing users to be renamed: When the attempt (within XWiki.copyDocument()) to add the new object to the new document fails because of the above, no error indication is given, and the document copy transaction doesn't abort, roll back or return a failure status. Moreover, the cache (at least for the current session) now holds a copy of the new document, composed as expected, so any attempt by the calling page to verify the copy without first flushing the cache seems to succeed.
I think I asked whether my characterization of this problem was correct, but didn't get a response. Probably I should simply have filed it as a bug and let the developers correct me if I was wrong. To avoid a problem of this sort in the future, I think that perhaps the best protocol would be that I file it unless someone objects; that would make sure that it was accounted for.
brain[sic]
-----Original Message----- *From:* BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com] *Sent:* Friday, September 01, 2006 3:45 AM *To:* xwiki-users@objectweb.org *Subject:* RE: [xwiki-users] "Clone" another documents objects when creating a new document
Hello,
I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe)
$xwiki.copyDocument($sourceDoc, $targetDoc)
*Jeremie, Bousquet GSE Solution CMO Gemalto *Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE *Jeremie.Bousquet@gemalto.com* www.gemalto.com <http://www.gemalto.com/>
------------------------------------------------------------------------ *From:* Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] *Sent:* vendredi 25 août 2006 12:58 *To:* xwiki-users@objectweb.org *Subject:* [xwiki-users] "Clone" another documents objects when creating a new document
Hi All,
Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document.
/Brandon Esbach/ /Software Engineer/ /M/A-Com Eurotec Operations/ /LoughMahon Technology Park,/ /Skehard Road,/ /Blackrock,/ /Cork, Ireland/ /Tel +353 21 4808305/
------------------------------------------------------------------------
-- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost XPertNet: http://www.xpertnet.fr/ Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost AIM: nvludo Yahoo: ludovic
Ludovic: Very good, thank you. I will file the bug[s]. I was a little reluctant to do this, because I wasn't sure it really was a bug, but I think I understand now that even if it wasn't, bug reports that turn out to be mistaken aren't as bad as those that don't get filed. At minimum, they are formally tracked and answered, whereas the mailing list is not, though by your high level of participation you and Jérémi may have set unrealistic expectations. I do not want to suggest that you stop being helpful in the mailing list for that reason(please!) but perhaps an effort to clarify this might forestall some of the frustrated complaints that we see here. For example, it would help me - and probably others - more confidently to offer this advice to anyone so that you wouldn't have to, if you were merely to confirm my above-stated understanding of the situation. And for completeness regarding this particular problem, I will note that in 0.9.840, XWiki.ProtectUserPage(), which is called from com.xpn.xwiki.XWiki.createUser(), still creates a "levelsye" field at line 1827 of XWiki.java in package com.xpn.xwiki, so to be fully rid of this problem you must either change this line from newrightsobject.setStringValue("levelsye", userRights); to newrightsobject.setStringValue("levels", userRights); and recompile/redeploy, or re-run your offered database script after adding a new user. This code appears to be the ultimate source of the problem, and will appear in my JIRA filing. Again, thank you for continued conscientious support of a well-crafted product. brain[sic]
-----Original Message----- From: Ludovic Dubost [mailto:ludovic@xwiki.com] Sent: Monday, September 04, 2006 4:11 AM To: xwiki-users@objectweb.org Subject: Re: [xwiki-users] "Clone" another documents objects when creating a new document
I slightly remember this problem. I think it is fixed in the recent version of XWiki OR it does not happen if you database was created from a recent one. Have you tried cleaning up the database from any field called "levelsye". Deleting in xwikiproperties and xwikiclassesprop should do it.
What we can do is give an SQL script to clean-up the database of this problem and move to 0.9.3 db which the problem fixed. You should indeed file the bug.
We should also make sure recent version of XWiki clean up this problem using updateSchema
Ludovic
THOMAS, BRIAN M (SBCSI) a écrit :
Jeremie (and Ludovic):
I don't know whether this has been fixed yet, but in 0.9.840 if you copy a user's profile page (the one created by XWiki.createUser()) the object copy fails silently (transaction aborted). If your code examines the copied document immediately from the same session, without clearing the cache, it looks right, but after calling $xwiki.flushCache(), or viewing the document from any other session, only an empty template shows, with no XWiki.XWikiUsers object to display and no XWiki.XWikiRights objects.
The object copy fails because one of them - the XWikiRights object for XWiki.XWikiAdminGroup, which was created by XWiki.ProtectUserPage() when the user was created - contains a field "levelsye" which is not in the current schema for objects of class XWiki.XWikiRights, which names the field "levels" instead. And it also doesn't matter if the user was created by your wiki instance after installation or if it came built-in with the database installation; the default users are also corrupted this way.
I must apologize: I probably should have filed a bug on this, but I didn't. It wasn't initially clear to me what the status of it was, and since the job I was trying to do was my major priority, I didn't take the time to find out. But I think it's two bugs - actually three from the standpoint of the delivered product - because the database load contains the result of one of the errors in the code:
- first, the root cause: XWiki.ProtectUserPage creates an XWiki.XWikiRights object with a "groups" field with value "XWiki.XWikiAdmin", a field named "levelsye" with the value from its userRights parameter, and "allow" value of 1. This object cannot be copied to another page, because the "levelsye" field is not in the current schema for XWiki.XWikiRights.
- second: the 0.9.2 database upload contains the result of this problem in all of its built-in user profile documents. I had thought that this was the source of the problem, and that all new users simply had the defective rights object copied from one of those, until I discovered the above problem.
- finally, the resulting problem that I had when changing XWiki's authentication scheme, which required existing users to be renamed: When the attempt (within XWiki.copyDocument()) to add the new object to the new document fails because of the above, no error indication is given, and the document copy transaction doesn't abort, roll back or return a failure status. Moreover, the cache (at least for the current session) now holds a copy of the new document, composed as expected, so any attempt by the calling page to verify the copy without first flushing the cache seems to succeed.
I think I asked whether my characterization of this problem was correct, but didn't get a response. Probably I should simply have filed it as a bug and let the developers correct me if I was wrong. To avoid a problem of this sort in the future, I think that perhaps the best protocol would be that I file it unless someone objects; that would make sure that it was accounted for.
brain[sic]
-----Original Message----- *From:* BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com] *Sent:* Friday, September 01, 2006 3:45 AM *To:* xwiki-users@objectweb.org *Subject:* RE: [xwiki-users] "Clone" another documents objects when creating a new document
Hello,
I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe)
$xwiki.copyDocument($sourceDoc, $targetDoc)
*Jeremie, Bousquet GSE Solution CMO Gemalto *Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE *Jeremie.Bousquet@gemalto.com* www.gemalto.com <http://www.gemalto.com/>
-------------------------------------------------------------- ----------
*From:* Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] *Sent:* vendredi 25 août 2006 12:58 *To:* xwiki-users@objectweb.org *Subject:* [xwiki-users] "Clone" another documents objects when creating a new document
Hi All,
Is there any way to clone all objects in an
existing document
to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document.
/Brandon Esbach/ /Software Engineer/ /M/A-Com Eurotec Operations/ /LoughMahon Technology Park,/ /Skehard Road,/ /Blackrock,/ /Cork, Ireland/ /Tel +353 21 4808305/
----------------------------------------------------------------------
--
-- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost XPertNet: http://www.xpertnet.fr/ Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost AIM: nvludo Yahoo: ludovic
participants (4)
-
BOUSQUET Jeremie -
Esbach, Brandon -
Ludovic Dubost -
THOMAS, BRIAN M (SBCSI)