com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);
userProxyInode = userProxy.getInode();
// adding roles to user
Permission permission = null;
if (readPermissions != null) {
for (int n = 0; n < readPermissions.length; n++) {
permission = new Permission(userProxyInode, readPermissions[n], PERMISSION_READ);
permissionAPI.save(permission, userProxy, systemUser, false);
}
}
if (writePermissions != null) {
for (int n = 0; n < writePermissions.length; n++) {
permission = new Permission(userProxyInode, writePermissions[n], PERMISSION_WRITE);
permissionAPI.save(permission, userProxy, systemUser, false);
}
}
Date today = new Date();
Address address = PublicAddressFactory.getInstance();
address.setUserName(user.getFullName());
address.setCompanyId(companyId);
address.setUserId(user.getUserId());
address.setCreateDate(today);
address.setModifiedDate(today);
address.setPriority(1);
address.setClassName(user.getClass().getName());
address.setClassPK(user.getUserId());
address.setDescription("Primary");
address.setStreet1(street1);
address.setStreet2(street2);
address.setCountry(country);
address.setCity(city);
address.setState(state);
address.setZip(zip);
address.setPhone(phone);
address.setFax(fax);
address.setCell(cell);
PublicAddressFactory.save(address);
// creating tag users
if (UtilMethods.isSet(userForm.getTagName())) {
StringTokenizer tagNameToken = new StringTokenizer(userForm.getTagName(), ",");
if (tagNameToken.hasMoreTokens()) {
for (; tagNameToken.hasMoreTokens();) {
String tagTokenized = tagNameToken.nextToken().trim();
TagFactory.addTag(tagTokenized, user.getUserId(),"");
}
}
}
for (String roleId : roles) {
com.dotmarketing.business.APILocator.getRoleAPI().addRoleToUser(roleId, user);
}
userCreated++;
userTaged++;
arrayUserIds.add(user.getUserId());
} else {
// email duplicated
if (userForm.isUpdateDuplicatedUsers()) {
if (UtilMethods.isSet(firstName))
userDuplicated.setFirstName(firstName);
if (UtilMethods.isSet(middleName))
userDuplicated.setMiddleName(middleName);
if (UtilMethods.isSet(lastName))
userDuplicated.setLastName(lastName);
userDuplicated
.setGreeting("Welcome, " + userDuplicated.getFirstName() + " " + userDuplicated.getLastName() + "!");
if (UtilMethods.isSet(email))
userDuplicated.setEmailAddress(email.trim().toLowerCase());
if (UtilMethods.isSet(birthday))
userDuplicated.setBirthday(birthday);
if (UtilMethods.isSet(password)) {
userDuplicated.setPassword(PublicEncryptionFactory.digestString(password));
userDuplicated.setPasswordEncrypted(true);
}
APILocator.getUserAPI().save(userDuplicated,APILocator.getUserAPI().getSystemUser(),false);
UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(userDuplicated,APILocator.getUserAPI().getSystemUser(), false);
// getting and saving the user
// additional info
String userAdditionalInfo = "";
for (int j = 1; j <= numberGenericVariables; j++) {
try {
userAdditionalInfo = lineTok[i++];
} catch (Exception e) {
userAdditionalInfo = "";
}
if (!userAdditionalInfo.equalsIgnoreCase("")) {
userProxy.setVar(j, userAdditionalInfo);
}
}
com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);
String userProxyInode = userProxy.getInode();
permissionAPI.removePermissions(userProxy);
// adding roles to user
if (readPermissions != null) {
for (int n = 0; n < readPermissions.length; n++) {
permissionAPI.save(new Permission(userProxyInode, readPermissions[n], PERMISSION_READ), userProxy, systemUser, false);
}
}
if (writePermissions != null) {
for (int n = 0; n < writePermissions.length; n++) {
permissionAPI.save(new Permission(userProxyInode, writePermissions[n], PERMISSION_WRITE), userProxy, systemUser, false);
}
}
Address address = null;
List<Address> addresses = PublicAddressFactory.getAddressesByUserId(userDuplicated.getUserId());