Search in sources :

Example 6 with SMPRedirect

use of com.helger.phoss.smp.domain.redirect.SMPRedirect in project phoss-smp by phax.

the class SMPRedirectManagerMongoDB method toDomain.

@Nonnull
@ReturnsMutableCopy
public static SMPRedirect toDomain(@Nonnull final IIdentifierFactory aIdentifierFactory, @Nonnull final ISMPServiceGroupManager aServiceGroupMgr, @Nonnull final Document aDoc) {
    // The ID itself is derived from ServiceGroupID and DocTypeID
    final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aIdentifierFactory.parseParticipantIdentifier(aDoc.getString(BSON_SERVICE_GROUP_ID)));
    final IDocumentTypeIdentifier aDocTypeID = toDocumentTypeID(aDoc.get(BSON_DOCTYPE_ID, Document.class));
    final X509Certificate aCert = CertificateHelper.convertStringToCertficateOrNull(aDoc.getString(BSON_TARGET_CERTIFICATE));
    return new SMPRedirect(aServiceGroup, aDocTypeID, aDoc.getString(BSON_TARGET_HREF), aDoc.getString(BSON_TARGET_SUBJECT_CN), aCert, aDoc.getString(BSON_EXTENSIONS));
}
Also used : SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) Document(org.bson.Document) X509Certificate(java.security.cert.X509Certificate) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 7 with SMPRedirect

use of com.helger.phoss.smp.domain.redirect.SMPRedirect in project phoss-smp by phax.

the class SMPRedirectManagerMongoDB method createOrUpdateSMPRedirect.

@Nonnull
public ISMPRedirect createOrUpdateSMPRedirect(@Nonnull final ISMPServiceGroup aServiceGroup, @Nonnull final IDocumentTypeIdentifier aDocumentTypeIdentifier, @Nonnull @Nonempty final String sTargetHref, @Nonnull @Nonempty final String sSubjectUniqueIdentifier, @Nullable final X509Certificate aCertificate, @Nullable final String sExtension) {
    ValueEnforcer.notNull(aServiceGroup, "ServiceGroup");
    ValueEnforcer.notNull(aDocumentTypeIdentifier, "DocumentTypeIdentifier");
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("createOrUpdateSMPRedirect (" + aServiceGroup + ", " + aDocumentTypeIdentifier + ", " + sTargetHref + ", " + sSubjectUniqueIdentifier + ", " + aCertificate + ", " + (StringHelper.hasText(sExtension) ? "with extension" : "without extension") + ")");
    final ISMPRedirect aOldRedirect = getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocumentTypeIdentifier);
    final SMPRedirect aNewRedirect = new SMPRedirect(aServiceGroup, aDocumentTypeIdentifier, sTargetHref, sSubjectUniqueIdentifier, aCertificate, sExtension);
    if (aOldRedirect == null) {
        // Create new ID
        _createSMPRedirect(aNewRedirect);
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("createOrUpdateSMPRedirect - success - created");
        m_aCallbacks.forEach(x -> x.onSMPRedirectCreated(aNewRedirect));
    } else {
        // Reuse old ID
        _updateSMPRedirect(aNewRedirect);
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("createOrUpdateSMPRedirect - success - updated");
        m_aCallbacks.forEach(x -> x.onSMPRedirectUpdated(aNewRedirect));
    }
    return aNewRedirect;
}
Also used : SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) Nonnull(javax.annotation.Nonnull)

Example 8 with SMPRedirect

use of com.helger.phoss.smp.domain.redirect.SMPRedirect in project phoss-smp by phax.

the class SMPRedirectManagerXML method deleteSMPRedirect.

