private int getClaimantCount(final ContentClaim claim) { if (claim == null) { return 0; } final ResourceClaim resourceClaim = claim.getResourceClaim(); if (resourceClaim == null) { return 0; } return claimManager.getClaimantCount(resourceClaim); }
@Override public boolean isInUse() { // Note that it is critical here that we always check isWritable() BEFORE checking // the claimant count. This is due to the fact that if the claim is in fact writable, the claimant count // could increase. So if we first check claimant count and that is 0, and then we check isWritable, it may be // that the claimant count has changed to 1 before checking isWritable. // However, if isWritable() is false, then the only way that the claimant count can increase is if a FlowFile referencing // the Resource Claim is cloned. In this case, though, the claimant count has not become 0. // Said another way, if isWritable() == false, then the claimant count can never increase from 0. return isWritable() || claimManager.getClaimantCount(this) > 0; } }
@Override public int getClaimantCount(final ContentClaim claim) { if (claim == null) { return 0; } return resourceClaimManager.getClaimantCount(claim.getResourceClaim()); }
private void removeIncompleteContent(final String containerName, final Path containerPath, final Path fileToRemove) { if (Files.isDirectory(fileToRemove)) { final Path lastPathName = fileToRemove.subpath(1, fileToRemove.getNameCount()); final String fileName = lastPathName.toFile().getName(); if (fileName.equals(ARCHIVE_DIR_NAME)) { return; } final File[] children = fileToRemove.toFile().listFiles(); if (children != null) { for (final File child : children) { removeIncompleteContent(containerName, containerPath, child.toPath()); } } return; } final Path relativePath = containerPath.relativize(fileToRemove); final Path sectionPath = relativePath.subpath(0, 1); if (relativePath.getNameCount() < 2) { return; } final Path idPath = relativePath.subpath(1, relativePath.getNameCount()); final String id = idPath.toFile().getName(); final String sectionName = sectionPath.toFile().getName(); final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(containerName, sectionName, id, false, false); if (resourceClaimManager.getClaimantCount(resourceClaim) == 0) { removeIncompleteContent(fileToRemove); } }
@Override public int getClaimantCount(final ContentClaim claim) { if (claim == null) { return 0; } final ContentClaim backupClaim = getBackupClaim(claim); if (backupClaim == null) { return claimManager.getClaimantCount(resolveClaim(claim).getResourceClaim()); } else { return getBackupRepository().getClaimantCount(backupClaim); } }
@Override public boolean isInUse() { // Note that it is critical here that we always check isWritable() BEFORE checking // the claimant count. This is due to the fact that if the claim is in fact writable, the claimant count // could increase. So if we first check claimant count and that is 0, and then we check isWritable, it may be // that the claimant count has changed to 1 before checking isWritable. // However, if isWritable() is false, then the only way that the claimant count can increase is if a FlowFile referencing // the Resource Claim is cloned. In this case, though, the claimant count has not become 0. // Said another way, if isWritable() == false, then the claimant count can never increase from 0. return isWritable() || claimManager.getClaimantCount(this) > 0; } }