annotate gwt-client/src/main/java/org/dive4elements/river/client/server/CreateCollectionServiceImpl.java @ 8203:238fc722f87a

sed 's/logger/log/g' src/**/*.java
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 13:19:22 +0200
parents ea9eef426962
children 0a5239a1e46e
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;
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Document;
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 856
diff changeset
13 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 856
diff changeset
14
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
17 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
18 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
19 import org.dive4elements.artifacts.common.utils.XMLUtils;
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.river.client.shared.model.Collection;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.river.client.shared.model.DefaultCollection;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
29 import org.dive4elements.river.client.client.services.CreateCollectionService;
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 /**
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 * This interface provides the createCollection service to create new
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 * collections in the artifact server.
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 *
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 */
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public class CreateCollectionServiceImpl
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 extends RemoteServiceServlet
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 implements CreateCollectionService
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
42 /** Private log. */
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
43 private static final Logger log =
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 856
diff changeset
44 Logger.getLogger(CreateCollectionServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 856
diff changeset
45
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 /** XPath to figure out the uuid of the created collection.*/
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 public static final String XPATH_COLLECTION_UUID =
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 "/art:result/art:artifact-collection/@art:uuid";
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
50 /** XPath to figure out the ttl of the created collection.*/
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
51 public static final String XPATH_COLLECTION_TTL =
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
52 "/art:result/art:artifact-collection/@art:ttl";
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
53
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
54 /** Error message key that is thrown if an error occured while creating
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
55 * a new collection.*/
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
56 public static final String ERROR_CREATE_COLLECTION =
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
57 "error_create_collection";
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
59
2941
9cff19a02743 Minor Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1430
diff changeset
60 /** Attempt creation of Collection. */
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
61 public Collection create(String locale, String ownerId)
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
62 throws ServerException
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
63 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
64 log.info("Start creating a new collection.");
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
66 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
67
1430
6bb6d43eeb2d Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
68 Document create =
71
987567f31200 Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 26
diff changeset
69 ClientProtocolUtils.newCreateCollectionDocument(null);
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
70 HttpClient client = new HttpClientImpl(url, locale);
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 try {
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 Document doc = (Document) client.createCollection(
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 create, ownerId, new DocumentResponseHandler());
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
71
987567f31200 Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 26
diff changeset
76 String uuid = XMLUtils.xpathString(
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 doc, XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE);
71
987567f31200 Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 26
diff changeset
78
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
79 String ttlStr = XMLUtils.xpathString(
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
80 doc, XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE);
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
81
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
82 if (uuid.trim().length() == 0 || ttlStr.length() == 0) {
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
83 throw new ServerException(ERROR_CREATE_COLLECTION);
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
84 }
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
85
856
ec5c75da5c7a Bugfix flys/issue166: Parse Collection names from DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
86 return new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid);
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 }
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 catch (ConnectionException ce) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
89 log.error(ce, ce);
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 }
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 71
diff changeset
92 throw new ServerException(ERROR_CREATE_COLLECTION);
26
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 }
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
c19985f75118 Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org