Search in sources :

Example 1 with DocumentEvent

use of org.pentaho.metaverse.impl.DocumentEvent in project pentaho-metaverse by pentaho.

the class LocatorRunner method processFile.

/**
 * Processes the contents of a file. Creates a metaverse document, sets the main properties,
 * and calls the document listeners to parse/process the file.
 *
 * @param namespace The namespace to use for creating ids
 * @param name      The name of the file
 * @param id        The id of the file
 * @param file      The contents of the file
 */
public void processFile(INamespace namespace, String name, String id, Object file) {
    if (stopping) {
        return;
    }
    String extension = FilenameUtils.getExtension(name);
    if ("".equals(extension)) {
        return;
    }
    String mimeType;
    try {
        mimeType = fileNameMap.getContentTypeFor(name);
    } catch (Exception e) {
        mimeType = null;
    // optional attribute, continue...
    }
    try {
        IDocument metaverseDocument = MetaverseUtil.createDocument(namespace, locator.getContents(file), id, name, extension, mimeType);
        DocumentEvent event = new DocumentEvent();
        event.setEventType("add");
        event.setDocument(metaverseDocument);
        locator.notifyListeners(event);
    } catch (Exception e) {
        LOG.error(Messages.getString("ERROR.NoContentForFile", name), e);
    }
}
Also used : DocumentEvent(org.pentaho.metaverse.impl.DocumentEvent) IDocument(org.pentaho.metaverse.api.IDocument)

Aggregations

IDocument (org.pentaho.metaverse.api.IDocument)1 DocumentEvent (org.pentaho.metaverse.impl.DocumentEvent)1