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) {
}
}
}
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.