Package ca.carleton.gcrc.couch.onUpload.conversion

Source Code of ca.carleton.gcrc.couch.onUpload.conversion.OriginalFileDescriptor

package ca.carleton.gcrc.couch.onUpload.conversion;

import java.io.File;

import net.sf.json.JSONObject;
import ca.carleton.gcrc.couch.onUpload.UploadConstants;

public class OriginalFileDescriptor extends AbstractDescriptor {

  private AttachmentDescriptor attDescription;
 
  public OriginalFileDescriptor(AttachmentDescriptor attDescription){
    this.attDescription = attDescription;
  }

  public File getMediaFile(){
    File file = null;
   
    JSONObject originalObj = getJson();
    if( originalObj.containsKey(UploadConstants.MEDIA_FILE_KEY) ) {
      String mediaFileName = originalObj.optString(UploadConstants.MEDIA_FILE_KEY);
      file = new File(attDescription.getMediaDir(), mediaFileName);
    }
   
    return file;
  }
 
  public String getMediaFileName() {
    return getStringAttribute(UploadConstants.MEDIA_FILE_KEY);
  }
 
  public void setMediaFileName(String mediaFileName) {
    setStringAttribute(UploadConstants.MEDIA_FILE_KEY,mediaFileName);
  }
 
  public String getContentType() {
    return getStringAttribute(UploadConstants.MIME_KEY);
  }
 
  public void setContentType(String contentType) {
    setStringAttribute(UploadConstants.MIME_KEY,contentType);
  }
 
  public String getEncodingType() {
    return getStringAttribute(UploadConstants.ENCODING_KEY);
  }
 
  public void setEncodingType(String encodingType) {
    setStringAttribute(UploadConstants.ENCODING_KEY,encodingType);
  }
 
  public long getSize() {
    return getLongAttribute(UploadConstants.SIZE_KEY);
  }
 
  public void setSize(long size) {
    setLongAttribute(UploadConstants.SIZE_KEY, size);
  }
 
  public int getHeight() {
    return getIntAttribute(UploadConstants.HEIGHT_KEY);
  }
 
  public void setHeight(int height) {
    setIntAttribute(UploadConstants.HEIGHT_KEY, height);
  }
 
  public int getWidth() {
    return getIntAttribute(UploadConstants.WIDTH_KEY);
  }
 
  public void setWidth(int width) {
    setIntAttribute(UploadConstants.WIDTH_KEY, width);
  }
 
  @Override
  protected JSONObject getJson(){
    JSONObject attachmentDescription = attDescription.getJson();
   
    JSONObject originalFileDescription = attachmentDescription.optJSONObject(UploadConstants.ORIGINAL_FILE_KEY);
   
    return originalFileDescription;
  }

  @Override
  protected void setSavingRequired(boolean flag) {
    attDescription.setSavingRequired(flag);
  }
}
TOP

Related Classes of ca.carleton.gcrc.couch.onUpload.conversion.OriginalFileDescriptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.