Skip to content

Commit 86b1bcd

Browse files
RANGER-5104: Ranger Upgrade is failing while executing the PatchPreSql057_ForUpdateToUniqueGUID_J10052 (#511)
* RANGER-5104: Ranger Upgrade is failing while executing the PatchPreSql057_ForUpdateToUniqueGUID_J10052 * Fix typo in db_setup.py --------- Co-authored-by: Abhishek Kumar <[email protected]>
1 parent fb8d3b8 commit 86b1bcd

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

security-admin/scripts/db_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ def apply_patches(self, db_name, db_user, db_password, PATCHES_PATH):
203203
#getting Java patch which needs to be run before this DB patch.
204204
pre_dict = self.get_pre_post_java_patches(prefix_for_preSql_patch)
205205
if pre_dict:
206-
log ("[I] ruunig pre java patch:[{}]".format(pre_dict),"info")
206+
log ("[I] Running Pre Java Patch:[{}]".format(pre_dict),"info")
207207
self.execute_java_patches(xa_db_host, db_user, db_password, db_name, pre_dict)
208208
self.import_db_patches(db_name, db_user, db_password, currentPatch)
209209
#getting Java patch which needs to be run immediately after this DB patch.
210210
post_dict = self.get_pre_post_java_patches(prefix_for_postSql_patch)
211211
if post_dict:
212-
log ("[I] ruunig post java patch:[{}]".format(post_dict),"info")
212+
log ("[I] Running Post Java Patch:[{}]".format(post_dict),"info")
213213
self.execute_java_patches(xa_db_host, db_user, db_password, db_name, post_dict)
214214
self.update_applied_patches_status(db_name, db_user, db_password, "DB_PATCHES")
215215
else:

security-admin/src/main/java/org/apache/ranger/db/XXSecurityZoneDao.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,19 @@ public List<RangerSecurityZoneHeaderInfo> findAllZoneHeaderInfosByServiceId(Long
158158

159159
return securityZoneList;
160160
}
161+
162+
public List<XXSecurityZone> getAllZoneIdNames() {
163+
@SuppressWarnings("unchecked")
164+
List<Object[]> results = getEntityManager().createNamedQuery("XXSecurityZone.getAllZoneIdNames").getResultList();
165+
166+
List<XXSecurityZone> securityZoneList = new ArrayList<XXSecurityZone>(results.size());
167+
for (Object[] result : results) {
168+
XXSecurityZone xXSecurityZone = new XXSecurityZone();
169+
xXSecurityZone.setId((Long) result[0]);
170+
xXSecurityZone.setName((String) result[1]);
171+
securityZoneList.add(xXSecurityZone);
172+
}
173+
174+
return securityZoneList;
175+
}
161176
}

security-admin/src/main/java/org/apache/ranger/patch/PatchPreSql_057_ForUpdateToUniqueGUID_J10052.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void execLoad() {
106106
private void updatePolicyGUIDToUniqueValue() {
107107
logger.info("==> updatePolicyGUIDToUniqueValue() ");
108108

109-
List<XXSecurityZone> allXXZones = daoMgr.getXXSecurityZoneDao().getAll();
109+
List<XXSecurityZone> allXXZones = daoMgr.getXXSecurityZoneDao().getAllZoneIdNames();
110110
List<XXService> allXXService = daoMgr.getXXService().getAll();
111111

112112
if (CollectionUtils.isNotEmpty(allXXZones) && CollectionUtils.isNotEmpty(allXXService)) {

security-admin/src/main/resources/META-INF/jpa_named_queries.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,12 @@
17241724
</query>
17251725
</named-query>
17261726

1727+
<named-query name="XXSecurityZone.getAllZoneIdNames">
1728+
<query>
1729+
select obj.id, obj.name from XXSecurityZone obj
1730+
</query>
1731+
</named-query>
1732+
17271733
<named-query name="XXSecurityZoneRefGroup.findByZoneId">
17281734
<query>
17291735
select obj from XXSecurityZoneRefGroup obj where obj.zoneId = :zoneId

0 commit comments

Comments
 (0)