comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/rest/ListUsersResource.java @ 473:d0ac790a6c89 dive4elements-move

Moved directories to org.dive4elements
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 10:57:18 +0200
parents artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ListUsersResource.java@e2aad8d8ebd7
children 415df0fc4fa1
comparison
equal deleted inserted replaced
472:783cc1b6b615 473:d0ac790a6c89
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 :

http://dive4elements.wald.intevation.org