The following explains the example code.
- Annotation
@SourceConfigTypeConfig defines Name, Version and
Description of the source configuration type.
- Annotation
@VersionParams defines version information. You can
also create a source configuration type without using annotation
@VersionParams, for example for implementations not
requiring artifacts. If you do so, it is your responsibility to handle the
behavior of the source configuration type to process and exit gracefully so
that manual or automatic import of a component version works properly. See
Defining the Behavior of the Custom Source Configuration Type.
- If you want to use version properties in
downloadVersionContent(), you must set those
properties in the
VersionInfo Java object so that they are available
later on.
VersionInfo has setter methods for setting the
properties.
public Collection<VersionInfo> getNextVersionInfo(Properties properties)
throws Exception {
if(properties == null)
return null;
List<VersionInfo> infoList = new ArrayList<VersionInfo>();
VersionInfo inf = new VersionInfo(properties.getProperty("revision"));
inf.setVersionProps(properties);
infoList.add(inf);
return infoList;
}
public void downloadVersionContent(VersionInfo versionInfo,
File processingDirectoryLocation) throws Exception {
Properties prop = versionInfo.getVersionProps();
// Do some work.
}
- Annotation
@SourceConfigTypeParam defines individual properties
that will be configured during component configuration.
- You MUST use a getter and setter for each property using any of the
annotation.
- You should override the
equals and
hashcode methods for equality checks. You can also
override the
toString method for string representation of an
object.
- If any of the
@SourceConfigTypeParam properties are marked as
readOnly=false, those properties of the
CommonIntegrator can be updated in
downloadVersionContent() and are persisted in the
database. These persisted objects can be used later on or in the next component
version integration.
@SourceConfigTypeParam(displayName = "File Content",
description = "Content of the file", required = true, readOnly = false)
private String fileContent;
public void downloadVersionContent(VersionInfo versionInfo,
File processingDirectoryLocation) throws Exception {
// Update writable/updatable properties [readOnly = false]
fileContent = “my new content generated dynamically”;
}
Note: The next time the common integrator runs, it will have
fileContent initialized with “my new content generated
dynamically,” as this value persists in the database.
Copyright © 2011–2017 Serena Software, Inc., a Micro Focus company. All rights reserved.