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 <[email protected]> wrote:
> Thanks cmdskp,
>
> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 least four values (sadly, I can't find
> > > > > the blog page which gave the list), but the main two are:
>
> > > > > - parent
> > > > > - children
>
> > > > > Here's a nice example 
> > > > > capabilities.xml:http://code.google.com/p/google-wave-resources/source/browse/trunk/sa...
>
> > > > > To ensure your get the children for an event, specify
> > > > > context="children" as well as content="true" (to get their content)
> > > > > for your event. Like so:
> > > > > <w:capability name="blip_submitted" content="true" context="children" 
> > > > > /
>
> > > > > If you want the parent above of the event's blip, specify
> > > > > context="parent" as well as content="true" (to get the parent's
> > > > > content) for your event.  Like so:
> > > > > <w:capability name="blip_submitted" content="true" context="parent" />
>
> > > > > You always get the content of the event blip I believe - though I
> > > > > could be wrong if you set content="false" - never tried that.
>
> > > > > The context attribute is also mentioned in passing under the Java API
> > > > > method blip.getChild(int index), getChildren(), etc... methods 
> > > > > here:http://wave-robot-java-client.googlecode.com/svn/trunk/doc/com/google...
>
> > > > > "Returns the Nth child blip of this blip (if available). Use the
> > > > > isChildAvailable() method to check for availability of the child
> > > > > blip.
> > > > > Note: The behavior of this method is dependent on the 'context'
> > > > > settings in the Capabilities XML configuration. Child blips may not
> > > > > have been sent with this event."
>
> > > > > Hope that clears up some of the misunderstanding on how you choose
> > > > > what data to be sent for an event and what is possible currently.
>
> > > > > If you have a sandbox account I recommend you do a search for:
> > > > > with:public tag:Office Hours
>
> > > > > There's a lot of answers there from Google on various topics not
> > > > > covered in the main tutorials - though some of it is out-of-date now
> > > > > since the API development is moving forward.
>
> > > > > On Nov 23, 3:22 am, Vikram Dhillon <[email protected]> wrote:
>
> > > > > > The visual really helped, I wasn't thinking properly so I apologize 
> > > > > > for that
> > > > > > and thanks for your clarification on the subject. So from what I 
> > > > > > understand
> > > > > > now, how about this: if we can export the whole conversation, to a 
> > > > > > file or
> > > > > > something, then the robot can stri[p off everything besides the 
> > > > > > root blip and
> > > > > > then sync it back may be
>
> > > > > > --
> > > > > > Regards,
> > > > > > Vikram Dhillon
>
> > > > > > On Sunday 22 November 2009 08:15:13 pm Olreich wrote:
>
> > > > > > > GetChildren on the root blip will get the first blip. 
> > > > > > > Unfortunately,
> > > > > > > because the root blip has to be the blip submitted to have that
> > > > > > > function work, it's limited. In fact, it's even more limited 
> > > > > > > because
> > > > > > > of the fact that the root blips child's child is null in the 
> > > > > > > current
> > > > > > > version of the API. (an annoying quirk)
>
> > > > > > > Visual:
>
> > > > > > > r--->Blip 1
> > > > > > >     ^--->Blip 2
> > > > > > >         ^--->Blip A
> > > > > > >    
>
> ...
>
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en.


Reply via email to