Repository: incubator-ranger Updated Branches: refs/heads/master 08a94c741 -> 01326be73
RANGER-1199: Optimize tag-download to include only tags that have policies Signed-off-by: Madhan Neethiraj <mad...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/01326be7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/01326be7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/01326be7 Branch: refs/heads/master Commit: 01326be73368a0700dce2c13e1850d620112780c Parents: 08a94c7 Author: Abhay Kulkarni <akulka...@hortonworks.com> Authored: Wed Oct 26 17:28:12 2016 -0700 Committer: Madhan Neethiraj <mad...@apache.org> Committed: Tue Nov 1 21:34:40 2016 -0700 ---------------------------------------------------------------------- .../apache/ranger/biz/RangerTagDBRetriever.java | 18 ++-- .../org/apache/ranger/biz/ServiceDBStore.java | 36 +++++--- .../apache/ranger/db/XXServiceResourceDao.java | 4 +- .../ranger/db/XXServiceResourceElementDao.java | 4 +- .../db/XXServiceResourceElementValueDao.java | 4 +- .../org/apache/ranger/db/XXTagAttributeDao.java | 4 +- .../apache/ranger/db/XXTagAttributeDefDao.java | 12 +++ .../java/org/apache/ranger/db/XXTagDao.java | 13 +++ .../java/org/apache/ranger/db/XXTagDefDao.java | 13 +++ .../apache/ranger/db/XXTagResourceMapDao.java | 12 +++ .../service/RangerServiceResourceService.java | 2 +- .../resources/META-INF/jpa_named_queries.xml | 94 +++++++++++++++++++- 12 files changed, 183 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/biz/RangerTagDBRetriever.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/RangerTagDBRetriever.java b/security-admin/src/main/java/org/apache/ranger/biz/RangerTagDBRetriever.java index 0949092..04c27a7 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/RangerTagDBRetriever.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/RangerTagDBRetriever.java @@ -96,7 +96,7 @@ public class RangerTagDBRetriever { private List<RangerTagResourceMap> getAllTagResourceMaps() { - List<XXTagResourceMap> xTagResourceMaps = daoMgr.getXXTagResourceMap().findByServiceId(xService.getId()); + List<XXTagResourceMap> xTagResourceMaps = daoMgr.getXXTagResourceMap().findForServicePlugin(xService.getId()); ListIterator<XXTagResourceMap> iterTagResourceMap = xTagResourceMaps.listIterator(); List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>(); @@ -203,9 +203,9 @@ public class RangerTagDBRetriever { TagRetrieverServiceResourceContext(XXService xService) { Long serviceId = xService == null ? null : xService.getId(); - List<XXServiceResource> xServiceResources = daoMgr.getXXServiceResource().findTaggedResourcesInServiceId(serviceId); - List<XXServiceResourceElement> xServiceResourceElements = daoMgr.getXXServiceResourceElement().findForTaggedResourcesInServiceId(serviceId); - List<XXServiceResourceElementValue> xServiceResourceElementValues = daoMgr.getXXServiceResourceElementValue().findForTaggedResourcesInServiceId(serviceId); + List<XXServiceResource> xServiceResources = daoMgr.getXXServiceResource().findForServicePlugin(serviceId); + List<XXServiceResourceElement> xServiceResourceElements = daoMgr.getXXServiceResourceElement().findForServicePlugin(serviceId); + List<XXServiceResourceElementValue> xServiceResourceElementValues = daoMgr.getXXServiceResourceElementValue().findForServicePlugin(serviceId); this.service = xService; this.iterServiceResource = xServiceResources.listIterator(); @@ -318,7 +318,7 @@ public class RangerTagDBRetriever { List<RangerServiceResource> ret = null; if (service != null) { - List<XXServiceResource> xServiceResources = daoMgr.getXXServiceResource().findTaggedResourcesInServiceId(service.getId()); + List<XXServiceResource> xServiceResources = daoMgr.getXXServiceResource().findForServicePlugin(service.getId()); if (CollectionUtils.isNotEmpty(xServiceResources)) { ret = new ArrayList<RangerServiceResource>(xServiceResources.size()); @@ -348,8 +348,8 @@ public class RangerTagDBRetriever { TagRetrieverTagDefContext(XXService xService) { Long serviceId = xService == null ? null : xService.getId(); - List<XXTagDef> xTagDefs = daoMgr.getXXTagDef().findByServiceId(serviceId); - List<XXTagAttributeDef> xTagAttributeDefs = daoMgr.getXXTagAttributeDef().findByServiceId(serviceId); + List<XXTagDef> xTagDefs = daoMgr.getXXTagDef().findForServicePlugin(serviceId); + List<XXTagAttributeDef> xTagAttributeDefs = daoMgr.getXXTagAttributeDef().findForServicePlugin(serviceId); this.service = xService; this.iterTagDef = xTagDefs.listIterator(); @@ -473,8 +473,8 @@ public class RangerTagDBRetriever { TagRetrieverTagContext(XXService xService) { Long serviceId = xService == null ? null : xService.getId(); - List<XXTag> xTags = daoMgr.getXXTag().findByServiceId(serviceId); - List<XXTagAttribute> xTagAttributes = daoMgr.getXXTagAttribute().findByServiceId(serviceId); + List<XXTag> xTags = daoMgr.getXXTag().findForServicePlugin(serviceId); + List<XXTagAttribute> xTagAttributes = daoMgr.getXXTagAttribute().findForServicePlugin(serviceId); this.service = xService; this.iterTag = xTags.listIterator(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java index d709869..b6b2dc5 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java @@ -34,11 +34,9 @@ import java.util.Map.Entry; import java.util.StringTokenizer; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.text.SimpleDateFormat; import java.util.TreeMap; @@ -1515,7 +1513,7 @@ public class ServiceDBStore extends AbstractServiceStore { service = svcService.update(service); if (hasTagServiceValueChanged || hasIsEnabledChanged) { - updatePolicyVersion(service); + updatePolicyVersion(service, false); } } @@ -1786,7 +1784,7 @@ public class ServiceDBStore extends AbstractServiceStore { createNewPolicyItemsForPolicy(policy, xCreatedPolicy, denyExceptions, xServiceDef, RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_DENY_EXCEPTIONS); createNewDataMaskPolicyItemsForPolicy(policy, xCreatedPolicy, dataMaskItems, xServiceDef, RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_DATAMASK); createNewRowFilterPolicyItemsForPolicy(policy, xCreatedPolicy, rowFilterItems, xServiceDef, RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_ROWFILTER); - handlePolicyUpdate(service); + handlePolicyUpdate(service, true); RangerPolicy createdPolicy = policyService.getPopulatedViewObject(xCreatedPolicy); dataHistService.createObjectDataHistory(createdPolicy, RangerDataHistService.ACTION_CREATE); @@ -1846,9 +1844,14 @@ public class ServiceDBStore extends AbstractServiceStore { policy.setVersion(xxExisting.getVersion()); List<XXTrxLog> trxLogList = policyService.getTransactionLog(policy, xxExisting, RangerPolicyService.OPERATION_UPDATE_CONTEXT); - + updatePolicySignature(policy); - + + boolean isTagVersionUpdateNeeded = false; + if (service.getType().equals(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_TAG_NAME)) { + isTagVersionUpdateNeeded = existing.getIsEnabled() ? !policy.getIsEnabled() : policy.getIsEnabled(); + isTagVersionUpdateNeeded = isTagVersionUpdateNeeded || !StringUtils.equals(existing.getResourceSignature(), policy.getResourceSignature()); + } policy = policyService.update(policy); XXPolicy newUpdPolicy = daoMgr.getXXPolicy().getById(policy.getId()); @@ -1863,7 +1866,7 @@ public class ServiceDBStore extends AbstractServiceStore { createNewDataMaskPolicyItemsForPolicy(policy, newUpdPolicy, dataMaskPolicyItems, xServiceDef, RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_DATAMASK); createNewRowFilterPolicyItemsForPolicy(policy, newUpdPolicy, rowFilterItems, xServiceDef, RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_ROWFILTER); - handlePolicyUpdate(service); + handlePolicyUpdate(service, isTagVersionUpdateNeeded); RangerPolicy updPolicy = policyService.getPopulatedViewObject(newUpdPolicy); dataHistService.createObjectDataHistory(updPolicy, RangerDataHistService.ACTION_UPDATE); @@ -1907,7 +1910,7 @@ public class ServiceDBStore extends AbstractServiceStore { deleteExistingPolicyResources(policy); policyService.delete(policy); - handlePolicyUpdate(service); + handlePolicyUpdate(service, true); dataHistService.createObjectDataHistory(policy, RangerDataHistService.ACTION_DELETE); @@ -2690,11 +2693,11 @@ public class ServiceDBStore extends AbstractServiceStore { return validConfigs; } - private void handlePolicyUpdate(RangerService service) throws Exception { - updatePolicyVersion(service); + private void handlePolicyUpdate(RangerService service, boolean isTagVersionUpdateNeeded) throws Exception { + updatePolicyVersion(service, isTagVersionUpdateNeeded); } - private void updatePolicyVersion(RangerService service) throws Exception { + private void updatePolicyVersion(RangerService service, boolean isTagVersionUpdateNeeded) throws Exception { if(service == null || service.getId() == null) { return; } @@ -2739,20 +2742,27 @@ public class ServiceDBStore extends AbstractServiceStore { if(CollectionUtils.isNotEmpty(referringServices)) { for(XXService referringService : referringServices) { - serviceVersionInfoDbObj = serviceVersionInfoDao.findByServiceId(referringService.getId()); if (serviceVersionInfoDbObj != null) { serviceVersionInfoDbObj.setPolicyVersion(getNextVersion(serviceVersionInfoDbObj.getPolicyVersion())); serviceVersionInfoDbObj.setPolicyUpdateTime(service.getPolicyUpdateTime()); + if (isTagVersionUpdateNeeded) { + serviceVersionInfoDbObj.setTagVersion(getNextVersion(serviceVersionInfoDbObj.getTagVersion())); + serviceVersionInfoDbObj.setTagUpdateTime(service.getTagUpdateTime()); + } serviceVersionInfoDao.update(serviceVersionInfoDbObj); } else { LOG.warn("updatePolicyVersion(service=" + referringService.getName() + "): serviceVersionInfo not found, creating it.."); serviceVersionInfoDbObj = new XXServiceVersionInfo(); serviceVersionInfoDbObj.setServiceId(referringService.getId()); serviceVersionInfoDbObj.setPolicyVersion(getNextVersion(referringService.getPolicyVersion())); - serviceVersionInfoDbObj.setTagVersion(referringService.getTagVersion()); + if (isTagVersionUpdateNeeded) { + serviceVersionInfoDbObj.setTagVersion(getNextVersion(referringService.getTagVersion())); + } else { + serviceVersionInfoDbObj.setTagVersion(referringService.getTagVersion()); + } serviceVersionInfoDbObj.setPolicyUpdateTime(new Date()); serviceVersionInfoDbObj.setTagUpdateTime(referringService.getTagUpdateTime()); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceDao.java index 71bbfab..ef90a45 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceDao.java @@ -72,12 +72,12 @@ public class XXServiceResourceDao extends BaseDao<XXServiceResource> { } } - public List<XXServiceResource> findTaggedResourcesInServiceId(Long serviceId) { + public List<XXServiceResource> findForServicePlugin(Long serviceId) { if (serviceId == null) { return new ArrayList<XXServiceResource>(); } try { - return getEntityManager().createNamedQuery("XXServiceResource.findTaggedResourcesInServiceId", tClass) + return getEntityManager().createNamedQuery("XXServiceResource.findForServicePlugin", tClass) .setParameter("serviceId", serviceId).getResultList(); } catch (NoResultException e) { return new ArrayList<XXServiceResource>(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementDao.java index 240eb62..4f958ea 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementDao.java @@ -59,12 +59,12 @@ public class XXServiceResourceElementDao extends BaseDao<XXServiceResourceElemen } } - public List<XXServiceResourceElement> findForTaggedResourcesInServiceId(Long serviceId) { + public List<XXServiceResourceElement> findForServicePlugin(Long serviceId) { if (serviceId == null) { return new ArrayList<XXServiceResourceElement>(); } try { - return getEntityManager().createNamedQuery("XXServiceResourceElement.findForTaggedResourcesInServiceId", tClass) + return getEntityManager().createNamedQuery("XXServiceResourceElement.findForServicePlugin", tClass) .setParameter("serviceId", serviceId) .getResultList(); } catch (NoResultException e) { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementValueDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementValueDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementValueDao.java index d324331..e780bc1 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementValueDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceResourceElementValueDao.java @@ -72,12 +72,12 @@ public class XXServiceResourceElementValueDao extends BaseDao<XXServiceResourceE } @SuppressWarnings("unchecked") - public List<XXServiceResourceElementValue> findForTaggedResourcesInServiceId(Long serviceId) { + public List<XXServiceResourceElementValue> findForServicePlugin(Long serviceId) { if (serviceId == null) { return new ArrayList<XXServiceResourceElementValue>(); } try { - return getEntityManager().createNamedQuery("XXServiceResourceElementValue.findForTaggedResourcesInServiceId") + return getEntityManager().createNamedQuery("XXServiceResourceElementValue.findForServicePlugin") .setParameter("serviceId", serviceId).getResultList(); } catch (NoResultException e) { return new ArrayList<XXServiceResourceElementValue>(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java index a24e3db..a5b7fac 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java @@ -45,12 +45,12 @@ public class XXTagAttributeDao extends BaseDao<XXTagAttribute> { } } - public List<XXTagAttribute> findByServiceId(Long serviceId) { + public List<XXTagAttribute> findForServicePlugin(Long serviceId) { if (serviceId == null) { return new ArrayList<XXTagAttribute>(); } try { - return getEntityManager().createNamedQuery("XXTagAttribute.findByServiceId", tClass) + return getEntityManager().createNamedQuery("XXTagAttribute.findForServicePlugin", tClass) .setParameter("serviceId", serviceId).getResultList(); } catch (NoResultException e) { return new ArrayList<XXTagAttribute>(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java index 294c222..145399f 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java @@ -57,6 +57,18 @@ public class XXTagAttributeDefDao extends BaseDao<XXTagAttributeDef> { } } + public List<XXTagAttributeDef> findForServicePlugin(Long serviceId) { + if (serviceId == null) { + return new ArrayList<XXTagAttributeDef>(); + } + try { + return getEntityManager().createNamedQuery("XXTagAttributeDef.findForServicePlugin", tClass) + .setParameter("serviceId", serviceId).getResultList(); + } catch (NoResultException e) { + return new ArrayList<XXTagAttributeDef>(); + } + } + public List<XXTagAttributeDef> findByResourceId(Long resourceId) { if (resourceId == null) { return new ArrayList<XXTagAttributeDef>(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java index 199a155..77428db 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java @@ -124,6 +124,19 @@ public class XXTagDao extends BaseDao<XXTag> { } } + public List<XXTag> findForServicePlugin(Long serviceId) { + if (serviceId == null) { + return new ArrayList<XXTag>(); + } + + try { + return getEntityManager().createNamedQuery("XXTag.findForServicePlugin", tClass) + .setParameter("serviceId", serviceId).getResultList(); + } catch (NoResultException e) { + return new ArrayList<XXTag>(); + } + } + public List<XXTag> findByServiceIdAndOwner(Long serviceId, Short owner) { if (serviceId == null) { return new ArrayList<XXTag>(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java index 86793ec..dfd2fcb 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java @@ -73,6 +73,19 @@ public class XXTagDefDao extends BaseDao<XXTagDef> { } } + public List<XXTagDef> findForServicePlugin(Long serviceId) { + if (serviceId == null) { + return new ArrayList<XXTagDef>(); + } + + try { + return getEntityManager().createNamedQuery("XXTagDef.findForServicePlugin", tClass) + .setParameter("serviceId", serviceId).getResultList(); + } catch (NoResultException e) { + return new ArrayList<XXTagDef>(); + } + } + public List<String> getAllNames() { try { return getEntityManager().createNamedQuery("XXTagDef.getAllNames", String.class).getResultList(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java index 40dbe86..bbcd546 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java @@ -140,4 +140,16 @@ public class XXTagResourceMapDao extends BaseDao<XXTagResourceMap> { return new ArrayList<XXTagResourceMap>(); } } + + public List<XXTagResourceMap> findForServicePlugin(Long serviceId) { + if (serviceId == null) { + return new ArrayList<XXTagResourceMap>(); + } + try { + return getEntityManager().createNamedQuery("XXTagResourceMap.findForServicePlugin", tClass) + .setParameter("serviceId", serviceId).getResultList(); + } catch (NoResultException e) { + return new ArrayList<XXTagResourceMap>(); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java index e5937e6..d725680 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java @@ -116,7 +116,7 @@ public class RangerServiceResourceService extends RangerServiceResourceServiceBa public List<RangerServiceResource> getTaggedResourcesInServiceId(Long serviceId) { List<RangerServiceResource> ret = new ArrayList<RangerServiceResource>(); - List<XXServiceResource> xxServiceResources = daoMgr.getXXServiceResource().findTaggedResourcesInServiceId(serviceId); + List<XXServiceResource> xxServiceResources = daoMgr.getXXServiceResource().findByServiceId(serviceId); if(CollectionUtils.isNotEmpty(xxServiceResources)) { for(XXServiceResource xxServiceResource : xxServiceResources) { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/01326be7/security-admin/src/main/resources/META-INF/jpa_named_queries.xml ---------------------------------------------------------------------- diff --git a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml index 4fcf0ea..a94b9a0 100644 --- a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml +++ b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml @@ -781,6 +781,20 @@ </query> </named-query> + <named-query name="XXServiceResourceElement.findForServicePlugin"> + <query> + select obj from XXServiceResourceElement obj where obj.resourceId in + (select serviceRes.id from XXServiceResource serviceRes, XXService service where service.id = :serviceId and service.tagService is not null and serviceRes.serviceId = service.id and serviceRes.id in + (select tagResMap.resourceId from XXTagResourceMap tagResMap, XXTag tag, XXTagDef tagDef + where tagResMap.tagId = tag.id and tag.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + ) + order by obj.resourceId, obj.id + </query> + </named-query> + <named-query name="XXServiceResourceElement.findByServiceId"> <query>select obj from XXServiceResourceElement obj where obj.resourceId in (select serviceresource.id from XXServiceResource serviceresource where serviceresource.serviceId = :serviceId) @@ -805,6 +819,20 @@ </query> </named-query> + <named-query name="XXServiceResourceElementValue.findForServicePlugin"> + <query> + select obj from XXServiceResourceElementValue obj, XXServiceResourceElement serviceResElem where obj.resElementId = serviceResElem.id and + serviceResElem.resourceId in + (select serviceRes.id from XXServiceResource serviceRes, XXService service where service.id = :serviceId and service.tagService is not null and serviceRes.serviceId = service.id and serviceRes.id in + (select tagResMap.resourceId from XXTagResourceMap tagResMap, XXTag tag, XXTagDef tagDef + where tagResMap.tagId = tag.id and tag.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + ) + order by serviceResElem.resourceId, serviceResElem.id + </query> + </named-query> <named-query name="XXServiceResourceElementValue.findByServiceId"> <query>select obj from XXServiceResourceElementValue obj, XXServiceResourceElement resElem where obj.resElementId = resElem.id and resElem.resourceId in (select res.id from XXServiceResource res where res.serviceId = :serviceId) @@ -852,6 +880,17 @@ order by obj.resourceId</query> </named-query> + <named-query name="XXTagResourceMap.findForServicePlugin"> + <query> + select obj from XXTagResourceMap obj, XXService service where service.id = :serviceId and service.tagService is not null and obj.tagId in + (select tag.id from XXTag tag, XXTagDef tagDef where tag.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + order by obj.resourceId + </query> + </named-query> + <named-query name="XXTagResourceMap.getTagIdsForResourceId"> <query>select obj.tagId from XXTagResourceMap obj where obj.resourceId = :resourceId order by obj.id @@ -873,6 +912,14 @@ </query> </named-query> + <named-query name="XXTagDef.findForServicePlugin"> + <query>select obj from XXTagDef obj, XXService service where service.id = :serviceId and service.tagService is not null and + obj.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + order by obj.id + </query> + </named-query> <named-query name="XXTagDef.findByResourceId"> <query>select obj from XXTagDef obj where obj.id in (select tag.type from XXTag tag, XXTagResourceMap tagRes where tag.id = tagRes.tagId and tagRes.resourceId = :resourceId) @@ -894,7 +941,16 @@ order by obj.tagDefId </query> </named-query> - + <named-query name="XXTagAttributeDef.findForServicePlugin"> + <query>select obj from XXTagAttributeDef obj where obj.tagDefId in + (select tagDef.id from XXTagDef tagDef, XXService service where service.id = :serviceId and service.tagService is not null and + tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + order by obj.tagDefId + </query> + </named-query> <named-query name="XXTagAttributeDef.findByResourceId"> <query>select obj from XXTagAttributeDef obj where obj.tagDefId in (select tag.type from XXTag tag, XXTagResourceMap tagRes where tag.id = tagRes.tagId and tagRes.resourceId = :resourceId) @@ -930,6 +986,16 @@ </query> </named-query> + <named-query name="XXTag.findForServicePlugin"> + <query> + select obj from XXTag obj, XXTagDef tagDef, XXService service where service.id = :serviceId and service.tagService is not null and + obj.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + order by obj.id + </query> + </named-query> + <named-query name="XXTag.findByServiceIdAndOwner"> <query>select obj from XXTag obj where obj.owner = :owner and obj.id in (select tagRes.tagId from XXTagResourceMap tagRes, XXServiceResource resource where tagRes.resourceId = resource.id and resource.serviceId = :serviceId) @@ -964,6 +1030,18 @@ </query> </named-query> + <named-query name="XXTagAttribute.findForServicePlugin"> + <query> + select obj from XXTagAttribute obj where obj.tagId in + (select tag.id from XXTag tag, XXTagDef tagDef, XXService service where service.id = :serviceId and service.tagService is not null and + tag.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + order by obj.tagId + </query> + </named-query> + <named-query name="XXServiceResource.findByGuid"> <query>select obj from XXServiceResource obj where obj.guid = :guid</query> </named-query> @@ -973,7 +1051,7 @@ order by obj.id </query> </named-query> - + <named-query name="XXServiceResource.findTaggedResourcesInServiceId"> <query>select obj from XXServiceResource obj where obj.serviceId = :serviceId and obj.id in (select tagResMap.resourceId from XXTagResourceMap tagResMap) @@ -981,6 +1059,18 @@ </query> </named-query> + <named-query name="XXServiceResource.findForServicePlugin"> + <query> + select obj from XXServiceResource obj, XXService service where service.id = :serviceId and service.tagService is not null and obj.serviceId = service.id and obj.id in + (select tagResMap.resourceId from XXTagResourceMap tagResMap, XXTag tag, XXTagDef tagDef + where tagResMap.tagId = tag.id and tag.type = tagDef.id and tagDef.name in + (select policyResMap.value from XXPolicyResourceMap policyResMap, XXPolicyResource policyRes, XXPolicy policy + where policy.service = service.tagService and policyRes.policyId = policy.id and policyResMap.resourceId = policyRes.id) + ) + order by obj.id + </query> + </named-query> + <named-query name="XXServiceResource.findByServiceAndResourceSignature"> <query>select obj from XXServiceResource obj where obj.serviceId = :serviceId and obj.resourceSignature = :resourceSignature</query> </named-query>