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));
}
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;
}
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;
}
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;
}
Aggregations