***  This package contains classes that provide Binary Compatibility only, not Source Compatibility  ***

Note:
Extension of the classes in this package is prohibited unless otherwise documented. Similarly, extension or implementation of the interfaces in this package is prohibited except as documented.

Package com.sas.services.publish

Publish services.

See:
          Description

Interface Summary
BinaryFileEntryInterface The BinaryFileEntryInterface provides a mechanism for setting and getting the attributes of a binary file entry.
ChannelTransportInterface The ChannelTransportInterface provides a mechanism for publishing a result package to a channel.
DatasetEntryInterface The DatasetEntryInterface provides a mechanism for getting the attributes of a data set entry.
EntryInterface The EntryInterface provides a mechanism for getting and setting the attributes of a result package or result package entry.
EventDataInterface Contains the SASPackage event data.
HTMLEntryInterface The HTMLEntryInterface provides a mechanism for getting and setting the attributes of an HTML entry.
HTMLFileInterface The HTMLFileInterface provides a mechanism for setting and getting the attributes of a file contained within an HTML entry.
LibraryMemberEntryInterface The LibraryMemberEntryInterface provides a mechanism for setting and getting the attributes of a library member entry.
MailInterface Interface that defines common mail recipient information.
ReferenceEntryInterface The ReferenceEntryInterface provides a mechanism for setting and getting the attributes of a reference entry.
RemoteResultSetInterface Remotable interface corresponding to java.sql.ResultSet.
ResultPackageInterface The ResultPackageInterface provides a mechanism for setting and getting the attributes of a result package.
ResultSetProviderInterface An object which provides result sets which may be remote.
ServiceResultSetMetaDataInterface The ServiceResultSetMetaDataInterface provides a mechanism for getting the information about the types and properties of the columns in a ResultSet object.
TextFileEntryInterface The TextFileEntryInterface provides a mechanism for setting and getting the attributes of a text file entry.
TransportInterface The TransportInterface interface provides common behavior for delivery transports when retrieving and publishing result packages.
ViewerEntryInterface The ViewerEntryInterface provides a mechanism for setting and getting the attributes of a viewer entry.
 

Class Summary
AbstractEntry Abstract implementation of a result package entry.
AnnotatedServiceResultSet This class defines the methods needed to consume column and data set annotations.
BinaryFileEntry Represents a binary file entry that can then be added to a result package for publishing.
DirectoryHierarchy The publishing framework directory hierarchy.
EventData Contains the SASPackage event data.
ExtendedAttributeData This class represents the extended attribute information for a data set.
HTMLEntry Represents an HTML entry that can then be added to a result package for publishing.
HTMLFile The HTMLFileInterface provides a mechanism for setting and getting the attributes of a file contained within an HTML entry.
MailAttachment Container class for maintaining email attachment information.
ReferenceEntry Represents a reference entry that can then be added to a result package for publishing.
RemoteResultSet Remotable interface corresponding to java.sql.ResultSet.
ResultPackage Represents a result package that can then be published using one of the supported delivery transports.
TextFileEntry Represents a text file entry that can then be added to a result package for publishing.
TransportFactory A factory used to manufacture delivery transport objects.
ViewerEntry Represents a viewer entry that can then be added to a result package for publishing.
 

Package com.sas.services.publish Description

Publish services.

Publish Services

Overview

Supported Delivery Transports

ResultSet Usage

Data Set Extended Attribute Support

SASPackage Event Usage

Examples

Overview

Publishing services provide a native JAVA interface for dynamic content publishing. The publish services enable you to write applications that create, populate, publish and retrieve collections of information known as result packages. For example, it can be utilized to publish collected reports, tables, or documents.

Supported Delivery Transports

At this time, the archive, channel, requester, and WebDAV delivery transports are supported. The TransportFactory class should be used to create the specific delivery transport objects. Each delivery transport provides a mechanism for publishing the result package and retrieving a result package.

Announcements will be made as future delivery transports become available.

Archive Transport

