/*
* This software and supporting documentation were developed by
*
* Siemens Corporate Technology
* Competence Center Knowledge Management and Business Transformation
* D-81730 Munich, Germany
*
* Authors (representing a really great team ;-) )
* Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
* This software is Open Source under GNU General Public License (GPL).
* Read the text of this license in LICENSE.TXT
* or look at www.opensource.org/licenses/
*
* Once more we emphasize, that:
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, WITHOUT ANY WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/
// Subscribe_ApplicationPage
// Package
package appl.Subscribe.GUI;
// Imports
// This application
import appl.Subscribe.GUI.*;
import appl.Subscribe.Params.*;
import appl.Subscribe.Servlet.*;
import appl.Subscribe.Utils.*;
// Other application/module packages
import mod.AccountDB.GUI.Templates.AccountTemplateHandler;
import mod.AccountDB.Utils.DB.AccountDB2;
import mod.PeopleDB.GUI.Person_HtmlParam;
import mod.PeopleDB.GUI.Department_HtmlParam;
import mod.PeopleDB.Utils.DB.PeopleDB2;
import mod.RolesDB.Utils.DB.*;
// KFM
import KFM.Exceptions.*;
import KFM.GUI.*;
import KFM.GUI.Templates.*;
import KFM.DB.*;
import KFM.HTML.FormInputChecker;
import KFM.Language;
import KFM.log.*;
// JSDK classes
import javax.servlet.*;
import javax.servlet.http.*;
// Java packages
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
/** Application Page of Subscribe.
*
* <H2>Related classes</H2>
*
* <P>Cut&paste-source was `Portal_ApplicationPage� in KMS.</P>
*
* @author ThH
* @version 0.1 (2000-08-21)
*/
abstract public class Subscribe_ApplicationPage
extends ApplicationPage2
implements SubscribeServletInterface
{
// ************************************************************
// Constants
// ************************************************************
protected final static Subscribe_Events mEvents = new Subscribe_Events();
protected final static Subscribe_HtmlParam mParams = new Subscribe_HtmlParam();
// ************************************************************
// Variables
// ************************************************************
/** */
protected Subscribe_Props mServletProps = null;
/** */
protected KFM_Database2 mDb;
/** */
protected KFM_JdbcAdapter mDbA;
/** */
protected AccountDB2 mAccountDb;
/** */
protected PeopleDB2 mPeopleDb;
/** */
protected RolesDB2 mRolesDb;
// ************************************************************
// Methods
// ************************************************************
/** */
public Subscribe_ApplicationPage (
Subscribe_Props aServletProps,
HttpServletRequest aReq)
{
super(KFM_HttpServletRequest.getContextAndServletPath(aReq), aServletProps);
// setClassName(this); // Only final class does this.
mServletProps = aServletProps;
}
/** Initialization.
*
* <P>Ensures that all the needed databases and templates can be used.
* It might implement any form of caching, sessions, etc..</P>
*/
protected void prepareRequest (
AuthorizedUserState aUs,
KFM_HttpServletRequest aReq)
throws KFMException, KFM_SQLException
{
mDb = new KFM_Database2(
mServletProps.Log2,
mServletProps.JdbcDriver,
mServletProps.JdbcConnectionURL,
mServletProps.JdbcUser,
mServletProps.JdbcPassword);
mDb.establishConnection("Subscribe_ApplicationPage");
mDbA = new KFM_JdbcAdapter(mDb, mLog);
mDbA.open();
// Clear autocommit *after* opening the DB Adapter. Really!
mDb.setAutoCommit(false); /*sic*/
mAccountDb = new AccountDB2(mDbA);
mPeopleDb = new PeopleDB2(mDbA);
mRolesDb = new RolesDB2(mDbA);
registerDb(cDbTypeOrdinary,
mDb, mDbA,
null, // Actually, we should register `mAccountDb�, `mPeopleDb� *and* `mRolesDb� here.
"DB");
}
/** Transform the events.
*
* <P>Converts the OUT events of the last request into the IN events which will
* be used in handleEvent().</P>
*/
protected void transformEvents (
AuthorizedUserState us,
KFM_HttpServletRequest aReq)
throws java.io.IOException, KFMException
{
}
/** Handle the events.
*/
protected void handleEvent (
AuthorizedUserState aUs,
KFM_HttpServletRequest aReq,
HttpServletResponse aRes)
throws java.io.IOException,
KFMException,
KFM_SQLException
{
// Prepare the HTTP response.
aRes.setContentType(cTextHtml);
PrintWriter tWriter = aRes.getWriter();
// Get execute.
String tExecute = aReq.getParam(mParams.EXECUTE);
//
// THE BIG IF
//
if(tExecute.equals(mEvents.Subscribe_UpdatePermissions)) {
// Create the form for updating an account.
handle_UpdatePermissions(aReq, aRes, tWriter);
} else if(tExecute.equals(mEvents.Subscribe_DoUpdatePermissions)) {
// Try to do the update of an existing account.
try{
handle_DoUpdatePermissions(aReq, aRes, tWriter);
}
catch (KFM.CryptException e)
{
throw new KFMException(e);
}
} else if(tExecute.equals(mEvents.Subscribe_Person_Store)) {
Vector errors = check(aReq); // Get errors.
if(errors.isEmpty()) {
try{
handle_Subscribe_Person_Store(aReq, aRes, tWriter);
}
catch (KFM.CryptException e)
{
throw new KFMException(e);
}
} else {
handle_Person_New(aReq, aRes, tWriter, errors);
}
} else if (tExecute.equals(mEvents.statistic)) {
handle_Statistic(aUs, aReq, tWriter);
} else /*mEvents.Subscribe_Person_New*/ {
// No other execute matched.
handle_Person_New(aReq, aRes, tWriter, /*errors*/ new Vector());
}
}
// ************************************************************
// Methods of the interface `SubscribeServletInterface�
// ************************************************************
/** Adds the needed permissions into DB.
*
*@param accountName name of the user account
*/
public abstract void createPermissions (
String aAccountName)
throws KFM_SQLException;
/** Adds the needed permissions into DB.
* A more general method than createPermissions above(),
* as it allows to pass the servlet request object
* (which may have further info needed for creating the permissions.
*
* @param aReq the servlet request
* @param accountName name of the user account
*/
public void createPermissions (
KFM_HttpServletRequest aReq,
String aAccountName)
throws KFM_SQLException
{
// Default behavior is to delegate to createPermissions without
// servlet request argument. Subclasses may redefine this.
createPermissions(aAccountName);
}
/** Prints the registered page
*
*@param aWriter PrintWriter
*@param userName the account
*@param language the choosen language
*@param accountAlready Exists true wether the account exists or not
*/
public abstract void printRegisteredPage (
PrintWriter aWriter,
String aUserName,
String aLanguage,
boolean aAccountAlreadyExists)
throws IOException;
/** Sends notification email to admin
*
*@param req kfm_httpServletrequest
*@param userName User name
*/
public abstract void sendAdminEmail (
KFM_HttpServletRequest aReq,
String aUserName);
// ************************************************************
// Handle methods
// ************************************************************
/** Subscribe a new person: form to enter user's information.
*
* <P>This event is also used when the user enters erroneous information,
* so that he can correct his errors immediately.</P>
*
* @Param aReq
* @Param aOut
* @Param errors Errors occured.
*/
public void handle_Person_New (
KFM_HttpServletRequest aReq,
HttpServletResponse aRes,
PrintWriter aWriter,
Vector errors)
throws IOException, KFM_SQLException
{
transactionReadOnly();
String language = aReq.getParam(mParams.LANGUAGE);
String execute = aReq.getParam(mParams.EXECUTE);
String title = aReq.getParam(mParams.P_TITLE);
String firstname = aReq.getParam(mParams.P_FIRSTNAME);
String secondname = aReq.getParam(mParams.P_SECONDNAME);
String lastname = aReq.getParam(mParams.P_LASTNAME);
String phonestate = aReq.getParam(mParams.P_PHONESTATE);
String phonetown = aReq.getParam(mParams.P_PHONETOWN);
String phonelocation= aReq.getParam(mParams.P_PHONELOCATION);
String phonedirect = aReq.getParam(mParams.P_PHONEDIRECT);
String faxdirect = aReq.getParam(mParams.P_FAXDIRECT);
String email = aReq.getParam(mParams.P_EMAILADDRESS);
String homepage = aReq.getParam(mParams.P_HOMEPAGEURL);
String department = aReq.getParam(mParams.P_DEPARTMENTSHORTNAME);
String location = aReq.getParam(mParams.D_LOCATION);
String company = aReq.getParam(mParams.D_COMPANYNAME);
if(company.equals("")) company = "Siemens AG";
String passwrd = aReq.getParam(mParams.A_PASSWORD);
String passwrdVerify = aReq.getParam(mParams.A_PASSWORDRE);
// Create template
AccountTemplateHandler tAccountTH = new AccountTemplateHandler(
mServletProps.TemplateDir,
"Person_New",
mServletProps.DefaultStylesheet,
"footer-url-not-needed-here");
tAccountTH.startWithLanguage(
language.equals(Language.GERMAN)
? Language.German
: Language.English);
// Remove the HTML params which will be edited in this form.
removeParams(aReq);
aReq.replaceParam(mParams.EXECUTE, mEvents.Subscribe_Person_Store);
// Setup the form.
tAccountTH.setAllFormOpentag(
"<form action=\"" + aReq.getContextAndServletPath() + "\" method=\"POST\">",
aReq.toHiddenParams());
tAccountTH.setEditView(execute.equals(mEvents.Subscribe_Person_Store)); // Set new or edit view.
// Add errors.
if(! errors.isEmpty()) {
Enumeration enu = errors.elements();
while(enu.hasMoreElements()) {
String[] tmp = (String[]) enu.nextElement();
tAccountTH.addError(tmp[0], tmp[1]);
}
}
// Add information.
tAccountTH.setPersonTitleInput("50", title, true);
tAccountTH.setPersonFirstNameInput("50", firstname, true);
tAccountTH.setPersonSecondNameInput("50", secondname, true);
tAccountTH.setPersonLastNameInput("50", lastname, true);
tAccountTH.setPersonPhoneStateInput("50", phonestate, true);
tAccountTH.setPersonPhoneTownInput("50", phonetown, true);
tAccountTH.setPersonPhoneLocationInput("50", phonelocation, true);
tAccountTH.setPersonPhoneDirectInput("50", phonedirect, true);
tAccountTH.setPersonFaxDirectInput("50", faxdirect, true);
tAccountTH.setPersonEmailInput("50", email, true);
tAccountTH.setPersonHomepageInput("255", homepage, true);
tAccountTH.setDepartmentInput("50", department, true);
tAccountTH.setDepartmentLocationInput("50", location, true);
tAccountTH.setDepartmentCompanyInput("50", company, true);
tAccountTH.setPersonPasswordInput("50", passwrd,true);
tAccountTH.setPersonPasswordVerifyInput("50", passwrdVerify, true);
// Output.
tAccountTH.execute();
aWriter.println(tAccountTH.writeToString());
// autocommitted
}
/** Store a new person.
*/
public void handle_Subscribe_Person_Store (
KFM_HttpServletRequest aReq,
HttpServletResponse aRes,
PrintWriter aWriter)
throws IOException, KFM_SQLException, KFM.CryptException
{
String tLanguage = aReq.getParam(mParams.LANGUAGE);
// Does this person already exist in DB?
if(existsPerson(aReq)) {
// Person already exists.
printRegisteredPage(aWriter,
mPeopleDb.getUniqueUserName(
aReq.getParam(mParams.P_EMAILADDRESS)),
aReq.getParam(mParams.LANGUAGE),
true);
transactionRollback();
return;
} else {
// Person does not exist.
// Try to create the new account.
String userName = "Fehler";
// insert department data into db
insertDepartment(aReq);
// insert person data into db
userName = insertPerson(aReq);
// insert account data into db
mAccountDb.addAccount(userName, userName, aReq.getParam(mParams.A_PASSWORD));
// insert permissions into db
createPermissions(aReq, userName);
// print the welcome page
printRegisteredPage(aWriter, userName, aReq.getParam(mParams.LANGUAGE), false);
// send notification email to admin
sendAdminEmail(aReq, userName);
// now everything was saved - close the transaction
transactionCommit();
return;
}
}
/** Update an account: form.
*
*@param kfmreq
*@param aWriter
*/
public void handle_UpdatePermissions (
KFM_HttpServletRequest aReq,
HttpServletResponse aRes,
PrintWriter aWriter)
throws IOException, KFM_SQLException
{
transactionReadOnly();
String language = aReq.getParam(mParams.LANGUAGE);
String username = aReq.getParam(Person_HtmlParam.INPUT_PERSON_USERNAME);
String passwrd = aReq.getParam(mParams.A_PASSWORD);
removeParams(aReq);
AccountTemplateHandler tAccountTH = new AccountTemplateHandler(
mServletProps.TemplateDir,
"UpdatePermissions",
mServletProps.DefaultStylesheet,
" ");
tAccountTH.startWithLanguage(
language.equals(Language.GERMAN)
? Language.German
: Language.English);
// Setup form.
aReq.replaceParam(mParams.EXECUTE, mEvents.Subscribe_DoUpdatePermissions);
tAccountTH.setAllFormOpentag(
"<form action=\"" + aReq.getContextAndServletPath()+ "\" method=\"POST\">",
aReq.toHiddenParams());
tAccountTH.setPersonUsernameInput("50", username, true);
tAccountTH.setPersonPasswordInput("50", passwrd, true);
tAccountTH.execute();
aWriter.println(tAccountTH.writeToString());
// autocommitted
}
/** Try to do the update of an existing account.
*
*@param aReq KFM_HttpServletRequest
*@param aWriter Stream to which the output should be written
*@param datasEnterd false for a empty form true for a filled form
*/
public void handle_DoUpdatePermissions (
KFM_HttpServletRequest aReq,
HttpServletResponse aRes,
PrintWriter aWriter)
throws IOException,
KFM_SQLException,
KFM.CryptException
{
String language = aReq.getParam(mParams.LANGUAGE);
String username = aReq.getParam(Person_HtmlParam.INPUT_PERSON_USERNAME);
String passwrd = aReq.getParam(mParams.A_PASSWORD);
removeParams(aReq);
// Data entered -> check it.
Vector errors = checkUser(username, passwrd, language);
if(! errors.isEmpty()) {
// Some data not correct.
AccountTemplateHandler tAccountTH = new AccountTemplateHandler(
mServletProps.TemplateDir,
"UpdatePermissions",
mServletProps.DefaultStylesheet,
" ");
tAccountTH.startWithLanguage(
language.equals(Language.GERMAN)
? Language.German
: Language.English);
// Setup form.
aReq.replaceParam(mParams.EXECUTE, mEvents.Subscribe_DoUpdatePermissions);
tAccountTH.setAllFormOpentag(
"<form action=\"" + aReq.getContextAndServletPath() + "\" method=\"POST\">",
aReq.toHiddenParams());
// Insert errors in form.
Enumeration enu = errors.elements();
while(enu.hasMoreElements()) {
String[] tmp = (String[]) enu.nextElement();
tAccountTH.addError(tmp[0], tmp[1]);
}
tAccountTH.setPersonUsernameInput("50", username, true);
tAccountTH.setPersonPasswordInput("50", passwrd, true);
tAccountTH.execute();
aWriter.println(tAccountTH.writeToString());
transactionRollback();
return;
} else {
// Data correct.
createPermissions(username);
KfmTemplate templ = new KfmTemplate(
mServletProps.TemplateDir,
"PermissionsUpdated",
mServletProps.DefaultStylesheet,
" ");
templ.startWithLanguage(
language.equals(Language.GERMAN)
? Language.German
: Language.English);
templ.replaceAllKfm("applUrl", mServletProps.ApplUrl + "&username="
+ KFM_HttpServletRequest.printUrlEscaped(username));
templ.execute();
aWriter.println(templ.writeToString());
transactionCommit();
return;
}
}
// ************************************************************
// Helper methods of handle_Subscribe_Person_Store,
// redefine them in subclasses as fit
// ************************************************************
protected boolean existsPerson(KFM_HttpServletRequest aReq)
throws KFM_SQLException
{
KFMSystem.log.detail("CAFEBABE: Inside Subscribe_ApplicationPage::existsPerson");
return mPeopleDb.existsPerson( aReq.getParam(mParams.P_EMAILADDRESS));
}
protected String insertPerson(KFM_HttpServletRequest aReq)
throws KFM_SQLException
{
return mPeopleDb.insertPerson(
aReq.getParam(mParams.P_TITLE),
aReq.getParam(mParams.P_FIRSTNAME),
aReq.getParam(mParams.P_SECONDNAME),
aReq.getParam(mParams.P_LASTNAME),
aReq.getParam(mParams.P_PHONESTATE),
aReq.getParam(mParams.P_PHONETOWN),
aReq.getParam(mParams.P_PHONELOCATION),
aReq.getParam(mParams.P_PHONEDIRECT),
aReq.getParam(mParams.P_FAXDIRECT),
aReq.getParam(mParams.P_EMAILADDRESS),
aReq.getParam(mParams.P_HOMEPAGEURL),
aReq.getParam(mParams.P_DEPARTMENTSHORTNAME),
aReq.getParam(mParams.P_IPADDRESS));
}
protected void insertDepartment(KFM_HttpServletRequest aReq)
throws KFM_SQLException
{
mPeopleDb.insertDepartment(
aReq.getParam(mParams.P_DEPARTMENTSHORTNAME),
"",
aReq.getParam(mParams.D_COMPANYNAME),
"",
aReq.getParam(mParams.D_LOCATION));
}
// ************************************************************
// Further helper methods
// ************************************************************
/** Checks username and passord whether account exists in accountdb.
*
* Writes errors in the Vector returned.
*
*@param username username
*@param password passwrod of user
*@param language used language( for errormessages)
*@return Vetor of String[2] containing labels and errrormessages
*/
protected Vector checkUser (
String username,
String password,
String language)
throws KFM_SQLException,
KFM.CryptException
{
ErrVector founderrors = new ErrVector();
boolean tGerman = language.equals(Language.GERMAN);
if(username.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_USERNAME,
tGerman ? "Bitte geben Sie Ihre Benutzerkennung an."
: "Please enter your account.");
} else {
if(mAccountDb.existsAccount(username)) {
if(password.equals("")) {
founderrors.addError("InputPersonPasswordVerify",
(tGerman ? "Leere Passwort sind nicht erlaubt."
: "Empty passwords are not allowed."));
} else if(! mAccountDb.passwordIsCorrect(username, password)) {
// Wrong password.
founderrors.addError("InputPersonPasswordVerify",
(tGerman ? "Bitte geben Sie Ihr richtiges Passwort an."
: "Please enter your correct password."));
}
} else {
// Account does not exist.
founderrors.addError(Person_HtmlParam.INPUT_PERSON_USERNAME,
(tGerman ? "Diese Benutzerkennung existiert nicht."
: "This account does not exists."));
}
}
return founderrors;
}
/** Removes params form KFM_ServletRequest
*
* @param req the ServletRequest
*/
protected void removeParams(KFM_HttpServletRequest req)
{
req.removeParam(Person_HtmlParam.INPUT_PERSON_USERNAME);
req.removeParam(mParams.P_TITLE);
req.removeParam(mParams.P_FIRSTNAME);
req.removeParam(mParams.P_SECONDNAME);
req.removeParam(mParams.P_LASTNAME);
req.removeParam(mParams.P_PHONESTATE);
req.removeParam(mParams.P_PHONETOWN);
req.removeParam(mParams.P_PHONELOCATION);
req.removeParam(mParams.P_PHONEDIRECT);
req.removeParam(mParams.P_FAXDIRECT);
req.removeParam(mParams.P_EMAILADDRESS);
req.removeParam(mParams.P_HOMEPAGEURL);
req.removeParam(mParams.P_DEPARTMENTSHORTNAME);
req.removeParam(mParams.D_COMPANYNAME);
req.removeParam(mParams.P_IPADDRESS);
req.removeParam(mParams.D_LOCATION);
req.removeParam(mParams.A_PASSWORD);
req.removeParam(mParams.A_PASSWORDRE);
req.removeParam("updatePermissions$!$"); // @@@
req.removeParam("savePerson$!$"); // @@@
}
/** Check for errors in parameters.
*
* @param kfmrep ServletRequest
* @return ErrorVector
*/
protected Vector check (KFM_HttpServletRequest aReq)
{
//
// Step one: get parameters from request
//
ErrVector founderrors = new ErrVector();
String language = aReq.getParam(mParams.LANGUAGE);
String execute = aReq.getParam(mParams.EXECUTE);
if(! execute.equals(mEvents.Subscribe_Person_Store)) {
return new Vector();
}
String title = aReq.getParam(mParams.P_TITLE);
String firstname = aReq.getParam(mParams.P_FIRSTNAME);
String secondname = aReq.getParam(mParams.P_SECONDNAME);
String lastname = aReq.getParam(mParams.P_LASTNAME);
String phonestate = aReq.getParam(mParams.P_PHONESTATE);
String phonetown = aReq.getParam(mParams.P_PHONETOWN);
String phonelocation= aReq.getParam(mParams.P_PHONELOCATION);
String phonedirect = aReq.getParam(mParams.P_PHONEDIRECT);
String faxdirect = aReq.getParam(mParams.P_FAXDIRECT);
String email = aReq.getParam(mParams.P_EMAILADDRESS);
String homepage = aReq.getParam(mParams.P_HOMEPAGEURL);
String department = aReq.getParam(mParams.P_DEPARTMENTSHORTNAME);
String location = aReq.getParam(mParams.D_LOCATION);
String company = aReq.getParam(mParams.D_COMPANYNAME);
String passwrd = aReq.getParam(mParams.A_PASSWORD);
String passwrdVerify= aReq.getParam(mParams.A_PASSWORDRE);
//
// Step two: check words for existence and correctness
//
// `g == true� for German, `g == false� for English.
boolean g = language.equals(Language.GERMAN);
String NOVALIDNAME, OBLIGATORY, NOVALIDEMAIL, NOVALIDNUMBER;
if(g) {
NOVALIDNAME = " ist kein g�ltiger Name.";
OBLIGATORY = " ist obligatorisch.";
NOVALIDEMAIL = " ist keine g�ltige Email Adresse.";
NOVALIDNUMBER = " ist keine g�ltige Telefonnummer.";
} else {
// Default language english.
NOVALIDNAME = " is not a valid name.";
OBLIGATORY = " is obligatory.";
NOVALIDEMAIL = " is not a valid email address.";
NOVALIDNUMBER = " is not a valid telefon number.";
}
if(! FormInputChecker.isNameCorrect(title)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_TITLE,
(g ? "Titel:" : "Title:") + title + NOVALIDNAME);
}
if(firstname.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_FIRSTNAME,
(g ? "Vorname:" : "First name:") + OBLIGATORY);
} else if(! FormInputChecker.isNameCorrect(firstname)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_FIRSTNAME,
(g ? "Vorname:" : "First name:") + firstname + NOVALIDNAME);
}
if(! FormInputChecker.isNameCorrect(secondname)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_SECONDNAME,
(g ? "Second name:" : "Zweitname:") + secondname + NOVALIDNAME);
}
if(lastname.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_LASTNAME,
(g ? "Nachname" : "Lastname:" ) + OBLIGATORY);
} else if(! FormInputChecker.isNameCorrect(lastname)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_LASTNAME,
(g ? "Nachname:" : "Lastname:") + lastname + NOVALIDNAME);
}
if(! FormInputChecker.isCorrectPhone(phonestate)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONESTATE,
(g ? "L�ndervorwahl: " : "Phone State: ") + phonestate + NOVALIDNUMBER);
}
if(! FormInputChecker.isCorrectPhone(phonetown)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONETOWN,
(g ? "Stadtvorwahl: " : "Phone city: ") + phonetown + NOVALIDNUMBER);
}
if(! FormInputChecker.isCorrectPhone(phonelocation)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONELOCATION,
(g ? "Standortvorwahl: " : "Phone Location: ") + phonelocation + NOVALIDNUMBER);
}
if(! FormInputChecker.isCorrectPhone(phonedirect)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONEDIRECT,
(g ? "Durchwahl: " : "Phone Direct: ") + phonedirect + NOVALIDNUMBER);
}
if(! FormInputChecker.isCorrectPhone(faxdirect)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_FAXDIRECT,
(g ? "Fax: " : "Fax: ") + faxdirect + NOVALIDNUMBER);
}
boolean tPhoneWasEntered =
! phonestate.equals("")
&& ! phonetown.equals("")
&& ! phonelocation.equals("")
&& ! phonedirect.equals("");
// if not (all phones are empty or all phones not empty)
if(!( ( phonestate.equals("") &&
phonetown.equals("") &&
phonelocation.equals("") &&
phonedirect.equals(""))
|| tPhoneWasEntered)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONESTATE,
(g ? "Bitte geben Sie eine vollst�ndige Telefonnummer an."
: "Please enter a complete telefon number."));
}
if(! faxdirect.equals("") && ! tPhoneWasEntered) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_PHONESTATE,
(g ? "Bitte geben Sie zuerst eine vollst�ndige Telefonnummer an, bevor Sie eine Faxnummer angeben."
: "Please enter a complete telefon number before entering a fax number."));
}
if(email.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_EMAIL,
(g ? "Email Adresse" : "Email-Address:") + OBLIGATORY);
} else if(! FormInputChecker.isCorrectEmail(email)) {
founderrors.addError(Person_HtmlParam.INPUT_PERSON_EMAIL,
(g ? "Email Adresse" : "Email-Address:") + email + NOVALIDEMAIL);
}
if(company.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_DEPARTMENT_COMPANY,
(g ? "Firma" + OBLIGATORY + " Bitte pr�fen Sie den von uns eingetragenen Defaultwert."
: "Company" + OBLIGATORY + " Please check the defaultvalue."));
}
if(department.equals("")) {
founderrors.addError(Person_HtmlParam.INPUT_DEPARTMENT_SHORTNAME,
(g ? "Abteilung" : "Department:") + OBLIGATORY);
} else if(! FormInputChecker.isNameDigitAmpersandCorrect(department)) {
founderrors.addError(Person_HtmlParam.INPUT_DEPARTMENT_SHORTNAME,
(g ? "Abteilung:" : "Department:") + department + NOVALIDNAME);
}
if(! FormInputChecker.isNameDigitSlashCorrect(location)) {
founderrors.addError(Person_HtmlParam.INPUT_DEPARTMENT_LOCATION,
(g ? "Standort:" : "Location:") + location + NOVALIDNAME);
}
if(passwrd.equals("")) {
founderrors.addError("InputPersonPassword",
(g ? "Passwort" : "Password") + OBLIGATORY);
}
if(passwrdVerify.equals("")) {
founderrors.addError("InputPersonPasswordVerify",
(g ? "Passwortwiederholung " : "Passwordverify ") + OBLIGATORY);
}
//check passwords are ok
if((! passwrdVerify.equals("")) && (! passwrd.equals("")) && (! passwrd.equals(passwrdVerify)))
{
founderrors.addError("InputPersonPassword",
(g ? "Passwort und Passwortwiederholung stimmen nicht �berein."
: "Password and Passwordverify do not match."));
}
return founderrors;
}
/** Prints user-visible error message.
*
* <P>Currently never used.</P>
*
* @param aWriter PrintWriter
* @param message to print
* @param adminEmail email address of administrator
* @param language langue selected e.g. English
*/
public static void printError (
PrintWriter aWriter,
String message,
String adminEmail,
String language)
{
//JD: PrintWriter does not throw IOException
//try {
aWriter.println("<H2 Align=center>A error occured! / Ein Fehler ist aufgetreten!</H2>"
+ "<H3 Align=center>Please report the following to your<A HREF='" + adminEmail +"'> administrator</A>:</H3>"
+ "<H3 Align=center>Bitte teilen Sie ihrem <A HREF='" + adminEmail +"'> Administrator</A> folgendes mit:</H3>"
+ "<H3 Align=center>" + message + "</H3>");
//} catch (IOException e){
// System.err.println("IOException: " + e.getMessage());
//}
}
// ************************************************************
// Inner classes
// ************************************************************
/** Helper class for reporting errors.
*/
private static class ErrVector extends Vector
{
private void addError (
String one,
String two)
{
this.addElement(new String[] { one, two });
}
}
}