001/** 002 * Copyright 2015 DuraSpace, Inc. 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 */ 016package org.fcrepo.http.api.repository; 017 018import static javax.ws.rs.core.MediaType.APPLICATION_XHTML_XML; 019import static javax.ws.rs.core.MediaType.APPLICATION_XML; 020import static javax.ws.rs.core.MediaType.TEXT_HTML; 021import static javax.ws.rs.core.MediaType.TEXT_PLAIN; 022import static org.fcrepo.http.commons.domain.RDFMediaType.JSON_LD; 023import static org.fcrepo.http.commons.domain.RDFMediaType.N3; 024import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2; 025import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES; 026import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML; 027import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE; 028import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE_X; 029 030import javax.inject.Inject; 031import javax.jcr.Session; 032import javax.ws.rs.GET; 033import javax.ws.rs.Path; 034import javax.ws.rs.Produces; 035 036import org.fcrepo.http.commons.AbstractResource; 037import org.fcrepo.http.commons.responses.HtmlTemplate; 038import org.fcrepo.kernel.api.utils.iterators.RdfStream; 039import org.springframework.context.annotation.Scope; 040 041import com.codahale.metrics.annotation.Timed; 042 043/** 044 * Expose node types at a REST endpoint 045 * @author cbeer 046 */ 047@Scope("prototype") 048@Path("/fcr:nodetypes") 049public class FedoraRepositoryNodeTypes extends AbstractResource { 050 051 @Inject 052 protected Session session; 053 054 /** 055 * Retrieve all node types as RDF 056 * @return All node types as RDF 057 */ 058 @GET 059 @Produces({TURTLE, N3, N3_ALT2, RDF_XML, NTRIPLES, APPLICATION_XML, TEXT_PLAIN, TURTLE_X, 060 TEXT_HTML, APPLICATION_XHTML_XML, JSON_LD}) 061 @Timed 062 @HtmlTemplate("jcr:nodetypes") 063 public RdfStream getNodeTypes() { 064 return nodeService.getNodeTypes(session).session(session); 065 } 066 067}