Activity - fileWritingActivity

Activity Type: File

Description

The use of this activity requires the jar: "jakarta-oro-2.0.8.jar" to be loaded on the server, for the handling of regular expressions.

Edit the contents of a file:

Examples

<!-- Insert "!!" at the first character position of the file -->
<fileWritingActivity name="insert">
  <file>path/file.ext</file>
  <locate>
    <offset>1</offset>
  </locate>
  <insert text="!!"/>
  <output name="out"/>
</fileWritingActivity>
<!-- Insert "!!" at the beginning of the file -->
<fileWritingActivity name="insert">
  <file>path/file.ext</file>
  <locate>
    <offset>start</offset>
    <perLine>true</perLine>
  </locate>
  <insert text="!!" />
  <output name="out"/>
</fileWritingActivity>
<!-- Append "!!" to the end of the file -->
<fileWritingActivity name="append">
  <file>path/file.ext</file>
  <append text="!!"/>
  <output name="out"/>
</fileWritingActivity>
<!-- Append "!!" to the end of each line -->
<fileWritingActivity name="append">
  <file>path/file.ext</file>
  <locate>
    <perLine>true</perLine>
  </locate>
  <append text="!!"/>
  <output name="out"/>
</fileWritingActivity>
<!-- Delete characters 1 to 4 inclusive from the file -->
<fileWritingActivity name="delete">
  <file>path/file.ext</file>
  <locate>
    <offset>1</offset>
    <length>3</length>
  </locate>
  <delete/>
  <output name="out"/>
</fileWritingActivity>
<!-- Delete the first three occurrences of the string "zonk" -->
<fileWritingActivity name="delete">
  <file>path/file.ext</file>
  <locate>
    <regexp>zonk</regexp>
    <match>1-3</match>
  </locate>
  <delete/>
  <output name="out"/>
</fileWritingActivity>
<!-- Replace the first, fourth, ninth, sixteenth occurrences -->
<!-- of the string "zonk"                                    -->
<fileWritingActivity name="matchSequence">
  <file>path/file.ext</file>
  <locate>
    <regexp>zonk</regexp>
    <match>1:4:9:...</match>
    <perLine>false</perLine>
  </locate>
  <replace text="!!" />
  <output name="out"/>
</fileWritingActivity>
<!-- Replace the third to final characters of the file with -->
<!-- input from the "data" activity output stream.          -->
<fileWritingActivity name="replaceOffsetPerLine">
  <file>path/file.ext</file>
  <locate>
    <offset>3</offset>
    <length>toEnd</length>
    <perLine>false</perLine>
  </locate>
  <replace from="data"/>
  <output name="out"/>
</fileWritingActivity>

Specification

Element fileWritingActivity:

Input and Output Types

Warning to Service Deployers

This activity can be used by clients to potentially access any directory on your server below that exposed by the associated OGSA-DAI service.

Data Resource Accessor

This activity requires a data resource accessor that implements the following interface: uk.org.ogsadai.dataresource.FileAccessProvider

XML Schema

OGSA-DAI/schema/ogsadai/xsd/activities/file_writing.xsd

Class

uk.org.ogsadai.activity.files.FileWritingActivity

Client Toolkit Classes