The archive transport allows applications to publish and retrieve packages to an archive. An archive is a result set package that is compressed and saved to a directory file. It is a single binary collection of all items in a package. The archive contains the contents of a package and metadata that is necessary for extracting the contents. An archive is compressed using ZIP compression and is saved with an SPK extension.

Channel Transport

The channel transport allows applications to publish packages to a channel. A channel is a topic or identifier that acts as a conduit for related information. The package is published to each subscriber of the channel. How the package is delivered to each subscriber is determined by the subscriber's metadata. The channel and subscriber metadata is configured in the SAS Metadata Repository. The Publish Framework Plugin within the SAS Management Console can be used to configure channels and subscribers.

A publish channel can be defined with an archive or a WebDAV persistent store. The package is persisted to this location and is then published to all subscribers of the channel. A utility has been provided to help in cleaning up the channel. The persisted metadata and the persisted packages can be deleted using the Package Cleanup Utility. This utility is a Java class that provides a simple, command line interface for deleting packages from a publish channel based on the expiration date of the package. This utility supports the deletion of packages from either type of persistent store.

Requester Transport

Applications can utilize the Requester transport to retrieve packages accessible by an IOM Workspace server.

WebDAV Transport

Applications can utilize the WebDAV delivery transport to publish and retrieve from a WebDAV web server. WebDAV (Web-based Distributed Authoring and Versioning) is an emerging industry standard that is based on extensions to HTTP 1.1. WebDAV enables collaborative development of files and collections of files on remote Web servers. A WebDAV server facilities concurrent access to and update of package data on the Internet.

WebDAV is documented in RFC2518. Visit the WebDAV site for more information.

ResultSet Usage

Data set entries implement the com.sas.services.publish.ResultSetProviderInterface because they provide result sets which may be remote. Non-distributed applications should use the entry's getResultSet() method to retrieve the local result set:

     DatasetEntryInterface datasetEntry = .......;
     ResultSet rs;
     try
     {
        rs = datasetEntry.getResultSet();
     }
     catch (RemoteException e)
     {
       // do something with exception
     }
     catch (IOException e)
     {
       // do something with exception
     }
 

java.sq.ResultSet cannot be exposed over a remote interface because it is not a remote interface and is not serializable. Therefore, distributed applications should use the static convenience method, getResultSet() on com.sas.services.publish.RemoteResultSet to obtain the data set entry's result set. This convenience method obtains the local result set if possible. Otherwise, if the provider is a remote object, the remote result set is obtained and returned as a ResultSet. The client can get the local or remote result set with a single method call.

     DatasetEntryInterface datasetEntry = .......;
     ResultSet rs;
     try
     {
        rs = RemoteResultSet.getResultSet(datasetEntry);
     }
     catch (RemoteException e)
     {
       // do something with exception
     }
     catch (IOException e)
     {
       // do something with exception
     }
 

Data Set Extended Attribute Support

Extended Attributes are a set of name/value pairs that are associated with either a column within a SAS data set or a SAS dat set in general. Extended attributes are now supported on SAS data sets. In order to access the extended attributes, callers should use the isWrapperFor and unwrap methods on the ResultSet as follows:

     DatasetEntryInterface datasetEntry = .......;
     ResultSet resultSet;
     // Unwrap ResultSet instance to gain access to the AnnotatedResultSet methds
    com.sas.sql.AnnotatedResultSet attrs;
 
    try
     {
        resultSet = datasetEntry.getResultSet();
        if (resultSet.isWrapperFor(com.sas.sql.AnnotationResultSet.class) == true)
        {    
           System.out.println("ResultSet annotations are supported with this data set.");
           attrs = resultSet.unwrap(com.sas.sql.AnnotatedResultSet);
        }
        else
        {
           System.out.println("ResultSet annotations not supported with this data set.")
        }
     }
     catch (RemoteException e)
     {
      // do something with exception
    }
     catch (IOException e)
     {
       // do something with exception
     }
 

