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

InsertFeedHandler

public class InsertFeedHandler extends AbstractFeedHandler
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)

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

        super.processRequest(request, response);
        if (this.authenticated) {
            AdminService service = null;
            try {
                ServerBaseFeed feed = createFeedFromRequest(request);
                GDataAccount account = createRequestedAccount(request);

                GDataServerRegistry registry = GDataServerRegistry
                        .getRegistry();
                ServiceFactory serviceFactory = registry.lookup(
                        ServiceFactory.class, ComponentType.SERVICEFACTORY);
                if (serviceFactory == null) {
                    setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                            "required component is not available");
                    throw new FeedHandlerException(
                            "Can't save feed - ServiceFactory is null");
                }
                service = serviceFactory.getAdminService();
                service.createFeed(feed, account);
            } catch (ServiceException e) {
                setError(GDataResponse.SERVER_ERROR,
                        "can not create feed");
                LOG.error("Can not create feed -- " + e.getMessage(), e);
            } catch (FeedHandlerException e) {
                LOG.error("Can not create feed -- " + e.getMessage(), e);

            }catch (ParseException e) {
                LOG.error("Can not create feed -- " + e.getMessage(), e);
            }finally{
                if(service != null)
                    service.close();
            }

        }
        sendResponse(response);