|
|
The following Java code example deletes a resource called testResourceToBeDeleted in the repository.import java.util.*;import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;import com.adobe.repository.infomodel.*;import com.adobe.repository.infomodel.bean.*;import com.adobe.repository.RepositoryException;import com.adobe.idp.Document;public class DeleteResource {public static void main(String[] args) {// This example will delete a resource from the LiveCycle ES repository.// First, a resource will be created and written to the repository.// That resource will then be deleted from the repository.try{// Set the LiveCycle ES service connection propertiesProperties connectionProps = new Properties();connectionProps.setProperty("DSC_DEFAULT_SOAP_ENDPOINT", "http://localhost:8080");connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL", "SOAP");connectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");// Create the service client factoryServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);// Create a ResourceRepositoryClient object using the service client factoryResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);// Create a RepositoryInfomodelFactoryBean needed for creating resourcesRepositoryInfomodelFactoryBean repositoryInfomodelFactory = new RepositoryInfomodelFactoryBean(null);// Specify the URI of the target folder for writing the resourceString testFolderUri = "/testFolder";// Create the resource to be written to the folderResource testResource = repositoryInfomodelFactory.newResource(new Id(),new Lid(),"testResourceToBeDeleted");// Set the resource’s descriptiontestResource.setDescription("test resource to be deleted");// Write the resource to the folderrepositoryClient.writeResource(testFolderUri, testResource);// Retrieve the resource’s URIString resourceUri = testFolderUri + "/" + testResource.getName();// Retrieve the resource to verify that it was successfully writtenResource r = repositoryClient.readResource(resourceUri);// Print the resource verification messageSystem.out.println("Resource " + resourceUri + " was successfully written.");// Delete the resourcerepositoryClient.deleteResource(resourceUri);// Verify that the resource has been deletedtry {// Attempt to read the nonexistent resource,// which will cause an exception if the resource was deleted.Document d = repositoryClient.readResourceContent(resourceUri);} catch (RepositoryException re) {// Indicate successful deletionSystem.out.println("Resource " + resourceUri + " was successfully deleted.");}} catch (Exception e) {System.out.println("Exception thrown while trying to delete the resource" +e.getMessage());}}}
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Repository.18.19.html