001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * tdelprat 016 */ 017 018package org.nuxeo.ecm.restapi.server.jaxrs.config.types; 019 020import javax.ws.rs.GET; 021import javax.ws.rs.Path; 022import javax.ws.rs.PathParam; 023 024import org.nuxeo.ecm.core.schema.DocumentType; 025import org.nuxeo.ecm.core.schema.SchemaManager; 026import org.nuxeo.ecm.restapi.jaxrs.io.types.DocumentTypes; 027import org.nuxeo.ecm.webengine.model.WebObject; 028import org.nuxeo.ecm.webengine.model.impl.DefaultObject; 029import org.nuxeo.runtime.api.Framework; 030 031@WebObject(type = "docType") 032public class DocTypeEndPoint extends DefaultObject { 033 034 @GET 035 public DocumentTypes getAll() { 036 SchemaManager sm = Framework.getLocalService(SchemaManager.class); 037 return new DocumentTypes(sm.getDocumentTypes()); 038 } 039 040 @GET 041 @Path("{name}") 042 public DocumentType getDocType(@PathParam("name") String name) { 043 SchemaManager sm = Framework.getLocalService(SchemaManager.class); 044 DocumentType docType = sm.getDocumentType(name); 045 return docType; 046 } 047}