Search in sources :

Example 1 with StorageInterface

use of io.kestra.core.storages.StorageInterface in project kestra by kestra-io.

the class Delete method run.

@Override
public Delete.Output run(RunContext runContext) throws Exception {
    StorageInterface storageInterface = runContext.getApplicationContext().getBean(StorageInterface.class);
    URI render = URI.create(runContext.render(this.uri));
    boolean delete = storageInterface.delete(render);
    if (errorOnMissing && !delete) {
        throw new NoSuchElementException("Unable to find file '" + render + "'");
    }
    return Output.builder().uri(render).deleted(delete).build();
}
Also used : StorageInterface(io.kestra.core.storages.StorageInterface) URI(java.net.URI) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with StorageInterface

use of io.kestra.core.storages.StorageInterface in project kestra by kestra-io.

the class PluginScanner method scanClassLoader.

@SuppressWarnings({ "unchecked", "rawtypes" })
private RegisteredPlugin scanClassLoader(final ClassLoader classLoader, ExternalPlugin externalPlugin, Manifest manifest) {
    List<Class<? extends Task>> tasks = new ArrayList<>();
    List<Class<? extends AbstractTrigger>> triggers = new ArrayList<>();
    List<Class<? extends Condition>> conditions = new ArrayList<>();
    List<Class<? extends StorageInterface>> storages = new ArrayList<>();
    List<Class<?>> controllers = new ArrayList<>();
    final SoftServiceLoader<BeanIntrospectionReference> definitions = SoftServiceLoader.load(BeanIntrospectionReference.class, classLoader);
    if (manifest == null) {
        manifest = getManifest(classLoader);
    }
    for (ServiceDefinition<BeanIntrospectionReference> definition : definitions) {
        if (definition.isPresent()) {
            final BeanIntrospectionReference ref = definition.load();
            Class beanType = ref.getBeanType();
            if (Modifier.isAbstract(beanType.getModifiers())) {
                continue;
            }
            if (Task.class.isAssignableFrom(beanType)) {
                tasks.add(beanType);
            }
            if (AbstractTrigger.class.isAssignableFrom(beanType)) {
                triggers.add(beanType);
            }
            if (Condition.class.isAssignableFrom(beanType)) {
                conditions.add(beanType);
            }
            if (StorageInterface.class.isAssignableFrom(beanType)) {
                storages.add(beanType);
            }
            if (beanType.isAnnotationPresent(Controller.class)) {
                controllers.add(beanType);
            }
        }
    }
    return RegisteredPlugin.builder().externalPlugin(externalPlugin).manifest(manifest).classLoader(classLoader).tasks(tasks).triggers(triggers).conditions(conditions).controllers(controllers).storages(storages).build();
}
Also used : Condition(io.kestra.core.models.conditions.Condition) Task(io.kestra.core.models.tasks.Task) BeanIntrospectionReference(io.micronaut.core.beans.BeanIntrospectionReference) ArrayList(java.util.ArrayList) StorageInterface(io.kestra.core.storages.StorageInterface) AbstractTrigger(io.kestra.core.models.triggers.AbstractTrigger)

Example 3 with StorageInterface

use of io.kestra.core.storages.StorageInterface in project kestra by kestra-io.

the class Size method run.

@Override
public Size.Output run(RunContext runContext) throws Exception {
    StorageInterface storageInterface = runContext.getApplicationContext().getBean(StorageInterface.class);
    URI render = URI.create(runContext.render(this.uri));
    Long size = storageInterface.size(render);
    return Output.builder().size(size).build();
}
Also used : StorageInterface(io.kestra.core.storages.StorageInterface) URI(java.net.URI)

Aggregations

StorageInterface (io.kestra.core.storages.StorageInterface)3 URI (java.net.URI)2 Condition (io.kestra.core.models.conditions.Condition)1 Task (io.kestra.core.models.tasks.Task)1 AbstractTrigger (io.kestra.core.models.triggers.AbstractTrigger)1 BeanIntrospectionReference (io.micronaut.core.beans.BeanIntrospectionReference)1 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1