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 javax.ws.rs.core.Response.ok;
023import static org.fcrepo.http.commons.domain.RDFMediaType.JSON_LD;
024import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
025import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
026import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES;
027import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
028import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
029import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE_X;
030import static org.fcrepo.kernel.modeshape.utils.NamespaceTools.getNamespaces;
031
032import javax.inject.Inject;
033import javax.jcr.Session;
034import javax.ws.rs.GET;
035import javax.ws.rs.Path;
036import javax.ws.rs.Produces;
037import javax.ws.rs.core.Response;
038
039import org.fcrepo.http.commons.AbstractResource;
040import org.fcrepo.http.commons.responses.HtmlTemplate;
041import org.fcrepo.http.commons.responses.RdfNamespacedStream;
042import org.springframework.context.annotation.Scope;
043
044import com.codahale.metrics.annotation.Timed;
045
046/**
047 * Expose node types at a REST endpoint
048 * @author cbeer
049 */
050@Scope("prototype")
051@Path("/fcr:nodetypes")
052@Deprecated
053public class FedoraRepositoryNodeTypes extends AbstractResource {
054
055    @Inject
056    protected Session session;
057
058    /**
059     * Retrieve all node types as RDF
060     * @return All node types as RDF
061     */
062    @GET
063    @Produces({TURTLE, N3, N3_ALT2, RDF_XML, NTRIPLES, APPLICATION_XML, TEXT_PLAIN, TURTLE_X,
064                      TEXT_HTML, APPLICATION_XHTML_XML, JSON_LD})
065    @Timed
066    @HtmlTemplate("jcr:nodetypes")
067    public Response getNodeTypes() {
068        return ok(new RdfNamespacedStream(
069                      nodeService.getNodeTypes(session),
070                      getNamespaces(session)))
071            .header("Warning", "This endpoint is deprecated and will be removed in the 4.6.0 release.").build();
072    }
073
074}