001    package railo.commons.io.res.type.s3;
002    
003    import java.io.IOException;
004    import java.net.MalformedURLException;
005    import java.security.InvalidKeyException;
006    import java.security.NoSuchAlgorithmException;
007    
008    import org.xml.sax.SAXException;
009    
010    import railo.runtime.type.dt.DateTime;
011    
012    public final class Bucket implements S3Info {
013    
014            private final S3 s3;
015            private String name;
016            private DateTime creation;
017            private String ownerIdKey;
018            private String ownerDisplayName;
019            
020            public Bucket(S3 s3) {
021                    this.s3 = s3;
022            }
023    
024            /**
025             * @return the ownerIdKey
026             */
027            public String getOwnerIdKey() {
028                    return ownerIdKey;
029            }
030    
031            /**
032             * @param ownerIdKey the ownerIdKey to set
033             */
034            public void setOwnerIdKey(String ownerIdKey) {
035                    this.ownerIdKey = ownerIdKey;
036            }
037    
038            /**
039             * @return the ownerDisplayName
040             */
041            public String getOwnerDisplayName() {
042                    return ownerDisplayName;
043            }
044    
045            /**
046             * @param ownerDisplayName the ownerDisplayName to set
047             */
048            public void setOwnerDisplayName(String ownerDisplayName) {
049                    this.ownerDisplayName = ownerDisplayName;
050            }
051    
052            /**
053             * @return the name
054             */
055            public String getName() {
056                    return name;
057            }
058    
059            /**
060             * @return the creation
061             */
062            public DateTime getCreation() {
063                    return creation;
064            }
065    
066            /**
067             * @param name the name to set
068             */
069            public void setName(String name) {
070                    this.name = name;
071            }
072    
073            /**
074             * @param creation the creation to set
075             */
076            public void setCreation(DateTime creation) {
077                    this.creation = creation;
078            }
079            
080            public Content[] listContent(String prefix,String marker,int maxKeys) throws InvalidKeyException, MalformedURLException, NoSuchAlgorithmException, IOException, SAXException {
081                    return s3.listContents(name, prefix, marker, maxKeys);
082            }
083            
084            /**
085             *
086             * @see java.lang.Object#toString()
087             */
088            public String toString() {
089                    return "name:"+name+";creation:"+creation+";ownerDisplayName:"+ownerDisplayName+";ownerIdKey:"+ownerIdKey;
090            }
091    
092            /**
093             *
094             * @see railo.commons.io.res.type.s3.S3Info#getLastModified()
095             */
096            public long getLastModified() {
097                    return getCreation().getTime();
098            }
099    
100            /**
101             * @see railo.commons.io.res.type.s3.S3Info#getSize()
102             */
103            public long getSize() {
104                    return 0;
105            }
106    
107            /**
108             * @see railo.commons.io.res.type.s3.S3Info#exists()
109             */
110            public boolean exists() {
111                    return true;
112            }
113    
114            /**
115             * @see railo.commons.io.res.type.s3.S3Info#isDirectory()
116             */
117            public boolean isDirectory() {
118                    return true;
119            }
120    
121            /**
122             * @see railo.commons.io.res.type.s3.S3Info#isFile()
123             */
124            public boolean isFile() {
125                    return false;
126            }
127    }