@Override public void storeDomain(final Domain domain, final boolean overwrite) throws DomainIdNullException, DomainAlreadyExistsException, DomainStorageException { delegate.storeDomain(domain, overwrite); purgeDomain(domain.getId()); clearDomainIdsFromCache(); }
private void addThinDomainModels( final String domain, final Element modelsNode, final Element root) { IMetadataDomainRepository repo = getMetadataRepository(); Domain domainObject = repo.getDomain(domain); String locale = LocaleHelper.getClosestLocale( LocaleHelper.getLocale().toString(), domainObject.getLocaleCodes()); Element modelNode; for (LogicalModel model : domainObject.getLogicalModels()) { String vis = (String) model.getProperty("visible"); if (vis != null) { String[] visibleContexts = vis.split(","); boolean visibleToContext = false; for (String context : visibleContexts) { if ("adhoc".equals(context.trim())) { visibleToContext = true; break; } } if (!visibleToContext) { continue; } } modelNode = modelsNode.addElement("model"); // $NON-NLS-1$ modelNode.addElement("domain_id").setText(domain); // $NON-NLS-1$ if (model.getId() != null) { modelNode.addElement("model_id").setText(model.getId()); // $NON-NLS-1$ } String modelName = model.getName(locale); if (modelName != null) { modelNode.addElement("model_name").setText(modelName); // $NON-NLS-1$ } if (model.getDescription() != null) { String modelDescription = model.getDescription(locale); if (modelDescription != null) { modelNode.addElement("model_description").setText(modelDescription); // $NON-NLS-1$ } } } return; }
@Override public Set<String> getDomainIds() { final IPentahoSession session = PentahoSessionHolder.getSession(); final String domainKey = generateDomainIdCacheKeyForSession(session); Set<String> domainIds = (Set<String>) cacheManager.getFromRegionCache(CACHE_REGION, domainKey); if (domainIds != null) { // We've previously cached domainIds available for this session return domainIds; } // Domains are accessible by anyone. What they contain may be different so rely on the lookup to // be // session-specific. domainIds = delegate.getDomainIds(); cacheManager.putInRegionCache(CACHE_REGION, domainKey, new HashSet<String>(domainIds)); return domainIds; }
public MappedQuery generateSql( Query query, String locale, IMetadataDomainRepository repo, DatabaseMeta databaseMeta, Map<String, Object> parameters, boolean genAsPreparedStatement) throws PentahoMetadataException { Constraint securityConstraint = null; if (repo != null) { String mqlSecurityConstraint = repo.generateRowLevelSecurityConstraint(query.getLogicalModel()); if (StringUtils.isNotBlank(mqlSecurityConstraint)) { securityConstraint = new Constraint(CombinationType.AND, mqlSecurityConstraint); } } // resolve any missing parameters with default values if (parameters == null && query.getParameters().size() > 0) { parameters = new HashMap<String, Object>(); } for (Parameter param : query.getParameters()) { if (!parameters.containsKey(param.getName())) { parameters.put(param.getName(), param.getDefaultValue()); } } return getSQL( query.getLogicalModel(), query.getSelections(), query.getConstraints(), query.getOrders(), databaseMeta, locale, parameters, genAsPreparedStatement, query.getDisableDistinct(), query.getLimit(), securityConstraint); }
@Override public Domain getDomain(final String id) { final IPentahoSession session = PentahoSessionHolder.getSession(); final CacheKey key = new CacheKey(session.getId(), id); Domain domain = (Domain) cacheManager.getFromRegionCache(CACHE_REGION, key); if (domain != null) { if (logger.isDebugEnabled()) { logger.debug("Found domain in cache: " + key); // $NON-NLS-1$ } return domain; } domain = delegate.getDomain(id); if (domain != null) { SecurityHelper helper = new SecurityHelper(); domain = helper.createSecureDomain(this, domain); // cache domain with the key we used to look it up, not whatever new id it might have now if (logger.isDebugEnabled()) { logger.debug("Caching domain by session: " + key); // $NON-NLS-1$ } cacheManager.putInRegionCache(CACHE_REGION, key, domain); } return domain; }
@Override public boolean hasAccess(final int accessType, final IConcept aclHolder) { return delegate.hasAccess(accessType, aclHolder); }
@Override public String generateRowLevelSecurityConstraint(final LogicalModel model) { return delegate.generateRowLevelSecurityConstraint(model); }
@Override public void removeModel(final String domainId, final String modelId) throws DomainIdNullException, DomainStorageException { delegate.removeModel(domainId, modelId); purgeDomain(domainId); }
@Override public void removeDomain(final String domainId) { delegate.removeDomain(domainId); purgeDomain(domainId); removeDomainFromIDCache(domainId); }
@Override public void flushDomains() { forAllKeys(REMOVE_ALL_CALLBACK); clearDomainIdsFromCache(); delegate.flushDomains(); }