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

io.bdeploy.bhive.objects.AugmentedObjectDatabase 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.objects;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;

import io.bdeploy.bhive.BHiveTransactions;
import io.bdeploy.bhive.model.ObjectId;
import io.bdeploy.common.ActivityReporter;

/**
 * An {@link ObjectDatabase} which can be augmented using an additional {@link ReadOnlyObjectDatabase}.
 * 

* Objects will be consumed first from the {@link ReadOnlyObjectDatabase} and then from the local one. *

* Object will always be added to the local database. *

* Removing an object will either remove it locally or silently do nothing. */ public class AugmentedObjectDatabase extends ObjectDatabase { private final ReadOnlyObjectDatabase augment; public AugmentedObjectDatabase(Path root, Path tmp, ActivityReporter reporter, BHiveTransactions transactions, ReadOnlyObjectDatabase augment) { super(root, tmp, reporter, transactions); this.augment = augment; } @Override public Path getObjectFile(ObjectId id) { if (augment != null && augment.hasObject(id)) { return augment.getObjectFile(id); } return super.getObjectFile(id); } @Override public InputStream getStream(ObjectId id) throws IOException { if (augment != null && augment.hasObject(id)) { return augment.getStream(id); } return super.getStream(id); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy