package org.intermine.webservice.server.lists;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.intermine.api.InterMineAPI;
import org.intermine.web.context.InterMineContext;

public class AvailableListsServlet extends HttpServlet
{
    /**
     * Serialisation constant.
     */
    private static final long serialVersionUID = 1L;

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        getAvailableLists(request, response);
    }

    private void getAvailableLists(HttpServletRequest request, HttpServletResponse response) {
        final InterMineAPI im = InterMineContext.getInterMineAPI();
        new AvailableListsService(im).service(request, response);
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        saveUploadedList(request, response);
    }

    private void saveUploadedList(HttpServletRequest request, HttpServletResponse response) {
        final InterMineAPI im = InterMineContext.getInterMineAPI();
        new ListUploadService(im).service(request, response);
    }

    @Override
    public void doDelete(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        deleteList(request, response);
    }

    private void deleteList(HttpServletRequest request, HttpServletResponse response) {
        final InterMineAPI im = InterMineContext.getInterMineAPI();
        new ListDeletionService(im).service(request, response);
    }

}

package org.intermine.webservice.server.lists;

import org.intermine.webservice.server.WebService;
import org.intermine.webservice.server.core.NoServiceException;
import org.intermine.webservice.server.core.WebServiceServlet;

public class AvailableListsServlet extends WebServiceServlet
{
    private static final long serialVersionUID = 1L;

    @Override
    protected WebService getService(Method method) throws NoServiceException {
        switch (method) {
        case GET:
            return new AvailableListsService(api);
        case POST:
            return new ListUploadService(api);
        case DELETE:
            return new ListDeletionService(api);
        default:
            throw new NoServiceException();
        }
    }

}

Use the new WebServiceServlet framework
Use the new WebServiceServlet framework


Former-commit-id: 07bac49517b1151a281de191cd9e80c229196181