added user export functionality and refined the user import functionality,

including a lot of functionality associated with VCards
This commit is contained in:
Eric J. Bowersox 2004-06-13 05:12:09 +00:00
parent e6e94f3427
commit 7061d88b22
21 changed files with 2074 additions and 68 deletions

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -343,6 +343,17 @@ public class StringUtil
} // end isBooleanTrue } // end isBooleanTrue
public static final boolean areEqual(String s1, String s2)
{
if (s1==null)
return (s2==null);
else if (s2==null)
return false;
else
return s1.equals(s2);
} // end areEqual
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Static initializer * Static initializer
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -44,9 +44,9 @@ public interface AdminOperations
public abstract void setProperties(GlobalProperties props) throws DataException; public abstract void setProperties(GlobalProperties props) throws DataException;
public abstract AdminUserContext createNewAccount(String username, String password, String reminder, public abstract AdminUserContext createNewAccount(String username, String password, boolean prehashed,
boolean verify_email, boolean lockout, Role base_role, String reminder, boolean verify_email, boolean lockout,
String description, boolean auto_join) Role base_role, String description, boolean auto_join)
throws DataException, AccessError; throws DataException, AccessError;
public abstract List getIPBanInfo() throws DataException; public abstract List getIPBanInfo() throws DataException;

View File

@ -9,14 +9,16 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core; package com.silverwrist.venice.core;
import java.io.IOException;
import java.io.Writer;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
@ -73,4 +75,6 @@ public interface AdminUserContext
public abstract void setProperties(AdminUserProperties props) throws DataException; public abstract void setProperties(AdminUserProperties props) throws DataException;
public abstract void export(Writer xml) throws IOException, DataException;
} // end interface AdminUserContext } // end interface AdminUserContext

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -126,6 +126,8 @@ public interface ContactInfo
public abstract void importVCard(VCard vc); public abstract void importVCard(VCard vc);
public abstract VCard exportVCard();
public abstract boolean canSetPhoto(); public abstract boolean canSetPhoto();
} // end interface ContactInfo } // end interface ContactInfo

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -21,6 +21,7 @@ import java.util.Date;
import com.silverwrist.venice.except.AccessError; import com.silverwrist.venice.except.AccessError;
import com.silverwrist.venice.except.DataException; import com.silverwrist.venice.except.DataException;
import com.silverwrist.venice.except.EmailException; import com.silverwrist.venice.except.EmailException;
import com.silverwrist.venice.util.VCard;
public interface UserProfile public interface UserProfile
{ {
@ -76,6 +77,8 @@ public interface UserProfile
public abstract boolean isAnonymous(); public abstract boolean isAnonymous();
public abstract VCard getVCard();
public abstract boolean canSendQuickEmail(); public abstract boolean canSendQuickEmail();
public abstract void sendQuickEmail(String subject, String text) public abstract void sendQuickEmail(String subject, String text)

View File

@ -276,7 +276,7 @@ class AdminOperationsImpl implements AdminOperations
} // end setProperties } // end setProperties
public AdminUserContext createNewAccount(String username, String password, String reminder, public AdminUserContext createNewAccount(String username, String password, boolean prehashed, String reminder,
boolean verify_email, boolean lockout, Role base_role, boolean verify_email, boolean lockout, Role base_role,
String description, boolean auto_join) String description, boolean auto_join)
throws DataException, AccessError throws DataException, AccessError
@ -288,7 +288,7 @@ class AdminOperationsImpl implements AdminOperations
base_role = env.getDefaultRole("Global.NewUser"); base_role = env.getDefaultRole("Global.NewUser");
// Create the user account. // Create the user account.
ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getRemoteAddress(),username,password,reminder, ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getRemoteAddress(),username,password,prehashed,reminder,
verify_email,lockout,0,base_role,description); verify_email,lockout,0,base_role,description);
if (auto_join) if (auto_join)

View File

