[23/29] incubator-nifi git commit: NIFI-702: Ensure that we always skip to the appropriate location within the ContentClaim when exporting to an external stream or Path

2015-06-21 Thread danbress
NIFI-702: Ensure that we always skip to the appropriate location within the 
ContentClaim when exporting to an external stream or Path


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/a1f04384
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/a1f04384
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/a1f04384

Branch: refs/heads/NIFI-632
Commit: a1f0438451e5893770616e2829a3f4ea034f625f
Parents: cef7206
Author: Mark Payne marka...@hotmail.com
Authored: Fri Jun 19 11:10:11 2015 -0400
Committer: Mark Payne marka...@hotmail.com
Committed: Fri Jun 19 11:10:11 2015 -0400

--
 .../repository/VolatileContentRepository.java   | 30 
 1 file changed, 12 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a1f04384/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
--
diff --git 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
index 5971865..e4fa428 100644
--- 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
+++ 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
@@ -23,7 +23,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -44,11 +43,10 @@ import 
org.apache.nifi.controller.repository.claim.StandardContentClaim;
 import org.apache.nifi.controller.repository.io.ArrayManagedOutputStream;
 import org.apache.nifi.controller.repository.io.MemoryManager;
 import org.apache.nifi.engine.FlowEngine;
+import org.apache.nifi.processor.DataUnit;
 import org.apache.nifi.stream.io.ByteArrayInputStream;
 import org.apache.nifi.stream.io.StreamUtils;
-import org.apache.nifi.processor.DataUnit;
 import org.apache.nifi.util.NiFiProperties;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -372,20 +370,16 @@ public class VolatileContentRepository implements 
ContentRepository {
 return 0L;
 }
 
-if (append) {
-try (final InputStream in = read(claim);
-final OutputStream destinationStream = 
Files.newOutputStream(destination, StandardOpenOption.APPEND)) {
+final StandardOpenOption openOption = append ? 
StandardOpenOption.APPEND : StandardOpenOption.CREATE;
+try (final InputStream in = read(claim);
+final OutputStream destinationStream = 
Files.newOutputStream(destination, openOption)) {
 
-if (offset  0) {
-StreamUtils.skip(in, offset);
-}
-
-StreamUtils.copy(in, destinationStream, length);
-return length;
+if (offset  0) {
+StreamUtils.skip(in, offset);
 }
-} else {
-Files.copy(read(claim), destination, 
StandardCopyOption.REPLACE_EXISTING);
-return Files.size(destination);
+
+StreamUtils.copy(in, destinationStream, length);
+return length;
 }
 }
 
@@ -419,7 +413,7 @@ public class VolatileContentRepository implements 
ContentRepository {
 }
 
 final ContentClaim backupClaim = getBackupClaim(claim);
-return (backupClaim == null) ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
+return backupClaim == null ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
 }
 
 @Override
@@ -429,13 +423,13 @@ public class VolatileContentRepository implements 
ContentRepository {
 }
 
 final ContentClaim backupClaim = getBackupClaim(claim);
-return (backupClaim == null) ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
+return backupClaim == null ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
 }
 
 @Override
 public OutputStream write(final ContentClaim claim) throws IOException {
 final ContentClaim backupClaim = getBackupClaim(claim);
-return (backupClaim == null) ? 

incubator-nifi git commit: NIFI-702: Ensure that we always skip to the appropriate location within the ContentClaim when exporting to an external stream or Path

2015-06-19 Thread markap14
Repository: incubator-nifi
Updated Branches:
  refs/heads/develop cef720679 - a1f043845


NIFI-702: Ensure that we always skip to the appropriate location within the 
ContentClaim when exporting to an external stream or Path


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/a1f04384
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/a1f04384
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/a1f04384

Branch: refs/heads/develop
Commit: a1f0438451e5893770616e2829a3f4ea034f625f
Parents: cef7206
Author: Mark Payne marka...@hotmail.com
Authored: Fri Jun 19 11:10:11 2015 -0400
Committer: Mark Payne marka...@hotmail.com
Committed: Fri Jun 19 11:10:11 2015 -0400

--
 .../repository/VolatileContentRepository.java   | 30 
 1 file changed, 12 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a1f04384/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
--
diff --git 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
index 5971865..e4fa428 100644
--- 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
+++ 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
@@ -23,7 +23,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -44,11 +43,10 @@ import 
org.apache.nifi.controller.repository.claim.StandardContentClaim;
 import org.apache.nifi.controller.repository.io.ArrayManagedOutputStream;
 import org.apache.nifi.controller.repository.io.MemoryManager;
 import org.apache.nifi.engine.FlowEngine;
+import org.apache.nifi.processor.DataUnit;
 import org.apache.nifi.stream.io.ByteArrayInputStream;
 import org.apache.nifi.stream.io.StreamUtils;
-import org.apache.nifi.processor.DataUnit;
 import org.apache.nifi.util.NiFiProperties;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -372,20 +370,16 @@ public class VolatileContentRepository implements 
ContentRepository {
 return 0L;
 }
 
-if (append) {
-try (final InputStream in = read(claim);
-final OutputStream destinationStream = 
Files.newOutputStream(destination, StandardOpenOption.APPEND)) {
+final StandardOpenOption openOption = append ? 
StandardOpenOption.APPEND : StandardOpenOption.CREATE;
+try (final InputStream in = read(claim);
+final OutputStream destinationStream = 
Files.newOutputStream(destination, openOption)) {
 
-if (offset  0) {
-StreamUtils.skip(in, offset);
-}
-
-StreamUtils.copy(in, destinationStream, length);
-return length;
+if (offset  0) {
+StreamUtils.skip(in, offset);
 }
-} else {
-Files.copy(read(claim), destination, 
StandardCopyOption.REPLACE_EXISTING);
-return Files.size(destination);
+
+StreamUtils.copy(in, destinationStream, length);
+return length;
 }
 }
 
@@ -419,7 +413,7 @@ public class VolatileContentRepository implements 
ContentRepository {
 }
 
 final ContentClaim backupClaim = getBackupClaim(claim);
-return (backupClaim == null) ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
+return backupClaim == null ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
 }
 
 @Override
@@ -429,13 +423,13 @@ public class VolatileContentRepository implements 
ContentRepository {
 }
 
 final ContentClaim backupClaim = getBackupClaim(claim);
-return (backupClaim == null) ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
+return backupClaim == null ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
 }
 
 @Override
 public OutputStream write(final ContentClaim claim) throws IOException {
 final ContentClaim