*** This class provides Binary Compatibility only, not Source Compatibility ***

Class BinaryFileEntry

java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
com.sas.services.publish.AbstractEntry
com.sas.services.publish.BinaryFileEntry
All Implemented Interfaces:
com.sas.entities.EntityKeyInterface, com.sas.io.InputStreamProviderInterface, BinaryFileEntryInterface, EntryInterface, Serializable, Remote

@SASScope("ALL") @BinaryCompatibilityOnly public class BinaryFileEntry extends AbstractEntry implements BinaryFileEntryInterface
Represents a binary file entry that can then be added to a result package for publishing. See Constructing a Result Package to Publish for an example of how this class is used.
Since:
1.0
See Also:
  • Constructor Details

    • BinaryFileEntry

      public BinaryFileEntry(File file) throws IllegalArgumentException, RemoteException
      Creates a binary file entry. When the binary file is published, the file name is used as the name. If a different name is preferred, use the constructor that takes the input stream and the name of the entry.

      There is no default MIME type. To set the MIME type for the entry, use setMIMEType(java.lang.String).

      Parameters:
      file - The binary file.
      Throws:
      IllegalArgumentException - If a null file is specified.
      RemoteException - If a network anomaly is encountered.
    • BinaryFileEntry

      public BinaryFileEntry(InputStream inputStream, String name) throws IllegalArgumentException, RemoteException
      Creates a binary file entry. When the binary file is published, the input stream will be consumed until end-of-file.

      There is no default MIME type. To set the MIME type for the entry, use setMIMEType(java.lang.String).

      Parameters:
      inputStream - The input stream of the binary file.
      name - The name of the binary file entry. This name will be used as the name of the entry when publishing the package.
      Throws:
      IllegalArgumentException - If a null input stream or a null name is specified.
      RemoteException - If a network anomaly is encountered.
  • Method Details

    • getName

      public String getName() throws RemoteException, TransportException, IllegalStateException
      Returns the name of the file.
      Specified by:
      getName in interface BinaryFileEntryInterface
      Returns:
      String The name of the file.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      TransportException - If the transport encounters an error getting the name.
      RemoteException - If a network anomaly is encountered.
    • getMIMEType

      public String getMIMEType() throws RemoteException, TransportException, IllegalStateException
      Returns the MIME type associated with this binary file entry. The user-specified MIME type is assigned when the binary file entry is published.
      Specified by:
      getMIMEType in interface BinaryFileEntryInterface
      Returns:
      String The MIME type associated with this binary file entry; can be null.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      TransportException - If the transport encounters an error getting the MIME type.
      RemoteException - If a network anomaly is encountered
    • setMIMEType

      public void setMIMEType(String mimeType) throws IllegalStateException, RemoteException
      Sets the MIME associated with this file entry.
      Specified by:
      setMIMEType in interface BinaryFileEntryInterface
      Parameters:
      mimeType - The MIME type associated with this file entry.
      Throws:
      IllegalStateException - If the entry is read only or if the package containing this entry has already been closed.
      RemoteException - If a network anomaly is encountered.
    • getInputStream

      public InputStream getInputStream() throws IOException, RemoteException, IllegalStateException
      Gets the input stream for this binary file entry.
      Specified by:
      getInputStream in interface BinaryFileEntryInterface
      Returns:
      The input stream that can be used for reading the contents of the binary file entry.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      IOException - If an error occurs constructing the input stream.
      RemoteException - If a network anomaly is encountered.
    • getInputStream

      public InputStream getInputStream(Object streamID) throws IOException, RemoteException, UnmarshalException, IllegalStateException
      Deprecated.
      Use getInputStream()which now supports remote input streams.
      Gets the input stream for this binary file entry. Because input streams are not remotable, this method will throw a RemoteException if it is invoked on a remote object. Distributed applications should utilize getRemoteInputStream(java.lang.Object)in order to obtain the input stream.
      Specified by:
      getInputStream in interface BinaryFileEntryInterface
      Specified by:
      getInputStream in interface com.sas.io.InputStreamProviderInterface
      Parameters:
      streamID - The stream description should be null; it will be ignored.
      Returns:
      The input stream that can be used for reading the contents of the binary file entry.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      UnmarshalException - If invoked on a remote object.
      IOException - If an error occurs constructing the input stream.
      RemoteException - If a network anomaly is encountered.
    • getRemoteInputStream

      public com.sas.io.RemoteInputStreamInterface getRemoteInputStream(Object streamID) throws com.sas.io.ChainedIOException, RemoteException, IllegalStateException
      Deprecated.
      Use getInputStream()which now supports remote input streams.
      Get the binary file as a remote input stream. If your application runs in a distributed environment, it is suggested that you use RemoteInputStream. InputStreams are not remote objects.
      Specified by:
      getRemoteInputStream in interface BinaryFileEntryInterface
      Specified by:
      getRemoteInputStream in interface com.sas.io.InputStreamProviderInterface
      Parameters:
      streamID - The stream description should be null ;it will be ignored.
      Returns:
      RemoteInputStream The file as a remote input stream.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      com.sas.io.ChainedIOException - If an I/O error occurs obtaining the input stream.
      RemoteException - If a network anomaly is encountered.
    • hasInputStream

      public Object hasInputStream() throws UnmarshalException, RemoteException, IllegalStateException
      Deprecated.
      this method no longer needed as getInputStream() will return an input stream that can be used in a remote environment
      Check if getInputStream(java.lang.Object)will succeed. See getInputStream(java.lang.Object)to determine whether this method should be used.
      Specified by:
      hasInputStream in interface BinaryFileEntryInterface
      Specified by:
      hasInputStream in interface com.sas.io.InputStreamProviderInterface
      Returns:
      non-null if getInputStream(java.lang.Object) would succeed; throws UnmarshalException if it would fail
      Throws:
      UnmarshalException - if invoked on a remote object
      IllegalStateException - If the package containing this entry is already closed.
      RemoteException - if a network I/O error occurs.
    • consumeStream

      public void consumeStream() throws IOException, RemoteException, IllegalStateException
      Consume and close the input stream provided on the constructor. If an input stream is provided on the entry's constructor, then it does not get consumed until the package is published. This method may be invoked to force the stream to get consumed and closed immediately instead of waiting until the publish occurs.
      Throws:
      IllegalStateException - If the package containing this entry is already closed.
      IOException - If an error occurs constructing the input stream.
      RemoteException - If a network anomaly is encountered.
    • closeEntry

      protected void closeEntry()
      Remove any temporary files needed for inputstream re-use and mark this entry as closed.
    • finalize

      protected void finalize() throws Throwable
      At finalize time, cleanup temporary files if necessary.
      Overrides:
      finalize in class Object
      Throws:
      Throwable