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 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 JSONObject storedFile = new JSONObject(); 045 storedFile.put("file_name", fileName); 046 storedFile.put("repo_path", repoPath); 047 storedFile.put("topic_id", fileTopicId); 048 return storedFile; 049 } catch (Exception e) { 050 throw new RuntimeException("Serialization failed (" + this + ")", e); 051 } 052 } 053}