Thanks very much cmdskp, that's a great help and is working for me!

Oddly enough, after being on hiatus for Thanksgiving holiday, my
algorithm seems to also work.  It's possible that it may have
something to do with the new API update on 11/27, even though this
doesn't seem to relate to the issue(s) resolved in the update.

Your approach gives me a new and possibly more stable solution.
Thanks very much!

Stephen

On Nov 26, 12:39 am, cmdskp <cmd...@gmail.com> wrote:
> Thanks - okay, I don't see any glaring differences - I've approached
> this differently in parts which I'll go through in case they have
> something to do with it.
>
> However, I don't know if also missed Austin's reply and mine about
> updating your capabilities.xml version number?  And perhaps even
> changing your appengine-web.xml version number and changing the App
> Engine website application versions default to match...  I think this
> is the most likely thing to try.
>
> The differences with my own code below, I can see, are:
> - using the EventType.WAVELET_SELF_ADDED instead of isSelfAdded() (If
> it triggers anyway, I can't see any reason this makes any difference)
> - going through the children in reverse order and modifying the
> deepest first (processBlipText is the last line in my processBlip
> recursion.
> - checking isChildAvaliable(i) and using getChild(i) (I read someone
> recommending this on a sandbox wave awhile ago)
>
> Anyway, here's my recursion code:
>
> public void processEvents(RobotMessageBundle aBundle) {
>         Wavelet tempWavelet = aBundle.getWavelet();
>         for (Event tempEvent: aBundle.getEvents()) {
>                 String tempModifiedBy = tempEvent.getModifiedBy();
>                 EventType tempEventType = tempEvent.getType();
>                 if (tempEventType==EventType.WAVELET_SELF_ADDED) {
>                         Blip tempBlip = tempWavelet.getRootBlip();
>                         processBlip(tempBlip, tempWavelet, false); // prevent 
> deleting of
> root blip!
>                 }
>         }
>
> }
>
> private boolean processBlip(Blip aBlip, Wavelet aWavelet, boolean
> aAllowDelete) {
>         try {
>                 List<Blip> tempChildren = aBlip.getChildren();
>                 for (int i=tempChildren.size()-1; i>=0; --i) {
>                         try {
>                                 if (aBlip.isChildAvailable(i)) {
>                                         Blip tempChildBlip = 
> aBlip.getChild(i);
>                                         if (tempChildBlip!=null) {
>                                                 processBlip(tempChildBlip, 
> aWavelet, true);
>                                         }
>                                 }
>                         } catch (Exception e) {
>                         }
>                 }
>         } catch (Exception e) {
>         }
>         return processBlipText(aBlip, aAllowDelete, "");
>
> }
>
> private boolean processBlipText(Blip aBlip, boolean aAllowDelete,
> String aModfierEmail) {
>         TextView tempTextView = aBlip.getDocument();
>         if (tempTextView==null) {
>                 LOG.warning("TextView was null!");
>                 return false;
>         }
>         String tempText;
>         try {
>                 tempText = tempTextView.getText();
>                 if (tempText==null) {
>                         LOG.warning("Text was null!");
>                         return false;
>                 }
>         } catch (Exception tempException) {
>                 LOG.warning("Exception .getText()");
>                 return false;
>         }
> // the rest here is just lots of code processing tempText or aBlip for
> delete()
>
> }
>
> On Nov 26, 4:46 am, Stephen George <sfgeo...@gmail.com> wrote:
>
> > Thankscmdskp,
>
> > I must have missed your response to the other thread, sorry.  I'd be
> > happy to swap notes.  Here's my traversal approach.  Apologies for
> > this long message...
>
> > package com.googlecode.wave.myrobot;
>
> > import com.google.wave.api.*;
> > import java.util.logging.Logger;
> > import java.util.Date;
>
> > @SuppressWarnings("serial")
> > public class MyRobotServlet extends AbstractRobotServlet
> > {
> >   static String INDENT    = "  ";
> >   static String ERROR_BULLET  = " #";
> >   static String RULE      = "------";
>
> >   private static final Logger logger =
> >     Logger.getLogger(MyRobotServlet.class.getName());
>
> >   @Override
> >   public void processEvents(RobotMessageBundle bundle)
> >   {
> >     if( bundle.wasSelfAdded() )
> >     {
> >       log( "I've been added to " + bundle.getWavelet().getWaveId() );
> >       actOnBundle( bundle, "self_added" );
> >     }
> >   }
>
> >   protected void actOnBundle( RobotMessageBundle bundle, String
> > eventname )
> >   {
> >     Wavelet wavelet = bundle.getWavelet();
> >     StringBuilder list_html = new StringBuilder();
> >     list_html.append("I'm responding to ").append( eventname ).append
> > ("\n\n");
>
> >     traverseBlipGadgets( wavelet.getRootBlip(), list_html, 0 );
> >     log( list_html.toString() );
> >   }
>
> >   protected void traverseBlipGadgets( Blip blip, StringBuilder
> > list_html, int indent_level )
> >   {
> >     StringBuilder indentation = generateIndentation( indent_level );
>
> >     list_html.append( getBlipLabel( blip, indentation ) );
>
> >     try
> >     {
> >       for( Blip blippie : blip.getDocument().getInlineBlips() )
> >       {
> >         traverseBlipGadgets( blippie, list_html, indent_level + 1 );
> >       }
> >     }
> >     catch( NullPointerException ex )
> >     {
> >       String warning = indentation + ERROR_BULLET +
> > "NullPointerException while trying to getInlineBlips()";
> >       list_html.append( warning ).append( "\n" );
> >       logger.warning( warning );
> >     }
>
> >     try
> >     {
> >       for( Blip blooper : blip.getChildren() )
> >       {
> >         list_html.append( indentation ).append( RULE ).append( "\n" );
> >         traverseBlipGadgets( blooper, list_html, indent_level );
> >       }
> >     }
> >     catch( NullPointerException ex )
> >     {
> >       String warning = indentation + ERROR_BULLET +
> > "NullPointerException while trying to getChildren()";
> >       list_html.append( warning ).append( "\n" );
> >       logger.warning( warning );
> >     }
> >   }
>
> >   protected static StringBuilder getBlipLabel( Blip blip,
> > StringBuilder indentation )
> >   {
> >     StringBuilder blip_label = new StringBuilder();
> >     try
> >     {
> >       blip_label.append( indentation + "Blip Id: " + blip.getBlipId()
> > + "\n" );
> >       blip_label.append( indentation + "Parent ID: " +
> > blip.getParentBlipId() + "\n" );
> >       blip_label.append( indentation + "Has Children: " +
> > (blip.hasChildren() ? "Y" : "N" ) + "\n" );
> >     }
> >     catch( NullPointerException ex )
> >     {
> >       blip_label.append( indentation + "(NULL Blip Exception #1)\n" );
> >     }
>
> >     try
> >     {
> >       long lastmod = blip.getLastModifiedTime();
> >       Date meDate = new Date(lastmod);
> >       blip_label.append( indentation + "Last Modified: " +
> > meDate.toString() + "\n" );
> >     }
> >     catch( NullPointerException ex )
> >     {
> >       blip_label.append( indentation + "(NULL Blip Exception #2)\n" );
> >     }
>
> >     try
> >     {
> >       blip_label.append( indentation + "Content: " + blip.getDocument
> > ().getText() + "\n" );
> >     }
> >     catch( NullPointerException ex )
> >     {
> >       blip_label.append( indentation + "(NULL Blip Exception #3\n" );
> >     }
>
> >     return blip_label;
> >   }
>
> >   protected static StringBuilder generateIndentation( int
> > indent_level )
> >   {
> >     StringBuilder indentation = new StringBuilder();
> >     for ( int i = 0; i < indent_level; i++ )
> >     {
> >       indentation.append( INDENT );
> >     }
> >     return indentation;
> >   }
>
> > }
>
> > On Nov 25, 11:25 pm,cmdskp<cmd...@gmail.com> wrote:
>
> > > Good to know it looks like you can combine the context values.  Though
> > > with WAVELET_SELF_ADDED there would not be a parent - since the
> > > root-node is returned with that event - it is the top-most blip and
> > > has no parent logically...though I've not checked to see if it's null
> > > or points to itself, I would expect null there.
>
> > > I don't know if you've tested my robot cleantxt on WAVELET_SELF_ADDED
> > > yet as I offered in another thread - it proves it's possible.  Another
> > > quick test on it on a new wave there and the functionality remains
> > > tonight.  Perhaps if you show your recursive code we might spot a
> > > difference?
>
> > > However, during my testing tonight I was trying the BLIP_SUBMITTED
> > > event and with that one I can't get the submitted blip's children, not
> > > even their Id's - it always returns 0 children, same for
> > > DOCUMENT_CHANGED.
>
> > > On Nov 26, 3:50 am, Stephen George <sfgeo...@gmail.com> wrote:
>
> > > > Olreich,
>
> > > > I'll start by saying that I haven't had much success with getting
> > > > both.
>
> > > > However, if you take a look at Google's implementation of the private
> > > > method AbstractRobot.processCapabilities(), it looks like it *should*
> > > > be possible by splitting the contexts with commas:
>
> > > > <w:capability name="WAVELET_SELF_ADDED"
> > > > context="PARENT,SIBLINGS,CHILDREN" />
>
> > > > I believe that is at least intention from the code links below.  I
> > > > personally have still not had luck recursively traversing through all
> > > > children and inline blips from the root blip when my robot is added to
> > > > a dense wave.
>
> > > > See 
> > > > also:http://code.google.com/p/wave-robot-java-client/source/browse/trunk/s......
>
> > > > On Nov 24, 5:18 am, Olreich <olre...@gmail.com> wrote:
>
> > > > > The only remaining question is:
>
> > > > > Can one specify both parent and child context, and thus get all
> > > > > blip_data with a single event?
>
> > > > > On Nov 23, 10:53 pm,cmdskp<cmd...@gmail.com> wrote:
>
> > > > > > @qMax:  As of today, it appears to delete only the blip and its 
> > > > > > inline
> > > > > > replies (the collapseable blips) - not standard reply children.
>
> > > > > > @shitu: Last night I was testing deleting of all blips on
> > > > > > WAVELET_SELF_ADDED.  It worked fine then, I recursively went through
> > > > > > the children and all were deleted - it also gave me every blips text
> > > > > > content. (I did not test inline replies...)
> > > > > > However, sometimes .delete() will throw an exception in the logs - 
> > > > > > but
> > > > > > that issue has been raised on the wave API issue tracker.
>
> > > > > > There still seems some confusion about the model used by Wave when 
> > > > > > it
> > > > > > comes to what blips are given with an event.  It's also a moving
> > > > > > target as bugs get fixed.
>
> > > > > > In the documentation and guides I've used for the 'capabilities.xml'
> > > > > > file there is an extra attribute which tells the wave server which
> > > > > > blips content to send on that event to the robot.
>
> > > > > > This attribute can be set to at
>
> ...
>
> read more »

--

You received this message because you are subscribed to the Google Groups 
"Google Wave API" group.
To post to this group, send email to google-wave-...@googlegroups.com.
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en.


Reply via email to