X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FOrganisation.java;h=9c57049a969ed4a2e18045183bc92cefaeb1b75d;hp=526bf303c710f1785f70f044b4ae9d947ba3cefc;hb=a1618d15f672d5ced82d6f4f6f06d2f58412fd1f;hpb=dea55fb19948e7fa05e4b9369873e96360a5064a diff --git a/src/org/cacert/gigi/dbObjects/Organisation.java b/src/org/cacert/gigi/dbObjects/Organisation.java index 526bf303..9c57049a 100644 --- a/src/org/cacert/gigi/dbObjects/Organisation.java +++ b/src/org/cacert/gigi/dbObjects/Organisation.java @@ -10,7 +10,7 @@ import org.cacert.gigi.GigiApiException; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.database.GigiResultSet; import org.cacert.gigi.dbObjects.Certificate.CertificateStatus; -import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType; +import org.cacert.gigi.dbObjects.Country.CountryCodeType; import org.cacert.gigi.dbObjects.wrappers.DataContainer; public class Organisation extends CertificateOwner { @@ -54,7 +54,7 @@ public class Organisation extends CertificateOwner { private String name; - private CountryCode state; + private Country country; private String province; @@ -66,15 +66,15 @@ public class Organisation extends CertificateOwner { private String postalAddress; - public Organisation(String name, CountryCode state, String province, String city, String email, String optionalName, String postalAddress, User creator) throws GigiApiException { + public Organisation(String name, Country country, String province, String city, String email, String optionalName, String postalAddress, User creator) throws GigiApiException { if ( !creator.isInGroup(Group.ORGASSURER)) { throw new GigiApiException("Only Organisation RA Agents may create organisations."); } - if (state == null || state.getCountryCodeType() != CountryCodeType.CODE_2_CHARS) { + if (country == null) { throw new GigiApiException("Got country code of illegal type."); } this.name = name; - this.state = state; + this.country = country; this.province = province; this.city = city; this.email = email; @@ -84,7 +84,7 @@ public class Organisation extends CertificateOwner { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO organisations SET id=?, name=?, state=?, province=?, city=?, contactEmail=?, optional_name=?, postal_address=?, creator=?")) { ps.setInt(1, id); ps.setString(2, name); - ps.setString(3, state.getCountryCode()); + ps.setString(3, country.getCode()); ps.setString(4, province); ps.setString(5, city); ps.setString(6, email); @@ -100,7 +100,7 @@ public class Organisation extends CertificateOwner { protected Organisation(GigiResultSet rs) throws GigiApiException { super(rs.getInt("id")); name = rs.getString("name"); - state = CountryCode.getCountryCode(rs.getString("state"), CountryCodeType.CODE_2_CHARS); + country = Country.getCountryByCode(rs.getString("state"), CountryCodeType.CODE_2_CHARS); province = rs.getString("province"); city = rs.getString("city"); email = rs.getString("contactEmail"); @@ -112,8 +112,8 @@ public class Organisation extends CertificateOwner { return name; } - public CountryCode getState() { - return state; + public Country getState() { + return country; } public String getProvince() { @@ -210,8 +210,8 @@ public class Organisation extends CertificateOwner { } } - public void updateCertData(String o, CountryCode c, String st, String l) throws GigiApiException { - if (c == null || c.getCountryCodeType() != CountryCodeType.CODE_2_CHARS) { + public void updateCertData(String o, Country c, String st, String l) throws GigiApiException { + if (c == null) { throw new GigiApiException("Got country code of illegal type."); } for (Certificate cert : getCertificates(false)) { @@ -221,14 +221,14 @@ public class Organisation extends CertificateOwner { } try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `organisations` SET `name`=?, `state`=?, `province`=?, `city`=? WHERE `id`=?")) { ps.setString(1, o); - ps.setString(2, c.getCountryCode()); + ps.setString(2, c.getCode()); ps.setString(3, st); ps.setString(4, l); ps.setInt(5, getId()); ps.executeUpdate(); } name = o; - state = c; + country = c; province = st; city = l; }