@ -9,14 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.impl;
import java.io.*;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
@ -27,6 +28,8 @@ import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.*; import com.silverwrist.venice.security.*;
import com.silverwrist.venice.svc.SecurityMonitorEnvironment;
import com.silverwrist.venice.util.BuildVCard;
class AdminUserContextImpl implements AdminUserContext class AdminUserContextImpl implements AdminUserContext
{ {
@ -621,6 +624,121 @@ class AdminUserContextImpl implements AdminUserContext
} // end setProperties } // end setProperties
public void export(Writer xml) throws IOException, DataException
{
// get the community-level security monitor
SecurityMonitorEnvironment sm_env =
(SecurityMonitorEnvironment)(env.getGlobalSite().queryService(SecurityMonitorEnvironment.class));
SecurityMonitor cmon = sm_env.getMonitor("Community");
// get the contact information
ContactInfoImpl ci = new ContactInfoImpl(env,contactid,true);
// some things we need a database connection for...
String hash = null, reminder = null;
List join_comms = null;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get the password and password reminder
conn = env.getConnection();
stmt = conn.prepareStatement("SELECT passhash, passreminder FROM users WHERE uid = ?;");
stmt.setInt(1,uid);
rs = stmt.executeQuery();
if (!(rs.next()))
throw new DataException("internal error: can\'t find user record for uid " + uid);
hash = rs.getString(1);
reminder = rs.getString(2);
// get the list of communities of which we're a member
rs.close();
stmt.close();
stmt = conn.prepareStatement("SELECT s.alias, m.granted_lvl FROM sigmember m, sigs s "
+ "WHERE s.sigid = m.sigid AND m.uid = ?;");
stmt.setInt(1,uid);
rs = stmt.executeQuery();
while (rs.next())
{ // load alias and grant levels
Role r = cmon.getRoleForLevel(rs.getInt(2));
Object[] foo = new Object[] { rs.getString(1), r };
if (join_comms==null)
join_comms = new ArrayList();
join_comms.add(foo);
} // end while
if (join_comms==null)
join_comms = Collections.EMPTY_LIST;
} // end try
catch (SQLException e)
{ // translate the SQLException
throw new DataException("Database error: " + e.getMessage(),e);
} // end catch
finally
{ // shut down everything
SQLUtil.shutdown(rs);
SQLUtil.shutdown(stmt);
SQLUtil.shutdown(conn);
} // end finally
xml.write("<venice-user id=\"" + uid + "\">\n");
xml.write("<username>" + username + "</username>\n");
xml.write("<password prehashed=\"true\">" + hash + "</password>\n");
xml.write("<password-reminder>" + reminder + "</password-reminder>\n");
xml.write("<description>" + description + "</description>\n");
xml.write("<options confirmed=\"");
xml.write(email_verified ? "true" : "false");
xml.write("\" locked=\"");
xml.write(lockout ? "true" : "false");
xml.write("\" role=\"");
xml.write(env.getRoleForLevel(level).getSymbol());
xml.write("\" hideaddr=\"");
xml.write(ci.getPrivateAddress() ? "true" : "false");
xml.write("\" hidephone=\"");
xml.write(ci.getPrivatePhone() ? "true" : "false");
xml.write("\" hidefax=\"");
xml.write(ci.getPrivateFax() ? "true" : "false");
xml.write("\" hideemail=\"");
xml.write(ci.getPrivateEmail() ? "true" : "false");
xml.write("\" autojoin=\"");
xml.write(email_verified ? "true" : "false");
xml.write("\" postpictures=\"");
xml.write(flags.get(UserContextImpl.BF_POSTPICTURES) ? "true" : "false");
xml.write("\" optout=\"");
xml.write(flags.get(UserContextImpl.BF_ADM_NOPHOTO) ? "true" : "false");
xml.write("\" nophoto=\"");
xml.write(flags.get(UserContextImpl.BF_MASSMAIL_OPTOUT) ? "true" : "false");
xml.write("\" locale=\"");
xml.write(my_locale.toString());
xml.write("\" zonehint=\"");
xml.write(my_tz.getID());
xml.write("\" />\n");
// get the vCard info and serialize it
BuildVCard bvc = ci.getVCardBuilder();
bvc.setTimeZone(my_tz);
bvc.create().exportXML(xml);
for (Iterator it=join_comms.iterator(); it.hasNext(); )
{ // add <join/> elements for communities user is a member of
Object[] foo = (Object[])(it.next());
xml.write("<join role=\"");
xml.write(((Role)(foo[1])).getSymbol());
xml.write("\">");
xml.write(foo[0].toString());
xml.write("</join>\n");
} // end for
// all done!
xml.write("</venice-user>\n");
} // end export
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Package-level static operations * Package-level static operations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -923,6 +923,12 @@ class ContactInfoImpl implements ContactInfo, Stashable
} // end importVCard } // end importVCard
public VCard exportVCard()
{
return getVCardBuilder().create();
} // end exportVCard
public boolean canSetPhoto() public boolean canSetPhoto()
{ {
return can_set_photo; return can_set_photo;
@ -1096,4 +1102,96 @@ class ContactInfoImpl implements ContactInfo, Stashable
} // end stash } // end stash
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
BuildVCard getVCardBuilder()
{
BuildVCard bvc = new BuildVCard();
bvc.setFamilyName(family_name);
bvc.setGivenName(given_name);
bvc.setMiddleName(new String(new char[] { middle_initial }));
bvc.setPrefix(prefix);
bvc.setSuffix(suffix);
bvc.setOrganizationName(company);
bvc.setURL(url);
// add the address to the VCard
BuildVCardAddress baddr = new BuildVCardAddress();
baddr.setHomeAddress(true);
baddr.setWorkAddress(true);
baddr.setPreferred(true);
if (addr1!=null)
{ // save off address
if (addr2!=null)
{ // set extension, then street
baddr.setExtension(addr1);
baddr.setStreet(addr2);
} // end if
else // set the street address
baddr.setStreet(addr1);
} // end if
baddr.setLocality(locality);
baddr.setRegion(region);
baddr.setPostalCode(postal_code);
baddr.setCountry(country);
bvc.addAddress(baddr.create());
// Add phone number.
BuildVCardPhone bphone = new BuildVCardPhone();
if (phone!=null)
{ // set attributes and number
bphone.setHomePhone(true);
bphone.setWorkPhone(true);
bphone.setVoicePhone(true);
bphone.setNumber(phone);
bvc.addPhone(bphone.create());
bphone.reset();
} // end if
// Add fax number.
if (fax!=null)
{ // set attributes and number
bphone.setHomePhone(true);
bphone.setWorkPhone(true);
bphone.setFax(true);
bphone.setNumber(fax);
bvc.addPhone(bphone.create());
bphone.reset();
} // end if
// Add mobile number.
if (mobile!=null)
{ // set attributes and number
bphone.setCellPhone(true);
bphone.setPCSPhone(true);
bphone.setNumber(mobile);
bvc.addPhone(bphone.create());
} // end if
// Add E-mail address.
if (email!=null)
{ // set attributes and address
BuildVCardEmail bemail = new BuildVCardEmail();
bemail.setHomeEmail(true);
bemail.setWorkEmail(true);
bemail.setInternetEmail(true);
bemail.setPreferred(true);
bemail.setAddress(email);
bvc.addEmailAddress(bemail.create());
} // end if
return bvc;
} // end getVCardBuilder
} // end class ContactInfoImpl } // end class ContactInfoImpl

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -1802,7 +1802,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
*/ */
static final ReturnNewUser createAccount(EnvEngine env, String remote_addr, String username, String password, static final ReturnNewUser createAccount(EnvEngine env, String remote_addr, String username, String password,
String reminder, boolean verify_email, boolean lockout, boolean prehashed, String reminder, boolean verify_email, boolean lockout,
int confirm_num, Role base_role, String description) int confirm_num, Role base_role, String description)
throws AccessError, DataException throws AccessError, DataException
{ {
@ -1833,7 +1833,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
SQLUtil.shutdown(rs); SQLUtil.shutdown(rs);
// Insert a new record for this user // Insert a new record for this user
String hash_value = Generator.hashPassword(password); String hash_value = (prehashed ? password : Generator.hashPassword(password));
StringBuffer sql = StringBuffer sql =
new StringBuffer("INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, " new StringBuffer("INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, "
+ "base_lvl, created, lastaccess, passreminder, description) VALUES ('"); + "base_lvl, created, lastaccess, passreminder, description) VALUES ('");

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -25,7 +25,7 @@ import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*; import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
import com.silverwrist.venice.util.MailSend; import com.silverwrist.venice.util.*;
class UserProfileImpl implements UserProfile class UserProfileImpl implements UserProfile
{ {
@ -435,6 +435,95 @@ class UserProfileImpl implements UserProfile
} // end isAnonymous } // end isAnonymous
public VCard getVCard()
{
BuildVCard bvc = new BuildVCard();
bvc.setFamilyName(family_name);
bvc.setGivenName(given_name);
bvc.setMiddleName(new String(new char[] { middle_initial }));
bvc.setPrefix(prefix);
bvc.setSuffix(suffix);
bvc.setNickname(username);
bvc.setOrganizationName(company);
bvc.setNote(descr);
bvc.setURL(url);
// add the address to the VCard
BuildVCardAddress baddr = new BuildVCardAddress();
baddr.setHomeAddress(true);
baddr.setWorkAddress(true);
baddr.setPreferred(true);
if (addr1!=null)
{ // save off address
if (addr2!=null)
{ // set extension, then street
baddr.setExtension(addr1);
baddr.setStreet(addr2);
} // end if
else // set the street address
baddr.setStreet(addr1);
} // end if
baddr.setLocality(locality);
baddr.setRegion(region);
baddr.setPostalCode(postal_code);
baddr.setCountry(country);
bvc.addAddress(baddr.create());
// Add phone number.
BuildVCardPhone bphone = new BuildVCardPhone();
if (phone!=null)
{ // set attributes and number
bphone.setHomePhone(true);
bphone.setWorkPhone(true);
bphone.setVoicePhone(true);
bphone.setNumber(phone);
bvc.addPhone(bphone.create());
bphone.reset();
} // end if
// Add fax number.
if (fax!=null)
{ // set attributes and number
bphone.setHomePhone(true);
bphone.setWorkPhone(true);
bphone.setFax(true);
bphone.setNumber(fax);
bvc.addPhone(bphone.create());
bphone.reset();
} // end if
// Add mobile number.
if (mobile!=null)
{ // set attributes and number
bphone.setCellPhone(true);
bphone.setPCSPhone(true);
bphone.setNumber(mobile);
bvc.addPhone(bphone.create());
} // end if
// Add E-mail address.
if (email!=null)
{ // set attributes and address
BuildVCardEmail bemail = new BuildVCardEmail();
bemail.setHomeEmail(true);
bemail.setWorkEmail(true);
bemail.setInternetEmail(true);
bemail.setPreferred(true);
bemail.setAddress(email);
bvc.addEmailAddress(bemail.create());
} // end if
return bvc.create();
} // end getVCard
public boolean canSendQuickEmail() public boolean canSendQuickEmail()
{ {
return !is_anon && !(env.isAnonymous()); return !is_anon && !(env.isAnonymous());

View File

@ -871,7 +871,7 @@ public class VeniceEngineImpl implements VeniceEngine, ServiceProvider, EngineBa
logger.debug("createNewAccount(\"" + username + "\",<password>,<reminder>)..."); logger.debug("createNewAccount(\"" + username + "\",<password>,<reminder>)...");
// Create the user account. // Create the user account.
ReturnNewUser rnu = UserContextImpl.createAccount(env,remote_addr,username,password,reminder,false, ReturnNewUser rnu = UserContextImpl.createAccount(env,remote_addr,username,password,false,reminder,false,
false,confirm_num,new_role,null); false,confirm_num,new_role,null);
// create a new context for the user (they're now effectively logged in) // create a new context for the user (they're now effectively logged in)

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -89,10 +89,11 @@ public class ImportHelper
DOMElementHelper h = new DOMElementHelper((Element)n); DOMElementHelper h = new DOMElementHelper((Element)n);
String id = h.getElement().getAttribute("id"); String id = h.getElement().getAttribute("id");
String username = null, password = null, reminder = null, description = null; String username = null, password = null, reminder = null, description = null;
String zonehint = null; String zonehint = null, locale = "en_US";
Role r = default_role; Role r = default_role;
boolean confirm = false, locked = false, hideaddr = false, hidephone = false, hidefax = false; boolean confirm = false, locked = false, hideaddr = false, hidephone = false, hidefax = false;
boolean hideemail = false, autojoin = true; boolean hideemail = false, autojoin = true, prehashed = false, post_pics = false, opt_out = false;
boolean no_photo = false;
VCard vcard = null; VCard vcard = null;
ArrayList join_list = null; ArrayList join_list = null;
@ -105,10 +106,15 @@ public class ImportHelper
username = username.trim(); username = username.trim();
if (!(IDUtils.isValidVeniceID(username))) if (!(IDUtils.isValidVeniceID(username)))
throw new ValidationException("<username/> \"" + username + "\" is not a valid Venice ID"); throw new ValidationException("<username/> \"" + username + "\" is not a valid Venice ID");
password = h.getSubElementText("password"); Element pelt = h.getSubElement("password");
if (pelt==null)
throw new ValidationException("no <password/> element found");
DOMElementHelper hh = new DOMElementHelper(pelt);
password = hh.getElementText();
if (password==null) if (password==null)
throw new ValidationException("no <password/> element found"); throw new ValidationException("no <password/> element found");
password = password.trim(); password = password.trim();
prehashed = loader.loadGetAttributeBoolean(pelt,"prehashed",prehashed);
reminder = h.getSubElementText("password-reminder"); reminder = h.getSubElementText("password-reminder");
if (reminder!=null) if (reminder!=null)
reminder = reminder.trim(); reminder = reminder.trim();
@ -134,6 +140,11 @@ public class ImportHelper
hidefax = loader.loadGetAttributeBoolean(opts,"hidefax",hidefax); hidefax = loader.loadGetAttributeBoolean(opts,"hidefax",hidefax);
hideemail = loader.loadGetAttributeBoolean(opts,"hideemail",hideemail); hideemail = loader.loadGetAttributeBoolean(opts,"hideemail",hideemail);
autojoin = loader.loadGetAttributeBoolean(opts,"autojoin",autojoin); autojoin = loader.loadGetAttributeBoolean(opts,"autojoin",autojoin);
post_pics = loader.loadGetAttributeBoolean(opts,"postpictures",post_pics);
opt_out = loader.loadGetAttributeBoolean(opts,"optout",opt_out);
no_photo = loader.loadGetAttributeBoolean(opts,"nophoto",no_photo);
if (hopts.hasAttribute("locale"))
locale = opts.getAttribute("locale").trim();
if (hopts.hasAttribute("zonehint")) if (hopts.hasAttribute("zonehint"))
zonehint = opts.getAttribute("zonehint").trim(); zonehint = opts.getAttribute("zonehint").trim();
@ -229,7 +240,7 @@ public class ImportHelper
// EXECUTE PHASE - make this user go! // EXECUTE PHASE - make this user go!
try try
{ // create the user context { // create the user context
AdminUserContext uc = adm.createNewAccount(username,password,reminder,confirm,locked,r, AdminUserContext uc = adm.createNewAccount(username,password,prehashed,reminder,confirm,locked,r,
description,autojoin); description,autojoin);
// set up the contact info // set up the contact info
@ -241,6 +252,11 @@ public class ImportHelper
ci.importVCard(vcard); ci.importVCard(vcard);
uc.putContactInfo(ci); uc.putContactInfo(ci);
// set up the locale
Locale l = International.get().createLocale(locale);
if (l!=null)
uc.setLocale(l);
// set up the timezone // set up the timezone
String tmp = vcard.getTimeZone(); String tmp = vcard.getTimeZone();
if (tmp!=null) if (tmp!=null)
@ -268,6 +284,13 @@ public class ImportHelper
} // end if } // end if
// set the user properties
AdminUserProperties props = uc.getProperties();
props.setDisplayPostPictures(post_pics);
props.setMassMailOptOut(opt_out);
props.setDisallowPhoto(no_photo);
uc.setProperties(props);
if (join_list!=null) if (join_list!=null)
{ // set up the community membership { // set up the community membership
for (int j=0; j<join_list.size(); j+=2) for (int j=0; j<join_list.size(); j+=2)

View File

@ -0,0 +1,102 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui.helpers;
import java.io.*;
import java.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.DataException;
import com.silverwrist.venice.except.InternalStateError;
import com.silverwrist.venice.ui.ContentExecute;
import com.silverwrist.venice.ui.RequestExec;
public class UserExportHelper implements ContentExecute
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int m_length;
private InputStream m_stm;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public UserExportHelper(AdminOperations adm, Collection userdata) throws DataException, IOException
{
// Start by normalizing the user data.
ArrayList tmp = new ArrayList(userdata.size());
Iterator it;
for (it=userdata.iterator(); it.hasNext(); )
{ // morph all the objects...
Object o = it.next();
if (o==null)
continue;
if (o instanceof AdminUserContext)
tmp.add((AdminUserContext)o);
else if (o instanceof UserContext)
tmp.add(adm.getUserContext(((UserContext)o).getUID()));
else if (o instanceof UserProfile)
tmp.add(adm.getUserContext(((UserProfile)o).getUID()));
else if (o instanceof Number)
tmp.add(adm.getUserContext(((Number)o).intValue()));
else
tmp.add(adm.getUserContext(o.toString()));
} // end for
StringWriter wr = new StringWriter();
wr.write("<?xml version=\"1.0\"?>\n<venice-import-users>\n");
for (it=tmp.iterator(); it.hasNext(); )
{ // get each user and export it
AdminUserContext uc = (AdminUserContext)(it.next());
uc.export(wr);
} // end for
wr.write("</venice-import-users>\n");
try
{ // convert the output so it acts like an attachment
byte[] ary = wr.toString().getBytes("UTF-8");
m_length = ary.length;
m_stm = new ByteArrayInputStream(ary);
} // end try
catch (UnsupportedEncodingException e)
{ // this is not supposed to happen
throw new InternalStateError("encoding not found?!?!?!?");
} // end catch
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface ContentExecute
*--------------------------------------------------------------------------------
*/
public void execute(RequestExec req) throws IOException
{
req.sendBinary("text/xml","export-data.xml",m_length,m_stm);
} // end execute
} // end class UserExportHelper

View File

@ -0,0 +1,429 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.util;
import java.util.*;
public class BuildVCard
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String formatted_name = null;
private String family_name = null;
private String given_name = null;
private String middle_name = null;
private String prefix = null;
private String suffix = null;
private String nickname = null;
private HashSet addresses = new HashSet();
private HashSet phones = new HashSet();
private HashSet email_addresses = new HashSet();
private String mailer = null;
private String timezone = null;
private String title = null;
private String role = null;
private String orgname = null;
private String note = null;
private String sort_string = null;
private String url = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public BuildVCard()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final String realFormattedName()
{
if (formatted_name!=null)
return formatted_name;
StringBuffer buf = new StringBuffer();
if (prefix!=null)
buf.append(prefix).append(' ');
if (given_name!=null)
buf.append(given_name);
if ((middle_name!=null) || (family_name!=null))
buf.append(' ');
if (middle_name!=null)
{ // figure out the middle name
buf.append(middle_name);
if (middle_name.length()==1)
buf.append('.');
if (family_name!=null)
buf.append(' ');
} // end if
if (family_name!=null)
buf.append(family_name);
if (suffix!=null)
buf.append(' ').append(suffix);
String s = buf.toString();
if (s.length()==0)
return null;
return s;
} // end realFormattedName
/*--------------------------------------------------------------------------------
* Public getters/setters
*--------------------------------------------------------------------------------
*/
public final String getFormattedName()
{
return formatted_name;
} // end getFormattedName
public final void setFormattedName(String s)
{
formatted_name = s;
} // end setFormattedName
public final String getFamilyName()
{
return family_name;
} // end getFamilyName
public final void setFamilyName(String s)
{
family_name = s;
} // end setFamilyName
public final String getGivenName()
{
return given_name;
} // end getGivenName
public final void setGivenName(String s)
{
given_name = s;
} // end setGivenName
public final String getMiddleName()
{
return middle_name;
} // end getMiddleName
public final void setMiddleName(String s)
{
middle_name = s;
} // end setMiddleName
public final String getPrefix()
{
return prefix;
} // end getPrefix
public final void setPrefix(String s)
{
prefix = s;
} // end setPrefix
public final String getSuffix()
{
return suffix;
} // end getSuffix
public final void setSuffix(String s)
{
suffix = s;
} // end setSuffix
public final String getNickname()
{
return nickname;
} // end getNickname
public final void setNickname(String s)
{
nickname = s;
} // end setNickname
public final String getMailer()
{
return mailer;
} // end getMailer
public final void setMailer(String s)
{
mailer = s;
} // end setMailer
public final String getTimeZone()
{
return timezone;
} // end getTimeZone
public final void setTimeZone(String s)
{
if ((s!=null) && !VCard.validateTZText(s))
throw new IllegalArgumentException("not a valid timezone string");
timezone = s;
} // end setTimeZone
public final void setTimeZone(TimeZone tz)
{
int ofs = tz.getRawOffset();
StringBuffer buf = new StringBuffer();
if (ofs<0)
{ // negative offset
buf.append('-');
ofs = -ofs;
} // end if
else // positive offset
buf.append('+');
ofs /= 60000; // convert to minutes
int hrs = ofs / 60; // get hours
if (hrs>=10)
buf.append(hrs);
else
buf.append('0').append(hrs);
buf.append(':');
ofs -= (hrs * 60); // get minutes
if (ofs>=10)
buf.append(ofs);
else
buf.append('0').append(ofs);
timezone = buf.toString();
} // end setTimeZone
public final String getTitle()
{
return title;
} // end getTitle
public final void setTitle(String s)
{
title = s;
} // end setTitle
public final String getRole()
{
return role;
} // end getRole
public final void setRole(String s)
{
role = s;
} // end setRole
public final String getOrganizationName()
{
return orgname;
} // end getOrganizationName
public final void setOrganizationName(String s)
{
orgname = s;
} // end setOrganizationName
public final String getNote()
{
return note;
} // end getNode
public final void setNote(String s)
{
note = s;
} // end setNote
public final String getSortString()
{
return sort_string;
} // end getSortString
public final void setSortString(String s)
{
sort_string = s;
} // end sort_string
public final String getURL()
{
return url;
} // end getURL
public final void setURL(String s)
{
url = s;
} // end setURL
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void reset()
{
formatted_name = null;
family_name = null;
given_name = null;
middle_name = null;
prefix = null;
suffix = null;
nickname = null;
addresses.clear();
phones.clear();
email_addresses.clear();
mailer = null;
timezone = null;
title = null;
role = null;
orgname = null;
note = null;
sort_string = null;
url = null;
} // end reset
public VCard create()
{
return new VCard(realFormattedName(),family_name,given_name,middle_name,prefix,suffix,nickname,addresses,phones,
email_addresses,mailer,timezone,title,role,orgname,note,sort_string,url);
} // end create
public final List getAddresses()
{
if (addresses.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(addresses);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getAddresses
public final List getPhones()
{
if (phones.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(phones);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getPhones
public final List getEmailAddresses()
{
if (email_addresses.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(email_addresses);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getEmailAddresses
public final void addAddress(VCardAddress addr)
{
addresses.add(addr);
} // end addAddress
public final void removeAddress(VCardAddress addr)
{
addresses.remove(addr);
} // end removeAddress
public final void removeAllAddresses()
{
addresses.clear();
} // end removeAllAddresses
public final void addPhone(VCardPhone phone)
{
phones.add(phone);
} // end addPhone
public final void removePhone(VCardPhone phone)
{
phones.remove(phone);
} // end removePhone
public final void removeAllPhones()
{
phones.clear();
} // end removeAllPhones
public final void addEmailAddress(VCardEmail email)
{
email_addresses.add(email);
} // end addEmailAddress
public final void removeEmailAddress(VCardEmail email)
{
email_addresses.remove(email);
} // end removeEmailAddress
public final void removeAllEmailAddresses()
{
email_addresses.clear();
} // end removeAllEmailAddresses
} // end class BuildVCard

View File

@ -0,0 +1,259 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.util;
public class BuildVCardAddress
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private boolean home_adr = false;
private boolean work_adr = false;
private boolean postal_adr = false;
private boolean parcel_adr = false;
private boolean domestic_adr = false;
private boolean intl_adr = false;
private boolean preferred = false;
private String pobox = null;
private String ext_address = null;
private String street = null;
private String locality = null;
private String region = null;
private String postal_code = null;
private String country = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public BuildVCardAddress()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Public getters/setters
*--------------------------------------------------------------------------------
*/
public final boolean isHomeAddress()
{
return home_adr;
} // end isHomeAddress
public final void setHomeAddress(boolean f)
{
home_adr = f;
} // end setHomeAddress
public final boolean isWorkAddress()
{
return work_adr;
} // end isWorkAddress
public final void setWorkAddress(boolean f)
{
work_adr = f;
} // end setWorkAddress
public final boolean isPostalAddress()
{
return postal_adr;
} // end isPostalAddress
public final void setPostalAddress(boolean f)
{
postal_adr = f;
} // end setPostalAddress
public final boolean isParcelAddress()
{
return parcel_adr;
} // end isParcelAddress
public final void setParcelAddress(boolean f)
{
parcel_adr = f;
} // end setParcelAddress
public final boolean isDomesticAddress()
{
return domestic_adr;
} // end isDomesticAddress
public final void setDomesticAddress(boolean f)
{
domestic_adr = f;
if (domestic_adr && intl_adr)
intl_adr = false;
} // end setDomesticAddress
public final boolean isInternationalAddress()
{
return intl_adr;
} // end isInternationalAddress
public final void setInternationalAddress(boolean f)
{
intl_adr = f;
if (domestic_adr && intl_adr)
domestic_adr = false;
} // end setInternationalAddress
public final boolean isPreferred()
{
return preferred;
} // end isPreferred
public final void setPreferred(boolean f)
{
preferred = f;
} // end setPreferred
public final String getPOBox()
{
return pobox;
} // end getPOBox
public final void setPOBox(String s)
{
pobox = s;
} // end setPOBox
public final String getExtension()
{
return ext_address;
} // end getExtension
public final void setExtension(String s)
{
ext_address = s;
} // end setExtension
public final String getStreet()
{
return street;
} // end getStreet
public final void setStreet(String s)
{
street = s;
} // end setStreet
public final String getLocality()
{
return locality;
} // end getLocality
public final void setLocality(String s)
{
locality = s;
} // end setLocality
public final String getRegion()
{
return region;
} // end getRegion
public final void setRegion(String s)
{
region = s;
} // end setRegion
public final String getPostalCode()
{
return postal_code;
} // end getPostalCode
public final void setPostalCode(String s)
{
postal_code = s;
} // end setPostalCode
public final String getCountry()
{
return country;
} // end getCountry
public final void setCountry(String s)
{
country = s;
} // end setCountry
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void reset()
{
home_adr = false;
work_adr = false;
postal_adr = false;
parcel_adr = false;
domestic_adr = false;
intl_adr = false;
preferred = false;
pobox = null;
ext_address = null;
street = null;
locality = null;
region = null;
postal_code = null;
country = null;
} // end reset
public VCardAddress create()
{
return new VCardAddress(home_adr,work_adr,postal_adr,parcel_adr,domestic_adr,intl_adr,preferred,pobox,ext_address,
street,locality,region,postal_code,country);
} // end create
} // end class BuildVCardAddress

View File

@ -0,0 +1,142 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.util;
public class BuildVCardEmail
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private boolean home_email = false;
private boolean work_email = false;
private boolean internet_email = false;
private boolean x400_email = false;
private boolean preferred = false;
private String address = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public BuildVCardEmail()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Public getters/setters
*--------------------------------------------------------------------------------
*/
public final boolean isHomeEmail()
{
return home_email;
} // end isHomeEmail
public final void setHomeEmail(boolean f)
{
home_email = f;
} // end setHomeEmail
public final boolean isWorkEmail()
{
return work_email;
} // end isHomeEmail
public final void setWorkEmail(boolean f)
{
work_email = f;
} // end setWorkEmail
public final boolean isInternetEmail()
{
return internet_email;
} // end isInternetEmail
public final void setInternetEmail(boolean f)
{
internet_email = f;
} // end setInternetEmail
public final boolean isX400Email()
{
return x400_email;
} // end isX400Email
public final void setX400Email(boolean f)
{
x400_email = f;
} // end setX400Email
public final boolean isPreferred()
{
return preferred;
} // end isPreferred
public final void setPreferred(boolean f)
{
preferred = f;
} // end setPreferred
public final String getAddress()
{
return address;
} // end getAddress
public final void setAddress(String s)
{
address = s;
} // end setAddress
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void reset()
{
home_email = false;
work_email = false;
internet_email = false;
x400_email = false;
preferred = false;
address = null;
} // end reset
public VCardEmail create()
{
return new VCardEmail(home_email,work_email,internet_email,x400_email,preferred,address);
} // end create
} // end class BuildVCardEmail

View File

@ -0,0 +1,255 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.util;
public class BuildVCardPhone
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private boolean home_phone = false;
private boolean work_phone = false;
private boolean voice_phone = false;
private boolean fax_phone = false;
private boolean pager = false;
private boolean message = false;
private boolean cell_phone = false;
private boolean video_phone = false;
private boolean bbs_phone = false;
private boolean modem_phone = false;
private boolean isdn_phone = false;
private boolean pcs_phone = false;
private boolean preferred = false;
private String number = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public BuildVCardPhone()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Public getters/setters
*--------------------------------------------------------------------------------
*/
public final boolean isHomePhone()
{
return home_phone;
} // end isHomePhone
public final void setHomePhone(boolean f)
{
home_phone = f;
} // end setHomePhone
public final boolean isWorkPhone()
{
return work_phone;
} // end isWorkPhone
public final void setWorkPhone(boolean f)
{
work_phone = f;
} // end setWorkPhone
public final boolean isVoicePhone()
{
return voice_phone;
} // end isVoicePhone
public final void setVoicePhone(boolean f)
{
voice_phone = f;
} // end setVoicePhone
public final boolean isFax()
{
return fax_phone;
} // end isFax
public final void setFax(boolean f)
{
fax_phone = f;
} // end setFax
public final boolean isPager()
{
return pager;
} // end isPager
public final void setPager(boolean f)
{
pager = f;
} // end setPager
public final boolean isMessage()
{
return message;
} // end isMessage
public final void setMessage(boolean f)
{
message = f;
} // end setMessage
public final boolean isCellPhone()
{
return cell_phone;
} // end isCellPhone
public final void setCellPhone(boolean f)
{
cell_phone = f;
} // end setCellPhone
public final boolean isVideoPhone()
{
return video_phone;
} // end isVideoPhone
public final void setVideoPhone(boolean f)
{
video_phone = f;
} // end setVideoPhone
public final boolean isBBS()
{
return bbs_phone;
} // end isBBS
public final void setBBS(boolean f)
{
bbs_phone = f;
} // end setBBS
public final boolean isModemPhone()
{
return modem_phone;
} // end isModemPhone
public final void setModemPhone(boolean f)
{
modem_phone = f;
} // end setModemPhone
public final boolean isISDNPhone()
{
return isdn_phone;
} // end isISDNPhone
public final void setISDNPhone(boolean f)
{
isdn_phone = f;
} // end setISDNPhone
public final boolean isPCSPhone()
{
return pcs_phone;
} // end isPCSPhone
public final void setPCSPhone(boolean f)
{
pcs_phone = f;
} // end setPCSPhone
public final boolean isPreferred()
{
return preferred;
} // end isPreferred
public final void setPreferred(boolean f)
{
preferred = f;
} // end setPreferred
public final String getNumber()
{
return number;
} // end getNumber
public final void setNumber(String s)
{
number = s;
} // end setNumber
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void reset()
{
home_phone = false;
work_phone = false;
voice_phone = false;
fax_phone = false;
pager = false;
message = false;
cell_phone = false;
video_phone = false;
bbs_phone = false;
modem_phone = false;
isdn_phone = false;
pcs_phone = false;
preferred = false;
number = null;
} // end reset
public VCardPhone create()
{
return new VCardPhone(home_phone,work_phone,voice_phone,fax_phone,pager,message,cell_phone,video_phone,bbs_phone,
modem_phone,isdn_phone,pcs_phone,preferred,number);
} // end create
} // end class BuildVCardPhone

View File

@ -9,14 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.util; package com.silverwrist.venice.util;
import java.io.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import org.w3c.dom.*; import org.w3c.dom.*;
@ -57,10 +58,35 @@ public class VCard
private String url = null; private String url = null;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructors
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
VCard(String formatted_name, String family_name, String given_name, String middle_name, String prefix, String suffix,
String nickname, Collection addresses, Collection phones, Collection email_addresses, String mailer,
String timezone, String title, String role, String orgname, String note, String sort_string, String url)
{
this.formatted_name = formatted_name;
this.family_name = family_name;
this.given_name = given_name;
this.middle_name = middle_name;
this.prefix = prefix;
this.suffix = suffix;
this.nickname = nickname;
this.addresses.addAll(addresses);
this.phones.addAll(phones);
this.email_addresses.addAll(email_addresses);
this.mailer = mailer;
this.timezone = timezone;
this.title = title;
this.role = role;
this.orgname = orgname;
this.note = note;
this.sort_string = sort_string;
this.url = url;
} // end constructor
public VCard(Element xml) throws ValidationException public VCard(Element xml) throws ValidationException
{ {
if (!(xml.getTagName().equals("vCard"))) if (!(xml.getTagName().equals("vCard")))
@ -183,6 +209,35 @@ public class VCard
} // end cleanup } // end cleanup
static final boolean validateTZText(String s)
{
if (s.equals("Z") || s.equals("z"))
return true;
// validate the offset string
boolean valid = (s.length()>=3) && ((s.charAt(0)=='+') || (s.charAt(0)=='-'));
if (valid)
valid = ((s.charAt(1)>='0') && (s.charAt(1)<='9'));
if (valid)
valid = ((s.charAt(2)>='0') && (s.charAt(2)<='9'));
if (!valid)
return false;
if (s.length()>3)
{ // validate the last bit of the string
if (s.charAt(3)==':') // +hh:mm or -hh:mm
valid = ( (s.length()==6) && (s.charAt(4)>='0') && (s.charAt(4)<='9') && (s.charAt(5)>='0')
&& (s.charAt(5)<='9'));
else // +hhmm or -hhmm
valid = ( (s.length()==5) && (s.charAt(3)>='0') && (s.charAt(3)<='9') && (s.charAt(4)>='0')
&& (s.charAt(4)<='9'));
} // end if
// else it's just a +hh or -hh notation
return valid;
} // end validateTZText
private static final String readElemText(Element elt) private static final String readElemText(Element elt)
{ {
DOMElementHelper h = new DOMElementHelper(elt); DOMElementHelper h = new DOMElementHelper(elt);
@ -199,31 +254,7 @@ public class VCard
s = s.trim(); s = s.trim();
// Validate that this is a proper ISO 8601 time zone offset. // Validate that this is a proper ISO 8601 time zone offset.
boolean valid; if (!validateTZText(s))
if (s.equals("Z") || s.equals("z"))
valid = true; // "Z" = Zulu time!
else
{ // validate the offset string
valid = (s.length()>=3) && ((s.charAt(0)=='+') || (s.charAt(0)=='-'));
if (valid)
valid = ((s.charAt(1)>='0') && (s.charAt(1)<='9'));
if (valid)
valid = ((s.charAt(2)>='0') && (s.charAt(2)<='9'));
if (s.length()>3)
{ // validate the last bit of the string
if (s.charAt(3)==':') // +hh:mm or -hh:mm
valid = ( (s.length()==6) && (s.charAt(4)>='0') && (s.charAt(4)<='9') && (s.charAt(5)>='0')
&& (s.charAt(5)<='9'));
else // +hhmm or -hhmm
valid = ( (s.length()==5) && (s.charAt(3)>='0') && (s.charAt(3)<='9') && (s.charAt(4)>='0')
&& (s.charAt(4)<='9'));
} // end if
// else it's just a +hh or -hh notation
} // end else
if (!valid)
{ // the time zone text is not valid { // the time zone text is not valid
logger.error("<TZ/> text invalid (" + s + ")"); logger.error("<TZ/> text invalid (" + s + ")");
throw new ValidationException("<TZ/> value is not a valid ISO 8601 time zone offset"); throw new ValidationException("<TZ/> value is not a valid ISO 8601 time zone offset");
@ -379,6 +410,36 @@ public class VCard
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public final List getAddresses()
{
if (addresses.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(addresses);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getAddresses
public final List getPhones()
{
if (phones.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(phones);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getPhones
public final List getEmailAddresses()
{
if (email_addresses.isEmpty())
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(email_addresses);
rc.trimToSize();
return Collections.unmodifiableList(rc);
} // end getEmailAddresses
public final VCardAddress getPreferredAddress() public final VCardAddress getPreferredAddress()
{ {
return findAddress(new VCardAddress.Predicate(){ return findAddress(new VCardAddress.Predicate(){
@ -524,4 +585,71 @@ public class VCard
} // end getInternetEmail } // end getInternetEmail
public final void exportXML(Writer xml_writer) throws IOException
{
xml_writer.write("<vCard xmlns=\"vcard-temp\">\n<VERSION>2.0</VERSION>\n");
if (formatted_name!=null)
xml_writer.write("<FN>" + formatted_name + "</FN>\n");
if ((family_name!=null) || (given_name!=null) || (middle_name!=null) || (prefix!=null) || (suffix!=null))
{ // write out the "N" block
xml_writer.write("<N>");
if (family_name!=null)
xml_writer.write("<FAMILY>" + family_name + "</FAMILY>");
if (given_name!=null)
xml_writer.write("<GIVEN>" + given_name + "</GIVEN>");
if (middle_name!=null)
xml_writer.write("<MIDDLE>" + middle_name + "</MIDDLE>");
if (prefix!=null)
xml_writer.write("<PREFIX>" + prefix + "</PREFIX>");
if (suffix!=null)
xml_writer.write("<SUFFIX>" + suffix + "</SUFFIX>");
xml_writer.write("</N>\n");
} // end if
if (nickname!=null)
xml_writer.write("<NICKNAME>" + nickname + "</NICKNAME>\n");
Iterator it;
for (it=addresses.iterator(); it.hasNext(); )
{ // get each address and output it
VCardAddress addr = (VCardAddress)(it.next());
addr.exportXML(xml_writer);
} // end for
for (it=phones.iterator(); it.hasNext(); )
{ // get each phone number and output it
VCardPhone phone = (VCardPhone)(it.next());
phone.exportXML(xml_writer);
} // end for
for (it=email_addresses.iterator(); it.hasNext(); )
{ // get each E-mail address and output it
VCardEmail addr = (VCardEmail)(it.next());
addr.exportXML(xml_writer);
} // end for
if (mailer!=null)
xml_writer.write("<MAILER>" + mailer + "</MAILER>\n");
if (timezone!=null)
xml_writer.write("<TZ>" + timezone + "</TZ>\n");
if (title!=null)
xml_writer.write("<TITLE>" + title + "</TITLE>\n");
if (role!=null)
xml_writer.write("<ROLE>" + role + "</ROLE>\n");
if (orgname!=null)
xml_writer.write("<ORG><ORGNAME>" + orgname + "</ORGNAME></ORG>\n");
if (note!=null)
xml_writer.write("<NOTE>" + note + "</NOTE>\n");
if (sort_string!=null)
xml_writer.write("<SORTSTR>" + sort_string + "</SORTSTR>\n");
if (url!=null)
xml_writer.write("<URL>" + url + "</URL>\n");
xml_writer.write("</vCard>\n");
} // end exportXML
} // end class VCard } // end class VCard

View File

@ -9,14 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.util; package com.silverwrist.venice.util;
import java.io.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
@ -55,10 +56,31 @@ public class VCardAddress
private String country; private String country;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructors
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
VCardAddress(boolean home_adr, boolean work_adr, boolean postal_adr, boolean parcel_adr, boolean domestic_adr,
boolean intl_adr, boolean preferred, String pobox, String ext_address, String street, String locality,
String region, String postal_code, String country)
{
this.home_adr = home_adr;
this.work_adr = work_adr;
this.postal_adr = postal_adr;
this.parcel_adr = parcel_adr;
this.domestic_adr = domestic_adr;
this.intl_adr = intl_adr;
this.preferred = preferred;
this.pobox = pobox;
this.ext_address = ext_address;
this.street = street;
this.locality = locality;
this.region = region;
this.postal_code = postal_code;
this.country = country;
} // end constructor
VCardAddress(Element adr) throws ValidationException VCardAddress(Element adr) throws ValidationException
{ {
DOMElementHelper h = new DOMElementHelper(adr); DOMElementHelper h = new DOMElementHelper(adr);
@ -81,6 +103,119 @@ public class VCardAddress
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
final void exportXML(Writer xml_writer) throws IOException
{
xml_writer.write("<ADR>");
if (home_adr)
xml_writer.write("<HOME/>");
if (work_adr)
xml_writer.write("<WORK/>");
if (postal_adr)
xml_writer.write("<POSTAL/>");
if (parcel_adr)
xml_writer.write("<PARCEL/>");
if (domestic_adr)
xml_writer.write("<DOM/>");
if (intl_adr)
xml_writer.write("<INTL/>");
if (preferred)
xml_writer.write("<PREF/>");
xml_writer.write("\n");
if (pobox!=null)
xml_writer.write("<POBOX>" + pobox + "</POBOX>\n");
if (ext_address!=null)
xml_writer.write("<EXTADR>" + ext_address + "</EXTADR>\n");
if (street!=null)
xml_writer.write("<STREET>" + street + "</STREET>\n");
if (locality!=null)
xml_writer.write("<LOCALITY>" + locality + "</LOCALITY>\n");
if (region!=null)
xml_writer.write("<REGION>" + region + "</REGION>\n");
if (postal_code!=null)
xml_writer.write("<PCODE>" + postal_code + "</PCODE>\n");
if (country!=null)
xml_writer.write("<CTRY>" + country + "</CTRY>\n");
xml_writer.write("</ADR>\n");
} // end exportXML
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public boolean equals(Object o)
{
if ((o==null) || !(o instanceof VCardAddress))
return false;
VCardAddress other = (VCardAddress)o;
if ( (home_adr!=other.home_adr) || (work_adr!=other.work_adr) || (postal_adr!=other.postal_adr)
|| (parcel_adr!=other.parcel_adr) || (domestic_adr!=other.domestic_adr) || (intl_adr!=other.intl_adr)
|| (preferred!=other.preferred))
return false;
if (!StringUtil.areEqual(pobox,other.pobox))
return false;
if (!StringUtil.areEqual(ext_address,other.ext_address))
return false;
if (!StringUtil.areEqual(street,other.street))
return false;
if (!StringUtil.areEqual(locality,other.locality))
return false;
if (!StringUtil.areEqual(region,other.region))
return false;
if (!StringUtil.areEqual(postal_code,other.postal_code))
return false;
return StringUtil.areEqual(country,other.country);
} // end equals
public int hashCode()
{
int rc = 0;
int mask = 0x40000000;
if (home_adr)
rc |= mask;
mask >>= 1;
if (work_adr)
rc |= mask;
mask >>= 1;
if (postal_adr)
rc |= mask;
mask >>= 1;
if (parcel_adr)
rc |= mask;
mask >>= 1;
if (domestic_adr)
rc |= mask;
mask >>= 1;
if (intl_adr)
rc |= mask;
mask >>= 1;
if (preferred)
rc |= mask;
if (pobox!=null)
rc ^= pobox.hashCode();
if (ext_address!=null)
rc ^= ext_address.hashCode();
if (street!=null)
rc ^= street.hashCode();
if (locality!=null)
rc ^= locality.hashCode();
if (region!=null)
rc ^= region.hashCode();
if (postal_code!=null)
rc ^= postal_code.hashCode();
if (country!=null)
rc ^= country.hashCode();
return rc;
} // end hashCode
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External getters/setters * External getters/setters
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -9,14 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.util; package com.silverwrist.venice.util;
import java.io.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
@ -47,10 +48,22 @@ public class VCardEmail
private String address; private String address;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructors
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
VCardEmail(boolean home_email, boolean work_email, boolean internet_email, boolean x400_email, boolean preferred,
String address)
{
this.home_email = home_email;
this.work_email = work_email;
this.internet_email = internet_email;
this.x400_email = x400_email;
this.preferred = preferred;
this.address = address;
} // end constructor
VCardEmail(Element elt) VCardEmail(Element elt)
{ {
DOMElementHelper h = new DOMElementHelper(elt); DOMElementHelper h = new DOMElementHelper(elt);
@ -67,6 +80,71 @@ public class VCardEmail
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
final void exportXML(Writer xml_writer) throws IOException
{
xml_writer.write("<EMAIL>");
if (home_email)
xml_writer.write("<HOME/>");
if (work_email)
xml_writer.write("<WORK/>");
if (internet_email)
xml_writer.write("<INTERNET/>");
if (x400_email)
xml_writer.write("<X400/>");
if (preferred)
xml_writer.write("<PREF/>");
if (address!=null)
xml_writer.write("<USERID>" + address + "</USERID>");
xml_writer.write("</EMAIL>\n");
} // end exportXML
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public boolean equals(Object o)
{
if ((o==null) || !(o instanceof VCardEmail))
return false;
VCardEmail other = (VCardEmail)o;
if ( (home_email!=other.home_email) || (work_email!=other.work_email) || (internet_email!=other.internet_email)
|| (x400_email!=other.x400_email) || (preferred!=other.preferred))
return false;
return StringUtil.areEqual(address,other.address);
} // end equals
public int hashCode()
{
int rc = 0;
int mask = 0x40000000;
if (home_email)
rc |= mask;
mask >>= 1;
if (work_email)
rc |= mask;
mask >>= 1;
if (internet_email)
rc |= mask;
mask >>= 1;
if (x400_email)
rc |= mask;
mask >>= 1;
if (preferred)
rc |= mask;
if (address!=null)
rc ^= address.hashCode();
return rc;
} // end hashCode
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External getters/setters * External getters/setters
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -9,14 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.util; package com.silverwrist.venice.util;
import java.io.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
@ -55,10 +56,31 @@ public class VCardPhone
private String number; private String number;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructors
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
VCardPhone(boolean home_phone, boolean work_phone, boolean voice_phone, boolean fax_phone, boolean pager,
boolean message, boolean cell_phone, boolean video_phone, boolean bbs_phone, boolean modem_phone,
boolean isdn_phone, boolean pcs_phone, boolean preferred, String number)
{
this.home_phone = home_phone;
this.work_phone = work_phone;
this.voice_phone = voice_phone;
this.fax_phone = fax_phone;
this.pager = pager;
this.message = message;
this.cell_phone = cell_phone;
this.video_phone = video_phone;
this.bbs_phone = bbs_phone;
this.modem_phone = modem_phone;
this.isdn_phone = isdn_phone;
this.pcs_phone = pcs_phone;
this.preferred = preferred;
this.number = number;
} // end constructor
VCardPhone(Element elt) VCardPhone(Element elt)
{ {
DOMElementHelper h = new DOMElementHelper(elt); DOMElementHelper h = new DOMElementHelper(elt);
@ -81,6 +103,114 @@ public class VCardPhone
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
final void exportXML(Writer xml_writer) throws IOException
{
xml_writer.write("<TEL>");
if (home_phone)
xml_writer.write("<HOME/>");
if (work_phone)
xml_writer.write("<WORK/>");
if (voice_phone)
xml_writer.write("<VOICE/>");
if (fax_phone)
xml_writer.write("<FAX/>");
if (pager)
xml_writer.write("<PAGER/>");
if (message)
xml_writer.write("<MSG/>");
if (cell_phone)
xml_writer.write("<CELL/>");
if (video_phone)
xml_writer.write("<VIDEO/>");
if (bbs_phone)
xml_writer.write("<BBS/>");
if (modem_phone)
xml_writer.write("<MODEM/>");
if (isdn_phone)
xml_writer.write("<ISDN/>");
if (pcs_phone)
xml_writer.write("<PCS/>");
if (preferred)
xml_writer.write("<PREF/>");
if (number!=null)
xml_writer.write("<NUMBER>" + number + "</NUMBER>");
xml_writer.write("</TEL>\n");
} // end exportXML
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public boolean equals(Object o)
{
if ((o==null) || !(o instanceof VCardPhone))
return false;
VCardPhone other = (VCardPhone)o;
if ( (home_phone!=other.home_phone) || (work_phone!=other.work_phone) || (voice_phone!=other.voice_phone)
|| (fax_phone!=other.fax_phone) || (pager!=other.pager) || (message!=other.message)
|| (cell_phone!=other.cell_phone) || (video_phone!=other.video_phone) || (bbs_phone!=other.bbs_phone)
|| (modem_phone!=other.modem_phone) || (isdn_phone!=other.isdn_phone) || (pcs_phone!=other.pcs_phone)
|| (preferred==other.preferred))
return false;
return StringUtil.areEqual(number,other.number);
} // end equals
public int hashCode()
{
int rc = 0;
int mask = 0x40000000;
if (home_phone)
rc |= mask;
mask >>= 1;
if (work_phone)
rc |= mask;
mask >>= 1;
if (voice_phone)
rc |= mask;
mask >>= 1;
if (fax_phone)
rc |= mask;
mask >>= 1;
if (pager)
rc |= mask;
mask >>= 1;
if (message)
rc |= mask;
mask >>= 1;
if (cell_phone)
rc |= mask;
mask >>= 1;
if (video_phone)
rc |= mask;
mask >>= 1;
if (bbs_phone)
rc |= mask;
mask >>= 1;
if (modem_phone)
rc |= mask;
mask >>= 1;
if (isdn_phone)
rc |= mask;
mask >>= 1;
if (pcs_phone)
rc |= mask;
mask >>= 1;
if (preferred)
rc |= mask;
if (number!=null)
rc ^= number.hashCode();
return rc;
} // end hashCode
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External getters/setters * External getters/setters
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------