source: VirtualCollectionRegistry/branches/VirtualCollectionRegistry-1.0-beta/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/rest/BaseResource.java @ 5596

Last change on this file since 5596 was 5596, checked in by Twan Goosen, 10 years ago

created a branch for VCR 1.0-beta. Trunk now 1.1-SNAPSHOT

File size: 1.9 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.virtualcollectionregistry.rest;
18
19import java.io.IOException;
20import java.io.InputStream;
21import java.io.OutputStream;
22import javax.ws.rs.GET;
23import javax.ws.rs.Path;
24import javax.ws.rs.Produces;
25import javax.ws.rs.WebApplicationException;
26import javax.ws.rs.core.MediaType;
27import javax.ws.rs.core.Response;
28import javax.ws.rs.core.StreamingOutput;
29import org.apache.wicket.util.io.IOUtils;
30
31/**
32 *
33 * @author twagoo
34 */
35@Path("")
36public class BaseResource {
37
38    /**
39     * Serves a short description HTML page at the service root
40     *
41     * @return
42     */
43    @GET
44    @Path("/")
45    @Produces({MediaType.TEXT_XML})
46    public Response getDescription() {
47        final StreamingOutput writer = new StreamingOutput() {
48            @Override
49            public void write(OutputStream output) throws IOException,
50                    WebApplicationException {
51                try (InputStream is = getClass().getResourceAsStream("/restIndex.html")) {
52                    IOUtils.copy(is, output);
53                } finally {
54                    output.close();
55                }
56            }
57        };
58        return Response.ok(writer).type(MediaType.TEXT_HTML).build();
59    }
60
61}
Note: See TracBrowser for help on using the repository browser.