Class AbstractFileImporter
- java.lang.Object
-
- org.nuxeo.ecm.platform.filemanager.service.extension.AbstractFileImporter
-
- All Implemented Interfaces:
Serializable,Comparable<FileImporter>,FileImporter
- Direct Known Subclasses:
AudioImporter,CSVZipImporter,DefaultFileImporter,ExportedZipImporter,ImagePlugin,NoteImporter,ThreeDImporter,VideoImporter
public abstract class AbstractFileImporter extends Object implements FileImporter
File importer abstract class.Default file importer behavior.
- Author:
- Andreas Kalogeropolos
- See Also:
FileImporter, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDISABLE_AUDIT_LOGGERDeprecated.since 2021.34, useCoreSession.DISABLE_AUDIT_LOGGERinsteadprotected StringdocTypeprotected booleanenabledprotected FileManagerServicefileManagerServiceDeprecated.since 10.3, useFramework.getService(Class)instead if neededprotected List<String>filtersprotected Stringnameprotected Integerorderprotected List<Pattern>patternsstatic StringSKIP_UPDATE_AUDIT_LOGGING
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFileImporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckAllowedSubtypes(CoreSession session, String path, String typeName)protected voidcheckIn(DocumentModel doc)Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected voidcheckInAfterAdd(DocumentModel doc)Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected voidcheckSecurity(CoreSession session, String path)intcompareTo(FileImporter other)DocumentModelcreate(CoreSession session, Blob content, String path, boolean overwrite, String fullname, TypeManager typeService)Creates the document.protected voidcreateDocument(DocumentModel doc, String title)Creates the document (sets its properties).DocumentModelcreateOrUpdate(FileImporterContext context)Returns a created or updated document based on the givencontext.protected voiddoSecurityCheck(CoreSession documentManager, String path, String typeName)Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)insteadprotected voiddoSecurityCheck(CoreSession documentManager, String path, String typeName, TypeManager typeService)Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)insteadprotected BlobgetBlob(DocumentModel doc)protected StringgetDefaultDocType()Default document type to use when the plugin XML configuration does not specify one.StringgetDocType()Returns the document type configured for thisFileImporter,nullif no document type is configured.protected StringgetDocType(DocumentModel container)Gets the doc type to use in the given container.FileManagerServicegetFileManagerService()Deprecated.since 10.3, useFramework.getService(Class)instead if neededList<String>getFilters()Gets filters.StringgetName()Gets the plugin name.protected StringgetNearestContainerPath(CoreSession documentManager, String path)Returns nearest container pathIntegergetOrder()Returns the plugin order for sorting.booleanisEnabled()booleanisOneToMany()ReturnstrueifFileImporter.createOrUpdate(FileImporterContext)creates more than one document for the given blob,falseotherwise.protected booleanisOverwriteByTitle()Whether document overwrite is detected by checking title or filename.booleanmatches(String mimeType)Tests whether plugin is suitable for the given mimetype.voidsetDocType(String docType)Sets the document type configured for this importer.voidsetEnabled(boolean enabled)voidsetFileManagerService(FileManagerService fileManagerService)Deprecated.since 10.3, useFramework.getService(Class)instead if neededvoidsetFilters(List<String> filters)Sets filters.voidsetName(String name)Sets plugin name.voidsetOrder(Integer order)Sets the plugin order for sorting.protected booleanskipCheckInForBlob(Blob blob)Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected voidupdateDocument(DocumentModel doc, Blob content)Updates the document (sets its properties).protected booleanupdateDocumentIfPossible(DocumentModel doc, Blob content)Tries to update the documentdocwith the blobcontent.
-
-
-
Field Detail
-
name
protected String name
-
docType
protected String docType
-
enabled
protected boolean enabled
-
order
protected Integer order
-
SKIP_UPDATE_AUDIT_LOGGING
public static final String SKIP_UPDATE_AUDIT_LOGGING
- See Also:
- Constant Field Values
-
DISABLE_AUDIT_LOGGER
public static final String DISABLE_AUDIT_LOGGER
Deprecated.since 2021.34, useCoreSession.DISABLE_AUDIT_LOGGERinsteadOriginally duplicated from NXAuditEventsService.DISABLE_AUDIT_LOGGER to avoid circular dependency.- See Also:
- Constant Field Values
-
fileManagerService
@Deprecated(since="10.3") protected transient FileManagerService fileManagerService
Deprecated.since 10.3, useFramework.getService(Class)instead if needed
-
-
Method Detail
-
getFilters
public List<String> getFilters()
Description copied from interface:FileImporterGets filters.The filters are all the mime/type this plugin can deal with.
- Specified by:
getFiltersin interfaceFileImporter- Returns:
- list of string holding each filters.
-
setFilters
public void setFilters(List<String> filters)
Description copied from interface:FileImporterSets filters.The filters are all the mime/types this plugin can deal with.
- Specified by:
setFiltersin interfaceFileImporter- Parameters:
filters- a list of strings representing each filter
-
matches
public boolean matches(String mimeType)
Description copied from interface:FileImporterTests whether plugin is suitable for the given mimetype.- Specified by:
matchesin interfaceFileImporter- Parameters:
mimeType- the mimetype to test
-
getName
public String getName()
Description copied from interface:FileImporterGets the plugin name.- Specified by:
getNamein interfaceFileImporter- Returns:
- a string holding the plugin name
-
setName
public void setName(String name)
Description copied from interface:FileImporterSets plugin name.- Specified by:
setNamein interfaceFileImporter- Parameters:
name- a string holding the name
-
getDocType
public String getDocType()
Description copied from interface:FileImporterReturns the document type configured for thisFileImporter,nullif no document type is configured.- Specified by:
getDocTypein interfaceFileImporter
-
setDocType
public void setDocType(String docType)
Description copied from interface:FileImporterSets the document type configured for this importer.- Specified by:
setDocTypein interfaceFileImporter
-
getDocType
protected String getDocType(DocumentModel container)
Gets the doc type to use in the given container.
-
getDefaultDocType
protected String getDefaultDocType()
Default document type to use when the plugin XML configuration does not specify one.To implement when the default
createOrUpdate(FileImporterContext)method is used.
-
isOverwriteByTitle
protected boolean isOverwriteByTitle()
Whether document overwrite is detected by checking title or filename.To implement when the default
createOrUpdate(FileImporterContext)method is used.
-
createDocument
protected void createDocument(DocumentModel doc, String title)
Creates the document (sets its properties).updateDocument(org.nuxeo.ecm.core.api.DocumentModel, org.nuxeo.ecm.core.api.Blob)will be called after this.Default implementation sets the title.
-
updateDocumentIfPossible
protected boolean updateDocumentIfPossible(DocumentModel doc, Blob content)
Tries to update the documentdocwith the blobcontent.Returns
trueif the document is really updated.- Since:
- 7.1
-
updateDocument
protected void updateDocument(DocumentModel doc, Blob content)
Updates the document (sets its properties).Default implementation sets the content.
-
getBlob
protected Blob getBlob(DocumentModel doc)
-
isOneToMany
public boolean isOneToMany()
Description copied from interface:FileImporterReturnstrueifFileImporter.createOrUpdate(FileImporterContext)creates more than one document for the given blob,falseotherwise.- Specified by:
isOneToManyin interfaceFileImporter
-
create
public DocumentModel create(CoreSession session, Blob content, String path, boolean overwrite, String fullname, TypeManager typeService) throws IOException
Description copied from interface:FileImporterCreates the document.- Specified by:
createin interfaceFileImporter- Parameters:
session- the manager used to create the Documentcontent- the content of the Filepath- the path of current documentoverwrite- a boolean deciding whether to create or update if we find a document with the same fileNamefullname- the filename of the File- Throws:
IOException
-
createOrUpdate
public DocumentModel createOrUpdate(FileImporterContext context) throws IOException
Description copied from interface:FileImporterReturns a created or updated document based on the givencontext.- Specified by:
createOrUpdatein interfaceFileImporter- Throws:
IOException- See Also:
FileImporterContext
-
skipCheckInForBlob
@Deprecated(since="9.1") protected boolean skipCheckInForBlob(Blob blob)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersAvoid checkin for a 0-length blob. Microsoft-WebDAV-MiniRedir first creates a 0-length file and then locks it before putting the real file. But we don't want this first placeholder to cause a versioning event.
-
getFileManagerService
@Deprecated(since="10.3") public FileManagerService getFileManagerService()
Deprecated.since 10.3, useFramework.getService(Class)instead if needed
-
setFileManagerService
@Deprecated(since="10.3") public void setFileManagerService(FileManagerService fileManagerService)
Deprecated.since 10.3, useFramework.getService(Class)instead if neededDescription copied from interface:FileImporterEmbeds a reference to the holding FileManagerService instance to be able to reuse generic file creation utility methods in specific plugin implementations.- Specified by:
setFileManagerServicein interfaceFileImporter- Parameters:
fileManagerService- instance where the Plugin is registered as a contribution
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabledin interfaceFileImporter
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceFileImporter
-
getOrder
public Integer getOrder()
Description copied from interface:FileImporterReturns the plugin order for sorting.- Specified by:
getOrderin interfaceFileImporter
-
setOrder
public void setOrder(Integer order)
Description copied from interface:FileImporterSets the plugin order for sorting.- Specified by:
setOrderin interfaceFileImporter
-
compareTo
public int compareTo(FileImporter other)
- Specified by:
compareToin interfaceComparable<FileImporter>
-
getNearestContainerPath
protected String getNearestContainerPath(CoreSession documentManager, String path)
Returns nearest container pathIf given path points to a folderish document, return it. Else, return parent path.
-
checkIn
@Deprecated(since="9.1") protected void checkIn(DocumentModel doc)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importers
-
checkInAfterAdd
@Deprecated(since="9.1") protected void checkInAfterAdd(DocumentModel doc)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importers
-
doSecurityCheck
@Deprecated protected void doSecurityCheck(CoreSession documentManager, String path, String typeName)
Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)instead- Since:
- 10.10
-
doSecurityCheck
@Deprecated protected void doSecurityCheck(CoreSession documentManager, String path, String typeName, TypeManager typeService)
Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)instead
-
checkSecurity
protected void checkSecurity(CoreSession session, String path)
- Since:
- 11.3
-
checkAllowedSubtypes
protected void checkAllowedSubtypes(CoreSession session, String path, String typeName)
- Since:
- 11.3
-
-