Hi everyone,

I'm using Restlet 2.0.14 JEE. My question is about good practices and a good 
understanding of Restlet.

In my resources, which extends ServerResource, I usually check my parameters to 
verify users input. My idea is to send back a status code immediately (401 
unauthorized, 403 bad request etc.) if some parameters are incorrect. My aim is 
too abort immediately the request and send back the status code.

To do so, I'm code such like :

[CODE]

if(myUsernameParam != null){
/*
* Parameter found, do stuff like
* isUserAuthorized = checkUser(myUsernameParam);
*/
}
else{
    // Stop everything
    logger.fatal("Parameter not found");
    this.setStatus(Status.CLIENT_BAD_REQUEST, "Parameter not found");
    this.abort();
}

// We continue our process in the resource

if(isUserAuthorized){
/*
* Do stuff
*/
}
else{
    // Stop everything
    logger.fatal("Client unauthorized");
    this.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED, "Client unauthorized");
    this.abort();
}
[/CODE]

However, I'm not sure that this.abort() is really doing his job and send back 
response like a 'return' statement.

Or are there other good pratices to do what I do ?

Thanks :)

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2985719

Reply via email to