]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/dbObjects/Organisation.java
fix: correct validation of minimum and maximum ages
[gigi.git] / src / club / wpia / gigi / dbObjects / Organisation.java
index 6e48185568eee3b8bde60282dba52f68bab0aaea..7029929388a9854eb46618307def03f87bfa71d9 100644 (file)
@@ -67,7 +67,7 @@ public class Organisation extends CertificateOwner {
     private String postalAddress;
 
     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)) {
+        if ( !creator.isInGroup(Group.ORG_AGENT)) {
             throw new GigiApiException("Only Organisation RA Agents may create organisations.");
         }
         if (country == null) {
@@ -145,10 +145,13 @@ public class Organisation extends CertificateOwner {
     }
 
     public synchronized void addAdmin(User admin, User actor, boolean master) throws GigiApiException {
-        if ( !admin.canAssure()) {
+        if (actor == admin) {
+            throw new GigiApiException("You may not add yourself as Organisation Admin. Ask another Organisation Agent to do so.");
+        }
+        if ( !admin.canVerify()) {
             throw new GigiApiException("Cannot add person who is not RA Agent.");
         }
-        if ( !actor.isInGroup(Group.ORGASSURER) && !isMaster(actor)) {
+        if ( !actor.isInGroup(Group.ORG_AGENT) && !isMaster(actor)) {
             throw new GigiApiException("Only Organisation RA Agents or Organisation Administrators may add admins to an organisation.");
         }
         try (GigiPreparedStatement ps1 = new GigiPreparedStatement("SELECT 1 FROM `org_admin` WHERE `orgid`=? AND `memid`=? AND `deleted` IS NULL")) {
@@ -169,7 +172,7 @@ public class Organisation extends CertificateOwner {
     }
 
     public void removeAdmin(User admin, User actor) throws GigiApiException {
-        if ( !actor.isInGroup(Group.ORGASSURER) && !isMaster(actor)) {
+        if ( !actor.isInGroup(Group.ORG_AGENT) && !isMaster(actor)) {
             throw new GigiApiException("Only Organisation RA Agents or Organisation Administrators may delete admins from an organisation.");
         }
         try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE org_admin SET deleter=?, deleted=NOW() WHERE orgid=? AND memid=?")) {
@@ -195,7 +198,7 @@ public class Organisation extends CertificateOwner {
     }
 
     public static Organisation[] getOrganisations(int offset, int count) {
-        try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `certOwners`.`id` FROM `organisations` INNER JOIN `certOwners` ON `certOwners`.`id`=`organisations`.`id` WHERE `certOwners`.`deleted` IS NULL OFFSET ? LIMIT ?", true)) {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `certOwners`.`id` FROM `organisations` INNER JOIN `certOwners` ON `certOwners`.`id`=`organisations`.`id` WHERE `certOwners`.`deleted` IS NULL OFFSET ?::INTEGER LIMIT ?::INTEGER", true)) {
             ps.setInt(1, offset);
             ps.setInt(2, count);
             GigiResultSet res = ps.executeQuery();