use of com.enonic.xp.blob.BlobKey in project xp by enonic.
the class AbstractBlobVacuumCommand method shouldDelete.
private boolean shouldDelete(final Segment segment, final BlobRecord blobRecord) {
if (isOldBlobRecord(blobRecord)) {
result.processed();
if (params.hasListener()) {
params.getListener().processed(1L);
}
final BlobKey blobKey = blobRecord.getKey();
if (!isUsedByVersion(segment, blobKey)) {
if (LOG.isDebugEnabled()) {
LOG.debug("No version found for " + getFieldIndexPath().toString() + " [" + blobKey + "]");
}
result.deleted();
return true;
}
result.inUse();
}
return false;
}
use of com.enonic.xp.blob.BlobKey in project xp by enonic.
the class MemoryBlobStore method addRecord.
@Override
public BlobRecord addRecord(final Segment segment, final ByteSource in) throws BlobStoreException {
final BlobKey key = BlobKey.from(in);
final MemoryBlobRecord record = new MemoryBlobRecord(key, in);
return doStoreRecord(segment, key, record);
}
use of com.enonic.xp.blob.BlobKey in project xp by enonic.
the class IndexAccessSegmentsDumpUpgrader method upgradeVersionDumpEntry.
private Pre6VersionDumpEntryJson upgradeVersionDumpEntry(final RepositoryId repositoryId, final Pre4VersionDumpEntryJson versionDumpEntry) {
// Retrieves the existing node version
final Segment nodeDataSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_NODE_SEGMENT_LEVEL);
final BlobKey nodeBlobKey = BlobKey.from(versionDumpEntry.getBlobKey());
final DumpBlobRecord nodeBlobRecord = dumpReader.getDumpBlobStore().getRecord(nodeDataSegment, nodeBlobKey);
final Pre4NodeVersionJson nodeVersion = getNodeVersion(nodeBlobRecord);
// Serializes the new index config blob
final byte[] serializedIndexConfig = serialize(nodeVersion.getIndexConfigDocument());
final Segment indexConfigSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_INDEX_CONFIG_SEGMENT_LEVEL);
final BlobKey indexConfigBlobKey = addRecord(indexConfigSegment, serializedIndexConfig);
// Serializes the new access control blob
final byte[] serializedAccessControl = serializeAccessControl(nodeVersion);
final Segment accessControlSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_ACCESS_CONTROL_SEGMENT_LEVEL);
final BlobKey accessControlBlobKey = addRecord(accessControlSegment, serializedAccessControl);
// Return the new version dump entry
return Pre6VersionDumpEntryJson.create().nodePath(versionDumpEntry.getNodePath()).timestamp(versionDumpEntry.getTimestamp()).version(versionDumpEntry.getVersion()).nodeBlobKey(versionDumpEntry.getBlobKey()).indexConfigBlobKey(indexConfigBlobKey.toString()).accessControlBlobKey(accessControlBlobKey.toString()).nodeState(versionDumpEntry.getNodeState()).build();
}
use of com.enonic.xp.blob.BlobKey in project xp by enonic.
the class IndexConfigUpgrader method upgradeVersionMeta.
private VersionDumpEntryJson upgradeVersionMeta(final VersionDumpEntryJson version) {
final DumpBlobRecord nodeBlobRecord = dumpReader.getDumpBlobStore().getRecord(NODE_SEGMENT, BlobKey.from(version.getNodeBlobKey()));
final NodeVersionDataJson nodeVersionDataJson = getNode(nodeBlobRecord);
final NodeVersion nodeVersion = nodeVersionDataJson.fromJson().build();
if (ContentConstants.CONTENT_NODE_COLLECTION.equals(nodeVersion.getNodeType())) {
final BlobKey newIndexConfigBlob = upgradeIndexConfigDocument(BlobKey.from(version.getIndexConfigBlobKey()), nodeVersion);
return VersionDumpEntryJson.create(version).indexConfigBlobKey(newIndexConfigBlob.toString()).build();
}
return version;
}
Aggregations