Search in sources :

Example 6 with DBResultRow

use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.

the class SMPTransportProfileManagerJDBC method getSMPTransportProfileOfID.

@Nullable
public ISMPTransportProfile getSMPTransportProfileOfID(@Nullable final String sID) {
    if (StringHelper.hasNoText(sID))
        return null;
    final Wrapper<DBResultRow> aDBResult = new Wrapper<>();
    newExecutor().querySingle("SELECT name, deprecated FROM smp_tprofile WHERE id=?", new ConstantPreparedStatementDataProvider(sID), aDBResult::set);
    if (aDBResult.isNotSet())
        return null;
    final DBResultRow aRow = aDBResult.get();
    return new SMPTransportProfile(sID, aRow.getAsString(0), aRow.getAsBoolean(1, SMPTransportProfile.DEFAULT_DEPRECATED));
}
Also used : Wrapper(com.helger.commons.wrapper.Wrapper) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) SMPTransportProfile(com.helger.peppol.smp.SMPTransportProfile) Nullable(javax.annotation.Nullable)

Example 7 with DBResultRow

use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.

the class SMPUserManagerJDBC method getAllUsers.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<DBUser> getAllUsers() {
    final ICommonsList<DBUser> ret = new CommonsArrayList<>();
    // Plaintext password....
    final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT username, password FROM smp_user");
    if (aDBResult != null)
        for (final DBResultRow aRow : aDBResult) ret.add(new DBUser(aRow.getAsString(0), aRow.getAsString(1)));
    return ret;
}
Also used : DBResultRow(com.helger.db.jdbc.executor.DBResultRow) DBUser(com.helger.phoss.smp.backend.sql.domain.DBUser) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 8 with DBResultRow

use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.

the class SMPRedirectManagerJDBC method getAllSMPRedirects.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPRedirect> getAllSMPRedirects() {
    final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT businessIdentifierScheme, businessIdentifier, documentIdentifierScheme, documentIdentifier, redirectionUrl, certificateUID, certificate, extension" + " FROM smp_service_metadata_red");
    final ICommonsList<ISMPRedirect> ret = new CommonsArrayList<>();
    if (aDBResult != null)
        for (final DBResultRow aRow : aDBResult) {
            final ISMPServiceGroup aServiceGroup = m_aServiceGroupMgr.getSMPServiceGroupOfID(new SimpleParticipantIdentifier(aRow.getAsString(0), aRow.getAsString(1)));
            final X509Certificate aCertificate = CertificateHelper.convertStringToCertficateOrNull(aRow.getAsString(6));
            ret.add(new SMPRedirect(aServiceGroup, new SimpleDocumentTypeIdentifier(aRow.getAsString(2), aRow.getAsString(3)), aRow.getAsString(4), aRow.getAsString(5), aCertificate, aRow.getAsString(7)));
        }
    return ret;
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) X509Certificate(java.security.cert.X509Certificate) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 9 with DBResultRow

use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.

the class SMPRedirectManagerJDBC method getAllSMPRedirectsOfServiceGroup.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPRedirect> getAllSMPRedirectsOfServiceGroup(@Nullable final ISMPServiceGroup aServiceGroup) {
    final ICommonsList<ISMPRedirect> ret = new CommonsArrayList<>();
    if (aServiceGroup != null) {
        final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
        final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT documentIdentifierScheme, documentIdentifier, redirectionUrl, certificateUID, certificate, extension" + " FROM smp_service_metadata_red" + " WHERE businessIdentifierScheme=? AND businessIdentifier=?", new ConstantPreparedStatementDataProvider(aParticipantID.getScheme(), aParticipantID.getValue()));
        if (aDBResult != null)
            for (final DBResultRow aRow : aDBResult) {
                final X509Certificate aCertificate = CertificateHelper.convertStringToCertficateOrNull(aRow.getAsString(4));
                ret.add(new SMPRedirect(aServiceGroup, new SimpleDocumentTypeIdentifier(aRow.getAsString(0), aRow.getAsString(1)), aRow.getAsString(2), aRow.getAsString(3), aCertificate, aRow.getAsString(5)));
            }
    }
    return ret;
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) X509Certificate(java.security.cert.X509Certificate) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 10 with DBResultRow

use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.

the class SMPServiceGroupManagerJDBC method getSMPServiceGroupOfID.

@Nullable
public SMPServiceGroup getSMPServiceGroupOfID(@Nullable final IParticipantIdentifier aParticipantID) {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("getSMPServiceGroupOfID(" + (aParticipantID == null ? "null" : aParticipantID.getURIEncoded()) + ")");
    if (aParticipantID == null)
        return null;
    // Use cache
    SMPServiceGroup ret = m_aCache == null ? null : m_aCache.get(aParticipantID.getURIEncoded());
    if (ret != null)
        return ret;
    // Not in cache
    final Wrapper<DBResultRow> aResult = new Wrapper<>();
    newExecutor().querySingle("SELECT sg.extension, so.username" + " FROM smp_service_group sg, smp_ownership so" + " WHERE sg.businessIdentifierScheme=? AND sg.businessIdentifier=?" + " AND so.businessIdentifierScheme=sg.businessIdentifierScheme AND so.businessIdentifier=sg.businessIdentifier", new ConstantPreparedStatementDataProvider(aParticipantID.getScheme(), aParticipantID.getValue()), aResult::set);
    if (aResult.isNotSet())
        return null;
    ret = new SMPServiceGroup(aResult.get().getAsString(1), aParticipantID, aResult.get().getAsString(0));
    if (m_aCache != null)
        m_aCache.put(aParticipantID.getURIEncoded(), ret);
    return ret;
}
Also used : Wrapper(com.helger.commons.wrapper.Wrapper) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) Nullable(javax.annotation.Nullable)

Aggregations

DBResultRow (com.helger.db.jdbc.executor.DBResultRow)17 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)14 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)11 Nullable (javax.annotation.Nullable)11 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)10 Nonnull (javax.annotation.Nonnull)10 Wrapper (com.helger.commons.wrapper.Wrapper)9 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)8 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)7 SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)6 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)6 ValueEnforcer (com.helger.commons.ValueEnforcer)4 ReturnsMutableObject (com.helger.commons.annotation.ReturnsMutableObject)4 CallbackList (com.helger.commons.callback.CallbackList)4 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)4 MutableBoolean (com.helger.commons.mutable.MutableBoolean)4 EChange (com.helger.commons.state.EChange)4 ESuccess (com.helger.commons.state.ESuccess)4