Or, wiping out all the data in an ATG repository. Sometimes you have to do it, for example to reset some tables to start from scratch: ATG provides a documented operational tag remove-all-items that can be written in an XML file executed with startSQLRepository. This tag demands an item-descriptor attribute, but to completely wipe out a repository you’ll have to copy/paste the descriptor names from the repository definition file.

Here’s a very quick and dirty page to produce the XML file:

<%@ page contentType="text/xml;charset=UTF-8" import="atg.repository.Repository" %>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE gsa-template SYSTEM "dynamosystemresource:/atg/dtds/gsa/gsa_1.0.dtd">
<gsa-template>

<%@ taglib uri="/dspEL" prefix="dsp" %>

<%--
  Generates an XML file that contains the "remove-all-items" tags to remove all items of all item
  descriptors in the repository component passed as the repository parameter.
--%>

<dsp:droplet name="/atg/dynamo/droplet/IsEmpty">
  <dsp:param name="value" param="repository" />
  <dsp:oparam name="false">
    <%
      // we need a Dynamo request to be able to resolveName()
      DynamoHttpServletRequest req = atg.servlet.ServletUtil.getDynamoRequest(request);
      Repository rep = (Repository)req.resolveName(request.getParameter("repository"));
      if (rep != null) {
        String[] itemDescNames = rep.getItemDescriptorNames();
        if (itemDescNames != null) {
          for (int i = 0; i < itemDescNames.length; i++) {
            // emit the remove-all-items tag
            out.print("<remove-all-items item-descriptor=\"" + itemDescNames[i] + "\" />" + "\r\n");
          }
        }
      }
    %>
  </dsp:oparam>
</dsp:droplet>

</gsa-template>

Save this page in a webapp and call it with specifying the repository to be wiped out:

http://localhost:8840/default/remove-all-items.jsp?repository=/TestRepository

You can then save the result in an XML file in the localconfig directory and execute it with:

bin/startSQLRepository -m module -repository /TestRepository /test-repository-remove-all-items.xml

See again the documentation for the system property to set to make it all work.