2002-01-06 19:05:37 -07:00
|
|
|
// 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.
|
|
|
|
//
|
2006-01-25 21:40:34 -07:00
|
|
|
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@users.sf.net>,
|
2002-01-06 19:05:37 -07:00
|
|
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
2004-07-10 16:54:15 -06:00
|
|
|
// Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
2002-01-06 19:05:37 -07:00
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
|
|
|
|
importPackage(Packages.com.silverwrist.venice.core);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.except);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.view);
|
|
|
|
|
|
|
|
// get the request object and the username
|
|
|
|
rinput = bsf.lookupBean("request");
|
|
|
|
username = rinput.getRequestAttribute("username");
|
|
|
|
|
|
|
|
rc = null;
|
|
|
|
try
|
|
|
|
{ // retrieve the user profile and save it off
|
|
|
|
prof = rinput.user.getProfile(username);
|
|
|
|
rinput.setRequestAttribute("profile",prof);
|
|
|
|
|
|
|
|
// determine the full name of the user and save it off
|
|
|
|
buf = new java.lang.StringBuffer(prof.givenName);
|
|
|
|
if (!(vlib.emptyString(prof.namePrefix)))
|
|
|
|
{ // insert the prefix at the beginning of the string
|
2004-07-10 16:54:15 -06:00
|
|
|
if (buf.length()>0)
|
|
|
|
buf.insert(0," ");
|
2002-01-06 19:05:37 -07:00
|
|
|
buf.insert(0,prof.namePrefix);
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
|
|
|
tmp = String.fromCharCode(prof.middleInitial);
|
2004-07-10 16:54:15 -06:00
|
|
|
if (tmp!=" ") // append the middle initial
|
|
|
|
buf.append(" ").append(tmp).append(".");
|
2002-01-06 19:05:37 -07:00
|
|
|
|
2004-07-10 16:54:15 -06:00
|
|
|
if (!(vlib.emptyString(prof.familyName)))
|
|
|
|
buf.append(" ").append(prof.familyName);
|
2002-01-06 19:05:37 -07:00
|
|
|
if (!(vlib.emptyString(prof.nameSuffix)))
|
2004-07-10 16:54:15 -06:00
|
|
|
buf.append(" ").append(prof.nameSuffix);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
2004-07-10 16:54:15 -06:00
|
|
|
sfullname = buf.toString().trim();
|
|
|
|
if (vlib.emptyString(sfullname))
|
|
|
|
sfullname = username;
|
|
|
|
rinput.setRequestAttribute("fullname",sfullname);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
// determine the last line of the address and save it off
|
|
|
|
if (vlib.emptyString(prof.locality))
|
|
|
|
{ // allocate stringbuffer based on region
|
|
|
|
if (vlib.emptyString(prof.region))
|
|
|
|
buf = new java.lang.StringBuffer();
|
|
|
|
else
|
|
|
|
buf = new java.lang.StringBuffer(prof.region);
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
else if (vlib.emptyString(prof.region))
|
|
|
|
buf = new java.lang.StringBuffer(prof.locality);
|
|
|
|
else
|
|
|
|
{ // tack together both locality and region
|
|
|
|
buf = new java.lang.StringBuffer(prof.locality);
|
2004-07-10 16:54:15 -06:00
|
|
|
buf.append(", ").append(prof.region);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
} // end else
|
|
|
|
|
|
|
|
if (!(vlib.emptyString(prof.postalCode)))
|
|
|
|
{ // append the postal code
|
2004-07-10 16:54:15 -06:00
|
|
|
buf.append(" ").append(prof.postalCode);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
2004-07-10 16:54:15 -06:00
|
|
|
rinput.setRequestAttribute("address.lastline",buf.toString().trim());
|
|
|
|
|
2004-07-12 16:27:14 -06:00
|
|
|
scountry = prof.fullCountry;
|
2004-07-10 16:54:15 -06:00
|
|
|
if (prof.country.equals("XX"))
|
|
|
|
scountry = "";
|
|
|
|
rinput.setRequestAttribute("country",scountry);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
// Save off the user photo tag.
|
2002-04-24 00:39:29 -06:00
|
|
|
html = vlib.queryHTMLRendering(rinput);
|
|
|
|
rinput.setRequestAttribute("user.photo",html.getUserPhotoTag(prof.photoURL));
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
// Create a view object and send it out.
|
|
|
|
rc = new JSPView("User Profile - " + username,"user_profile.jsp");
|
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (e)
|
|
|
|
{ // handle an exception thrown by the profile code
|
|
|
|
etype = vlib.exceptionType(e) + "";
|
|
|
|
if (etype.match("DataException"))
|
|
|
|
rc = new ErrorBox("Database Error","Database error finding user: " + e.message,"top.js.vs");
|
|
|
|
else
|
|
|
|
rc = e;
|
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
2004-07-10 16:54:15 -06:00
|
|
|
vlib.output(rc); // all done!
|