All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.bhive.op.ImportObjectOperation Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.bhive.op;

import static io.bdeploy.common.util.RuntimeAssert.assertNotNull;

import java.nio.file.Path;

import io.bdeploy.bhive.BHive;
import io.bdeploy.bhive.audit.AuditParameterExtractor.NoAudit;
import io.bdeploy.bhive.model.ObjectId;
import io.bdeploy.bhive.model.Tree;
import io.bdeploy.bhive.objects.ObjectDatabase;

/**
 * Import a single blob from existing data in memory into the {@link ObjectDatabase}. Useful mainly
 * when building artificial {@link Tree}.
 */
public class ImportObjectOperation extends BHive.TransactedOperation {

    @NoAudit
    private byte[] data;

    @Override
    public ObjectId callTransacted() throws Exception {
        assertNotNull(data, "Data to import not set");
        return getObjectManager().db(x -> x.addObject(data));
    }

    /**
     * Set the {@link Path} to import from. Must be an existing file.
     */
    public ImportObjectOperation setData(byte[] data) {
        this.data = data.clone();
        return this;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy