Quick Start (SOAP mode): Creating Application Version using the Java API

The following Java code example creates an application using the JAVA API.

/* 
 * This Java Quick Start uses the SOAP mode and contains the following JAR files 
 * in the class path: 
 * 1. adobe-livecycle-client.jar 
 * 2. adobe-usermanager-client.jar 
 * 3. adobe-application-remote-client.jar 
 * 4. adobe-repository-client.jar 
 * 5. activation.jar (required for SOAP mode) 
 * 6. axis.jar (required for SOAP mode) 
 * 7. commons-codec-1.3.jar (required for SOAP mode) 
 * 8. commons-collections-3.1.jar  (required for SOAP mode) 
 * 9. commons-discovery.jar (required for SOAP mode) 
 * 10. commons-logging.jar (required for SOAP mode) 
 * 11. dom3-xml-apis-2.5.0.jar (required for SOAP mode) 
 * 12. jaxen-1.1-beta-9.jar (required for SOAP mode) 
 * 13. jaxrpc.jar (required for SOAP mode) 
 * 14. log4j.jar (required for SOAP mode) 
 * 15. mail.jar (required for SOAP mode) 
 * 16. saaj.jar (required for SOAP mode) 
 * 17. wsdl4j.jar (required for SOAP mode) 
 * 18. xalan.jar (required for SOAP mode) 
 * 19. xbean.jar (required for SOAP mode) 
 * 20. xercesImpl.jar (required for SOAP mode) 
 *  
 * These JAR files are located in the following path: 
 * <install directory>/sdk/client-libs/common 
 *  
 *   
 * SOAP required JAR files are located in the following path: 
 * <install directory>/sdk/client-libs/thirdparty 
 *  
 * 
 */ 
package com.adobe.idp.dsc.applicationmanager; 
import java.util.Properties; 
import java.util.Random; 
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory; 
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties; 
import com.adobe.livecycle.applicationmanager.client.ApplicationManagerClient; 
import com.adobe.repository.bindings.ResourceRepositoryDelegate; 
import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient; 
public class CreateApplicationVersion_SOAP { 
    private static String applicationFolder = "Applications"; 
    private static String defaultAppVersion = "1.0"; 
    public static void main(String[] args) { 
        // Set connection properties required to invoke AEM Forms 
        Properties connectionProps = new Properties(); 
        connectionProps.setProperty("DSC_DEFAULT_SOAP_ENDPOINT", 
                "http://[server]:[port]"); 
        connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL", 
                ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL); 
        connectionProps.setProperty("DSC_SERVER_TYPE", 
                ServiceClientFactoryProperties.DSC_JBOSS_SERVER_TYPE); 
        connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator"); 
        connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password"); 
        // Create ServiceClientFactory object 
        ServiceClientFactory myFactory = ServiceClientFactory 
                .createInstance(connectionProps); 
        // Create ApplicationManagerClient object 
        ApplicationManagerClient appClient = new ApplicationManagerClient( 
                myFactory); 
        // Create ResourceRepositoryDelegate object 
        ResourceRepositoryDelegate repositoryClient = new ResourceRepositoryClient( 
                myFactory); 
        final Random num = new Random(); 
        String appName = "App" + num.nextInt(); 
        String newAppName = null; 
        try { 
            // Create application with default application version 
            newAppName = appClient.createApplication(appName); 
            if (repositoryClient.resourceExists("/" + applicationFolder + "/" 
                    + appName.toString() + "/" + defaultAppVersion)) { 
                System.out.println("Application with name: " + appName + "/" 
                        + defaultAppVersion + " is created succesfully!"); 
            } 
        } catch (Exception e) { 
            e.printStackTrace(); 
        } 
        try { 
            // Create version of the new application 
            appName = appClient.createApplicationVersion(newAppName, 
                    defaultAppVersion, "2.0", "version increment"); 
            if (repositoryClient.resourceExists("/" + applicationFolder + "/" 
                    + appName.toString() + "/" + "2.0")) { 
                System.out.println("Application version 2.0 created : " 
                        + appName + "/" + "2.0"); 
            } 
        } catch (Exception e) { 
            e.printStackTrace(); 
        } 
    } 
}

// Ethnio survey code removed