001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on Jan 18, 2005 2:58:22 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.entities;
044:
045: import java.io.File;
046:
047: import net.jforum.util.preferences.ConfigKeys;
048: import net.jforum.util.preferences.SystemGlobals;
049:
050: /**
051: * @author Rafael Steil
052: * @version $Id: Attachment.java,v 1.5 2006/08/20 22:47:35 rafaelsteil Exp $
053: */
054: public class Attachment {
055: private int id;
056: private int postId;
057: private int privmsgsId;
058: private int userId;
059: private AttachmentInfo info;
060:
061: /**
062: * @return Returns the id.
063: */
064: public int getId() {
065: return this .id;
066: }
067:
068: /**
069: * @param id The id to set.
070: */
071: public void setId(int id) {
072: this .id = id;
073: }
074:
075: /**
076: * @return Returns the postId.
077: */
078: public int getPostId() {
079: return this .postId;
080: }
081:
082: /**
083: * @param postId The postId to set.
084: */
085: public void setPostId(int postId) {
086: this .postId = postId;
087: }
088:
089: /**
090: * @return Returns the privmsgsId.
091: */
092: public int getPrivmsgsId() {
093: return this .privmsgsId;
094: }
095:
096: /**
097: * @param privmsgsId The privmsgsId to set.
098: */
099: public void setPrivmsgsId(int privmsgsId) {
100: this .privmsgsId = privmsgsId;
101: }
102:
103: /**
104: * @return Returns the userId.
105: */
106: public int getUserId() {
107: return this .userId;
108: }
109:
110: /**
111: * @param userId The userId to set.
112: */
113: public void setUserId(int userId) {
114: this .userId = userId;
115: }
116:
117: /**
118: * @return Returns the info.
119: */
120: public AttachmentInfo getInfo() {
121: return this .info;
122: }
123:
124: /**
125: * @param info The info to set.
126: */
127: public void setInfo(AttachmentInfo info) {
128: this .info = info;
129: }
130:
131: public boolean hasThumb() {
132: return SystemGlobals
133: .getBoolValue(ConfigKeys.ATTACHMENTS_IMAGES_CREATE_THUMB)
134: && new File(SystemGlobals
135: .getValue(ConfigKeys.ATTACHMENTS_STORE_DIR)
136: + '/'
137: + this .info.getPhysicalFilename()
138: + "_thumb").exists();
139: }
140:
141: public String thumbPath() {
142: return SystemGlobals
143: .getValue(ConfigKeys.ATTACHMENTS_UPLOAD_DIR)
144: + '/' + this .info.getPhysicalFilename() + "_thumb";
145: }
146: }
|