1 23 24 package org.infoglue.cms.entities.content.impl.simple; 25 26 import java.io.BufferedInputStream ; 27 import java.io.ByteArrayInputStream ; 28 import java.io.ByteArrayOutputStream ; 29 import java.io.InputStream ; 30 31 import org.infoglue.cms.entities.content.DigitalAsset; 32 import org.infoglue.cms.entities.content.DigitalAssetVO; 33 import org.infoglue.cms.entities.kernel.BaseEntityVO; 34 35 public class DigitalAssetImpl implements DigitalAsset 36 { 37 private DigitalAssetVO valueObject = new DigitalAssetVO(); 38 private byte[] assetBytes = null; 39 private java.util.Collection contentVersions; 40 private java.util.Collection userProperties; 41 private java.util.Collection roleProperties; 42 private java.util.Collection groupProperties; 43 private java.io.InputStream assetBlob; 44 private boolean assetBlobRead = false; 45 46 49 public BaseEntityVO getVO() 50 { 51 return (BaseEntityVO) getValueObject(); 52 } 53 54 57 public void setVO(BaseEntityVO valueObject) 58 { 59 setValueObject((DigitalAssetVO) valueObject); 60 } 61 62 65 public Integer getId() 66 { 67 return getDigitalAssetId(); 68 } 69 70 public Object getIdAsObject() 71 { 72 return getId(); 73 } 74 75 public DigitalAssetVO getValueObject() 76 { 77 return this.valueObject; 78 } 79 80 public void setValueObject(DigitalAssetVO valueObject) 81 { 82 this.valueObject = valueObject; 83 } 84 85 public java.lang.Integer getDigitalAssetId() 86 { 87 return this.valueObject.getDigitalAssetId(); 88 } 89 90 public void setDigitalAssetId(java.lang.Integer digitalAssetId) 91 { 92 this.valueObject.setDigitalAssetId(digitalAssetId); 93 } 94 95 public java.lang.String getAssetFileName() 96 { 97 return this.valueObject.getAssetFileName(); 98 } 99 100 public void setAssetFileName(java.lang.String assetFileName) 101 { 102 this.valueObject.setAssetFileName(assetFileName); 103 } 104 105 public java.lang.String getAssetKey() 106 { 107 return this.valueObject.getAssetKey(); 108 } 109 110 public void setAssetKey(java.lang.String assetKey) 111 { 112 this.valueObject.setAssetKey(assetKey); 113 } 114 115 public java.lang.String getAssetFilePath() 116 { 117 return this.valueObject.getAssetFilePath(); 118 } 119 120 public void setAssetFilePath(java.lang.String assetFilePath) 121 { 122 this.valueObject.setAssetFilePath(assetFilePath); 123 } 124 125 public java.lang.String getAssetContentType() 126 { 127 return this.valueObject.getAssetContentType(); 128 } 129 130 public void setAssetContentType(java.lang.String assetContentType) 131 { 132 this.valueObject.setAssetContentType(assetContentType); 133 } 134 135 public java.lang.Integer getAssetFileSize() 136 { 137 return this.valueObject.getAssetFileSize(); 138 } 139 140 public void setAssetFileSize(java.lang.Integer assetFileSize) 141 { 142 this.valueObject.setAssetFileSize(assetFileSize); 143 } 144 145 public java.util.Collection getContentVersions() 146 { 147 return this.contentVersions; 148 } 149 150 public void setContentVersions (java.util.Collection contentVersions) 151 { 152 this.contentVersions = contentVersions; 153 } 154 155 public java.util.Collection getUserProperties() 156 { 157 return this.userProperties; 158 } 159 160 public void setUserProperties(java.util.Collection userProperties) 161 { 162 this.userProperties = userProperties; 163 } 164 165 public java.util.Collection getRoleProperties() 166 { 167 return this.roleProperties; 168 } 169 170 public void setRoleProperties(java.util.Collection roleProperties) 171 { 172 this.roleProperties = roleProperties; 173 } 174 175 public java.util.Collection getGroupProperties() 176 { 177 return this.groupProperties; 178 } 179 180 public void setGroupProperties(java.util.Collection groupProperties) 181 { 182 this.groupProperties = groupProperties; 183 } 184 185 public void setAssetBlob(java.io.InputStream assetBlob) 186 { 187 this.assetBlob = assetBlob; 188 } 189 190 public synchronized InputStream getAssetBlob() 191 { 192 InputStream inputStream = null; 193 if(this.assetBytes != null) 194 { 195 inputStream = new ByteArrayInputStream (assetBytes); 196 } 197 else 198 { 199 inputStream = assetBlob; 200 } 201 202 assetBlobRead = true; 203 204 return inputStream; 205 } 206 207 public void setAssetBytes(byte[] bytes) 208 { 209 setAssetBlob(new ByteArrayInputStream (bytes)); 210 } 211 212 213 public byte[] getAssetBytes() 214 { 215 if(this.assetBytes == null) 216 { 217 try 218 { 219 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream (); 220 221 BufferedInputStream bis = new BufferedInputStream (getAssetBlob()); 222 223 int character; 224 while ((character = bis.read()) != -1) 225 { 226 byteArrayOutputStream.write(character); 227 } 228 byteArrayOutputStream.flush(); 229 230 bis.close(); 231 byteArrayOutputStream.close(); 232 233 this.assetBytes = byteArrayOutputStream.toByteArray(); 234 } 235 catch(Exception e) 236 { 237 e.printStackTrace(); 238 } 239 } 240 241 return this.assetBytes; 242 } 243 244 public boolean getIsAssetBlobRead() 245 { 246 return assetBlobRead; 247 } 248 } 249 | Popular Tags |