thanks, the first and second examples works fine.
For now my workaround is to hard code authentication into the source code of the second example (RandomSelectWebScript.java).
the modifs are:
private TransactionService transactionService;
private Logger logger = Logger.getLogger(RandomSelectWebScript.class);
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException
{
boolean switchUser = false;
String currentUser = AuthenticationUtil.getCurrentUserName();
if (!currentUser.equals("admin")) {
//logger.debug("Current user is not admin so switching to admin");
AuthenticationUtil.setCurrentUser("admin");
switchUser = true;
}
UserTransaction txn = transactionService.getUserTransaction();
try {
txn.begin();
// get the referenced incoming node
NodeRef rootNodeRef = getNodeRef(req);
// draw a random child
NodeRef childNodeRef = randomChild(rootNodeRef);
// stream child back
output(res, childNodeRef);
} catch(Throwable e) {
try {
if (txn.getStatus() == Status.STATUS_ACTIVE) txn.rollback();
} catch (Throwable ee) {
e.printStackTrace();
}
}
if (switchUser) AuthenticationUtil.setCurrentUser(currentUser);
}
I changed also the description of the WS to :
<webscript>
<shortname>Streams a random content item</shortname>
<description>Streams a random content item</description>
<url>/demo/random?path={path}</url>
<authentication>guest</authentication>
<transaction>none</transaction>
<format default="">argument</format>
</webscript>
But it doesn't work ?!
Thanks in advance,
Tegel