This is an example of reading the data set annotations:

 // Check for Data Set Annotations
 if (attrs.hasResultSetAnnotations())
 {
    // Print the collection of annotations
    System.out.println("The data set annotations are:");
    Map data = attrs.getResultSetAnnotations();
    Iterator> it = data.entrySet().iterator();
    while (it.hasNext())
    {
       Map.Entry pairs = it.next();
       if (pairs.getValue() instanceof String)
       {
          System.out.println("  '" + pairs.getKey() + "', '" + pairs.getValue() + "'");
       }
       else if (pairs.getValue() instanceof Double)
       {
          System.out.println("  '" + pairs.getKey() + "', " + pairs.getValue());
       }
    }
 }
 else
 {
    System.out.println("There are no data set annotations.");
 }
 
 

SASPackage Event Usage

The Event Services are provided as a part of the Foundation Services. A variety of asynchronous notification and request management services will be provided to support dyanmic-event driven, processes.

A SASPackage Event is an XML event that contains metadata describing the result package. If the package was persisted, the SASPackage Event will contain a URL to the persisted package.

The Publish Services allow you to create and obtain the body portion of the SASPackage event. A SASPackage event body can be created in two different ways. Use publishResultPackage(com.sas.services.publish.ResultPackageInterface, boolean) to obtain the SASPackage event body that describes the result package that was just published. After the result package is published, the event data is returned. The event data contains the SASPackage event body, along with other event information. The event body describes the published result package and will include information such as a URL to where it has been persisted, as well as what transport was used to publish the result package.

The second way to create the SASPackage event body is by invoking getEventData() on a result package instance. The result package will create a SASPackage event that is self-describing. If the result package was retrieved using one of the supported delivery transports, the SASPackage event body will contain the persistence information that describes how the package was published.

The specification for the published package event is as follows:

 <sas-event:Event xmlns:sas-event="http://www.sas.com/xml/namespace/services.events-1.1" sas-event:name="SASPackage.ChannelName">
  <sas-event:Header>
   <sas-event:Version>1.0</sas-event:Version>
   <sas-event:SentAt>timestamp</sas-event:SentAt>
  </sas-event:Header>
  <sas-event:Body>
   <sas-publish:Package  xmlns:sas-publish="http://www.sas.com/xml/namespace/services.publish-1.1"
xmlns:userSpecPkgNamespace="userSpecPakgNamespaceValue"
sas-publish:version="1.0"
sas-publish:description="package description"
sas-publish:abstract="package abstract"
                sas-publish:channel="channel on which the package was published"
sas-publish:packageUrl="URL to persisted package
userSpecName="value" > <sas-publish:Entries> <sas-publish:Entry sas-publish:type="catalog" sas-publish:description="description" userSpecName="value"> <sas-publish:Catalog sas-publish:name="member name"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="dataset" sas-publish:description="description" userSpecName="value"> <sas-publish:Dataset sas-publish:name="member name"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="fdb" sas-publish:description="description" userSpecName="value"> <sas-publish:FDB sas-publish:name="member name"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="file" sas-publish:description="description" userSpecName="value"> <sas-publish:File sas-publish:type="text or binary" sas-publish:name="file name" sas-publish:mimetype="MIME type"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="html" sas-publish:description="description" userSpecName="value"> <sas-publish:HTML sas-publish:type="body, frame, contents or page" sas-publish:name="file name" sas-publish:url="URL"/> <sas-publish:Companion sas-publish:name="file name" url="URL" sas-publish:mimetype="MIME type"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="mddb" sas-publish:description="description" userSpecName="value"> <sas-publish:MDDB sas-publish:name="member name"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="reference" sas-publish:description="description" userSpecName="value"> <sas-publish:Reference sas-publish:type="html or url" sas-publish:reference="reference"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="sqlview" sas-publish:description="description" userSpecName="value"> <sas-publish:SQLView sas-publish:name="member name"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="viewer" sas-publish:description="description" userSpecName="value"> <sas-publish:Viewer sas-publish:type="text or html" sas-publish:name="file name" sas-publish:mimetype="MIME type"/> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="nestedpackage" sas-publish:description="description" userSpecName="value"> <sas-publish:Package xmlns:userSpecPackageNamespace="userSpecPackageNamespaceValue"
sas-publish:description="package description" sas-publish:abstract="package abstract"
                    userSpecName="value" > <sas-publish:Entries> <sas-publish:Entry sas-publish:type="entry type" sas-publish:description="description" userSpecName="value"> </sas-publish:Entry> . . additional Entry elements for this nested package . . </sas-publish:Entries> </sas-publish:Package> </sas-publish:Entry> </sas-publish:Entries/> </sas-publish:Package> </sas-event:Body> </sas-event:Event>

