Methods Summary |
---|
protected org.apache.lucene.gdata.data.GDataAccount | getAccountFromRequest(javax.servlet.http.HttpServletRequest request)
try {
GDataAccount account = AccountBuilder.buildAccount(request
.getReader());
if (account == null) {
setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "");
throw new AccountHandlerException(
"unexpected value -- parsed account is null");
}
return account;
} catch (IOException e) {
setError(HttpServletResponse.SC_BAD_REQUEST, "can not read input");
throw new AccountHandlerException("Can't read from request reader",
e);
} catch (SAXException e) {
setError(HttpServletResponse.SC_BAD_REQUEST,
"can not parse gdata account");
throw new AccountHandlerException(
"Can not parse incoming gdata account", e);
}
|
protected int | getErrorCode()
return this.error;
|
protected java.lang.String | getErrorMessage()
return this.errorMessage;
|
public void | processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
try{
this.authenticated = authenticateAccount(request,
AccountRole.USERADMINISTRATOR);
if (this.authenticated) {
GDataServerRegistry registry = GDataServerRegistry.getRegistry();
ServiceFactory factory = registry.lookup(ServiceFactory.class,
ComponentType.SERVICEFACTORY);
try {
GDataAccount account = getAccountFromRequest(request);
if (!account.requiredValuesSet()) {
setError(GDataResponse.SERVER_ERROR,
"Required server component not available");
throw new AccountHandlerException(
"Required values are not set -- account can not be saved -- "
+ account);
}
this.service = factory.getAdminService();
processServiceAction(account);
} catch (ServiceException e) {
LOG.error("Can't process account action -- " + e.getMessage(),
e);
setError(e.getErrorCode(), "");
}
catch (AccountHandlerException e) {
LOG.error("Can't process account action -- " + e.getMessage(),
e);
}
}else{
setError(GDataResponse.UNAUTHORIZED,"Authorization failed");
}
sendResponse(response);
}finally{
if(this.service!=null)
this.service.close();
}
|
protected abstract void | processServiceAction(org.apache.lucene.gdata.data.GDataAccount account)
|
protected void | sendResponse(javax.servlet.http.HttpServletResponse response)
if (!this.isError)
return;
try {
response.sendError(this.error, this.errorMessage);
} catch (IOException e) {
LOG.warn("can send error in RequestHandler ", e);
}
|
protected void | setError(int error, java.lang.String message)
this.error = error;
this.errorMessage = message;
this.isError = true;
|