Java-based APIs to work with baseline and labels id175UB30E05Z
The following Java-based APIs allow you to create baseline and add labels to files in a baseline. These APIs are available in the form of a bundle. You must include this bundle in your code to use these APIs.
Bundle details:
-
Group ID: com.adobe.fmdita
-
Artifact ID: api
-
Version: 3.5
-
Package: com.adobe.fmdita.api.baselines
-
Class details:
code language-java public class BaselineUtils extends Object
The BaselineUtils class contain methods for creating baselines and applying labels to files in a baseline.
Create a baseline
The create baseline method has two versions – one for XML Documentation solution version 3.5, and other for versions prior to 3.5 release (which includes versions 3.4, 3.3, and 3.2). The version 3.5 API allows creation of baseline using a label, direct references, and indirect references in a map file.
The other version of API uses the date and time to create a baseline. This API is retained for backward-compatibility with systems using XML Documentation solution 3.4, 3.3, or 3.2.
Syntax (for version 3.5):
public static String createBaseline(Session session,
String sourcePath,
String baselineTitle,
String label,
LinkedHashMap directContext,
LinkedHashMap indirectContext)
throws GuidesApiException
Parameters:
session
sourcePath
baselineTitle
label
directContext
If after iteration on all keys of the map, no version is found, then the baseline creation process fails.
If the HashMap is empty (send empty and not null map for default), then by default it, is populated as:
directContext.put("label", label);
directContext.put("latest", true);
If you want the baseline creation to only pick version of a given label and fail if no such version exists, then put the
label
key and the label you want to create baseline on.indirectContext
If after iteration on all keys of the map, no version is found, then the baseline creation process fails.
If the HashMap is empty (send empty and not null map for default), then by default, it is populated as:
indirectContext.put("label", label);
indirectContext.put "pickAutomatically", null);
If you want it to be the latest version in place of picking up a version automatically, then replace:
indirectContext.put("pickAutomatically", null);
with:
indirectContext.put("latest", true)
Returns:
The name of the baseline, which is the node name of the baseline in the JCR repository. The title of the newly created baseline will be shown to the user on the Baseline page for the DITA map.
Exception:
Throws ItemExistExceptiom
if a baseline with the same title already exists.
Syntax (for versions 3.4, 3.3, and 3.2)
public static String createBaseline
(Session session,
String sourcePath,
String baselineTitle,
Date versionDate) throws GuidesApiException
Parameters:
session
sourcePath
baselineTitle
versionDate
d-MM-yyyy H:mm
format.Returns:
The name of the baseline, which is the node name of the baseline in the JCR repository. The title of the newly created baseline will be shown to the user on the Baseline page for the DITA map.
Exception:
Throws RepositoryException.
Apply labels
The applyLabel
method applies one or multiple labels to the files in a baseline.
Syntax:
public static void applyLabel(Session session,
String sourcePath,
String baselineName,
String label)
throws RepositoryException, WorkflowException, Exception
Parameters:
session
sourcePath
baselineName
Note: Label is applied to version of files that are directly referenced from the map file in the baseline.
label
In case you want to set multiple labels, then separate labels with a comma; for example Label1, Label2.
Exception:
Throws RepositoryException
.
Delete labels
The deleteLabel
method deletes one or multiple labels from the files in a baseline.
Syntax:
public static Map
<String, String> deleteLabel(Session session,
String sourcePath,
String baselineName,
String label) throws GuidesApiException
Parameters:
session
sourcePath
baselineName
Note: Label is deleted from the version of files that are directly referenced from the map file in the baseline.
label
In case you want to delete multiple labels, then separate labels with a comma; for example Label1, Label2.
Returns:
The map with key:value pair of path:deletedlabels
for all files in the baseline.
Exception:
Throws RepositoryException`, `VersionException`, `Exception
.