in teamcity-s3-sdk/src/main/java/jetbrains/buildServer/artifacts/s3/transport/PresignedUrlRequestSerializer.java [176:224]
public static PresignedUrlListRequestDto deserializeRequest(@NotNull final String data) {
try {
final Element document = XmlUtil.from_s(data);
if (!document.getName().equals(OBJECT_KEYS)) {
throw new IllegalArgumentException("Expected document name to be '" + OBJECT_KEYS + "' but got '" + document.getName() + "'");
}
final Collection<PresignedUrlRequestDto> result = new HashSet<>();
final boolean isVersion2 = document.getAttribute(PRE_SIGN_V2) != null;
final Attribute customTtlAttribute = document.getAttribute(CUSTOM_TTL);
final Long customTtl = customTtlAttribute != null ? customTtlAttribute.getLongValue() : null;
Attribute contentTypeAttribute = document.getAttribute(S3_UPLOAD_CONTENT_TYPE);
String contentType = contentTypeAttribute != null ? contentTypeAttribute.getValue() : null;
for (Object child : document.getChildren(OBJECT_KEY)) {
final Element objectKeyEl = (Element)child;
final Attribute nPartsAttr = objectKeyEl.getAttribute(NUMBER_OF_PARTS);
final Attribute httpMethodAttr = objectKeyEl.getAttribute(HTTP_METHOD);
final int numberOfParts = nPartsAttr != null ? nPartsAttr.getIntValue() : 1;
final String httpMethod = httpMethodAttr != null ? httpMethodAttr.getValue() : null;
final String text = objectKeyEl.getText().trim();
if (isVersion2) {
final Iterator iterator = objectKeyEl.getChildren(DIGEST).iterator();
final List<String> digests = new ArrayList<>();
while (iterator.hasNext()) {
final Element element = (Element)iterator.next();
digests.add(element.getValue());
}
final Attribute uploadIdAttr = objectKeyEl.getAttribute(UPLOAD_ID);
final String uploadId = uploadIdAttr != null ? uploadIdAttr.getValue() : null;
if (!digests.isEmpty()) {
result.add(PresignedUrlRequestDto.from(text, uploadId, digests));
} else {
result.add(PresignedUrlRequestDto.from(text, numberOfParts, httpMethod));
}
} else {
result.add(PresignedUrlRequestDto.from(text, numberOfParts, httpMethod));
}
}
return new PresignedUrlListRequestDto(result, isVersion2, customTtl, contentType);
} catch (Exception e) {
LOGGER.warnAndDebugDetails("Got exception while parsing XML", e);
throw new IllegalArgumentException("Request is not a valid XML");
}
}