FileManagerService: Override the default importer


I want to create my own File importer, so I did a contribution to the FileManagerService extension. But still my code is not executed the default importer is running.

Here's what I tried:

<?xml version="1.0"?>
<component name="org.nuxeo.project.sample.filemanager">

    <plugin class="org.nuxeo.project.sample.BookFileManagerPlugin" name="DefaultFileImporter" order="1">

public class BookFileManagerPlugin extends AbstractFileImporter {

    private static final long serialVersionUID = 1L;

    public DocumentModel create(CoreSession documentManager, Blob content, String path, boolean overwrite,
            String filename, TypeManager typeService) throws ClientException, IOException {

        String title = FileManagerUtils.fetchTitle(FileManagerUtils.fetchFileName(filename));

        BookTitleService service;
        try {
            service = Framework.getService(BookTitleService.class);
        } catch (Exception e) {
            throw new ClientException(e);

        title = service.correctTitle(title);

        Random random = new Random(new Date().getTime());
        String randomName = String.valueOf(random.nextLong());

        DocumentModel doc = documentManager.createDocumentModel(path, randomName, "Book");
        doc.setPropertyValue("dublincore:title", "Title test");
        doc.setPropertyValue("dublincore:description", filename);
        doc.setProperty("file", "content", content);
        doc = documentManager.createDocument(doc);;

        return doc;

0 votes

0 answers