public class MemberImportManager extends java.lang.Object implements JcmsConstants
A manager to be instanciated to import Members from a CSV input file.
CSV File's expected format:
Name, First name, Email, Login, Organization, Department, JobTitle, Phone, Mobile, custom optional columns ... # First line must contain headers # Use '#' caracter to comment a line FOO, John, john.foo@example.com, , Acme, Sales, Manager, 0102030405, 0605040302
The limit controller is checked only if account activation mails is chosen.
Modifier and Type | Class and Description |
---|---|
class |
MemberImportManager.SendActivationMailAlarmListener
This class aims to manage activation email sending, after a batch of DB Member have been persisted.
|
Modifier and Type | Field and Description |
---|---|
protected int |
activeMemberCountBase
Count of active Members at start of import.
|
static java.lang.String |
COMMENT_CHARACTER
A character to use at start of a line to comment.
|
protected int |
createActiveCount
Count of active members (may not yet be activated).
|
protected int |
createCount
The count of created Members.
|
protected java.util.List<java.lang.String> |
createdMembersIdList
The created members id list.
|
protected java.io.File |
csvFile |
protected com.csvreader.CsvReader |
csvReader
the reader that makes the parsing.
|
protected int |
dbOperationsCount
Used to count operations on DBData, to perform periodical commit / begin transaction.
|
static boolean |
DEFAULT_DBMEMBER
The default use of DBMember class.
|
static int |
DEFAULT_DEFERR_EMAILS
The default duration of derring the sending of emails.
|
static int |
DEFAULT_USAGE |
protected java.util.Map<java.lang.String,MemberImport> |
emailInfoMap
This map contains the Member objects parsed from CSV.
|
protected long |
endTime
For debug purpose.
|
protected int |
expectedColumnCout
Expected headers columns number.
|
protected java.util.Collection<java.lang.String> |
groupIds |
protected boolean |
hasToSendEmail |
protected Member |
importAuthor |
protected java.lang.String |
importPropertyKey |
protected int |
invalidCount |
protected boolean |
isAnyError
Is there any error during checking the csv file ?
|
protected boolean |
isBlockingError
True if an error should block the processing.
|
protected boolean |
isSimulation |
protected JcmsContext |
jcmsContext |
static java.lang.String |
LANG_PROPERTY_PREFIX
Property key prefix.
|
protected java.util.Map<java.lang.Integer,MemberImport> |
lineInfoMap
This map contains the Member objects parsed from CSV.
|
protected java.util.Map<java.lang.String,MemberImport> |
loginInfoMap
This map contains the new computed logins.
|
static java.lang.String |
MAX_ERROR_PER_IMPORT_PROP
Property key to indicate the max number of errors to show per import.
|
static java.lang.String |
MAX_MEMBER_PER_IMPORT_PROP
Property key to indicate the max member per import.
|
static java.lang.String |
MEMBER_DC_SRC_COLUMNS_KEY
A DataController contextMap key, which stores the sources columns of the csv file, as a String[].
|
protected java.util.List<MemberImport> |
memberImportList
The list containing each line.
|
protected long |
previousTime
For debug purpose.
|
protected javax.servlet.http.HttpServletRequest |
request |
protected javax.servlet.http.HttpServletResponse |
response |
static java.lang.String |
REVISION |
java.lang.String |
separator
The separator to use, may be selected by UI.
|
protected long |
startTime
For debug purpose.
|
protected int |
updateCount
The count of updated Members.
|
protected java.util.List<java.lang.String> |
updatedMembersIdList
The update members id list.
|
protected java.lang.String |
userLang |
static java.lang.String |
WORKSPACE_ROOT_CATEGORY_VID_PROP
Property key to indicate the root Category's virtual id of the Workspace Category tree.
|
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, ICON_ARCHIVE, ICON_LOCK, ICON_LOCK_STRONG, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
Constructor and Description |
---|
MemberImportManager(JcmsContext jcmsContext) |
Modifier and Type | Method and Description |
---|---|
protected void |
computeLogin(MemberImport memberImport)
Computes login from email : remove right part after '@'.
|
java.lang.String[] |
filterGroupsToProposedWorkspaces(java.lang.String[] chosenGroupIds,
java.util.Set<Workspace> wsSet)
Utility method to control that all chosen groups belongs to given workspace Set.
|
int |
getCreateCount() |
java.io.File |
getCsvFile() |
int |
getInvalidCount() |
java.util.List<MemberImport> |
getMemberInfoList()
Get the list of all
MemberImport used during import. |
java.lang.String |
getSeparator() |
int |
getUpdateCount() |
int |
getUsage() |
boolean |
hasToSendEmail() |
protected Member |
internalGetMemberFromLogin(java.lang.String login)
Searches Member from login from persisted Members, and in temporary login Map.
|
boolean |
isAccountImport() |
boolean |
isAnyError() |
boolean |
isBlockingError() |
boolean |
isContactImport() |
static boolean |
isEnabled() |
boolean |
isSimulation() |
boolean |
isUseMemberClass() |
boolean |
performImport()
Iterate on
memberImportList , and create or update each member. |
protected void |
performImport(MemberImport mbrImport)
Perform save of the Member object if possible.
|
void |
prepareImport()
May be called for simulation (in this case
isSimulation is true). |
void |
setCsvFile(java.io.File csvFile) |
void |
setGroupIds(java.util.Collection<java.lang.String> groupIds) |
void |
setHasToSendEmail(boolean hasToSendEmail) |
void |
setRequest(javax.servlet.http.HttpServletRequest request) |
void |
setResponse(javax.servlet.http.HttpServletResponse response) |
void |
setSeparator(java.lang.String separator) |
void |
setSimulation(boolean isSimulation) |
void |
setUsage(int usage) |
void |
setUseMemberClass(boolean useMemberClass)
Set true to create Member in JStore.
|
ControllerStatus |
validateCsvFile() |
public static final java.lang.String REVISION
public static final java.lang.String MEMBER_DC_SRC_COLUMNS_KEY
public static final java.lang.String MAX_MEMBER_PER_IMPORT_PROP
public static final java.lang.String MAX_ERROR_PER_IMPORT_PROP
public static final java.lang.String WORKSPACE_ROOT_CATEGORY_VID_PROP
public static final java.lang.String COMMENT_CHARACTER
public static int DEFAULT_USAGE
public static boolean DEFAULT_DBMEMBER
protected boolean isSimulation
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
protected java.lang.String importPropertyKey
protected java.util.Collection<java.lang.String> groupIds
protected java.io.File csvFile
public static final java.lang.String LANG_PROPERTY_PREFIX
protected int expectedColumnCout
protected Member importAuthor
protected boolean hasToSendEmail
protected long startTime
protected long endTime
protected long previousTime
protected com.csvreader.CsvReader csvReader
public java.lang.String separator
protected JcmsContext jcmsContext
protected java.lang.String userLang
protected java.util.Map<java.lang.Integer,MemberImport> lineInfoMap
protected java.util.List<MemberImport> memberImportList
protected java.util.Map<java.lang.String,MemberImport> emailInfoMap
protected java.util.Map<java.lang.String,MemberImport> loginInfoMap
protected int createCount
protected int updateCount
protected int createActiveCount
protected int activeMemberCountBase
protected int dbOperationsCount
protected int invalidCount
protected boolean isBlockingError
protected boolean isAnyError
protected java.util.List<java.lang.String> createdMembersIdList
protected java.util.List<java.lang.String> updatedMembersIdList
public static final int DEFAULT_DEFERR_EMAILS
public MemberImportManager(JcmsContext jcmsContext)
jcmsContext
- the JcmsContext
public boolean isSimulation()
public void setSimulation(boolean isSimulation)
isSimulation
- the isSimulation to setpublic java.io.File getCsvFile()
public void setCsvFile(java.io.File csvFile)
csvFile
- the csvFile to setpublic java.util.List<MemberImport> getMemberInfoList()
MemberImport
used during import. (May be creation, and updates).public boolean isAnyError()
public int getCreateCount()
public int getUpdateCount()
public int getInvalidCount()
public java.lang.String getSeparator()
public boolean isBlockingError()
public void setRequest(javax.servlet.http.HttpServletRequest request)
request
- the request to setpublic void setResponse(javax.servlet.http.HttpServletResponse response)
response
- the response to setpublic void setSeparator(java.lang.String separator)
separator
- the separator to setpublic static boolean isEnabled()
public boolean hasToSendEmail()
public void setHasToSendEmail(boolean hasToSendEmail)
hasToSendEmail
- the hasToSendEmail to setpublic void setGroupIds(java.util.Collection<java.lang.String> groupIds)
groupIds
- the groupIds to setpublic boolean isUseMemberClass()
public void setUseMemberClass(boolean useMemberClass)
useMemberClass
- the useMemberClass to setpublic int getUsage()
public void setUsage(int usage)
usage
- the usage (Account or contact) for members to create to set.public boolean isAccountImport()
public boolean isContactImport()
public void prepareImport() throws java.io.IOException
isSimulation
is true).isSimulation
is false).isSimulation
is true, a warning message about memberLimitController may be added to jcmsContext. Else, this message should be managed by performImport()
.java.io.IOException
- IOException which can be thrown by import processpublic boolean performImport()
memberImportList
, and create or update each member.protected void performImport(MemberImport mbrImport)
mbrImport
- the mock Member to be imported.public ControllerStatus validateCsvFile() throws java.io.IOException
java.io.IOException
- IOException which can be thrown when validate is donepublic java.lang.String[] filterGroupsToProposedWorkspaces(java.lang.String[] chosenGroupIds, java.util.Set<Workspace> wsSet)
chosenGroupIds
- the Group ids to validate.wsSet
- the workspace Set of the loggedMember.protected void computeLogin(MemberImport memberImport)
Computes login from email : remove right part after '@'.
Updates the given memberImport if needed.memberImport
- the mock Member to create to compute its login.protected Member internalGetMemberFromLogin(java.lang.String login)
login
- the login to retrieve the associated Member.Copyright © 2001-2010 Jalios SA. All Rights Reserved.