getNextVersionInfo Method

The getNextVersionInfo method gets information about the next version to be imported.

getNextVersionInfo takes the Properties object as a parameter.

If you want specific properties to be used when creating the VersionInfo object, compose VersionParams so that those properties are passed to this method. The values of these parameters are supplied when importing versions.

For example:

 
@VersionParams
(
versionParams = 
{ 
@VersionParam(displayName = "Specific version/tag", name = "revision",
 description = "Name of specific version or tag"), @VersionParam(displayName =
 "Name to create the version with", name = "name", description = "Name for
 identifying the version")
}
) 

The above returns

Collection<VersionInfo>

This is the collection of VersionInfo objects that can be created using values from the VersionParams annotation.

public Collection<VersionInfo> 
getNextVersionInfo(Properties properties) throws Exception 
{
   
    // This is the name of the first VersionParam object
    String versionName = properties.getProperty("revision");
    VersionInfo info = new VersionInfo(versionName);
     
    // Set some additional properties to existing Properties Object 
    // so that we can use it in    
    // downloadVersionContent 
    properties.put("myCustomProperty", “myValue”);
    info.setVersionProps(properties); // SET PROPERTIES
    return Arrays.asList(info);
}

public void 
downloadVersionContent(VersionInfo versionInfo, File processingDirectoryLocation) 
    throws Exception 
{
    // Extract properties from VersionInfo object
    Properties prop = versionInfo.getVersionProps();
    String myProp = prop.getProperty("myCustomProperty");
    Client someClient = new Client();
    Client.downloadContent(processingDirectoryLocation, myProp);
}

If you find that there is no version to create based on the getNextVersionInfo()call and do not need to call downloadVersionContent(), you should return a null or empty Collections object. When the Deployment Automation server receives an empty or null object instead of a collection of VersionInfo objects, it skips calling downloadVersionContent().

public Collection<VersionInfo> 
getNextVersionInfo(Properties properties) throws Exception 
{
   
    // This is the name of the first VersionParam object
    String versionName = properties.getProperty("revision");

    // No need to go further, we are not creating the version.
    if(versionName == null || versionName. length() == 0)
     return null;

    VersionInfo info = new VersionInfo(versionName);
     
    // Set some additional properties to existing Properties Object 
    // so that we can use it in    
    // downloadVersionContent 
    properties.put("myCustomProperty", “myValue”);
    info.setVersionProps(properties); // SET PROPERTIES
    return Arrays.asList(info);
}