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 {
private String name;
- private String state;
+ private CountryCode state;
private String province;
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;
}
}
- 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");
return name;
}
- public String getState() {
+ public CountryCode getState() {
return state;
}
}
}
- 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();
ps.executeUpdate();
}
name = o;
- state = c.getCountryCode();
+ state = c;
province = st;
city = l;
}