CLI upload-examples failed to delete file under windows

This commit is contained in:
James Agnew 2016-12-05 14:51:59 -05:00
parent ffefb79bf1
commit cfb2c51eab
2 changed files with 43 additions and 36 deletions

View File

@ -287,7 +287,6 @@ public class ExampleDataUploader extends BaseCommand {
}
}
if (subResourceList.size() < 10 && resources.size() > 0) {
subResourceList.add(resources.remove(0));
continue;
@ -357,8 +356,8 @@ public class ExampleDataUploader extends BaseCommand {
Entry next = iterator.next();
// DataElement have giant IDs that seem invalid, need to investigate this..
if ("Subscription".equals(next.getResource().getResourceName()) || "DataElement".equals(next.getResource().getResourceName()) || "OperationOutcome".equals(next.getResource().getResourceName())
|| "OperationDefinition".equals(next.getResource().getResourceName())) {
if ("Subscription".equals(next.getResource().getResourceName()) || "DataElement".equals(next.getResource().getResourceName())
|| "OperationOutcome".equals(next.getResource().getResourceName()) || "OperationDefinition".equals(next.getResource().getResourceName())) {
ourLog.info("Skipping " + next.getResource().getResourceName() + " example");
iterator.remove();
} else {
@ -437,8 +436,8 @@ public class ExampleDataUploader extends BaseCommand {
BundleEntryComponent next = iterator.next();
// DataElement have giant IDs that seem invalid, need to investigate this..
if ("Subscription".equals(next.getResource().getResourceType()) || "DataElement".equals(next.getResource().getResourceType()) || "OperationOutcome".equals(next.getResource().getResourceType())
|| "OperationDefinition".equals(next.getResource().getResourceType())) {
if ("Subscription".equals(next.getResource().getResourceType()) || "DataElement".equals(next.getResource().getResourceType())
|| "OperationOutcome".equals(next.getResource().getResourceType()) || "OperationDefinition".equals(next.getResource().getResourceType())) {
ourLog.info("Skipping " + next.getResource().getResourceType() + " example");
iterator.remove();
} else {
@ -659,37 +658,41 @@ public class ExampleDataUploader extends BaseCommand {
private void downloadFileFromInternet(CloseableHttpResponse result, File localFile) throws IOException {
FileOutputStream buffer = FileUtils.openOutputStream(localFile);
try {
long maxLength = result.getEntity().getContentLength();
long nextLog = -1;
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
while ((nRead = result.getEntity().getContent().read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
long fileSize = FileUtils.sizeOf(localFile);
if (fileSize > nextLog) {
System.err.print("\r" + Ansi.ansi().eraseLine());
System.err.print(FileUtils.byteCountToDisplaySize(fileSize));
if (maxLength > 0) {
System.err.print(" [");
int stars = (int) (50.0f * ((float) fileSize / (float) maxLength));
for (int i = 0; i < stars; i++) {
System.err.print("*");
long maxLength = result.getEntity().getContentLength();
long nextLog = -1;
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
while ((nRead = result.getEntity().getContent().read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
long fileSize = FileUtils.sizeOf(localFile);
if (fileSize > nextLog) {
System.err.print("\r" + Ansi.ansi().eraseLine());
System.err.print(FileUtils.byteCountToDisplaySize(fileSize));
if (maxLength > 0) {
System.err.print(" [");
int stars = (int) (50.0f * ((float) fileSize / (float) maxLength));
for (int i = 0; i < stars; i++) {
System.err.print("*");
}
for (int i = stars; i < 50; i++) {
System.err.print(" ");
}
System.err.print("]");
}
for (int i = stars; i < 50; i++) {
System.err.print(" ");
}
System.err.print("]");
System.err.flush();
nextLog += 100000;
}
System.err.flush();
nextLog += 100000;
}
}
buffer.flush();
buffer.flush();
System.err.println();
System.err.flush();
System.err.println();
System.err.flush();
} finally {
IOUtils.closeQuietly(buffer);
}
}
}

View File

@ -66,6 +66,10 @@
external references (and therefore can't be loaded
by the server). Thanks to Hannes Ulrich for reporting!
</action>
<action type="fix">
HAPI FHIR CLI failed to delete a file when uploading
example resources while running under Windows.
</action>
</release>
<release version="2.1" date="2016-11-11">
<action type="add">