Mercurial > dive4elements > gnv-client
changeset 36:ad381cc47217
Format Code to max 80 Chars per Row
gnv/trunk@172 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Fri Oct 02 08:54:13 2009 +0000 @@ -14,18 +14,19 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactDatabaseActionBase extends Action { protected final static String SUCCSESS_FORWARD_ID = "success"; protected final static String EXCEPTION_FORWARD_ID = "success"; - + /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(ArtifactDatabaseActionBase.class); - + private static Logger log = Logger + .getLogger(ArtifactDatabaseActionBase.class); + /** * Constructor */ @@ -34,7 +35,10 @@ } /** - * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, @@ -44,13 +48,14 @@ ActionForward forward = mapping.findForward(SUCCSESS_FORWARD_ID); return forward; } - + /** * Returns the ExceptionForward for the ArtifactDatabaseActions + * * @param mapping * @return */ - protected ActionForward getExceptionForward (ActionMapping mapping){ + protected ActionForward getExceptionForward(ActionMapping mapping) { log.debug("ArtifactDatabaseActionBase.getExceptionForward"); ActionForward lForward = mapping.findForward(EXCEPTION_FORWARD_ID); return lForward;
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -28,13 +28,14 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ChangeOptionsAction extends ArtifactDatabaseActionBase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(ChangeOptionsAction.class); + /** * Constructor */ @@ -48,51 +49,67 @@ throws Exception { log.debug("NextArtifactStepAction.execute"); try { - SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - + SessionModel sm = SessionModelFactory.getInstance() + .getSessionModel(request); + String target = request.getParameter("target"); OutputMode outputMode = sm.getOutputMode(target); - if (outputMode != null){ - - Collection<OutputParameter> op = outputMode.getOutputParameters(); - if (op != null){ + if (outputMode != null) { + + Collection<OutputParameter> op = outputMode + .getOutputParameters(); + if (op != null) { Iterator<OutputParameter> it = op.iterator(); DiagrammOptions diagrammOptions = new DiagrammOptions(); - while (it.hasNext()){ + while (it.hasNext()) { OutputParameter parameter = it.next(); - diagrammOptions.setValue(parameter.getName(), request.getParameter(parameter.getName())); - + diagrammOptions.setValue(parameter.getName(), request + .getParameter(parameter.getName())); + } sm.setDiagrammOptions(diagrammOptions); } } - + ArtifactDescription ad = sm.getArtifactDescription(); - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); - + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient(); + ArtifactDescription artifactDescription = adc + .getCurrentStepDescription(sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact()); + Node currentUI = artifactDescription.getCurrentUI(); XSLTransformer transformer = new XSLTransformer(); - String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); - + String ui = transformer.transform(new XMLUtils().getNodeXPath( + currentUI, "dynamic"), "UTF-8", request + .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); + request.setAttribute("ui", ui); - - String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); + + String staticUI = transformer + .transform( + new XMLUtils().getNodeXPath(currentUI, "static"), + "UTF-8", + request + .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); request.setAttribute("staticui", staticUI); - request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty())); - - if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){ - }else{ + request.setAttribute("furthertargets", + (ad.getReachableStates() != null && !ad + .getReachableStates().isEmpty())); + + if (ad.getReachableStates() != null + && !ad.getReachableStates().isEmpty()) { + } else { request.setAttribute("diagramm", true); } return super.execute(mapping, form, request, response); } catch (Exception e) { - log.error(e,e); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); return super.getExceptionForward(mapping); } } - - }
--- a/gnv/src/main/java/de/intevation/gnv/action/CommunicationKeys.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/CommunicationKeys.java Fri Oct 02 08:54:13 2009 +0000 @@ -1,8 +1,9 @@ package de.intevation.gnv.action; + /** * * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class CommunicationKeys { /**
--- a/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -10,7 +10,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DoExportAction extends DoOutputAction { @@ -18,7 +18,7 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(DoExportAction.class); - + /** * Constructor */ @@ -32,21 +32,22 @@ log.debug("DoExportAction.setHeaders"); try { super.setHeaders(target, mimeType, response, request); - String fileName = "GNVEXPORT_"+System.currentTimeMillis()+"."; - - if (target.equalsIgnoreCase("chart")){ - fileName = fileName + mimeType.substring(mimeType.indexOf("/")+1); - }else if (target.equalsIgnoreCase("CSV")){ - fileName = fileName +"csv"; - }else{ - fileName = fileName +"txt"; + String fileName = "GNVEXPORT_" + System.currentTimeMillis() + "."; + + if (target.equalsIgnoreCase("chart")) { + fileName = fileName + + mimeType.substring(mimeType.indexOf("/") + 1); + } else if (target.equalsIgnoreCase("CSV")) { + fileName = fileName + "csv"; + } else { + fileName = fileName + "txt"; } - log.debug("FileName for Export: "+fileName); - response.setHeader("Content-Disposition","attachment;filename="+fileName); + log.debug("FileName for Export: " + fileName); + response.setHeader("Content-Disposition", "attachment;filename=" + + fileName); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } - }
--- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -27,7 +27,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DoOutputAction extends ArtifactDatabaseActionBase { @@ -35,6 +35,7 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(DoOutputAction.class); + /** * Constructor */ @@ -42,9 +43,11 @@ super(); } - /** - * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, @@ -54,56 +57,65 @@ try { String target = request.getParameter("target"); String mimeType = request.getParameter("mimetype"); - - log.debug("Target: "+target); - log.debug("MimeType: "+mimeType); - + + log.debug("Target: " + target); + log.debug("MimeType: " + mimeType); + // TODO Check if is propper; - - SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - OutputMode outputMode = sm.getOutputMode(target); - if (outputMode != null && outputMode.getMimeType().equals(mimeType)){ - Collection<OutputParameter> inputParameter =outputMode.getOutputParameters(); + + SessionModel sm = SessionModelFactory.getInstance() + .getSessionModel(request); + OutputMode outputMode = sm.getOutputMode(target); + if (outputMode != null && outputMode.getMimeType().equals(mimeType)) { + Collection<OutputParameter> inputParameter = outputMode + .getOutputParameters(); Collection<InputParameter> ips = null; - if (inputParameter != null){ + if (inputParameter != null) { ips = new ArrayList<InputParameter>(inputParameter.size()); Iterator<OutputParameter> it = inputParameter.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String name = it.next().getName(); String[] values = request.getParameterValues(name); - InputParameter ip = new DefaultInputParameter(name, values); + InputParameter ip = new DefaultInputParameter(name, + values); ips.add(ip); } } - - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - + + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient(); + this.setHeaders(target, mimeType, response, request); - + OutputStream outputStream = response.getOutputStream(); - adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips); - + adc.doOutput(sm.getSelectedArtifactFactory(), sm + .getCurrentArtifact(), outputStream, target, mimeType, + ips); + outputStream.flush(); outputStream.close(); - }else{ - if (outputMode == null){ + } else { + if (outputMode == null) { log.error("Outputmode wird nicht unterstützt."); - }else if (!outputMode.getMimeType().equals(mimeType)){ - log.error("MimeType "+mimeType+" wird nicht unterstützt."); + } else if (!outputMode.getMimeType().equals(mimeType)) { + log.error("MimeType " + mimeType + + " wird nicht unterstützt."); } // TODO FIXME: Fehlerbehandlung } return super.execute(mapping, form, request, response); } catch (Exception e) { - log.error(e,e); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); return super.getExceptionForward(mapping); } } - - protected void setHeaders(String target, String mimeType, HttpServletResponse response, HttpServletRequest request){ + + protected void setHeaders(String target, String mimeType, + HttpServletResponse response, HttpServletRequest request) { response.setHeader("Content-Type", mimeType); } - }
--- a/gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -20,20 +20,24 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class FetchArtifactFactoriesAction extends ArtifactDatabaseActionBase{ +public class FetchArtifactFactoriesAction extends ArtifactDatabaseActionBase { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(FetchArtifactFactoriesAction.class); + private static Logger log = Logger + .getLogger(FetchArtifactFactoriesAction.class); public FetchArtifactFactoriesAction() { super(); } /** - * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, @@ -41,13 +45,18 @@ throws Exception { log.debug("ArtifactDatabaseActionBase.execute"); try { - Collection<ArtifactObject> artifactFactories = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient().getArtifactFactories(); - SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + Collection<ArtifactObject> artifactFactories = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient() + .getArtifactFactories(); + SessionModel sm = SessionModelFactory.getInstance() + .getSessionModel(request); sm.setArtifacteFactories(artifactFactories); return super.execute(mapping, form, request, response); } catch (Exception e) { - log.error(e,e); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); return super.getExceptionForward(mapping); } }
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -29,14 +29,15 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class NextArtifactStepAction extends ArtifactDatabaseActionBase { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class); - + private static Logger log = Logger + .getLogger(SelectArtifactFactoryAction.class); + /** * Constructor */ @@ -45,7 +46,10 @@ } /** - * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, @@ -53,74 +57,117 @@ throws Exception { try { log.debug("NextArtifactStepAction.execute"); - SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + SessionModel sm = SessionModelFactory.getInstance() + .getSessionModel(request); ArtifactDescription ad = sm.getArtifactDescription(); Collection<String> inputParameter = ad.getInputParameter(); Collection<InputParameter> ips = null; - if (inputParameter != null){ + if (inputParameter != null) { ips = new ArrayList<InputParameter>(inputParameter.size()); Iterator<String> it = inputParameter.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String name = it.next(); String[] values = request.getParameterValues(name); InputParameter ip = new DefaultInputParameter(name, values); ips.add(ip); } } - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){ + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient(); + if (ad.getReachableStates() != null + && !ad.getReachableStates().isEmpty()) { // TODO: Woher kommt der zu erreichende Status; String target = null; - if (ad.getReachableStates().size() > 1){ - target = request.getParameter("product"); // TODO HACK for Propducts every other Step has currently only one reachable state. - }else{ + if (ad.getReachableStates().size() > 1) { + target = request.getParameter("product"); // TODO HACK for + // Propducts every + // other Step has + // currently only + // one reachable + // state. + } else { target = ad.getReachableStates().iterator().next(); } - - ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips); - + + ArtifactDescription artifactDescription = adc.doNextStep(sm + .getSelectedArtifactFactory(), sm.getCurrentArtifact(), + target, ips); + Node currentUI = artifactDescription.getCurrentUI(); XSLTransformer transformer = new XSLTransformer(); - String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); - + String ui = transformer + .transform( + new XMLUtils().getNodeXPath(currentUI, + "dynamic"), + "UTF-8", + request + .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); + request.setAttribute("ui", ui); - - String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); + + String staticUI = transformer + .transform( + new XMLUtils() + .getNodeXPath(currentUI, "static"), + "UTF-8", + request + .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); request.setAttribute("staticui", staticUI); - - request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty())); - - }else{ - - adc.doFeed(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), ips); - + + request.setAttribute("furthertargets", + (ad.getReachableStates() != null && !ad + .getReachableStates().isEmpty())); + + } else { + + adc.doFeed(sm.getSelectedArtifactFactory(), sm + .getCurrentArtifact(), ips); + request.setAttribute("diagramm", true); - + // statistic abholen und in das sessionmodell schreiben. - - Collection<ArtifactStatisticValue> statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); + + Collection<ArtifactStatisticValue> statistics = adc + .calculateStatistics(sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact()); sm.setStatistics(statistics); - - ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); - + + ArtifactDescription artifactDescription = adc + .getCurrentStepDescription(sm + .getSelectedArtifactFactory(), sm + .getCurrentArtifact()); + Node currentUI = artifactDescription.getCurrentUI(); XSLTransformer transformer = new XSLTransformer(); - String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); - + String ui = transformer + .transform( + new XMLUtils().getNodeXPath(currentUI, + "dynamic"), + "UTF-8", + request + .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); + request.setAttribute("ui", ui); - - String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); + + String staticUI = transformer + .transform( + new XMLUtils() + .getNodeXPath(currentUI, "static"), + "UTF-8", + request + .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); request.setAttribute("staticui", staticUI); - - request.setAttribute("furthertargets",false); + + request.setAttribute("furthertargets", false); } return super.execute(mapping, form, request, response); } catch (Exception e) { - log.error(e,e); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); return super.getExceptionForward(mapping); } } - }
--- a/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Fri Oct 02 08:54:13 2009 +0000 @@ -23,53 +23,68 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class SelectArtifactFactoryAction extends ArtifactDatabaseActionBase { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class); - + private static Logger log = Logger + .getLogger(SelectArtifactFactoryAction.class); + /** - * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("SelectArtifactFactoryAction.execute"); - String selectedArtifactFactoryID = request.getParameter("artifactFactory"); - log.debug("Selected ArtifactFactory ==> "+selectedArtifactFactoryID); - + String selectedArtifactFactoryID = request + .getParameter("artifactFactory"); + log.debug("Selected ArtifactFactory ==> " + selectedArtifactFactoryID); + try { - SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - Collection<ArtifactObject> artifactFactories = sm.getArtifactFactories(); + SessionModel sm = SessionModelFactory.getInstance() + .getSessionModel(request); + Collection<ArtifactObject> artifactFactories = sm + .getArtifactFactories(); // Löscht die Artifactspezifischen Attribute am Sessionmodel sm.resetModel(); - if (artifactFactories == null || artifactFactories.isEmpty()){ - new FetchArtifactFactoriesAction().execute(mapping, form, request, response); - + if (artifactFactories == null || artifactFactories.isEmpty()) { + new FetchArtifactFactoriesAction().execute(mapping, form, + request, response); + } - + sm.selectArtifactFactory(selectedArtifactFactoryID); - ArtifactObject af = sm.getSelectedArtifactFactory();; - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); + ArtifactObject af = sm.getSelectedArtifactFactory(); + ; + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient(); ArtifactObject artifact = adc.createNewArtifact(af); sm.setCurrentArtifact(artifact); - - ArtifactDescription artifactdescription = adc.getCurrentStepDescription(af, artifact); - + + ArtifactDescription artifactdescription = adc + .getCurrentStepDescription(af, artifact); + XSLTransformer transformer = new XSLTransformer(); - String ui = transformer.transform(artifactdescription.getCurrentUI(), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); - + String ui = transformer.transform(artifactdescription + .getCurrentUI(), "UTF-8", request + .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); + request.setAttribute("ui", ui); - + // return succsess return super.execute(mapping, form, request, response); } catch (Exception e) { - log.error(e,e); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); return super.getExceptionForward(mapping); } }
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Fri Oct 02 08:54:13 2009 +0000 @@ -15,10 +15,9 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class DefaultSessionModel implements SessionModel{ - +public class DefaultSessionModel implements SessionModel { /** * the logger, used to log exceptions and additonaly information @@ -31,15 +30,14 @@ private static final long serialVersionUID = 3431484439985158311L; private Collection<ArtifactObject> artifactFactories = null; - + private ArtifactObject selectedArtifactFactory = null; - - private ArtifactObject currentArtifact =null; - - private DiagrammOptions diagrammOptions= null; - - private Collection<ArtifactStatisticValue> statistics= null; - + + private ArtifactObject currentArtifact = null; + + private DiagrammOptions diagrammOptions = null; + + private Collection<ArtifactStatisticValue> statistics = null; /** * Constructor @@ -52,21 +50,22 @@ * @see de.intevation.gnv.action.sessionmodel.SessionModel#selectArtifactFactory(java.lang.String) */ public void selectArtifactFactory(String artiFactFactoryId) { - Collection<ArtifactObject> artifactObjects = this.getArtifactFactories(); - if (artifactObjects != null){ + Collection<ArtifactObject> artifactObjects = this + .getArtifactFactories(); + if (artifactObjects != null) { Iterator<ArtifactObject> unselect = artifactObjects.iterator(); this.selectedArtifactFactory = null; - while (unselect.hasNext()){ + while (unselect.hasNext()) { unselect.next().setSelected(false); } Iterator<ArtifactObject> it = artifactObjects.iterator(); - while (it.hasNext()){ - ArtifactObject obj = it.next(); - if(obj.getId().equals(artiFactFactoryId)){ - obj.setSelected(true); - this.selectedArtifactFactory = obj; - break; - } + while (it.hasNext()) { + ArtifactObject obj = it.next(); + if (obj.getId().equals(artiFactFactoryId)) { + obj.setSelected(true); + this.selectedArtifactFactory = obj; + break; + } } } } @@ -78,7 +77,7 @@ Collection<ArtifactObject> artifactFactories) { this.artifactFactories = artifactFactories; } - + /** * @see de.intevation.gnv.action.sessionmodel.SessionModel#getAttributeFactories() */ @@ -125,8 +124,8 @@ * @see de.intevation.gnv.action.sessionmodel.SessionModel#getArtifactDescription() */ public ArtifactDescription getArtifactDescription() { - if (this.currentArtifact != null){ - return (ArtifactDescription)this.currentArtifact; + if (this.currentArtifact != null) { + return (ArtifactDescription) this.currentArtifact; } return null; } @@ -136,24 +135,24 @@ */ public OutputMode getOutputMode(String name) { ArtifactDescription ad = this.getArtifactDescription(); - if (ad != null){ - if (ad.getOutputModes() != null){ + if (ad != null) { + if (ad.getOutputModes() != null) { return ad.getOutputModes().get(name); } } return null; } - + /** * @see de.intevation.gnv.action.sessionmodel.SessionModel#resetModel() */ public void resetModel() { log.debug("DefaultSessionModel.resetModel"); this.selectedArtifactFactory = null; - this.currentArtifact =null; - this.diagrammOptions= null; + this.currentArtifact = null; + this.diagrammOptions = null; this.statistics = null; - + } /**
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Fri Oct 02 08:54:13 2009 +0000 @@ -8,19 +8,18 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DiagrammOptions { - private Map<String, String> values = new HashMap<String, String>(); + /** * Constructor */ public DiagrammOptions() { super(); } - /** * @return @@ -28,12 +27,12 @@ public String getValue(String key) { return this.values.get(key); } - + /** * @param width */ public void setValue(String key, String value) { - this.values.put(key, value); + this.values.put(key, value); } } \ No newline at end of file
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Fri Oct 02 08:54:13 2009 +0000 @@ -13,34 +13,34 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface SessionModel extends Serializable{ - +public interface SessionModel extends Serializable { + Collection<ArtifactObject> getArtifactFactories(); - + void setArtifacteFactories(Collection<ArtifactObject> artifactFactories); - + void selectArtifactFactory(String artiFactFactoryId); - + ArtifactObject getSelectedArtifactFactory(); - + ArtifactObject getCurrentArtifact(); - + void setCurrentArtifact(ArtifactObject artifact); - + void setDiagrammOptions(DiagrammOptions diagrammOptions); - + DiagrammOptions getDiagrammOptions(); - + OutputMode getOutputMode(String name); - + ArtifactDescription getArtifactDescription(); - + void resetModel(); - + void setStatistics(Collection<ArtifactStatisticValue> statistics); - + Collection<ArtifactStatisticValue> getStatistics(); }
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java Fri Oct 02 08:54:13 2009 +0000 @@ -9,17 +9,16 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class SessionModelFactory { - + public final static String SESSION_MODEL_ID = "de.intevation.gnv.action.sessionmodel.SessionModel.ID"; /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(SessionModelFactory.class); - /** * The singleton Instance of this Factory. */ @@ -34,33 +33,35 @@ /** * This Method provides an singleton Instance of this Class. + * * @return an singleton Instance of this Class */ - public static SessionModelFactory getInstance(){ - if (instance == null){ + public static SessionModelFactory getInstance() { + if (instance == null) { instance = new SessionModelFactory(); } return instance; } - - + /** * Getting the ArtifactDatabaseClient + * * @return the ArtifactDatabaseClient */ - public SessionModel getSessionModel(HttpServletRequest request){ - synchronized (this.getClass()) { + public SessionModel getSessionModel(HttpServletRequest request) { + synchronized (this.getClass()) { SessionModel sm = null; - if (request.getSession().getAttribute(SESSION_MODEL_ID)!= null){ - sm = (SessionModel)request.getSession().getAttribute(SESSION_MODEL_ID); + if (request.getSession().getAttribute(SESSION_MODEL_ID) != null) { + sm = (SessionModel) request.getSession().getAttribute( + SESSION_MODEL_ID); ; - }else{ + } else { sm = new DefaultSessionModel(); request.getSession().setAttribute(SESSION_MODEL_ID, sm); } - + return sm; - } + } } }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Fri Oct 02 08:54:13 2009 +0000 @@ -14,20 +14,22 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface ArtifactDatabaseClient { - - + public final static String ARTIFACTDATABASE_COUNT_ID = "de.intevation.gnv.artifactdatabase.client.ArtifactDatabase.count"; - + public final static String ARTIFACTDATABASE_URL_ID = "de.intevation.gnv.artifactdatabase.client.ArtifactDatabase.url"; + /** * Return the Artifactfactories which can be resolved. + * * @return the Artifactfactories which can be resolved. * @throws ArtifactDatabaseClientException */ - public Collection<ArtifactObject> getArtifactFactories() throws ArtifactDatabaseClientException; + public Collection<ArtifactObject> getArtifactFactories() + throws ArtifactDatabaseClientException; /** * @@ -35,7 +37,8 @@ * @return the new Artifact * @throws ArtifactDatabaseClientException */ - public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) throws ArtifactDatabaseClientException; + public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) + throws ArtifactDatabaseClientException; /** * @@ -43,8 +46,10 @@ * @return the Current Artifact * @throws ArtifactDatabaseClientException */ - public ArtifactDescription getCurrentStepDescription(ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException; - + public ArtifactDescription getCurrentStepDescription( + ArtifactObject artifactFactory, ArtifactObject currentArtifact) + throws ArtifactDatabaseClientException; + /** * * @param artifactFactory @@ -54,9 +59,11 @@ * @return * @throws ArtifactDatabaseClientException */ - public ArtifactDescription doNextStep(ArtifactObject artifactFactory, ArtifactObject currentArtifact, String target, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException; - - + public ArtifactDescription doNextStep(ArtifactObject artifactFactory, + ArtifactObject currentArtifact, String target, + Collection<InputParameter> inputParameter) + throws ArtifactDatabaseClientException; + /** * @param artifactFactory * @param currentArtifact @@ -64,9 +71,11 @@ * @return * @throws ArtifactDatabaseClientException */ - public void doFeed(ArtifactObject artifactFactory, ArtifactObject currentArtifact, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException; - - + public void doFeed(ArtifactObject artifactFactory, + ArtifactObject currentArtifact, + Collection<InputParameter> inputParameter) + throws ArtifactDatabaseClientException; + /** * * @param artifactFactory @@ -76,13 +85,19 @@ * @param mimeType * @throws ArtifactDatabaseClientException */ - public void doOutput(ArtifactObject artifactFactory, ArtifactObject currentArtifact, OutputStream stream, String targetName, String mimeType, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException; - + public void doOutput(ArtifactObject artifactFactory, + ArtifactObject currentArtifact, OutputStream stream, + String targetName, String mimeType, + Collection<InputParameter> inputParameter) + throws ArtifactDatabaseClientException; + /** * @param artifactFactory * @param currentArtifact * @return * @throws ArtifactDatabaseClientException */ - public Collection<ArtifactStatisticValue> calculateStatistics(ArtifactObject artifactFactory, ArtifactObject currentArtifact)throws ArtifactDatabaseClientException; + public Collection<ArtifactStatisticValue> calculateStatistics( + ArtifactObject artifactFactory, ArtifactObject currentArtifact) + throws ArtifactDatabaseClientException; }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java Fri Oct 02 08:54:13 2009 +0000 @@ -7,18 +7,16 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactDatabaseClientFactory { - - /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(ArtifactDatabaseClientFactory.class); + private static Logger log = Logger + .getLogger(ArtifactDatabaseClientFactory.class); - /** * The singleton Instance of this Factory. */ @@ -33,24 +31,24 @@ /** * This Method provides an singleton Instance of this Class. + * * @return an singleton Instance of this Class */ - public static ArtifactDatabaseClientFactory getInstance(){ - if (instance == null){ + public static ArtifactDatabaseClientFactory getInstance() { + if (instance == null) { instance = new ArtifactDatabaseClientFactory(); } return instance; } - - + /** * Getting the ArtifactDatabaseClient + * * @return the ArtifactDatabaseClient */ - public ArtifactDatabaseClient getArtifactDatabaseClient(){ - //TODO Read from Configuration? + public ArtifactDatabaseClient getArtifactDatabaseClient() { + // TODO Read from Configuration? return new DefaultArtifactDatabaseClient(); } - }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Fri Oct 02 08:54:13 2009 +0000 @@ -43,14 +43,14 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultArtifactDatabaseClient implements ArtifactDatabaseClient { /** * The URI of the namespace of the artifacts. */ public final static String NAMESPACE_URI = "http://www.intevation.de/2009/artifacts"; - + /** * The XML prefix for the artifacts namespace. */ @@ -59,18 +59,19 @@ /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(DefaultArtifactDatabaseClient.class); - + private static Logger log = Logger + .getLogger(DefaultArtifactDatabaseClient.class); + /** * The Databases which could be used */ private static Collection<String> artifactDatabases = null; - + /** * Is the Class initialized? */ private static boolean initialized = false; - + /** * Constructor */ @@ -81,57 +82,67 @@ /** * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getArtifactFactories() */ - public Collection<ArtifactObject> getArtifactFactories() throws ArtifactDatabaseClientException { + public Collection<ArtifactObject> getArtifactFactories() + throws ArtifactDatabaseClientException { Collection<ArtifactObject> resultValues = null; - if (!initialized){ + if (!initialized) { this.initialize(); } try { log.debug("DefaultArtifactDatabaseClient.getArtifactFactories"); Iterator<String> it = artifactDatabases.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String server = it.next(); - String url = server+ "/factories"; + String url = server + "/factories"; Document document = this.doGetRequest(url); - if (resultValues == null){ - resultValues = this.getArtifactFactories(document,server); - }else{ - resultValues.addAll(this.getArtifactFactories(document,server)); + if (resultValues == null) { + resultValues = this.getArtifactFactories(document, server); + } else { + resultValues.addAll(this.getArtifactFactories(document, + server)); } } } catch (IOException e) { - log.error(e,e); + log.error(e, e); } return resultValues; } - private Collection<ArtifactObject> getArtifactFactories(Document document, String server){ + private Collection<ArtifactObject> getArtifactFactories(Document document, + String server) { XMLUtils xmlUtils = new XMLUtils(); - NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, "/result/factories/factory"); - Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>(artifactFactories.getLength()); - if (artifactFactories != null){ - for (int i = 0; i < artifactFactories.getLength(); i++){ - Node artifactFactoryNode = artifactFactories.item(i); - String name = xmlUtils.getStringXPath(artifactFactoryNode, "@name"); - String description = xmlUtils.getStringXPath(artifactFactoryNode, "@description"); - ArtifactFactory artifactFactory = new ArtifactFactory(name, description, server); + NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, + "/result/factories/factory"); + Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( + artifactFactories.getLength()); + if (artifactFactories != null) { + for (int i = 0; i < artifactFactories.getLength(); i++) { + Node artifactFactoryNode = artifactFactories.item(i); + String name = xmlUtils.getStringXPath(artifactFactoryNode, + "@name"); + String description = xmlUtils.getStringXPath( + artifactFactoryNode, "@description"); + ArtifactFactory artifactFactory = new ArtifactFactory(name, + description, server); resultValues.add(artifactFactory); } } return resultValues; } - + /** * @throws IOException */ - private Document doGetRequest(String requestUrl) throws IOException, ArtifactDatabaseClientException { + private Document doGetRequest(String requestUrl) throws IOException, + ArtifactDatabaseClientException { return this.doGetRequest(requestUrl, null); } - + /** * @throws IOException */ - private Document doGetRequest(String requestUrl, Document requestBody) throws IOException, ArtifactDatabaseClientException { + private Document doGetRequest(String requestUrl, Document requestBody) + throws IOException, ArtifactDatabaseClientException { XMLUtils xmlUtils = new XMLUtils(); Representation output = doGetRequestInternal(requestUrl, requestBody); Document document = xmlUtils.readDocument(output.getStream()); @@ -148,9 +159,11 @@ Document requestBody) { Client client = new Client(Protocol.HTTP); Request request = new Request(Method.GET, requestUrl); - if (requestBody != null){ - String documentBody = new XMLUtils().writeDocument2String(requestBody); - Representation representation = new StringRepresentation(documentBody); + if (requestBody != null) { + String documentBody = new XMLUtils() + .writeDocument2String(requestBody); + Representation representation = new StringRepresentation( + documentBody); request.setEntity(representation); } Response response = client.handle(request); @@ -158,11 +171,12 @@ Representation output = response.getEntity(); return output; } - + /** * @throws IOException */ - private InputStream doPostRequest(String requestUrl, Document requestBody) throws IOException { + private InputStream doPostRequest(String requestUrl, Document requestBody) + throws IOException { log.debug("##################################################"); log.debug(new XMLUtils().writeDocument2String(requestBody)); log.debug("##################################################"); @@ -172,22 +186,25 @@ Representation representation = new StringRepresentation(documentBody); request.setEntity(representation); Response response = client.handle(request); - // TODO RESPONSESTATUS AUSWERTEN. + // TODO RESPONSESTATUS AUSWERTEN. Representation output = response.getEntity(); return output.getStream(); } - - private synchronized void initialize(){ - if (!initialized){ - PropertiesReader pr = PropertiesReaderFactory.getInstance().getPropertiesReader(); - int count = Integer.parseInt(pr.getPropertieValue(ARTIFACTDATABASE_COUNT_ID, "0")); + + private synchronized void initialize() { + if (!initialized) { + PropertiesReader pr = PropertiesReaderFactory.getInstance() + .getPropertiesReader(); + int count = Integer.parseInt(pr.getPropertieValue( + ARTIFACTDATABASE_COUNT_ID, "0")); artifactDatabases = new ArrayList<String>(count); - for (int i = 0; i < count ; i++){ - artifactDatabases.add(pr.getPropertieValue(ARTIFACTDATABASE_URL_ID+"."+(i+1), "N/N")); + for (int i = 0; i < count; i++) { + artifactDatabases.add(pr.getPropertieValue( + ARTIFACTDATABASE_URL_ID + "." + (i + 1), "N/N")); } initialized = true; } - + } /** @@ -195,49 +212,46 @@ */ public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) throws ArtifactDatabaseClientException { - + try { - Document request = this.createCreateRequestBody(artifactFactory.getId()); + Document request = this.createCreateRequestBody(artifactFactory + .getId()); Document result = doPostRequest(artifactFactory, request, "create"); return this.getArtifact(result); } catch (IOException e) { - log.error(e,e); + log.error(e, e); throw new ArtifactDatabaseClientException(e); } } - - - private ArtifactObject getArtifact(Document document){ + + private ArtifactObject getArtifact(Document document) { XMLUtils xmlUtils = new XMLUtils(); String uuid = xmlUtils.getStringXPath(document, "/result/uuid/@value"); String hash = xmlUtils.getStringXPath(document, "/result/hash/@value"); - log.info("NEW Artifact: "+uuid+" / "+hash); + log.info("NEW Artifact: " + uuid + " / " + hash); return new Artifact(uuid, hash); } - - - - - private Document createCreateRequestBody(String artifactFactoryName){ + + private Document createCreateRequestBody(String artifactFactoryName) { Document document = new XMLUtils().newDocument(); - Node rootNode = this.createRootNode(document); + Node rootNode = this.createRootNode(document); Element typeNode = this.createArtifactElement(document, "type"); typeNode.setAttribute("name", "create"); rootNode.appendChild(typeNode); - + Element factoyNode = this.createArtifactElement(document, "factory"); factoyNode.setAttribute("name", artifactFactoryName); rootNode.appendChild(factoyNode); - + return document; } - - private Element createRootNode(Document document){ - Element rootNode = this.createArtifactElement(document,"action"); + + private Element createRootNode(Document document) { + Element rootNode = this.createArtifactElement(document, "action"); document.appendChild(rootNode); return rootNode; } - + /** * @param document * @return @@ -255,28 +269,29 @@ * @throws IOException */ private Document doPostRequest(ArtifactObject artifactFactory, - Document request, String suburl) throws IOException, ArtifactDatabaseClientException { + Document request, String suburl) throws IOException, + ArtifactDatabaseClientException { XMLUtils xmlUtils = new XMLUtils(); - String url = ((ArtifactFactory)artifactFactory).getDataBaseUrl(); - InputStream is = this.doPostRequest(url+"/"+suburl, request); + String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl(); + InputStream is = this.doPostRequest(url + "/" + suburl, request); Document result = xmlUtils.readDocument(is); this.check4ExceptionReport(result); return result; } - /** - * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getCurrentStepDescription(de.intevation.gnv.artifactdatabase.objects.ArtifactFactory, de.intevation.gnv.artifactdatabase.objects.ArtifactObject) + * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getCurrentStepDescription(de.intevation.gnv.artifactdatabase.objects.ArtifactFactory, + * de.intevation.gnv.artifactdatabase.objects.ArtifactObject) */ - public ArtifactDescription getCurrentStepDescription(ArtifactObject artifactFactory, - ArtifactObject currentArtifact) + public ArtifactDescription getCurrentStepDescription( + ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException { try { String url = this.getArtifactUrl(artifactFactory, currentArtifact); Document result = this.doGetRequest(url); - return this.readDescription(result,currentArtifact); + return this.readDescription(result, currentArtifact); } catch (IOException e) { - log.error(e,e); + log.error(e, e); throw new ArtifactDatabaseClientException(e); } } @@ -288,120 +303,152 @@ */ private String getArtifactUrl(ArtifactObject artifactFactory, ArtifactObject currentArtifact) { - String url = ((ArtifactFactory)artifactFactory).getDataBaseUrl()+"/artifact/"+ currentArtifact.getId(); + String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl() + + "/artifact/" + currentArtifact.getId(); return url; } - - private ArtifactDescription readDescription(Document document, ArtifactObject artifact) throws ArtifactDatabaseClientException{ - // Check if there was an Error or Exception reported from the ArtifactDatabase + + private ArtifactDescription readDescription(Document document, + ArtifactObject artifact) throws ArtifactDatabaseClientException { + // Check if there was an Error or Exception reported from the + // ArtifactDatabase this.check4ExceptionReport(document); XMLUtils xmlUtils = new XMLUtils(); - if (artifact instanceof ArtifactDescription){ - ArtifactDescription ad = (ArtifactDescription)artifact; - Node uiNode = xmlUtils.getNodeXPath(document, "/result/ui"); - Node outputNode = xmlUtils.getNodeXPath(document, "/result/outputs"); - + if (artifact instanceof ArtifactDescription) { + ArtifactDescription ad = (ArtifactDescription) artifact; + Node uiNode = xmlUtils.getNodeXPath(document, "/result/ui"); + Node outputNode = xmlUtils + .getNodeXPath(document, "/result/outputs"); + Map<String, OutputMode> outputModes = null; - if (outputNode != null){ - NodeList outputModesNodes = xmlUtils.getNodeSetXPath(outputNode, "output"); - if (outputModesNodes != null){ - outputModes = new HashMap<String, OutputMode>(outputModesNodes.getLength()); - for (int i = 0; i < outputModesNodes.getLength(); i++){ + if (outputNode != null) { + NodeList outputModesNodes = xmlUtils.getNodeSetXPath( + outputNode, "output"); + if (outputModesNodes != null) { + outputModes = new HashMap<String, OutputMode>( + outputModesNodes.getLength()); + for (int i = 0; i < outputModesNodes.getLength(); i++) { Node outputModeNode = outputModesNodes.item(i); - String name = xmlUtils.getStringXPath(outputModeNode, "@name"); - String mimeType = xmlUtils.getStringXPath(outputModeNode, "@mime-type"); - - NodeList parameterNodes = xmlUtils.getNodeSetXPath(outputModeNode, "parameter/parameter"); + String name = xmlUtils.getStringXPath(outputModeNode, + "@name"); + String mimeType = xmlUtils.getStringXPath( + outputModeNode, "@mime-type"); + + NodeList parameterNodes = xmlUtils.getNodeSetXPath( + outputModeNode, "parameter/parameter"); Collection<OutputParameter> parameter = null; - if (parameterNodes != null){ - parameter = new ArrayList<OutputParameter>(parameterNodes.getLength()); - for (int j = 0; j < parameterNodes.getLength(); j++){ - Node outputParameterNode = parameterNodes.item(j); - parameter.add(new DefaultOutputParameter(xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@value"),xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@type"))); + if (parameterNodes != null) { + parameter = new ArrayList<OutputParameter>( + parameterNodes.getLength()); + for (int j = 0; j < parameterNodes.getLength(); j++) { + Node outputParameterNode = parameterNodes + .item(j); + parameter.add(new DefaultOutputParameter( + xmlUtils.getStringXPath( + outputParameterNode, "@name"), + xmlUtils.getStringXPath( + outputParameterNode, "@value"), + xmlUtils.getStringXPath( + outputParameterNode, "@name"), + xmlUtils.getStringXPath( + outputParameterNode, "@type"))); } } - outputModes.put(name,new DefaultOutputMode(name, mimeType, parameter)); + outputModes.put(name, new DefaultOutputMode(name, + mimeType, parameter)); } - + } } - - String currentState = xmlUtils.getStringXPath(document, "/result/state/@name"); - NodeList statesList = xmlUtils.getNodeSetXPath(document, "/result/reachable-states/state/@name"); - Collection<String> reachableStates = new ArrayList<String>(statesList.getLength()); - for (int i = 0; i < statesList.getLength(); i++){ + + String currentState = xmlUtils.getStringXPath(document, + "/result/state/@name"); + NodeList statesList = xmlUtils.getNodeSetXPath(document, + "/result/reachable-states/state/@name"); + Collection<String> reachableStates = new ArrayList<String>( + statesList.getLength()); + for (int i = 0; i < statesList.getLength(); i++) { reachableStates.add(statesList.item(i).getNodeValue()); } - - NodeList inputNodes = xmlUtils.getNodeSetXPath(document, "/result/model/input"); - if (inputNodes != null){ - Collection<String> inputParameter = new ArrayList<String>(inputNodes.getLength()); - for (int i = 0; i < inputNodes.getLength(); i++){ + + NodeList inputNodes = xmlUtils.getNodeSetXPath(document, + "/result/model/input"); + if (inputNodes != null) { + Collection<String> inputParameter = new ArrayList<String>( + inputNodes.getLength()); + for (int i = 0; i < inputNodes.getLength(); i++) { Node inputNode = inputNodes.item(i); String name = xmlUtils.getStringXPath(inputNode, "@name"); inputParameter.add(name); } ad.setInputParameter(inputParameter); } - + ad.setOutputModes(outputModes); ad.setCurrentOut(outputNode); ad.setCurrentUI(uiNode); ad.setCurrentState(currentState); ad.setReachableStates(reachableStates); return ad; - }else{ + } else { log.error("Artifact must be Instance of ArtifactDescription"); - throw new ArtifactDatabaseClientException("Artifact must be Instance of ArtifactDescription"); + throw new ArtifactDatabaseClientException( + "Artifact must be Instance of ArtifactDescription"); } - - + } /** - * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doNextStep(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, de.intevation.gnv.artifactdatabase.objects.ArtifactObject, java.lang.String, java.util.Collection) + * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doNextStep(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * java.lang.String, java.util.Collection) */ public ArtifactDescription doNextStep(ArtifactObject artifactFactory, ArtifactObject currentArtifact, String target, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException { - + try { // 1 Feed this.doFeed(artifactFactory, currentArtifact, inputParameter); - // 2 Advance + // 2 Advance String url = this.getArtifactUrl(artifactFactory, currentArtifact); - Document advanceDocument = this.createAdvanceRequestBody(currentArtifact, target); - InputStream advanceResult = this.doPostRequest(url, advanceDocument); - this.check4ExceptionReport(new XMLUtils().readDocument(advanceResult)); + Document advanceDocument = this.createAdvanceRequestBody( + currentArtifact, target); + InputStream advanceResult = this + .doPostRequest(url, advanceDocument); + this.check4ExceptionReport(new XMLUtils() + .readDocument(advanceResult)); // 3 Describe - return this.getCurrentStepDescription(artifactFactory, currentArtifact); + return this.getCurrentStepDescription(artifactFactory, + currentArtifact); } catch (IOException e) { - log.error(e,e); + log.error(e, e); throw new ArtifactDatabaseClientException(e); } } - + private Document createFeedRequestBody(ArtifactObject currentArtifact, - Collection<InputParameter> inputParameter){ + Collection<InputParameter> inputParameter) { Document document = new XMLUtils().newDocument(); - Node rootNode = this.createRootNode(document); - + Node rootNode = this.createRootNode(document); + Element typeNode = this.createArtifactElement(document, "type"); typeNode.setAttribute("name", "feed"); rootNode.appendChild(typeNode); - + Element uuidNode = this.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", currentArtifact.getId()); rootNode.appendChild(uuidNode); - + Element hashNode = this.createArtifactElement(document, "hash"); hashNode.setAttribute("value", currentArtifact.getHash()); rootNode.appendChild(hashNode); - - Node dataNode = this.createParameterNodes(inputParameter, document, "data"); + + Node dataNode = this.createParameterNodes(inputParameter, document, + "data"); rootNode.appendChild(dataNode); - + return document; } @@ -410,19 +457,22 @@ * @param document * @param rootNode */ - private Node createParameterNodes(Collection<InputParameter> inputParameter, Document document, String nodeName) { + private Node createParameterNodes( + Collection<InputParameter> inputParameter, Document document, + String nodeName) { Element dataNode = this.createArtifactElement(document, nodeName); - - if (inputParameter != null){ + + if (inputParameter != null) { Iterator<InputParameter> it = inputParameter.iterator(); - while(it.hasNext()){ + while (it.hasNext()) { InputParameter ip = it.next(); String name = ip.getName(); String[] values = ip.getValues(); - if (values != null){ - for (int i = 0; i < values.length; i++){ + if (values != null) { + for (int i = 0; i < values.length; i++) { String value = values[i]; - Element inputNode = this.createArtifactElement(document, "input"); + Element inputNode = this.createArtifactElement( + document, "input"); inputNode.setAttribute("name", name); inputNode.setAttribute("value", value); dataNode.appendChild(inputNode); @@ -432,30 +482,34 @@ } return dataNode; } - - private Document createAdvanceRequestBody(ArtifactObject currentArtifact, String target){ - Document document = new XMLUtils().newDocument(); - Node rootNode = this.createRootNode(document); - - Element typeNode = this.createArtifactElement(document, "type"); - typeNode.setAttribute("name", "advance"); - rootNode.appendChild(typeNode); - - Element uuidNode = this.createArtifactElement(document, "uuid"); - uuidNode.setAttribute("value", currentArtifact.getId()); - rootNode.appendChild(uuidNode); - - Element hashNode = this.createArtifactElement(document, "hash"); - hashNode.setAttribute("value", currentArtifact.getHash()); - rootNode.appendChild(hashNode); - Element targetNode = this.createArtifactElement(document, "target"); - targetNode.setAttribute("name", target); - rootNode.appendChild(targetNode); - return document; + + private Document createAdvanceRequestBody(ArtifactObject currentArtifact, + String target) { + Document document = new XMLUtils().newDocument(); + Node rootNode = this.createRootNode(document); + + Element typeNode = this.createArtifactElement(document, "type"); + typeNode.setAttribute("name", "advance"); + rootNode.appendChild(typeNode); + + Element uuidNode = this.createArtifactElement(document, "uuid"); + uuidNode.setAttribute("value", currentArtifact.getId()); + rootNode.appendChild(uuidNode); + + Element hashNode = this.createArtifactElement(document, "hash"); + hashNode.setAttribute("value", currentArtifact.getHash()); + rootNode.appendChild(hashNode); + Element targetNode = this.createArtifactElement(document, "target"); + targetNode.setAttribute("name", target); + rootNode.appendChild(targetNode); + return document; } /** - * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doOutput(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, de.intevation.gnv.artifactdatabase.objects.ArtifactObject, java.io.OutputStream, java.lang.String, java.lang.String, java.util.Collection) + * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doOutput(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * java.io.OutputStream, java.lang.String, java.lang.String, + * java.util.Collection) */ public void doOutput(ArtifactObject artifactFactory, ArtifactObject currentArtifact, OutputStream stream, @@ -464,111 +518,131 @@ throws ArtifactDatabaseClientException { try { XMLUtils xmlUtils = new XMLUtils(); - Document requestBody = this.createOutRequestBody(currentArtifact, targetName, mimeType, inputParameter); - - String requestUrl = this.getArtifactUrl(artifactFactory, currentArtifact)+"/"+targetName; - InputStream is = this.doPostRequest( requestUrl, requestBody); - + Document requestBody = this.createOutRequestBody(currentArtifact, + targetName, mimeType, inputParameter); + + String requestUrl = this.getArtifactUrl(artifactFactory, + currentArtifact) + + "/" + targetName; + InputStream is = this.doPostRequest(requestUrl, requestBody); + byte[] b = new byte[4096]; - int i = -1 ; - while ((i = is.read(b)) > 0) - { + int i = -1; + while ((i = is.read(b)) > 0) { stream.write(b, 0, i); } - } catch (IOException e) { - log.error(e,e); + } catch (IOException e) { + log.error(e, e); throw new ArtifactDatabaseClientException(e); } } - - private Document createOutRequestBody(ArtifactObject currentArtifact, String target, String mimeType, Collection<InputParameter> inputParameter){ + + private Document createOutRequestBody(ArtifactObject currentArtifact, + String target, String mimeType, + Collection<InputParameter> inputParameter) { Document document = new XMLUtils().newDocument(); - Node rootNode = this.createRootNode(document); - + Node rootNode = this.createRootNode(document); + Element typeNode = this.createArtifactElement(document, "type"); typeNode.setAttribute("name", "out"); rootNode.appendChild(typeNode); - + Element uuidNode = this.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", currentArtifact.getId()); rootNode.appendChild(uuidNode); - + Element hashNode = this.createArtifactElement(document, "hash"); hashNode.setAttribute("value", currentArtifact.getHash()); rootNode.appendChild(hashNode); - + Element outNode = this.createArtifactElement(document, "out"); outNode.setAttribute("name", target); rootNode.appendChild(outNode); - + Element mimeTypeNode = this.createArtifactElement(document, "out"); mimeTypeNode.setAttribute("value", mimeType); outNode.appendChild(mimeTypeNode); - - Node parameterNode = this.createParameterNodes(inputParameter, document, "params"); + + Node parameterNode = this.createParameterNodes(inputParameter, + document, "params"); outNode.appendChild(parameterNode); - + return document; -} + } /** - * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doFeed(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, de.intevation.gnv.artifactdatabase.objects.ArtifactObject, java.util.Collection) + * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doFeed(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, + * java.util.Collection) */ public void doFeed(ArtifactObject artifactFactory, ArtifactObject currentArtifact, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException { - + try { - Document feedDocument = this.createFeedRequestBody(currentArtifact, inputParameter); + Document feedDocument = this.createFeedRequestBody(currentArtifact, + inputParameter); String url = this.getArtifactUrl(artifactFactory, currentArtifact); InputStream feedResult = this.doPostRequest(url, feedDocument); - Document feedResultDocument = new XMLUtils().readDocument(feedResult); + Document feedResultDocument = new XMLUtils() + .readDocument(feedResult); this.check4ExceptionReport(feedResultDocument); } catch (IOException e) { - log.error(e,e); + log.error(e, e); throw new ArtifactDatabaseClientException(e); } } - - private void check4ExceptionReport(Document document) throws ArtifactDatabaseClientException{ - - String message = new XMLUtils().getStringXPath(document,"/exceptionreport/exception"); - if (message != null){ + + private void check4ExceptionReport(Document document) + throws ArtifactDatabaseClientException { + + String message = new XMLUtils().getStringXPath(document, + "/exceptionreport/exception"); + if (message != null) { throw new ArtifactDatabaseClientException(message); } - + } public Collection<ArtifactStatisticValue> calculateStatistics( - ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException{ - log.debug("DefaultArtifactDatabaseClient.calculateStatistics") ; + ArtifactObject artifactFactory, ArtifactObject currentArtifact) + throws ArtifactDatabaseClientException { + log.debug("DefaultArtifactDatabaseClient.calculateStatistics"); Collection<ArtifactStatisticValue> result; try { result = null; String targetName = "statistics"; - String requestUrl = this.getArtifactUrl(artifactFactory, currentArtifact)+"/"+targetName; - Document requestBody = this.createOutRequestBody(currentArtifact, targetName, "text/xml", null); + String requestUrl = this.getArtifactUrl(artifactFactory, + currentArtifact) + + "/" + targetName; + Document requestBody = this.createOutRequestBody(currentArtifact, + targetName, "text/xml", null); XMLUtils xmlUtils = new XMLUtils(); - InputStream is = this.doPostRequest(requestUrl, requestBody); + InputStream is = this.doPostRequest(requestUrl, requestBody); Document resultDocument = xmlUtils.readDocument(is); - if (resultDocument != null){ - NodeList resultNodes = xmlUtils.getNodeSetXPath(resultDocument, "/statistic-values/statistic"); - if (resultNodes != null){ - result = new ArrayList<ArtifactStatisticValue>(resultNodes.getLength()); - for (int i = 0; i < resultNodes.getLength(); i++){ + if (resultDocument != null) { + NodeList resultNodes = xmlUtils.getNodeSetXPath(resultDocument, + "/statistic-values/statistic"); + if (resultNodes != null) { + result = new ArrayList<ArtifactStatisticValue>(resultNodes + .getLength()); + for (int i = 0; i < resultNodes.getLength(); i++) { Node statisticNode = resultNodes.item(i); - String name = xmlUtils.getStringXPath(statisticNode, "@name"); - String value = xmlUtils.getStringXPath(statisticNode, "@value"); - result.add(new DefaultArtifactStatisticValue(name, value)); + String name = xmlUtils.getStringXPath(statisticNode, + "@name"); + String value = xmlUtils.getStringXPath(statisticNode, + "@value"); + result.add(new DefaultArtifactStatisticValue(name, + value)); } } } } catch (IOException e) { - log.error(e,e); + log.error(e, e); throw new ArtifactDatabaseClientException(e); } - + return result; } }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/exception/ArtifactDatabaseClientException.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/exception/ArtifactDatabaseClientException.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.artifactdatabase.client.exception; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactDatabaseClientException extends Exception { @@ -22,6 +23,7 @@ /** * Constructor + * * @param arg0 */ public ArtifactDatabaseClientException(String arg0) { @@ -30,6 +32,7 @@ /** * Constructor + * * @param arg0 */ public ArtifactDatabaseClientException(Throwable arg0) { @@ -38,6 +41,7 @@ /** * Constructor + * * @param arg0 * @param arg1 */
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Fri Oct 02 08:54:13 2009 +0000 @@ -10,22 +10,22 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class Artifact implements ArtifactObject, ArtifactDescription { private String id = null; private String hash = null; private boolean selected = false; - + private Node currentUI = null; private Node currentOut = null; - + private Collection<String> reachableStates; private Collection<String> inputParameter; - private Map<String,OutputMode> outputModes; + private Map<String, OutputMode> outputModes; private String currentState = null; - + /** * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getCurrentUI() */ @@ -86,7 +86,7 @@ * Constructor */ public Artifact(String uuid, String hash) { - + this.id = uuid; this.hash = hash; } @@ -153,12 +153,12 @@ public Map<String, OutputMode> getOutputModes() { return this.outputModes; } - + /** * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getOutputModesAsCollection() */ public Collection<OutputMode> getOutputModesAsCollection() { - if (this.outputModes != null){ + if (this.outputModes != null) { return this.outputModes.values(); } return null;
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Fri Oct 02 08:54:13 2009 +0000 @@ -10,7 +10,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface ArtifactDescription { @@ -20,12 +20,14 @@ public Node getCurrentUI(); /** - @param currentUI the currentUI to set + * @param currentUI + * the currentUI to set */ public void setCurrentUI(Node currentUI); /** - @param currentOut the currentOut to set + * @param currentOut + * the currentOut to set */ public void setCurrentOut(Node currentOut); @@ -33,8 +35,10 @@ * @return the reachableStates */ public Collection<String> getReachableStates(); + /** - @param reachableStates the reachableStates to set + * @param reachableStates + * the reachableStates to set */ public void setReachableStates(Collection<String> reachableStates); @@ -44,30 +48,31 @@ public String getCurrentState(); /** - @param currentState the currentState to set + * @param currentState + * the currentState to set */ public void setCurrentState(String currentState); - + /** * @return the reachableStates */ public Collection<String> getInputParameter(); - + /** * @param inputParameter */ public void setInputParameter(Collection<String> inputParameter); - + /** * @return the reachableStates */ public Map<String, OutputMode> getOutputModes(); - + /** * @return the reachableStates */ public Collection<OutputMode> getOutputModesAsCollection(); - + /** * @param outputParameter */
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactFactory.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactFactory.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,19 +2,21 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactFactory implements ArtifactObject { private String name = null; - + private String description = null; - - private boolean selected = false; - + + private boolean selected = false; + private String dataBaseUrl = null; + /** * @return the dataBaseUrl */ @@ -22,9 +24,9 @@ return dataBaseUrl; } - /** * Constructor + * * @param name * @param description * @param dataBaseUrl @@ -36,8 +38,6 @@ this.dataBaseUrl = dataBaseUrl; } - - /** * @see de.intevation.gnv.artifactdatabase.objects.ArtifactObject#getId() */ @@ -74,7 +74,6 @@ return description; } - /** * @see de.intevation.gnv.artifactdatabase.objects.ArtifactObject#getHash() */
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactObject.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactObject.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,22 +2,23 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface ArtifactObject { - - + public String getId(); - + public boolean isSelected(); - + public void setSelected(boolean selected); - + public String getName(); + public String getDescription(); - + public String getHash(); }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,14 +2,15 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface ArtifactStatisticValue { - - + String getKey(); + String getValue(); }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,17 +2,16 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class DefaultArtifactStatisticValue implements ArtifactStatisticValue{ +public class DefaultArtifactStatisticValue implements ArtifactStatisticValue { - private String key = null; - + private String value = null; - public DefaultArtifactStatisticValue(String key, String value) { super();
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultInputParameter.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultInputParameter.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,19 +2,20 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultInputParameter implements InputParameter { - private String name = null; - + private String[] values = null; - + /** * Constructor + * * @param name * @param values */
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java Fri Oct 02 08:54:13 2009 +0000 @@ -7,26 +7,24 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultOutputMode implements OutputMode { - private String name = null; - + private String mimeType = null; - + private Collection<OutputParameter> outputParameter = null; public DefaultOutputMode(String name, String mimeType, - Collection<OutputParameter> outputParameter) { + Collection<OutputParameter> outputParameter) { super(); this.name = name; this.mimeType = mimeType; this.outputParameter = outputParameter; } - /** * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getMimeType() */ @@ -40,7 +38,7 @@ public String getName() { return this.name; } - + /** * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getOutputParameters() */
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,28 +2,30 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultOutputParameter implements OutputParameter { - private String name = null; - + private String value = null; - + private String description = null; - + private String type = null; - + /** * Constructor + * * @param name * @param value * @param description */ - public DefaultOutputParameter(String name, String value, String description, String type) { + public DefaultOutputParameter(String name, String value, + String description, String type) { super(); this.name = name; this.value = value;
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/InputParameter.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/InputParameter.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,14 +2,15 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface InputParameter { - + public String getName(); - + public String[] getValues(); }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java Fri Oct 02 08:54:13 2009 +0000 @@ -7,14 +7,14 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface OutputMode { - + public String getName(); - + public String getMimeType(); - - public Collection<OutputParameter > getOutputParameters(); + + public Collection<OutputParameter> getOutputParameters(); }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,16 +2,19 @@ * */ package de.intevation.gnv.artifactdatabase.objects; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface OutputParameter { - - + String getName(); + String getValue(); + String getDescription(); + String getType(); }
--- a/gnv/src/main/java/de/intevation/gnv/propertiesreader/MapPropertiesReader.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/propertiesreader/MapPropertiesReader.java Fri Oct 02 08:54:13 2009 +0000 @@ -9,7 +9,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class MapPropertiesReader implements PropertiesReader { /** @@ -17,7 +17,8 @@ */ private static Logger log = Logger.getLogger(MapPropertiesReader.class); - private Map<String,String> properties = null; + private Map<String, String> properties = null; + /** * Constructor */ @@ -27,11 +28,12 @@ } /** - * @see de.intevation.gnv.propertiesreader.PropertiesReader#getPropertieValue(java.lang.String, java.lang.String) + * @see de.intevation.gnv.propertiesreader.PropertiesReader#getPropertieValue(java.lang.String, + * java.lang.String) */ public String getPropertieValue(String key, String defaultValue) { String value = this.properties.get(key); - if (value == null){ + if (value == null) { value = defaultValue; } return value;
--- a/gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReader.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReader.java Fri Oct 02 08:54:13 2009 +0000 @@ -2,12 +2,13 @@ * */ package de.intevation.gnv.propertiesreader; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface PropertiesReader { - + public String getPropertieValue(String key, String defaultValue); }
--- a/gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReaderFactory.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReaderFactory.java Fri Oct 02 08:54:13 2009 +0000 @@ -11,18 +11,15 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class PropertiesReaderFactory { - - /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(PropertiesReaderFactory.class); - /** * The singleton Instance of this Factory. */ @@ -32,6 +29,7 @@ * The ConnectionPool providing the Connections to the DatabaseBackends */ private PropertiesReader propertiesReader = null; + /** * Constructor */ @@ -41,37 +39,43 @@ /** * This Method provides an singleton Instance of this Class. + * * @return an singleton Instance of this Class */ - public static PropertiesReaderFactory getInstance(){ - if (instance == null){ + public static PropertiesReaderFactory getInstance() { + if (instance == null) { instance = new PropertiesReaderFactory(); } return instance; } - - + /** * Getting the ConnectionPool + * * @return the ConnectionPool */ - public PropertiesReader getPropertiesReader(){ + public PropertiesReader getPropertiesReader() { return this.propertiesReader; } - + /** * Getting the ConnectionPool - * @param config The Config that should be read + * + * @param config + * The Config that should be read */ - public void initPropertiesReader(Object config){ - if (config instanceof ServletConfig){ - this.propertiesReader = new ServletPropertiesReader((ServletConfig)config); - }else if (config instanceof Map){ - this.propertiesReader = new MapPropertiesReader((Map<String, String>)config); - }else{ - log.error("No PropertiesReader for Instance "+ config.getClass().getName()); + public void initPropertiesReader(Object config) { + if (config instanceof ServletConfig) { + this.propertiesReader = new ServletPropertiesReader( + (ServletConfig) config); + } else if (config instanceof Map) { + this.propertiesReader = new MapPropertiesReader( + (Map<String, String>) config); + } else { + log.error("No PropertiesReader for Instance " + + config.getClass().getName()); } - + } }
--- a/gnv/src/main/java/de/intevation/gnv/propertiesreader/ServletPropertiesReader.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/propertiesreader/ServletPropertiesReader.java Fri Oct 02 08:54:13 2009 +0000 @@ -13,7 +13,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ServletPropertiesReader implements PropertiesReader { @@ -22,32 +22,34 @@ */ private static Logger log = Logger.getLogger(ServletPropertiesReader.class); - private Map<String,String> properties = null; + private Map<String, String> properties = null; + /** * Constructor */ public ServletPropertiesReader(ServletConfig config) { super(); log.info("ServletPropertiesReader will be initialized"); - if (config != null){ - + if (config != null) { + Enumeration<String> keys = config.getInitParameterNames(); properties = new HashMap<String, String>(); - while(keys.hasMoreElements()){ + while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = config.getInitParameter(key); - log.info("New ConbfigurationValue; "+ key + " ==> "+ value); + log.info("New ConbfigurationValue; " + key + " ==> " + value); this.properties.put(key, value); } } } /** - * @see de.intevation.gnv.propertiesreader.PropertiesReader#getPropertieValue(java.lang.String, java.lang.String) + * @see de.intevation.gnv.propertiesreader.PropertiesReader#getPropertieValue(java.lang.String, + * java.lang.String) */ public String getPropertieValue(String key, String defaultValue) { String value = this.properties.get(key); - if (value == null){ + if (value == null) { value = defaultValue; } return value;
--- a/gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java Fri Oct 02 08:54:13 2009 +0000 @@ -15,7 +15,7 @@ /** * * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class GNVActionServlet extends ActionServlet { /** @@ -24,12 +24,12 @@ private static Logger log = null; static { - //BasicConfigurator.configure(); - + // BasicConfigurator.configure(); + } - + static String LOGGINIG_CONFIG_FILE_ID = "de.intevation.gnv.servlet.log4j.configuration"; - + /** * The UID of this Class */ @@ -42,13 +42,14 @@ public void init(ServletConfig config) throws ServletException { super.init(config); try { - String path = config.getServletContext().getRealPath("/")+config.getInitParameter(LOGGINIG_CONFIG_FILE_ID); + String path = config.getServletContext().getRealPath("/") + + config.getInitParameter(LOGGINIG_CONFIG_FILE_ID); PropertyConfigurator.configure(path); log = Logger.getLogger(GNVActionServlet.class); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } log.info("PropertiesReader will be configured."); PropertiesReaderFactory.getInstance().initPropertiesReader(config); - } + } }
--- a/gnv/src/main/java/de/intevation/gnv/util/XMLUtils.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/util/XMLUtils.java Fri Oct 02 08:54:13 2009 +0000 @@ -31,25 +31,23 @@ import org.xml.sax.SAXException; /** - * @author Sascha L. Teichmann + * @author Sascha L. Teichmann */ -public class XMLUtils -{ +public class XMLUtils { private static Logger logger = Logger.getLogger(XMLUtils.class); public XMLUtils() { } - public static class ElementCreator - { + public static class ElementCreator { protected Document document; - protected String ns; - protected String prefix; + protected String ns; + protected String prefix; public ElementCreator(Document document, String ns, String prefix) { this.document = document; - this.ns = ns; - this.prefix = prefix; + this.ns = ns; + this.prefix = prefix; } public Element create(String name) { @@ -68,12 +66,9 @@ public Document newDocument() { try { - return DocumentBuilderFactory - .newInstance() - .newDocumentBuilder() - .newDocument(); - } - catch (ParserConfigurationException pce) { + return DocumentBuilderFactory.newInstance().newDocumentBuilder() + .newDocument(); + } catch (ParserConfigurationException pce) { logger.error(pce.getLocalizedMessage(), pce); } return null; @@ -85,7 +80,7 @@ public XPath newXPath(NamespaceContext namespaceContext) { XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); + XPath xpath = factory.newXPath(); if (namespaceContext != null) { xpath.setNamespaceContext(namespaceContext); } @@ -96,18 +91,14 @@ return xpath(root, query, returnTyp, null); } - public final String xpathString( - Object root, String query, NamespaceContext namespaceContext - ) { - return (String)xpath(root, query, XPathConstants.STRING, namespaceContext); + public final String xpathString(Object root, String query, + NamespaceContext namespaceContext) { + return (String) xpath(root, query, XPathConstants.STRING, + namespaceContext); } - public static final Object xpath( - Object root, - String query, - QName returnType, - NamespaceContext namespaceContext - ) { + public static final Object xpath(Object root, String query, + QName returnType, NamespaceContext namespaceContext) { if (root == null) { return null; } @@ -117,17 +108,14 @@ if (xpath != null) { return xpath.evaluate(query, root, returnType); } - } - catch (XPathExpressionException xpee) { + } catch (XPathExpressionException xpee) { logger.error(xpee.getLocalizedMessage(), xpee); } return null; } - - public Object getXPath( - Object root, String query, QName returnType - ) { + + public Object getXPath(Object root, String query, QName returnType) { return xpath(root, query, returnType); } @@ -136,73 +124,70 @@ } public NodeList getNodeSetXPath(Object root, String query) { - return (NodeList)getXPath(root, query, XPathConstants.NODESET); + return (NodeList) getXPath(root, query, XPathConstants.NODESET); } public Node getNodeXPath(Object root, String query) { - return (Node)getXPath(root, query, XPathConstants.NODE); + return (Node) getXPath(root, query, XPathConstants.NODE); } public String getStringXPath(Object root, String xpath) { return getStringXPath(root, xpath, null); } - public String getStringXPath( - Object root, String query, String def - ) { - String s = (String)getXPath(root, query, XPathConstants.STRING); - return s == null || s.length() == 0 - ? def - : s; + public String getStringXPath(Object root, String query, String def) { + String s = (String) getXPath(root, query, XPathConstants.STRING); + return s == null || s.length() == 0 ? def : s; } - - public Document readDocument(InputStream inputStream){ + + public Document readDocument(InputStream inputStream) { Document returnValue = null; try { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory + .newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); - returnValue = docBuilder.parse (inputStream); + returnValue = docBuilder.parse(inputStream); } catch (ParserConfigurationException e) { - logger.error(e,e); + logger.error(e, e); } catch (SAXException e) { - logger.error(e,e); + logger.error(e, e); } catch (IOException e) { - logger.error(e,e); + logger.error(e, e); } return returnValue; } - - public String writeNode2String(Node node){ + + public String writeNode2String(Node node) { try { DOMSource source = new DOMSource(node); return writeDOMSource2String(source); } catch (TransformerConfigurationException e) { - logger.error(e,e); + logger.error(e, e); } catch (TransformerFactoryConfigurationError e) { - logger.error(e,e); + logger.error(e, e); } catch (TransformerException e) { - logger.error(e,e); + logger.error(e, e); } return null; } - - public Document reInitDocument(Document document){ - - StringBufferInputStream inputStream = new StringBufferInputStream(this.writeDocument2String(document)); + + public Document reInitDocument(Document document) { + + StringBufferInputStream inputStream = new StringBufferInputStream(this + .writeDocument2String(document)); return this.readDocument(inputStream); } - - - public String writeDocument2String(Document document){ + + public String writeDocument2String(Document document) { try { DOMSource source = new DOMSource(document); return writeDOMSource2String(source); } catch (TransformerConfigurationException e) { - logger.error(e,e); + logger.error(e, e); } catch (TransformerFactoryConfigurationError e) { - logger.error(e,e); + logger.error(e, e); } catch (TransformerException e) { - logger.error(e,e); + logger.error(e, e); } return null; } @@ -217,10 +202,11 @@ private String writeDOMSource2String(DOMSource source) throws TransformerFactoryConfigurationError, TransformerConfigurationException, TransformerException { - TransformerFactory transformerFactory = TransformerFactory.newInstance(); + TransformerFactory transformerFactory = TransformerFactory + .newInstance(); Transformer transformer = transformerFactory.newTransformer(); StringWriter sw = new StringWriter(); - StreamResult result = new StreamResult(sw); + StreamResult result = new StreamResult(sw); transformer.transform(source, result); return sw.getBuffer().toString(); }
--- a/gnv/src/main/java/de/intevation/gnv/util/XSLTransformer.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/util/XSLTransformer.java Fri Oct 02 08:54:13 2009 +0000 @@ -22,43 +22,46 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class XSLTransformer { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(XSLTransformer.class); + /** * Constructor */ public XSLTransformer() { super(); } - - public String transform(Node toTransform, String encoding, String templateFileName){ + + public String transform(Node toTransform, String encoding, + String templateFileName) { String resultValue = null; - try { - XMLUtils xmlUtils = new XMLUtils(); - Source templateSource = new StreamSource(new File(templateFileName)); - TransformerFactory xformFactory = TransformerFactory.newInstance(); - Transformer transformer = xformFactory.newTransformer(templateSource); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - StreamResult scrResult = new StreamResult(baos); - //log.debug(xmlUtils.writeNode2String(toTransform)); - DOMSource source = new DOMSource(toTransform); - transformer.transform(source, scrResult); - resultValue = new String(baos.toByteArray(),encoding); - } catch (TransformerConfigurationException e) { - log.error(e,e); - } catch (UnsupportedEncodingException e) { - log.error(e,e); - } catch (TransformerFactoryConfigurationError e) { - log.error(e,e); - } catch (TransformerException e) { - log.error(e,e); - } - + try { + XMLUtils xmlUtils = new XMLUtils(); + Source templateSource = new StreamSource(new File(templateFileName)); + TransformerFactory xformFactory = TransformerFactory.newInstance(); + Transformer transformer = xformFactory + .newTransformer(templateSource); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + StreamResult scrResult = new StreamResult(baos); + // log.debug(xmlUtils.writeNode2String(toTransform)); + DOMSource source = new DOMSource(toTransform); + transformer.transform(source, scrResult); + resultValue = new String(baos.toByteArray(), encoding); + } catch (TransformerConfigurationException e) { + log.error(e, e); + } catch (UnsupportedEncodingException e) { + log.error(e, e); + } catch (TransformerFactoryConfigurationError e) { + log.error(e, e); + } catch (TransformerException e) { + log.error(e, e); + } + return resultValue; }
--- a/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java Fri Oct 02 08:54:13 2009 +0000 @@ -21,7 +21,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactDatabaseClientTestCase extends TestCase { @@ -29,13 +29,15 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = null; - - static{ + + static { BasicConfigurator.configure(); log = Logger.getLogger(DefaultArtifactDatabaseClient.class); } + /** * Constructor + * * @param namemessage */ public ArtifactDatabaseClientTestCase(String name) { @@ -49,35 +51,49 @@ protected void setUp() throws Exception { super.setUp(); } - - public void testArtifactDatabaseClient(){ - + + public void testArtifactDatabaseClient() { + try { - ArtifactDatabaseClient artifactDatabaseClient = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - Collection<ArtifactObject> factories = artifactDatabaseClient.getArtifactFactories(); - if (factories != null && !factories.isEmpty()){ + ArtifactDatabaseClient artifactDatabaseClient = ArtifactDatabaseClientFactory + .getInstance().getArtifactDatabaseClient(); + Collection<ArtifactObject> factories = artifactDatabaseClient + .getArtifactFactories(); + if (factories != null && !factories.isEmpty()) { Iterator<ArtifactObject> it = factories.iterator(); - while(it.hasNext()){ + while (it.hasNext()) { ArtifactObject aof = it.next(); - ArtifactObject artifact = artifactDatabaseClient.createNewArtifact(aof); - ArtifactDescription ad = artifactDatabaseClient.getCurrentStepDescription(aof, artifact); + ArtifactObject artifact = artifactDatabaseClient + .createNewArtifact(aof); + ArtifactDescription ad = artifactDatabaseClient + .getCurrentStepDescription(aof, artifact); log.debug("Artifact aktualisert."); XSLTransformer transformer = new XSLTransformer(); - String transformedUI = transformer.transform(ad.getCurrentUI(), "UTF-8",("src/main/webapp/WEB-INF/config/templates/describe-ui.xsl")); + String transformedUI = transformer + .transform( + ad.getCurrentUI(), + "UTF-8", + ("src/main/webapp/WEB-INF/config/templates/describe-ui.xsl")); log.debug(transformedUI); - - Collection<InputParameter> inputParameter = new ArrayList<InputParameter>(1); - inputParameter.add(new DefaultInputParameter("product", new String[]{"timeSeries"})); - ad = artifactDatabaseClient.doNextStep(aof, artifact, "timeSeries",inputParameter); - - transformedUI = transformer.transform(ad.getCurrentUI(), "UTF-8",("src/main/webapp/WEB-INF/config/templates/describe-ui.xsl")); + + Collection<InputParameter> inputParameter = new ArrayList<InputParameter>( + 1); + inputParameter.add(new DefaultInputParameter("product", + new String[] { "timeSeries" })); + ad = artifactDatabaseClient.doNextStep(aof, artifact, + "timeSeries", inputParameter); + + transformedUI = transformer + .transform( + ad.getCurrentUI(), + "UTF-8", + ("src/main/webapp/WEB-INF/config/templates/describe-ui.xsl")); log.debug(transformedUI); } } - - + } catch (ArtifactDatabaseClientException e) { - log.error(e,e); + log.error(e, e); fail(); } }
--- a/gnv/src/test/java/de/intevation/gnv/util/XSLTransformerTestCase.java Fri Oct 02 08:49:18 2009 +0000 +++ b/gnv/src/test/java/de/intevation/gnv/util/XSLTransformerTestCase.java Fri Oct 02 08:54:13 2009 +0000 @@ -17,7 +17,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class XSLTransformerTestCase extends TestCase { @@ -25,12 +25,12 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = null; - - static{ + + static { BasicConfigurator.configure(); log = Logger.getLogger(DefaultArtifactDatabaseClient.class); } - + public XSLTransformerTestCase() { super(); } @@ -39,17 +39,19 @@ super(name); } - - public void testDescribeUI(){ - + public void testDescribeUI() { + try { - //System.setProperty("javax.xml.transform.TransformerFactory","com.icl.saxon.TransformerFactoryImpl"); - Document document = new XMLUtils().readDocument(new FileInputStream(new File("src/test/ressources/describe-ui-test.xml"))); + // System.setProperty("javax.xml.transform.TransformerFactory","com.icl.saxon.TransformerFactoryImpl"); + Document document = new XMLUtils() + .readDocument(new FileInputStream(new File( + "src/test/ressources/describe-ui-test.xml"))); XSLTransformer transformer = new XSLTransformer(); - String value = transformer.transform(document, "UTF-8", "src/main/webapp/WEB-INF/config/templates/describe-ui.xsl"); + String value = transformer.transform(document, "UTF-8", + "src/main/webapp/WEB-INF/config/templates/describe-ui.xsl"); log.debug(value); } catch (FileNotFoundException e) { - log.error(e,e); + log.error(e, e); } } }