* This method removes the asset key from the cache and send an invalidation message
* to the cluster when the cms is in cluster
* @param asset
*/
public static void removeAssetFromCache(Versionable asset){
DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
HostAPI hostAPI = APILocator.getHostAPI();
try{
User systemUser = APILocator.getUserAPI().getSystemUser();
Host host = hostAPI.findParentHost((Treeable)asset, systemUser, false);
if(host == null)
return;
String hostId = host.getIdentifier();
Identifier identifier = APILocator.getIdentifierAPI().find(asset);
if(identifier.getAssetType().equals("contentlet")){
Contentlet c = (Contentlet) asset;
long languageId = UtilMethods.isSet(c.getLanguageId())?c.getLanguageId():APILocator.getLanguageAPI().getDefaultLanguage().getId();
cache.remove(getPrimaryGroup() + hostId + ":" + identifier.getURI(),getPrimaryGroup() + "_" + hostId + "_" + languageId );
} else {
cache.remove(getPrimaryGroup() + hostId + ":" + identifier.getURI(),getPrimaryGroup() + "_" + hostId);
}
}catch (Exception e) {
Logger.error(LiveCache.class, "Unable to remove asset from live cache", e);
}