* @param context the page context
* @return true if the asset should be added to the package
*/
protected boolean isToBeAdded(String assetURL,
MarinerPageContext context) {
MarinerSessionContext sc = context.getSessionContext();
// A size of zero is the guaranteed initial value for the cache
// model size in the session context. If this value is seen, the
// cache model needs to be initialized
if (sc.getDeviceAssetCacheMaxSize() == 0) {
int cacheSize = 0;
String cacheSizeAsString =
context.getDevicePolicyValue(
"protocol.mime.urls.to.cache");
if (cacheSizeAsString != null) {
try {
cacheSize = Integer.valueOf(
cacheSizeAsString).intValue();
} catch (NumberFormatException e) {
cacheSize = 0;
}
}
if (cacheSize == 0) {
// Specifically set the value in the session context to a
// non-zero but "disabled" value so we know that the device
// policy value has previously been checked and set in the
// session context
sc.setDeviceAssetCacheMaxSize(-1);
} else {
sc.setDeviceAssetCacheMaxSize(cacheSize);
}
}
// NB: the session context will return false if the cache model is
// disabled
return !sc.isAssetCached(assetURL);
}