/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.isi.karma.imp;

import java.io.IOException;

import org.json.JSONException;

import edu.isi.karma.rep.RepFactory;
import edu.isi.karma.rep.Worksheet;
import edu.isi.karma.rep.Workspace;
import edu.isi.karma.webserver.KarmaException;

/**
 * 
 * This abstract class in an interface to all classes with import functionality
 *
 * @author mielvandersande
 */
public abstract class Import {

    private final RepFactory factory;
    private Worksheet worksheet;
    protected Workspace workspace;
    
    public Import(String worksheetName, Workspace workspace, String encoding) {
        this.factory = workspace.getFactory();
        this.worksheet = factory.createWorksheet(worksheetName, workspace, encoding);
        this.workspace = workspace;
    }

    public Import(RepFactory factory, Worksheet worksheet) {
        this.factory = factory;
        this.worksheet = worksheet;
    }

    public RepFactory getFactory() {
        return factory;
    }

    public Worksheet getWorksheet() {
        return worksheet;
    }
    
    public void createWorksheet(String worksheetName, Workspace workspace, String encoding) {
    	this.worksheet = factory.createWorksheet(worksheetName, workspace, encoding);
    }
    
    /*
     * Generate worksheet from data
     */
    public abstract Worksheet generateWorksheet() throws JSONException, IOException, KarmaException, ClassNotFoundException;
    
}

@@ -600,24 +600,81 @@
 space;%0A    %0A
+    public static int MAX_WORKSHEET_NAME_LEN = 100;%0A    %0A
     public I
@@ -788,16 +788,161 @@
 tory();%0A
+        if(worksheetName.length() %3E MAX_WORKSHEET_NAME_LEN)%0A        %09worksheetName = worksheetName.substring(0, MAX_WORKSHEET_NAME_LEN) + %22...%22;%0A
         

Set a max length for worksheet name