/** * Starts the output with the given root element and attributes * * @param rootElement the name of the root element of the generated document. * @param attr the attributes for the root element * @return the output itself for fluent method calls */ public StructuredOutput beginOutput(@Nonnull String rootElement, Attribute... attr) { if (opensCalled == 0) { try { hd.startDocument(); } catch (SAXException e) { throw Exceptions.handle(e); } } opensCalled++; beginObject(rootElement, attr); return this; }
/** * Starts the output with the given root element. * * @param rootElement the name of the root element of the generated document. * @return the output itself for fluent method calls */ public StructuredOutput beginOutput(@Nonnull String rootElement) { if (opensCalled == 0) { try { hd.startDocument(); } catch (SAXException e) { throw Exceptions.handle(e); } } opensCalled++; beginObject(rootElement); return this; }
private void outputOwnerInfo(XMLStructuredOutput out, String name) { out.beginObject(name); out.property("ID", "initiatorId"); out.property(RESPONSE_DISPLAY_NAME, "initiatorName"); out.endObject(); }
long numObjects = objectCount.inc(); if (numObjects <= limit) { output.beginObject("Contents"); output.property("Key", file.getName()); output.property("LastModified",
structuredOutput.beginObject("LastModified"); structuredOutput.text(RFC822_INSTANT.format(object.getLastModifiedInstant())); structuredOutput.endObject(); structuredOutput.beginObject(HTTP_HEADER_NAME_ETAG); structuredOutput.text(etag(etag)); structuredOutput.endObject();
/** * 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()); } }
out.beginObject("Part"); out.property("PartNumber", part.getName()); out.property("LastModified", RFC822_INSTANT.format(Instant.ofEpochMilli(part.lastModified())));