Search in sources :

Example 21 with NodeVersion

use of com.enonic.xp.node.NodeVersion in project xp by enonic.

the class VersionEntryProcessor method addVersions.

private void addVersions(final EntryLoadResult.Builder result, final VersionsDumpEntry versionsDumpEntry, final Set<VersionMeta> versions) {
    for (final VersionMeta version : versions) {
        final NodeVersion nodeVersion = getVersion(version);
        if (nodeVersion == null) {
            reportVersionError(result, version);
            return;
        }
        try {
            this.nodeService.importNodeVersion(ImportNodeVersionParams.create().nodeId(versionsDumpEntry.getNodeId()).timestamp(version.getTimestamp()).nodePath(version.getNodePath()).nodeVersion(nodeVersion).nodeVersionId(version.getVersion()).nodeCommitId(version.getNodeCommitId()).build());
            validateOrAddBinary(nodeVersion, result);
            result.successful();
        } catch (Exception e) {
            final String message = String.format("Cannot load version with id %s, path %s: %s", versionsDumpEntry.getNodeId(), version.getNodePath(), e.getMessage());
            result.error(EntryLoadError.error(message));
            LOG.error(message, e);
        }
    }
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) VersionMeta(com.enonic.xp.repo.impl.dump.model.VersionMeta) IOException(java.io.IOException) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException)

Example 22 with NodeVersion

use of com.enonic.xp.node.NodeVersion 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)

Example 23 with NodeVersion

use of com.enonic.xp.node.NodeVersion in project xp by enonic.

the class RepositoryIdDumpUpgrader method upgradeNodeVersionBlob.

private void upgradeNodeVersionBlob(final String nodeBlobKey) {
    final DumpBlobRecord dumpBlobRecord = dumpReader.getDumpBlobStore().getRecord(SEGMENT, BlobKey.from(nodeBlobKey));
    final NodeVersionDataJson sourceNodeVersion = getNodeVersion(dumpBlobRecord);
    final NodeVersion updatedNodeVersion = sourceNodeVersion.fromJson().id(NodeId.from(upgradeString(sourceNodeVersion.getId()))).build();
    writeNodeVersion(updatedNodeVersion, dumpBlobRecord);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) NodeVersionDataJson(com.enonic.xp.repo.impl.node.json.NodeVersionDataJson)

Aggregations

NodeVersion (com.enonic.xp.node.NodeVersion)23 Node (com.enonic.xp.node.Node)9 Test (org.junit.jupiter.api.Test)8 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)6 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)6 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeId (com.enonic.xp.node.NodeId)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 InternalContext (com.enonic.xp.repo.impl.InternalContext)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodePath (com.enonic.xp.node.NodePath)3 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 BlobKey (com.enonic.xp.blob.BlobKey)2 BlobRecord (com.enonic.xp.blob.BlobRecord)2 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)2 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)2 MemoryBlobRecord (com.enonic.xp.internal.blobstore.MemoryBlobRecord)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2