From 58a9ff0fcfd11074729cea8d5a8af967eee8f754 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 10 Aug 2016 12:32:41 +0200 Subject: [PATCH] Continued a bit: (please cherry-pick) - implemented controller (bean) method deleteCellphoneData() with event being fired after the cell phone has been deleted. This can be used for later event logging or what ever. - implemented form for deleting cell phone data - fixed id for commandButton (is edit_cellphone) - added missing i18n strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../phone/JobsAdminPhoneWebRequestBean.java | 48 +++++++++++++++++++ .../JobsAdminPhoneWebRequestController.java | 7 +++ .../localization/bundle_de_DE.properties | 2 + .../localization/bundle_en_US.properties | 2 + .../cellphone/admin_cellphone_delete.xhtml | 24 +++++++++- .../cellphone/admin_cellphone_edit.xhtml | 2 +- 6 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index 861b3e12..b59be276 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -30,6 +30,8 @@ import javax.naming.NamingException; import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.helper.JobsWebRequestController; +import org.mxchange.jphone.events.cellphone.deleted.AdminCellphoneNumberDeletedEvent; +import org.mxchange.jphone.events.cellphone.deleted.AdminDeletedCellphoneNumberEvent; import org.mxchange.jphone.events.updated.AdminCellphoneNumberUpdatedEvent; import org.mxchange.jphone.events.updated.AdminUpdatedCellphoneNumberEvent; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; @@ -60,6 +62,13 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements @Inject private JobsWebRequestController beanHelper; + /** + * Event being fired when an administrator has deleted cell phone number + */ + @Inject + @Any + private Event cellPhoneNumberDeletedEvent; + /** * Event being fired when an administrator has updated cell phone number */ @@ -94,6 +103,45 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements } } + @Override + public String deleteCellphoneData () { + // Is all data set + if (this.beanHelper.getCellPhoneNumber() == null) { + // Not set, throw NPE + throw new NullPointerException("this.cellphoneNumber is null"); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("this.cellphoneNumber.phoneId is null"); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.phoneId={0} is not valid", this.beanHelper.getCellPhoneNumber().getPhoneId())); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider() == null) { + // Throw NPE + throw new NullPointerException("this.cellphoneNumber.cellphoneProvider is null"); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("this.cellphoneNumber.cellphoneProvider.providerId is null"); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.cellphoneProvider.providerId={0} is not valid.", this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId())); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("this.cellphoneNumber.phoneNumber is null"); //NOI18N + } else if (this.beanHelper.getCellPhoneNumber().getPhoneNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("this.cellphoneNumber.phoneNumber={0} is not valid.", this.beanHelper.getCellPhoneNumber().getPhoneNumber())); //NOI18N + } + + // Call EJB + this.adminPhoneBean.deleteCellphoneData(this.beanHelper.getCellPhoneNumber()); + + // Fire event + this.cellPhoneNumberDeletedEvent.fire(new AdminCellphoneNumberDeletedEvent(this.beanHelper.getCellPhoneNumber())); + + // All fine, redirect + return "admin_list_cellphone?faces-redirect=true&includeViewParams=true"; //NOI18N + } + @Override public String editCellphoneData () { // Is all data set diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java index c74a4593..82db717d 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java @@ -29,6 +29,13 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; @Local public interface JobsAdminPhoneWebRequestController extends Serializable { + /** + * Deletes given cellphone entry data + *

+ * @return Redirect outcome + */ + String deleteCellphoneData (); + /** * Changes cellphone entry data *

diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index fc8aeaf9..7c143d8a 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -616,3 +616,5 @@ ADMIN_CELLPHONE_DATA_LEGEND_TITLE=Mobilfunknummer und -anbieter ab\u00e4ndern. ERROR_CANNOT_LOCK_USER_ACCOUNT_UNCONFIRMED=Fehler: Kann das Benutzerkonto nicht sperren, da es noch nicht best\u00e4tigt ist. ADMIN_MOBILE_PROVIDER_REQUIRED=Bitte einen Mobilfunkanbieter ausw\u00e4hlen. ADMIN_CELLPHONE_NUMBER_REQUIRED=Bitte Mobilfunknummer angeben. +BUTTON_ADMIN_DELETE_CELLPHONE=Mobilfunknummer l\u00f6schen +ADMIN_DELETE_CELLPHONE_DATA_NOTICE=Wenn Sie die Mobilfunknummer l\u00f6schen, steht diese nicht mehr im System zur Verf\u00fcgung. Bitte \u00fcberlegen Sie genau, ob Sie dies wollen. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index df788677..fc455c03 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -616,3 +616,5 @@ ADMIN_CELLPHONE_DATA_LEGEND_TITLE=Change cell phone number and provider. ERROR_CANNOT_LOCK_USER_ACCOUNT_UNCONFIRMED=Error: Cannot lock user account, it is still unconfirmed. ADMIN_MOBILE_PROVIDER_REQUIRED=Please choose a mobile provider. ADMIN_CELLPHONE_NUMBER_REQUIRED=Please enter a cell phone number. +BUTTON_ADMIN_DELETE_CELLPHONE=Delete cell phone number +ADMIN_DELETE_CELLPHONE_DATA_NOTICE=If you delete the cell phone number, it won't be available anymore for anything. Please consider carefully if you really want this. diff --git a/web/admin/cellphone/admin_cellphone_delete.xhtml b/web/admin/cellphone/admin_cellphone_delete.xhtml index 13f28dc0..186dfecc 100644 --- a/web/admin/cellphone/admin_cellphone_delete.xhtml +++ b/web/admin/cellphone/admin_cellphone_delete.xhtml @@ -19,7 +19,29 @@ - Here goes your content. + +

+
+ +
+ +
+ + + +
+ +
+ + + +
+ + + diff --git a/web/admin/cellphone/admin_cellphone_edit.xhtml b/web/admin/cellphone/admin_cellphone_edit.xhtml index 2c87088a..2fbc9826 100644 --- a/web/admin/cellphone/admin_cellphone_edit.xhtml +++ b/web/admin/cellphone/admin_cellphone_edit.xhtml @@ -30,7 +30,7 @@
-- 2.39.5