Personal tools

Pawn:TransferContext

From Adapt

Jump to: navigation, search
/*
 * TransferContext.java
 *
 * Created on February 10, 2006, 3:19 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package edu.umiacs.pawn.resource;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

/**
 *
 * @author toaster
 */
public interface TransferContext
{
    /**
     * Return ID of current object. This is only valid between start/end object
     * calls.
     *
     * @return urn of current object
     */
    public long getCurrentObject();
    
    
    /**
     * Retrun the id of the current working manifest. This is only valid between
     * start/end manifest calls.
     *
     * @return urn of current manifest
     */
    public long getCurrentManifest();
    
    /**
     * Get the namespace of the current manifest. This is only valid between 
     * start/end manifest calls
     *
     * @return namespace of current manifest
     */
    public String getNamespace();
    
    /**
     * get the absolute path of an item from the category/obligation root to 
     * parent manifest.
     *
     * @return path from obligation root to parent manifest
     */
    public long[] getAbsoluteParentPath();
    
    
    /**
     * get the parent path from the user-chosen manifest to current parent.
     *
     * @return parent path from selected manifest, or null if working on root manifest
     *
     */
    public long[] getRelativeParentPath();
    
    /**
     * Return the descriptive name for a path component.
     *
     * @return descriptive name of path, null if pathID is not part of current path
     */
    public String getPathComponentName(long pathID);
    
    /***
     *
     * Context-specific properties
     *
     */
    
    /**
     * Set an error message for a given item. The error will be attached to the 
     * current object/manifest/metadata. If this is called prior to any object/manifest
     * it's assumed the error applies to the entire archive action. Multiple errors
     * may be added to any item.
     *
     * @param name descriptive name of the error
     * @param fatal did this error prevent the item from being archived.
     * @param content descriptive message about this error, may be null.
     *
     */
    public void addError(String name, boolean fatal, String content);
    
    /**
     * Abort the entire transfer. This should be used lightly and mainly in the
     * startTransfer/setParameters calls. Resources should handle any cleanup prior
     * to calling this. Calling abort will result in NO more calls to the DataMover, ie
     * you will not get EndTransfer called.
     *
     * @param reason short reason why transfer aborted
     * @param details detailed message, IE stack trace, or other descriptive message. May be null.
     */
    public void abortTransfer(String reason, String details);
    
    /**
     * Return an input stream for the current object/manifest/metadata. This is 
     * only gaurenteed to be available during calls to processXXX. Any other time
     * the result is undefined.
     *
     * @throws java.io.IOException If pawn cannot retrieve bits from a reservation, generally shouldn't happen
     *
     * @return inputstream to current item
     */
    public InputStream getInputStream() throws IOException;
    
    /**
     * Return name of current metadata/object/manifest as defined by the creating 
     * interface
     *
     * @return get name of current item
     */
    
    
    
    public String getName(); 
    
    /**
     * Return type of current metadata/object/manifest as defined by the creating 
     * interface
     *
     * @return get bundle-defined type of current item
     */
    public String getType(); 
    
    /**
     * return mime type of current object/metadata, not valid for manifests
     *
     * @return mimetype of current item
     */
    public String getMimeType();
    
    /**
     * Return creation date for metadata/data if appropriate. 
     *
     * @return creation date of current item
     */
    public Date getCreationDate();
    
    /**
     * get size of item, valid for objects/metadata only
     *
     * @return size of current item
     */
    public long getSize();
    
    /**
     * return current urn, valid for metadata/data/manifest
     *
     * @return string urn of item
     */
    public long getID();
    
    /**
     * get original url of items, valid for objects/metadata only.
     *
     * @return url of item
     */
    public String getOriginalURL();
    
    /**
     * get checksum, valid for objects only
     *
     * @return checksum string
     */
    public String getChecksum();
    
    /**
     * get mets checksum type sring, valid for objects only
     *
     * @return checksum type string
     */
    public String getChecksumType();
    
    /**
     * get a temporary directory. Any items in this directory will be deleted 
     * after the resource is finished.
     *
     */
    public java.io.File getTemporaryDirectory() throws java.io.IOException;
    
    
}

-- Main.MikeSmorul - 02 Nov 2007