public String generateRequestCacheKey(HttpServletRequest request) { StringBuilder cacheKey = new StringBuilder(UrlUtils.getCurrentUri(request)); return DigestUtils.md5Digest(cacheKey.toString()); }
public String generateRequestCacheKey(HttpServletRequest request) { StringBuilder cacheKey = new StringBuilder(UrlUtils.getCurrentUri(request)); return DigestUtils.md5Digest(cacheKey.toString()); }
etagValue.append(DigestUtils.md5Digest(new String(response, configuration.getEncoding()))); etagValue.append("\"");
etagValue.append(DigestUtils.md5Digest(new String(response, configuration.getEncoding()))); etagValue.append("\"");
@Override public boolean handle(HandlerContext handlerContext) { // Generate a brand new request key String requestKey = DigestUtils.md5Digest(UUID.randomUUID().toString()); // Create a new instance intended to be stored in session RequestFlashData requestData = new RequestFlashData(handlerContext.getRequest()); // Store request data in cache for later use handlerContext.getContext().getRequestFlashDataCache().put(requestKey, requestData); // Store the generated request key as a request attribute for later use handlerContext.getRequest().setAttribute(WebConstants.DANDELION_REQUEST_KEY, requestKey); return true; } }
@Override public boolean handle(HandlerContext handlerContext) { // Generate a brand new request key String requestKey = DigestUtils.md5Digest(UUID.randomUUID().toString()); // Create a new instance intended to be stored in session RequestFlashData requestData = new RequestFlashData(handlerContext.getRequest()); // Store request data in cache for later use handlerContext.getContext().getRequestFlashDataCache().put(requestKey, requestData); // Store the generated request key as a request attribute for later use handlerContext.getRequest().setAttribute(WebConstants.DANDELION_REQUEST_KEY, requestKey); return true; } }
@Override public String getAssetVersion(Asset asset) { LOG.debug("Calculating version hash for the asset: {}", asset.toLog()); StorageEntry storageEntry = getContext().getAssetStorage().get(asset.getStorageKey()); String contents = null; if(storageEntry != null) { contents = storageEntry.getContents(); } String version = null; if (StringUtils.isBlank(contents)) { LOG.warn("Asset {} has an empty contents. Using a random String for the hash", asset.toLog()); version = DigestUtils.md5Digest(UUID.randomUUID().toString()); } else { version = DigestUtils.md5Digest(contents); } return version; } }
@Override public String getAssetVersion(Asset asset) { LOG.debug("Calculating version hash for the asset: {}", asset.toLog()); StorageEntry storageEntry = getContext().getAssetStorage().get(asset.getStorageKey()); String contents = null; if(storageEntry != null) { contents = storageEntry.getContents(); } String version = null; if (StringUtils.isBlank(contents)) { LOG.warn("Asset {} has an empty contents. Using a random String for the hash", asset.toLog()); version = DigestUtils.md5Digest(UUID.randomUUID().toString()); } else { version = DigestUtils.md5Digest(contents); } return version; } }
/** * <p> * Generates a MD5 hash using information of the provided {@link Asset}. * </p> * <p> * The set of information used to generate the hash depends on the location * key. * </p> * <ul> * <li>{@code webapp}, {@code jar}, {@code webjar}, {@code classpath} and * {@code remote}: bundle name + asset name + asset type</li> * <li>{@code api}: bundle name + asset name + asset type + current URI</li> * </ul> * * @param asset * The asset holding information used to generate the hash. * @return a MD5 hash. */ public static String generateStorageKey(Asset asset, HttpServletRequest request) { Validate.notNull(asset.getConfigLocationKey(), "The location key of the provided asset cannot be null"); StringBuilder keyContext = new StringBuilder(); keyContext.append(asset.getBundle()); keyContext.append(asset.getName()); keyContext.append(asset.getType().name()); if (asset.getConfigLocationKey().equalsIgnoreCase(ApiLocator.LOCATION_KEY)) { keyContext.append(UrlUtils.getCurrentUri(request)); } return DigestUtils.md5Digest(keyContext.toString()); }
/** * <p> * Generates a MD5 hash using information of the provided {@link Asset}. * </p> * <p> * The set of information used to generate the hash depends on the location * key. * </p> * <ul> * <li>{@code webapp}, {@code jar}, {@code webjar}, {@code classpath} and * {@code remote}: bundle name + asset name + asset type</li> * <li>{@code api}: bundle name + asset name + asset type + current URI</li> * </ul> * * @param asset * The asset holding information used to generate the hash. * @return a MD5 hash. */ public static String generateStorageKey(Asset asset, HttpServletRequest request) { Validate.notNull(asset.getConfigLocationKey(), "The location key of the provided asset cannot be null"); StringBuilder keyContext = new StringBuilder(); keyContext.append(asset.getBundle()); keyContext.append(asset.getName()); keyContext.append(asset.getType().name()); if (asset.getConfigLocationKey().equalsIgnoreCase(ApiLocator.LOCATION_KEY)) { keyContext.append(UrlUtils.getCurrentUri(request)); } return DigestUtils.md5Digest(keyContext.toString()); }