On Wed, May 30, 2012 at 4:46 PM, Jeremie BOUSQUET
<jeremie.bousquet(a)gmail.com> wrote:
Hello,
I'm wondering if I'm on the good path ...
I'm trying to move out some "old core" api usage, and replace them
using the DocumentAccessBridge (3.5.1), in a java component.
Considering a very simple use-case : setting property value of an
object. Here the document containing object is not in same space as
the class.
1- With old core:
XWikiDocument doc = context.getWiki().getDocument("Prefs.Document", context);
BaseObject obj = serverDoc.getObject("Code.Class");
obj.set("property", value, context);
2- With DAB, using deprecated method:
dab.setProperty("Prefs.Document", "Code.Class", "property",
value);
3- With DAB, using non-deprecated methods:
SpaceReference prefsSpaceRef = new SpaceReference(new
EntityReference("Prefs", EntityType.SPACE));
DocumentReference prefsDocRef = new DocumentReference("Document",
prefsSpaceRef);
SpaceReference codeSpaceRef = new SpaceReference(new
EntityReference("Code", EntityType.SPACE));
DocumentReference classDocRef = new DocumentReference("Class",
codeSpaceRef);
dab.setProperty(prefsDocRef, classDocRef, "property", value);
Questions:
a- the code with 3- is, IMO, quite verbose compared to the others. Is
it really the best way to do this ? Of course I could store the
SpaceReference objects to factorize their use and simplify the code.
I'd better be sure before recoding all this ...
b- what's the best practice, for a component, to properly manage the
targeted wiki, in order to be single/multi-wiki/workspaces proof ?
Here I didn't bother specifying the targeted wiki, if I do it will add
more "*Reference" creations.
c- is there any facility method to convert an oldish xwiki document
reference (as "wiki:Space.Page" or "Space.Page") to a
DocumentReference ?
By the way, is the bridge API representative of the future new xwiki
data model that will replace old core, or is it only representative of
the current bridge api ?
The bridge is just temporary and crappy API allowing to not
technically trigger a dependency on oldcore module and nothing more,
if you have to depend on oldcore for other reason you'd better
directly use old APis IMO. The new model will look nothing like that
hopefully.
Thanks,
Jeremie
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne