View comments | RSS feed
API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking the Repository service using a Java client library

Quick Start: Invoking the Repository service using a Java client library
The following Java code example adds a form design (an XDP file) to the LiveCycle ES repository by using the Repository service’s Java client library. (See About the Repository Service.)
import java.io.FileInputStream;
import java.util.Properties;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
import com.adobe.repository.infomodel.Id;
import com.adobe.repository.infomodel.Lid;
 
import com.adobe.repository.infomodel.bean.RepositoryInfomodelFactoryBean;
import com.adobe.repository.infomodel.bean.Resource;
import com.adobe.repository.infomodel.bean.ResourceContent;
 
 
public class UploadForm {
 
	public static void main(String[] args) {
		
		try 
		{
		//This example will upload an XDP file to the LiveCycle Repository
		//Set LiveCycle ES service connection properties
		Properties connectionProps = new Properties();
		connectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");
		connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");          
		connectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");
		connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");
		connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");
		
		ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
		
		//Create a ResourceRepositoryClient object
		ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
		
		//Specify the parent path
		 String parentResourcePath = "/";
		
		//Create a RepositoryInfomodelFactoryBean object
		 RepositoryInfomodelFactoryBean infomodelFactory = new RepositoryInfomodelFactoryBean(null);
		
		//Create a Resource object to add to the Repository
		 Resource newResource = (Resource) infomodelFactory.newImage(
							new Id(), 
							new Lid(), 
							"Loan.xdp"); 
						  
		//Create a ResourceContent object that contains the content (file bytes)
		ResourceContent content = (ResourceContent) infomodelFactory.newResourceContent();
			
		//Create a Document that references an XDP file 
		//to add to the Repository
		FileInputStream myForm = new FileInputStream("C:\\Adobe\\Loan.xdp"); 
		Document form = new Document(myForm);
		
		//Set the description and the MIME type
		content.setDataDocument(form); 
		content.setMimeType("application/vnd.adobe.xdp+xml");
										
		//Assign content to the Resource object
		newResource.setContent(content) ;
			
		//Set a description of the resource
		newResource.setDescription("An XDP file");
					  
		//Commit to repository, and update resource
		//in memory (by assignment)
		Resource addResource = repositoryClient.writeResource(parentResourcePath, newResource);
		
		//Get the description of the returned Resource object
		System.out.println("The description of the new resource is "+addResource.getDescription());
		
		//Close the FileStream object
		myForm.close(); 
		
		} catch (Exception e) {
			 
			 e.printStackTrace();
		   }
		}
}
 

API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking the Repository service using a Java client library

Programming with LiveCycle ES (LiveDocs)
Adobe LiveCycle ES Update 1

Comments


No screen name said on Jun 22, 2009 at 4:51 AM :
Please add import/entry for commons-codec in the quick start of Invoking the Repository service using a Java client library

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000008.html