Skip to main content

 Version 5

Legacy documentation for PageSeeder v5

Task ps-request

This task has been removed as of PageSeeder v6. Use Task request instead.

Allows Ant scripts to request data and write it to a file in a designated location.

Definition

<ps:ps-request
           jsessionid="[jsessionid]"
                       port="[port]"
                       host="[host]"
           siteprefix="[siteprefix]"
     servletprefix="[servletprefix]"
            servlet="[servlet path]"
                   output="[output]"
                   method="[method]">
      <parameter name="[param name]"
               value="[param value]"/>

                                 or

 <fileset dir="[requests directory]"
           includes="[requests.xml]" />
</ps:ps-request>

Attributes

AttributeDescriptionRequired
jsessionidUsed for authentication, this attribute is optional. However, it will always be used if specified.Yes, unless username/password or propertiesfile are specified
usernameIf jsessionid is not specified this can be used for authentication.Yes, unless jsessionid or propertiesfile are specified
passwordIf jsessionid is not specified this can be used for authentication.Yes, unless jsessionid or propertiesfile are specified
propertiesfileDescribes the location of the properties file for connecting to the PageSeeder Server.
The attribute value can be; the full path of the file, the relative path (with the base directory the location of the Ant script), or the file name (in which case the file MUST be located on the classpath).
Yes, unless (jsessionid or username/password) and host are specified
portThe port address of the PageSeeder Server - default: 80
(used when no properties file is specified)
No
hostThe host name of the PageSeeder Server
(used when no properties file is specified)
Yes, unless propertiesfile is specified
siteprefixThe PageSeeder site prefix defined - default: /ps
(used when no properties file is specified)
No
servletprefixThe PageSeeder servlet prefix defined - for services use /service - default: /servlet
(used when no properties file is specified)
No
outputSpecifies the path of the file to write the response toYes
servletSpecifies the servlet to be executed or the service URL  if servletprefix=/serviceYes
methodSpecifies the method of the request POST or GET.Yes

Nested Elements

Nested elements are parameters that are added to the Request when connecting to the PageSeeder server. For the two types of Request tasks, nested elements work as follows:

Single Request

Each <parameter> element has attributes for @name and @value:

       <parameter name="[param name]" value="[param value]" />

Multiple Requests

All Requests are made to the same servlet with different Parameter elements expressed in one or more Request Files. A Request File is a UTF-8-encoded XML document that expresses the parameters for a single request in the following syntax:

<request>
  <parameter name="x">a</parameter>
  <parameter name="y">b</parameter>
</request>

Optionally a <servlet path="p"/> element can be added to change the servlet path for a request.

<request>
  <servlet path="p"/>
  <parameter name="x">a</parameter>
  <parameter name="y">b</parameter>
</request>

Processed in alphabetical path order, each Request has a Response written to the output file as follows:

<responses>
  <response filepath="z/d.xml">
  ...
  </response>
  <response filepath="z/e.xml">
  ...
  </response>
</responses>

Example Scripts – Stand-alone

Get the content of an XLink

<ps:ps-request
    servlet="com.pageseeder.XLinkThread" method="GET"
    host="mycompany.com" output="c:\output\results.xml"
    username="jsmith" password="xyz" >
  <parameter name="xl" value="123"/>
</ps:ps-request>

Create multiple comments using a service

<ps:ps-request
    servletprefix="/service" servlet="/comments/forurl" method="POST"
    host="mycompany.com" output="c:\output\results.xml"
    username="jsmith" password="xyz" >
  <fileset dir="c:\input\comments">
    <include name="*.*"/>
  </fileset>
</ps:ps-request>

Files in c:\input\comments:

request1.xml

<?xml version="1.0" encoding="utf-8" ?>
<request>
  <parameter name="url">http://www.mysite.com/</parameter>
  <parameter name="title">My Comment</parameter>
  <parameter name="groups">test-mygroup</parameter>
  <parameter name="content">Hello world!</parameter>
  <parameter name="authorname">John Jones</parameter>
</request>

request2.xml

<?xml version="1.0" encoding="utf-8" ?>
<request>
  <parameter name="url">http://www.mysite.com/</parameter>
  <parameter name="title">My Comment 2</parameter>
  <parameter name="groups">test-mygroup</parameter>
  <parameter name="content">Hello again world!</parameter>
  <parameter name="authorname">John Jones</parameter>
</request>

Edit a Document  Section

Useful for programmatically editing documents but it requires knowing the ID of the Fragments. This typically means defining the Fragment ID from the start rather than using the PageSeeder-generated ID.

<input message="URI ID for document:" addproperty="uriid"/>
<input message="Fragment ID in document:" addproperty="fragmentid"/>
<input message="Group Name:" addproperty="groupname"/>
<ps:ps-request
    servlet="com.pageseeder.InsertEditXLink" method="POST"
    host="mycompany.com" output="c:\output\results.xml"
    username="jsmith" password="xyz" >
  <parameter name="uri" value="${uriid}"/>
  <parameter name="loc" value="${fragmentid}"/>
  <parameter name="role" value="Documentation"/>
  <parameter name="contentType" value="text/xml"/>
  <parameter name="content" value="<body&gt;<para&gt;New 
content</para&gt;</body&gt;"/>
  <parameter name="groups" value="${groupname}"/>
  <parameter name="title" value="Document Change"/>
</ps:ps-request>

Example Scripts – PS Publish

Get the content of an XLink

<input message="Comment ID:" addproperty="xlinkid"/>
<ps:ps-request
    servlet="com.pageseeder.XLinkThread" method="GET"
    output="${ps-working}/results.xml"
    jsessionid="${ps-jsessionid}" host="${ps-host}" port="${ps-port}"
    servletPrefix="${ps-servletPrefix}" sitePrefix="${ps-sitePrefix}" >
  <parameter name="xl" value="${xlinkid}"/>
</ps:ps-request>

Create A Task

It is important to note that there is no validation of the values that correspond to <name> attributes such as @status and @priority. The allowable values for these fields can be edited using Group – Properties but it is the developers responsibility to ensure integrity between the Properties and their code.

<ps:ps-request host="${ps-host}" port="${ps-port}" 
      sitePrefix="${ps-sitePrefix}" jsessionid="${ps-jsessionid}"
      output="${ps-working}/psrequest/request-response.xml"
      method="POST" servletPrefix="${ps-servletPrefix}"
      servlet="com.pageseeder.InsertXLinkFormDo">
      <parameter name="role" value="Comment"/>
      <parameter name="groupName" value="${ps-groupName}"/>
      <parameter name="groups" value="${ps-groupName}"/>
      <parameter name="status" value="Open"/>
      <parameter name="priority" value="Low"/>
      <parameter name="broadcast" value="Yes"/>
      <parameter name="title" value="(Task) -  ${task-name}
                                      Finish on ${current.time}"/>
      <parameter name="content" value=" ${task-name}
                                      Finished on ${current.time}"/>
      <parameter name="labels" value="publish-task"/>
    </ps:ps-request>
Created on , last edited on