Commit 47f96818 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

More working on vcard mapping.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5626 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8d1caa7a
...@@ -11,10 +11,14 @@ ...@@ -11,10 +11,14 @@
package org.jivesoftware.admin; package org.jivesoftware.admin;
import org.dom4j.DocumentHelper; import org.dom4j.*;
import org.dom4j.Element; import org.dom4j.io.OutputFormat;
import org.dom4j.QName;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLWriter;
import java.io.IOException;
import java.io.StringWriter;
/** /**
* Bean that stores the vcard mapping. It is also responsible for saving the mapping * Bean that stores the vcard mapping. It is also responsible for saving the mapping
...@@ -24,32 +28,32 @@ import org.jivesoftware.util.JiveGlobals; ...@@ -24,32 +28,32 @@ import org.jivesoftware.util.JiveGlobals;
*/ */
public class LdapUserProfile { public class LdapUserProfile {
private String name; private String name = "";
private String email; private String email = "";
private String fullName; private String fullName = "";
private String nickname; private String nickname = "";
private String birthday; private String birthday = "";
private String home_street; private String homeStreet = "";
private String home_city; private String homeCity = "";
private String home_state; private String homeState = "";
private String home_zip; private String homeZip = "";
private String home_country; private String homeCountry = "";
private String home_phone; private String homePhone = "";
private String home_mobile; private String homeMobile = "";
private String home_fax; private String homeFax = "";
private String home_pager; private String homePager = "";
private String business_street; private String businessStreet = "";
private String business_city; private String businessCity = "";
private String business_state; private String businessState = "";
private String business_zip; private String businessZip = "";
private String business_country; private String businessCountry = "";
private String business_job_title; private String businessJobTitle = "";
private String business_department; private String businessDepartment = "";
private String business_phone; private String businessPhone = "";
private String business_mobile; private String businessMobile = "";
private String business_fax; private String businessFax = "";
private String business_pager; private String businessPager = "";
private String business_web_page; private String businessWebPage = "";
public String getName() { public String getName() {
return name; return name;
...@@ -91,172 +95,172 @@ public class LdapUserProfile { ...@@ -91,172 +95,172 @@ public class LdapUserProfile {
this.birthday = birthday; this.birthday = birthday;
} }
public String getHome_street() { public String getHomeStreet() {
return home_street; return homeStreet;
} }
public void setHome_street(String home_street) { public void setHomeStreet(String homeStreet) {
this.home_street = home_street; this.homeStreet = homeStreet;
} }
public String getHome_city() { public String getHomeCity() {
return home_city; return homeCity;
} }
public void setHome_city(String home_city) { public void setHomeCity(String homeCity) {
this.home_city = home_city; this.homeCity = homeCity;
} }
public String getHome_state() { public String getHomeState() {
return home_state; return homeState;
} }
public void setHome_state(String home_state) { public void setHomeState(String homeState) {
this.home_state = home_state; this.homeState = homeState;
} }
public String getHome_zip() { public String getHomeZip() {
return home_zip; return homeZip;
} }
public void setHome_zip(String home_zip) { public void setHomeZip(String homeZip) {
this.home_zip = home_zip; this.homeZip = homeZip;
} }
public String getHome_country() { public String getHomeCountry() {
return home_country; return homeCountry;
} }
public void setHome_country(String home_country) { public void setHomeCountry(String homeCountry) {
this.home_country = home_country; this.homeCountry = homeCountry;
} }
public String getHome_phone() { public String getHomePhone() {
return home_phone; return homePhone;
} }
public void setHome_phone(String home_phone) { public void setHomePhone(String homePhone) {
this.home_phone = home_phone; this.homePhone = homePhone;
} }
public String getHome_mobile() { public String getHomeMobile() {
return home_mobile; return homeMobile;
} }
public void setHome_mobile(String home_mobile) { public void setHomeMobile(String homeMobile) {
this.home_mobile = home_mobile; this.homeMobile = homeMobile;
} }
public String getHome_fax() { public String getHomeFax() {
return home_fax; return homeFax;
} }
public void setHome_fax(String home_fax) { public void setHomeFax(String homeFax) {
this.home_fax = home_fax; this.homeFax = homeFax;
} }
public String getHome_pager() { public String getHomePager() {
return home_pager; return homePager;
} }
public void setHome_pager(String home_pager) { public void setHomePager(String homePager) {
this.home_pager = home_pager; this.homePager = homePager;
} }
public String getBusiness_street() { public String getBusinessStreet() {
return business_street; return businessStreet;
} }
public void setBusiness_street(String business_street) { public void setBusinessStreet(String businessStreet) {
this.business_street = business_street; this.businessStreet = businessStreet;
} }
public String getBusiness_city() { public String getBusinessCity() {
return business_city; return businessCity;
} }
public void setBusiness_city(String business_city) { public void setBusinessCity(String businessCity) {
this.business_city = business_city; this.businessCity = businessCity;
} }
public String getBusiness_state() { public String getBusinessState() {
return business_state; return businessState;
} }
public void setBusiness_state(String business_state) { public void setBusinessState(String businessState) {
this.business_state = business_state; this.businessState = businessState;
} }
public String getBusiness_zip() { public String getBusinessZip() {
return business_zip; return businessZip;
} }
public void setBusiness_zip(String business_zip) { public void setBusinessZip(String businessZip) {
this.business_zip = business_zip; this.businessZip = businessZip;
} }
public String getBusiness_country() { public String getBusinessCountry() {
return business_country; return businessCountry;
} }
public void setBusiness_country(String business_country) { public void setBusinessCountry(String businessCountry) {
this.business_country = business_country; this.businessCountry = businessCountry;
} }
public String getBusiness_job_title() { public String getBusinessJobTitle() {
return business_job_title; return businessJobTitle;
} }
public void setBusiness_job_title(String business_job_title) { public void setBusinessJobTitle(String businessJobTitle) {
this.business_job_title = business_job_title; this.businessJobTitle = businessJobTitle;
} }
public String getBusiness_department() { public String getBusinessDepartment() {
return business_department; return businessDepartment;
} }
public void setBusiness_department(String business_department) { public void setBusinessDepartment(String businessDepartment) {
this.business_department = business_department; this.businessDepartment = businessDepartment;
} }
public String getBusiness_phone() { public String getBusinessPhone() {
return business_phone; return businessPhone;
} }
public void setBusiness_phone(String business_phone) { public void setBusinessPhone(String businessPhone) {
this.business_phone = business_phone; this.businessPhone = businessPhone;
} }
public String getBusiness_mobile() { public String getBusinessMobile() {
return business_mobile; return businessMobile;
} }
public void setBusiness_mobile(String business_mobile) { public void setBusinessMobile(String businessMobile) {
this.business_mobile = business_mobile; this.businessMobile = businessMobile;
} }
public String getBusiness_fax() { public String getBusinessFax() {
return business_fax; return businessFax;
} }
public void setBusiness_fax(String business_fax) { public void setBusinessFax(String businessFax) {
this.business_fax = business_fax; this.businessFax = businessFax;
} }
public String getBusiness_pager() { public String getBusinessPager() {
return business_pager; return businessPager;
} }
public void setBusiness_pager(String business_pager) { public void setBusinessPager(String businessPager) {
this.business_pager = business_pager; this.businessPager = businessPager;
} }
public String getBusiness_web_page() { public String getBusinessWebPage() {
return business_web_page; return businessWebPage;
} }
public void setBusiness_web_page(String business_web_page) { public void setBusinessWebPage(String businessWebPage) {
this.business_web_page = business_web_page; this.businessWebPage = businessWebPage;
} }
/** /**
...@@ -268,27 +272,27 @@ public class LdapUserProfile { ...@@ -268,27 +272,27 @@ public class LdapUserProfile {
fullName = "{displayName}"; fullName = "{displayName}";
nickname = ""; nickname = "";
birthday = ""; birthday = "";
home_street = "{homePostalAddress}"; homeStreet = "{homePostalAddress}";
home_city = ""; homeCity = "";
home_state = ""; homeState = "";
home_zip = "{homeZip}"; homeZip = "{homeZip}";
home_country = "{countryCode}"; homeCountry = "{countryCode}";
home_phone = "{homePhone}"; homePhone = "{homePhone}";
home_mobile = ""; homeMobile = "";
home_fax = ""; homeFax = "";
home_pager = ""; homePager = "";
business_street = "{postalAddress}"; businessStreet = "{postalAddress}";
business_city = "{l}"; businessCity = "{l}";
business_state = "{st}"; businessState = "{st}";
business_zip = "{postalCode}"; businessZip = "{postalCode}";
business_country = "{countryCode}"; businessCountry = "{countryCode}";
business_job_title = "{title}"; businessJobTitle = "{title}";
business_department = "{department}"; businessDepartment = "{department}";
business_phone = "{otherTelephone}"; businessPhone = "{otherTelephone}";
business_mobile = "{mobile}"; businessMobile = "{mobile}";
business_fax = "{facsimileTelephoneNumber}"; businessFax = "{facsimileTelephoneNumber}";
business_pager = "{pager}"; businessPager = "{pager}";
business_web_page = ""; businessWebPage = "";
} }
/** /**
...@@ -300,379 +304,221 @@ public class LdapUserProfile { ...@@ -300,379 +304,221 @@ public class LdapUserProfile {
fullName = "{displayName}"; fullName = "{displayName}";
nickname = "{uid}"; nickname = "{uid}";
birthday = ""; birthday = "";
home_street = "{homePostalAddress}"; homeStreet = "{homePostalAddress}";
home_city = ""; homeCity = "";
home_state = ""; homeState = "";
home_zip = ""; homeZip = "";
home_country = ""; homeCountry = "";
home_phone = "{homePhone}"; homePhone = "{homePhone}";
home_mobile = ""; homeMobile = "";
home_fax = ""; homeFax = "";
home_pager = ""; homePager = "";
business_street = "{postalAddress}"; businessStreet = "{postalAddress}";
business_city = "{l}"; businessCity = "{l}";
business_state = "{st}"; businessState = "{st}";
business_zip = "{postalCode}"; businessZip = "{postalCode}";
business_country = ""; businessCountry = "";
business_job_title = "{title}"; businessJobTitle = "{title}";
business_department = "{departmentNumber}"; businessDepartment = "{departmentNumber}";
business_phone = "{telephoneNumber}"; businessPhone = "{telephoneNumber}";
business_mobile = "{mobile}"; businessMobile = "{mobile}";
business_fax = ""; businessFax = "";
business_pager = "{pager}"; businessPager = "{pager}";
business_web_page = ""; businessWebPage = "";
} }
/** /**
* Saves current configuration as XML properties. * Saves current configuration as XML properties.
*/ */
public void saveXMLProperties() { public void saveProperties() {
Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp")); Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp"));
Element subelement; Element subelement;
// Add name // Add name
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
subelement = vCard.addElement("N"); subelement = vCard.addElement("N");
Element given = subelement.addElement("GIVEN"); subelement.addElement("GIVEN").setText(name.trim());
if (name.trim().startsWith("{")) {
String xmlValue = name.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
given.addAttribute("attrs", xmlValue.trim());
given.setText("{0}");
}
else {
given.setText(name.trim());
}
} }
// Add email // Add email
if (email != null && email.trim().length() > 0) { if (email != null && email.trim().length() > 0) {
subelement = vCard.addElement("EMAIL"); subelement = vCard.addElement("EMAIL");
subelement.addElement("INTERNET"); subelement.addElement("INTERNET");
Element userID = subelement.addElement("USERID"); subelement.addElement("USERID").setText(email.trim());
if (email.trim().startsWith("{")) {
String xmlValue = email.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
userID.addAttribute("attrs", xmlValue.trim());
userID.setText("{0}");
}
else {
userID.setText(name.trim());
}
} }
// Add Full Name // Add Full Name
subelement = vCard.addElement("FN"); vCard.addElement("FN").setText(fullName.trim());
if (fullName.trim().startsWith("{")) {
String xmlValue = fullName.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
subelement.addAttribute("attrs", xmlValue.trim());
subelement.setText("{0}");
}
else {
subelement.setText(fullName.trim());
}
// Add nickname // Add nickname
if (nickname != null && nickname.trim().length() > 0) { if (nickname != null && nickname.trim().length() > 0) {
subelement = vCard.addElement("NICKNAME"); vCard.addElement("NICKNAME").setText(nickname.trim());
if (nickname.trim().startsWith("{")) {
String xmlValue = nickname.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
subelement.addAttribute("attrs", xmlValue.trim());
subelement.setText("{0}");
}
else {
subelement.setText(nickname.trim());
}
} }
// Add birthday // Add birthday
if (birthday != null && birthday.trim().length() > 0) { if (birthday != null && birthday.trim().length() > 0) {
subelement = vCard.addElement("BDAY"); vCard.addElement("BDAY").setText(birthday.trim());
if (birthday.trim().startsWith("{")) {
String xmlValue = birthday.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
subelement.addAttribute("attrs", xmlValue.trim());
subelement.setText("{0}");
}
else {
subelement.setText(birthday.trim());
}
} }
// Add home address // Add home address
subelement = vCard.addElement("ADR"); subelement = vCard.addElement("ADR");
subelement.addElement("HOME"); subelement.addElement("HOME");
if (home_street != null && home_street.trim().length() > 0) { if (homeStreet != null && homeStreet.trim().length() > 0) {
Element street = subelement.addElement("STREET"); subelement.addElement("STREET").setText(homeStreet.trim());
if (home_street.trim().startsWith("{")) {
String xmlValue = home_street.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
street.addAttribute("attrs", xmlValue.trim());
street.setText("{0}");
}
else {
street.setText(home_street.trim());
}
} }
if (home_city != null && home_city.trim().length() > 0) { if (homeCity != null && homeCity.trim().length() > 0) {
Element city = subelement.addElement("LOCALITY"); subelement.addElement("LOCALITY").setText(homeCity.trim());
if (home_city.trim().startsWith("{")) {
String xmlValue = home_city.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(home_city.trim());
}
} }
if (home_state != null && home_state.trim().length() > 0) { if (homeState != null && homeState.trim().length() > 0) {
Element city = subelement.addElement("REGION"); subelement.addElement("REGION").setText(homeState.trim());
if (home_state.trim().startsWith("{")) {
String xmlValue = home_state.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(home_state.trim());
}
} }
if (home_zip != null && home_zip.trim().length() > 0) { if (homeZip != null && homeZip.trim().length() > 0) {
Element city = subelement.addElement("PCODE"); subelement.addElement("PCODE").setText(homeZip.trim());
if (home_zip.trim().startsWith("{")) {
String xmlValue = home_zip.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(home_zip.trim());
}
} }
if (home_country != null && home_country.trim().length() > 0) { if (homeCountry != null && homeCountry.trim().length() > 0) {
Element city = subelement.addElement("CTRY"); subelement.addElement("CTRY").setText(homeCountry.trim());
if (home_country.trim().startsWith("{")) {
String xmlValue = home_country.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(home_country.trim());
}
} }
// Add business address // Add business address
subelement = vCard.addElement("ADR"); subelement = vCard.addElement("ADR");
subelement.addElement("WORK"); subelement.addElement("WORK");
if (business_street != null && business_street.trim().length() > 0) { if (businessStreet != null && businessStreet.trim().length() > 0) {
Element street = subelement.addElement("STREET"); subelement.addElement("STREET").setText(businessStreet.trim());
if (business_street.trim().startsWith("{")) {
String xmlValue = business_street.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
street.addAttribute("attrs", xmlValue.trim());
street.setText("{0}");
}
else {
street.setText(business_street.trim());
}
} }
if (business_city != null && business_city.trim().length() > 0) { if (businessCity != null && businessCity.trim().length() > 0) {
Element city = subelement.addElement("LOCALITY"); subelement.addElement("LOCALITY").setText(businessCity.trim());
if (business_city.trim().startsWith("{")) {
String xmlValue = business_city.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(business_city.trim());
}
} }
if (business_state != null && business_state.trim().length() > 0) { if (businessState != null && businessState.trim().length() > 0) {
Element city = subelement.addElement("REGION"); subelement.addElement("REGION").setText(businessState.trim());
if (business_state.trim().startsWith("{")) {
String xmlValue = business_state.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(business_state.trim());
}
} }
if (business_zip != null && business_zip.trim().length() > 0) { if (businessZip != null && businessZip.trim().length() > 0) {
Element city = subelement.addElement("PCODE"); subelement.addElement("PCODE").setText(homeZip.trim());
if (business_zip.trim().startsWith("{")) {
String xmlValue = business_zip.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(home_zip.trim());
}
} }
if (business_country != null && business_country.trim().length() > 0) { if (businessCountry != null && businessCountry.trim().length() > 0) {
Element city = subelement.addElement("CTRY"); subelement.addElement("CTRY").setText(businessCountry.trim());
if (business_country.trim().startsWith("{")) {
String xmlValue = business_country.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
city.addAttribute("attrs", xmlValue.trim());
city.setText("{0}");
}
else {
city.setText(business_country.trim());
}
} }
// Add home phone // Add home phone
if (home_phone != null && home_phone.trim().length() > 0) { if (homePhone != null && homePhone.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("HOME"); subelement.addElement("HOME");
subelement.addElement("VOICE"); subelement.addElement("VOICE");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(homePhone.trim());
if (home_phone.trim().startsWith("{")) {
String xmlValue = home_phone.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(home_phone.trim());
}
} }
// Add home mobile // Add home mobile
if (home_mobile != null && home_mobile.trim().length() > 0) { if (homeMobile != null && homeMobile.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("HOME"); subelement.addElement("HOME");
subelement.addElement("VOICE"); subelement.addElement("VOICE");
subelement.addElement("CELL"); subelement.addElement("CELL");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(homeMobile.trim());
if (home_mobile.trim().startsWith("{")) {
String xmlValue = home_mobile.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(home_mobile.trim());
}
} }
// Add home fax // Add home fax
if (home_fax != null && home_fax.trim().length() > 0) { if (homeFax != null && homeFax.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("HOME"); subelement.addElement("HOME");
subelement.addElement("FAX"); subelement.addElement("FAX");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(homeFax.trim());
if (home_fax.trim().startsWith("{")) {
String xmlValue = home_fax.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(home_fax.trim());
}
} }
// Add home pager // Add home pager
if (home_pager != null && home_pager.trim().length() > 0) { if (homePager != null && homePager.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("HOME"); subelement.addElement("HOME");
subelement.addElement("PAGER"); subelement.addElement("PAGER");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(homePager.trim());
if (home_pager.trim().startsWith("{")) {
String xmlValue = home_pager.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(home_pager.trim());
}
} }
// Add business phone // Add business phone
if (business_phone != null && business_phone.trim().length() > 0) { if (businessPhone != null && businessPhone.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("WORK"); subelement.addElement("WORK");
subelement.addElement("VOICE"); subelement.addElement("VOICE");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(businessPhone.trim());
if (business_phone.trim().startsWith("{")) {
String xmlValue = business_phone.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(business_phone.trim());
}
} }
// Add business mobile // Add business mobile
if (business_mobile != null && business_mobile.trim().length() > 0) { if (businessMobile != null && businessMobile.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("WORK"); subelement.addElement("WORK");
subelement.addElement("VOICE"); subelement.addElement("VOICE");
subelement.addElement("CELL"); subelement.addElement("CELL");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(businessMobile.trim());
if (business_mobile.trim().startsWith("{")) {
String xmlValue = business_mobile.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(business_mobile.trim());
}
} }
// Add business fax // Add business fax
if (business_fax != null && business_fax.trim().length() > 0) { if (businessFax != null && businessFax.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("WORK"); subelement.addElement("WORK");
subelement.addElement("FAX"); subelement.addElement("FAX");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(businessFax.trim());
if (business_fax.trim().startsWith("{")) {
String xmlValue = business_fax.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(business_fax.trim());
}
} }
// Add business pager // Add business pager
if (business_pager != null && business_pager.trim().length() > 0) { if (businessPager != null && businessPager.trim().length() > 0) {
subelement = vCard.addElement("TEL"); subelement = vCard.addElement("TEL");
subelement.addElement("WORK"); subelement.addElement("WORK");
subelement.addElement("PAGER"); subelement.addElement("PAGER");
Element number = subelement.addElement("NUMBER"); subelement.addElement("NUMBER").setText(businessPager.trim());
if (business_pager.trim().startsWith("{")) {
String xmlValue = business_pager.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
number.addAttribute("attrs", xmlValue.trim());
number.setText("{0}");
}
else {
number.setText(business_pager.trim());
}
} }
// Add job title // Add job title
if (business_job_title != null && business_job_title.trim().length() > 0) { if (businessJobTitle != null && businessJobTitle.trim().length() > 0) {
subelement = vCard.addElement("TITLE"); vCard.addElement("TITLE").setText(businessJobTitle.trim());
if (business_job_title.trim().startsWith("{")) {
String xmlValue = business_job_title.replaceAll("\\{", "");
xmlValue = xmlValue.replaceAll("}", "");
subelement.addAttribute("attrs", xmlValue.trim());
subelement.setText("{0}");
}
else {
subelement.setText(business_job_title.trim());
}
} }
// TODO Add job department // TODO Add job department
// TODO Add web page // TODO Add web page
String vcardXML = vCard.asXML(); // Generate content to store in property
String vcardXML;
StringWriter writer = new StringWriter();
OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
try {
xmlWriter.write(vCard);
vcardXML = writer.toString();
}
catch (IOException e) {
Log.error("Error pretty formating XML", e);
vcardXML = vCard.asXML();
}
StringBuilder sb = new StringBuilder(vcardXML.length()); StringBuilder sb = new StringBuilder(vcardXML.length());
sb.append("<![CDATA[").append(vcardXML).append("]]>"); sb.append("<![CDATA[").append(vcardXML).append("]]>");
// Save mapping as an XML property
JiveGlobals.setXMLProperty("ldap.vcard-mapping", sb.toString()); JiveGlobals.setXMLProperty("ldap.vcard-mapping", sb.toString());
}
/**
* Returns true if the vCard mappings where successfully loaded from the XML
* property.
*
* @return true if mappings where loaded from saved property.
*/
public boolean loadFromProperties() {
String xmlProperty = JiveGlobals.getXMLProperty("ldap.vcard-mapping");
if (xmlProperty == null || xmlProperty.trim().length() == 0) {
return false;
}
try {
Document document = DocumentHelper.parseText(xmlProperty);
Element vCard = document.getRootElement();
Element element = vCard.element("N");
if (element != null) {
name = element.elementTextTrim("GIVEN");
}
element = vCard.element("EMAIL");
if (element != null) {
email = element.elementTextTrim("USERID");
}
element = vCard.element("FN");
if (element != null) {
fullName = vCard.getTextTrim();
}
element = vCard.element("NICKNAME");
if (element != null) {
nickname = vCard.getTextTrim();
}
element = vCard.element("BDAY");
if (element != null) {
birthday = vCard.getTextTrim();
}
// TODO add rest of fields
}
catch (DocumentException e) {
Log.error("Error loading vcard mappings from property", e);
return false;
}
return true;
} }
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
String defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields"); String defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields");
String defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter"); String defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter");
if (serverType.equals("activedirectory")) { if (serverType.equals("activedirectory")) {
if (defaultUsernameField == null) { if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings // Initialize vCard mappings
vcardBean.initForActiveDirectory(); vcardBean.initForActiveDirectory();
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
} }
} }
else { else {
if (defaultUsernameField == null) { if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings // Initialize vCard mappings
vcardBean.initForOpenLDAP(); vcardBean.initForOpenLDAP();
} }
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter); JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter);
} }
// Save vCard mappings // Save vCard mappings
vcardBean.saveXMLProperties(); vcardBean.saveProperties();
// Enable the LDAP auth and user providers. The group provider will be enabled on the next step. // Enable the LDAP auth and user providers. The group provider will be enabled on the next step.
JiveGlobals.setXMLProperty("provider.user.className", JiveGlobals.setXMLProperty("provider.user.className",
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
- Street Address - Street Address
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homestreet" value="<%= vcardBean.getHome_street() %>" id="home_street" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homestreet" value="<%= vcardBean.getHomeStreet() %>" id="home_street" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
- City - City
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homecity" value="<%= vcardBean.getHome_city() %>" id="home_city" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homecity" value="<%= vcardBean.getHomeCity() %>" id="home_city" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
- State/Province - State/Province
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homestate" value="<%= vcardBean.getHome_state() %>" id="home_state" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homestate" value="<%= vcardBean.getHomeState() %>" id="home_state" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
- Postal Code - Postal Code
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homezip" value="<%= vcardBean.getHome_zip() %>" id="home_zip" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homezip" value="<%= vcardBean.getHomeZip() %>" id="home_zip" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
- Country - Country
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homecountry" value="<%= vcardBean.getHome_country() %>" id="home_country" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homecountry" value="<%= vcardBean.getHomeCountry() %>" id="home_country" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
- Phone Number - Phone Number
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homephone" value="<%= vcardBean.getHome_phone() %>" id="home_phone" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homephone" value="<%= vcardBean.getHomePhone() %>" id="home_phone" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
- Mobile Number - Mobile Number
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homemobile" value="<%= vcardBean.getHome_mobile() %>" id="home_mobile" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homemobile" value="<%= vcardBean.getHomeMobile() %>" id="home_mobile" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
- Fax - Fax
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homefax" value="<%= vcardBean.getHome_fax() %>" id="home_fax" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homefax" value="<%= vcardBean.getHomeFax() %>" id="home_fax" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
- Pager - Pager
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="homepager" value="<%= vcardBean.getHome_pager() %>" id="home_pager" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="homepager" value="<%= vcardBean.getHomePager() %>" id="home_pager" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -338,7 +338,7 @@ ...@@ -338,7 +338,7 @@
- Street Address - Street Address
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workstreet" value="<%= vcardBean.getBusiness_street() %>" id="business_street" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workstreet" value="<%= vcardBean.getBusinessStreet() %>" id="business_street" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -346,7 +346,7 @@ ...@@ -346,7 +346,7 @@
- City - City
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workcity" value="<%= vcardBean.getBusiness_city() %>" id="business_city" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workcity" value="<%= vcardBean.getBusinessCity() %>" id="business_city" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
- State/Province - State/Province
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workstate" value="<%= vcardBean.getBusiness_state() %>" id="business_state" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workstate" value="<%= vcardBean.getBusinessState() %>" id="business_state" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -362,7 +362,7 @@ ...@@ -362,7 +362,7 @@
- Postal Code - Postal Code
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workzip" value="<%= vcardBean.getBusiness_zip() %>" id="business_zip" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workzip" value="<%= vcardBean.getBusinessZip() %>" id="business_zip" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -370,7 +370,7 @@ ...@@ -370,7 +370,7 @@
- Country - Country
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workcountry" value="<%= vcardBean.getBusiness_country() %>" id="business_country" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workcountry" value="<%= vcardBean.getBusinessCountry() %>" id="business_country" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -378,7 +378,7 @@ ...@@ -378,7 +378,7 @@
- Job Title - Job Title
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="worktitle" value="<%= vcardBean.getBusiness_job_title() %>" id="business_job_title" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="worktitle" value="<%= vcardBean.getBusinessJobTitle() %>" id="business_job_title" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -386,7 +386,7 @@ ...@@ -386,7 +386,7 @@
- Department - Department
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workdept" value="<%= vcardBean.getBusiness_department() %>" id="business_department" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workdept" value="<%= vcardBean.getBusinessDepartment() %>" id="business_department" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -394,7 +394,7 @@ ...@@ -394,7 +394,7 @@
- Phone Number - Phone Number
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workphone" value="<%= vcardBean.getBusiness_phone() %>" id="business_phone" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workphone" value="<%= vcardBean.getBusinessPhone() %>" id="business_phone" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -402,7 +402,7 @@ ...@@ -402,7 +402,7 @@
- Mobile Number - Mobile Number
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workmobile" value="<%= vcardBean.getBusiness_mobile() %>" id="business_mobile" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workmobile" value="<%= vcardBean.getBusinessMobile() %>" id="business_mobile" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -410,7 +410,7 @@ ...@@ -410,7 +410,7 @@
- Fax - Fax
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workfax" value="<%= vcardBean.getBusiness_fax() %>" id="business_fax" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workfax" value="<%= vcardBean.getBusinessFax() %>" id="business_fax" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -418,7 +418,7 @@ ...@@ -418,7 +418,7 @@
- Pager - Pager
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="workpager" value="<%= vcardBean.getBusiness_pager() %>" id="business_pager" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workpager" value="<%= vcardBean.getBusinessPager() %>" id="business_pager" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -426,7 +426,7 @@ ...@@ -426,7 +426,7 @@
- Web page - Web page
</td> </td>
<td class="jive-vcardTable-value"> <td class="jive-vcardTable-value">
<input type="text" name="workurl" value="<%= vcardBean.getBusiness_web_page() %>" id="business_web_page" size="22" maxlength="50" onFocus="jiveRowHighlight(this);"> <input type="text" name="workurl" value="<%= vcardBean.getBusinessWebPage() %>" id="business_web_page" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td> </td>
</tr> </tr>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment