Identifying Existing Versions

You typically need to access existing versions and their properties.

The interface ComponentInfo enables you to:

CommonIntegrator (sct-commons-1.0.0.jar) provides an additional Interface named ComponentInfo that has following methods:

CAUTION:
You should be very careful if you use getAllVersions(), as this takes a lot of time and processing to go through all versions and their properties for a component.

The ComponentInfo interface is automatically initialized when you define this in the class along with its getters and setters.

private ComponentInfo info;

public ComponentInfo getInfo() {
    return info;
}

public void setInfo(ComponentInfo info) {
    this.info = info;
}

Once initialized, you can use this for creating or identifying artifacts as follows.

Existing Versions

// For all the existing versions
List<VersionInfo> existingVersions = 
  (componentInfo == null) ? null : componentInfo.getAllVersions();

if(existingVersions != null && existingVersions.size() > 0) {
    for(VersionInfo info : existingVersions) {
        // your logic here
    }
}

Latest Versions

// For latest versions
VersionInfo singleLatestVersion = 
  (componentInfo == null) ? null : componentInfo.getLatestVersion();
// your logic goes here.