Ingest from Cloud

Create custom endpoints to ingest content into Visallo. A long-running process will process the loading of content asynchronously. Plugins must register a CloudResourceSource service that returns a CloudResourceItem (or multiple) given a JSON configuration object generated by a custom component in the UI.

Cloud import items are available in the file import popover.

Tutorial

For this tutorial we'll build a new URL cloud ingest plugin. The user will supply a URL (to a document, image, etc.) to import into Visallo.

Web Plugin Resources

Register the plugin and configuration component, along with a message bundle.

public void init(WebApp app, ServletContext servletContext, Handler authenticationHandler) {
    app.registerJavaScript("/org/visallo/examples/ingest_cloud/plugin.js", true);

    app.registerJavaScriptComponent("/org/visallo/examples/ingest_cloud/UrlConfig.jsx");

    app.registerResourceBundle("/org/visallo/examples/ingest_cloud/messages.properties");
}

Register Extension

require(['public/v1/api'], function(visallo) {

    visallo.registry.registerExtension('org.visallo.ingest.cloud', {
        identifier: 'org.visallo.examples.ingest_cloud.UrlIngestCloudResourceSource',
        componentPath: 'org/visallo/examples/ingest_cloud/UrlConfig'
    });

});

React Configuration Component

Now, create the React component interface to specify a URL to ingest.

const UrlConfig = React.createClass({

Call the onImport when the user clicks import.

onImport() {
    const { url } = this.state;
    this.props.onImport({ paths: [url] });
}

Create the CloudResourceSource

Create the Java class, and register as a service in META-INF/services. The full Java class should match the identifier defined in the extension.

public class UrlIngestCloudResourceSource implements CloudResourceSource {

    @Override
    public Collection<CloudResourceSourceItem> getItems(JSONObject jsonObject) {

        Collection<CloudResourceSourceItem> items = new ArrayList<>();

        JSONArray paths = jsonObject.getJSONArray("paths");
        String url = paths.optString(0);
        items.add(itemForUrl(url));

        return items;
    }

org.visallo.examples.ingest_cloud.UrlIngestCloudResourceSource

Message Bundle

The interface needs some message keys for the component, and an implicit title based on the identifier.

org.visallo.examples.ingest_cloud.placeholder=URL to Import...
org.visallo.examples.ingest_cloud.button=Import
org.visallo.examples.ingest_cloud.UrlIngestCloudResourceSource.title=URL

Flight Component Example

Legacy plugins written in Flight should trigger a cloudImported event with the configuration.

For example:

this.trigger('cloudImported', { paths: [url] })

results matching ""

    No results matching ""