FileDocCategorySizeDatePackage
DefaultInsertHandler.javaAPI DocApache Lucene 2.1.03570Wed Feb 14 10:46:04 GMT 2007org.apache.lucene.gdata.servlet.handler

DefaultInsertHandler

public class DefaultInsertHandler extends AbstractGdataRequestHandler
Default Handler implementation. This handler processes the incoming {@link org.apache.lucene.gdata.server.GDataRequest} and inserts the requested feed entry into the storage and the search component.

The handler sends following response to the client:

  1. if the entry was added - HTTP status code 200 OK
  2. if an error occurs - HTTP status code 500 INTERNAL SERVER ERROR
  3. if the resource could not found - HTTP status code 404 NOT FOUND

The added entry will be send back to the client if the insert request was successful.

author
Simon Willnauer

Fields Summary
private static final Log
LOG
Constructors Summary
Methods Summary
public voidprocessRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

throws
ServletException
see
org.apache.lucene.gdata.servlet.handler.GDataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

               
    
	   
                 
        try {
            initializeRequestHandler(request,response,GDataRequestType.INSERT);            
        } catch (GDataRequestException e) {
            sendError();
            return;
        }
        if(!authenticateAccount(this.feedRequest,AccountRole.ENTRYAMINISTRATOR)){
            setError(GDataResponse.UNAUTHORIZED);
            sendError();
            return;
        }
       
        try{        
        BaseEntry entry = this.service.createEntry(this.feedRequest,this.feedResponse);
        setFeedResponseFormat();
        setFeedResponseStatus(GDataResponse.CREATED);        
        this.feedResponse.sendResponse(entry, this.feedRequest.getConfigurator());
        
        }catch (ServiceException e) {
           LOG.error("Could not process GetFeed request - "+e.getMessage(),e);
           setError(e.getErrorCode());
           sendError();
        }finally{
        closeService();
        }