# HG changeset patch # User Ingo Weinzierl # Date 1319545875 0 # Node ID ab8eb2f544f2f0ccd299ad3db78522a28c13aa29 # Parent d0eb2202ffbe21a2d1603739d48a208d38bd016e Replaced stdout and stderr logging with log4j loggers in server classes. flys-client/trunk@3069 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/ChangeLog Tue Oct 25 12:31:15 2011 +0000 @@ -1,3 +1,45 @@ +2011-10-25 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java, + src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java, + src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java, + src/main/java/de/intevation/flys/client/server/meta/Converter.java, + src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java, + src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java, + src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java, + src/main/java/de/intevation/flys/client/server/UserServiceImpl.java, + src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java, + src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java, + src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java, + src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java, + src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java, + src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java, + src/main/java/de/intevation/flys/client/server/GetArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java, + src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java, + src/main/java/de/intevation/flys/client/server/AdvanceServiceImpl.java, + src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java, + src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/DistanceInfoServiceImpl.java, + src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java, + src/main/java/de/intevation/flys/client/server/DoCollectionAction.java, + src/main/java/de/intevation/flys/client/server/ReportServiceImpl.java, + src/main/java/de/intevation/flys/client/server/RemoveArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java, + src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java, + src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java, + src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java, + src/main/java/de/intevation/flys/client/server/DistanceInfoXML.java, + src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java, + src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java, + src/main/java/de/intevation/flys/client/server/CollectionHelper.java, + src/main/java/de/intevation/flys/client/server/ArtifactHelper.java, + src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java: + Replaced logging to stderr and stdout with log4j loggers. + 2011-10-25 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/BaseServlet.java: New. diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Oct 25 12:31:15 2011 +0000 @@ -8,7 +8,6 @@ } public static UIProvider getProvider(String uiProvider, User user) { - System.out.println("Provider: " + uiProvider); if (uiProvider == null || uiProvider.equals("")) { return new SelectProvider(); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.server; +import org.apache.log4j.Logger; + import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; @@ -13,6 +15,10 @@ extends DescribeCollectionServiceImpl implements AddArtifactService { + private static final Logger logger = + Logger.getLogger(AddArtifactService.class); + + public Collection add( Collection collection, Artifact artifact, @@ -20,7 +26,7 @@ String locale) throws ServerException { - System.out.println("AddArtifactServiceImpl.add"); + logger.info("AddArtifactServiceImpl.add"); return CollectionHelper.addArtifact(collection, artifact, url, locale); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/AdvanceServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/AdvanceServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/AdvanceServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -27,6 +29,9 @@ extends RemoteServiceServlet implements AdvanceService { + private static final Logger logger = Logger.getLogger(AdvanceService.class); + + public static final String XPATH_RESULT = "/art:result/text()"; public static final String OPERATION_FAILURE = "FAILED"; @@ -41,7 +46,7 @@ String target) throws ServerException { - System.out.println("AdvanceServiceImpl.advance"); + logger.info("AdvanceServiceImpl.advance"); Document advance = ClientProtocolUtils.newAdvanceDocument( artifact.getUuid(), @@ -72,7 +77,7 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_ADVANCE_ARTIFACT); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Tue Oct 25 12:31:15 2011 +0000 @@ -10,6 +10,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.artifacts.common.utils.XMLUtils; @@ -36,6 +38,10 @@ */ public class ArtifactDescriptionFactory { + private static final Logger logger = + Logger.getLogger(ArtifactDescriptionFactory.class); + + public static final String XPATH_STATE_NAME = "@art:name"; public static final String XPATH_UIPROVIDER = "@art:uiprovider"; @@ -60,7 +66,7 @@ * @return the {@link ArtifactDescription}. */ public static ArtifactDescription createArtifactDescription(Document doc) { - System.out.println("ArtifactDescriptionFactory - create()"); + logger.debug("ArtifactDescriptionFactory.createArtifactDescription"); Node currentState = ClientProtocolUtils.getCurrentState(doc); Node staticNode = ClientProtocolUtils.getStaticUI(doc); @@ -73,7 +79,8 @@ XPATH_STATE_NAME, XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE); - System.out.println("Current state name: " + state); + + logger.debug("Current state name: " + state); DataList currentData = extractCurrentData(dynamicNode, state); DataList[] old = extractOldData(staticNode); @@ -103,7 +110,7 @@ * entered. */ protected static DataList extractCurrentData(Node dynamicNode, String state) { - System.out.println("ArtifactDescriptionFactory - extractCurrentData()"); + logger.debug("ArtifactDescriptionFactory.extractCurrentData"); NodeList data = ClientProtocolUtils.getSelectNode(dynamicNode); String uiProvider = extractUIProvider(dynamicNode); @@ -141,8 +148,7 @@ * @return the default DataItem. */ protected static DataItem extractDefaultDataItem(Node data) { - System.out.println( - "ArtifactDescriptionFactory - extractSelectedDataItem"); + logger.debug("ArtifactDescriptionFactory.extractDefaultDataItem"); String value = XMLUtils.xpathString( data, "@art:defaultValue", ArtifactNamespaceContext.INSTANCE); @@ -166,11 +172,10 @@ * @return the {@link DataItem}s. */ protected static DataItem[] extractCurrentDataItems(NodeList items) { - System.out.println( - "ArtifactDescriptionFactory - extractCurrentDataItems()"); + logger.debug("ArtifactDescriptionFactory.extractCurrentDataItems"); if (items == null || items.getLength() == 0) { - System.out.println("No data items found."); + logger.debug("No data items found."); return null; } @@ -199,10 +204,10 @@ protected static double[] extractMinMaxQValues(Node item) { - System.out.println("ArtifactDescriptionFactory - extractMinMaxQValues"); + logger.debug("ArtifactDescriptionFactory.extractMinMaxQValues"); if (item == null) { - System.err.println("This node is empty - no min/max Q values."); + logger.debug("This node is empty - no min/max Q values."); return null; } @@ -213,7 +218,7 @@ ArtifactNamespaceContext.INSTANCE); if (node == null) { - System.out.println("No min/max Q values found."); + logger.debug("No min/max Q values found."); return null; } @@ -222,10 +227,10 @@ protected static double[] extractMinMaxWValues(Node item) { - System.out.println("ArtifactDescriptionFactory - extractMinMaxWValues"); + logger.debug("ArtifactDescriptionFactory.extractMinMaxWValues"); if (item == null) { - System.err.println("This node is empty - no min/max W values."); + logger.debug("This node is empty - no min/max W values."); return null; } @@ -236,7 +241,7 @@ ArtifactNamespaceContext.INSTANCE); if (node == null) { - System.out.println("No min/max W values found."); + logger.debug("No min/max W values found."); return null; } @@ -245,7 +250,7 @@ protected static double[] extractMinMaxValues(Node node) { - System.out.println("ArtifactDescriptionFactory.extractMinMaxValues"); + logger.debug("ArtifactDescriptionFactory.extractMinMaxValues"); String minStr = XMLUtils.xpathString( node, "art:min/text()", ArtifactNamespaceContext.INSTANCE); @@ -254,7 +259,7 @@ node, "art:max/text()", ArtifactNamespaceContext.INSTANCE); if (maxStr == null || minStr == null) { - System.err.println("No min/max values found."); + logger.debug("No min/max values found."); return null; } @@ -265,7 +270,7 @@ return new double[] { min, max }; } catch (NumberFormatException nfe) { - System.err.println("Error while parsing min/max values."); + logger.debug("Error while parsing min/max values."); } return null; @@ -281,7 +286,7 @@ * @return the DataList objects. */ protected static DataList[] extractOldData(Node staticNode) { - System.out.println("ArtifactDescriptionFactory - extractOldData()"); + logger.debug("ArtifactDescriptionFactory.extractOldData()"); NodeList stateNodes = (NodeList) XMLUtils.xpath( staticNode, @@ -290,7 +295,7 @@ ArtifactNamespaceContext.INSTANCE); if (stateNodes == null || stateNodes.getLength() == 0) { - System.out.println("No old items found."); + logger.debug("No old items found."); return null; } @@ -356,7 +361,7 @@ ArtifactNamespaceContext.INSTANCE); if (itemList == null || itemList.getLength() == 0) { - System.out.println("No old data items found."); + logger.debug("No old data items found."); return null; } @@ -403,7 +408,7 @@ * @return an array with identifiers of reachable states. */ protected static String[] extractReachableStates(Node reachable) { - System.out.println("ArtifactDescriptionFactory - extractReachableStates()"); + logger.debug("ArtifactDescriptionFactory.extractReachableStates()"); NodeList list = (NodeList) XMLUtils.xpath( reachable, @@ -441,7 +446,7 @@ * @return an array of Output modes. */ protected static OutputMode[] extractOutputModes(NodeList outputs) { - System.out.println("ArtifactDescriptionFactory - extractOutputModes()"); + logger.debug("ArtifactDescriptionFactory.extractOutputModes"); if (outputs == null || outputs.getLength() == 0) { return null; @@ -465,7 +470,7 @@ outs.add(new DefaultOutputMode(name, desc, mimeType)); } else { - System.err.println("Found an invalid output mode."); + logger.debug("Found an invalid output mode."); } } @@ -474,7 +479,7 @@ protected static Recommendation[] extractRecommendedArtifacts(Document doc){ - System.out.println("ArtifactDescriptionFactory - extract recommended."); + logger.debug("ArtifactDescriptionFactory.extractRecommendedArtifacts."); NodeList list = (NodeList) XMLUtils.xpath( doc, diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ArtifactHelper.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactHelper.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactHelper.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -24,6 +26,9 @@ */ public class ArtifactHelper { + private static final Logger logger = Logger.getLogger(ArtifactHelper.class); + + /** The error message key that is thrown if an error occured while artifact * creation.*/ public static final String ERROR_CREATE_ARTIFACT = "error_create_artifact"; @@ -43,7 +48,7 @@ Recommendation recommendation) throws ServerException { - System.out.println("ArtifactHelper.create"); + logger.debug("ArtifactHelper.create"); String uuid; String ids; @@ -69,7 +74,7 @@ return (Artifact) client.create(create, new FLYSArtifactCreator()); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_CREATE_ARTIFACT); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.server; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.flys.client.shared.exceptions.ServerException; @@ -18,6 +20,10 @@ extends RemoteServiceServlet implements ArtifactService { + private static final Logger logger = + Logger.getLogger(ArtifactServiceImpl.class); + + /** * Creates new Artifacts based on a given Recommendation and factory. * Note, that all the work is done in ArtifactHelper! @@ -36,7 +42,7 @@ ) throws ServerException { - System.out.println("ArtifactServiceImpl.create"); + logger.info("ArtifactServiceImpl.create"); return ArtifactHelper.createArtifact(serverUrl, locale, factory, recom); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -10,6 +10,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import au.com.bytecode.opencsv.CSVReader; @@ -31,6 +33,10 @@ extends RemoteServiceServlet implements CSVExportService { + private static final Logger logger = + Logger.getLogger(CSVExportServiceImpl.class); + + public static final String ERROR_NO_EXPORT_FOUND = "error_no_export_found"; @@ -41,7 +47,7 @@ String name) throws ServerException { - System.out.println("CSVExportServiceImpl.getCSV"); + logger.info("CSVExportServiceImpl.getCSV"); Document requestDoc = XMLUtils.newDocument(); @@ -65,7 +71,7 @@ return (List) csvReader.readAll (); } catch (IOException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce.getLocalizedMessage()); } throw new ServerException(ERROR_NO_EXPORT_FOUND); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -12,6 +12,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -40,6 +42,10 @@ extends RemoteServiceServlet implements ChartInfoService { + private static final Logger logger = + Logger.getLogger(ChartInfoServiceImpl.class); + + public static final String XPATH_TRANSFORM_MATRIX = "/art:chartinfo/art:transformation-matrix/art:matrix"; @@ -60,7 +66,7 @@ Map attr) throws ServerException { - System.out.println("ChartInfoServiceImpl.getChartInfo"); + logger.info("ChartInfoServiceImpl.getChartInfo"); Document request = ClientProtocolUtils.newOutCollectionDocument( collection.identifier(), @@ -86,7 +92,7 @@ e.printStackTrace(); } - System.err.println("Error while fetching chart info."); + logger.debug("Error while fetching chart info."); throw new ServerException(EXCEPTION_STRING); } @@ -102,7 +108,7 @@ protected Axis[] parseXAxes(Document doc) { - System.out.println("ChartInfoServiceImpl.parseXAxes"); + logger.debug("ChartInfoServiceImpl.parseXAxes"); NodeList axes = (NodeList) XMLUtils.xpath( doc, @@ -115,7 +121,7 @@ protected Axis[] parseYAxes(Document doc) { - System.out.println("ChartInfoServiceImpl.parseYAxes"); + logger.debug("ChartInfoServiceImpl.parseYAxes"); NodeList axes = (NodeList) XMLUtils.xpath( doc, @@ -128,11 +134,11 @@ protected Axis[] parseAxes(NodeList axes) { - System.out.println("ChartInfoServiceImpl.parseAxes"); + logger.debug("ChartInfoServiceImpl.parseAxes"); int count = axes != null ? axes.getLength() : 0; - System.out.println("Chart has " + count + " axes."); + logger.debug("Chart has " + count + " axes."); if (count == 0) { return null; @@ -167,7 +173,7 @@ if (pos >= result.length) { // this should never happen - System.err.println("The axis is out of valid range: " + pos); + logger.debug("The axis is out of valid range: " + pos); continue; } @@ -178,7 +184,7 @@ } } - System.out.println("Parsed " + result.length + " axes"); + logger.debug("Parsed " + result.length + " axes"); return result; } @@ -193,7 +199,7 @@ * coordinates. */ protected Transform2D[] parseTransformationMatrix(Document doc) { - System.out.println("ChartInfoServiceImpl.parseTransformationMatrix"); + logger.debug("ChartInfoServiceImpl.parseTransformationMatrix"); NodeList matrix = (NodeList) XMLUtils.xpath( doc, @@ -209,7 +215,7 @@ Transform2D t = createTransformer(matrix.item(i)); if (t == null) { - System.err.println("Broken transformation matrix at pos: " + i); + logger.warn("Broken transformation matrix at pos: " + i); continue; } @@ -242,11 +248,11 @@ Double.parseDouble(ty)); } catch (NumberFormatException nfe) { - System.err.println("Error while parsing matrix values."); + logger.warn("Error while parsing matrix values."); } } - System.err.println("No matrix values found."); + logger.warn("No matrix values found."); return new Transform2D(1d, 1d, 0d, 0d); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -7,6 +7,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -27,8 +29,12 @@ public class ChartOutputServiceImpl extends HttpServlet { + private static final Logger logger = + Logger.getLogger(ChartOutputServiceImpl.class); + + public void doGet(HttpServletRequest req, HttpServletResponse resp) { - System.out.println("ChartOutputServiceImpl.doGet"); + logger.info("ChartOutputServiceImpl.doGet"); try { OutputStream out = resp.getOutputStream(); @@ -51,12 +57,10 @@ out.flush(); } catch (IOException ioe) { - ioe.printStackTrace(); - System.err.println(ioe.getMessage()); + logger.error(ioe, ioe); } catch (Exception e) { - e.printStackTrace(); - System.err.println(e.getMessage()); + logger.error(e, e); } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java Tue Oct 25 12:31:15 2011 +0000 @@ -5,6 +5,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; @@ -15,6 +17,10 @@ */ public class ChartServiceHelper { + private static final Logger logger = + Logger.getLogger(ChartServiceHelper.class); + + /** The default chart width if no value is specified in the request.*/ public static final int DEFAULT_CHART_WIDTH = 600; @@ -35,7 +41,7 @@ * @return a document to adjust chart settings. */ protected static Document getChartAttributes(Map req) { - System.out.println("ChartServiceHelper.getChartAttributes"); + logger.debug("ChartServiceHelper.getChartAttributes"); Document doc = XMLUtils.newDocument(); @@ -71,7 +77,7 @@ Element attributes, ElementCreator ec) { - System.out.println("ChartServiceHelper.appendChartSize"); + logger.debug("ChartServiceHelper.appendChartSize"); Element size = ec.create("size"); @@ -104,7 +110,7 @@ Element attributes, ElementCreator ec) { - System.out.println("ChartServiceHelper.appendXRange"); + logger.debug("ChartServiceHelper.appendXRange"); Element range = ec.create("xrange"); @@ -134,7 +140,7 @@ Element attributes, ElementCreator ec) { - System.out.println("ChartServiceHelper.appendYRange"); + logger.debug("ChartServiceHelper.appendYRange"); Element range = ec.create("yrange"); @@ -165,7 +171,7 @@ ElementCreator ec ) { - System.out.println("ChartServiceHelper.appendFormat"); + logger.debug("ChartServiceHelper.appendFormat"); String formatStr = req.get("format"); if (formatStr == null || formatStr.length() == 0) { diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.artifacts.httpclient.exceptions.ConnectionException; @@ -22,6 +24,10 @@ extends DescribeCollectionServiceImpl implements CollectionAttributeService { + private static final Logger logger = + Logger.getLogger(CollectionAttributeServiceImpl.class); + + public static final String ERROR_UPDATING_COLLECTION_ATTRIBUTE = "error_update_collection_attribute"; @@ -29,7 +35,7 @@ public Collection update(Collection collection, String url, String locale) throws ServerException { - System.out.println("CollectionAttributeServiceImpl.update"); + logger.info("CollectionAttributeServiceImpl.update"); Document attribute = CollectionHelper.createAttribute(collection); Document action = ClientProtocolUtils.newSetAttributeDocument( @@ -43,12 +49,12 @@ collection.identifier(), new DocumentResponseHandler()); - System.out.println("Collection attribute successfully set."); + logger.debug("Collection attribute successfully set."); return describe(collection.identifier(), url, locale); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_UPDATING_COLLECTION_ATTRIBUTE); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java Tue Oct 25 12:31:15 2011 +0000 @@ -14,6 +14,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.artifacts.common.utils.XMLUtils; @@ -48,6 +50,10 @@ */ public class CollectionHelper { + private static final Logger logger = + Logger.getLogger(CollectionHelper.class); + + public static final String ERROR_ADD_ARTIFACT = "error_add_artifact"; public static final String ERROR_REMOVE_ARTIFACT = "error_remove_artifact"; @@ -59,7 +65,7 @@ public static Document createAttribute(Collection collection) { - System.out.println("CollectionHelper.createAttribute"); + logger.debug("CollectionHelper.createAttribute"); Document doc = XMLUtils.newDocument(); @@ -103,14 +109,14 @@ Collection c, Map mmodes) { - System.out.println("CollectionHelper.createOutputElements"); + logger.debug("CollectionHelper.createOutputElements"); java.util.Collection modes = mmodes != null ? mmodes.values() : null; if (modes == null || modes.size() == 0) { - System.err.println("Collection has no modes: " + c.identifier()); + logger.debug("Collection has no modes: " + c.identifier()); return null; } @@ -142,7 +148,7 @@ Collection collection, OutputMode mode) { - System.out.println("CollectionHelper.createOutputElement"); + logger.debug("CollectionHelper.createOutputElement"); Element out = cr.create("output"); cr.addAttr(out, "name", mode.getName(), false); @@ -151,7 +157,7 @@ List themes = themeList != null ? themeList.getThemes() : null; if (themes == null || themes.size() == 0) { - System.err.println("No themes for output mode: " + mode.getName()); + logger.debug("No themes for output mode: " + mode.getName()); return null; } @@ -221,12 +227,12 @@ ElementCreator cr, Collection c) { - System.out.println("CollectionHelper.createRecommendationsElements"); + logger.debug("CollectionHelper.createRecommendationsElements"); List rs = c.getRecommendations(); if (rs == null || rs.size() == 0) { - System.err.println("Collection did not load recommendations: " + + logger.debug("Collection did not load recommendations: " + c.identifier()); return null; } @@ -259,7 +265,7 @@ Collection c, Recommendation r) { - System.out.println("CollectionHelper.createRecommendationElement"); + logger.debug("CollectionHelper.createRecommendationElement"); Element recommendation = cr.create("recommendation"); cr.addAttr(recommendation, "factory", r.getFactory(), true); @@ -280,10 +286,10 @@ * @return a Collection with CollectionItems. */ public static Collection parseCollection(Document description) { - System.out.println("AddArtifactServiceImpl.parseCollection"); + logger.debug("AddArtifactServiceImpl.parseCollection"); if (description == null) { - System.err.println("The DESCRIBE of the Collection is null!"); + logger.warn("The DESCRIBE of the Collection is null!"); return null; } @@ -303,12 +309,12 @@ ArtifactNamespaceContext.INSTANCE); if (uuid.length() == 0) { - System.err.println("Found an invalid (zero length uuid) Collection!"); + logger.warn("Found an invalid (zero length uuid) Collection!"); return null; } if (ttlStr.length() == 0) { - System.err.println("Found an invalid Collectioni (zero length ttl)!"); + logger.warn("Found an invalid Collectioni (zero length ttl)!"); return null; } @@ -337,7 +343,7 @@ ArtifactNamespaceContext.INSTANCE); if (items == null || items.getLength() == 0) { - System.out.println("No collection item found for this collection."); + logger.debug("No collection item found for this collection."); return c; } @@ -354,7 +360,7 @@ } } - System.out.println( + logger.debug( "Found " + c.getItemLength() + " collection items " + "for the Collection '" + c.identifier() + "'."); @@ -363,7 +369,7 @@ protected static Map parseThemeLists(Document desc) { - System.out.println("DescribeCollectionServiceImpl.parseThemeLists"); + logger.debug("DescribeCollectionServiceImpl.parseThemeLists"); NodeList lists = (NodeList) XMLUtils.xpath( desc, @@ -395,7 +401,7 @@ protected static ThemeList parseThemeList(Element node) { - System.out.println("DescribeCollectionServiceImpl.parseThemeList"); + logger.debug("DescribeCollectionServiceImpl.parseThemeList"); NodeList themes = node.getElementsByTagNameNS( ArtifactNamespaceContext.NAMESPACE_URI, @@ -418,7 +424,7 @@ protected static Theme parseTheme(Element ele) { - System.out.println("DescribeCollectionServiceImpl.parseTheme"); + logger.debug("DescribeCollectionServiceImpl.parseTheme"); String uri = ArtifactNamespaceContext.NAMESPACE_URI; @@ -453,10 +459,10 @@ Element node, boolean outs ) { - System.out.println("AddArtifactServiceImpl.parseCollectionItem"); + logger.debug("AddArtifactServiceImpl.parseCollectionItem"); if (node == null) { - System.err.println("The node for parsing CollectionItem is null!"); + logger.debug("The node for parsing CollectionItem is null!"); return null; } @@ -466,7 +472,7 @@ String hash = node.getAttributeNS(uri, "hash"); if (uuid == null || uuid.length() == 0) { - System.err.println("Found an invalid CollectionItem!"); + logger.warn("Found an invalid CollectionItem!"); return null; } @@ -498,10 +504,10 @@ * @return a list of OutputModes. */ protected static List parseOutputModes(Element node) { - System.out.println("AddArtifactServiceImpl.parseOutputModes"); + logger.debug("AddArtifactServiceImpl.parseOutputModes"); if (node == null) { - System.err.println("The node for parsing OutputModes is null!"); + logger.debug("The node for parsing OutputModes is null!"); return null; } @@ -512,7 +518,7 @@ int size = list.getLength(); if (size == 0) { - System.err.println("No outputmode nodes found!"); + logger.debug("No outputmode nodes found!"); return null; } @@ -527,7 +533,7 @@ String type = tmp.getAttributeNS(uri, "type"); if (name.length() == 0) { - System.err.println("Found an invalid output mode."); + logger.warn("Found an invalid output mode."); continue; } @@ -547,7 +553,7 @@ outmode = new MapMode(name, desc, mime, fs); } else { - System.err.println("Broken Output mode without type found."); + logger.warn("Broken Output mode without type found."); continue; } @@ -559,7 +565,7 @@ protected static List extractFacets(Element outmode) { - System.out.println("DescribeCollectionServiceImpl - extractFacets()"); + logger.debug("DescribeCollectionServiceImpl - extractFacets()"); NodeList facetList = (NodeList) XMLUtils.xpath( outmode, @@ -590,7 +596,7 @@ public static List parseRecommendations(Document doc) { - System.out.println("DescribeCollectionServiceImpl.parseRecommendations"); + logger.debug("DescribeCollectionServiceImpl.parseRecommendations"); NodeList list = (NodeList) XMLUtils.xpath( doc, @@ -631,10 +637,10 @@ String locale) throws ServerException { - System.out.println("Collection.addArtifact"); + logger.debug("Collection.addArtifact"); if (collection == null) { - System.err.println("The given Collection is null!"); + logger.warn("The given Collection is null!"); return null; } @@ -644,12 +650,12 @@ HttpClient client = new HttpClientImpl(url, locale); try { - System.out.println("Do HTTP request now."); + logger.debug("Do HTTP request now."); Document response = (Document) client.doCollectionAction( add, collection.identifier(), new DocumentResponseHandler()); - System.out.println( + logger.debug( "Finished HTTP request successfully. Parse Collection now."); Collection c = CollectionHelper.parseCollection(response); @@ -661,10 +667,10 @@ return c; } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } catch (Exception e) { - e.printStackTrace(); + logger.error(e, e); } throw new ServerException(ERROR_ADD_ARTIFACT); @@ -683,10 +689,10 @@ String locale) throws ServerException { - System.out.println("Collection.removeArtifact"); + logger.debug("Collection.removeArtifact"); if (collection == null) { - System.err.println("The given Collection is null!"); + logger.warn("The given Collection is null!"); return null; } @@ -696,14 +702,14 @@ HttpClient client = new HttpClientImpl(url, locale); try { - System.out.println("Do HTTP request now."); + logger.debug("Do HTTP request now."); Document response = (Document) client.doCollectionAction( remove, collection.identifier(), new DocumentResponseHandler()); - System.out.println( + logger.debug( "Finished HTTP request successfully. Parse Collection now."); - System.out.println(XMLUtils.toString(response)); + logger.debug(XMLUtils.toString(response)); Collection c = CollectionHelper.parseCollection(response); @@ -714,10 +720,10 @@ return c; } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } catch (Exception e) { - e.printStackTrace(); + logger.error(e, e); } throw new ServerException(ERROR_REMOVE_ARTIFACT); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -4,6 +4,8 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.httpclient.exceptions.ConnectionException; @@ -31,6 +33,10 @@ extends RemoteServiceServlet implements CollectionItemAttributeService { + private static final Logger logger = + Logger.getLogger(CollectionItemAttributeServiceImpl.class); + + public static final String XPATH_RESULT = "/art:result/text()"; public static final String OPERATION_FAILURE = "FAILED"; @@ -46,7 +52,7 @@ String locale) throws ServerException { - System.out.println( + logger.info( "CollectionItemAttributeServiceImpl.getCollectionItemAttribute"); Document requestDoc = XMLUtils.newDocument(); @@ -77,7 +83,7 @@ return readXML (res, artifact); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_NO_STYLES_FOUND); @@ -92,7 +98,7 @@ CollectionItemAttribute attributes) throws ServerException { - System.out.println( + logger.info( "CollectionItemAttributeServiceImpl.setCollectionItemAttribute"); Document doc = writeXML(attributes, artifact); @@ -107,9 +113,9 @@ return; } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); + throw new ServerException(ce.getLocalizedMessage()); } - throw new ServerException(""); } protected CollectionItemAttribute readXML(Document doc, String artifact) diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -29,6 +31,10 @@ extends RemoteServiceServlet implements CreateCollectionService { + private static final Logger logger = + Logger.getLogger(CreateCollectionServiceImpl.class); + + /** XPath to figure out the uuid of the created collection.*/ public static final String XPATH_COLLECTION_UUID = "/art:result/art:artifact-collection/@art:uuid"; @@ -46,7 +52,7 @@ public Collection create(String serverUrl, String locale, String ownerId) throws ServerException { - System.out.println("Start creating a new collection."); + logger.info("Start creating a new collection."); Document create = ClientProtocolUtils.newCreateCollectionDocument(null); @@ -69,7 +75,7 @@ return new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_CREATE_COLLECTION); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.flys.client.shared.exceptions.ServerException; @@ -16,13 +18,17 @@ extends DoCollectionAction implements DeleteCollectionService { + private static final Logger logger = + Logger.getLogger(DeleteCollectionServiceImpl.class); + + public static final String XPATH_RESULT = "/art:result/text()"; public static final String OPERATION_FAILURE = "FAILED"; public void delete(Collection c, String url) throws ServerException { - System.out.println("Delete collection: " + c.identifier()); + logger.info("Delete collection: " + c.identifier()); Document del = ClientProtocolUtils.newDeleteCollectionDocument(); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.utils.ClientProtocolUtils; @@ -25,6 +27,10 @@ extends RemoteServiceServlet implements DescribeArtifactService { + private static final Logger logger = + Logger.getLogger(DescribeArtifactServiceImpl.class); + + public static final String ERROR_DESCRIBE_ARTIFACT = "error_describe_artifact"; @@ -32,7 +38,7 @@ public Artifact describe(String url, String locale, Artifact artifact) throws ServerException { - System.out.println("DescribeArtifactServiceImpl.describe"); + logger.info("DescribeArtifactServiceImpl.describe"); Document describe = ClientProtocolUtils.newDescribeDocument( artifact.getUuid(), @@ -42,7 +48,7 @@ HttpClient client = new HttpClientImpl(url, locale); try { - System.out.println("Start Http request now."); + logger.debug("Start Http request now."); Document description = (Document) client.describe( new de.intevation.artifacts.httpclient.objects.Artifact( @@ -52,7 +58,7 @@ new DocumentResponseHandler()); if (description != null) { - System.out.println("Finished Http request sucessfully!"); + logger.debug("Finished Http request sucessfully!"); return (Artifact) new FLYSArtifactCreator().create(description); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.utils.ClientProtocolUtils; @@ -28,6 +30,10 @@ extends RemoteServiceServlet implements DescribeCollectionService { + private static final Logger logger = + Logger.getLogger(DescribeCollectionServiceImpl.class); + + /** The error message key that is thrown if an error occured while * describe() a Collection.*/ public static final String ERROR_DESCRIBE_COLLECTION = @@ -37,7 +43,7 @@ public Collection describe(String uuid, String serverUrl, String locale) throws ServerException { - System.out.println("DescribeCollectionServiceImpl.describe"); + logger.info("DescribeCollectionServiceImpl.describe"); Document describe = ClientProtocolUtils.newDescribeCollectionDocument( uuid); @@ -54,12 +60,12 @@ throw new ServerException(ERROR_DESCRIBE_COLLECTION); } - System.out.println("Collection successfully parsed."); + logger.debug("Collection successfully parsed."); return c; } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_DESCRIBE_COLLECTION); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -7,6 +7,8 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -29,6 +31,10 @@ extends RemoteServiceServlet implements DistanceInfoService { + private static final Logger logger = + Logger.getLogger(DistanceInfoServiceImpl.class); + + public static final String ERROR_NO_DISTANCEINFO_FOUND = "error_no_distanceinfo_found"; @@ -41,7 +47,7 @@ String river) throws ServerException { - System.out.println("DistanceInfoServiceImpl.getDistanceInfo"); + logger.info("DistanceInfoServiceImpl.getDistanceInfo"); Document doc = XMLUtils.newDocument(); @@ -61,7 +67,7 @@ try { Document result = client.callService(url, "distanceinfo", doc); - System.out.println("Extract distance info objects now."); + logger.debug("Extract distance info objects now."); DistanceInfoObject[] objects = extractDistanceInfoObjects(result); if (objects != null && objects.length > 0) { @@ -69,7 +75,7 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND); @@ -89,12 +95,12 @@ NodeList list = result.getElementsByTagName("distance"); if (list == null || list.getLength() == 0) { - System.err.println("No distance info found."); + logger.warn("No distance info found."); throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND); } int num = list.getLength(); - System.out.println("Response contains " + num + " objects."); + logger.debug("Response contains " + num + " objects."); List objects = new ArrayList(num); @@ -108,7 +114,7 @@ } } - System.out.println("Retrieved " + objects.size() + " distances."); + logger.debug("Retrieved " + objects.size() + " distances."); return (DistanceInfoObject[]) objects.toArray(new DistanceInfoObject[num]); @@ -142,11 +148,11 @@ return new DistanceInfoObjectImpl(desc, f, t, riverside, b, tp); } catch (NumberFormatException nfe) { - System.err.println(nfe.getLocalizedMessage()); + logger.warn(nfe.getLocalizedMessage()); } } - System.err.println("Invalid distance info object found."); + logger.warn("Invalid distance info object found."); return null; } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoXML.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoXML.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoXML.java Tue Oct 25 12:31:15 2011 +0000 @@ -7,6 +7,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -26,12 +28,15 @@ public class DistanceInfoXML extends HttpServlet { + private static final Logger logger = Logger.getLogger(DistanceInfoXML.class); + + public static final String ERROR_NO_DISTANCEINFO_FOUND = "error_no_distanceinfo_found"; public void doGet(HttpServletRequest req, HttpServletResponse resp) { - System.out.println("DistanceInfoXML.doGet"); + logger.info("DistanceInfoXML.doGet"); String river = req.getParameter("river"); String url = req.getParameter("server"); @@ -74,10 +79,10 @@ out.close(); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } catch (IOException ioe) { - System.err.println(ioe.getLocalizedMessage()); + logger.error(ioe, ioe); } } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/DoCollectionAction.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DoCollectionAction.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DoCollectionAction.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -21,6 +23,10 @@ */ public class DoCollectionAction extends RemoteServiceServlet { + private static final Logger logger = + Logger.getLogger(DoCollectionAction.class); + + public static final String XPATH_RESULT = "/art:result/text()"; public static final String OPERATION_FAILURE = "FAILED"; public static final String FAILURE_EXCEPTION = "collection_action_failed"; @@ -29,6 +35,8 @@ protected void doAction(Collection c, Document action, String url) throws ServerException { + logger.info("DoCollectionAction.doAction"); + HttpClient client = new HttpClientImpl(url); try { @@ -42,12 +50,12 @@ ArtifactNamespaceContext.INSTANCE); if (result == null || result.equals(OPERATION_FAILURE)) { - System.err.println("Operation failed."); + logger.error("Operation failed."); throw new ServerException(FAILURE_EXCEPTION); } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); throw new ServerException(FAILURE_EXCEPTION); } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -5,6 +5,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -25,8 +27,12 @@ public class ExportServiceImpl extends HttpServlet { + private static final Logger logger = + Logger.getLogger(ExportServiceImpl.class); + + public void doGet(HttpServletRequest req, HttpServletResponse resp) { - System.out.println("ExportServiceImpl.doGet"); + logger.info("ExportServiceImpl.doGet"); try { OutputStream out = resp.getOutputStream(); @@ -40,7 +46,7 @@ resp.setHeader("Content-Disposition", "attachment;filename=" + fn); - System.out.println("Request " + type + " export."); + logger.debug("Request " + type + " export."); Document request = ClientProtocolUtils.newOutCollectionDocument( uuid, mode, type); @@ -51,7 +57,7 @@ out.flush(); } catch (IOException ioe) { - System.err.println(ioe.getMessage()); + logger.error(ioe, ioe); } } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Tue Oct 25 12:31:15 2011 +0000 @@ -9,6 +9,8 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -29,6 +31,10 @@ */ public class FLYSArtifactCreator implements ArtifactCreator { + private static final Logger logger = + Logger.getLogger(FLYSArtifactCreator.class); + + /** The XPath to the artifact's uuid.*/ public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; @@ -82,7 +88,7 @@ * @return an instance of an {@link Artifact}. */ protected Artifact extractArtifact(Document doc) { - System.out.println("FLYSArtifactCreator - extractArtifact()"); + logger.debug("FLYSArtifactCreator - extractArtifact()"); String uuid = XMLUtils.xpathString( doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); @@ -103,10 +109,10 @@ List msg = parseBackgroundMessages(doc); - System.out.println("NEW Artifact UUID: " + uuid); - System.out.println("NEW Artifact HASH: " + hash); - System.out.println("NEW Artifact NAME: " + name); - System.out.println("NEW Artifact IN BACKGROUND: " + background); + logger.debug("NEW Artifact UUID: " + uuid); + logger.debug("NEW Artifact HASH: " + hash); + logger.debug("NEW Artifact NAME: " + name); + logger.debug("NEW Artifact IN BACKGROUND: " + background); if (name == null) { return new DefaultArtifact(uuid, hash, background, msg); @@ -115,7 +121,7 @@ name = name.trim(); if (name.length() > 0 && name.equals("winfo")) { - System.out.println("+++++ NEW WINFO ARTIFACT."); + logger.debug("+++++ NEW WINFO ARTIFACT."); return new WINFOArtifact(uuid, hash, background, msg); } @@ -130,7 +136,7 @@ int len = list != null ? list.getLength() : 0; - System.out.println("Found " + len + " background messages."); + logger.debug("Found " + len + " background messages."); List res = new ArrayList(len); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -27,6 +29,9 @@ extends RemoteServiceServlet implements FeedService { + private static final Logger logger = Logger.getLogger(FeedServiceImpl.class); + + /** XPath that points to the result type of a feed or advance operation.*/ public static final String XPATH_RESULT = "/art:result/@art:type"; @@ -58,7 +63,7 @@ Data[] data) throws ServerException { - System.out.println("StepForwardServiceImpl.feed"); + logger.info("StepForwardServiceImpl.feed"); Document feed = ClientProtocolUtils.newFeedDocument( artifact.getUuid(), @@ -76,7 +81,7 @@ new DocumentResponseHandler()); if (description == null) { - System.err.println("StepForwardService.feed() - FAILED"); + logger.warn("StepForwardService.feed() - FAILED"); throw new ServerException(ERROR_FEED_DATA); } @@ -86,7 +91,7 @@ ArtifactNamespaceContext.INSTANCE); if (result == null || !result.equals(OPERATION_FAILURE)) { - System.out.println("StepForwardService.feed() - SUCCESS"); + logger.debug("StepForwardService.feed() - SUCCESS"); return (Artifact) new FLYSArtifactCreator().create(description); } else if (result != null && result.equals(OPERATION_FAILURE)) { @@ -98,10 +103,10 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } - System.err.println("StepForwardService.feed() - FAILED"); + logger.warn("StepForwardService.feed() - FAILED"); throw new ServerException(ERROR_FEED_DATA); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/GetArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/GetArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/GetArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -28,6 +30,10 @@ extends RemoteServiceServlet implements GetArtifactService { + private static final Logger logger = + Logger.getLogger(GetArtifactServiceImpl.class); + + public static final String ERROR_DESCRIBE_ARTIFACT = "error_describe_artifact"; @@ -43,7 +49,7 @@ String hash) throws ServerException { - System.out.println("GetArtifactServiceImpl.getArtifact"); + logger.info("GetArtifactServiceImpl.getArtifact"); Document describe = ClientProtocolUtils.newDescribeDocument( uuid, hash, true); @@ -71,7 +77,7 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_DESCRIBE_ARTIFACT); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.HashMap; +import org.apache.log4j.Logger; + import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; @@ -20,6 +22,10 @@ extends ArtifactServiceImpl implements LoadArtifactService { + private static final Logger logger = + Logger.getLogger(LoadArtifactServiceImpl.class); + + public static final String ERROR_LOAD_ARTIFACT = "error_load_artifact"; @@ -43,7 +49,7 @@ String locale ) throws ServerException { - System.out.println( + logger.info( "LoadArtifactServiceImpl.load: " + recom.getMasterArtifact()); // 1) Clone the Artifact specified in >>recom<< @@ -51,12 +57,12 @@ url, locale, factory, recom); if (clone != null) { - System.out.println("Successfully create Artifact Clone. Add now!"); + logger.debug("Successfully create Artifact Clone. Add now!"); Collection c = CollectionHelper.addArtifact( parent, clone, url, locale); if (c != null) { - System.out.println("Successfully added Clone to Collection."); + logger.debug("Successfully added Clone to Collection."); return clone; } @@ -89,7 +95,7 @@ String locale ) throws ServerException { - System.out.println("LoadArtifactServiceImpl.loadMany"); + logger.debug("LoadArtifactServiceImpl.loadMany"); ArrayList artifacts = new ArrayList(); HashMap cloneMap = @@ -103,7 +109,7 @@ Artifact prevClone = cloneMap.get(recom); if (prevClone != null) { // Already cloned a recommendation like this. - System.out.println("LoadArtifactServiceImpl: Avoid reclones, " + logger.debug("LoadArtifactServiceImpl: Avoid reclones, " + "clone already exists."); artifacts.add(prevClone); } @@ -113,13 +119,13 @@ ? factory : recom.getFactory(); - System.out.println("One will be cloned with : " + realFactory); + logger.debug("One will be cloned with : " + realFactory); Artifact clone = ArtifactHelper.createArtifact( url, locale, realFactory, recom); if (clone != null) { - System.out.println("LoadArtifactServiceImple: Successfully " + logger.debug("LoadArtifactServiceImple: Successfully " + "loaded Artifact Clone."); Collection c = CollectionHelper.addArtifact( parent, clone, url, locale); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -3,6 +3,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.utils.XMLUtils; @@ -29,6 +31,10 @@ extends RemoteServiceServlet implements MapInfoService { + private static final Logger logger = + Logger.getLogger(MapInfoServiceImpl.class); + + public static final String XPATH_RIVER = "/mapinfo/river/@name"; @@ -54,25 +60,25 @@ public MapInfo getMapInfo(String url, String locale, String river) throws ServerException { - System.out.println("MapInfoServiceImpl.getMapInfo"); + logger.info("MapInfoServiceImpl.getMapInfo"); Document request = getRequestDocument(river);; HttpClient client = new HttpClientImpl(url, locale); try { - System.out.println("MapInfoServiceImpl.callService"); + logger.debug("MapInfoServiceImpl.callService"); Document result = client.callService(url, "mapinfo", request); if (result == null) { - System.err.println("MapInfo service returned no result."); + logger.warn("MapInfo service returned no result."); throw new ServerException(ERROR_NO_MAPINFO_FOUND); } return getMapInfo(result); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_NO_MAPINFO_FOUND); @@ -80,7 +86,7 @@ public static Document getRequestDocument(String rivername) { - System.out.println("MapInfoServiceImpl.getRequestDocument"); + logger.debug("MapInfoServiceImpl.getRequestDocument"); Document request = XMLUtils.newDocument(); ElementCreator cr = new ElementCreator(request, null, null); @@ -98,7 +104,7 @@ public static MapInfo getMapInfo(Document result) { - System.out.println("MapInfoServiceImpl.getMapInfo"); + logger.debug("MapInfoServiceImpl.getMapInfo"); String river = XMLUtils.xpathString(result, XPATH_RIVER, null); String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -5,6 +5,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.utils.ClientProtocolUtils; @@ -25,10 +27,14 @@ implements MapOutputService { + private static final Logger logger = + Logger.getLogger(MapOutputServiceImpl.class); + + public void doOut(Collection collection, String serverUrl) throws ServerException { - System.out.println("MapOutputServiceImpl.doGet"); + logger.info("MapOutputServiceImpl.doOut"); String uuid = collection.identifier(); @@ -41,15 +47,15 @@ Document response = XMLUtils.parseDocument(is); + logger.debug(XMLUtils.toString(response)); + // TODO parse response document and return a MapConfig object } catch (ConnectionException e) { - e.printStackTrace(); - System.err.println(e.getMessage()); + logger.error(e, e); } catch (IOException ioe) { - ioe.printStackTrace(); - System.err.println(ioe.getMessage()); + logger.error(ioe, ioe); } } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -3,6 +3,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -26,6 +28,10 @@ extends RemoteServiceServlet implements MetaDataService { + private static final Logger logger = + Logger.getLogger(MetaDataServiceImpl.class); + + public static final String ERROR_NO_META_DATA_FOUND = "error_no_meta_data_found"; @@ -39,7 +45,7 @@ String parameters ) throws ServerException { - System.out.println("MetaDataService.getMetaData"); + logger.info("MetaDataService.getMetaData"); Document doc = XMLUtils.newDocument(); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/RemoveArtifactServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/RemoveArtifactServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/RemoveArtifactServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.server; +import org.apache.log4j.Logger; + import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.client.services.RemoveArtifactService; @@ -12,6 +14,10 @@ extends DescribeCollectionServiceImpl implements RemoveArtifactService { + private static final Logger logger = + Logger.getLogger(RemoveArtifactServiceImpl.class); + + public Collection remove( Collection collection, String artifactId, @@ -19,7 +25,7 @@ String locale) throws ServerException { - System.out.println("RemoveArtifactServiceImpl.remove"); + logger.info("RemoveArtifactServiceImpl.remove"); return CollectionHelper.removeArtifact(collection, artifactId, url, locale); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/ReportServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/ReportServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ReportServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -7,6 +7,8 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import org.apache.commons.lang.StringEscapeUtils; @@ -23,6 +25,10 @@ extends RemoteServiceServlet implements ReportService { + private static final Logger logger = + Logger.getLogger(ReportServiceImpl.class); + + @Override public String report( String collectionId, @@ -30,7 +36,7 @@ String locale, String out ) { - System.err.println("report: " + collectionId + " " + out); + logger.info("report: " + collectionId + " " + out); Document request = ClientProtocolUtils.newOutCollectionDocument( collectionId, @@ -43,7 +49,7 @@ in = client.collectionOut(request, collectionId, out); if (in == null) { - System.err.println("report: no report"); + logger.debug("report: no report"); return null; } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -9,6 +9,8 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Node; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -34,6 +36,10 @@ extends RemoteServiceServlet implements RiverService { + private static final Logger logger = + Logger.getLogger(RiverServiceImpl.class); + + /** The XPath string that points to the rivers in the resulting document.*/ public static final String XPATH_RIVERS = "/art:rivers/art:river"; @@ -85,7 +91,7 @@ return (River[]) theRivers.toArray(new River[count]); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_NO_RIVERS_FOUND); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.flys.client.shared.exceptions.ServerException; @@ -16,10 +18,14 @@ extends DoCollectionAction implements SetCollectionNameService { + private static final Logger logger = + Logger.getLogger(SetCollectionNameServiceImpl.class); + + public void setName(Collection c, String url) throws ServerException { - System.out.println("Set name of collection: " + c.identifier()); + logger.info("Set name of collection: " + c.identifier()); String name = c.getName(); Document set = ClientProtocolUtils.newSetCollectionNameDocument(name); diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.flys.client.shared.exceptions.ServerException; @@ -16,13 +18,17 @@ extends DoCollectionAction implements SetCollectionTTLService { + private static final Logger logger = + Logger.getLogger(SetCollectionTTLServiceImpl.class); + + public static final String XPATH_RESULT = "/art:result/text()"; public static final String OPERATION_FAILURE = "FAILED"; public void setTTL(Collection c, String url) throws ServerException { - System.out.println("Set ttl of collection: " + c.identifier()); + logger.info("Set ttl of collection: " + c.identifier()); long ttl = c.getTTL(); String value = null; diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -2,6 +2,8 @@ import org.w3c.dom.Document; +import org.apache.log4j.Logger; + import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.artifacts.common.utils.XMLUtils; @@ -29,6 +31,10 @@ extends AdvanceServiceImpl implements StepForwardService { + private static final Logger logger = + Logger.getLogger(StepForwardServiceImpl.class); + + /** XPath that points to the result type of a feed or advance operation.*/ public static final String XPATH_RESULT = "/art:result/@art:type"; @@ -57,12 +63,12 @@ public Artifact go(String url, String locale, Artifact artifact, Data[] data) throws ServerException { - System.out.println("StepForwardServiceImpl.go"); + logger.info("StepForwardServiceImpl.go"); Artifact afterFeed = feed(url, locale, artifact, data); if (afterFeed == null) { - System.err.println("StepForwardService.feed() - FAILED"); + logger.warn("StepForwardService.feed() - FAILED"); throw new ServerException(ERROR_FEED_DATA); } @@ -70,7 +76,7 @@ String[] reachable = desc.getReachableStates(); if (reachable == null || reachable.length == 0) { - System.out.println("Did not find any reachable state."); + logger.debug("Did not find any reachable state."); return afterFeed; } @@ -97,7 +103,7 @@ Data[] data) throws ServerException { - System.out.println("StepForwardServiceImpl.feed"); + logger.info("StepForwardServiceImpl.feed"); Document feed = ClientProtocolUtils.newFeedDocument( artifact.getUuid(), @@ -115,7 +121,7 @@ new DocumentResponseHandler()); if (description == null) { - System.err.println("StepForwardService.feed() - FAILED"); + logger.warn("StepForwardService.feed() - FAILED"); throw new ServerException(ERROR_FEED_DATA); } @@ -125,7 +131,7 @@ ArtifactNamespaceContext.INSTANCE); if (result == null || !result.equals(OPERATION_FAILURE)) { - System.out.println("StepForwardService.feed() - SUCCESS"); + logger.debug("StepForwardService.feed() - SUCCESS"); return (Artifact) new FLYSArtifactCreator().create(description); } else if (result != null && result.equals(OPERATION_FAILURE)) { @@ -137,10 +143,10 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } - System.err.println("StepForwardService.feed() - FAILED"); + logger.warn("StepForwardService.feed() - FAILED"); throw new ServerException(ERROR_FEED_DATA); } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -10,6 +10,8 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -36,12 +38,16 @@ extends RemoteServiceServlet implements UserCollectionsService { + private static final Logger logger = Logger.getLogger( + UserCollectionsServiceImpl.class); + + public Collection[] getUserCollections( String serverUrl, String locale, String userid) { - System.out.println("UserCollectionsServiceImpl.getUserCollections"); + logger.info("UserCollectionsServiceImpl.getUserCollections"); HttpClient client = new HttpClientImpl(serverUrl, locale); @@ -55,7 +61,7 @@ ArtifactNamespaceContext.INSTANCE); if (list == null || list.getLength() == 0) { - System.out.println("No collection found for user: " + userid); + logger.debug("No collection found for user: " + userid); return null; } @@ -71,15 +77,15 @@ } } - System.out.println("User has " + all.size() + " collections."); + logger.debug("User has " + all.size() + " collections."); return (Collection[]) all.toArray(new Collection[all.size()]); } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } - System.err.println("No user collections found."); + logger.debug("No user collections found."); return null; } @@ -106,12 +112,12 @@ return new DefaultCollection(uuid, ttl, name, new Date(time)); } catch (NumberFormatException nfe) { - System.err.println("Error while parsing collection attributes."); + logger.warn("Error while parsing collection attributes."); return null; } } - System.err.println("Found an invalid Collection."); + logger.warn("Found an invalid Collection."); return null; } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -6,6 +6,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -28,6 +30,9 @@ extends RemoteServiceServlet implements UserService { + private static final Logger logger = Logger.getLogger(UserServiceImpl.class); + + public static final String ERROR_NO_SUCH_USER = "error_no_such_user"; public User getCurrentUser(String serverUrl, String locale) @@ -58,10 +63,10 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } - System.err.println("No users existing in the server."); + logger.error("No users existing in the server."); throw new AuthenticationException(ERROR_NO_SUCH_USER); } } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java Tue Oct 25 12:31:15 2011 +0000 @@ -10,6 +10,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.log4j.Logger; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -32,6 +34,10 @@ extends RemoteServiceServlet implements WQInfoService { + private static final Logger logger = + Logger.getLogger(WQInfoServiceImpl.class); + + public static final String ERROR_NO_WQINFO_FOUND = "error_no_wqinfo_found"; @@ -46,7 +52,7 @@ double to) throws ServerException { - System.out.println("WQInfoServiceImpl.getWQInfo"); + logger.info("WQInfoServiceImpl.getWQInfo"); Document doc = XMLUtils.newDocument(); @@ -75,7 +81,7 @@ try { Document result = client.callService(url, "mainvalues", doc); - System.out.println("Extract wq info objects now."); + logger.debug("Extract wq info objects now."); WQInfoObject[] objects = extractWQInfoObjects(result); if (objects != null && objects.length > 0) { @@ -83,7 +89,7 @@ } } catch (ConnectionException ce) { - System.err.println(ce.getLocalizedMessage()); + logger.error(ce, ce); } throw new ServerException(ERROR_NO_WQINFO_FOUND); @@ -107,13 +113,13 @@ ArtifactNamespaceContext.INSTANCE); if (list == null || list.getLength() == 0) { - System.err.println("No wq info found."); + logger.warn("No wq info found."); throw new ServerException(ERROR_NO_WQINFO_FOUND); } int num = list.getLength(); - System.out.println("Response contains " + num + " objects."); + logger.debug("Response contains " + num + " objects."); List objects = new ArrayList(num); @@ -126,7 +132,7 @@ } } - System.out.println("Retrieved " + objects.size() + " wq values"); + logger.debug("Retrieved " + objects.size() + " wq values"); return (WQInfoObject[]) objects.toArray(new WQInfoObject[num]); @@ -160,11 +166,11 @@ new Double(value)); } catch (NumberFormatException nfe) { - System.err.println(nfe.getLocalizedMessage()); + logger.warn(nfe.getLocalizedMessage()); } } - System.err.println("Invalid wq info object found."); + logger.warn("Invalid wq info object found."); return null; } diff -r d0eb2202ffbe -r ab8eb2f544f2 flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java Tue Oct 25 11:07:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java Tue Oct 25 12:31:15 2011 +0000 @@ -7,6 +7,7 @@ import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; +import org.apache.log4j.Logger; import de.intevation.flys.client.shared.model.DataCageTree; import de.intevation.flys.client.shared.model.DataCageNode; @@ -20,6 +21,9 @@ public class Converter { + private static final Logger logger = Logger.getLogger(Converter.class); + + public interface NodeConverter { DataCageNode convert(Element node, Converter converter); @@ -83,7 +87,7 @@ public static final NodeConverter I18N_CONVERTER = new I18NConverter(); protected void registerConverters() { - System.err.println("register converters called"); + logger.debug("register converters called"); converters.put("river", NAME_CONVERTER); converters.put("gauge", NAME_CONVERTER); converters.put("historical", NAME_CONVERTER); @@ -91,7 +95,7 @@ } public DataCageTree convert(Document document) { - System.err.println("convert called"); + logger.debug("convert called"); //System.err.println(XMLUtils.toString(document)); ArrayList roots = new ArrayList(); @@ -99,7 +103,7 @@ for (int i = 0, N = nodes.getLength(); i < N; ++i) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { - System.err.println("search for name: " + node.getLocalName()); + logger.debug("search for name: " + node.getLocalName()); NodeConverter converter = converters.get(node.getLocalName()); if (converter == null) { converter = I18N_CONVERTER;