/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.server.resources;

import java.io.*;
import java.util.Vector;
import java.util.Enumeration;

import org.bodington.server.BuildingServerException;
import org.bodington.sqldatabase.*;
import org.bodington.database.*;
import org.bodington.server.realm.User;
import org.bodington.text.BigString;


public class UploadedFileSummary
	implements java.io.Serializable
	{
	public static final int FLAG_FOLDER		=1;
	public static final int FLAG_DELETED	=2;
	
	
	// stored fields
	
	private PrimaryKey uploaded_file_id;
	private PrimaryKey resource_id;					//which resource does the file belong to
	private PrimaryKey parent_uploaded_file_id;		//which folder is it in
	private PrimaryKey create_user_id;
	private PrimaryKey update_user_id;
	private java.sql.Timestamp created_time;	//time this file was created.
	private java.sql.Timestamp updated_time;	//time file was last edited.
	private int flags;							// folder/file deleted/not deleted etc...
	private long size;							// stored in database as two 32 bit integers
	private long bytes_uploaded;				// stored in database as two 32 bit integers
	private String name;
	private String url;							// url encoded name
	private String mime_type;
	
	private int left_index;						//visitation model left index
	private int right_index;					//visitation model right index
	
	
     public PrimaryKey getPrimaryKey()
		{
        return getUploadedFileId();
        }

    void setPrimaryKey(PrimaryKey key)
    	{
    	setUploadedFileId( key );
    	}
    	
    public PrimaryKey getUploadedFileId()
		{
        return uploaded_file_id;
        }

    void setUploadedFileId(PrimaryKey key)
    	{
    	uploaded_file_id = key;
    	}
    	

    public PrimaryKey getResourceId()
		{
        return resource_id;
        }

    void setResourceId(PrimaryKey key)
    	{
    	resource_id = key;
    	}
    	

    public PrimaryKey getParentUploadedFileId()
		{
        return parent_uploaded_file_id;
        }

    void setParentUploadedFileId(PrimaryKey key)
    	{
    	parent_uploaded_file_id = key;
    	}
    	

     void setCreateUserId( PrimaryKey key )
	    {
	    create_user_id = key;
	    }
    public PrimaryKey getCreateUserId()
	    {
        return create_user_id;
	    }


    	
    void setUpdateUserId( PrimaryKey key )
	    {
	    update_user_id = key;
	    }
    public PrimaryKey getUpdateUserId()
	    {
        return update_user_id;
	    }


    	
	public java.sql.Timestamp getCreatedTime()
		{
		return created_time;
		}
	void setCreatedTime( java.sql.Timestamp t )
		{
		created_time = t;
		}


	public java.sql.Timestamp getUpdatedTime()
		{
		return updated_time;
		}
	void setUpdatedTime( java.sql.Timestamp t )
		{
		updated_time = t;
		}


   	public int getFlags()
		{
		return flags;
		}
	void setFlags( int f )
		{
		flags = f;
		}
	public boolean isDeleted()
		{
		return (flags & FLAG_DELETED)!=0;
		}
	public boolean isFolder()
		{
		return (flags & FLAG_FOLDER)!=0;
		}


	public long getSize()
		{
		return size;
		}

	void setSize( long l )
		{
		size = l;
		}


	public long getBytesUploaded()
		{
		return bytes_uploaded;
		}

	void setBytesUploaded( long l )
		{
		bytes_uploaded = l;
		}


	public boolean isComplete()
		{
		return bytes_uploaded == size;
		}


    void setName( String n )
	    {
	    name = n;
	    }

    public String getName()
	    {
        return name;
	    }


    void setUrl( String n )
	    {
	    url = n;
	    }

    public String getUrl()
	    {
        return url;
	    }


    void setMimeType( String n )
	    {
	    mime_type = n;
	    }

    public String getMimeType()
	    {
        return mime_type;
	    }




   	public int getLeftIndex()
		{
		return left_index;
		}
	void setLeftIndex( int l )
		{
		left_index=l;
		}

	public int getRightIndex()
		{
		return right_index;
		}
	void setRightIndex( int r )
		{
		right_index=r;
		}

	}
