Delete a Section

Deleting a section is not as straightforward as deleting a content item or person. There may be content items that depend on its existence. Any content items that have this section as their home section must either be:

  • Moved to a new home section, or

  • Deleted together with the section

When a selection is deleted it is actually removed from the database - the operation is irreversible. Moreover, any content items that you delete along with it are also physically deleted. So deleting content items indirectly in this way is a much more significant operation than deleting them directly - an ordinary content item delete operation just changes the content item's state to deleted.

To start a delete operation, send an HTTP DELETE request to the same URI that would be used to retrieve it (see Retrieve a Section). For example:

curl --include -u user:password -X DELETE \
> http://host-ip-address/webservice/escenic/section/20
HTTP/1.1 303 See Other
Server: Apache-Coyote/1.1
Date: Tue, 20 Mar 2012 09:12:00 GMT
Location: http://host-ip-address/webservice/escenic/section/20/delete

The usual response to this request is 303 See Other, and includes a Location header as shown above. You must then:

  1. GET the resource referenced in the Location header:

    curl -u user:password http://host-ip-address/webservice/escenic/section/20/delete

    The resource will be an Atom entry containing an empty VDF payload document something like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <entry xmlns="http://www.w3.org/2005/Atom">
      <content type="application/vnd.vizrt.payload+xml">
        <vdf:payload xmlns:vdf="http://www.vizrt.com/types"
        model="http://host-ip-address/webservice/escenic/model/com.escenic.section.delete.20"/>
      </content>
    </entry>
  2. GET the VDF model document referenced by the VDF payload:

    curl -u user:password http://host-ip-address/webservice/escenic/model/com.escenic.section.delete.20

    This provides the information you need to be able to add correctly formatted information to the payload document:

    <?xml version="1.0" encoding="UTF-8"?>
    <vdf:model xmlns:vdf="http://www.vizrt.com/types">
      <vdf:schema>
        <vdf:fielddef name="com.escenic.section.delete.title"
                         label="Delete section"
                         mediatype="text/plain"
                         xsdtype="string"
                         contenteditable="false"/>
        <vdf:fielddef name="com.escenic.section.delete.replacement"
                         label="&lt;html&gt;The section with name &quot;Section Name&quot; contains 892 content item(s). You can&lt;br/&gt;choose a new home section for your content item(s) or allow the content item(s)&lt;br/&gt;to be deleted&lt;/html&gt;"
                         mediatype="text/plain"
                         xsdtype="string">
          <vdf:choice scope="limit">
            <vdf:collection src="escenic/section" select="title"/>
          </vdf:choice>
        </vdf:fielddef>
        <vdf:fielddef name="com.escenic.section.delete.confirmation"
                         label="Do you really want to delete this section?"
                         mediatype="text/plain"
                         xsdtype="boolean">
          <vdf:value>false</vdf:value>
        </vdf:fielddef>
      </vdf:schema>
    </vdf:model>
  3. Add information to the empty VDF payload document that complies with the schema in the model document. The VDF model specifies that the payload can contain three fields:

    • com.escenic.section.delete.title: This field is defined as read-only (contenteditable="false") so there is no point specifing a value for it.

    • com.escenic.section.delete.replacement: If you return the URL of another section in this field, then any content items belonging to the deleted section will be moved to it. If you leave the field empty or unspecified, then the content items will be deleted along with the section.

    • com.escenic.section.delete.confirmation : You must return true in this field to confirm deletion of the section. If you return false or specify nothing then the delete operation is canceled.

    This example will complete the section deletion and move all the orphaned content items to a new section:

    <?xml version="1.0" encoding="UTF-8"?>
    <entry xmlns="http://www.w3.org/2005/Atom">
      <content type="application/vnd.vizrt.payload+xml">
        <vdf:payload xmlns:vdf="http://www.vizrt.com/types"
        model="http://host-ip-address/webservice/escenic/model/com.escenic.section.delete.20">
          <vdf:field name="com.escenic.section.delete.replacement">
            <vdf:origin href="http://host-ip-address/webservice/escenic/section/15"/>
            <vdf:value>News</vdf:value>
          </vdf:field>
          <vdf:field name="com.escenic.section.delete.confirmation">
            <vdf:value>true</vdf:value>
          </vdf:field>
        </vdf:payload>
      </content>
    </entry>
  4. PUT the resource back to the same location. If you saved the Atom entry in a file called my-delete-section.xml, for example, then you could use the following curl command:

    curl --include -u user:password -X PUT -H "Content-Type: application/atom+xml" \
    > http://host-ip-address/webservice/escenic/section/20/delete --upload-file my-delete-section.xml
    HTTP/1.1 100 Continue
    
    HTTP/1.1 204 No Content
    Server: Apache-Coyote/1.1
    Date: Tue, 19 Feb 2013 05:50:26 GMT