annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 1070:7096a2e13676

Added functionality to publish the the mbr of the generated layer to the client. gnv-artifacts/trunk@1166 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 07 Jun 2010 14:42:42 +0000
parents 04967dc9c83f
children f953c9a559d8
rev   line source
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.utils;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.File;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.io.FileNotFoundException;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.io.FileOutputStream;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.io.IOException;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 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
8 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
9 import java.util.Date;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
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
11 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
12
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Document;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 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
16 import org.w3c.dom.Node;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
18 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
19
853
164d102b0af5 Fixed Bug in renaming a Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 807
diff changeset
20 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
21 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
22 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
23 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
24 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
25
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /**
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
27 * 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
28 * 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
29 *
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
30 * @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
31 */
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 public class MetaWriter {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 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
35
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 public static final String NODE_MAPSERVER = "mapserver";
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public static final String NODE_SERVER = "server";
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 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
39 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
40
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 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
42
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
43 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
44 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
45
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
46 /**
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
47 * Constructor.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
48 */
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 private MetaWriter() {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 773
diff changeset
51
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
52
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
53 /**
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
54 * 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
55 *
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
56 * @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
57 */
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
58 public static Document initMeta() {
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 Document meta = XMLUtils.newDocument();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 meta,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 ArtifactNamespaceContext.NAMESPACE_URI,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 Element root = creator.create("meta");
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 meta.appendChild(root);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
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
68 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
69 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
70
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
71 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 ) {
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 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
82 document = initMeta();
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
83 }
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
84
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 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
86 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
87 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
88 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
89 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
90
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
91 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
92 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
93 + "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
94 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
95 }
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
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 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
98 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
99 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
100 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
101
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 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
103 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
104 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
105 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
106 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
107 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
108 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
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 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
111 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
112 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
113 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
114 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
115 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
116
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 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
118 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
119 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
120 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
121 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
122 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
123
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 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 }
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
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 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
135
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 return true;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
137 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
138
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
139 /**
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
140 * 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
141 *
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
142 * @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
143 * @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
144 */
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
145 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
146 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
147 meta,
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
148 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
149 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
150 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
151 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
152 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
153 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 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
155 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
156 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
157 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
158 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
159
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 }
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
168 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
169 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
170 /**
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
171 * 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
172 *
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
173 * @param path The destination of the file.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
174 * @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
175 */
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
176 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
177 try {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 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
179
730
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
180 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
181 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
182 metaFile.delete();
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
183 }
452fad121560 Implemented code for changing the title of a wms layer (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
184
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 if (!metaFile.createNewFile() || !metaFile.canWrite()) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 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
187 return false;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 OutputStream out = null;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 boolean success = false;
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 try {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 out = new FileOutputStream(metaFile);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 success = XMLUtils.toStream(meta, out);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 finally {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 if (out != null) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 try { out.close(); }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 catch (IOException ioe) {}
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 if (!success && metaFile.exists()) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 metaFile.delete();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
207 return success;
647
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 catch (FileNotFoundException fnfe) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 logger.error(fnfe);
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
211 return false;
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 catch (IOException ioe) {
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 logger.error(ioe, ioe);
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 647
diff changeset
215 return false;
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 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219
806
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
220 /**
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
221 * Append meta information about the mapservice itself.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
222 *
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
223 * @param callContext The CallContext object.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
224 * @param document The meta information document.
2cea76f1112e Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
225 * @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
226 */
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
227 public static void insertAbstractMeta(
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 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
229 Document document
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 ) {
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
231 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
232 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
233 }
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
234
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 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
236 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
237 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
238 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
239 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
240
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 document,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 ArtifactNamespaceContext.NAMESPACE_URI,
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 GNVArtifactContext context =
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 (GNVArtifactContext) callContext.globalContext();
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 String server = (String)
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 context.get(GNVArtifactContext.MAPSERVER_SERVER_PATH_KEY);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 String map = (String)
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 context.get(GNVArtifactContext.MAPSERVER_MAP_PATH_KEY);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254
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
255 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
256 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
257 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
258
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
259 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
260 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
261 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
262 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
263 }
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 Element mapserver = creator.create(NODE_MAPSERVER);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 Element serverPath = creator.create(NODE_SERVER);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 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
268 Element timetolive = creator.create(NODE_TTL);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 mapPath.setTextContent(map);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 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
272 timetolive.setTextContent(ttl);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 mapserver.appendChild(serverPath);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 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
276 mapserver.appendChild(timetolive);
647
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 meta.appendChild(mapserver);
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 }
bb0aa1f81280 Added missing class MetaWriter from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org