Search in sources :

Example 6 with BlobKey

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;
}
Also used : BlobKey(com.enonic.xp.blob.BlobKey)

Example 7 with BlobKey

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);
}
Also used : BlobKey(com.enonic.xp.blob.BlobKey)

Example 8 with BlobKey

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();
}
Also used : Pre4NodeVersionJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4NodeVersionJson) BlobKey(com.enonic.xp.blob.BlobKey) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) Segment(com.enonic.xp.blob.Segment)

Example 9 with BlobKey

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;
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) BlobKey(com.enonic.xp.blob.BlobKey) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) NodeVersionDataJson(com.enonic.xp.repo.impl.node.json.NodeVersionDataJson)

Aggregations

BlobKey (com.enonic.xp.blob.BlobKey)9 Test (org.junit.jupiter.api.Test)3 Segment (com.enonic.xp.blob.Segment)2 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)2 Path (java.nio.file.Path)2 BlobRecord (com.enonic.xp.blob.BlobRecord)1 BlobStore (com.enonic.xp.blob.BlobStore)1 BlobStoreException (com.enonic.xp.blob.BlobStoreException)1 SegmentLevel (com.enonic.xp.blob.SegmentLevel)1 Branch (com.enonic.xp.branch.Branch)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 ValueFactory (com.enonic.xp.data.ValueFactory)1 IndexPath (com.enonic.xp.index.IndexPath)1 Node (com.enonic.xp.node.Node)1 NodeId (com.enonic.xp.node.NodeId)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 NodeService (com.enonic.xp.node.NodeService)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 NodeVersionId (com.enonic.xp.node.NodeVersionId)1