| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.s3.domain; |
| 20 | |
| 21 | /** |
| 22 | * Every bucket and object in Amazon S3 has an owner, the user that created the bucket or object. |
| 23 | * The owner of a bucket or object cannot be changed. However, if the object is overwritten by |
| 24 | * another user (deleted and rewritten), the new object will have a new owner. |
| 25 | * <p/> |
| 26 | * |
| 27 | * @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html? |
| 28 | * RESTAccessPolicy.html" /> |
| 29 | * @author Adrian Cole |
| 30 | */ |
| 31 | public class CanonicalUser { |
| 32 | private final String id; |
| 33 | private String displayName; |
| 34 | |
| 35 | public CanonicalUser(String id) { |
| 36 | this.id = id; |
| 37 | } |
| 38 | |
| 39 | public CanonicalUser(String id, String displayName) { |
| 40 | this(id); |
| 41 | this.displayName = displayName; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * To locate the CanonicalUser ID for a user, the user must perform the |
| 46 | * {@link org.jclouds.s3.blobstore.S3AsyncBlobStore#list(String)} and retrieve |
| 47 | * {@link BucketMetadata#getOwner()} |
| 48 | */ |
| 49 | public String getId() { |
| 50 | return id; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * read-only as is maintained by Amazon. |
| 55 | */ |
| 56 | public String getDisplayName() { |
| 57 | return displayName; |
| 58 | } |
| 59 | |
| 60 | public void setDisplayName(String displayName) { |
| 61 | this.displayName = displayName; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public int hashCode() { |
| 66 | final int prime = 31; |
| 67 | int result = 1; |
| 68 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public boolean equals(Object obj) { |
| 74 | if (this == obj) |
| 75 | return true; |
| 76 | if (obj == null) |
| 77 | return false; |
| 78 | if (getClass() != obj.getClass()) |
| 79 | return false; |
| 80 | CanonicalUser other = (CanonicalUser) obj; |
| 81 | if (id == null) { |
| 82 | if (other.id != null) |
| 83 | return false; |
| 84 | } else if (!id.equals(other.id)) |
| 85 | return false; |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | } |