moved the language and country lists OUT of the database and into properties
files as they are likely to change VERY infrequently; this simplifies a lot of bits of code that would otherwise have to call through VeniceEngine, etc. Also folded the LocaleFactory class method into the new International object used for managing the lists.
This commit is contained in:
@@ -58,7 +58,7 @@ public class Account extends VeniceServlet
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
NewAccountDialog template = new NewAccountDialog(getCountryList());
|
||||
NewAccountDialog template = new NewAccountDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
@@ -109,7 +109,7 @@ public class Account extends VeniceServlet
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
EditProfileDialog template = new EditProfileDialog(getCountryList());
|
||||
EditProfileDialog template = new EditProfileDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -68,7 +68,7 @@ public class CommunityAdmin extends VeniceServlet
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
EditCommunityProfileDialog template = new EditCommunityProfileDialog(getCountryList(),getLanguageList());
|
||||
EditCommunityProfileDialog template = new EditCommunityProfileDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CommunityOperations extends VeniceServlet
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
CreateCommunityDialog template = new CreateCommunityDialog(getCountryList(),getLanguageList());
|
||||
CreateCommunityDialog template = new CreateCommunityDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SystemAdmin extends VeniceServlet
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
AdminModifyUserDialog template = new AdminModifyUserDialog(getCountryList());
|
||||
AdminModifyUserDialog template = new AdminModifyUserDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -36,8 +36,6 @@ public class Variables
|
||||
|
||||
// ServletContext ("application") attributes
|
||||
protected static final String ENGINE_ATTRIBUTE = "com.silverwrist.venice.core.Engine";
|
||||
protected static final String COUNTRYLIST_ATTRIBUTE = "com.silverwrist.venice.db.CountryList";
|
||||
protected static final String LANGUAGELIST_ATTRIBUTE = "com.silverwrist.venice.db.LanguageList";
|
||||
protected static final String STYLESHEET_ATTRIBUTE = "com.silverwrist.venice.rendering.StyleSheet";
|
||||
|
||||
// HttpSession ("session") attributes
|
||||
@@ -168,54 +166,6 @@ public class Variables
|
||||
|
||||
} // end clearUserContext
|
||||
|
||||
public static List getCountryList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
Object foo = ctxt.getAttribute(COUNTRYLIST_ATTRIBUTE);
|
||||
if (foo!=null)
|
||||
return (List)foo;
|
||||
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
|
||||
try
|
||||
{ // get the country list via the engine and save it
|
||||
List rc = engine.getCountryList();
|
||||
ctxt.setAttribute(COUNTRYLIST_ATTRIBUTE,rc);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // the country list could not be retrieved
|
||||
logger.error("Failed to retrieve country list from engine: " + e.getMessage(),e);
|
||||
throw new ServletException("Country list retrieval failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
public static List getLanguageList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
Object foo = ctxt.getAttribute(LANGUAGELIST_ATTRIBUTE);
|
||||
if (foo!=null)
|
||||
return (List)foo;
|
||||
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
|
||||
try
|
||||
{ // get the country list via the engine and save it
|
||||
List rc = engine.getLanguageList();
|
||||
ctxt.setAttribute(LANGUAGELIST_ATTRIBUTE,rc);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // the country list could not be retrieved
|
||||
logger.error("Failed to retrieve language list from engine: " + e.getMessage(),e);
|
||||
throw new ServletException("Language list retrieval failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
public static ComponentRender getMenu(HttpSession session)
|
||||
{
|
||||
return (ComponentRender)(session.getAttribute(MENU_ATTRIBUTE));
|
||||
|
||||
@@ -312,30 +312,6 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
|
||||
} // end clearUserContext
|
||||
|
||||
protected static final List getCountryList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
return Variables.getCountryList(ctxt);
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
protected final List getCountryList() throws ServletException
|
||||
{
|
||||
return Variables.getCountryList(getServletContext());
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
protected final List getLanguageList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
return Variables.getLanguageList(ctxt);
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
protected final List getLanguageList() throws ServletException
|
||||
{
|
||||
return Variables.getLanguageList(getServletContext());
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
protected final void changeMenuTop(HttpServletRequest request)
|
||||
{
|
||||
Variables.setMenuTop(getServletContext(),request.getSession(true));
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.LocaleFactory;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.security.Role;
|
||||
@@ -31,7 +30,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdminModifyUserDialog(List country_list)
|
||||
public AdminModifyUserDialog()
|
||||
{
|
||||
super("Modify User Account",null,"moduserform","sysadmin");
|
||||
setHiddenField("cmd","UM");
|
||||
@@ -60,7 +59,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true));
|
||||
addFormField(new CDFormCategoryHeader("Phone Numbers"));
|
||||
addFormField(new CDTextFormField("phone","Telephone",null,false,32,32));
|
||||
addFormField(new CDTextFormField("mobile","Mobile/cellphone",null,false,32,32));
|
||||
@@ -277,7 +276,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
admuser.setDescription(getFieldValue("descr"));
|
||||
admuser.setLocale(LocaleFactory.createLocale(getFieldValue("locale")));
|
||||
admuser.setLocale(International.get().createLocale(getFieldValue("locale")));
|
||||
admuser.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
|
||||
|
||||
} // end doDialog
|
||||
|
||||
@@ -20,8 +20,7 @@ package com.silverwrist.venice.servlets.format;
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.Country;
|
||||
import com.silverwrist.util.*;
|
||||
|
||||
public class CDCountryListFormField extends CDPickListFormField
|
||||
{
|
||||
@@ -30,10 +29,9 @@ public class CDCountryListFormField extends CDPickListFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDCountryListFormField(String name, String caption, String caption2, boolean required,
|
||||
List country_list)
|
||||
public CDCountryListFormField(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
super(name,caption,caption2,required,country_list);
|
||||
super(name,caption,caption2,required,International.get().getCountryList());
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* 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 Community System.
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
@@ -20,15 +20,18 @@ package com.silverwrist.venice.servlets.format;
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.Language;
|
||||
import com.silverwrist.util.*;
|
||||
|
||||
public class CDLanguageListFormField extends CDPickListFormField
|
||||
{
|
||||
public CDLanguageListFormField(String name, String caption, String caption2, boolean required,
|
||||
List language_list)
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDLanguageListFormField(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
super(name,caption,caption2,required,language_list);
|
||||
super(name,caption,caption2,required,International.get().getLanguageList());
|
||||
|
||||
} // end constructor
|
||||
|
||||
@@ -38,6 +41,11 @@ public class CDLanguageListFormField extends CDPickListFormField
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDPickListFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Language l = (Language)obj;
|
||||
@@ -48,6 +56,11 @@ public class CDLanguageListFormField extends CDPickListFormField
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDLanguageListFormField(this);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class CommunityProfileData implements JSPRender
|
||||
@@ -163,7 +163,8 @@ public class CommunityProfileData implements JSPRender
|
||||
|
||||
public String getFullCountry()
|
||||
{
|
||||
return engine.getNameOfCountry(ci.getCountry());
|
||||
Country c = International.get().getCountryForCode(ci.getCountry());
|
||||
return ((c==null) ? null : c.getName());
|
||||
|
||||
} // end getFullCountry
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CreateCommunityDialog extends ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CreateCommunityDialog(List country_list, List language_list)
|
||||
public CreateCommunityDialog()
|
||||
{
|
||||
super("Create New Community",null,"createcommform","sigops");
|
||||
setHiddenField("cmd","C");
|
||||
@@ -58,12 +58,12 @@ public class CreateCommunityDialog extends ContentDialog
|
||||
addFormField(new CDVeniceIDFormField("alias","Community Alias",null,true,32,32));
|
||||
addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
|
||||
addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("loc","City",null,false,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true));
|
||||
addFormField(new CDFormCategoryHeader("Security"));
|
||||
addFormField(new CDSimplePickListFormField("comtype","Community type:",null,true,vec_pubpriv,'|'));
|
||||
addFormField(new CDTextFormField("joinkey","Join key","(for private communities)",false,32,64));
|
||||
|
||||
@@ -101,7 +101,7 @@ public class EditCommunityProfileDialog extends ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public EditCommunityProfileDialog(List country_list, List language_list)
|
||||
public EditCommunityProfileDialog()
|
||||
{
|
||||
super("Edit Community Profile:",null,"commprofform","sigadmin");
|
||||
setHiddenField("cmd","P");
|
||||
@@ -124,7 +124,7 @@ public class EditCommunityProfileDialog extends ContentDialog
|
||||
addFormField(new CDVeniceIDFormField("alias","Community Alias",null,true,32,32));
|
||||
addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
|
||||
addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true));
|
||||
addFormField(new CDTextFormField("url","Home page",null,false,32,255));
|
||||
logo_control = new CDCommunityLogoControl("logo","Community logo","commlogo");
|
||||
addFormField(logo_control);
|
||||
@@ -136,7 +136,7 @@ public class EditCommunityProfileDialog extends ContentDialog
|
||||
addFormField(new CDTextFormField("loc","City",null,false,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true));
|
||||
|
||||
addFormField(new CDFormCategoryHeader("Security"));
|
||||
addFormField(new CDSimplePickListFormField("comtype","Communty type",null,true,vec_pubpriv,'|'));
|
||||
|
||||
@@ -20,8 +20,7 @@ package com.silverwrist.venice.servlets.format;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.LocaleFactory;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
@@ -100,7 +99,7 @@ public class EditProfileDialog extends ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public EditProfileDialog(List country_list)
|
||||
public EditProfileDialog()
|
||||
{
|
||||
super("Edit Your Profile",null,"profform","account");
|
||||
setHiddenField("cmd","P");
|
||||
@@ -124,7 +123,7 @@ public class EditProfileDialog extends ContentDialog
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true));
|
||||
addFormField(new CDFormCategoryHeader("Phone Numbers"));
|
||||
addFormField(new CDTextFormField("phone","Telephone",null,false,32,32));
|
||||
addFormField(new CDTextFormField("mobile","Mobile/cellphone",null,false,32,32));
|
||||
@@ -289,7 +288,7 @@ public class EditProfileDialog extends ContentDialog
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
uc.setDescription(getFieldValue("descr"));
|
||||
uc.setLocale(LocaleFactory.createLocale(getFieldValue("locale")));
|
||||
uc.setLocale(International.get().createLocale(getFieldValue("locale")));
|
||||
uc.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
|
||||
|
||||
// Finally, change the password if applicable.
|
||||
|
||||
@@ -36,7 +36,7 @@ public class NewAccountDialog extends ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public NewAccountDialog(List country_list)
|
||||
public NewAccountDialog()
|
||||
{
|
||||
super("Create Account",null,"createform","account");
|
||||
setInstructions("To create a new account, please enter your information below.");
|
||||
@@ -52,7 +52,7 @@ public class NewAccountDialog extends ContentDialog
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true));
|
||||
addFormField(new CDFormCategoryHeader("E-mail"));
|
||||
addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Account Information"));
|
||||
|
||||
Reference in New Issue
Block a user