1 40 package com.mvnforum.admin.importexport.mvnforum; 41 42 import com.mvnforum.admin.AttachmentXML; 43 import net.myvietnam.mvncore.exception.*; 44 45 56 public class MvnForumAttachmentXML { 57 58 private AttachmentXML attachmentXML=null; 59 private boolean attachmentCreated=false; 60 private MvnForumPostXML parentPost =null; 61 62 String attachMemberName =null; 63 String attachFilename =null; 64 String attachFileSize =null; 65 String attachMimeType =null; 66 String attachDesc =null; 67 String attachCreationIP =null; 68 String attachCreationDate =null; 69 String attachModifiedDate =null; 70 String attachDownloadCount =null; 71 String attachOption =null; 72 String attachStatus =null; 73 74 public MvnForumAttachmentXML() { 75 super(); 76 attachmentXML=new AttachmentXML(); 77 attachmentCreated=false; 78 parentPost=null; 79 } 80 81 public int getAttachmentID() { 82 return attachmentXML.getAttachmentID(); 83 } 84 85 public void setAttachmentID(String id) { 86 if (id!=null) attachmentXML.setAttachmentID(id); 87 } 88 89 95 public void setAttachmentId(String id) { 96 setAttachmentID(id); 97 } 98 99 public int getParentCategoryID() { 100 return attachmentXML.getParentCategoryID(); } 102 103 public int getParentForumID() { 104 return attachmentXML.getParentForumID(); } 106 107 public int getParentThreadID() { 108 return attachmentXML.getParentThreadID(); } 110 111 public int getParentPostID() { 112 return attachmentXML.getParentPostID(); } 114 115 public void setParentPost(Object o) 116 throws ForeignKeyNotFoundException { 117 if (o instanceof MvnForumPostXML) { 118 parentPost=(MvnForumPostXML)o; 119 } else { 121 throw new ForeignKeyNotFoundException("Can't find parent post."); 122 } 123 } 124 125 public void setAttachMemberName(String value) { 126 attachMemberName=value; 127 } 128 129 public void setAttachFilename(String value) { 130 attachFilename=value; 131 } 132 133 public void setAttachFileSize(String value) { 134 attachFileSize=value; 135 } 136 137 public void setAttachMimeType(String value) { 138 attachMimeType=value; 139 } 140 141 public void setAttachDesc(String value) { 142 attachDesc=value; 143 } 144 145 public void setAttachCreationIP(String value) { 146 attachCreationIP=value; 147 } 148 149 public void setAttachCreationDate(String value) { 150 attachCreationDate=value; 151 } 152 153 public void setAttachModifiedDate(String value) { 154 attachModifiedDate=value; 155 } 156 157 public void setAttachDownloadCount(String value) { 158 attachDownloadCount=value; 159 } 160 161 public void setAttachOption(String value) { 162 attachOption=value; 163 } 164 165 public void setAttachStatus(String value) { 166 attachStatus=value; 167 } 168 169 public void addAttachment() throws CreateException, DuplicateKeyException, 170 ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException, BadInputException { 171 176 if (attachmentCreated) return; 177 178 if (parentPost!=null) { 179 parentPost.addPost(); 180 attachmentXML.setParentPostID(parentPost.getPostID()); 181 attachmentXML.setParentThreadID(parentPost.getParentThreadID()); 182 attachmentXML.setParentForumID(parentPost.getParentForumID()); 183 attachmentXML.setParentCategoryID(parentPost.getParentCategoryID()); 184 } 185 186 ImportMvnForum.addMessage("Adding attachment \""+attachFilename+"\"."); 187 attachmentXML.addAttachment(attachMemberName, attachFilename, 189 attachFileSize, attachMimeType, attachDesc, 190 attachCreationIP, attachCreationDate, attachModifiedDate, 191 attachDownloadCount, attachOption, attachStatus); 192 attachmentCreated=true; 193 194 if (parentPost!=null) { 195 parentPost.updateAddedAttachment(this); 196 } 197 } 198 199 200 } 201 | Popular Tags |