ListBucketResult.java

/*
 * Copyright 2018 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.genesys.filerepository.service.s3;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;

/**
 * Built from AWS S3 documentation at
 * <ul>
 * <li>http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html#RESTBucketGET-responses</li>
 * <li>http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html#RESTBucketGET-responses-examples</li>
 * </ul>
 *
 * <pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;
    &lt;Name&gt;bucket&lt;/Name&gt;
    &lt;Prefix/&gt;
    &lt;Marker/&gt;
    &lt;MaxKeys&gt;1000&lt;/MaxKeys&gt;
    &lt;IsTruncated&gt;false&lt;/IsTruncated&gt;
    &lt;Contents&gt;
        &lt;Key&gt;my-image.jpg&lt;/Key&gt;
        &lt;LastModified&gt;2009-10-12T17:50:30.000Z&lt;/LastModified&gt;
        &lt;ETag&gt;&quot;fba9dede5f27731c9771645a39863328&quot;&lt;/ETag&gt;
        &lt;Size&gt;434234&lt;/Size&gt;
        &lt;StorageClass&gt;STANDARD&lt;/StorageClass&gt;
        &lt;Owner&gt;
            &lt;ID&gt;75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a&lt;/ID&gt;
            &lt;DisplayName&gt;mtd@amazon.com&lt;/DisplayName&gt;
        &lt;/Owner&gt;
    &lt;/Contents&gt;
    &lt;Contents&gt;
       &lt;Key&gt;my-third-image.jpg&lt;/Key&gt;
         &lt;LastModified&gt;2009-10-12T17:50:30.000Z&lt;/LastModified&gt;
         &lt;ETag&gt;&quot;1b2cf535f27731c974343645a3985328&quot;&lt;/ETag&gt;
         &lt;Size&gt;64994&lt;/Size&gt;
         &lt;StorageClass&gt;STANDARD_IA&lt;/StorageClass&gt;
         &lt;Owner&gt;
            &lt;ID&gt;75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a&lt;/ID&gt;
            &lt;DisplayName&gt;mtd@amazon.com&lt;/DisplayName&gt;
        &lt;/Owner&gt;
    &lt;/Contents&gt;
&lt;/ListBucketResult&gt;
 * </pre>
 */
@XmlRootElement(name = "ListBucketResult", namespace = "http://s3.amazonaws.com/doc/2006-03-01/")
@XmlAccessorType(XmlAccessType.NONE)
public class ListBucketResult {
	/**
	 * Name of the bucket.
	 */
	@XmlElement(name = "Name")
	private String name;

	/**
	 * Keys that begin with the indicated prefix.
	 */
	@XmlElement(name = "Prefix")
	private String prefix;

	/**
	 * Indicates where in the bucket listing begins. Marker is included in the
	 * response if it was sent with the request.
	 */
	@XmlElement(name = "Marker")
	private String marker;

	/**
	 * The maximum number of keys returned in the response body.
	 */
	@XmlElement(name = "MaxKeys")
	private int maxKeys;

	/**
	 * Indicates where in the bucket listing begins. Marker is included in the
	 * response if it was sent with the request.
	 */
	@XmlElement(name = "NextMarker")
	private String nextMarker;

	/**
	 * Causes keys that contain the same string between the prefix and the first
	 * occurrence of the delimiter to be rolled up into a single result element in
	 * the CommonPrefixes collection. These rolled-up keys are not returned
	 * elsewhere in the response. Each rolled up result counts as only one return
	 * against the MaxKeys value.
	 */
	@XmlElement(name = "Delimiter")
	private String delimiter;

	/**
	 * Specifies whether (true) or not (false) all of the results were returned. All
	 * of the results may not be returned if the number of results exceeds that
	 * specified by MaxKeys.
	 */
	@XmlElement(name = "IsTruncated")
	private boolean truncated;

	/**
	 * A response can contain CommonPrefixes only if you specify a delimiter. When
	 * you do, CommonPrefixes contains all (if there are any) keys between Prefix
	 * and the next occurrence of the string specified by delimiter. In effect,
	 * CommonPrefixes lists keys that act like subdirectories in the directory
	 * specified by Prefix. For example, if prefix is notes/ and delimiter is a
	 * slash (/), in notes/summer/july, the common prefix is notes/summer/. All of
	 * the keys rolled up in a common prefix count as a single return when
	 * calculating the number of returns. See MaxKeys.
	 */
	@XmlElement(name = "CommonPrefixes")
	@JacksonXmlElementWrapper(useWrapping = false)
	private List<CommonPrefix> commonPrefixes;

	/**
	 * Metadata about each object returned.
	 */
	@XmlElement(name = "Contents")
	@JacksonXmlElementWrapper(useWrapping = false)
	private List<Content> contents;

	/**
	 * Gets the name.
	 *
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 *
	 * @param name the name to set
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * Gets the prefix.
	 *
	 * @return the prefix
	 */
	public String getPrefix() {
		return prefix;
	}

	/**
	 * Sets the prefix.
	 *
	 * @param prefix the prefix to set
	 */
	public void setPrefix(final String prefix) {
		this.prefix = prefix;
	}

	/**
	 * Gets the max keys.
	 *
	 * @return the maxKeys
	 */
	public int getMaxKeys() {
		return maxKeys;
	}

	/**
	 * Sets the max keys.
	 *
	 * @param maxKeys the maxKeys to set
	 */
	public void setMaxKeys(final int maxKeys) {
		this.maxKeys = maxKeys;
	}

	/**
	 * Gets the delimiter.
	 *
	 * @return the delimiter
	 */
	public String getDelimiter() {
		return delimiter;
	}

	/**
	 * Sets the delimiter.
	 *
	 * @param delimiter the delimiter to set
	 */
	public void setDelimiter(final String delimiter) {
		this.delimiter = delimiter;
	}

	/**
	 * Checks if is truncated.
	 *
	 * @return the truncated
	 */
	public boolean isTruncated() {
		return truncated;
	}

	/**
	 * Sets the truncated.
	 *
	 * @param truncated the truncated to set
	 */
	public void setTruncated(final boolean truncated) {
		this.truncated = truncated;
	}

	/**
	 * Gets the common prefixes.
	 *
	 * @return the commonPrefixes
	 */
	public List<CommonPrefix> getCommonPrefixes() {
		return commonPrefixes;
	}

	/**
	 * Sets the common prefixes.
	 *
	 * @param commonPrefixes the commonPrefixes to set
	 */
	public void setCommonPrefixes(final List<CommonPrefix> commonPrefixes) {
		this.commonPrefixes = commonPrefixes;
	}

	/**
	 * Gets the contents.
	 *
	 * @return the contents
	 */
	public List<Content> getContents() {
		return contents;
	}

	/**
	 * Sets the contents.
	 *
	 * @param contents the new contents
	 */
	public void setContents(final List<Content> contents) {
		this.contents = contents;
	}
}