You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Marc Sommer <ma...@schlund.de> on 2003/05/22 16:52:24 UTC
creating GroupNodes and LinkNodes
hi NG,
i need help to create GroupNodes and LinkNodes with the low-level-api of
slide...
<objectnode classname="org.apache.slide.structure.GroupNode"
uri="/users/testgroup">
<objectnode classname="org.apache.slide.structure.LinkNode"
uri="/users/testgroup/testuser" linkedUri="/users/testuser"/>
</objectnode>
could anybody post a snippet which shows that, including the usage of
the NamespaceAccessToken and SecurityToken?
thanks in advance
marc
--
Marc Sommer
Interne Applikationen
+49 721 91374-364
PGP Key-ID: 0743ED19
Schlund + Partner AG
http://www.schlund.de
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
AW: creating GroupNodes and LinkNodes
Posted by Michael Plomer <m_...@gmx.net>.
Hi Marc,
first, you'll need to obtain a NamespaceAccessToken:
// prepare the namespace access token (assuming you want the
default namespace)
String namespace = Domain.getDefaultNamespace();
NamespaceAccessToken nat = Domain.accessNamespace(new
SecurityToken(this), namespace);
// "this" is a HttpServlet in my case, but could be almost
anything (or so I think...)
Next, you need a SlideToken, which you could construct, for instance,
>from the
credentials in your servlets request (that is, assuming you are writing
a servlet...).
// prepare the slide token
Principal principal = request.getUserPrincipal();
CredentialsToken credentials;
if (principal == null)
credentials = new CredentialsToken("");
else
credentials = new CredentialsToken(principal);
SlideToken st = new SlideTokenImpl(credentials);
Creating a group node is pretty straightforward, most of the code deals
with exception handling:
// prepare the structure helper
Structure structureHelper = nat.getStructureHelper();
try {
try {
// start namespace tansaction
nat.begin();
// create the node in the structure
ObjectNode object = new GroupNode();
structureHelper.create(st, object,
"/users/testgroup");
// commit the transaction
nat.commit();
} catch (AccessDeniedException ex) {
... // handle exception
throw ex;
} catch (ObjectAlreadyExistsException ex) {
... // handle exception
throw ex;
} catch (Exception ex) {
... // handle exception
throw ex;
}
// ... SUCCESS ...
} catch (Exception ex) {
try {
nat.rollback();
} catch (SystemException sysex) { // catch silently }
}
Linking users into the group should be done like this:
// prepare the structure helper
Structure structureHelper = nat.getStructureHelper();
try {
try {
// start namespace tansaction
nat.begin();
// retrieve the node to be linked
ObjectNode object = structureHelper.retrieve(st,
"/users/testuser");
// create the link node
structureHelper.createLink(st, new LinkNode(),
"/users/testgroup/testuser", object);
// commit the transaction
nat.commit();
} catch (AccessDeniedException ex) {
... // handle exception
throw ex;
} catch (ObjectAlreadyExistsException ex) {
... // handle exception
throw ex;
} catch (Exception ex) {
... // handle exception
throw ex;
}
// ... SUCCESS ...
} catch (Exception ex) {
try {
nat.rollback();
} catch (SystemException sysex) { // catch silently }
}
Hope this helps. Keep in mind that while this code is from a servlet
I wrote and actually works, I might have edited in some errors when
writing this mail...
Regards,
Michael
-------/ Michael Plomer /--/ stud. Hilfskraft CONCERT /----
------/ Fraunhofer IPSI /--/ Kooperationskomponenten /-----
-----/ Darmstadt/Germany /--/ eMail: plomer@ipsi.fhg.de /------
----/ 0173 / 5 33 66 23 /--/ m_plomer@gmx.net /-------
>>-----Ursprüngliche Nachricht-----
>>Von: Marc Sommer [mailto:marc.sommer@schlund.de]
>>Gesendet: Donnerstag, 22. Mai 2003 16:52
>>An: Slide Users Mailing List
>>Betreff: creating GroupNodes and LinkNodes
>>
>>
>>hi NG,
>>
>>i need help to create GroupNodes and LinkNodes with the
>>low-level-api of
>>slide...
>>
>><objectnode classname="org.apache.slide.structure.GroupNode"
>>uri="/users/testgroup">
>><objectnode classname="org.apache.slide.structure.LinkNode"
>>uri="/users/testgroup/testuser" linkedUri="/users/testuser"/>
>></objectnode>
>>
>>could anybody post a snippet which shows that, including the usage of
>>the NamespaceAccessToken and SecurityToken?
>>
>>thanks in advance
>>marc
>>
>>
>>--
>>
>>Marc Sommer
>>Interne Applikationen
>>+49 721 91374-364
>>PGP Key-ID: 0743ED19
>>Schlund + Partner AG
>>http://www.schlund.de
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: slide-user-help@jakarta.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org