List<JetspeedPrincipal> currentList = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); List<JetspeedPrincipal> targetList = new ArrayList<JetspeedPrincipal>(principals); for (Iterator<JetspeedPrincipal> i = currentList.iterator(); i.hasNext(); )
associatedFrom = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
query.addOrderByAscending("type"); query.addOrderByAscending("name"); principals = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
associatedTo = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
@SuppressWarnings("unchecked") public List<PasswordCredential> getHistoricPasswordCredentials(User user, Long securityDomain) { Criteria criteria = new Criteria(); criteria.addEqualTo("principalId", user.getId()); criteria.addEqualTo("type", PasswordCredential.TYPE_HISTORICAL); // check cache String cacheKey = "getHistoricPasswordCredentials:"+criteria; List<PasswordCredential> passwordCredentials = (List<PasswordCredential>) jspmCache.getPasswordCredentialQuery(cacheKey); if (passwordCredentials != null) { return new ArrayList<PasswordCredential>(passwordCredentials); } // perform query Query query = QueryFactory.newQuery(PasswordCredentialImpl.class,criteria); passwordCredentials = (List<PasswordCredential>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); for (PasswordCredential passwordCredential : passwordCredentials) { // store the user by hand as its configured as auto-retrieve="false" ((PasswordCredentialImpl)passwordCredential).setUser(user); } // put result in cache jspmCache.putPasswordCredentialQuery(cacheKey, user.getId(), user.getDomainId(), new ArrayList<PasswordCredential>(passwordCredentials)); // return result return passwordCredentials; }
@SuppressWarnings("unchecked") public List<PersistentJetspeedPermission> getPermissions(String type, String nameFilter) { Criteria criteria = new Criteria(); criteria.addEqualTo("type", type); if (nameFilter != null && nameFilter.length() > 0) { criteria.addLike("name", nameFilter+"%"); } // check cache String cacheKey = "getPermissions:"+criteria; List<PersistentJetspeedPermission> permissions = (List<PersistentJetspeedPermission>) jspmCache.getPermissionQuery(cacheKey); if (permissions != null) { return new ArrayList<PersistentJetspeedPermission>(permissions); } // perform query QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, criteria); query.addOrderByAscending("name"); permissions = (List<PersistentJetspeedPermission>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putPermissionQuery(cacheKey, null, null, JSPMCache.ANY_ID, null, new ArrayList<PersistentJetspeedPermission>(permissions)); // return result return permissions; }
@SuppressWarnings("unchecked") public List<JetspeedPrincipal> getAssociatedTo(Long principalToId, JetspeedPrincipalType from, JetspeedPrincipalType to, String associationName, Long fromSecurityDomain, Long toSecurityDomain) { Criteria criteria = new Criteria(); criteria.addEqualTo("associationsFrom.associationName", associationName); criteria.addEqualTo("associationsFrom.to.id", principalToId); criteria.addEqualTo("type", from.getName()); criteria.addEqualTo("associationsFrom.to.type", to.getName()); criteria.addEqualTo("associationsFrom.to.domainId", toSecurityDomain); criteria.addEqualTo("domainId", fromSecurityDomain); // check cache String cacheKey = "getAssociatedTo:"+criteria; List<JetspeedPrincipal> associatedTo = (List<JetspeedPrincipal>)jspmCache.getAssociationQuery(cacheKey); if (associatedTo != null) { return new ArrayList<JetspeedPrincipal>(associatedTo); } // perform query Query query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class, criteria); associatedTo = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putAssociationQuery(cacheKey, principalToId, extractPrincipalIds(associatedTo), fromSecurityDomain, toSecurityDomain, new ArrayList<JetspeedPrincipal>(associatedTo)); // return result return associatedTo; }
@SuppressWarnings("unchecked") public List<JetspeedPrincipal> getAssociatedFrom(Long principalFromId, JetspeedPrincipalType from, JetspeedPrincipalType to, String associationName, Long fromSecurityDomain, Long toSecurityDomain) { Criteria criteria = new Criteria(); criteria.addEqualTo("associationsTo.associationName", associationName); criteria.addEqualTo("associationsTo.from.id", principalFromId); criteria.addEqualTo("associationsTo.from.type", from.getName()); criteria.addEqualTo("type", to.getName()); criteria.addEqualTo("associationsTo.from.domainId", fromSecurityDomain); criteria.addEqualTo("domainId", toSecurityDomain); // check cache String cacheKey = "getAssociatedFrom:"+criteria; List<JetspeedPrincipal> associatedFrom = (List<JetspeedPrincipal>)jspmCache.getAssociationQuery(cacheKey); if (associatedFrom != null) { return new ArrayList<JetspeedPrincipal>(associatedFrom); } // perform query Query query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class, criteria); associatedFrom = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putAssociationQuery(cacheKey, principalFromId, extractPrincipalIds(associatedFrom), fromSecurityDomain, toSecurityDomain, new ArrayList<JetspeedPrincipal>(associatedFrom)); // return result return associatedFrom; }
@SuppressWarnings("unchecked") public List<JetspeedPrincipal> getPrincipalsByAttribute(String attributeName, String attributeValue, JetspeedPrincipalType type, Long securityDomain) { Criteria criteria = new Criteria(); criteria.addEqualTo("attributes.name", attributeName); criteria.addEqualTo("attributes.value", attributeValue); criteria.addEqualTo("type", type.getName()); criteria.addEqualTo("domainId", securityDomain); // check cache String cacheKey = "getPrincipalsByAttribute:"+criteria; List<JetspeedPrincipal> principals = (List<JetspeedPrincipal>)jspmCache.getPrincipalQuery(cacheKey); if (principals != null) { return new ArrayList<JetspeedPrincipal>(principals); } // perform query Query query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class,criteria); principals = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putPrincipalQuery(cacheKey, JSPMCache.ANY_ID, null, securityDomain, new ArrayList<JetspeedPrincipal>(principals)); // return result return principals; }
@SuppressWarnings("unchecked") public Collection<SecurityDomain> getDomainsOwnedBy(Long ownerDomainId) { Criteria criteria = new Criteria(); criteria.addEqualTo("ownerDomainId", ownerDomainId); // check cache String cacheKey = "getDomainsOwnedBy:"+criteria; List<SecurityDomain> domains = (List<SecurityDomain>) jspmCache.getDomainQuery(cacheKey); if (domains != null) { return new ArrayList<SecurityDomain>(domains); } // perform query QueryByCriteria query = QueryFactory.newQuery(SecurityDomainImpl.class, criteria); query.addOrderByAscending("name"); domains = (List<SecurityDomain>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putDomainQuery(cacheKey, JSPMCache.ANY_ID, new ArrayList<SecurityDomain>(domains)); // return result return domains; }
@SuppressWarnings("unchecked") public List<PersistentJetspeedPermission> getPermissions() { // check cache String cacheKey = "getPermissions:[]"; List<PersistentJetspeedPermission> permissions = (List<PersistentJetspeedPermission>) jspmCache.getPermissionQuery(cacheKey); if (permissions != null) { return new ArrayList<PersistentJetspeedPermission>(permissions); } // perform query QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, new Criteria()); query.addOrderByAscending("type"); query.addOrderByAscending("name"); permissions = (List<PersistentJetspeedPermission>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putPermissionQuery(cacheKey, null, null, JSPMCache.ANY_ID, null, new ArrayList<PersistentJetspeedPermission>(permissions)); // return result return permissions; }
@SuppressWarnings("unchecked") public List<PersistentJetspeedPermission> getPermissions(PersistentJetspeedPrincipal principal) { Criteria criteria = new Criteria(); criteria.addEqualTo("principals.principalId", principal.getId()); // check cache String cacheKey = "getPermissions:"+criteria; List<PersistentJetspeedPermission> permissions = (List<PersistentJetspeedPermission>) jspmCache.getPermissionQuery(cacheKey); if (permissions != null) { return new ArrayList<PersistentJetspeedPermission>(permissions); } // perform query QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, criteria); query.addOrderByAscending("type"); query.addOrderByAscending("name"); permissions = (List<PersistentJetspeedPermission>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putPermissionQuery(cacheKey, principal.getId(), null, JSPMCache.ANY_ID, null, new ArrayList<PersistentJetspeedPermission>(permissions)); // return result return permissions; }
@SuppressWarnings("unchecked") public List<JetspeedPrincipal> getPrincipals(String nameFilter, JetspeedPrincipalType type, Long securityDomain) { Criteria criteria = new Criteria(); if (nameFilter != null && nameFilter.length() > 0) { criteria.addLike("name", nameFilter+"%"); } criteria.addEqualTo("type", type.getName()); criteria.addEqualTo("domainId", securityDomain); // check cache String cacheKey = "getPrincipals:"+criteria; List<JetspeedPrincipal> principals = (List<JetspeedPrincipal>)jspmCache.getPrincipalQuery(cacheKey); if (principals != null) { return new ArrayList<JetspeedPrincipal>(principals); } // perform query Query query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class,criteria); principals = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putPrincipalQuery(cacheKey, JSPMCache.ANY_ID, null, securityDomain, new ArrayList<JetspeedPrincipal>(principals)); // return result return principals; }
@SuppressWarnings("unchecked") public Collection<SecurityDomain> getAllDomains() { // check cache String cacheKey = "getDomains:[]"; List<SecurityDomain> domains = (List<SecurityDomain>) jspmCache.getDomainQuery(cacheKey); if (domains != null) { return new ArrayList<SecurityDomain>(domains); } // perform query QueryByCriteria query = QueryFactory.newQuery(SecurityDomainImpl.class, new Criteria()); query.addOrderByAscending("name"); domains = (List<SecurityDomain>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); // put result in cache jspmCache.putDomainQuery(cacheKey, JSPMCache.ANY_ID, new ArrayList<SecurityDomain>(domains)); // return result return domains; }