1 81 package com.ivata.groupware.business.library.item; 82 83 import java.beans.XMLDecoder ; 84 import java.beans.XMLEncoder ; 85 import java.io.File ; 86 import java.io.FileOutputStream ; 87 import java.io.IOException ; 88 import java.util.List ; 89 90 import com.ivata.groupware.business.drive.file.FileContentDO; 91 import com.ivata.groupware.business.library.topic.TopicDO; 92 import com.ivata.groupware.container.persistence.TimestampDO; 93 94 122 public class LibraryItemDO extends TimestampDO { 123 124 130 public static LibraryItemDO convertFromFile(FileContentDO fileContent) { 131 XMLDecoder decoder = new XMLDecoder (fileContent.getContent().getInputStream()); 132 LibraryItemDO itemDO = (LibraryItemDO) decoder.readObject(); 133 134 decoder.close(); 135 return itemDO; 136 } 137 138 142 private List fAQCategories; 143 144 147 private String imageDirectory; 148 149 152 private List pages; 153 154 158 private String summary; 159 160 161 165 private String title; 166 167 170 private TopicDO topic; 171 175 private Integer type; 176 177 191 public List getFAQCategories() { 192 return fAQCategories; 193 } 194 201 public final String getImageDirectory() { 202 return imageDirectory; 203 } 204 205 222 public List getPages() { 223 return pages; 224 } 225 226 233 public final String getSummary() { 234 return summary; 235 } 236 237 245 public final String getTitle() { 246 return title; 247 } 248 249 256 public final TopicDO getTopic() { 257 return topic; 258 } 259 260 265 public final Integer getType() { 266 return type; 267 } 268 269 275 public String saveToFile() 276 throws IOException { 277 String returnFileName = ""; 278 279 File tmpFile = File.createTempFile("drive", "xml"); 281 282 returnFileName = tmpFile.getPath(); 283 FileOutputStream file = new FileOutputStream (returnFileName); 285 XMLEncoder encoder = new XMLEncoder (file); 286 287 encoder.writeObject(this); 288 encoder.close(); 289 file.close(); 290 291 return returnFileName; 292 } 293 294 301 public final void setFAQCategories(final List fAQCategories) { 302 this.fAQCategories = fAQCategories; 303 } 304 305 310 public final void setImageDirectory(final String imageDirectory) { 311 this.imageDirectory = imageDirectory; 312 } 313 314 324 public final void setPages(final List pages) { 325 this.pages = pages; 326 } 327 328 334 public final void setSummary(final String summary) { 335 this.summary = summary; 336 } 337 338 339 345 public final void setTitle(final String title) { 346 this.title = title; 347 } 348 349 354 public final void setTopic(final TopicDO topic) { 355 this.topic = topic; 356 } 357 358 362 public final void setType(final Integer type) { 363 this.type = type; 364 } 365 366 } 367 | Popular Tags |