annotate gwt-client/src/main/java/org/dive4elements/river/client/server/DescribeArtifactServiceImpl.java @ 9726:0a5239a1e46e 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Mar 2022 10:26:50 +0100
parents 238fc722f87a
children
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.server;
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Document;
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
13 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
14 import org.apache.logging.log4j.LogManager;
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 865
diff changeset
15
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
18 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
20 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.river.client.shared.model.Artifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.river.client.client.services.DescribeArtifactService;
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /**
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 * This interface provides artifact specific operation DESCRIBE.
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 *
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 */
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public class DescribeArtifactServiceImpl
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 extends RemoteServiceServlet
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 implements DescribeArtifactService
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
39 private static final Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
40 LogManager.getLogger(DescribeArtifactServiceImpl.class);
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 865
diff changeset
41
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 865
diff changeset
42
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 public static final String ERROR_DESCRIBE_ARTIFACT =
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 "error_describe_artifact";
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
47 public Artifact describe(String locale, Artifact artifact)
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 throws ServerException
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
50 log.info("DescribeArtifactServiceImpl.describe");
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
52 String url = getServletContext().getInitParameter("server-url");
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
53
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 Document describe = ClientProtocolUtils.newDescribeDocument(
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 artifact.getUuid(),
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 artifact.getHash(),
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 true);
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 HttpClient client = new HttpClientImpl(url, locale);
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 try {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
62 log.debug("Start Http request now.");
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 Document description = (Document) client.describe(
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
65 new org.dive4elements.artifacts.httpclient.objects.Artifact(
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 artifact.getUuid(),
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 artifact.getHash()),
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 describe,
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 new DocumentResponseHandler());
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 if (description != null) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
72 log.debug("Finished Http request sucessfully!");
865
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 return (Artifact) new FLYSArtifactCreator().create(description);
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 }
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 catch (ConnectionException ce) {
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 ce.printStackTrace();
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 }
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 throw new ServerException(ERROR_DESCRIBE_ARTIFACT);
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
43f520f923a8 Remove the loading panel when its Artifact's background process is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org