The header elements, are standard event elements as defined by the Event Services. The name of the event will be "SASPackage", followed by a "." separator, followed by the channel name. The following table offers an explanation of how these header elements will be set/used within the publish framework.

Element Description
sas-event:Version Version of the event message.
sas-event:SentAt A timestamp indciating when the event was sent.

Explanations of the body elements are in the following table:

Element Description
sas-publish:Package Begins the package definition. Supported attributes for this element include:
  • sas-publish:version - the SASPackage version
  • sas-publish:description - the package description
  • sas-publish:abstract - the package abstract
  • sas-publish:channel - the channel on which the package was published
  • sas-publish:packageUrl - a URL to the persisted package. Packages may be persisted to an archive or to a WebDAV server.
  • one or more user-specified name/value pairs
The sas-publish namespace is defined in this element. Additionally, other user-specified namespaces may be declared in this element via the xmlns:prefix. These will be included if the user specified the NAMESPACES property when creating the package.
sas-publish:Entries Define the entries contained within the package.
sas-publish:Entry Define an individual entry of the package. This element will contain the required attribute, sas-publish:type. This attribute identifies the type of entry. Valid types include, catalog, dataset, fdb, file, html, mddb, reference, sqlview, viewer, and nestedpackage. If the entry description was specfied at publish time, the sas-publish:description attribute will be included. If a name/value was specified for the entry, one or more user-specified name/value attributes will be included in the element. The name portion of the name/value specification will be provided as the attribute, and the value portion will be provided as the attribute value.
sas-publish:Catalog Defines an individual catalog entry. The required sas-publish:name attribute provides the catalog member name.
sas-publish:Dataset Defines an individual data set entry. The required sas-publish:name attribute provides the dataset member name.
sas-publish:FDB Defines an individual FDB entry. The required sas-publish:name attribute provides the FDB member name.
sas-publish:File Defines an individual file entry. The sas-publish:name and sas-publish:type attributes are required. They provide the filename and the file type. Valid file types include text or binary. Optionally, the user-specified MIME type of the file entry will be provided in the sas-publish:mimetype attribute.
sas-publish:HTML Defines an individual HTML entry. The required sas-publish:type and sas-publish:name attributes identify the type of HTML file, and its file name. Valid types include body, frame, contents and page. Optionally, the sas-publish:url attribute identifies the URL.
sas-publish:Companion Defines an individual companion file in an HTML entry. The required sas-publish:name attribute identifies name of the file. Optionally, the url and sas-publish:mimetype attributes may be provided. They identify the URL and the MIME type of the file, respectively.
sas-publish:MDDB Defines an individual MDDB entry. The required sas-publish:name attribute provides the MDDB member name.
sas-publish:Reference Defines an individual reference entry. The required sas-publish:type attribute identifies the type of reference, either html or url. The actual reference inserted into the package is provied in the sas-publish:reference attribute.
sas-publish:SQLView Defines an individual SQL view. The required sas-publish:name attribute provides the SQL view member name.
sas-publish:Viewer Defines an individual viewer entry. The viewer type is provided in the sas-publish:type attribute. Valid types include text or html. The sas-publish:name attribute identifies the name of the viewer file. Optionally, the user-specified MIME type for the viewer entry will be provided in the sas-publish:mimetype attribute.

