001package systems.dmx.files;
002
003import systems.dmx.core.JSONEnabled;
004
005import org.codehaus.jettison.json.JSONObject;
006
007
008
009public class StoredFile implements JSONEnabled {
010
011    // ---------------------------------------------------------------------------------------------- Instance Variables
012
013    private final String fileName;
014    private final String repoPath;
015    private final long fileTopicId;
016
017    // ---------------------------------------------------------------------------------------------------- Constructors
018
019    StoredFile(String fileName, String repoPath, long fileTopicId) {
020        this.fileName = fileName;
021        this.repoPath = repoPath;
022        this.fileTopicId = fileTopicId;
023    }
024
025    // -------------------------------------------------------------------------------------------------- Public Methods
026
027    public String getFileName() {
028        return fileName;
029    }
030
031    public String getRepoPath() {
032        return repoPath;
033    }
034
035    public long getFileTopicId() {
036        return fileTopicId;
037    }
038
039    // ---
040
041    @Override
042    public JSONObject toJSON() {
043        try {
044            return new JSONObject()
045                .put("fileName", fileName)
046                .put("repoPath", repoPath)
047                .put("topicId", fileTopicId);
048        } catch (Exception e) {
049            throw new RuntimeException("Serialization failed", e);
050        }
051    }
052}