Class UserProfileImporter
- java.lang.Object
-
- org.nuxeo.ecm.user.center.profile.UserProfileImporter
-
@Experimental(comment="https://jira.nuxeo.com/browse/NXP-12200") public class UserProfileImporter extends Object
- Since:
- 7.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringBLOB_FOLDER_PROPERTYprotected ImporterConfigconfigstatic StringCONTENT_FILED_TYPE_NAMEprotected longcurrentRecordprotected StringdataFileNameprotected DateFormatdateformatprotected CharacterescapeCharacterprotected DatestartDateprotected longtotalRecordsstatic StringUSER_PROFILE_IMPORTER_USERNAME_COL
-
Constructor Summary
Constructors Constructor Description UserProfileImporter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcommitOrRollbackTransaction()Releases the transaction resources by committing the existing transaction (if any).protected Map<String,Serializable>computePropertiesMap(long lineNumber, DocumentType docType, Map<String,Integer> headerValues, org.apache.commons.csv.CSVRecord record)protected SerializableconvertValue(DocumentType docType, String fieldName, String headerValue, String stringValue, long lineNumber)voiddoImport(CoreSession session)voiddoImport(CoreSession session, org.apache.commons.csv.CSVParser parser, UserProfileService userProfileService)longgetCurrentRecord()protected DateFormatgetDateFormat()protected InputStreamgetResourceAsStream(String resource)longgetTotalRecords()protected booleanimportLine(org.apache.commons.csv.CSVRecord record, long lineNumber, Integer nameIndex, DocumentType docType, CoreSession session, UserProfileService userProfileService, Map<String,Integer> headerValues)Import a line from the CSV file.protected voidlogImportError(long lineNumber, String message, String... params)protected voidlogImportInfo(long lineNumber, String message, String... params)protected booleanstartTransaction()Starts a new transaction.static ThrowableunwrapException(Throwable t)protected booleanupdateDocument(long lineNumber, String name, DocumentType docType, CoreSession session, UserProfileService userProfileService, Map<String,Serializable> properties)
-
-
-
Field Detail
-
CONTENT_FILED_TYPE_NAME
public static final String CONTENT_FILED_TYPE_NAME
- See Also:
- Constant Field Values
-
USER_PROFILE_IMPORTER_USERNAME_COL
public static final String USER_PROFILE_IMPORTER_USERNAME_COL
- See Also:
- Constant Field Values
-
escapeCharacter
protected Character escapeCharacter
-
config
protected ImporterConfig config
-
dataFileName
protected String dataFileName
-
dateformat
protected transient DateFormat dateformat
-
totalRecords
protected long totalRecords
-
currentRecord
protected long currentRecord
-
BLOB_FOLDER_PROPERTY
public static final String BLOB_FOLDER_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UserProfileImporter
public UserProfileImporter()
-
-
Method Detail
-
doImport
public void doImport(CoreSession session)
-
getResourceAsStream
protected InputStream getResourceAsStream(String resource)
-
doImport
public void doImport(CoreSession session, org.apache.commons.csv.CSVParser parser, UserProfileService userProfileService) throws IOException
- Throws:
IOException
-
importLine
protected boolean importLine(org.apache.commons.csv.CSVRecord record, long lineNumber, Integer nameIndex, DocumentType docType, CoreSession session, UserProfileService userProfileService, Map<String,Integer> headerValues)
Import a line from the CSV file.- Returns:
trueif a document has been created or updated,falseotherwise.
-
computePropertiesMap
protected Map<String,Serializable> computePropertiesMap(long lineNumber, DocumentType docType, Map<String,Integer> headerValues, org.apache.commons.csv.CSVRecord record)
-
convertValue
protected Serializable convertValue(DocumentType docType, String fieldName, String headerValue, String stringValue, long lineNumber)
-
getDateFormat
protected DateFormat getDateFormat()
-
updateDocument
protected boolean updateDocument(long lineNumber, String name, DocumentType docType, CoreSession session, UserProfileService userProfileService, Map<String,Serializable> properties)
-
commitOrRollbackTransaction
protected void commitOrRollbackTransaction()
Releases the transaction resources by committing the existing transaction (if any). This is recommended before running a long process.
-
startTransaction
protected boolean startTransaction()
Starts a new transaction.Usually called after
commitOrRollbackTransaction(), for instance for saving back the results of a long process.- Returns:
- true if a new transaction was started
-
logImportError
protected void logImportError(long lineNumber, String message, String... params)
-
logImportInfo
protected void logImportInfo(long lineNumber, String message, String... params)
-
unwrapException
public static Throwable unwrapException(Throwable t)
-
getTotalRecords
public long getTotalRecords()
-
getCurrentRecord
public long getCurrentRecord()
-
-