public static final ContentReference fromModelAddress(PathAddress address, byte[] hash) { return new ContentReference(address.toCLIStyleString(), hash); } }
/** {@inheritDoc} */ @Override public File getDeploymentRoot(ContentReference reference) { if (reference == null || reference.getHexHash().isEmpty()) { return deploymentRoot; } File first = new File(deploymentRoot, reference.getHexHash().substring(0,2)); return new File(first, reference.getHexHash().substring(2)); }
DeploymentHandlerUtil.ContentItem addFromHash(ContentReference reference) throws OperationFailedException { if (!contentRepository.syncContent(reference)) { throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContent(reference.getHexHash()); } return new DeploymentHandlerUtil.ContentItem(reference.getHash()); }
/** * Mark content as obsolete. If content was already marked for obsolescenceTimeout ms then it is removed. * * @param ref the content refrence to be marked as obsolete. * * @return true if the content refrence is removed, fale otherwise. */ private boolean markAsObsolete(ContentReference ref) { if (obsoleteContents.containsKey(ref.getHexHash())) { //This content is already marked as obsolete if (obsoleteContents.get(ref.getHexHash()) + obsolescenceTimeout < System.currentTimeMillis()) { DeploymentRepositoryLogger.ROOT_LOGGER.obsoleteContentCleaned(ref.getContentIdentifier()); removeContent(ref); return true; } } else { obsoleteContents.put(ref.getHexHash(), System.currentTimeMillis()); //Mark content as obsolete } return false; }
final Set<ContentReference> references = contentHashReferences.get(reference.getHexHash()); if (references != null) { references.remove(reference); return; contentHashReferences.remove(reference.getHexHash()); if (!HashUtil.isEachHexHashInTable(reference.getHexHash())) { contentPath = Paths.get(reference.getContentIdentifier()); } else { contentPath = getDeploymentContentFile(reference.getHash(), false); if (HashUtil.isEachHexHashInTable(reference.getHexHash()) && this.readWrite) { //Otherwise this is not a deployment content if(!lock(reference.getHash())) { DeploymentRepositoryLogger.ROOT_LOGGER.contentDeletionError(DeploymentRepositoryLogger.ROOT_LOGGER.errorLockingDeployment(), contentPath.toString()); return; DeploymentRepositoryLogger.ROOT_LOGGER.contentDeletionError(ex, contentPath.toString()); } finally { if (HashUtil.isEachHexHashInTable(reference.getHexHash())) { unlock(reference.getHash());
@Override public boolean syncContent(ContentReference reference) { return hasContent(reference.getHash()); }
return Collections.emptyMap(); if (!contentHashReferences.containsKey(fsContent.getHexHash())) { //We have no reference to this content if (markAsObsolete(fsContent)) { cleanedContents.get(DELETED_CONTENT).add(fsContent.getContentIdentifier()); } else { cleanedContents.get(MARKED_CONTENT).add(fsContent.getContentIdentifier()); obsoleteContents.remove(fsContent.getHexHash()); //Remove existing references from obsoleteContents
public static final ContentReference fromModelAddress(PathAddress address, byte[] hash) { return new ContentReference(address.toCLIStyleString(), hash); } }
/** {@inheritDoc} */ @Override public File getDeploymentRoot(ContentReference reference) { if (reference == null || reference.getHexHash().isEmpty()) { return deploymentRoot; } String hex = reference.getHexHash(); File first = new File(deploymentRoot, hex.substring(0,2)); return new File(first, hex.substring(2)); }
DeploymentHandlerUtil.ContentItem addFromHash(ContentReference reference) throws OperationFailedException { if (!contentRepository.syncContent(reference)) { throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContent(reference.getHexHash()); } return new DeploymentHandlerUtil.ContentItem(reference.getHash()); }
private Set<ContentReference> listLocalContents() { Set<ContentReference> localReferences = new HashSet<>(); File[] rootHashes = repoRoot.listFiles(); if (rootHashes != null) { for (File rootHash : rootHashes) { if (rootHash.isDirectory()) { File[] complementaryHashes = rootHash.listFiles(); if (complementaryHashes == null || complementaryHashes.length == 0) { ContentReference reference = new ContentReference(rootHash.getAbsolutePath(), rootHash.getName()); localReferences.add(reference); } else { for (File complementaryHash : complementaryHashes) { String hash = rootHash.getName() + complementaryHash.getName(); ContentReference reference = new ContentReference(complementaryHash.getAbsolutePath(), hash); localReferences.add(reference); } } } } } else { DeploymentRepositoryLogger.ROOT_LOGGER.localContentListError(repoRoot.getAbsolutePath()); } return localReferences; }
@Override public void addContentReference(ContentReference reference) { if(!this.readWrite) { return; } synchronized (contentHashReferences) { Set<ContentReference> references = contentHashReferences.get(reference.getHexHash()); if (references == null) { references = new HashSet<>(); contentHashReferences.put(reference.getHexHash(), references); } references.add(reference); } }
@Override public void deleteDeployment(ContentReference reference) { if (hasContent(reference.getHash())) {//Don't delete referenced content in the back removeContent(reference); } else { localRepository.deleteDeployment(reference); removeContent(reference); } }
public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { byte[] hash = HashUtil.hexStringToByteArray(filePath); return deploymentFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } };
@Override public File getDeploymentRoot(ContentReference reference) { File file = localFileRepository.getDeploymentRoot(reference); if(! file.exists()) { return getFile(reference.getHexHash(), DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT); } return file; }
@Override public void deleteDeployment(ContentReference reference) { if (hasContent(reference.getHash())) {//Don't delete referenced content in the back removeContent(reference); } else { localRepository.deleteDeployment(reference); removeContent(reference); } }
public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { byte[] hash = HashUtil.hexStringToByteArray(filePath); return deploymentFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } };
@Override public File getDeploymentRoot(ContentReference reference) { File file = localFileRepository.getDeploymentRoot(reference); if(! file.exists()) { return getFile(reference.getHexHash(), DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT); } return file; }