Skip to content

Commit b351a9d

Browse files
committed
Small fixes
1 parent 2a91adc commit b351a9d

33 files changed

Lines changed: 44 additions & 17233 deletions

EDI-T/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<attribute name="maven.pomderived" value="true"/>
77
</attributes>
88
</classpathentry>
9+
<classpathentry kind="src" path="WebContent"/>
910
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
1011
<attributes>
1112
<attribute name="maven.pomderived" value="true"/>

EDI-T/.settings/org.eclipse.wst.common.component

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
44
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
55
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
6+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/WebContent"/>
67
<property name="java-output-path" value="/EDI-T/build/classes"/>
78
<property name="context-root" value="EDI-T"/>
89
</wb-module>
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<faceted-project>
3-
<runtime name="Apache Tomcat v7.0"/>
4-
<fixed facet="java"/>
5-
<fixed facet="jst.web"/>
6-
<fixed facet="wst.jsdt.web"/>
7-
<installed facet="jst.web" version="3.0"/>
8-
<installed facet="wst.jsdt.web" version="1.0"/>
9-
<installed facet="jst.jaxrs" version="1.1"/>
10-
<installed facet="java" version="1.6"/>
3+
<installed facet="cloudfoundry.standalone.app" version="1.0"/>
114
</faceted-project>

EDI-T/application.properties

Lines changed: 0 additions & 22 deletions
This file was deleted.

EDI-T/demo/application.properties

Lines changed: 0 additions & 26 deletions
This file was deleted.

EDI-T/demo/edi.jar

-75.5 MB
Binary file not shown.

EDI-T/demo/edi.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

EDI-T/src/it/cnr/irea/ediT/XsltService.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
import java.io.InputStream;
77
import java.io.OutputStream;
88
import java.io.UnsupportedEncodingException;
9+
import java.net.InetSocketAddress;
910
import java.net.MalformedURLException;
11+
import java.net.Socket;
12+
import java.net.SocketException;
1013
import java.net.URL;
14+
import java.net.URLConnection;
1115
import java.util.ArrayList;
1216
import java.util.HashMap;
1317
import java.util.List;
@@ -83,6 +87,17 @@ public byte[] transform(byte[] xslt, byte[] xml, HashMap<String, String> paramet
8387
return outStream.toByteArray();
8488
}
8589

90+
public boolean pingHost(String host, int port, int timeout) {
91+
try (Socket socket = new Socket()) {
92+
InetSocketAddress address = new InetSocketAddress(host, port);
93+
log.info("pinging " + address.getAddress().getHostAddress());
94+
socket.connect(address, timeout);
95+
return true;
96+
} catch (IOException e) {
97+
return false; // Either timeout or unreachable or failed DNS lookup.
98+
}
99+
}
100+
86101
/*
87102
* @param xslt URL of XSLT file or XSLT text
88103
* @param xml URL of XML file or XML text
@@ -102,8 +117,16 @@ public byte[] transform(String xslt, String xml, HashMap<String, String> paramet
102117
try {
103118
// if it qualifies as a URL open a URL stream
104119
URL xsltUrl = new URL(xslt);
120+
if ( pingHost(xsltUrl.getHost(), 80, 100) ) {
121+
log.info("PING succeeded");
122+
} else {
123+
log.severe("PING FAILED");
124+
}
125+
log.info("xslt URL '" + xsltUrl.toExternalForm() + "'");
126+
URLConnection conn = xsltUrl.openConnection();
127+
conn.connect();
128+
log.info("xslt contains: " + conn.getContent());
105129
xsltStream = xsltUrl.openStream();
106-
log.info("xslt from " + xslt);
107130
} catch(MalformedURLException e) {
108131
// otherwise treat it as a byte array
109132
xsltStream = new ByteArrayInputStream(xslt.getBytes());

EDI-T/src/it/cnr/irea/ediT/rest/RestBase.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,17 @@ public ResponseEntity<PostMetadataResponse> postMetadataNG(HttpServletRequest re
180180
log.info("xsltChain is correctly defined in EDIML");
181181
String xmlTemp = new String(document.xmlUTF8String(xmlDoc), "utf-8");
182182
for ( XsltUrl xslt : elementList.getXsltChain() ) {
183-
if ( xslt.getXslt() != null ) {
184-
log.info("xmlTemp: ");
185-
log.info(xmlTemp);
183+
if ( xslt != null ) {
184+
if ( xslt.getXslt() != null ) {
185+
log.severe("Transforming result with " + xslt.getXslt());
186+
log.info("xmlTemp: ");
187+
log.info(xmlTemp);
186188

187-
log.info("Transforming result with " + xslt.getXslt());
188-
byte[] result = xsltService.transform(xslt.getXslt(), xmlTemp , (HashMap<String, String>) null);
189-
xmlTemp = new String(result, "utf-8");
189+
byte[] result = xsltService.transform(xslt.getXslt(), xmlTemp , (HashMap<String, String>) null);
190+
xmlTemp = new String(result, "utf-8");
191+
}
192+
} else {
193+
log.severe("XSLT is NULL!!!");
190194
}
191195
}
192196
document.setOutput(service.loadXMLFromString(xmlTemp));

EDI-T/src/main/resources/application.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
1313
spring.data.rest.baseUri=edi
1414
spring.data.rest.base-uri=edi
1515

16-
server.port=8081
16+
server.port=8080
17+

0 commit comments

Comments
 (0)