/** * Closes the output and this XML document. */ public void endOutput() { endObject(); if (opensCalled-- == 1) { super.endResult(); try { hd.endDocument(); out.close(); } catch (SAXException | IOException e) { throw Exceptions.handle(e); } } }
private void outputOwnerInfo(XMLStructuredOutput out, String name) { out.beginObject(name); out.property("ID", "initiatorId"); out.property(RESPONSE_DISPLAY_NAME, "initiatorName"); out.endObject(); }
output.property("StorageClass", "STANDARD"); output.property("ETag", getETag(file)); output.endObject(); } else { return FileVisitResult.TERMINATE;
structuredOutput.beginObject("LastModified"); structuredOutput.text(RFC822_INSTANT.format(object.getLastModifiedInstant())); structuredOutput.endObject(); structuredOutput.beginObject(HTTP_HEADER_NAME_ETAG); structuredOutput.text(etag(etag)); structuredOutput.endObject(); structuredOutput.endOutput(); signalObjectSuccess(ctx);
/** * GET a list of all buckets * * @param ctx the context describing the current request */ private void listBuckets(WebContext ctx) { HttpMethod method = ctx.getRequest().method(); if (GET == method) { List<Bucket> buckets = storage.getBuckets(); Response response = ctx.respondWith(); response.setHeader(HTTP_HEADER_NAME_CONTENT_TYPE, CONTENT_TYPE_XML); XMLStructuredOutput out = response.xml(); out.beginOutput("ListAllMyBucketsResult", Attribute.set("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/")); out.property("hint", "Goto: " + ctx.getBaseURL() + "/ui to visit the admin UI"); outputOwnerInfo(out, "Owner"); out.beginObject("Buckets"); for (Bucket bucket : buckets) { out.beginObject(RESPONSE_BUCKET); out.property("Name", bucket.getName()); out.property("CreationDate", RFC822_INSTANT.format(Instant.ofEpochMilli(bucket.getFile().lastModified()))); out.endObject(); } out.endObject(); out.endOutput(); } else { throw new IllegalArgumentException(ctx.getRequest().method().name()); } }