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