EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB20777: How to get the subscriptions information programmatically using Web SDK in MicroStrategy 9.x


Community Admin

• Strategy


The example provided in this document is provided “as-is” to the user and assumes that the user:

  • Can program, compile (e.g. javac, jikes, etc.), and execute Java programs
  • Can configure environment variables (e.g. JAR files, property files, etc.)
  • Have all the necessary tools to create Java applications (JDK, IDE, etc.)
  • Has access to the Strategy SDK documentation.
  • Has read the customization warning at the bottom of this document

 
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:

  • Strategy Web Universal (JSP): {web_root}/WEB-INF/lib directory.
  • Strategy Web (.NET): Program Files\Common Files\Strategy directory.

Note:
 
More elaborate programs will require additional library files and are out of the scope of this document.
It is possible to extract the subscription information for the open session using Strategy Web SDK. This document gives an example of how to accomplish this.
 
package com.Strategy.memo;
import com.Strategy.web.objects.SimpleList;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.WebSubscription;
import com.Strategy.web.objects.WebSubscriptionsSource;
import com.Strategy.webapi.EnumDSSXMLSubscriptionDeliveryType;
 
public class QuerySubscriptions {
 
    public static void main(String[] args) {
 
        WebIServerSession webIServerSession = null;
 
        WebObjectsFactory webObjectFactory = WebObjectsFactory.getInstance();
        webIServerSession = webObjectFactory.getIServerSession();
        webIServerSession.setServerName("SERVER_HOSTNAME");
        webIServerSession.setServerPort(0);
        webIServerSession.setProjectName("Strategy Tutorial");
        webIServerSession.setLogin("administrator");
        webIServerSession.setPassword("");
 
        try{
 
            WebSubscriptionsSource subSource = webObjectFactory.getSubscriptionsSource();
 
            System.out.println("List of subscriptions: ");
            SimpleList subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeAll);
            System.out.println("\tTotal subscriptions: " + subList.size());
            printSubInfo(subList);
            subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeEmail);
            System.out.println("\tEmail subscriptions: " + subList.size());
            printSubInfo(subList);
            subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeInbox);
            System.out.println("\tHistory List subscriptions: " + subList.size());
            printSubInfo(subList);
            subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeMobile);
            System.out.println("\tMobile subscriptions: " + subList.size());
            printSubInfo(subList);
            subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypeFile);
            System.out.println("\tFile subscriptions: " + subList.size());
            printSubInfo(subList);
            subList =
              subSource.getSubscriptionsByDeliveryMode
              (EnumDSSXMLSubscriptionDeliveryType.DssXmlDeliveryTypePrinter);
            System.out.println("\tPrinter subscriptions: " + subList.size());
            printSubInfo(subList);
 
            webIServerSession.closeSession();
 
        }catch(Exception e){}
    }
 
    public static void printSubInfo(SimpleList sl) throws Exception {
 
        for(int i = 0; i < sl.size(); i++) {
 
            WebSubscription ws = (WebSubscription)sl.item(i);
 
            System.out.println("\t\t Name: " + ws.getName() + "Report/Document: " +
            ws.getcontent().getName());
        }
    }
}
WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 9, 2017

Last Updated:

June 9, 2017