001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Thierry Delprat
018 */
019package org.nuxeo.template.jaxrs;
020
021import java.util.List;
022
023import org.apache.commons.logging.Log;
024import org.apache.commons.logging.LogFactory;
025import org.nuxeo.ecm.core.api.CoreSession;
026import org.nuxeo.ecm.webengine.model.impl.DefaultObject;
027import org.nuxeo.runtime.api.Framework;
028import org.nuxeo.template.api.TemplateProcessorService;
029import org.nuxeo.template.api.adapters.TemplateSourceDocument;
030
031/**
032 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
033 */
034public abstract class AbstractResourceService extends DefaultObject {
035
036    protected static Log log = LogFactory.getLog(AbstractResourceService.class);
037
038    protected CoreSession session;
039
040    public AbstractResourceService(CoreSession session) {
041        this.session = session;
042    }
043
044    protected CoreSession getCoreSession() {
045        return session;
046    }
047
048    protected List<TemplateSourceDocument> getTemplates() {
049        CoreSession session = getCoreSession();
050        TemplateProcessorService tps = Framework.getLocalService(TemplateProcessorService.class);
051        return tps.getAvailableTemplates(session, null);
052    }
053
054}