/** * Get the SMTP settings with the default ID. * * @return <code>null</code> if no such settings are contained. */ @Nullable public ISMTPSettings getDefaultSMTPSettings () { final NamedSMTPSettings aSettings = getDefaultSettings (); return aSettings == null ? null : aSettings.getSMTPSettings (); }
/** * 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); }
@Override public void add (@Nonnull final FailedMailData aFailedMailData) { this.add (aFailedMailData, true); }
private static boolean _canDelete (@Nullable final NamedSMTPSettings aSettings) { return aSettings != null && !aSettings.getID ().equals (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID); }
@Override @Nullable protected String getObjectDisplayName (@Nonnull final WPECTYPE aWPEC, @Nonnull final NamedSMTPSettings aSelectedObject) { return aSelectedObject.getName (); }
@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; }
public FailedMailQueueWithDAO (@Nullable final String sFilename) { try { m_aDAO = new FMQDAO (sFilename); // Read outside FMQDAO constructor, so that the DAO can be used m_aDAO.myInitialRead (); } catch (final DAOException ex) { throw new InitializationException ("Failed to init FailedMailQueueWithDAO with filename '" + sFilename + "'", ex); } }
NamedSMTPSettings (@Nonnull @Nonempty final String sID, @Nonnull @Nonempty final String sName, @Nonnull final ISMTPSettings aSMTPSettings) { ValueEnforcer.notEmpty (sID, "ID"); m_sID = sID; setName (sName); setSMTPSettings (aSMTPSettings); }
public NamedSMTPSettingsManager (@Nonnull @Nonempty final String sFilename) throws DAOException { super (sFilename); initialRead (); }
private void _markAsChanged () { m_aRWLock.writeLocked ( () -> { // Must be called in a lock m_aDAO.myMarkChanged (); }); }
/** * Initial read - just to make initialRead accessible * * @throws DAOException * In case of error */ @MustBeLocked (ELockType.WRITE) protected void myInitialRead () throws DAOException { initialRead (); }
private void writeObject (@Nonnull final ObjectOutputStream aOOS) throws IOException { aOOS.defaultWriteObject (); aOOS.writeUTF (m_aDAO.getFilenameProvider ().get ()); }
public void add (@Nonnull final FailedMailData aFailedMailData, final boolean bAudit) { super.add (aFailedMailData); _markAsChanged (); if (bAudit) AuditHelper.onAuditExecuteSuccess ("failedmail-add", aFailedMailData); }
public void registerMicroTypeConverter (@Nonnull final IMicroTypeConverterRegistry aRegistry) { aRegistry.registerMicroElementTypeConverter (NamedSMTPSettings.class, new NamedSMTPSettingsMicroTypeConverter ()); aRegistry.registerMicroElementTypeConverter (UserDataObject.class, new UserDataObjectMicroTypeConverter ()); } }
@Override @Nullable protected NamedSMTPSettings getSelectedObject (@Nonnull final WPECTYPE aWPEC, @Nullable final String sID) { return m_aMgr.getSettings (sID); }
private static boolean _canDelete (@Nullable final NamedSMTPSettings aSettings) { return aSettings != null && !aSettings.getID ().equals (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID); }
@Override @Nullable protected String getObjectDisplayName (@Nonnull final WPECTYPE aWPEC, @Nonnull final NamedSMTPSettings aSelectedObject) { return aSelectedObject.getName (); }
public void reload () throws DAOException { m_aRWLock.writeLockedThrowing ( () -> { m_aMap.clear (); initialRead (); }); }
@Override @Nullable protected NamedSMTPSettings getSelectedObject (@Nonnull final WPECTYPE aWPEC, @Nullable final String sID) { return m_aMgr.getSettings (sID); }
private void _addItem (@Nonnull final NamedSMTPSettings aNamedSMTPSettings) { final String sUserID = aNamedSMTPSettings.getID (); if (m_aMap.containsKey (sUserID)) throw new IllegalArgumentException ("NamedSMTPSettings ID " + sUserID + " is already in use!"); m_aMap.put (sUserID, aNamedSMTPSettings); }