Repository Service API Quick Starts repository-service-api-quick-starts
Samples and examples in this document are only for AEM Forms on JEE environment.
The following Quick Starts are available for the AEM Forms Repository service.
Quick Start (SOAP mode): Creating a folder using the Java API
Quick Start (SOAP mode): Writing a resource using the Java API
Quick Start (SOAP mode): Listing resources using the Java API
Quick Start (SOAP mode): Reading a resource using the Java API
Quick Start (SOAP mode): Updating a resource using the Java API
Quick Start (SOAP mode): Searching for resources using the Java API
Quick Start (SOAP mode): Creating relationships between resources using the Java API
Quick Start (SOAP mode): Locking a resource using the Java API
Quick Start (SOAP mode): Managing access control lists using the Java API
Quick Start (SOAP mode): Deleting a resource using the Java API
AEM Forms operations can be performed using the AEM Forms strongly typed API and the connection mode should be set to SOAP
Applications/FormsApplication
Most AEM Forms repository service quick starts interact with an application named Applications/FormsApplication,
as shown in the following illustration.
The folder FormsFolder is a location in the AEM Forms repository. You can, for example, programmatically add this folder to Applications/FormsApplication
. (See Quick Start (SOAP mode): Creating a folder using the Java API.)
The path to a resource in the AEM Forms repository is:
Applications/Application-name/Application-version/Folder.../Filename
https://[server name]:[server port]/repository
. You can verify quick start results by using a web browser. For example, if you add content to the AEM Forms Repository, you can see the content in a web browser.Quick Start (SOAP mode): Creating a folder using the Java API quick-start-soap-mode-creating-a-folder-using-the-java-api
The following Java code example creates a folder called FormsFolder in the following location /Applications/FormsApplication/1.0/
. (See Creating Folders.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
β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 quick start creates a folder in the AEM Forms repository
β //Ensure that you create a AEM Forms application named FormsApplication using Workbench
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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 in a AEM Forms application named Application/FormsApplication
β ResourceCollection folder = repositoryInfomodelFactory.newResourceCollection(
β new Id(),
β new Lid(),
β "FormsFolder"
β );
β // Set the folderβs description
β folder.setDescription("A folder to store forms");
β // Write the folder to the repository
β Resource newFolder = repositoryClient.writeResource("/Applications/FormsApplication/1.0/", folder);
β // Retrieve the folderβs identifier value
β String msg = "The identifier value of the new folder is" + newFolder.getId();
β // Print folder verification message
β System.out.println(msg);
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to create the folder" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Writing a resource using the Java API quick-start-soap-mode-writing-a-resource-using-the-java-api
The following Java code example writes a resource called loan.xdp in the repository. The resource is added to the /Applications/FormsApplication/1.0/FormsFolder
location. (See Writing Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.io.FileInputStream;
βimport java.util.Properties;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
β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 WriteFile {
β // This quick start writes Loan.xdp to Applications/FormsApplication/1.0/FormsFolder
β //Ensure that you create a AEM Forms application named FormsApplication using Workbench
β public static void main(String[] args) {
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create a ResourceRepositoryClient object
β ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
β //Specify the parent path
β String parentResourcePath = "/Applications/FormsApplication/1.0/FormsFolder";
β //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:\\ΓΫΆΉΚΣΖ΅\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();
β }
β }
β}
Quick Start (SOAP mode): Listing resources using the Java API quick-start-soap-mode-listing-resources-using-the-java-api
The following Java code example lists resources that are in Applications/FormsApplication/1.0/FormsFolder
. (See Listing Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.Resource;
β//This quick start lists the content in Applications/FormsApplication/1.0/FormsFolder
β//Ensure that you create a AEM Forms application named Applications/FormsApplication using Workbench
βpublic class ListFiles {
β public static void main(String[] args) {
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // List all the files in the
β String resourceFolderPath = "/Applications/FormsApplication/1.0/FormsFolder";
β // Retrieve the list of resources under the folder path
β List members = repositoryClient.listMembers(resourceFolderPath);
β // Print out the resources that were found
β System.out.println("The following resources were found:");
β for (int i = 0; i < members.size(); i++) {
β Resource r = (Resource)(members.get(i));
β System.out.println(
β "Resource name: " +
β r.getName() +
β " Resource Description: " +
β r.getDescription()
β );
β }
β } catch (Exception e) {
β e.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Reading a resource using the Java API quick-start-soap-mode-reading-a-resource-using-the-java-api
The following Java code example reads a resource called Loan.xdp from the repository. The XDP file is in /Applications/FormsApplication/1.0/FormsFolder/
. (See Reading Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.*;
β//This quick start retrieves Loan.xdp from Applications/FormsApplication/1.0/FormsFolder
β//Ensure that you create a AEM Forms application named FormsApplication using Workbench
βpublic class ReadFile {
β public static void main(String[] args) {
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the path to the Loan.xdp
β String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder/Loan.xdp";
β // Retrieve the XDP file
β Resource r = repositoryClient.readResource(resourceUri);
β // Print the resource verification message
β System.out.println(
β "Resource " +
β resourceUri +
β " was successfully retrieved." +
β "Resource content contains " +
β r.getContent().getDataDocument().length() +
β " bytes."
β );
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to read the file" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Updating a resource using the Java API quick-start-soap-mode-updating-a-resource-using-the-java-api
The following Java code example updates /Applications/FormsApplication/1.0/FormsFolder
by modifying its description. (See Updating Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.*;
βimport java.util.*;
β//This quick start updates the description of Applications/FormsApplication/1.0/FormsFolder
β//Ensure that you create a AEM Forms application named Applications/FormsApplication using Workbench
βpublic class UpdateResource {
β public static void main(String[] args) {
β // This example will update a resource in the AEM Forms repository
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the resource to update
β String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder";
β // Retrieve the resource
β Resource resource = repositoryClient.readResource(resourceUri);
β // Update its description
β resource.setDescription("This folder stores XDP files");
β // Update the resource in the repository
β Resource updatedResource = repositoryClient.updateResource(
β resourceUri,
β resource,
β true
β );
β // Print the resource verification message
β System.out.println(
β "Resource " +
β resourceUri +
β "version " +
β updatedResource.getMajorVersion() +
β "." +
β updatedResource.getMinorVersion() +
β " was successfully updated."
β );
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to update the resource" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Searching for resources using the Java API quick-start-soap-mode-searching-for-resources-using-the-java-api
The following Java code example searches for Loan.xdp in Applications/FormsApplication/1.0/FormsFolder
. (See Searching for Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.*;
βimport com.adobe.repository.query.*;
βimport com.adobe.repository.query.sort.*;
β//This quick start searches for Loan.xdp in Applications/FormsApplication/1.0/FormsFolder
β//Ensure that you create a AEM Forms application named FormsApplication using Workbench
βpublic class SearchResources {
β public static void main(String[] args) {
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the target folder
β String testFolderUri = "/Applications/FormsApplication/1.0/FormsFolder";
β // Specify the attribute name for which to search
β String name = "Loan.xdp";
β // Create a Query used in the search
β Query query = new Query();
β Query.Statement statement = new Query.Statement(
β Resource.ATTRIBUTE_NAME,
β Query.Statement.OPERATOR_BEGINS_WITH,
β name
β );
β statement.setNamespace(ResourceProperty.RESERVED_NAMESPACE_REPOSITORY);
β query.addStatement(statement);
β // Create the sort order used in the search
β SortOrder sortOrder = new SortOrder();
β SortOrder.Element element = new SortOrder.Element(Resource.ATTRIBUTE_NAME, true);
β sortOrder.addSortElement(element);
β // Search for the resources
β List listProperties = repositoryClient.searchProperties(
β testFolderUri,
β query,
β ResourceCollection.DEPTH_INFINITE,
β 0,
β 10,
β sortOrder
β );
β // Display the resources that were found
β System.out.println("The following resources were found:");
β for (int i = 0; i < listProperties.size(); i++) {
β Resource r = (Resource)(listProperties.get(i));
β System.out.println(r.getName());
β }
β } catch (Exception e) {
β System.out.println(
β "An exception occurred while attempting to search for resources." +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Creating relationships between resources using the Java API quick-start-soap-mode-creating-relationships-between-resources-using-the-java-api
The following Java code example creates a relationship between two resources in the AEM Forms repository. (See Creating Resource Relationships.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.*;
βimport com.adobe.repository.infomodel.bean.*;
βpublic class CreateRelationship {
β public static void main(String[] args) {
β // This example creates a relationship between two resources in the AEM Forms repository.
β // First, two resources are created.
β // A dependence relationship between the two resources will then be established and verified.
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the target folder for writing the resource
β String testFolderUri = "/Applications/FormsApplication/1.0/FormsFolder";
β // Create the resources to be written to the folder
β Resource testResource1 = repositoryInfomodelFactory.newResource(
β new Id(),
β new Lid(),
β "FormFolderA"
β );
β Resource testResource2 = repositoryInfomodelFactory.newResource(
β new Id(),
β new Lid(),
β "FormFolderB"
β );
β // Set the resourcesβ descriptions
β testResource1.setDescription("test resource1");
β testResource2.setDescription("test resource2");
β // Write the resources to the folder
β repositoryClient.writeResource(testFolderUri, testResource1);
β repositoryClient.writeResource(testFolderUri, testResource2);
β // Retrieve the resourcesβ URIs
β String resourceUri1 = testFolderUri + "/" + testResource1.getName();
β String resourceUri2 = testFolderUri + "/" + testResource2.getName();
β // Retrieve the resources to verify that they were successfully written
β Resource r1 = repositoryClient.readResource(resourceUri1);
β Resource r2 = repositoryClient.readResource(resourceUri2);
β // Create a relationship between the two resources
β repositoryClient.createRelationship(
β resourceUri1,
β resourceUri2,
β Relation.TYPE_DEPENDANT_OF,
β true
β );
β // Verify the relationship
β List relations = repositoryClient.getRelated(
β resourceUri1,
β true,
β Relation.TYPE_DEPENDANT_OF
β );
β // Print the relationship
β for (int i = 0; i < relations.size(); i++) {
β Resource r = (Resource)(relations.get(i));
β System.out.println("Related resource: " + r.getName());
β }
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to create the relationship" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Locking a resource using the Java API quick-start-soap-mode-locking-a-resource-using-the-java-api
The following Java code example locks /Applications/FormsApplication/1.0/FormsFolder/Loan.xdp. (See Locking Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.*;
βpublic class LockFile {
β public static void main(String[] args) {
β // This example will lock and unlock a resource in the AEM Forms repository.
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the resource to lock
β String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder/Loan.xdp";
β // Lock the resource
β repositoryClient.lockResource(
β resourceUri,
β Lock.SCOPE_EXCLUSIVE,
β Lock.DEPTH_ZERO
β );
β // Retrieve the locks on the resource
β List locks = repositoryClient.getLocks(resourceUri);
β // Print out the locks for the resource
β System.out.println("The following locks now exist for the resource:");
β for (int i = 0; i < locks.size(); i++) {
β Lock l = (Lock)(locks.get(i));
β System.out.println(
β "Lock owner: " +
β l.getOwnerUserId() +
β " Lock depth: " +
β l.getDepth() +
β " Lock scope: " +
β l.getType()
β );
β }
β // Unlock the resource
β String lockToken = repositoryClient.unlockResource(resourceUri);
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to lock the file" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Managing access control lists using the Java API quick-start-soap-mode-managing-access-control-lists-using-the-java-api
The following Java code example reads and creates access control lists (ACLs) in the repository.
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport com.adobe.repository.infomodel.bean.*;
βpublic class UseACL {
β public static void main(String[] args) {
β // This example will read and create access control lists for resources in the AEM Forms repository.
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the resource to be used
β String resourceUri = "/Applications/FormsApplication";
β // Retrieve the access control list for the resource
β AccessControlList acl = repositoryClient.readAccessControlList(resourceUri);
β // Retrieve a list of the users having access permissions
β List users = acl.getUsersWithPermissions();
β // Print out the list of users
β System.out.println("The following users have permissions:");
β for (int i = 0; i < users.size(); i++) {
β String user = (String)(users.get(i));
β System.out.println("User identifier: " + user);
β }
β // Set up a new access control list
β acl = new AccessControlList();
β // Retrieve a user identifier to be used in the access control list
β String userId = (String)(users.get(0));
β // Create traversal permissions for the user
β List permissions = new ArrayList();
β permissions.add(AccessControlEntry.READ_METADATA_USER_PERM);
β permissions.add(AccessControlEntry.READ_CONTENT_USER_PERM);
β acl.setPermissionsForUser(userId, permissions);
β // Set the access control list for the folder
β repositoryClient.writeAccessControlList(resourceUri, acl, true);
β // Print out confirmation message
β System.out.println("User " + userId + " has traversal permissions for the folder");
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to manage access control lists" +
β e.getMessage()
β );
β }
β }
β}
Quick Start (SOAP mode): Deleting a resource using the Java API quick-start-soap-mode-deleting-a-resource-using-the-java-api
The following Java code example deletes Loan.xdp from Applications/FormsApplication/1.0/FormsFolder
. If this XDP file is not in this folder, an exception is thrown. (See Deleting Resources.)
β/*
β * This Java Quick Start uses the following JAR files
β * 1. adobe-repository-client.jar
β * 2. adobe-livecycle-client.jar
β * 3. adobe-usermanager-client.jar
β * 4. adobe-utilities.jar
β * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
β * on JBoss)
β * 6. commons-code-1.3.jar
β * 7. jacorb.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β * 8. jnp-client.jar (use a different JAR file if the Forms Server is not deployed on JBoss)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β * The adobe-utilities.jar file is in the following path:
β * <install directory>/sdk/client-libs/jboss
β *
β * The jboss-client.jar file is in the following path:
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
β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;
β// This quick start deletes Loan.xdp from Applications/FormsApplication/1.0/FormsFolder
β//If this XDP is not in this folder, an exception is thrown
β//Ensure that you create a AEM Forms application named FormsApplication using Workbench
βpublic class DeleteResource {
β public static void main(String[] args) {
β try
β {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.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);
β // Specify the URI of the target folder from which the resource is deleted
β String testFolderUri = "/Applications/FormsApplication/1.0/FormsFolder";
β // Create the resource to be written to the folder
β Resource testResource = repositoryInfomodelFactory.newResource(
β new Id(),
β new Lid(),
β "Loan.xdp"
β );
β // Retrieve the resourceβs URI
β String resourceUri = testFolderUri + "/" + testResource.getName();
β // Retrieve the resource to verify that it exists
β Resource r = repositoryClient.readResource(resourceUri);
β // Print the resource verification message
β System.out.println(r.getName() +" is about to be deleted");
β // Delete the resource
β repositoryClient.deleteResource(resourceUri);
β } catch (Exception e) {
β System.out.println(
β "Exception thrown while trying to delete the resource" +
β e.getMessage()
β );
β }
β }
β}