# HG changeset patch # User Tim Englich # Date 1257432804 0 # Node ID 013d47662161d8679fb13a33b244f09d8d0c4c66 # Parent aa5197b3f9304125beffb29c49bfe0950bac36bc Switched the Communication for Describe-Calls to the artifact-database from get to post. Added the possibility to tell the artifact-database that the ui should not be delivered in describe-responses. gnv/trunk@285 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r aa5197b3f930 -r 013d47662161 gnv/ChangeLog --- a/gnv/ChangeLog Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/ChangeLog Thu Nov 05 14:53:24 2009 +0000 @@ -1,3 +1,20 @@ +2009-11-05 Tim Englich + + * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java (ArtifactDatabaseClientFactory): + Removed some deprecatde TODO-Tasks. + * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java (getCurrentStepDescription): + Changed the Describe-Call of an Artifact from get to post an add the Flag which + determines if the UI should be delivered to the client. + * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java (getCurrentStepDescription): + Added the possibility to put an Flag which determines if the UI should be delivered from + the artifact-database to the Metodsignature. + + * src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java (execute), + src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute), + src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java (execute), + src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java (testArtifactDatabaseClient): + Added the Flag if the UI should be delivered by the artifact-database to the Method-Call. + 2009-10-28 Tim Englich * src/main/resources/applicationMessages*.properties: diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Thu Nov 05 14:53:24 2009 +0000 @@ -78,7 +78,8 @@ ArtifactDescription artifactDescription = adc .getCurrentStepDescription(sm.getSelectedArtifactFactory(), - sm.getCurrentArtifact()); + sm.getCurrentArtifact(), + true); Node currentUI = artifactDescription.getCurrentUI(); XSLTransformer transformer = new XSLTransformer(); diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Thu Nov 05 14:53:24 2009 +0000 @@ -146,7 +146,8 @@ artifactDescription = adc .getCurrentStepDescription(sm .getSelectedArtifactFactory(), sm - .getCurrentArtifact()); + .getCurrentArtifact(), + true); request.setAttribute("diagramm", true); diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Thu Nov 05 14:53:24 2009 +0000 @@ -70,7 +70,7 @@ sm.setCurrentArtifact(artifact); ArtifactDescription artifactdescription = adc - .getCurrentStepDescription(af, artifact); + .getCurrentStepDescription(af, artifact,true); XSLTransformer transformer = new XSLTransformer(); String ui = transformer.transform(artifactdescription diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Thu Nov 05 14:53:24 2009 +0000 @@ -39,7 +39,7 @@ * @throws ArtifactDatabaseClientException */ public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) - throws ArtifactDatabaseClientException; + throws ArtifactDatabaseClientException; /** * @@ -49,8 +49,9 @@ */ public ArtifactDescription getCurrentStepDescription( ArtifactObject artifactFactory, - ArtifactObject currentArtifact) - throws ArtifactDatabaseClientException; + ArtifactObject currentArtifact, + boolean includeUI) + throws ArtifactDatabaseClientException; /** * diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java Thu Nov 05 14:53:24 2009 +0000 @@ -49,7 +49,6 @@ * @return the ArtifactDatabaseClient */ public ArtifactDatabaseClient getArtifactDatabaseClient(Locale locale) { - // TODO Read from Configuration? DefaultArtifactDatabaseClient adc = new DefaultArtifactDatabaseClient(); adc.setLocale(locale); return adc; diff -r aa5197b3f930 -r 013d47662161 gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Thu Nov 05 14:53:24 2009 +0000 @@ -324,17 +324,46 @@ */ public ArtifactDescription getCurrentStepDescription( ArtifactObject artifactFactory, - ArtifactObject currentArtifact) - throws ArtifactDatabaseClientException { + ArtifactObject currentArtifact, + boolean includeUI) + throws ArtifactDatabaseClientException { try { String url = this.getArtifactUrl(artifactFactory, currentArtifact); - Document result = this.doGetRequest(url); - return this.readDescription(result, currentArtifact); + Document request = this.createDescribeRequestBody(currentArtifact, + includeUI); + InputStream describeResult = this.doPostRequest(url, request); + + return this.readDescription(new XMLUtils().readDocument(describeResult), + currentArtifact); } catch (IOException e) { log.error(e, e); throw new ArtifactDatabaseClientException(e); } } + + + private Document createDescribeRequestBody(ArtifactObject currentArtifact, + boolean includeUI){ + + Document document = new XMLUtils().newDocument(); + Node rootNode = this.createRootNode(document); + + Element typeNode = this.createArtifactElement(document, "type"); + typeNode.setAttribute("name", "describe"); + 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 includeUINode = this.createArtifactElement(document, "include-ui"); + includeUINode.appendChild(document.createTextNode(""+includeUI)); + rootNode.appendChild(includeUINode); + return document; + } /** * @param artifactFactory @@ -454,7 +483,15 @@ try { // 1 Feed this.doFeed(artifactFactory, currentArtifact, inputParameter); - // 2 Advance + + // 2. Noch einmal Describe um das jetzt zu erreichende Ziel zu ermitteln + ArtifactDescription ad = this.getCurrentStepDescription(artifactFactory, + new Artifact(currentArtifact.getId(), + currentArtifact.getHash()), + false); + target = ad.getReachableStates().iterator().next(); + + // 3 Advance String url = this.getArtifactUrl(artifactFactory, currentArtifact); Document advanceDocument = this.createAdvanceRequestBody( currentArtifact, target); @@ -464,7 +501,7 @@ .readDocument(advanceResult)); // 3 Describe return this.getCurrentStepDescription(artifactFactory, - currentArtifact); + currentArtifact,true); } catch (IOException e) { log.error(e, e); throw new ArtifactDatabaseClientException(e); diff -r aa5197b3f930 -r 013d47662161 gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java --- a/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java Wed Oct 28 09:52:03 2009 +0000 +++ b/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java Thu Nov 05 14:53:24 2009 +0000 @@ -67,7 +67,7 @@ ArtifactObject artifact = artifactDatabaseClient .createNewArtifact(aof); ArtifactDescription ad = artifactDatabaseClient - .getCurrentStepDescription(aof, artifact); + .getCurrentStepDescription(aof, artifact,true); log.debug("Artifact aktualisert."); XSLTransformer transformer = new XSLTransformer(); String transformedUI = transformer