use of jetbrains.buildServer.serverSide.metadata.impl.MetadataStorageEx in project teamcity-rest by JetBrains.
the class Build method getMetadata.
@XmlElement
public NamedDatas getMetadata() {
if (myBuild == null) {
return null;
} else {
return ValueWithDefault.decideDefaultIgnoringAccessDenied(myFields.isIncluded("metadata", false, false), () -> {
checkCanViewRuntimeData();
HashMap<String, Map<String, String>> result = new HashMap<>();
MetadataStorageEx metadataStorage = myServiceLocator.getSingletonService(MetadataStorageEx.class);
for (String providerId : metadataStorage.getProviderIds()) {
Iterator<BuildMetadataEntry> metadataEntryIterator = metadataStorage.getBuildEntry(myBuild.getBuildId(), providerId);
while (metadataEntryIterator.hasNext()) {
BuildMetadataEntry metadataEntry = metadataEntryIterator.next();
HashMap<String, String> properties = new HashMap<>(metadataEntry.getMetadata());
if (properties.get(".providerId") == null) {
properties.put(".providerId", providerId);
} else {
// assume clash here does not happen
properties.put(".teamcity.rest.providerId", providerId);
}
if (properties.get(".key") == null) {
properties.put(".key", metadataEntry.getKey());
} else {
// assume clash here does not happen
properties.put(".teamcity.rest.key", metadataEntry.getKey());
}
result.put(providerId + "_" + metadataEntry.getKey(), properties);
}
}
return new NamedDatas(result, myFields.getNestedField("metadata"));
});
}
}
Aggregations