Home

Automated Business Logic

What is this?

An Ant task that allows for simple manipulation of Google Sites pages.

Requirements

You will need Google's gdata libraries. They are well documented here.

For convenience, all required libraries are also provided in the Downloads section.

Defining the task

You can define the task in Ant using something like:

    <taskdef name="gsite" classname="com.autobizlogic.googlesitesant.SitesTask">
        <classpath>
            <pathelement location="lib/googlesitesant-0.9.jar"/>
            <pathelement location="lib/gdata-core-1.0.jar"/>
            <pathelement location="lib/gdata-client-meta-1.0.jar"/>
            <pathelement location="lib/gdata-client-1.0.jar"/>
            <pathelement location="lib/gdata-media-1.0.jar"/>
            <pathelement location="lib/gdata-spreadsheet-3.0.jar"/>
            <pathelement location="lib/gdata-sites-meta-2.0.jar"/>
            <pathelement location="lib/gdata-sites-2.0.jar"/>
            <pathelement location="lib/guava-11.0.2.jar"/>
            <pathelement location="lib/mail.jar"/>
            <pathelement location="lib/ant.jar"/>
        </classpath>
    </taskdef>

Common parameters

  • action: one of "create" (create a new page), "update" (set the content of an existing page), "regexp" (replace a regexp in an existing page), or "get" (retrieve the content of an existing page)
  • domainName: your Google Sites domain name, e.g. acmecorp.com
  • siteName: the name of your Google Sites site, e.g. acme-corp
  • userId: your Google Sites user ID, e.g. jdoe@acme.com
  • password: your Google Sites password
  • contentFileName: the path to the file that contains the content you want to put in Google Sites

Creating a new page

Creates a new page with the given title and content.

    <target name="createPage">
        <gsite 
            action="create"
            domainName="automatedbusinesslogic.com"
            siteName="automated-business-logic"
            userId="jdoe@acme.com"
            password="secret"
            pageTitle="My test subpage"
            parentPageName="/my-grandparent-page/my-parent-page"
            contentFileName="test.txt" />
    </target>

Extra parameters:
- pageTitle: the title of the page to be created, e.g. "My new page"
- parentPageName: optional, the name of the parent page, e.g. "my-parent-page". If not
specified, the new page will be at the root of the site. This currently supports only
one level, i.e. the parent page must be a top page.

Updating an existing page

Finds the page with the given name, and replaces its content with the specified content.

    <target name="runUpdateTest">
        <gsite 
            action="update"
            domainName="automatedbusinesslogic.com"
            siteName="automated-business-logic"
            userId="jdoe@acme.com"
            password="secret"
            pageName="/my-existing-page"
            contentFileName="test.txt" />
    </target>

Extra parameters:
- pageName: the name of an existing page, e.g. "my-existing-page"

Replacing parts of an existing page

Finds the specified page, and replaces all instances of the specified regular expression
with the specified content.

<target name="runRegexpTest">
    <gsite 
        action="regexp"
        domainName="automatedbusinesslogic.com"
        siteName="automated-business-logic"
        userId="jdoe@acme.com"
        password="secret"
        pageName="/comments/my-existing-page"
        pattern="some regexp"
        contentFileName="row.html" />
</target>

Extra parameters:
- pattern: a regular expression

Retrieving the content of an existing page

Stores the content of the specified page in a local file. This is handy, for instance, if you want to use an existing page as a template (or whatever other purpose you might think of, really).

<target name="runRegexpTest">
    <gsite 
        action="get"
        domainName="automatedbusinesslogic.com"
        siteName="automated-business-logic"
        userId="jdoe@acme.com"
        password="secret"
        pageName="/my-parent-page/my-existing-page"
        contentFileName="row.html" />
</target>