]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 19:16:55 +0000 (21:16 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 19:20:18 +0000 (21:20 +0200)
- moved converter classes to better locations: org.mxchange.addressbook.converter.foo is better :)
- added + used user converter to convert user id to User instance
- maybe c:choose/c:when/c:otherwise is better than ui:fragment? Still the page is a dummy
- updated jar(s)

lib/juser-core.jar
src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
src/java/org/mxchange/addressbook/beans/user/UserWebController.java
src/java/org/mxchange/addressbook/converter/country/CountryConverter.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/converter/user/UserConverter.java [new file with mode: 0644]
src/java/org/mxchange/jcountry/data/converter/CountryConverter.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/smsprovider/converter/SmsProviderConverter.java [deleted file]
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/user/user_profile.xhtml

index 703a0b80f39f09238c27db8637f60068503db2d3..6c0c84ec3a4aa2d7f6afaf8aa489c846041de01a 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 4aa9d47d46daa92cf97feaa3f2d4786dddb7855e..6d45f7ce6f5677fe65bde787f308fdfdfa65221e 100644 (file)
@@ -20,6 +20,7 @@ import java.text.MessageFormat;
 import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
@@ -44,6 +45,7 @@ import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
 import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
@@ -700,6 +702,34 @@ public class UserWebBean implements UserWebController {
                return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0));
        }
 
+       @Override
+       public User lookupUserById (final Long userId) throws UserNotFoundException {
+               // Init variable
+               User user = null;
+
+               // Try to lookup it in visible user list
+               for (final Iterator<User> iterator = this.visibleUserList.iterator(); iterator.hasNext();) {
+                       // Get next user
+                       User next = iterator.next();
+
+                       // Is the user id found?
+                       if (Objects.equals(next.getUserId(), userId)) {
+                               // Copy to other variable
+                               user = next;
+                               break;
+                       }
+               }
+
+               // Is it still null?
+               if (null == user) {
+                       // Not visible for the current user
+                       throw new UserNotFoundException(userId);
+               }
+
+               // Return it
+               return user;
+       }
+
        /**
         * Adds user's name and email address to bean's internal list. It also
         * updates the public user list if the user has decided to ha   }
index 9a71ae45a2762a0a7b5b3b2818d34f6b2b76fd57..dd79d6e06d4585c3e08dc0bf33da6f570a2fa281 100644 (file)
@@ -23,6 +23,7 @@ import org.mxchange.jcontacts.contact.gender.Gender;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 
@@ -33,6 +34,18 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
  */
 public interface UserWebController extends Serializable {
 
+       /**
+        * Tries to lookup user by given id number. If the user is not found or the
+        * account status is not CONFIRMED proper exceptions are thrown.
+        * <p>
+        * @param userId User id
+        * <p>
+        * @return User instance
+        * <p>
+        * @throws UserNotFoundException If the user is not found
+        */
+       User lookupUserById (final Long userId) throws UserNotFoundException;
+
        /**
         * Event observer for new user registrations
         * <p>
diff --git a/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java b/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java
new file mode 100644 (file)
index 0000000..25d172f
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.converter.country;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.inject.Inject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.country.CountryWebController;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * Converter for country instance
+ * <p>
+ * @author Roland Haeder
+ */
+@FacesConverter (value = "country")
+public class CountryConverter implements Converter {
+
+       /**
+        * Country bean
+        */
+       @Inject
+       private CountryWebController countryController;
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+               // Get full list
+               List<Country> countryList = this.countryController.allCountries();
+
+               // Is the value null or empty?
+               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+                       // Return null
+                       return null;
+               }
+
+               // 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());
+       }
+
+       /**
+        * Initialization of this converter
+        */
+       @PostConstruct
+       public void init () {
+               // 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
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+}
diff --git a/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java b/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java
new file mode 100644 (file)
index 0000000..06422b0
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.converter.smsprovider;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.inject.Inject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.smsprovider.SmsProviderWebController;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
+
+/**
+ * Converter for SMS provider instance
+ * <p>
+ * @author Roland Haeder
+ */
+@FacesConverter (value = "cellphoneCarrier")
+public class SmsProviderConverter implements Converter {
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * SMS provider bean
+        */
+       @Inject
+       private SmsProviderWebController providerController;
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+               // Get full list
+               List<SmsProvider> providerList = this.providerController.allSmsProvider();
+
+               // Is the value null or empty?
+               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+                       // Return null
+                       return null;
+               }
+
+               // 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());
+       }
+
+       /**
+        * Initialization of this converter
+        */
+       @PostConstruct
+       public void init () {
+               // 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
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/addressbook/converter/user/UserConverter.java b/src/java/org/mxchange/addressbook/converter/user/UserConverter.java
new file mode 100644 (file)
index 0000000..92f93d2
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.converter.user;
+
+import java.text.MessageFormat;
+import javax.annotation.PostConstruct;
+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.inject.Inject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.user.UserWebController;
+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
+ * <p>
+ * @author Roland Haeder
+ */
+@FacesConverter (value = "UserConverter")
+public class UserConverter implements Converter {
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * User bean
+        */
+       @Inject
+       private UserWebController userController;
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+               // Is the value null or empty?
+               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+                       // 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());
+       }
+
+       /**
+        * Initialization of this converter
+        */
+       @PostConstruct
+       public void init () {
+               // 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
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+}
diff --git a/src/java/org/mxchange/jcountry/data/converter/CountryConverter.java b/src/java/org/mxchange/jcountry/data/converter/CountryConverter.java
deleted file mode 100644 (file)
index b8f516f..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.data.converter;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.FacesConverter;
-import javax.inject.Inject;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.country.CountryWebController;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jcountry.data.Country;
-
-/**
- * Converter for country instance
- * <p>
- * @author Roland Haeder
- */
-@FacesConverter (value = "country")
-public class CountryConverter implements Converter {
-
-       /**
-        * Category bean
-        */
-       @Inject
-       private CountryWebController countryController;
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Trace message
-               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
-               // Get full list
-               List<Country> countryList = this.countryController.allCountries();
-
-               // Is the value null or empty?
-               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
-                       // Return null
-                       return null;
-               }
-
-               // 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());
-       }
-
-       /**
-        * Initialization of this converter
-        */
-       @PostConstruct
-       public void init () {
-               // 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
-               } catch (final NamingException ex) {
-                       // Continue to throw it
-                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
-               }
-       }
-}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/smsprovider/converter/SmsProviderConverter.java b/src/java/org/mxchange/jphone/phonenumbers/smsprovider/converter/SmsProviderConverter.java
deleted file mode 100644 (file)
index 41bafe7..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.phonenumbers.smsprovider.converter;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.FacesConverter;
-import javax.inject.Inject;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.smsprovider.SmsProviderWebController;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
-
-/**
- * Converter for SMS provider instance
- * <p>
- * @author Roland Haeder
- */
-@FacesConverter (value = "cellphoneCarrier")
-public class SmsProviderConverter implements Converter {
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * Category bean
-        */
-       @Inject
-       private SmsProviderWebController providerController;
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Trace message
-               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
-               // Get full list
-               List<SmsProvider> providerList = this.providerController.allSmsProvider();
-
-               // Is the value null or empty?
-               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
-                       // Return null
-                       return null;
-               }
-
-               // 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());
-       }
-
-       /**
-        * Initialization of this converter
-        */
-       @PostConstruct
-       public void init () {
-               // 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
-               } catch (final NamingException ex) {
-                       // Continue to throw it
-                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
-               }
-       }
-
-}
index edeadb2a4ff06162124edee77d952223fc2020ba..16e384a7c4f3b107fab35f9e1176654e2a5e8fce 100644 (file)
@@ -248,3 +248,4 @@ ADDRESSBOOK_OWNER=Besitzer:
 ADDRESSBOOK_STATUS=Status:
 PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=\u00d6ffentlicher Teil des Adressbuchs anzeigen
 USER_PROFILE_NOT_PUBLICLY_VISIBLE=Das Benutzerprofil ist privat.
