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            @Override
085            public String toString() {
086                    return "name:"+name+";creation:"+creation+";ownerDisplayName:"+ownerDisplayName+";ownerIdKey:"+ownerIdKey;
087            }
088    
089            @Override
090            public long getLastModified() {
091                    return getCreation().getTime();
092            }
093    
094            @Override
095            public long getSize() {
096                    return 0;
097            }
098    
099            @Override
100            public boolean exists() {
101                    return true;
102            }
103    
104            @Override
105            public boolean isDirectory() {
106                    return true;
107            }
108    
109            @Override
110            public boolean isFile() {
111                    return false;
112            }
113    }