public void sendContent(Object target, Filter filter) throws IllegalArgumentException { MeemContentClient meemContentClient = (MeemContentClient) target; Collection<MeemPath> valueSet; synchronized (meemPaths) { valueSet = meemPaths.values(); if (filter == null) { logger.info("!!!! No filter for meem content client"); for (MeemPath meemPath : valueSet) { meemContentClient.meemContentChanged(meemPath, contentStore.load(meemPath)); } } else if (filter instanceof ExactMatchFilter) { /* * If it is an exact match filter, grab the MeemPath out of it. * If that MeemPath isn't in the list, send back an empty MeemContent */ Object filterObject = ((ExactMatchFilter) filter).getTemplate(); if (filterObject instanceof MeemPath) { MeemPath filterPath = (MeemPath) filterObject; if (valueSet.contains(filterPath)) { meemContentClient.meemContentChanged(filterPath, contentStore.load(filterPath)); } else { meemContentClient.meemContentChanged(filterPath, new MeemContent()); } } } } }
public void storeMeemContent(MeemPath meemPath, MeemContent meemContent) { if (DEBUG) { logger.info("storing meem content: " + meemPath); } // only store meemstore paths if (meemPath.getSpace().equals(Space.MEEMSTORE)) { contentStore.store(meemPath, meemContent); String location = meemPath.getLocation(); boolean stored = false; synchronized (meemPaths) { if (!meemPaths.containsKey(location)) { meemPaths.put(location, meemPath); stored = true; } if (stored) { meemStoreClient.meemStored(meemPath); } // TODO[peter] Should this be called if the meem was just stored? meemContentClient.meemContentChanged(meemPath, meemContent); } } }
public void storeMeemDefinition(MeemPath meemPath, MeemDefinition meemDefinition) { if (DEBUG) { logger.info("storing meem def: " + meemPath); } // only store meemstore paths if (meemPath.getSpace().equals(Space.MEEMSTORE)) { int meemVersion = meemDefinition.getMeemAttribute().getVersion(); if (meemVersion > definitionStore.getVersion(meemPath)) { definitionStore.store(meemPath, meemDefinition); synchronized (meemPaths) { if (!meemPaths.containsKey(meemPath.getLocation())) { meemPaths.put(meemPath.getLocation(), meemPath); meemStoreClient.meemStored(meemPath); } meemDefinitionClient.meemDefinitionChanged(meemPath, meemDefinition); meemContentClient.meemContentChanged(meemPath, null); } } else { // definition version number is same or smaller than the persisted one // LogTools.warn(logger, "Request to persist MeemDefinition with lower version number than // most recent version"); } } }
public void destroyMeem(MeemPath meemPath) { String location = meemPath.getLocation(); MeemPath removePath; synchronized (meemPaths) { removePath = (MeemPath) meemPaths.remove(location); if (removePath != null) { contentStore.remove(meemPath); definitionStore.remove(meemPath); meemStoreClient.meemDestroyed(meemPath); meemDefinitionClient.meemDefinitionChanged(meemPath, null); meemContentClient.meemContentChanged(meemPath, null); } } }