SEC-831: Improve support for Postges, which requires "AS" for table aliasing, together with stored procedures for sequence allocation.
This commit is contained in:
parent
e38d5dfd87
commit
371769740a
|
@ -53,7 +53,7 @@ public class JdbcAclService implements AclService {
|
||||||
//~ Static fields/initializers =====================================================================================
|
//~ Static fields/initializers =====================================================================================
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(JdbcAclService.class);
|
protected static final Log log = LogFactory.getLog(JdbcAclService.class);
|
||||||
private static final String selectAclObjectWithParent = "select obj.object_id_identity obj_id, class.class class "
|
private static final String selectAclObjectWithParent = "select obj.object_id_identity as obj_id, class.class as class "
|
||||||
+ "from acl_object_identity obj, acl_object_identity parent, acl_class class "
|
+ "from acl_object_identity obj, acl_object_identity parent, acl_class class "
|
||||||
+ "where obj.parent_object = parent.id and obj.object_id_class = class.id "
|
+ "where obj.parent_object = parent.id and obj.object_id_class = class.id "
|
||||||
+ "and parent.object_id_identity = ? and parent.object_id_class = ("
|
+ "and parent.object_id_identity = ? and parent.object_id_class = ("
|
||||||
|
|
|
@ -64,7 +64,8 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
||||||
private AclCache aclCache;
|
private AclCache aclCache;
|
||||||
private String deleteEntryByObjectIdentityForeignKey = "delete from acl_entry where acl_object_identity=?";
|
private String deleteEntryByObjectIdentityForeignKey = "delete from acl_entry where acl_object_identity=?";
|
||||||
private String deleteObjectIdentityByPrimaryKey = "delete from acl_object_identity where id=?";
|
private String deleteObjectIdentityByPrimaryKey = "delete from acl_object_identity where id=?";
|
||||||
private String identityQuery = "call identity()";
|
private String classIdentityQuery = "call identity()"; // should be overridden for postgres : select currval('acl_class_seq')
|
||||||
|
private String sidIdentityQuery = "call identity()"; // should be overridden for postgres : select currval('acl_siq_seq')
|
||||||
private String insertClass = "insert into acl_class (class) values (?)";
|
private String insertClass = "insert into acl_class (class) values (?)";
|
||||||
private String insertEntry = "insert into acl_entry "
|
private String insertEntry = "insert into acl_entry "
|
||||||
+ "(acl_object_identity, ace_order, sid, mask, granting, audit_success, audit_failure)"
|
+ "(acl_object_identity, ace_order, sid, mask, granting, audit_success, audit_failure)"
|
||||||
|
@ -176,7 +177,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
||||||
jdbcTemplate.update(insertClass, new Object[] {clazz.getName()});
|
jdbcTemplate.update(insertClass, new Object[] {clazz.getName()});
|
||||||
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(),
|
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(),
|
||||||
"Transaction must be running");
|
"Transaction must be running");
|
||||||
classId = new Long(jdbcTemplate.queryForLong(identityQuery));
|
classId = new Long(jdbcTemplate.queryForLong(classIdentityQuery));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
classId = (Long) classIds.iterator().next();
|
classId = (Long) classIds.iterator().next();
|
||||||
|
@ -221,7 +222,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
||||||
jdbcTemplate.update(insertSid, new Object[] {new Boolean(principal), sidName});
|
jdbcTemplate.update(insertSid, new Object[] {new Boolean(principal), sidName});
|
||||||
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(),
|
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(),
|
||||||
"Transaction must be running");
|
"Transaction must be running");
|
||||||
sidId = new Long(jdbcTemplate.queryForLong(identityQuery));
|
sidId = new Long(jdbcTemplate.queryForLong(sidIdentityQuery));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sidId = (Long) sidIds.iterator().next();
|
sidId = (Long) sidIds.iterator().next();
|
||||||
|
@ -380,11 +381,15 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdentityQuery(String identityQuery) {
|
public void setClassIdentityQuery(String identityQuery) {
|
||||||
Assert.hasText(identityQuery, "New identity query is required");
|
Assert.hasText(identityQuery, "New identity query is required");
|
||||||
this.identityQuery = identityQuery;
|
this.classIdentityQuery = identityQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSidIdentityQuery(String identityQuery) {
|
||||||
|
Assert.hasText(identityQuery, "New identity query is required");
|
||||||
|
this.sidIdentityQuery = identityQuery;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param foreignKeysInDatabase if false this class will perform additional FK constrain checking, which may
|
* @param foreignKeysInDatabase if false this class will perform additional FK constrain checking, which may
|
||||||
* cause deadlocks (the default is true, so deadlocks are avoided but the database is expected to enforce FKs)
|
* cause deadlocks (the default is true, so deadlocks are avoided but the database is expected to enforce FKs)
|
||||||
|
|
Loading…
Reference in New Issue