<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1"
   xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.air.plugin.clearcaseucm" name="ClearCase UCM Snapshot" version="13"/>
    <description>
       The ClearCase UCM plugin automates populating a ClearCase workspace, creating a label, and publishing source changes to the Changes tab of the Build Life.
    </description>
    <tag>SCM/ClearCase UCM</tag>
    <server:plugin-type>Source</server:plugin-type>
  </header>

  <!-- ==================================== -->
  <!--  SCM STEPS                           -->
  <!-- ==================================== -->

  <step-type name="ClearCase Cleanup">
    <description>Perform a cleanup of the ClearCase working directory</description>
    <properties>
      <property name="source">
        <server:property-ui type="sourcePropSheetRef"
                            label="Source Config"
                            hidden="true"/>
      </property>
    </properties>
    <post-processing><![CDATA[
      if (properties.get("exitCode") != 0) {
          properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
      }
      else {
          properties.put("Status", "Success");
      }
   ]]></post-processing>

    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/commons-lang.jar:lib/CommonsUtil.jar"/>
      <arg file="clearcase_cleanup.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>

    <server:type>SCM_Cleanup</server:type>
    <server:validation language="javascript">
    </server:validation>
  </step-type>

  <step-type name="ClearCase Get Source">
    <description>This is a no-op</description>
    <properties>
      <property name="date">
          <server:property-ui type="textBox"
                              label="Date"
                              description="Date of source code to checkout ('yyyy-MM-dd HH:mm:ss z' OR 'E MMM dd HH:mm:ss zzz yyyy'
                              OR milliseconds since Unix Epoch). Defaults to the current time." />
        </property>
      <property name="source">
          <server:property-ui type="sourcePropSheetRef"
                              label="Source Config"
                              hidden="true"/>
        </property>
      </properties>
      <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>

    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="clearcase_populate.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>

    <server:type>SCM_Populate</server:type>
    <server:validation language="javascript">
    </server:validation>
  </step-type>

  <step-type name="ClearCase Changelog">
    <description>Perform a ClearCase changelog.</description>
    <properties>
      <property name="startRevision">
        <server:property-ui type="textBox"
                            label="Start Revision"
                            description="Start the changelog at this revision" />
      </property>
      <property name="endRevision">
        <server:property-ui type="textBox"
                            label="End Revision"
                            description="End the changelog at this revision" />
      </property>
      <property name="startDate">
        <server:property-ui type="textBox"
                            label="Start Date"
                            description="Start the changelog at this date ('yyyy-MM-dd HH:mm:ss z' OR
                            'E MMM dd HH:mm:ss zzz yyyy' OR milliseconds since Unix Epoch)" />
      </property>
      <property name="endDate">
        <server:property-ui type="textBox"
                            label="End Date"
                            description="End the changelog at this date ('yyyy-MM-dd HH:mm:ss z' OR
                            'E MMM dd HH:mm:ss zzz yyyy' OR milliseconds since Unix Epoch)" />
      </property>
      <property name="changesUrl">
        <server:property-ui type="textBox"
                            label="Changes URL"
                            hidden="true" />
      </property>
      <property name="source">
        <server:property-ui type="sourcePropSheetRef"
                            label="Source Config"
                            hidden="true"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>

    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="clearcase_changelog.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>

    <server:type>SCM_Changelog</server:type>
    <server:validation language="javascript">
    </server:validation>
  </step-type>

  <step-type name="ClearCase Quiet Period">
    <description>Check ClearCase history for quiet period detection and publish the results.</description>
    <properties>
      <property name="startDate">
        <server:property-ui type="textBox"
                            label="Start Date"
                            description="Start the changelog at this date ('yyyy-MM-dd HH:mm:ss z' OR
                            'E MMM dd HH:mm:ss zzz yyyy' OR milliseconds since Unix Epoch)" />
      </property>
      <property name="endDate">
        <server:property-ui type="textBox"
                            label="End Date"
                            description="End the changelog at this date ('yyyy-MM-dd HH:mm:ss z' OR
                            'E MMM dd HH:mm:ss zzz yyyy' OR milliseconds since Unix Epoch)" />
      </property>
      <property name="source">
        <server:property-ui type="sourcePropSheetRef"
                            label="Source Config"
                            hidden="true"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>

    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="clearcase_quietperiod.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>

    <server:type>SCM_QuietPeriod</server:type>
    <server:validation language="javascript">
    </server:validation>
  </step-type>

  <step-type name="ClearCase Label">
    <description>ClearCase Label Step</description>
    <properties>
      <property name="message" required="true">
        <server:property-ui type="textBox"
                            label="Message"
                            description="A message for the label" />
      </property>
      <property name="label" required="true">
        <server:property-ui type="textBox"
                            label="Tag"
                            description="The label name to create" />
      </property>
      <property name="source">
        <server:property-ui type="sourcePropSheetRef"
                            label="Source Config"
                            hidden="true"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>

    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="clearcase_label.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>

    <server:type>SCM_Label</server:type>
    <server:validation language="javascript">
    </server:validation>
  </step-type>

  <!-- ==================================== -->
  <!--  REPOSITORY                          -->
  <!-- ==================================== -->

  <server:property-group type="Repository" name="ClearCase UCM Snapshot Repository">
    <server:description>A placeholder for using the scm system. The repository is configured on a per workflow basis.</server:description>
    <server:property name="commandPath">
      <server:property-ui type="textBox"
                          label="Command Path"
                          description="The full path of the cleartool executable including the file name.
                          No value required if already on the path." />
    </server:property>
  </server:property-group>

  <!-- ==================================== -->
  <!--  SOURCE                              -->
  <!-- ==================================== -->

  <server:property-group type="Source" name="ClearCase UCM Snapshot Source Config">
    <server:property name="viewPath" required="true">
      <server:property-ui type="textBox"
                          label="View Location"
                          description="If strategy is Use Existing, the location of the view on the local machine.
                          Otherwise, The location of the view storage directory on the ClearCase server where the views
                          are stored. For Windows operating systems this should always be a UNC path."/>
    </server:property>
    <server:property name="viewName" required="true">
      <server:property-ui type="textBox"
                          label="View Name"
                          description="The name of the view."/>
    </server:property>
    <server:property name="streamName" required="true">
      <server:property-ui type="textBox"
                          label="Stream Name"
                          description="The name of the stream used by the view."/>
    </server:property>
    <server:property name="vobName">
      <server:property-ui type="textBox"
                          label="Project VOB Name"
                          description="The name of the Project VOB. It should begin with either \ or /. This is only used when creating a view. Ex: \pvob"/>
    </server:property>
    <server:property name="loadRules" required="true">
      <server:property-ui type="textAreaBox"
                          label="Paths"
                          description="Please list all the paths in your view in the form: VOB\path\to\files
                          Please specify one rule per line!
                          This information is used to detect changes, cleanup, and populate the snapshot."/>
    </server:property>
    <server:property name="checkoutWholeVob">
      <server:property-ui type="checkBox"
                          label="Populate Using All Components"
                          description="Check this box if you want the populate step to run the update command using only
                          the VOB name, which will pull files from all components within the VOB. If this is unchecked,
                          the update command will use each of the listed paths as the source to pull from instead of the entire VOB."
                          default-value="true" />
    </server:property>
    <server:property name="hostname">
      <server:property-ui type="textBox"
                          label="Hostname"
                          description="Provides the value for the -host parameter to be used in the mkview command."/>
    </server:property>
    <server:property name="globStorPath">
      <server:property-ui type="textBox"
                          label="Global Storage Path (gpath)"
                          description="Provides the value for the -gpath parameter to be used in the mkview command.
                          This parameter will be used presented to command verbatim so the viewname will not be appended.
                          This value cannot be empty if you supply a hostname."/>
    </server:property>
    <server:property name="hostStorPath">
      <server:property-ui type="textBox"
                          label="Host Storage Path (hpath)"
                          description="Provides the value for the -hpath parameter to be used in the mkview command.
                          This parameter will be used presented to command verbatim so the viewname will not be appended.
                          This value cannot be empty if you supply a hostname."/>
    </server:property>
    <server:property name="strategy" required="true">
      <server:property-ui type="selectBox"
                          label="View Creation Strategy"
                          description="The view strategy to use. Create Once: Create a new view only if one does not already exist.
                          Always Create: Create a new view with every build.
                          Use Existing: The view already exists and will be used every time."
                          default-value="useExisting"/>
      <server:value label="Create Once">createOnce</server:value>
      <server:value label="Always Create">alwaysCreate</server:value>
      <server:value label="Use Existing">useExisting</server:value>
    </server:property>
    <server:property name="tmode">
      <server:property-ui type="selectBox"
                          label="Tmode"
                          description="The Tmode to use. This is required if you are using a Populate step."/>
      <server:value label="Transparent">transparent</server:value>
      <server:value label="Insert">insert_cr</server:value>
      <server:value label="Strip">strip_cr</server:value>
    </server:property>
    <server:property name="ptime">
      <server:property-ui type="checkBox"
                          label="Use VOB Time"/>
    </server:property>
    <server:property name="useTags">
      <server:property-ui type="checkBox"
                          label="Use Tags"
                          description="Select here if you want your view to be globally created.
                          Having this option checked can cause problems with creating and dropping snapshots if you wish to have the same snapshot on multiple agents."/>
    </server:property>
    <server:property name="components">
      <server:property-ui type="textBox"
                          label="Components"
                          description="A comma separated list of the components you would like to baseline.
                          This field is only used with the Label step."/>
    </server:property>
    <server:property name="forceLabelOnNoChanges">
      <server:property-ui type="checkBox"
                          label="Force Label"
                          description="Select here if you want to create a baseline even if there are no changes. This is only used with the Label step."/>
    </server:property>
    <server:property name="labelBehavior">
      <server:property-ui type="selectBox"
                          label="Label Behavior"
                          description="Select the labeling behavior of the mkbl command. This is only used with the Label step."/>
      <server:value label="Default">default</server:value>
      <server:value label="Do Not Label">nlabel</server:value>
      <server:value label="Incremental">incremental</server:value>
      <server:value label="Full">full</server:value>
    </server:property>
    <server:property name="alternateView">
      <server:property-ui type="textBox"
                          label="Alternate View"
                          description="Specify an alternate view to be used for the baseline. This is only used with the Label step."/>
    </server:property>
    <server:property name="userExcludes">
      <server:property-ui type="textAreaBox"
                          label="Exclude Filters"
                          description="Exclude this list of usernames" />
    </server:property>
    <server:property name="fileFilters">
      <server:property-ui type="textAreaBox"
                          label="File Filters"
                          description="Restrict changelog to files matching these patterns. Lines start with + to include and - to exclude.
                          Wildcards *, **, and ? are allowed." />
    </server:property>
    <server:property name="repo" required="true">
      <server:property-ui type="repoPropSheetRef"
                          label="Repository"
                          description="Select the ClearCase Repository" />
    </server:property>
  </server:property-group>

</plugin>
