Search in sources :

Example 1 with EntitlementCertificate

use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.

the class HandleCertificatesOp method execute.

/**
 * we can now associate and persist the certs.
 * @param context
 */
@Override
public boolean execute(BindContext context) {
    if (!context.getConsumerType().isType(ConsumerTypeEnum.SHARE)) {
        Map<String, Entitlement> ents = context.getEntitlementMap();
        for (Entitlement ent : ents.values()) {
            EntitlementCertificate cert = certs.get(ent.getPool().getId());
            ent.getCertificates().add(cert);
            cert.setEntitlement(ent);
        }
        ecCurator.saveAll(certs.values(), false, false);
        eCurator.saveOrUpdateAll(ents.values(), false, false);
        this.ecGenerator.regenerateCertificatesByEntitlementIds(modifyingEnts, true);
    }
    return true;
}
Also used : EntitlementCertificate(org.candlepin.model.EntitlementCertificate) Entitlement(org.candlepin.model.Entitlement)

Example 2 with EntitlementCertificate

use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.

the class SubscriptionReconcilerTest method createEntitlementCertificate.

protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
    EntitlementCertificate toReturn = new EntitlementCertificate();
    CertificateSerial certSerial = new CertificateSerial(new Date());
    certSerial.setCollected(true);
    certSerial.setUpdated(new Date());
    certSerial.setCreated(new Date());
    toReturn.setKeyAsBytes(key.getBytes());
    toReturn.setCertAsBytes(cert.getBytes());
    toReturn.setSerial(certSerial);
    return toReturn;
}
Also used : EntitlementCertificate(org.candlepin.model.EntitlementCertificate) CertificateSerial(org.candlepin.model.CertificateSerial) Date(java.util.Date)

Example 3 with EntitlementCertificate

use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.

the class EntitlementImporterTest method createEntitlementCertificate.

protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
    EntitlementCertificate toReturn = new EntitlementCertificate();
    CertificateSerial certSerial = new CertificateSerial(new Date());
    certSerial.setCollected(true);
    certSerial.setUpdated(new Date());
    certSerial.setCreated(new Date());
    toReturn.setKeyAsBytes(key.getBytes());
    toReturn.setCertAsBytes(cert.getBytes());
    toReturn.setSerial(certSerial);
    return toReturn;
}
Also used : EntitlementCertificate(org.candlepin.model.EntitlementCertificate) CertificateSerial(org.candlepin.model.CertificateSerial) Date(java.util.Date)

Example 4 with EntitlementCertificate

use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.

the class DatabaseTestFixture method createEntitlementCertificate.

protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
    EntitlementCertificate toReturn = new EntitlementCertificate();
    CertificateSerial certSerial = new CertificateSerial(new Date());
    certSerialCurator.create(certSerial);
    toReturn.setKeyAsBytes(key.getBytes());
    toReturn.setCertAsBytes(cert.getBytes());
    toReturn.setSerial(certSerial);
    return toReturn;
}
Also used : EntitlementCertificate(org.candlepin.model.EntitlementCertificate) CertificateSerial(org.candlepin.model.CertificateSerial) Date(java.util.Date)

Example 5 with EntitlementCertificate

use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.

the class EntitlementTranslator method populate.

/**
 * {@inheritDoc}
 */
@Override
public EntitlementDTO populate(ModelTranslator modelTranslator, Entitlement source, EntitlementDTO dest) {
    dest = super.populate(modelTranslator, source, dest);
    dest.setId(source.getId());
    dest.setQuantity(source.getQuantity());
    dest.setDeletedFromPool(source.deletedFromPool());
    dest.setStartDate(source.getStartDate());
    dest.setEndDate(source.getEndDate());
    if (modelTranslator != null) {
        Owner owner = source.getOwner();
        dest.setOwner(owner != null ? modelTranslator.translate(owner, OwnerDTO.class) : null);
        Pool pool = source.getPool();
        dest.setPool(pool != null ? modelTranslator.translate(pool, PoolDTO.class) : null);
        Consumer consumer = source.getConsumer();
        dest.setConsumer(consumer != null ? modelTranslator.translate(consumer, ConsumerDTO.class) : null);
        Set<EntitlementCertificate> certs = source.getCertificates();
        if (certs != null && !certs.isEmpty()) {
            for (Certificate cert : certs) {
                if (cert != null) {
                    dest.addCertificate(modelTranslator.translate(cert, CertificateDTO.class));
                }
            }
        } else {
            dest.setCertificates(Collections.emptySet());
        }
    }
    return dest;
}
Also used : Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) EntitlementCertificate(org.candlepin.model.EntitlementCertificate) Pool(org.candlepin.model.Pool) Certificate(org.candlepin.model.Certificate) EntitlementCertificate(org.candlepin.model.EntitlementCertificate)

Aggregations

EntitlementCertificate (org.candlepin.model.EntitlementCertificate)29 Entitlement (org.candlepin.model.Entitlement)15 Consumer (org.candlepin.model.Consumer)14 CertificateSerial (org.candlepin.model.CertificateSerial)11 Date (java.util.Date)10 HashSet (java.util.HashSet)10 Test (org.junit.Test)10 HashMap (java.util.HashMap)9 Owner (org.candlepin.model.Owner)8 Pool (org.candlepin.model.Pool)8 Product (org.candlepin.model.Product)7 Map (java.util.Map)5 Event (org.candlepin.audit.Event)4 Certificate (org.candlepin.model.Certificate)3 PoolQuantity (org.candlepin.model.PoolQuantity)3 KeyPair (java.security.KeyPair)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 CertificateDTO (org.candlepin.dto.api.v1.CertificateDTO)2