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 String
DISABLE_AUDIT_LOGGER
Deprecated.since 2021.34, useCoreSession.DISABLE_AUDIT_LOGGER
insteadprotected String
docType
protected boolean
enabled
protected FileManagerService
fileManagerService
Deprecated.since 10.3, useFramework.getService(Class)
instead if neededprotected List<String>
filters
protected String
name
protected Integer
order
protected List<Pattern>
patterns
static String
SKIP_UPDATE_AUDIT_LOGGING
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFileImporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
checkAllowedSubtypes(CoreSession session, String path, String typeName)
protected void
checkIn(DocumentModel doc)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected void
checkInAfterAdd(DocumentModel doc)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected void
checkSecurity(CoreSession session, String path)
int
compareTo(FileImporter other)
DocumentModel
create(CoreSession session, Blob content, String path, boolean overwrite, String fullname, TypeManager typeService)
Creates the document.protected void
createDocument(DocumentModel doc, String title)
Creates the document (sets its properties).DocumentModel
createOrUpdate(FileImporterContext context)
Returns a created or updated document based on the givencontext
.protected void
doSecurityCheck(CoreSession documentManager, String path, String typeName)
Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)
insteadprotected void
doSecurityCheck(CoreSession documentManager, String path, String typeName, TypeManager typeService)
Deprecated.since 11.3, useand #checkAllowedSubtypes(CoreSession, String, String)
insteadprotected Blob
getBlob(DocumentModel doc)
protected String
getDefaultDocType()
Default document type to use when the plugin XML configuration does not specify one.String
getDocType()
Returns the document type configured for thisFileImporter
,null
if no document type is configured.protected String
getDocType(DocumentModel container)
Gets the doc type to use in the given container.FileManagerService
getFileManagerService()
Deprecated.since 10.3, useFramework.getService(Class)
instead if neededList<String>
getFilters()
Gets filters.String
getName()
Gets the plugin name.protected String
getNearestContainerPath(CoreSession documentManager, String path)
Returns nearest container pathInteger
getOrder()
Returns the plugin order for sorting.boolean
isEnabled()
boolean
isOneToMany()
Returnstrue
ifFileImporter.createOrUpdate(FileImporterContext)
creates more than one document for the given blob,false
otherwise.protected boolean
isOverwriteByTitle()
Whether document overwrite is detected by checking title or filename.boolean
matches(String mimeType)
Tests whether plugin is suitable for the given mimetype.void
setDocType(String docType)
Sets the document type configured for this importer.void
setEnabled(boolean enabled)
void
setFileManagerService(FileManagerService fileManagerService)
Deprecated.since 10.3, useFramework.getService(Class)
instead if neededvoid
setFilters(List<String> filters)
Sets filters.void
setName(String name)
Sets plugin name.void
setOrder(Integer order)
Sets the plugin order for sorting.protected boolean
skipCheckInForBlob(Blob blob)
Deprecated.since 9.1 automatic versioning is now handled at versioning service level, remove versioning behaviors from importersprotected void
updateDocument(DocumentModel doc, Blob content)
Updates the document (sets its properties).protected boolean
updateDocumentIfPossible(DocumentModel doc, Blob content)
Tries to update the documentdoc
with 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_LOGGER
insteadOriginally 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:FileImporter
Gets filters.The filters are all the mime/type this plugin can deal with.
- Specified by:
getFilters
in interfaceFileImporter
- Returns:
- list of string holding each filters.
-
setFilters
public void setFilters(List<String> filters)
Description copied from interface:FileImporter
Sets filters.The filters are all the mime/types this plugin can deal with.
- Specified by:
setFilters
in interfaceFileImporter
- Parameters:
filters
- a list of strings representing each filter
-
matches
public boolean matches(String mimeType)
Description copied from interface:FileImporter
Tests whether plugin is suitable for the given mimetype.- Specified by:
matches
in interfaceFileImporter
- Parameters:
mimeType
- the mimetype to test
-
getName
public String getName()
Description copied from interface:FileImporter
Gets the plugin name.- Specified by:
getName
in interfaceFileImporter
- Returns:
- a string holding the plugin name
-
setName
public void setName(String name)
Description copied from interface:FileImporter
Sets plugin name.- Specified by:
setName
in interfaceFileImporter
- Parameters:
name
- a string holding the name
-
getDocType
public String getDocType()
Description copied from interface:FileImporter
Returns the document type configured for thisFileImporter
,null
if no document type is configured.- Specified by:
getDocType
in interfaceFileImporter
-
setDocType
public void setDocType(String docType)
Description copied from interface:FileImporter
Sets the document type configured for this importer.- Specified by:
setDocType
in 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 documentdoc
with the blobcontent
.Returns
true
if 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:FileImporter
Returnstrue
ifFileImporter.createOrUpdate(FileImporterContext)
creates more than one document for the given blob,false
otherwise.- Specified by:
isOneToMany
in interfaceFileImporter
-
create
public DocumentModel create(CoreSession session, Blob content, String path, boolean overwrite, String fullname, TypeManager typeService) throws IOException
Description copied from interface:FileImporter
Creates the document.- Specified by:
create
in 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:FileImporter
Returns a created or updated document based on the givencontext
.- Specified by:
createOrUpdate
in 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:FileImporter
Embeds a reference to the holding FileManagerService instance to be able to reuse generic file creation utility methods in specific plugin implementations.- Specified by:
setFileManagerService
in interfaceFileImporter
- Parameters:
fileManagerService
- instance where the Plugin is registered as a contribution
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabled
in interfaceFileImporter
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabled
in interfaceFileImporter
-
getOrder
public Integer getOrder()
Description copied from interface:FileImporter
Returns the plugin order for sorting.- Specified by:
getOrder
in interfaceFileImporter
-
setOrder
public void setOrder(Integer order)
Description copied from interface:FileImporter
Sets the plugin order for sorting.- Specified by:
setOrder
in interfaceFileImporter
-
compareTo
public int compareTo(FileImporter other)
- Specified by:
compareTo
in 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
-
-