annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 1115:f953c9a559d8

Added license file and license headers. gnv-artifacts/trunk@1260 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:46:55 +0000
parents 7096a2e13676
children dec4257ad570
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1070
diff changeset
8
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.utils;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.io.File;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.io.FileNotFoundException;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.io.FileOutputStream;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import java.io.IOException;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import java.io.OutputStream;
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
16 import java.text.DecimalFormat;
772
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
17 import java.util.Date;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
19 import javax.xml.xpath.XPathConstants;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
20
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import org.apache.log4j.Logger;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Document;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.Element;
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
24 import org.w3c.dom.Node;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
26 import com.vividsolutions.jts.geom.Envelope;
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
27
853
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
28 import de.intevation.artifactdatabase.XMLUtils;
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
29 import de.intevation.artifacts.ArtifactNamespaceContext;
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
30 import de.intevation.artifacts.CallContext;
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
31 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
32 import de.intevation.gnv.wms.LayerInfo;
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
33
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 /**
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
35 * This class provides some methods to create files storing meta information
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
36 * about wms layers and a map service which serves these layers.
807
a645bd23c1c8 Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 806
diff changeset
37 *
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
38 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 */
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public class MetaWriter {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 private static Logger logger = Logger.getLogger(MetaWriter.class);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 public static final String NODE_MAPSERVER = "mapserver";
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public static final String NODE_SERVER = "server";
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public static final String NODE_MAP = "map";
772
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
47 public static final String NODE_TTL = "ttl";
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public static final String META_FILE_NAME = "meta.xml";
853
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
50
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
51 public static final String XPATH_META = "/art:meta";
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
52 public static final String XPATH_MAPSERVER = "art:meta/art:"+NODE_MAPSERVER;
730
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
53
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
54 /**
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
55 * Constructor.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
56 */
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 private MetaWriter() {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 773
diff changeset
59
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
60
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
61 /**
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
62 * Just create a new document and insert the root node.
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
63 *
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
64 * @return the meta document with necessary root node.
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
65 */
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
66 public static Document initMeta() {
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 Document meta = XMLUtils.newDocument();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 meta,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 ArtifactNamespaceContext.NAMESPACE_URI,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 Element root = creator.create("meta");
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 meta.appendChild(root);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
76 return meta;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
77 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
78
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
79 public static boolean insertLayer(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
80 CallContext context,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
81 Document document,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
82 String name,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
83 String title,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
84 String data,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
85 String model,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
86 String type,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
87 String status
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
88 ) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
89 if (document == null) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
90 document = initMeta();
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
91 }
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
92
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
93 Node meta = (Node) XMLUtils.xpath(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
94 document,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
95 XPATH_META,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
96 XPathConstants.NODE,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
97 ArtifactNamespaceContext.INSTANCE);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
98
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
99 if (meta == null) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
100 logger.error("No meta node was found in the given document. "
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
101 + "Cannot insert layer!");
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
102 return false;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
103 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
104
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
105 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
106 document,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
107 ArtifactNamespaceContext.NAMESPACE_URI,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
108 ArtifactNamespaceContext.NAMESPACE_PREFIX);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
109
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
110 Element layerEl = creator.create(LayerInfo.LAYER);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
111 Element nameEl = creator.create(LayerInfo.LAYER_NAME);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
112 Element titleEl = creator.create(LayerInfo.LAYER_TITLE);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
113 Element dataEl = creator.create(LayerInfo.LAYER_DATA);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
114 Element modelEl = creator.create(LayerInfo.LAYER_MODEL);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
115 Element typeEl = creator.create(LayerInfo.LAYER_TYPE);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
116 Element statusEl = creator.create(LayerInfo.LAYER_STATUS);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
117
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
118 modelEl.setTextContent(model);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
119 nameEl.setTextContent(name);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
120 titleEl.setTextContent(title);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
121 typeEl.setTextContent(type);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
122 statusEl.setTextContent(status);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
123 dataEl.setTextContent(data);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
124
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
125 layerEl.appendChild(modelEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
126 layerEl.appendChild(nameEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
127 layerEl.appendChild(titleEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
128 layerEl.appendChild(dataEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
129 layerEl.appendChild(typeEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
130 layerEl.appendChild(statusEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
131
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
132 if (logger.isDebugEnabled()) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
133 logger.debug("--------------- WMS LAYER PARAMS ---------------");
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
134 logger.debug("Name : " + name);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
135 logger.debug("Title : " + title);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
136 logger.debug("Data : " + data);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
137 logger.debug("Type : " + type);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
138 logger.debug("Model : " + model);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
139 logger.debug("Status: " + status);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
140 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
141
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
142 meta.appendChild(layerEl);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
143
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
144 return true;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
145 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
146
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
147 /**
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
148 * Method to write the <i>meta</i> document down to a file.
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
149 *
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
150 * @param path The destination of the file.
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
151 * @param meta The xml document storing the meta information.
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
152 */
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
153 public static boolean insertMbr(Envelope mbr, String srs, Document meta) {
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
154 Node mapserverNode = (Node) XMLUtils.xpath(
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
155 meta,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
156 XPATH_MAPSERVER,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
157 XPathConstants.NODE,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
158 ArtifactNamespaceContext.INSTANCE);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
159 if (mapserverNode != null){
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
160 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
161 meta,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
162 ArtifactNamespaceContext.NAMESPACE_URI,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
163 ArtifactNamespaceContext.NAMESPACE_PREFIX);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
164 Element bboxNode = creator.create("Box");
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
165 bboxNode.setAttribute("srsName", srs);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
166 Element coordinateNode = creator.create("coordinates");
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
167
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
168 DecimalFormat formatter = new DecimalFormat("###.############");
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
169 coordinateNode.setTextContent(formatter.format(mbr.getMinX()).replace(',', '.') +","+
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
170 formatter.format(mbr.getMinY()).replace(',', '.')+" "+
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
171 formatter.format(mbr.getMaxX()).replace(',', '.') +","+
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
172 formatter.format(mbr.getMaxY()).replace(',', '.'));
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
173 mapserverNode.appendChild(bboxNode);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
174 bboxNode.appendChild(coordinateNode);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
175 }
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
176 return true;
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
177 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
178 /**
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
179 * Method to write the <i>meta</i> document down to a file.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
180 *
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
181 * @param path The destination of the file.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
182 * @param meta The xml document storing the meta information.
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
183 */
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
184 public static boolean writeMetaFile(String path, Document meta) {
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 try {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 File metaFile = new File(path, META_FILE_NAME);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187
730
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
188 if (metaFile.exists()) {
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
189 logger.info("Delete old meta information file.");
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
190 metaFile.delete();
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
191 }
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
192
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 if (!metaFile.createNewFile() || !metaFile.canWrite()) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 logger.error("Error while writing meta file: "+metaFile.toString());
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
195 return false;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 OutputStream out = null;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 boolean success = false;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 try {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 out = new FileOutputStream(metaFile);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 success = XMLUtils.toStream(meta, out);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 finally {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 if (out != null) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 try { out.close(); }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 catch (IOException ioe) {}
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 if (!success && metaFile.exists()) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 metaFile.delete();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
215 return success;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 catch (FileNotFoundException fnfe) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 logger.error(fnfe);
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
219 return false;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 catch (IOException ioe) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 logger.error(ioe, ioe);
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
223 return false;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
228 /**
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
229 * Append meta information about the mapservice itself.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
230 *
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
231 * @param callContext The CallContext object.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
232 * @param document The meta information document.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
233 * @param meta The element where the new information need to be appended to.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
234 */
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
235 public static void insertAbstractMeta(
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 CallContext callContext,
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
237 Document document
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 ) {
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
239 if (document == null) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
240 document = initMeta();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
241 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
242
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
243 Node meta = (Node) XMLUtils.xpath(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
244 document,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
245 XPATH_META,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
246 XPathConstants.NODE,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
247 ArtifactNamespaceContext.INSTANCE);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
248
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 document,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 ArtifactNamespaceContext.NAMESPACE_URI,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 GNVArtifactContext context =
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 (GNVArtifactContext) callContext.globalContext();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 String server = (String)
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 context.get(GNVArtifactContext.MAPSERVER_SERVER_PATH_KEY);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 String map = (String)
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 context.get(GNVArtifactContext.MAPSERVER_MAP_PATH_KEY);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
263 Long time = callContext.getTimeToLive();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
264 time = time != null ? time + new Date().getTime() : null;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
265 String ttl = time != null ? time.toString() : null;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
266
772
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
267 if (logger.isDebugEnabled()) {
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
268 logger.debug("MAPSERVER PATH: " + server);
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
269 logger.debug("MAP PATH: " + map);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
270 logger.debug("TTL: " + ttl);
772
cd64ab8a46a7 Put time to live of an artifact into meta document which is created while wms publishing (issue197).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 730
diff changeset
271 }
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 Element mapserver = creator.create(NODE_MAPSERVER);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 Element serverPath = creator.create(NODE_SERVER);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 Element mapPath = creator.create(NODE_MAP);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
276 Element timetolive = creator.create(NODE_TTL);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 mapPath.setTextContent(map);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 serverPath.setTextContent(server);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
280 timetolive.setTextContent(ttl);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 mapserver.appendChild(serverPath);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 mapserver.appendChild(mapPath);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
284 mapserver.appendChild(timetolive);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 meta.appendChild(mapserver);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org