Deleting Resources

You can programmatically delete resources from a given location in the repository by using the Repository service Java API or web service API.

When you delete a resource, the deletion is normally permanent, though in some cases ECM repositories may store the versions of the resource according to their history mechanisms. Therefore, when deleting a resource, it is important to be sure that you will never need that resource again. The common reasons for deleting a resource include the need to increase the available space in the database. You can delete a version of a resource, but if you do so you must specify the resource identifier, and not its logical identifier (LID) or path. If you delete a folder, everything in that folder, including subfolders and resources, will be automatically deleted.

Related resources are not deleted. For example, if you have a form that uses the logo.gif file, and you delete logo.gif, a relationship will be stored in the pending relationship table. As an alternative, for version deprecation, set the object status of the latest version to deprecated.

A deletion operation is not transaction-safe in ECM systems. For example, if you attempt to delete 100 resources and the operation fails on the 50th resource, the first 49 instances will be deleted but the rest will not be. Otherwise, the default behavior is rollback (non-commitment).

Note: When using the com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient.deleteResources() method with ECM repository (EMC Documentum Content Server and IBM FileNet P8 Content Manager), the transaction will not be rolled back if the deletion fails for one of the specified resources, which means that those files that have been deleted cannot be undeleted.
Note: For more information about the Repository service, see Services Reference for LiveCycle.

Summary of steps

To delete a resource, follow these steps:

  1. Include project files.

  2. Create a Repository service client.

  3. Specify the URI of the resource to be deleted.

  4. Delete the resource.

Include project files

Include the necessary files in your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, include the proxy files.

Create the service client

Before you can programmatically read a resource, you must establish a connection and provide credentials. This is accomplished by creating a service client.

Specify the URI of the resource to be deleted

Create a string containing the URI of the resource to be deleted. The syntax includes forward slashes, as in this example: "/path/resource". If the resource to be deleted is a folder, the deletion will be recursive.

Delete the resource

Invoke the Repository service method to delete the resource, specifying the URI.

Delete resources using the Java API

Delete a resource by using the Repository API (Java):

  1. Include project files

    Include client JAR files in your Java project’s class path.

  2. Create the service client

    Create a ResourceRepositoryClient object by using its constructor and passing a ServiceClientFactory object that contains connection properties.

  3. Specify the URI of the resource to be deleted

    Specify the URI of the resource to be retrieved. In this case, because the resource named testResourceToBeDeleted is in the folder named testFolder, its URI is /testFolder/testResourceToBeDeleted. The URI is stored as a java.lang.String object. In this example, the resource is first written to the repository, and its URI is retrieved. For more information about writing a resource, see Writing Resources.

  4. Delete the resource

    Invoke the ResourceRepositoryClient object’s deleteResource method and pass the URI of the resource as a parameter.

Delete resources using the web service API

Delete a resource by using the Repository API (web service):

  1. Include project files

    • Create a Microsoft .NET client assembly that consumes the Repository WSDL using Base64.

    • Reference the Microsoft .NET client assembly.

  2. Create the service client

    Using the Microsoft .NET client assembly, create a RepositoryServiceService object by invoking its default constructor. Set its Credentials property using a System.Net.NetworkCredential object containing the user name and password.

  3. Specify the URI of the resource to be deleted

    Specify the URI of the resource to be retrieved. In this case, because the resource named testResourceToBeDeleted is in the folder named testFolder, its URI is "/testFolder/testResourceToBeDeleted". In this example, the resource is first written to the repository, and its URI is retrieved. For more information about writing a resource, see Writing Resources.

  4. Delete the resource

    Invoke the RepositoryServiceService object’s deleteResources method and pass a System.String array containing the URI of the resource as the first parameter. Pass null for the second parameter.

// Ethnio survey code removed