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
  3. KB20171: How to Search for Folders in the Metadata Using the MicroStrategy Java Web SDK 9.0.x

KB20171: How to Search for Folders in the Metadata Using the MicroStrategy Java Web SDK 9.0.x


Stefan Zepeda

Salesforce Solutions Architect • Strategy


The following sample code shows how to search for "My Reports" folder inside MicroStrategy.

 

import com.microstrategy.webapi.*;
import com.microstrategy.web.objects.*;
import com.microstrategy.web.objects.WebIServerSession;
import com.microstrategy.web.objects.WebObjectsFactory;
import com.microstrategy.web.objects.WebFolder;
import com.microstrategy.web.objects.WebObjectSource;
public class FindFolder {
public FindFolder() {
super();
}
public static void main(String[] args) {
// create factory object
WebObjectsFactory factory = WebObjectsFactory.getInstance();
WebIServerSession serverSession = factory.getIServerSession();
// set up session properties
serverSession.setServerName("SERVERNAME");
serverSession.setServerPort(34950);
serverSession.setProjectName("MicroStrategy Tutorial");
serverSession.setLogin("bkelt");
serverSession.setPassword("123");
WebObjectSource wos = factory.getObjectSource();
WebFolder folder = null;
WebSearch search = wos.getNewSearchObject();
String strFolderName = "My Reports";
try {
search.setNamePattern(strFolderName);
search.setSearchFlags(search.getSearchFlags() | EnumDSSXMLSearchFlags.DssXmlSearchNameWildCard);
// asynchronized search
search.setAsync(false);
// search for folder
search.types().add(
new Integer(EnumDSSXMLObjectTypes.DssXmlTypeFolder));
// search on repository
search.setDomain(EnumDSSXMLSearchDomain.DssXmlSearchDomainRepository);
search.submit();
WebFolder f = search.getResults();
// searching for "My Reports" folder
int size = f.size();
if (f.size() > 0)
{ for (int i=0; i< size; i++)
{
folder = (WebFolder) f.get(i);
WebFolder folderParent = folder.getParent();
if (folderParent != null)
{
//lists the path of the foler
System.out.println("parent folder: ***********" + folderParent.getName() );
System.out.println("parent folder: ***********" + folderParent.getParent().getParent().getName() );
}
System.out.println("DSS ID is: ***********" + folder.getID() );
System.out.println("Abrevation: ***********" + folder.getAbbreviation() );
}
}
} catch (Exception e) {
}
}
}

    Customization Warning:

     

    This customization is provided as a convenience to MicroStrategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, MicroStrategy 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, MicroStrategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about MicroStrategy Consulting assistance.

    Comment

    0 comments

    Details

    Knowledge Article

    Published:

    January 30, 2023

    Last Updated:

    January 31, 2024