@Nonnull
public EChange deleteSMPRedirect(@Nullable final ISMPRedirect aSMPRedirect) {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("deleteSMPRedirect (" + aSMPRedirect + ")");
    if (aSMPRedirect == null) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("deleteSMPRedirect - failure");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        final SMPRedirect aRealRedirect = internalDeleteItem(aSMPRedirect.getID());
        if (aRealRedirect == null) {
            AuditHelper.onAuditDeleteFailure(SMPRedirect.OT, aSMPRedirect.getID(), "no-such-id");
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("deleteSMPRedirect - failure");
            return EChange.UNCHANGED;
        }
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    m_aCallbacks.forEach(x -> x.onSMPRedirectDeleted(aSMPRedirect));
    AuditHelper.onAuditDeleteSuccess(SMPRedirect.OT, aSMPRedirect.getID(), aSMPRedirect.getServiceGroupID(), aSMPRedirect.getDocumentTypeIdentifier().getURIEncoded());
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("deleteSMPRedirect - success");
    return EChange.CHANGED;
}
Also used : SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) Nonnull(javax.annotation.Nonnull)

Example 9 with SMPRedirect

use of com.helger.phoss.smp.domain.redirect.SMPRedirect in project phoss-smp by phax.

the class SMPRedirectManagerXML method createOrUpdateSMPRedirect.

@Nonnull
public ISMPRedirect createOrUpdateSMPRedirect(@Nonnull final ISMPServiceGroup aServiceGroup, @Nonnull final IDocumentTypeIdentifier aDocumentTypeIdentifier, @Nonnull @Nonempty final String sTargetHref, @Nonnull @Nonempty final String sSubjectUniqueIdentifier, @Nullable final X509Certificate aCertificate, @Nullable final String sExtension) {
    ValueEnforcer.notNull(aServiceGroup, "ServiceGroup");
    ValueEnforcer.notNull(aDocumentTypeIdentifier, "DocumentTypeIdentifier");
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("createOrUpdateSMPRedirect (" + aServiceGroup + ", " + aDocumentTypeIdentifier + ", " + sTargetHref + ", " + sSubjectUniqueIdentifier + ", " + aCertificate + ", " + (StringHelper.hasText(sExtension) ? "with extension" : "without extension") + ")");
    final ISMPRedirect aOldRedirect = getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocumentTypeIdentifier);
    SMPRedirect aNewRedirect;
    if (aOldRedirect == null) {
        // Create new ID
        aNewRedirect = new SMPRedirect(aServiceGroup, aDocumentTypeIdentifier, sTargetHref, sSubjectUniqueIdentifier, aCertificate, sExtension);
        _createSMPRedirect(aNewRedirect);
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("createOrUpdateSMPRedirect - success - created");
        m_aCallbacks.forEach(x -> x.onSMPRedirectCreated(aNewRedirect));
    } else {
        // Reuse old ID
        aNewRedirect = new SMPRedirect(aServiceGroup, aDocumentTypeIdentifier, sTargetHref, sSubjectUniqueIdentifier, aCertificate, sExtension);
        _updateSMPRedirect(aNewRedirect);
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("createOrUpdateSMPRedirect - success - updated");
        m_aCallbacks.forEach(x -> x.onSMPRedirectUpdated(aNewRedirect));
    }
    return aNewRedirect;
}
Also used : SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) Nonnull(javax.annotation.Nonnull)

Aggregations

ISMPRedirect (com.helger.phoss.smp.domain.redirect.ISMPRedirect)9 SMPRedirect (com.helger.phoss.smp.domain.redirect.SMPRedirect)9 Nonnull (javax.annotation.Nonnull)6 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)4 X509Certificate (java.security.cert.X509Certificate)4 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)3 DBResultRow (com.helger.db.jdbc.executor.DBResultRow)3 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)2 SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)2 Nullable (javax.annotation.Nullable)2 MutableBoolean (com.helger.commons.mutable.MutableBoolean)1 ESuccess (com.helger.commons.state.ESuccess)1 Wrapper (com.helger.commons.wrapper.Wrapper)1 DBExecutor (com.helger.db.jdbc.executor.DBExecutor)1 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)1 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)1 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)1