Here is an example of a SASPackage event body. The result package that was published contains an external file and a reference . Because the package was published to a WebDAV server, the sas-publish:packageUrl attribute is specified. This attribute is a URL to the persisted package. The package was published with a name/value specification of "report=revenue department=research".
 <sas-publish:Package
 
     xmlns:sas-publish="http://www.sas.com/xml/namespace/services.publish-1.1"
     sas-publish:version="1.0"
     sas-publish:description="Revenue Info"
     sas-publish:packageUrl="http://alphaliteAirways.com/revenue/reports/2001/quarter3"
     report="revenue"
     department="research"> <sas-publish:Entries> <sas-publish:Entry sas-publish:type="file" sas-publish:description="Revenue graph"> <sas-publish:File sas-publish:type="binary" sas-publish:name="revenue.gif" sas-publish:mimetype="image/gif" /> </sas-publish:Entry> <sas-publish:Entry sas-publish:type="reference" sas-publish:description="Revenue details."> <sas-publish:Reference sas-publish:type="html" sas-publish:reference="http://www.alphaliteAirways.com/revenue.html" /> </sas-publish:Entry> </sas-publish:Entries> </sas-publish:Package>

Examples

Constructing a Result Package to Publish

This example demonstrates how to construct a result package that can then be published using one of the supported delivery transports.

 import com.sas.services.TransportException;
 import com.sas.services.publish.BinaryFileEntryInterface;
 import com.sas.services.publish.BinaryFileEntry;
 import com.sas.services.publish.HTMLEntry;
 import com.sas.services.publish.HTMLEntryInterface;
 import com.sas.services.publish.HTMLFile;
 import com.sas.services.publish.HTMLFileInterface;
 import com.sas.services.publish.ReferenceEntry;
 import com.sas.services.publish.ReferenceEntryInterface;
 import com.sas.services.publish.ResultPackage;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TextFileEntryInterface;
 import com.sas.services.publish.TextFileEntry;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.archive.ArchiveTransportInterface;
 import com.sas.services.util.AttributeMap;
 import com.sas.services.util.AttributeMapInterface;
 import java.io.File;
 import java.rmi.RemoteException;
 try
 {
    // create a new result package, passing in namevalues, description and properties
    AttributeMapInterface nv = new AttributeMap();
    nv.setAttribute("type", "report");
    ResultPackageInterface rpkg =  new ResultPackage();
    rpkg.setDescription("Alphalite Airways Package.");
    rpkg.setNameValuePairs(nv);
    // create a reference entry
    String reference = "http://AlphaliteAirways.com";
    ReferenceEntryInterface ref = new ReferenceEntry(reference, ReferenceEntry.URL_REFERENCE);
    nv = new AttributeMap();
    nv.setAttribute("etype", "ref");
    nv.setAttribute("Quarter4", "");
    ref.setDescription("Alphalite Airways Home Page.");
    ref.setNameValuePairs(nv);
    // add the reference entry to thhresult package
    rpkg.addEntry(ref);
    //create nested package that will contain the HTML reports
    ResultPackageInterface nested = new ResultPackage();
    nested.setDescription("This is my nested package.");
    AtributeMapInterface nestedNV = new AttributeMap();
    nestedNV.setAttribute("type", "report");
    nestedNV.setAttribute("region", "south");
    nestedNV.setAttribute("quarter", "4");
    nested.setNameValuePairs(nestedNV);
    // add nested package to the main result package
    rpkg.addEntry(nested);
    // create an HTML set entry
    File bodyFile = new File("c:\\body.html");
    File frameFile = new File("c:\\frame.html");
    File contentsFile = new File("c:\\contents.html");
    File pageFile = new File("c:\\page.html");
    File companionFile = new File("C:\\testsrc\\gchart.gif");
    File anotherBody = new File("c:\\body1.html");
    HTMLEntryInterface html = new HTMLEntry();
    html.setDescription("HTML Quarterly Sales Report.");
    // add all the files to the HTML set
    HTMLFileInterface frame = new HTMLFile(frameFile, HTMLFileInterface.MAIN_FRAME_FILE);
    frame.setURL("frame.html");
    html.setFile(frame);
    HTMLFileInterface body = new HTMLFile(bodyFile, HTMLFileInterface.BODY_COMPANION);
    body.setURL("body.html");
    html.addCompanionFile(body);
    HTMLFileInterface contents = new HTMLFile(contentsFile, HTMLFileInterface.CONTENTS_COMPANION);
    contents.setURL("contents.html");
    html.addCompanionFile(contents);
    HTMLFileInterface page = new HTMLFile(pageFile, HTMLFileInterface.PAGE_COMPANION);
    page.setURL("page.html");
    html.addCompanionFile(page);
    HTMLFileInterface comp = new HTMLFile(companionFile, HTMLFileInterface.MISC_COMPANION);
    comp.setURL("part1.gif");
    comp.setMIMEType("image//gif");
    html.addCompanionFile(comp);
    // add the HTML entry to the nested result package
    nested.addEntry(html);
    // lets create/add text file entry
    File textFile = new File("c:\\jobs\\report.sas");
    TextFileEntryInterface fileEntry = new TextFileEntry(textFile);
    fileEntry.setDescription("Job used to create the Sales Quarterly Reports.");
    fileEntry.setMIMEType("application/sas");
    nv = new AttributeMap();
    nv.setAttribute("jobType", "salesReport");
    fileEntry.setNameValuePairs(nv);
    // add the text file to the result package
    rpkg.addEntry(fileEntry);
    // lets create/add binary file entry
    File binFile = new File("c:\\jobs\\report.gif");
    BinaryFileEntryInterface binEntry = new BinaryFileEntry(binFile);
    binEntry.setDescription("Quarterly Report Graph.");
    binEntry.setMIMEType("image/gif");
    // add the binary file to the result package
    rpkg.addEntry(binEntry);
    // Now the result package can be published using
    // one of the delivery transports. This
    // example publishes the result package to an archive.
    File f = new File("C:\\monthly.spk");
    TransportFactory factory = new TransportFactory();
    ArchiveTransportInterface archive = factory.getArchiveTransport(f, null, null);
    archive.publishResultPackage(rpkg, false);
    
    // when done with the package, call close()
    rpkg.close();
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 catch (RemoteException e)
 {
    // do something with exception
 }
 

WebDAV Example

The following code example uses the webDAV transport to bind to a webDAV compliant web server. It then retrieves the package, identified by the collection URL set on the transport.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.webdav.DAVTransportInterface;
 import com.sas.services.util.AttributeMapInterface;
 import java.rmi.RemoteException;
 import java.util.Iterator;
 ResultPackageInterface pkg=null;
 try
 {
    String url = "http://myHost.server.com/~weekly/Sales";
    String user = "myUserId";
    String password = "myPassword";
    TransportFactory factory = new TransportFactory();
    DAVTransportInterface dav = factory.getDAVTransport(url, user, password, null, null);
    pkg =  dav.getResultPackage();
    // now lets print out the namevalue pairs for just the main package
    AttributeMapInterface namevalues = pkg.getNameValuePairs();
    if (namevalues != null)
    {
       String [] names = namevalues.listAttributeNames();
       for (int i=0; i < names.length; i++)
       {
          String name = names[i];
          String value = namevalues.getAttribute(name);
          System.out.println("NameValue name: " + name + " value: " + value);
       }
    }
    
    pkg.close();
 }
 catch (TransportException e)
 {
    // do something with this exception
 }
 catch (RemoteException e)
 {
    // do something with this exception
 }
 

WebDAV Publishing with Namespaces Example

This example specifies namespaces to use when publishing the result package to a WebDAV server. The "HOUSTON" prefix is defined to the namespace, "http://www.AlphaliteAirways.com/revenue/final". Once the namespaces are defined, the prefixes can be used on the name/value specification to indicate what namespace to use. In this example, the package's name/value pair is specified with a name of "HOUSTON:type". This indicates that this name/value will be stored to the specified WebDAV namespace of "http://www.AlphaliteAirways.com/revenue/final". Because a namespace is not specified for any other name/value pairs, the remaining name/value pairs are published to an empty namespace.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ReferenceEntry;
 import com.sas.services.publish.ReferenceEntryInterface;
 import com.sas.services.publish.ResultPackage;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.webdav.DAVTransportInterface;
 import com.sas.services.util.AttributeMap;
 import com.sas.services.util.AttributeMapInterface;
 import java.rmi.RemoteException;
 import java.util.HashMap;
 import java.util.Map;
 try
 {
    // define the HOUSTON prefix to the
    // "http://www.AlphaliteAirways.com/revenue/final" namespace
    Map namespaces = new HashMap();
    namespaces.put("HOUSTON", "http://www.AlphaliteAirways.com/revenue/final");
    // the HOUSTON prefix identifies that this
    // name/value pair will be stored with the result package
    // to the specified WebDAV namespace,
    // "http://www.AlphaliteAirways.com/revenue/final"
    AttributeMapInterface nv = new AttributeMap();
    nv.setAttribute("HOUSTON:type", "report");
    // create a new result package, passing in namevalues, description and properties
    ResultPackageInterface rpkg =  new ResultPackage();
    rpkg.setDescription("Alphalite Airways Package.");
    rpkg.setNameValuePairs(nv);
    // add a reference entry
    String reference = "http://AlphaliteAirways.com";
    ReferenceEntryInterface ref = new ReferenceEntry(reference, ReferenceEntry.URL_REFERENCE);
    nv = new AttributeMap();
    nv.setAttribute("etype", "ref");
    nv.setAttribute("Quarter4", "");
    ref.setDescription("Alphalite Airways Home Page.");
    ref.setNameValuePairs(nv);
    // add the reference entry to thhresult package
    rpkg.addEntry(ref);
    TransportFactory factory = new TransportFactory();
    String url = "http://AlphaliteAirways.com/~reports/Aug2000";
    DAVTransportInterface dav = factory.getDAVTransport(url, null, null, null, null);
    // set the namespaces on the transport
    dav.setNamespaces(namespaces);
    dav.publishResultPackage(rpkg, false);
    
    // close the package when done with it
    rpkg.close();   
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 catch (RemoteException e)
 {
    // do something with exception
 }
 

WebDAV Retrieving with Namespaces Example

This example specifies namespaces to use when retrieving a result package from a WebDAV server. By default, only name/value pairs that are defined to the empty namespace are returned to the user. This example specifies additional namespaces to return. The "HOUSTON" prefix is defined to the namespace, "http://www.AlphaliteAirways.com/revenue/final". This indicates that name/value pairs defined to the "http://www.AlphaliteAirways.com/revenue/final" namespace will be returned along with any defined to the empty namespace. Name/value pairs defined to the "http://www.AlphaliteAirways.com/revenue/final" namespace will be returned with a name that contains the "HOUSTON:" prefix.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ResultPackage;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.webdav.DAVTransportInterface;
 import com.sas.services.util.AttributeMap;
 import com.sas.services.util.AttributeMapInterface;
 import java.rmi.RemoteException;
 import java.util.HashMap;
 import java.util.Map;
 try
 {
    // define the HOUSTON prefix to the
    // "http://www.AlphaliteAirways.com/revenue/final" namespace
    Map namespaces = new HashMap();
    namespaces.put("HOUSTON", "http://www.AlphaliteAirways.com/revenue/final");
    AttributeMapInterface nv = new AttributeMap();
    // This indicates that any name/value properties defined to
    // the  "http://www.AlphaliteAirways.com/revenue/final"
    // namespace should be returned with the "HOUSTON:" prefix.
    nv.setAttribute("HOUSTON:type", "report");
    TransportFactory factory = new TransportFactory();
    String url = "http://AlphaliteAirways.com/~reports/Aug2000";
    DAVTransportInterface dav = factory.getDAVTransport(url, null, null, null, null);
    // set the namespaces on the DAV transport
    dav.setNamespaces(namespaces);
    ResultPackageInterface rPkg = dav.getResultPackage();
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 

WebDAV Publish as Archive Example

This example uses the asArchive method to indicate that this result package should be published as an archive (.spk file). By default, a result package is published as a set of loose files. This method overrides the default behavior so that the package is published as a binary file.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ReferenceEntry;
 import com.sas.services.publish.ReferenceEntryInterface;
 import com.sas.services.publish.ResultPackage;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.webdav.DAVTransportInterface;
 import java.rmi.RemoteException;
 try
 {
    // create a new result package, passing in namevalues, description and properties
    ResultPackageInterface rpkg =  new ResultPackage();
    rpkg.setDescription("Alphalite Airways Package.");
    // add a reference entry
    String reference = "http://AlphaliteAirways.com";
    ReferenceEntryInterface ref = new ReferenceEntry(reference, ReferenceEntry.URL_REFERENCE);
    ref.setDescription("Alphalite Airways Home Page.");
    // add the reference entry to thhresult package
    rpkg.addEntry(ref);
    TransportFactory factory = new TransportFactory();
    String url = "http://AlphaliteAirways.com/~reports/Aug2000";
    DAVTransportInterface dav = factory.getDAVTransport(url, null, null, null, null);
    // execute the asArchive method so that the
    // result package will be published as an
    // archive (.spk file)
    dav.asArchive(true);
    // the name of the archive file is specified. The .spk
    // extension is not specified as it will be added by the
    // WebDAV transport when the binary package is created.
    dav.setArchiveName("EastSales");
    dav.publishResultPackage(rpkg, false);
    
    rpkg.close();
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 catch (RemoteException e)
 {
    // do something with exception
 }
 

WebDAV Retrieve Archive Example

If a result package is published to WebDAV as an archive, the binary package is created with properties that identify it as a result package. The WebDAV transport supports the retrieval of these binary packages as well.

This example retrieves the binary result package that was published in the previous example.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ResultPackage;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.webdav.DAVTransportInterface;
 import java.rmi.RemoteException;
 try
 {
    TransportFactory factory = new TransportFactory();
    // The URL must identify the binary result package. In the
    // previous example, the .spk extension is added by the webdav
    // transport when the package is published.
    String url = "http://AlphaliteAirways.com/~reports/Aug2000/EastSales.spk";
    DAVTransportInterface dav = factory.getDAVTransport(url, null, null, null, null);
    ResultPackageInterface rPkg = dav.getResultPackage();
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 catch (RemoteException e)
 {
    // do something with exception
 }
 

Archive Example

This example demonstrates how to publish a package to an archive.

 import com.sas.services.TransportException;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.archive.ArchiveTransportInterface;
 import java.io.File;
 try
 {
    ResultPackageInterface rpkg;
    // This example assumes that the result package has already
    // been constructed at this point. An example of
    // this can be found in the
    // Constructing a Result Package to Publish example.
    // publish the package using the archive transport
    File f = new File("C:\\monthly.spk");
    TransportFactory factory = new TransportFactory();
    ArchiveTransportInterface archive = factory.getArchiveTransport(f, null, null);
    archive.publishResultPackage(rpkg, false);
    rpkg.close();
 }
 catch (TransportException e)
 {
    // do something with exception
 }
 

Requester Example

The following code fragment shows how the Requester transport is used to bind to a package on an IOM Workspace server. It then retrieves the package, identified by the location of the package in the file system on the server.

 import com.sas.iom.SAS.IWorkspace;
 import com.sas.services.TransportException;
 import com.sas.services.publish.TransportFactory;
 import com.sas.services.publish.ResultPackageInterface;
 import com.sas.services.publish.requester.RequesterTransportInterface;
 try
 {
    IWorkspace iWorkspace;
    //
    // This examples assumes that a connection is made to
    // get an IWorkspace (iWorkspace).
    //
    TransportFactory factory  = new TransportFactory();
    RequesterTransportInterface requesterTransport = factory.getRequesterTransport(iWorkspace, "d:\\spkfiles\\test.spk", null,null, null);
    ResultPackageInterface pkg = requesterTransport.getResultPackage();
 }
 catch (TransportException e)
 {
    // do something with this exception
 }
 // at this point examination of the package and its entries is identical to that shown in
 // the webDAV example
 


***  This package contains classes that provide Binary Compatibility only, not Source Compatibility  ***

Note:
Extension of the classes in this package is prohibited unless otherwise documented. Similarly, extension or implementation of the interfaces in this package is prohibited except as documented.


Copyright © 2009 SAS Institute Inc. All Rights Reserved.