public Interest handleContent(ContentObject result, Interest interest) { Log.finest( Log.FAC_TEST, "Interests registered: " + _interests.size() + " content object returned"); // Parameterized behavior that subclasses can override. ContentName interestName = null; if (_processedObjects.contains(result)) { Log.fine( Log.FAC_TEST, "FLOSSER: Got repeated content for interest: {0} content: {1}", interest, result.name()); } else { Log.finest( Log.FAC_TEST, "FLOSSER: Got new content for interest {0} content name: {1}", interest, result.name()); processContent(result); // update the interest. follow process used by ccnslurp. // exclude the next component of this object, and set up a // separate interest to explore its children. // first, remove the interest from our list as we aren't going to // reexpress it in exactly the same way synchronized (_interests) { for (Entry<ContentName, Interest> entry : _interests.entrySet()) { if (entry.getValue().equals(interest)) { interestName = entry.getKey(); _interests.remove(interestName); break; } } } int prefixCount = interest.name().count(); // DKS TODO should the count above be count()-1 and this just prefixCount? if (prefixCount == result.name().count()) { if (null == interest.exclude()) { ArrayList<Exclude.Element> excludes = new ArrayList<Exclude.Element>(); excludes.add(new ExcludeComponent(result.digest())); interest.exclude(new Exclude(excludes)); Log.finest(Log.FAC_TEST, "Creating new exclude filter for interest {0}", interest.name()); } else { if (interest.exclude().match(result.digest())) { Log.fine( Log.FAC_TEST, "We should have already excluded content digest: " + DataUtils.printBytes(result.digest())); } else { // Has to be in order... Log.finest(Log.FAC_TEST, "Adding child component to exclude."); interest.exclude().add(new byte[][] {result.digest()}); } } Log.finer( Log.FAC_TEST, "Excluding content digest: " + DataUtils.printBytes(result.digest()) + " onto interest {0} total excluded: " + interest.exclude().size(), interest.name()); } else { // Add an exclude for the content we just got // DKS TODO might need to split to matchedComponents like ccnslurp if (null == interest.exclude()) { ArrayList<Exclude.Element> excludes = new ArrayList<Exclude.Element>(); excludes.add(new ExcludeComponent(result.name().component(prefixCount))); interest.exclude(new Exclude(excludes)); Log.finest(Log.FAC_TEST, "Creating new exclude filter for interest {0}", interest.name()); } else { if (interest.exclude().match(result.name().component(prefixCount))) { Log.fine( Log.FAC_TEST, "We should have already excluded child component: {0}", ContentName.componentPrintURI(result.name().component(prefixCount))); } else { // Has to be in order... Log.finest(Log.FAC_TEST, "Adding child component to exclude."); interest.exclude().add(new byte[][] {result.name().component(prefixCount)}); } } Log.finer( Log.FAC_TEST, "Excluding child " + ContentName.componentPrintURI(result.name().component(prefixCount)) + " total excluded: " + interest.exclude().size()); if (_flossSubNamespaces || SegmentationProfile.isNotSegmentMarker(result.name().component(prefixCount))) { ContentName newNamespace = null; try { if (interest.name().count() == result.name().count()) { newNamespace = new ContentName(interest.name(), result.digest()); Log.info(Log.FAC_TEST, "Not adding content exclusion namespace: {0}", newNamespace); } else { newNamespace = new ContentName( interest.name(), result.name().component(interest.name().count())); Log.info(Log.FAC_TEST, "Adding new namespace: {0}", newNamespace); handleNamespace(newNamespace, interest.name()); } } catch (IOException ioex) { Log.warning("IOException picking up namespace: {0}", newNamespace); } } } } if (null != interest) synchronized (_interests) { _interests.put(interest.name(), interest); } return interest; }