/** * Get the settings with the default ID. * * @return <code>null</code> if no such settings are contained. */ @Nullable public NamedSMTPSettings getDefaultSettings () { return getSettings (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID); }
/** * Remove all contained SMTP settings * * @return {@link EChange#CHANGED} if a removal was performed. */ @Nullable public EChange removeAllSettings () { // Get all available settings IDs final ICommonsSet <String> aAllIDs = m_aRWLock.readLocked ( () -> m_aMap.copyOfKeySet ()); // Batch remove all settings EChange eChange = EChange.UNCHANGED; beginWithoutAutoSave (); try { for (final String sID : aAllIDs) eChange = eChange.or (removeSettings (sID)); } finally { endWithoutAutoSave (); } return eChange; }
@Override @Nonnull protected EChange onInit () { if (!isCreateDefaults ()) return EChange.UNCHANGED; // Create default item with as little data as possible _addItem (new NamedSMTPSettings (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID, CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_NAME, new SMTPSettings (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_HOST, CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_PORT, null, null, CSMTP.CHARSET_SMTP_OBJ, false))); return EChange.CHANGED; }
if (m_aMgr.updateSettings (aSelectedObject.getID (), sName, aSMTPSettings).isChanged ()) aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.SUCCESS_EDIT.getDisplayText (aDisplayLocale))); m_aMgr.addSettings (sName, aSMTPSettings); aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.SUCCESS_CREATE.getDisplayText (aDisplayLocale)));
@Nonnull final ISMTPSettings aSettings) final NamedSMTPSettings aNamedSettings = getSettings (sID); if (aNamedSettings == null) if (eChange.isUnchanged ()) return EChange.UNCHANGED; markAsChanged (); AuditHelper.onAuditModifySuccess (NamedSMTPSettings.OT, aNamedSettings.getID (),
@Override protected void performDelete (@Nonnull final WPECTYPE aWPEC, @Nonnull final NamedSMTPSettings aSelectedObject) { final Locale aDisplayLocale = aWPEC.getDisplayLocale (); if (m_aMgr.removeSettings (aSelectedObject.getID ()).isChanged ()) { aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.DELETE_SUCCESS.getDisplayTextWithArgs (aDisplayLocale, aSelectedObject.getName ()))); } else { aWPEC.postRedirectGetInternal (new BootstrapErrorBox ().addChild (EText.DELETE_ERROR.getDisplayTextWithArgs (aDisplayLocale, aSelectedObject.getName ()))); } } });
.getDefaultSMTPSettings () : null; if (LOGGER.isInfoEnabled ())
new DTCol (EText.HEADER_USERNAME.getDisplayText (aDisplayLocale)), new BootstrapDTColAction (aDisplayLocale)).setID (getID ()); for (final NamedSMTPSettings aCurObject : m_aMgr.getAllSettings ().values ())
_addItem (aNamedSettings); markAsChanged (); });
@Override @Nonnull protected EChange onRead (@Nonnull final IMicroDocument aDoc) { for (final IMicroElement eNamedSMTPSettings : aDoc.getDocumentElement ().getAllChildElements (ELEMENT_ITEM)) _addItem (MicroTypeConverter.convertToNative (eNamedSMTPSettings, NamedSMTPSettings.class)); return EChange.UNCHANGED; }
@Override protected void onAfterInstantiation (@Nonnull final IScope aScope) { try { m_aSMTPSettingsMgr = new NamedSMTPSettingsManager (SMTP_SETTINGS_XML); m_aFailedMailQueue = new FailedMailQueueWithDAO (FAILED_MAILS_XML); ScopedMailAPI.getInstance ().setFailedMailQueue (m_aFailedMailQueue); m_aGoMappingMgr = new GoMappingManager (GO_XML); m_aWebSiteResourceBundleMgr = new WebSiteResourceBundleManager (WEBSITE_RESOURCE_BUNDLES_XML); LOGGER.info (ClassHelper.getClassLocalName (this) + " was initialized"); } catch (final Throwable t) { throw new InitializationException ("Failed to init " + ClassHelper.getClassLocalName (this), t); } }
if (m_aMgr.updateSettings (aSelectedObject.getID (), sName, aSMTPSettings).isChanged ()) aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.SUCCESS_EDIT.getDisplayText (aDisplayLocale))); m_aMgr.addSettings (sName, aSMTPSettings); aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.SUCCESS_CREATE.getDisplayText (aDisplayLocale)));
@Override protected void performDelete (@Nonnull final WPECTYPE aWPEC, @Nonnull final NamedSMTPSettings aSelectedObject) { final Locale aDisplayLocale = aWPEC.getDisplayLocale (); if (m_aMgr.removeSettings (aSelectedObject.getID ()).isChanged ()) { aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.DELETE_SUCCESS.getDisplayTextWithArgs (aDisplayLocale, aSelectedObject.getName ()))); } else { aWPEC.postRedirectGetInternal (new BootstrapErrorBox ().addChild (EText.DELETE_ERROR.getDisplayTextWithArgs (aDisplayLocale, aSelectedObject.getName ()))); } } });
.getDefaultSMTPSettings () : null; if (LOGGER.isInfoEnabled ())
new DTCol (EText.HEADER_USERNAME.getDisplayText (aDisplayLocale)), new BootstrapDTColAction (aDisplayLocale)).setID (getID ()); for (final NamedSMTPSettings aCurObject : m_aMgr.getAllSettings ().values ())
@Override @Nullable protected NamedSMTPSettings getSelectedObject (@Nonnull final WPECTYPE aWPEC, @Nullable final String sID) { return m_aMgr.getSettings (sID); }
@Nonnull public EShowList handleAction (final WPECTYPE aWPEC, final FailedMailData aSelectedObject) { final Locale aDisplayLocale = aWPEC.getDisplayLocale (); // Resend a single failed mail final FailedMailData aFailedMailData = m_aFailedMailQueue.remove (aSelectedObject.getID ()); if (aFailedMailData != null) { final ISMTPSettings aDefaultSMTPSettings = aWPEC.hasAction (ACTION_RESEND_DEFAULT_SETTINGS) ? PhotonCoreManager.getSMTPSettingsMgr () .getDefaultSMTPSettings () : null; if (LOGGER.isInfoEnabled ()) LOGGER.info ("Trying to resend single failed mail with ID " + aFailedMailData.getID () + (aDefaultSMTPSettings != null ? " with default settings" : "") + "!"); // Main resend final ISMTPSettings aSMTPSettings = aDefaultSMTPSettings != null ? aDefaultSMTPSettings : aFailedMailData.getSMTPSettings (); ScopedMailAPI.getInstance ().queueMail (aSMTPSettings, aFailedMailData.getEmailData ()); // Success message aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.RESENT_SUCCESS.getDisplayText (aDisplayLocale))); } return EShowList.SHOW_LIST; } };
@Override @Nullable protected NamedSMTPSettings getSelectedObject (@Nonnull final WPECTYPE aWPEC, @Nullable final String sID) { return m_aMgr.getSettings (sID); }
@Nonnull public EShowList handleAction (final WPECTYPE aWPEC, final FailedMailData aSelectedObject) { final Locale aDisplayLocale = aWPEC.getDisplayLocale (); // Resend a single failed mail final FailedMailData aFailedMailData = m_aFailedMailQueue.remove (aSelectedObject.getID ()); if (aFailedMailData != null) { final ISMTPSettings aDefaultSMTPSettings = aWPEC.hasAction (ACTION_RESEND_DEFAULT_SETTINGS) ? PhotonCoreManager.getSMTPSettingsMgr () .getDefaultSMTPSettings () : null; if (LOGGER.isInfoEnabled ()) LOGGER.info ("Trying to resend single failed mail with ID " + aFailedMailData.getID () + (aDefaultSMTPSettings != null ? " with default settings" : "") + "!"); // Main resend final ISMTPSettings aSMTPSettings = aDefaultSMTPSettings != null ? aDefaultSMTPSettings : aFailedMailData.getSMTPSettings (); ScopedMailAPI.getInstance ().queueMail (aSMTPSettings, aFailedMailData.getEmailData ()); // Success message aWPEC.postRedirectGetInternal (new BootstrapSuccessBox ().addChild (EText.RESENT_SUCCESS.getDisplayText (aDisplayLocale))); } return EShowList.SHOW_LIST; } };