+PAGE_TITLE_LOGIN_USER_PROFILE=Benutzerprofil ansehen
index 65a5a3536cbaf47c00336fe2298ba74fbab8c1bf..4b7a0fe76900088ae11e646fbadec2d1f37b5f52 100644 (file)
@@ -248,3 +248,4 @@ ADDRESSBOOK_OWNER=Owner:
 ADDRESSBOOK_STATUS=Status:
 PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=Show public part of address book
 USER_PROFILE_NOT_PUBLICLY_VISIBLE=The user profile is private.
+PAGE_TITLE_LOGIN_USER_PROFILE=View user profile
index fc0f120007aca8d3ee3a8bded2b3dc8e92d0c044..59f8e6a837aa8989b7bb611f6ba50e8330efc8aa 100644 (file)
@@ -4,16 +4,18 @@
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:f="http://xmlns.jcp.org/jsf/core"
-         >
+         xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
        <f:metadata>
-               <f:viewParam id="userId" name="userId" value="#{shareController.shareeUserId}" required="true" requiredMessage="#{msg.PARAMETER_USER_ID_MISSING}" converterMessage="#{msg.PARAMETER_USER_ID_INVALID}" validatorMessage="#{msg.PARAMETER_USER_ID_NOT_FOUND}">
+               <f:viewParam id="userId" name="userId" value="#{userController.userId}" required="true" requiredMessage="#{msg.PARAMETER_USER_ID_MISSING}" converterMessage="#{msg.PARAMETER_USER_ID_INVALID}" validatorMessage="#{msg.PARAMETER_USER_ID_NOT_FOUND}">
                        <f:convertNumber for="userId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
                        <f:validator for="userId" validatorId="UserIdValidator" />
+                       <f:converter for="userId" converterId="UserConverter" />
                </f:viewParam>
        </f:metadata>
 
        <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.templateType}_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_USER_PROFILE}</ui:define>
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_USER_PROFILE}</ui:define>
 
                <ui:define name="content_header">
                </ui:define>
 
                <ui:define name="content">
-                       <ui:fragment rendered="#{shareController.isShareeUserIdSet()}">
-                               Here goes your content.
-                       </ui:fragment>
+                       <c:choose>
+                               <c:when test="#{userController.isUserIdEmpty()}">
+                                       <ui:include src="/WEB-INF/templates/generic/userid_error.tpl" />
+                               </c:when>
 
-                       <ui:fragment rendered="#{shareController.isShareeUserIdEmpty()}">
-                               <ui:include src="/WEB-INF/templates/generic/userid_error.tpl" />
-                       </ui:fragment>
+                               <c:when test="#{profileController.isProfileLinkVisible(userController.user)}">
+                                       Here goes your content.
+                               </c:when>
+
+                               <c:otherwise>
+                                       #{msg.ERROR_PROFILE_NOT_VISIBLE}
+                               </c:otherwise>
+                       </c:choose>
                </ui:define>
        </ui:composition>
 </html>