1 13 package info.magnolia.cms.beans.runtime; 14 15 import info.magnolia.cms.core.NodeData; 16 17 import java.io.InputStream ; 18 19 import javax.jcr.RepositoryException; 20 21 import org.apache.commons.lang.math.NumberUtils; 22 23 24 28 public class File { 29 30 private NodeData data; 31 32 private String extension; 33 34 private String fileName; 35 36 private String contentType; 37 38 private String nodeDataTemplate; 39 40 private int size; 41 42 public void setProperties(NodeData properties) { 43 this.setNodeDataTemplate(properties.getAttribute("nodeDataTemplate")); this.setExtension(properties.getAttribute("extension")); this.setFileName(properties.getAttribute("fileName")); this.setContentType(properties.getAttribute("contentType")); 48 String sizeString = properties.getAttribute("size"); if (NumberUtils.isNumber(sizeString)) { 50 this.setSize(Integer.parseInt(sizeString)); 51 } 52 53 } 54 55 public String getExtension() { 56 return extension; 57 } 58 59 public void setExtension(String extension) { 60 this.extension = extension; 61 } 62 63 public String getFileName() { 64 return fileName; 65 } 66 67 public void setFileName(String fileName) { 68 this.fileName = fileName; 69 } 70 71 public String getContentType() { 72 return contentType; 73 } 74 75 public void setContentType(String contentType) { 76 this.contentType = contentType; 77 } 78 79 public String getNodeDataTemplate() { 80 return nodeDataTemplate; 81 } 82 83 public void setNodeDataTemplate(String nodeDataTemplate) { 84 this.nodeDataTemplate = nodeDataTemplate; 85 } 86 87 public int getSize() { 88 return size; 89 } 90 91 public void setSize(int size) { 92 this.size = size; 93 } 94 95 public NodeData getNodeData() { 96 return this.data; 97 } 98 99 public void setNodeData(NodeData data) { 100 this.data = data; 101 } 102 103 public InputStream getStream() { 104 try { 105 return this.data.getValue().getStream(); 106 } 107 catch (RepositoryException re) { 108 return null; 109 } 110 } 111 } 112 | Popular Tags |