summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/model/Certificate.java110
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/model/Owner.java8
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/model/test/CertificateTest.java58
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/test/DatabaseTestFixture.java6
4 files changed, 181 insertions, 1 deletions
diff --git a/proxy/code/src/org/fedoraproject/candlepin/model/Certificate.java b/proxy/code/src/org/fedoraproject/candlepin/model/Certificate.java
new file mode 100644
index 0000000..2045746
--- /dev/null
+++ b/proxy/code/src/org/fedoraproject/candlepin/model/Certificate.java
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2009 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+
+package org.fedoraproject.candlepin.model;
+
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Lob;
+import javax.persistence.Id;
+import javax.persistence.Column;
+
+import org.hibernate.annotations.ForeignKey;
+
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+@Entity
+@Table(name="cp_certificate")
+public class Certificate {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long id;
+
+
+ @Lob
+ @Column(name="certificate_blob")
+ private String certificate;
+
+
+ @ManyToOne
+ @ForeignKey(name="fk_certificate_owner")
+ @JoinColumn(nullable=false)
+ private Owner owner;
+
+
+ public Certificate(String certificateIn, Owner ownerIn) {
+ certificate = certificateIn;
+ owner = ownerIn;
+ }
+
+ public Certificate() {
+ }
+
+ /**
+ * @return certficate blob
+ */
+ public String getCertificate() {
+ return certificate;
+ }
+
+ /**
+ *
+ * @param certificate
+ */
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+ /**
+ * @return the id
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the owner
+ */
+ @XmlTransient
+ public Owner getOwner() {
+ return owner;
+ }
+
+ /**
+ * @param ownerIn the owner to set
+ */
+ public void setOwner(Owner ownerIn) {
+ this.owner = ownerIn;
+ }
+
+
+}
diff --git a/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java b/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java
index 91959a5..3fe0e55 100644
--- a/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java
+++ b/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java
@@ -61,13 +61,18 @@ public class Owner {
@OneToMany(mappedBy="owner", targetEntity=User.class)
private Set<User> users;
+ @OneToMany(mappedBy="owner", targetEntity=Certificate.class)
+ private Set<Certificate> certificates;
+
+
/**
- * Default constructor.
+ * Default constructor
*/
public Owner() {
consumers = new HashSet<Consumer>();
entitlementPools = new HashSet<EntitlementPool>();
users = new HashSet<User>();
+ certificates = new HashSet<Certificate>();
}
/**
@@ -81,6 +86,7 @@ public class Owner {
consumers = new HashSet<Consumer>();
entitlementPools = new HashSet<EntitlementPool>();
users = new HashSet<User>();
+ certificates = new HashSet<Certificate>();
}
/**
diff --git a/proxy/code/src/org/fedoraproject/candlepin/model/test/CertificateTest.java b/proxy/code/src/org/fedoraproject/candlepin/model/test/CertificateTest.java
new file mode 100644
index 0000000..d0744c2
--- /dev/null
+++ b/proxy/code/src/org/fedoraproject/candlepin/model/test/CertificateTest.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2009 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+
+
+
+package org.fedoraproject.candlepin.model.test;
+
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Certificate;
+
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Before;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class CertificateTest extends DatabaseTestFixture {
+
+ @Before
+ public void setUpTestObjects() {
+
+ String ownerName = "Example Corporation";
+ Owner owner = new Owner(ownerName);
+
+ String cert = "This is not actually a certificate. No entitlements for you!";
+
+ Certificate certificate = new Certificate(cert, owner);
+ beginTransaction();
+ em.persist(owner);
+ em.persist(certificate);
+ commitTransaction();
+ }
+
+
+ @Test
+ public void testGetCertificate() {
+// Certificate newCertificate = new Certificate();
+
+ // doesn't actually do anything yet
+
+ }
+}
+
diff --git a/proxy/code/src/org/fedoraproject/candlepin/test/DatabaseTestFixture.java b/proxy/code/src/org/fedoraproject/candlepin/test/DatabaseTestFixture.java
index 79b5593..02a8506 100644
--- a/proxy/code/src/org/fedoraproject/candlepin/test/DatabaseTestFixture.java
+++ b/proxy/code/src/org/fedoraproject/candlepin/test/DatabaseTestFixture.java
@@ -5,6 +5,7 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
+import org.fedoraproject.candlepin.model.Certificate;
import org.fedoraproject.candlepin.model.Consumer;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.model.Entitlement;
@@ -96,6 +97,11 @@ public class DatabaseTestFixture {
em.remove(c);
}
+ List<Certificate> certificates = em.createQuery("from Certificate c").getResultList();
+ for (Certificate c : certificates){
+ em.remove(c);
+ }
+
commitTransaction();
em.close();
}