Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ListUsersResource.java @ 136:e2aad8d8ebd7
Added a Rest resource that lists all users provided by the artifact database.
artifacts/trunk@1361 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 02 Mar 2011 10:36:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
135:a48882c9e096 | 136:e2aad8d8ebd7 |
---|---|
1 /* | |
2 * Copyright (c) 2011 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 package de.intevation.artifactdatabase.rest; | |
9 | |
10 import de.intevation.artifacts.ArtifactDatabase; | |
11 import de.intevation.artifacts.ArtifactDatabaseException; | |
12 | |
13 import org.apache.log4j.Logger; | |
14 | |
15 import org.restlet.data.MediaType; | |
16 import org.restlet.data.Status; | |
17 import org.restlet.ext.xml.DomRepresentation; | |
18 import org.restlet.representation.EmptyRepresentation; | |
19 import org.restlet.representation.Representation; | |
20 import org.restlet.resource.ResourceException; | |
21 import org.restlet.Response; | |
22 | |
23 /** | |
24 * A Rest resource that lists the users provided by the artifact database. | |
25 * | |
26 * @author <a href="mailto:ingo.weinzierl@intevation">Ingo Weinzierl</a> | |
27 */ | |
28 public class ListUsersResource | |
29 extends BaseResource | |
30 { | |
31 /** The logger that is used in this class.*/ | |
32 private static Logger logger = Logger.getLogger(ListUsersResource.class); | |
33 | |
34 /** server URL where to reach the resource.*/ | |
35 public static final String PATH = "/list-users"; | |
36 | |
37 | |
38 @Override | |
39 protected Representation innerGet() | |
40 throws ResourceException | |
41 { | |
42 ArtifactDatabase db = getArtifactDatabase(); | |
43 | |
44 try { | |
45 logger.info(PATH); | |
46 | |
47 return new DomRepresentation( | |
48 MediaType.APPLICATION_XML, | |
49 db.listUsers(getCallMeta())); | |
50 } | |
51 catch (ArtifactDatabaseException adbe) { | |
52 logger.warn(adbe.getLocalizedMessage(), adbe); | |
53 | |
54 Response response = getResponse(); | |
55 response.setStatus( | |
56 Status.CLIENT_ERROR_NOT_FOUND, adbe.getMessage()); | |
57 return new EmptyRepresentation(); | |
58 } | |
59 } | |
60 } | |
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |