processi

about processes and engines

Archive for the ‘atompub’ Category

something about gcal

I had a request for creating events in Google Calendar from some business processes. It gave me the opportunity to play with Google Data; it wasn’t too difficult, especially since it’s based on Atom and AtomPub.

I have thus started working on a new rufus library. It’s very limited for now, but I can have code that looks like that :

require 'rubygems'
require 'rufus/gcal'

calendars = Rufus::Google::Calendar.get_calendars(
  :account => ENV['GUSER'],
  :password => ENV['GPASS'])

#calendars.values.each { |c| p [ c.name, c.href ] }

cal = calendars['gwork']

id = cal.post_quick!(
  'Tennis with John November 13 3pm-4:30pm')

cal.events(:q => 'tennis').each do |e|
  puts
  puts e.to_s
end

Behind the scenes, it relies heavily on the fine atom-tools gem by Brendan Taylor.

The only authentication mechanism used is the ClientLogin. For the other mechanisms, one can look at gdata-ruby.

My next step will be to polish the Event class and to allow for manipulation of Calendar resources. Then I will take a look at other Google Data APIs.

source : http://github.com/jmettraux/rufus-google
mailing-list : http://groups.google.com/group/rufus-ruby

Written by John Mettraux

November 13, 2008 at 12:07 am

Posted in atom, atompub, google, ruby, workflow

restful workflow engine

update : the work announced here has been renamed “ruote-kit”, you can find it at http://github.com/tosch/ruote-kit


I’ve been working on this vaporous thing / project for a while, now it’s here, in its first iteration. It’s called Kisha (steam train).

The short designation is “RESTful workflow engine”, the long one is “RESTful Rails® enveloppe for an OpenWFEru engine [and a worklist]”.

Kisha is leveraging Ruby on Rails 2.0.2 to present a RESTful interface to the OpenWFEru workflow engine.

This first iteration implements 2 core use cases via 2 resources.

The use cases are :

  • launching a new instance of a process
  • editing and then proceeding/saving a workitem

quick wiki quote :

A business process or business method is a collection of interrelated tasks, which solve a particular issue

The 2 resources are “processes” and “workitems”. Thus, RESTfully yours, these paths are available :

  • /processes the list of processes currently running in the workflow engine
  • /processes/{process_instance_id} accessing a particular process instance
  • /workitems all the workitems awaiting manipulation/proceeding from an external participant (you)
  • /workitems/{workitem_id} a particular workitem

Launching a process is done by POSTing a process/launchitem representation to /processes, while modifying/proceeding a workitem is by PUTting an updated representation of that workitem at /workitems/{workitem_id}.

(there is a working draft enumerating those resources at kisha.txt)

That’s for the theory.

Kisha is available in its first iteration as a zip download or via the source (see this piece of documentation).

For documentation and test purposes, I took care of providing a well-connected set of HTML representations of the resources, here are a few screenshots :

Kisha screenshot

What’s in this first iteration :

  • well connected HTML representations (learn the interface by playing around)
  • Rails ActiveResource JSON and XML representations
  • Atom representations as well
  • Possibility to post resources (/processes for now) via AtomPub
  • limited Authentication scheme (127.0.0.1 is trusted as well as the canonical “user” user, via basic http authentication)
  • binary Authorization (once you’re authentified, you can do everything)
  • a chart representation for workitems and processes (it’s taken out of densha)
  • a plain model for participants : there is one ‘catch-all’ participant (an expressions with a typo could be mistaken for a participant)

I’ve tried hard to accept a large set of variants for the process/workitem input (json, xml, yaml, atom entries, …), Kisha should be able to accomodate them all, this has proven the most time consuming aspect for now.

What will be in further iterations :

  • more authentication schemes (Pat is petitioning me about them)
  • a better authorization system (who can launch, who can proceed, who can pause)
  • more resources (process errors, process variables, maybe process definitions, …)
  • why not a /participants resource ?
  • more efficient usage of the resources (etag & co)
  • polishing the AtomPub interactions
  • activity [atom] feed
  • more documentation

Over for now.

Feedback is welcome on the OpenWFEru mailing lists.

Written by John Mettraux

December 20, 2007 at 5:52 am

web 2.0 and status

Today, I spent some time at the Tokyo Web 2.0 expo. I had the opportunity to shake hands with Hakon Wium Lie, the CTO of Opera and Tim O’Reilly.

The Opera guys had two OLPCs on their stand, they looked beautiful. I couldn’t get the O’Reilly booth guy to sell me his “Resftful Web Services” t-shirt unfortunately.

The best spot for free wifi was the Microsoft lounge (thanks for the coffee !), I jockeyed my macbook… My Debian laptop would have earned me some karma points.

I was quite surprised not to come across any booth yielding the Rails or Ruby standards. Some salarymen were mumbling those names, but no visible presence, except among the O’Reilly books.

This week-end is dedicated to sports, so I won’t progress much on OpenWFEru, my open source Ruby workflow and bpm engine. Next week, I will release version 0.9.16. This new version contains lots of improvements, as the changelog attests.

I’m quite happy with the BlogParticipant, a specialization of the new AtomPubParticipant, I can use phrase like “you can have business processes that blog”, “read the activity trace of your business processes as a blog” or “publication workflow for blog entries / content repositories” when pitching OpenWFEru to the salesguys around me.

OK, time for me to forget about computers and buzzwords.

Written by John Mettraux

November 16, 2007 at 2:49 pm

Posted in atompub, bpm, cms, openwferu

Rest and AtomPub for Rufus

Mark Masterson just posted about RESTafarian Workflow / BPM Ganja, here are my two favourite quotes :

I’m gnawing on the beginnings of the idea that we might be able to implement an entire BPMS on top of a RESTful infrastructure

I’m beginning to suspect that embracing the various aspects of REST might allow us to build the “next generation” of process management systems.

This is great to read, and I’m quite happy that OpenWFEru is just in the middle of that. I hope Mark will post more about his ideas, maybe one day, OpenWFEru could be useful for him.

The old OpenWFE (the java one) featured a RESTlike interface and I was surprised to find out a year ago that the FormsPlayer people were using it, directly from the browser for some of their customers.

The first RESTful business process engine that I know of is the GeoBPMS of Pat Cappelaere, there is OpenWFEru behind it and Pat was always evangelizing to me the need for a RESTful OpenWFEru (with AtomPub for posting resources).

Matt Zukowski, in parallel, was working on Fluxr, a RESTful envelope around OpenWFEru, but unfortunately, he cannot continue the development.

That’s it for the context, so why the title “Rest and AtomPub for Rufus” ?

Rufus is the nickname of OpenWFEru, please use it when you feel that OpenWFEru is too hard to pronounce.

I’ve just implemented a new AtomPubParticipant for Rufus. It posts its workitems to an AtomPub enabled resource.

require
  ('openwfe/extras/participants/atompub_participants')
include OpenWFE::Extras

target_uri = \
  "https://openwferu.wordpress.com/wp-app.php/posts"

params = {
  :username => "x",
  :password => "y",
  :categories => "test, workflow"
}

engine.register_participant(
  "app", 
  AtomPubParticipant.new(target_uri, params))

This example posts to a [dump] wordpress account. By default, it dumps the workitem as YAML, but it’s easy to override or monkey patch the methods of the AtomPubParticipant to have it use other formats.

So why brag about it ?

  • it’s easy to build a publication workflow based upon OpenWFEru and a blog engine like WordPress
  • a blog can be used for holding business activity trace/history

which are just sub-cases of :

  • in a RESTful environment, you can create resources via AtomPub inside of an OpenWFEru driven business process

Next step for me will be the implementation of a BlogParticipant for posting human oriented entries (no big work, it’s just an extension of the class AtomPubParticipant).

And the step after that is quite obvious : reverse the vapor, and expose the OpenWFEru resources for creation and modification via AtomPub.
It has already begun with exposing the activity of the engine, as a feed (rather read-only).

Mark will certainly be better than me at explaining the benefits of such a business process management system.

Written by John Mettraux

November 13, 2007 at 5:58 am

posting to wordpress via ruby and atompub

The ruby script here uploads posts to WordPress blogs via AtomPub.

Once you’ve set your blog coordinates in the script (around line 20), you can post like that :

echo "I love Ruby" | post.rb -t "title" -c "thoughts,ruby"

The script will publish your post and then ouptput the WordPress server reply.

#!/usr/bin/env ruby

# Copyright (c) 2007 John Mettraux
# Released under the MIT license
# http://www.opensource.org/licenses/mit-license.php

require 'optparse'
require 'net/http'

require 'rubygems'
require 'atom/entry' # sudo gem install atom-tools
require 'atom/collection'

    # a great thanks to the devs of all the libs used here

#
# some info about you and your blog

blog = "yourblog"
authorname = "Your Name"
username = "x"
password = "y"


bloguri = "http://#{blog}.wordpress.com"
base = "https://#{blog}.wordpress.com/wp-app.php"

#
# parse options

tags = []
title = nil
type = 'html'

opts = OptionParser.new
opts.banner = "Usage: post.rb [options]"
opts.separator ""
opts.separator "options :"

opts.on(
    "-c", 
    "--categories {list}", 
    "comma separated list of tags/categories") do |v|

    tags = v.split ","
end

opts.on(
    "-t", 
    "--title {title}", 
    "title for the post") do |v|

    title = v
end

opts.on(
    "-T", 
    "--type {html|xhtml|text}", 
    "type of the content. ('html' is the default).") do |v|

    type = v
end

opts.on(
    "-h", 
    "--help", 
    "displays this help") do

    puts
    puts opts.to_s
    puts
    exit 0
end

opts.parse ARGV


raise "please specify a title for the post with the -t option" \
    unless title

#
# gather content

content = ""
loop do
    line = STDIN.gets
    break unless line
    content += line
end

#
# create entry

entry = Atom::Entry.new
entry.title = title
#entry.updated = Time.now.httpdate
entry.updated!

author = Atom::Author.new
author.name = authorname
author.uri = bloguri
entry.authors << author

tags.each do |t|
    c = Atom::Category.new
    c["scheme"] = bloguri
    c["term"] = t.strip
    entry.categories << c
end

entry.content = content
entry.content["type"] = type if type

#puts entry.to_s

h = Atom::HTTP.new
h.user = username
h.pass = password
h.always_auth = :basic

c = Atom::Collection.new(base + "/posts", h)
res = c.post! entry

puts res.read_body

Next step for me, integration of the technique into ruote.

Updated 2007/11/11 : following the suggestions of Brendan Taylor, the author of atom-tools, I simplified the scripts, now relying on atom-tools for posting the entry.

Enjoy.

Written by John Mettraux

November 5, 2007 at 1:25 am

Posted in atom, atompub, rest, ruby, wordpress