@Test public void get_WithoutRequestAndWithParameters() { final String expected = "The asset [ /content/dam/test.png ] and [ 0 ] parameters are provided"; final String actual = (String) combinedProperties.get("test/no-request" + "?a=b&c=d&testParameter=Hello World!"); assertEquals(expected, actual); }
@Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); if (computedPropertyParameter.getName() == null) { return null; } Object result = null; final ComputedProperty computedProperty = computedProperties.get(computedPropertyParameter.getName()); if (computedProperty != null) { if (computedProperty.isCachable() && cachedValues.containsKey(computedPropertyParameter.getCacheId())) { result = cachedValues.get(computedPropertyParameter.getCacheId()); if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] served from ComputedPropertyAccessor cache.", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } else if (computedProperty.accepts(asset, request, computedPropertyParameter.getName())) { result = computedProperty.get(asset, request, computedPropertyParameter.getParameters()); if (computedProperty.isCachable()) { cachedValues.put(computedPropertyParameter.getCacheId(), result); } if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] ", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } } if (result == null && metaProperties != null) { result = metaProperties.get(computedPropertyParameter.getName()); } if (result == null && assetProperties != null) { result = assetProperties.get(computedPropertyParameter.getName()); } return result; }
CombinedProperties implements Map<String, Object> { @Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); if (computedPropertyParameter.getName() == null) { return null; } Object result = null; final ComputedProperty computedProperty = computedProperties.get(computedPropertyParameter.getName()); if (computedProperty != null) { if (computedProperty.isCachable() && cachedValues.containsKey(computedPropertyParameter.getCacheId())) { result = cachedValues.get(computedPropertyParameter.getCacheId()); if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] served from ComputedPropertyAccessor cache.", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } else if (computedProperty.accepts(asset, request, computedPropertyParameter.getName())) { result = computedProperty.get(asset, request, computedPropertyParameter.getParameters()); if (computedProperty.isCachable()) { cachedValues.put(computedPropertyParameter.getCacheId(), result); } if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] ", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } } if (result == null && metaProperties != null) { result = metaProperties.get(computedPropertyParameter.getName()); } if (result == null && assetProperties != null) { result = assetProperties.get(computedPropertyParameter.getName()); } return result; } }
CombinedProperties implements Map<String, Object> { @Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); if (computedPropertyParameter.getName() == null) { return null; } Object result = null; final ComputedProperty computedProperty = computedProperties.get(computedPropertyParameter.getName()); if (computedProperty != null) { if (computedProperty.isCachable() && cachedValues.containsKey(computedPropertyParameter.getCacheId())) { result = cachedValues.get(computedPropertyParameter.getCacheId()); if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] served from ComputedPropertyAccessor cache.", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } else if (computedProperty.accepts(asset, request, computedPropertyParameter.getName())) { result = computedProperty.get(asset, request, computedPropertyParameter.getParameters()); if (computedProperty.isCachable()) { cachedValues.put(computedPropertyParameter.getCacheId(), result); } if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] ", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } } if (result == null && metaProperties != null) { result = metaProperties.get(computedPropertyParameter.getName()); } if (result == null && assetProperties != null) { result = assetProperties.get(computedPropertyParameter.getName()); } return result; } CombinedProperties(final List<ComputedProperty> computedProperties,
                              final SlingHttpServletRequest request,
                              final Asset asset); }
CombinedProperties implements Map<String, Object> { @Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); if (computedPropertyParameter.getName() == null) { return null; } Object result = null; final ComputedProperty computedProperty = computedProperties.get(computedPropertyParameter.getName()); if (computedProperty != null) { if (computedProperty.isCachable() && cachedValues.containsKey(computedPropertyParameter.getCacheId())) { result = cachedValues.get(computedPropertyParameter.getCacheId()); if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] served from ComputedPropertyAccessor cache.", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } else if (computedProperty.accepts(asset, request, computedPropertyParameter.getName())) { result = computedProperty.get(asset, request, computedPropertyParameter.getParameters()); if (computedProperty.isCachable()) { cachedValues.put(computedPropertyParameter.getCacheId(), result); } if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] ", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } } if (result == null && metaProperties != null) { result = metaProperties.get(computedPropertyParameter.getName()); } if (result == null && assetProperties != null) { result = assetProperties.get(computedPropertyParameter.getName()); } return result; } CombinedProperties(final List<ComputedProperty> computedProperties,
                              final SlingHttpServletRequest request,
                              final Asset asset); @Override final int size(); @Override final boolean isEmpty(); @Override final boolean containsKey(Object key); @Override final boolean containsValue(Object value); @Override final Object get(Object key); @Override final Object put(String key, Object value); @Override Object remove(Object key); @Override final void putAll(Map<? extends String, ?> m); @Override final void clear(); @Override Set<String> keySet(); @Override final Collection<Object> values(); @Override final Set<Entry<String, Object>> entrySet(); @Override final boolean equals(Object o); @Override final int hashCode(); }
CombinedProperties implements Map<String, Object> { @Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); if (computedPropertyParameter.getName() == null) { return null; } Object result = null; final ComputedProperty computedProperty = computedProperties.get(computedPropertyParameter.getName()); if (computedProperty != null) { if (computedProperty.isCachable() && cachedValues.containsKey(computedPropertyParameter.getCacheId())) { result = cachedValues.get(computedPropertyParameter.getCacheId()); if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] served from ComputedPropertyAccessor cache.", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } else if (computedProperty.accepts(asset, request, computedPropertyParameter.getName())) { result = computedProperty.get(asset, request, computedPropertyParameter.getParameters()); if (computedProperty.isCachable()) { cachedValues.put(computedPropertyParameter.getCacheId(), result); } if (log.isDebugEnabled()) { log.debug(String.format("Computed value [ %s -> %s ] using [ %s ] ", computedPropertyParameter.getCacheId(), result, computedProperty.getClass().getName())); } } } if (result == null && metaProperties != null) { result = metaProperties.get(computedPropertyParameter.getName()); } if (result == null && assetProperties != null) { result = assetProperties.get(computedPropertyParameter.getName()); } return result; } CombinedProperties(final List<ComputedProperty> computedProperties,
                              final SlingHttpServletRequest request,
                              final Asset asset); @Override final int size(); @Override final boolean isEmpty(); @Override final boolean containsKey(Object key); @Override final boolean containsValue(Object value); @Override final Object get(Object key); @Override final Object put(String key, Object value); @Override Object remove(Object key); @Override final void putAll(Map<? extends String, ?> m); @Override final void clear(); @Override Set<String> keySet(); @Override final Collection<Object> values(); @Override final Set<Entry<String, Object>> entrySet(); @Override final boolean equals(Object o); @Override final int hashCode();  }