forked from aws/aws-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBucketWebsiteConfiguration.java
More file actions
232 lines (213 loc) · 8.89 KB
/
BucketWebsiteConfiguration.java
File metadata and controls
232 lines (213 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 com.amazonaws.services.s3.model;
import java.util.LinkedList;
import java.util.List;
/**
* Bucket configuration options for hosting static websites entirely out of
* Amazon S3.
* <p>
* To host a static website in Amazon S3, create a bucket, upload your files,
* and set the bucket website configuration. Once your bucket has been
* configured as a website, you can access all your content via the Amazon S3
* website endpoint. To ensure that the existing Amazon S3 REST API will
* continue to behave the same, regardless of whether or not your bucket has
* been configured to host a website, a new HTTP endpoint has been introduced
* where you can access your website content. The bucket content you want to
* make available via the website must be publicly readable.
* <p>
* To enable hosting websites, Amazon S3 introduces the following
* concepts/features:
* <ul>
* <li><b>Website endpoints</b> - When you configure a bucket as a website, the website
* is available via the the region-specific website endpoint where the bucket
* resides.
* <li><b>Index document support</b> - When configuring a bucket as a website you must
* provide an index document name. This is the webpage that Amazon S3 returns when
* it receives a request to the root of your website, or one of its
* subdirectories. Amazon S3 supports index documents in subdirectories.
* <li><b>Error document support</b> - Should an error occur, Amazon S3 will return an
* HTML error document, instead of an XML document.You can optionally provide
* your own error document that contains HTML, or any other static content
* specific to your website. You provide the error document name when you
* configure a bucket as a website. If you provide the custom error document,
* Amazon S3 returns your custom error document when an HTTP 4XX class error
* occurs. For other error non-4XX class errors, Amazon S3 will return its own
* error document.
* </ul>
* <p>
* For more information on how to host a website on Amazon S3, see:
* <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting.html">http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting.html</a>.
*
* @see AmazonS3#setBucketWebsiteConfiguration(String, BucketWebsiteConfiguration)
* @see AmazonS3#getBucketWebsiteConfiguration(String)
* @see AmazonS3#deleteBucketWebsiteConfiguration(String)
*/
public class BucketWebsiteConfiguration {
/**
* The document to serve when a directory is specified (ex: index.html).
* This path is relative to the requested resource.
*/
private String indexDocumentSuffix;
/** The complete path to the document to serve for 4xx errors. */
private String errorDocument;
/**
* Container for redirect information where all requests will be redirect
* to. You can redirect requests to another host, to another page, or with
* another protocol. In the event of an error, you can can specify a
* different error code to return. .
*/
private RedirectRule redirectAllRequestsTo;
/**
* The list of routing rules that can be used for configuring redirects if
* certain conditions are meet.
*/
private List<RoutingRule> routingRules = new LinkedList<RoutingRule>();
/**
* Creates a new BucketWebsiteConfiguration.
*/
public BucketWebsiteConfiguration() {
}
/**
* Creates a new BucketWebsiteConfiguration with the specified index
* document suffix.
*
* @param indexDocumentSuffix
* The document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
*/
public BucketWebsiteConfiguration(String indexDocumentSuffix) {
this.indexDocumentSuffix = indexDocumentSuffix;
}
/**
* Creates a new BucketWebsiteConfiguration with the specified index
* document suffix and error document.
*
* @param indexDocumentSuffix
* The document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
* @param errorDocument
* The complete path to the document to serve for 4xx errors.
*/
public BucketWebsiteConfiguration(String indexDocumentSuffix, String errorDocument) {
this.indexDocumentSuffix = indexDocumentSuffix;
this.errorDocument = errorDocument;
}
/**
* Returns the document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
*
* @return The document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
*/
public String getIndexDocumentSuffix() {
return indexDocumentSuffix;
}
/**
* Sets the document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
*
* @param indexDocumentSuffix
* The document to serve when a directory is specified (ex:
* index.html). This path is relative to the requested resource.
*/
public void setIndexDocumentSuffix(String indexDocumentSuffix) {
this.indexDocumentSuffix = indexDocumentSuffix;
}
/**
* Returns the complete path to the document to serve for 4xx errors, or
* null if no error document has been configured.
*
* @return The complete path to the document to serve for 4xx errors, or
* null if no error document has been configured.
*/
public String getErrorDocument() {
return errorDocument;
}
/**
* Sets the complete path to the document to serve for 4xx errors.
*
* @param errorDocument
* The complete path to the document to serve for 4xx errors.
*/
public void setErrorDocument(String errorDocument) {
this.errorDocument = errorDocument;
}
/**
* Sets the redirect information where all requests will be redirect to.
*
* @param redirectAllRequestsTo
* The Redirect information where all requests will be redirect
* to.
*/
public void setRedirectAllRequestsTo(RedirectRule redirectAllRequestsTo) {
this.redirectAllRequestsTo = redirectAllRequestsTo;
}
/**
* Return the redirect information where all requests will be redirect to.
*/
public RedirectRule getRedirectAllRequestsTo() {
return redirectAllRequestsTo;
}
/**
* Sets the redirect information where all requests will be redirect to and
* returns a reference to this object(BucketWebsiteConfiguration) for method
* chaining.
*
* @param redirectAllRequestsTo
* The Redirect information where all requests will be redirect
* to.
* @return a reference to this object(BucketWebsiteConfiguration) for method
* chaining.
*/
public BucketWebsiteConfiguration withRedirectAllRequestsTo(RedirectRule redirectAllRequestsTo) {
this.redirectAllRequestsTo = redirectAllRequestsTo;
return this;
}
/**
* Set the list of routing rules that can be used for configuring redirects
* if certain conditions are meet.
*
* @param routingRules
* The list of routing rules that can be used for configuring
* redirects.
*/
public void setRoutingRules(List<RoutingRule> routingRules) {
this.routingRules = routingRules;
}
/**
* Return the list of routing rules that can be used for configuring
* redirects if certain conditions are meet.
*/
public List<RoutingRule> getRoutingRules() {
return routingRules;
}
/**
* Set the list of routing rules that can be used for configuring redirects
* if certain conditions are meet and returns a reference to this
* object(BucketWebsiteConfiguration) for method chaining.
*
* @param routingRules
* The list of routing rules that can be used for configuring
* redirects.
* @return A reference to this object(BucketWebsiteConfiguration) for method
* chaining.
*
*/
public BucketWebsiteConfiguration withRoutingRules(List<RoutingRule> routingRules) {
this.routingRules = routingRules;
return this;
}
}