in rest-api/src/jetbrains/buildServer/server/rest/util/AggregatedBuildArtifactsElementBuilder.java [108:175]
public Element get() {
if (myElements.isEmpty()) {
throw new NotFoundException("No artifact found while constructing aggregated file element");
}
return new Element() {
@NotNull
@Override
public String getName() {
//noinspection ConstantConditions
return myElementName;
}
@NotNull
@Override
public String getFullName() {
//noinspection ConstantConditions
return myFullElementName;
}
@Override
public boolean isLeaf() {
if (myElements.size() == 1) return myElements.iterator().next().isLeaf();
return false;
}
@Nullable
@Override
public Iterable<Element> getChildren() throws BrowserException {
if (myElements.size() == 1) return myElements.iterator().next().getChildren();
final LinkedHashSet<Element> result = new LinkedHashSet<>();
for (Element element : myElements) {
final Iterable<Element> children = element.getChildren();
if (children != null) {
for (Element child : children) {
result.add(child);
}
}
}
return result;
}
@Override
public boolean isContentAvailable() {
if (myElements.size() == 1) return myElements.iterator().next().isContentAvailable();
return false;
}
@NotNull
@Override
public InputStream getInputStream() throws IllegalStateException, IOException, BrowserException {
if (myElements.size() == 1) return myElements.iterator().next().getInputStream();
throw new IllegalStateException("Content is not available for an aggregated file element");
}
@Override
public long getSize() {
if (myElements.size() == 1) return myElements.iterator().next().getSize();
return -1;
}
@NotNull
@Override
public Browser getBrowser() {
throw new RuntimeException("'getBrowser' operation not supported for an aggregated file element");
}
};
}