The example provided in this document is provided “as-is” to the user and assumes that the user:
PREREQUISITES:
For the sample to work, the Strategy Web JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:
To iterate through a user's subscriptions and output details of each subscription using the Web API 9.x including the format type, please modify and compile the class below accordingly:
package com.Strategy.sdk.sample.Subscriptions;
import com.Strategy.web.objects.SimpleList;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.WebSubscription;
import com.Strategy.web.objects.WebSubscriptionContentFormat;
import com.Strategy.web.objects.WebSubscriptionContentProperties;
import com.Strategy.web.objects.WebSubscriptionsSource;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
import com.Strategy.webapi.EnumDSSXMLSubscriptionDeliveryType
import com.Strategy.web.objects.WebObjectSource;
public class SubscriptionType {
// Create factory object.
static WebObjectsFactory factory=WebObjectsFactory.getInstance();
static WebIServerSession serverSession=factory.getIServerSession();
static WebObjectSource objectSource=factory.getObjectSource();
public static void main(String[] args) throws WebObjectsException {
serverSession.setServerName("ServerName");
serverSession.setServerPort(0);
serverSession.setProjectName("Strategy Tutorial");
serverSession.setLogin("administrator");
serverSession.setPassword("");
serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
WebSubscriptionsSource subSource = factory.getSubscriptionsSource();
WebSubscription sub = null;
// Retrieve all File Subscriptions
SimpleList list = subSource.getSubscriptionsByDeliveryMode(EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeFile);
System.out.println("Total number of File subscriptions are:" + Integer.toString(list.size()) + "\n");
// Output details for each subscription
for (int i = 0; i < list.size(); i++) {
sub = (com.Strategy.web.objects.WebSubscription) list.item(i);
System.out.println("Subscription name: " + sub.getName());
System.out.println("Subscription ID is: " + sub.getID());
System.out.println("Trigger is: " + (com.Strategy.web.objects.WebSubscriptionTrigger) sub.getSubscriptionTrigger());
// Output Format Type of the subscription
WebSubscriptionContentProperties contentProperties = sub.getContentProperties();
WebSubscriptionContentFormat contentFormat = contentProperties.getFormat();
int formatType = contentFormat.getType();
System.out.println("Format Type = " + formatType + "\n");
}
}
}