X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FOrganisation.java;h=526bf303c710f1785f70f044b4ae9d947ba3cefc;hp=bbb3214c84ad2408b690cdf9b41d2eab43c83863;hb=dea55fb19948e7fa05e4b9369873e96360a5064a;hpb=d3f2bc843552d3011a341555776fc7a77905ab55 diff --git a/src/org/cacert/gigi/dbObjects/Organisation.java b/src/org/cacert/gigi/dbObjects/Organisation.java index bbb3214c..526bf303 100644 --- a/src/org/cacert/gigi/dbObjects/Organisation.java +++ b/src/org/cacert/gigi/dbObjects/Organisation.java @@ -10,6 +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.wrappers.DataContainer; public class Organisation extends CertificateOwner { @@ -53,7 +54,7 @@ public class Organisation extends CertificateOwner { private String name; - private String state; + private CountryCode state; private String province; @@ -69,8 +70,11 @@ public class Organisation extends CertificateOwner { if ( !creator.isInGroup(Group.ORGASSURER)) { throw new GigiApiException("Only Organisation RA Agents may create organisations."); } + if (state == null || state.getCountryCodeType() != CountryCodeType.CODE_2_CHARS) { + throw new GigiApiException("Got country code of illegal type."); + } this.name = name; - this.state = state.getCountryCode(); + this.state = state; this.province = province; this.city = city; this.email = email; @@ -93,10 +97,10 @@ public class Organisation extends CertificateOwner { } } - protected Organisation(GigiResultSet rs) { + protected Organisation(GigiResultSet rs) throws GigiApiException { super(rs.getInt("id")); name = rs.getString("name"); - state = rs.getString("state"); + state = CountryCode.getCountryCode(rs.getString("state"), CountryCodeType.CODE_2_CHARS); province = rs.getString("province"); city = rs.getString("city"); email = rs.getString("contactEmail"); @@ -108,7 +112,7 @@ public class Organisation extends CertificateOwner { return name; } - public String getState() { + public CountryCode getState() { return state; } @@ -206,7 +210,10 @@ public class Organisation extends CertificateOwner { } } - public void updateCertData(String o, CountryCode c, String st, String l) { + public void updateCertData(String o, CountryCode c, String st, String l) throws GigiApiException { + if (c == null || c.getCountryCodeType() != CountryCodeType.CODE_2_CHARS) { + throw new GigiApiException("Got country code of illegal type."); + } for (Certificate cert : getCertificates(false)) { if (cert.getStatus() == CertificateStatus.ISSUED) { cert.revoke(); @@ -221,7 +228,7 @@ public class Organisation extends CertificateOwner { ps.executeUpdate(); } name = o; - state = c.getCountryCode(); + state = c; province = st; city = l; }