Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b92e0e2ef0
|
@ -4,4 +4,7 @@
|
|||
|
||||
## Other code changes
|
||||
|
||||
* no changes
|
||||
* Better tracking and reporting of snapshot generation issues
|
||||
* Inclusion of SAXON dependency for processing XSLT
|
||||
* Error message spacing correction
|
||||
* Basic FTPClient implementation
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.dstu2.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -517,7 +517,7 @@ public enum ResourceType {
|
|||
if ("VisionPrescription".equals(code))
|
||||
return VisionPrescription;
|
||||
|
||||
throw new FHIRException("Unknown resource type"+code);
|
||||
throw new FHIRException("Unknown resource type "+code);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.dstu2016may.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -612,7 +612,7 @@ public enum ResourceType {
|
|||
if ("VisionPrescription".equals(code))
|
||||
return VisionPrescription;
|
||||
|
||||
throw new FHIRException("Unknown resource type"+code);
|
||||
throw new FHIRException("Unknown resource type "+code);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -632,7 +632,7 @@ public enum ResourceType {
|
|||
if ("VisionPrescription".equals(code))
|
||||
return VisionPrescription;
|
||||
|
||||
throw new FHIRException("Unknown resource type"+code);
|
||||
throw new FHIRException("Unknown resource type "+code);
|
||||
}
|
||||
|
||||
}
|
|
@ -746,7 +746,7 @@ public enum ResourceType {
|
|||
if ("VisionPrescription".equals(code))
|
||||
return VisionPrescription;
|
||||
|
||||
throw new FHIRException("Unknown resource type"+code);
|
||||
throw new FHIRException("Unknown resource type "+code);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
|
||||
|
||||
|
@ -52,15 +53,16 @@ public class FTPClient {
|
|||
else {
|
||||
clientImpl.connect(server);
|
||||
}
|
||||
//clientImpl.setFileTransferMode(FTP.BINARY_FILE_TYPE);
|
||||
|
||||
clientImpl.login(user, password);
|
||||
|
||||
clientImpl.getSystemType();
|
||||
|
||||
int reply = clientImpl.getReplyCode();
|
||||
|
||||
if(!FTPReply.isPositiveCompletion(reply)) {
|
||||
clientImpl.disconnect();
|
||||
throw new IOException("FTP server refused connection.");
|
||||
throw new IOException("FTP server refused connection. Reply code: " + reply);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +87,20 @@ public class FTPClient {
|
|||
*/
|
||||
public void upload(String source, String path) throws IOException {
|
||||
String resolvedPath = resolveRemotePath(path);
|
||||
FileInputStream localStream = new FileInputStream(new File(source));
|
||||
FileInputStream localStream = new FileInputStream(source);
|
||||
clientImpl.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
clientImpl.storeFile( resolvedPath, localStream);
|
||||
localStream.close();
|
||||
|
||||
int reply = clientImpl.getReplyCode();
|
||||
|
||||
if(!FTPReply.isPositiveCompletion(reply)) {
|
||||
throw new IOException("Error uploading file. Reply code: " + reply);
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() throws IOException {
|
||||
clientImpl.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
@ -11,12 +12,14 @@ import org.mockftpserver.fake.FakeFtpServer;
|
|||
import org.mockftpserver.fake.UserAccount;
|
||||
import org.mockftpserver.fake.filesystem.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class FTPClientTest implements ResourceLoaderTests {
|
||||
|
@ -30,6 +33,7 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
|
||||
public static final String DUMMY_FILE_TO_UPLOAD = "dummyFileToUpload";
|
||||
public static final int FAKE_FTP_PORT = 8021;
|
||||
public static final String DUMMY_FILE_CONTENT = "Dummy file content\nMore content\n";
|
||||
|
||||
|
||||
FakeFtpServer fakeFtpServer;
|
||||
|
@ -47,6 +51,8 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
Path dummyFileToUploadPath;
|
||||
Path dummyUploadedFilePath;
|
||||
|
||||
String dummyFileContent;
|
||||
|
||||
@BeforeAll
|
||||
public void setup() throws IOException {
|
||||
setupDummyFileToUpload();
|
||||
|
@ -55,7 +61,14 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
}
|
||||
|
||||
private void setupDummyFileToUpload() throws IOException {
|
||||
dummyFileContent = createDummyFileContent();
|
||||
|
||||
dummyFileToUploadPath = Files.createTempFile("dummyFtpFileToUpload", "dummy");
|
||||
Files.write(dummyFileToUploadPath, DUMMY_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private String createDummyFileContent() {
|
||||
return DUMMY_FILE_CONTENT;
|
||||
}
|
||||
|
||||
public void setupFakeFtpServer() throws IOException {
|
||||
|
@ -74,6 +87,7 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
fileSystem.add(new FileEntry(dummyFileToDeletePath.toFile().getAbsolutePath()));
|
||||
//fileSystem.add(new FileEntry("c:\\data\\run.exe"));
|
||||
fakeFtpServer.setFileSystem(fileSystem);
|
||||
|
||||
fakeFtpServer.start();
|
||||
}
|
||||
|
||||
|
@ -102,17 +116,11 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
|
||||
FTPClient client = connectToFTPClient();
|
||||
|
||||
|
||||
String deleteFilePath = dummyFileToDeletePath.toFile().getAbsolutePath();
|
||||
|
||||
assertTrue(fakeFtpServer.getFileSystem().exists(deleteFilePath));
|
||||
|
||||
client.delete( RELATIVE_PATH_2 + "/" + DUMMY_FILE_TO_DELETE);
|
||||
|
||||
assertFalse(fakeFtpServer.getFileSystem().exists(deleteFilePath));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -135,6 +143,10 @@ public class FTPClientTest implements ResourceLoaderTests {
|
|||
|
||||
assertTrue(fakeFtpServer.getFileSystem().exists(uploadFilePath));
|
||||
|
||||
FileEntry fileEntry= (FileEntry)fakeFtpServer.getFileSystem().getEntry(uploadFilePath);
|
||||
InputStream inputStream = fileEntry.createInputStream();
|
||||
byte[] bytes = IOUtils.toByteArray(inputStream);
|
||||
String actualContent = new String(bytes, StandardCharsets.UTF_8);
|
||||
assertEquals(DUMMY_FILE_CONTENT,actualContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue