Take a survey

API Quick Starts (Code Examples) > Repository Service API Quick Starts > Quick Start: Creating a folder using the Java API

Quick Start: Creating a folder using the Java API
The following Java code example creates a folder called testFolder 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.*;
 
 
public class CreateFolder {
 
	public static void main(String[] args) {
 
		// This example will create a folder in the LiveCycle ES repository
		try 
		{
			// Set the LiveCycle ES service connection properties
			Properties 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 factory
			ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
			
			// Create a ResourceRepositoryClient object using the service client factory
			ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
 
			// Create a RepositoryInfomodelFactoryBean needed for creating resources
			RepositoryInfomodelFactoryBean repositoryInfomodelFactory = new RepositoryInfomodelFactoryBean(null);
			
			// Create a folder
			ResourceCollection testFolder = repositoryInfomodelFactory.newResourceCollection(
				new Id(), 
				new Lid(), 
				"testFolder"
			);
 
			// Set the folder’s description
			testFolder.setDescription("test folder");
 
			// Write the folder to the repository
			repositoryClient.writeResource("/", testFolder);
 
			// Retrieve the folder’s URI
			String testFolderUri = "/" + testFolder.getName();
 
			// Print folder verification message
			System.out.println("Folder " + testFolderUri + " was successfully created.");
 
		} catch (Exception e) {
				System.out.println(
					"Exception thrown while trying to create the folder" +
					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.2.html