From: Roland Haeder Date: Sat, 9 Apr 2016 16:10:27 +0000 (+0200) Subject: introduced new lib jphone-lib.jar which holds remote interfaces for jphone-core X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2b050be7fb41096e00c9c2076a623e7c75672307;p=pizzaservice-war.git introduced new lib jphone-lib.jar which holds remote interfaces for jphone-core --- diff --git a/lib/jphone-lib.jar b/lib/jphone-lib.jar new file mode 100644 index 00000000..bdeff312 Binary files /dev/null and b/lib/jphone-lib.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index bbdd9e37..1b0a0d39 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1036,6 +1036,7 @@ exists or setup the property manually. For example like this: + @@ -1054,6 +1055,7 @@ exists or setup the property manually. For example like this: + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 342fc01e..9d44227b 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=82213886 build.xml.stylesheet.CRC32=651128d4@1.68.1.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=6cb26eb6 -nbproject/build-impl.xml.script.CRC32=ad01ddaf +nbproject/build-impl.xml.data.CRC32=10a373e0 +nbproject/build-impl.xml.script.CRC32=f7d4e4e8 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index 2df1fa2e..9ed25a58 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -46,6 +46,7 @@ file.reference.jcountry-lib.jar=lib/jcountry-lib.jar file.reference.jcustomer-core.jar=lib/jcustomer-core.jar file.reference.jcustomer-lib.jar=lib/jcustomer-lib.jar file.reference.jphone-core.jar=lib/jphone-core.jar +file.reference.jphone-lib.jar=lib/jphone-lib.jar file.reference.jshop-core.jar=lib/jshop-core.jar file.reference.jshop-ee-lib.jar=lib/jshop-ee-lib.jar includes=** @@ -68,6 +69,7 @@ javac.classpath=\ ${file.reference.jcountry-core.jar}:\ ${file.reference.jcountry-lib.jar}:\ ${file.reference.jphone-core.jar}:\ + ${file.reference.jphone-lib.jar}:\ ${file.reference.jcontacts-core.jar}:\ ${file.reference.jcustomer-core.jar}:\ ${file.reference.jcustomer-lib.jar}:\ @@ -124,6 +126,7 @@ source.reference.jcountry-lib.jar=../jcountry-lib/src/ source.reference.jcustomer-core.jar=../jcustomer-core/src/ source.reference.jcustomer-lib.jar=../jcustomer-lib/src/ source.reference.jphone-core.jar=../jphone-core/src/ +source.reference.jphone-lib.jar=../jphone-lib/src/ source.reference.jshop-core.jar=../jshop-core/src/ source.reference.jshop-ee-lib.jar=../jshop-ee-lib/src/ source.root=src diff --git a/nbproject/project.xml b/nbproject/project.xml index f439710b..73eb585e 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -30,6 +30,10 @@ ${file.reference.jphone-core.jar} WEB-INF/lib + + ${file.reference.jphone-lib.jar} + WEB-INF/lib + ${file.reference.jcontacts-core.jar} WEB-INF/lib diff --git a/src/java/org/mxchange/jshopcore/model/category/PizzaCategoryConverter.java b/src/java/org/mxchange/jshopcore/model/category/PizzaCategoryConverter.java index 48cdb27a..b9fbf685 100644 --- a/src/java/org/mxchange/jshopcore/model/category/PizzaCategoryConverter.java +++ b/src/java/org/mxchange/jshopcore/model/category/PizzaCategoryConverter.java @@ -136,4 +136,5 @@ public class PizzaCategoryConverter implements Converter { throw new RuntimeException("context.lookup() failed.", ex); //NOI18N } } + } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 8d38921e..c94dc3fa 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -227,3 +227,4 @@ ADMIN_MENU_USER_TITLE=Benutzerverwaltung PAGE_TITLE_ADMIN_ADD_USER=Neues Benutzeraccount hinzufuegen #CONTENT_TITLE_ADMIN_ADD_USER CONTENT_TITLE_ADMIN_ADD_USER=Neues Benutzeraccount hinzufuegen: +TABLE_SUMMARY_ADMIN_LIST_USERS=Administration, alle Benutzer auflisten diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 8ced41b6..efc772b3 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -218,3 +218,4 @@ CONTENT_TITLE_ADMIN_UNLOCK_USER=Un-/Lock user accounts: ADMIN_MENU_USER_TITLE=User management PAGE_TITLE_ADMIN_ADD_USER=Add new user account CONTENT_TITLE_ADMIN_ADD_USER=Add new user account: +TABLE_SUMMARY_ADMIN_LIST_USERS=Administration, list all users diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionBean.java index 56bdc6e0..be085512 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionBean.java @@ -480,4 +480,5 @@ public class PizzaBasketWebSessionBean implements PizzaBasketWebSessionControlle // Return it return foundItem; } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java index 1c20c118..92673426 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java @@ -167,4 +167,5 @@ public interface PizzaBasketWebSessionController extends Serializable { * @return Last added item */ String outputLastAddedItem (); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java index ef700192..1c7d11ce 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java @@ -127,4 +127,5 @@ public class PizzaAdminCategoryWebRequestBean implements PizzaAdminCategoryWebRe public void setParentCategory (final Category parentCategory) { this.parentCategory = parentCategory; } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestController.java index 2e130ba0..a71bd398 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestController.java @@ -61,4 +61,5 @@ public interface PizzaAdminCategoryWebRequestController { * @param categoryTitle the title to set */ void setCategoryTitle (final String categoryTitle); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java index a1b11960..e325da56 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java @@ -227,4 +227,5 @@ public class PizzaCheckoutWebSessionBean implements PizzaCheckoutWebSessionContr throw new FacesException(e); } } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java index 2724eecb..3c2d5f53 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java @@ -46,4 +46,5 @@ public interface PizzaCheckoutWebSessionController extends Serializable { * @param customer Customer instance */ void setCustomer (final Customer customer); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java index c60e7975..3a761dc9 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java @@ -83,4 +83,5 @@ public class PizzaCountryWebApplicationBean implements PizzaCountryWebApplicatio // "Cache" country list as this will not change so often. this.countryList = this.countryBean.allCountries(); } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java index 616891d4..70d54870 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java @@ -33,4 +33,5 @@ public interface PizzaCountryWebApplicationController extends Serializable { * @return All countries */ List allCountries (); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java index d0eaa694..5a052a7b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java @@ -293,4 +293,5 @@ public class PizzaCustomerWebSessionBean implements PizzaCustomerWebSessionContr public boolean isRequiredPersonalDataSet () { return ((this.getGender() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && (this.getHouseNumber() != null) && (this.getZipCode() != null) && (this.getCity() != null)); } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionController.java index b9674d7e..d7a2e479 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionController.java @@ -212,4 +212,5 @@ public interface PizzaCustomerWebSessionController extends Serializable { * @return Whether the required personal data is set */ boolean isRequiredPersonalDataSet (); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java index b329e098..17d8bd9e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java @@ -171,4 +171,5 @@ public class PizzaAdminProductWebRequestBean implements PizzaAdminProductWebRequ public void setProductTitle (final String productTitle) { this.productTitle = productTitle; } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestController.java index 3a9a67a4..db59c24e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestController.java @@ -100,4 +100,5 @@ public interface PizzaAdminProductWebRequestController { * @param title Product's title */ void setProductTitle (final String title); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java index 28f042f2..662d4f8e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java @@ -79,4 +79,5 @@ public class PizzaReceiptWebSessionBean implements PizzaReceiptWebSessionControl public void setCustomer (final Customer customer) { this.customer = customer; } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java index 63052fd4..661817a9 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java @@ -46,4 +46,5 @@ public interface PizzaReceiptWebSessionController extends Serializable { * @param customer Customer instance */ void setCustomer (final Customer customer); + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationBean.java index f85638b8..1c365165 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationBean.java @@ -119,4 +119,5 @@ public class PizzaShopWebApplicationBean implements PizzaShopWebApplicationContr throw new FacesException(e); } } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationController.java index 5cbe8fcc..b7ccb5c8 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/shop/PizzaShopWebApplicationController.java @@ -70,4 +70,5 @@ public interface PizzaShopWebApplicationController extends Serializable { * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ List getAvailableProducts () throws FaceletException; + } diff --git a/src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java b/src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java new file mode 100644 index 00000000..f9eec18a --- /dev/null +++ b/src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaservice.converter.country; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jcountry.data.CountrySingletonBeanRemote; + +/** + * Converter for country instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "country") +public class PizzaCountryConverter implements Converter { + + /** + * Country bean + */ + private CountrySingletonBeanRemote countryBean; + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Initialization of this converter + */ + public PizzaCountryConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and country bean + this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/pizza-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2},this.countryBean={3} - CALLED!", context, component, submittedValue, this.countryBean)); //NOI18N + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Trace message + this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //NOI18N + + // Return null + return null; + } + + // Get full list + List countryList = this.countryBean.allCountries(); + + // Init value + Country country = null; + + // Try this better + try { + // Convert it to long + Long countryId = Long.parseLong(submittedValue); + + // Category id should not be below 1 + assert (countryId > 0) : "countryId is smaller than one: " + countryId; //NOI18N + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: countryId={0}", countryId)); //NOI18N + + // Try to find it + for (final Country cntry : countryList) { + // Is the id the same? (null-safe) + if (Objects.equals(cntry.getCountryId(), countryId)) { + // Found it + country = cntry; + break; + } + } + } catch (final NumberFormatException ex) { + // Log exception (maybe to much?) + this.loggerBeanLocal.logException(ex); + } + + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: country={0} - EXIT!", country)); //NOI18N + + // Return it + return country; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof Country)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Country.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((Country) value).getCountryId()); + } +} diff --git a/src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java b/src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java new file mode 100644 index 00000000..bc1c94b4 --- /dev/null +++ b/src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaservice.converter.smsprovider; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProviderSingletonBeanRemote; + +/** + * Converter for SMS provider instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "cellphoneCarrier") +public class PizzaSmsProviderConverter implements Converter { + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * SMS provider bean + */ + private SmsProviderSingletonBeanRemote providerController; + + /** + * Initialization of this converter + */ + public PizzaSmsProviderConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + /// and SMS provider controller + this.providerController = (SmsProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/smsprovider!org.mxchange.jphone.phonenumbers.smsprovider.PizzaSmsProviderSingletonBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Trace message + this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //NOI18N + + // Return null + return null; + } + + // Get full list + List providerList = this.providerController.allSmsProvider(); + + // Init value + SmsProvider provider = null; + + // Try this better + try { + // Convert it to long + Long providerId = Long.parseLong(submittedValue); + + // Category id should not be below 1 + assert (providerId > 0) : "providerId is smaller than one: " + providerId; //NOI18N + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N + + // Try to find it + for (final SmsProvider prov : providerList) { + // Is the id the same? (null-safe) + if (Objects.equals(prov.getProviderId(), providerId)) { + // Found it + provider = prov; + break; + } + } + } catch (final NumberFormatException ex) { + // Log exception (maybe to much?) + this.loggerBeanLocal.logException(ex); + } + + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: provider={0} - EXIT!", provider)); //NOI18N + + // Return it + return provider; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof SmsProvider)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement SmsProvider.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((SmsProvider) value).getProviderId()); + } +} diff --git a/src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java b/src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java new file mode 100644 index 00000000..5eb27066 --- /dev/null +++ b/src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaservice.converter.user; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.model.user.User; + +/** + * Converter for user id <-> valid user instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "UserConverter") +public class PizzaUserConverter implements Converter { + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * User bean + */ + private AddressbookUserWebSessionController userController; + + /** + * Initialization of this converter + */ + public PizzaUserConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and user controller + this.userController = (AddressbookUserWebSessionController) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Trace message + this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //NOI18N + + // Return null + return null; + } + + // Init instance + User user = null; + + try { + // Try to parse the value as long + Long userId = Long.valueOf(submittedValue); + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); + + // Try to get user instance from it + user = this.userController.lookupUserById(userId); + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: user={0}", user)); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final UserNotFoundException ex) { + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: Exception: {0} - Returning null ...", ex)); + + // Return null + return null; + } + + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: user={0} - EXIT!", user)); + + // Return it + return user; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof User)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement User.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((User) value).getUserId()); + } + +} diff --git a/web/WEB-INF/templates/base.tpl b/web/WEB-INF/templates/base.tpl index 96b05e21..4dad5f8c 100644 --- a/web/WEB-INF/templates/base.tpl +++ b/web/WEB-INF/templates/base.tpl @@ -12,8 +12,8 @@ - - + + Pizza-Service - <ui:insert name="title">Default title</ui:insert> diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 02340ff6..d25422b7 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -29,9 +29,6 @@ 30 - - true - faces/index.xhtml diff --git a/web/admin/admin_user_list.xhtml b/web/admin/admin_user_list.xhtml index 63f75e2c..4f336b36 100644 --- a/web/admin/admin_user_list.xhtml +++ b/web/admin/admin_user_list.xhtml @@ -14,7 +14,8 @@ - Here goes your content. + +