Search in sources :

Example 1 with SMLConfiguration

use of com.helger.peppol.domain.SMLConfiguration in project peppol-practical by phax.

the class SMLConfigurationManager method updateSMLInfo.

@Nonnull
public EChange updateSMLInfo(@Nullable final String sSMLInfoID, @Nonnull @Nonempty final String sDisplayName, @Nonnull @Nonempty final String sDNSZone, @Nonnull @Nonempty final String sManagementServiceURL, final boolean bClientCertificateRequired, @Nonnull final ESMPAPIType eSMPAPIType, @Nonnull final ESMPIdentifierType eSMPIdentifierType, final boolean bProduction) {
    final SMLConfiguration aExtSMLInfo = getOfID(sSMLInfoID);
    if (aExtSMLInfo == null) {
        AuditHelper.onAuditModifyFailure(SMLInfo.OT, "all", sSMLInfoID, "no-such-id");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        final SMLInfo aSMLInfo = aExtSMLInfo.getSMLInfo();
        EChange eChange = EChange.UNCHANGED;
        eChange = eChange.or(aSMLInfo.setDisplayName(sDisplayName));
        eChange = eChange.or(aSMLInfo.setDNSZone(sDNSZone));
        eChange = eChange.or(aSMLInfo.setManagementServiceURL(sManagementServiceURL));
        eChange = eChange.or(aSMLInfo.setClientCertificateRequired(bClientCertificateRequired));
        eChange = eChange.or(aExtSMLInfo.setSMPAPIType(eSMPAPIType));
        eChange = eChange.or(aExtSMLInfo.setSMPIdentifierType(eSMPIdentifierType));
        eChange = eChange.or(aExtSMLInfo.setProduction(bProduction));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        internalUpdateItem(aExtSMLInfo);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(SMLInfo.OT, "all", sSMLInfoID, sDisplayName, sDNSZone, sManagementServiceURL, Boolean.valueOf(bClientCertificateRequired), eSMPAPIType, eSMPIdentifierType, Boolean.valueOf(bProduction));
    return EChange.CHANGED;
}
Also used : SMLConfiguration(com.helger.peppol.domain.SMLConfiguration) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) SMLInfo(com.helger.peppol.sml.SMLInfo) EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 2 with SMLConfiguration

use of com.helger.peppol.domain.SMLConfiguration in project peppol-practical by phax.

the class SMLConfigurationManager method createSMLInfo.

@Nonnull
public ISMLConfiguration createSMLInfo(@Nonnull @Nonempty final String sSMLInfoID, @Nonnull @Nonempty final String sDisplayName, @Nonnull @Nonempty final String sDNSZone, @Nonnull @Nonempty final String sManagementServiceURL, final boolean bClientCertificateRequired, @Nonnull final ESMPAPIType eSMPAPIType, @Nonnull final ESMPIdentifierType eSMPIdentifierType, final boolean bProduction) {
    final SMLInfo aSMLInfo = new SMLInfo(sSMLInfoID, sDisplayName, sDNSZone, sManagementServiceURL, bClientCertificateRequired);
    final SMLConfiguration aExtSMLInfo = new SMLConfiguration(aSMLInfo, eSMPAPIType, eSMPIdentifierType, bProduction);
    m_aRWLock.writeLocked(() -> {
        internalCreateItem(aExtSMLInfo);
    });
    AuditHelper.onAuditCreateSuccess(SMLInfo.OT, sSMLInfoID, sDisplayName, sDNSZone, sManagementServiceURL, Boolean.valueOf(bClientCertificateRequired), eSMPAPIType, eSMPIdentifierType, Boolean.valueOf(bProduction));
    return aExtSMLInfo;
}
Also used : SMLConfiguration(com.helger.peppol.domain.SMLConfiguration) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) SMLInfo(com.helger.peppol.sml.SMLInfo) Nonnull(javax.annotation.Nonnull)

Example 3 with SMLConfiguration

use of com.helger.peppol.domain.SMLConfiguration in project peppol-practical by phax.

the class SMLConfigurationManager method removeSMLInfo.

@Nullable
public EChange removeSMLInfo(@Nullable final String sSMLInfoID) {
    if (StringHelper.hasNoText(sSMLInfoID))
        return EChange.UNCHANGED;
    m_aRWLock.writeLock().lock();
    try {
        final SMLConfiguration aExtSMLInfo = internalDeleteItem(sSMLInfoID);
        if (aExtSMLInfo == null) {
            AuditHelper.onAuditDeleteFailure(SMLInfo.OT, "no-such-id", sSMLInfoID);
            return EChange.UNCHANGED;
        }
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditDeleteSuccess(SMLInfo.OT, sSMLInfoID);
    return EChange.CHANGED;
}
Also used : SMLConfiguration(com.helger.peppol.domain.SMLConfiguration) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) Nullable(javax.annotation.Nullable)

Aggregations

ISMLConfiguration (com.helger.peppol.domain.ISMLConfiguration)3 SMLConfiguration (com.helger.peppol.domain.SMLConfiguration)3 SMLInfo (com.helger.peppol.sml.SMLInfo)2 Nonnull (javax.annotation.Nonnull)2 EChange (com.helger.commons.state.EChange)1 Nullable (javax.annotation.Nullable)1