08-13-2015 09:58 AM
Hello,
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">
<filter>.*</filter>
</plugin>
</component>
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);
documentManager.save();
return doc;
}
}
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.