001package org.nuxeo.template.xdocreport.jaxrs;
002
003import javax.ws.rs.GET;
004import javax.ws.rs.Path;
005
006import org.nuxeo.ecm.core.api.CoreSession;
007import org.nuxeo.ecm.webengine.model.WebObject;
008import org.nuxeo.ecm.webengine.model.impl.ModuleRoot;
009import org.nuxeo.runtime.transaction.TransactionHelper;
010
011/**
012 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
013 */
014@WebObject(type = "xdocRestRoot")
015@Path("/xdoctemplates")
016public class RootResource extends ModuleRoot {
017
018    @GET
019    public String index() {
020        String sid = getContext().getCoreSession().getSessionId();
021        return "ok :sid =" + sid;
022    }
023
024    protected CoreSession getCoreSession() {
025        TransactionHelper.startTransaction();
026
027        return getContext().getCoreSession();
028    }
029
030    @GET
031    @Path("ping")
032    public String getPong() {
033        return "pong";
034    }
035
036    @Path("resources")
037    public ResourceService getResourceService() {
038        return new ResourceService(getContext().getCoreSession());
039    }
040
041    @Path("xdocresources")
042    public XDocReportResourceService getXDocResourceService() {
043        return new XDocReportResourceService(getContext().getCoreSession());
044    }
045
046    @Path("reports")
047    public ReportService getReportService() {
048        return new ReportService();
049    }
050
051}