If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Get a list of all available namespaces

Started by Kaspatoo, 23 Sep 2010 08:14:48 AM

Previous topic - Next topic

Kaspatoo

Hallo,

as in another thread told, I am creating a Cognos Extended Application.
I am looking for an interface, a function or something else where I am able to get a list of all the namespaces which are installed on my Cognos.
I want to displays them to the user so that he can choose one.

Maybe someone has some ideas to solute my problem.
Thanks!

xiska

Hi

There are two situations you must consider.
If the user is already logged in and the second one is before the login.

You are writing of an extended application - threrefore I assume that the user is already logged in.
In this case you make a simple query against the contentstore.
The searchpath is "/directory/*" (try also /directory)
If there is only one external namespace you will get two resultsets because the internal will be readable if the traverse permission is granted.
If you ask for the property hasChildren you will get the information about the current access as well. If there are none the user does not have access.

Please note that you cannot use a query like "/directory//*" anymore because external objects are not searchable in this way. This would cause a dramatic slow down of the namespace server.
Note that a searthPath like /content//* will work like expected.

In history I used applications from the sdk samples to test these queries.
Now I prefer to use Soap Queries which can be used from anywhere and tranformed into java or .net code using xsl.

For some further ideas take a look http://www.xiska.de > It Technik > IBM Cognosr

Have Fun

birliban

Hi,

try this:
/**
* This method queries the Content Store for all the available namespaces.
*
* @param connection Connection to IBM Cognos 8
*
*/
public BaseClass[] getAvailableNamespaces(CRNConnect connection)
{
PropEnum props[] =
new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName };
BaseClass[] nameSpaces;
try
{
nameSpaces =
csHandler.queryObjectInCS(connection, "/directory/namespace", props);
return nameSpaces;
}
catch (java.rmi.RemoteException remoteEx)
{
remoteEx.printStackTrace();
return null;
}
}


csHandler is of class "CSHandlers" found in the SDK-samples
in the samples you also find the "CRNConnect"-class

Kaspatoo

#3
Did I understand right that I simply have to insert your code into my application?
I see that an Object of CRNConnect is required. Shall I use an Object which is provided by Cognos or to initialize a new Object of CRNConnect?
If Cognos is providing such an Object, how will I get access to it?

birliban

You could copy&paste this method I guess :)

But you should try to understand it first  ;)

In the samples included are the CRNConnect.java and the CSHandlers.java (in the folder "Commons" I think) - just add the files to your project and you should be good to go

Kaspatoo

#5
Hi,

yes I did so, i think.

As i just copied your code and integrated the classes (handler + connect) into my project and add all necessary libraries and started it I got a NullPointerException, because there was no Connection. So I manually ran the method connectToCognos but then got the following:

java.lang.NoClassDefFoundError: org.apache.commons.discovery.tools.DiscoverSingleton [...]

Another question I have is, how does my app know which login-data to use to connect to cognos? There was nothing to type in.

In the samples they also do queries but use <cps:CognosConnect id="xxx"/>
Is there any way to get access to an existing connection?

birliban

#6
To log on to the server I use this code:

        private static Logon sessionLogon;
private static CRNConnect connection = new CRNConnect();

/**
* @param args
*/
public static void main(String[] args) {
if (args.length == 0){
System.out.println("also accepting \"endPoint nameSpace userId userPassword\" as arguments");
connection.connectToCognosServer();
sessionLogon = new Logon();
while (!Logon.loggedIn(connection)){
System.out.println(sessionLogon.logon(connection));
if (!Logon.loggedIn(connection)){
int retry =
JOptionPane.showConfirmDialog(
null,
"Login Failed. Please try again.",
"Login Failed",
JOptionPane.OK_CANCEL_OPTION);
if (retry != JOptionPane.OK_OPTION){
System.exit(0);
}
}
}//while
} else {
if (args.length < 4){
System.out.println("Order of arguments: endPoint nameSpace userId userPassword");
System.exit(0);
}
connection.connectToCognosServer(args[0]);
sessionLogon = new Logon();
try {
System.out.println(sessionLogon.quickLogon(connection, args[1], args[2], args[3]));

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


Using connection.connectToCognosServer(); usually should pop up a window asking for server endpoint (something like: http://YOURSERVER:9300/p2pd/servlet/dispatch )

Using sessionLogon.logon(connection) shouldpop up a window asking for user credentials.
The Logon class is found in the samples as well...

Kaspatoo

Very interesting,

the class logon provides the method getNamespaces with an CRNConnect object as parameter.
For my use its adequate to get all namespaces without any authorisation.
So may that's enough!?

But, however, everytime I do "connection.connectToCognosServer"
I will get the same Exception:

javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:579)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:810)

root cause

java.lang.NoClassDefFoundError: org.apache.commons.discovery.tools.DiscoverSingleton
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:84)
at java.security.AccessController.doPrivileged(AccessController.java:197)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:80)
at org.apache.axis.components.logger.LogFactory.(LogFactory.java:72)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:194)
at org.apache.axis.handlers.BasicHandler.(BasicHandler.java:81)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:194)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:159)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:159)
at org.apache.axis.client.Service.getAxisClient(Service.java:143)
at org.apache.axis.client.Service.(Service.java:152)
at com.cognos.developer.schemas.bibus._3.AgentService_ServiceLocator.(AgentService_ServiceLocator.java:10)
at de.telekom.flexprod.cognos.objektverwaltung.adapters.CRNConnect.connectToCognosServer(CRNConnect.java:129)
at de.telekom.flexprod.cognos.objektverwaltung.AnzeigeServlet.doPost(AnzeigeServlet.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:579)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:810)


I have no idea what's going wrong.

birliban

Hi, are you missing some libraries ? All needed libraries can be found at Samples\lib folder. I'm only guessing though ^^

Kaspatoo

hi,

no, I tried them all, but then I sometimes get another Exception.

Kaspatoo

so thats my current result:

I make this:
Logon nsGetter = new Logon();
CRNConnect conn = new CRNConnect();
String[] namespaces = null;
conn.connectToCognosServer();
namespaces = nsGetter.getNamespaces(conn);


I have manipulated CRNConnect. There are no further inputdialogs. CMURL will be used as default.
The logging shows me that the program is crashing while trying this:
agentServiceLocator = new AgentService_ServiceLocator();

This class is found in
samples\WEB-INF\lib\axisCognosClient.jar\com\cognos\developer\schemas\bibus\_3\

This lib is already included!
I surrounded the statement with try catch but no exception is thrown.

In cognos I get this Message:
(german version)
##############################################################
CPS-PAG-4801 -> Operation in der Empfängerkomponente fehlgeschlagen.
<fault><faultcode>com.cognos.cps.services.wsrp.v1.types.OperationFailedFault</faultcode><faultstring>PRO-WSF-5008 Die normale Ausführung
der Operation ist fehlgeschlagen.</faultstring><detail><wsrp:OperationFailed xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas/xts/"
xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"></wsrp:OperationFailed><xts:exception xmlns:SOAP-ENV="http://schemas.xmlsoap.org
/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas/xts/"
xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>protocol.xts.requestfailed</xts:exceptionCode><xts:exceptionMsg>PRS-PRH-0239
Die Anforderung für den Protokoll-Handler "XTS" ist fehlgeschlagen.</xts:exceptionMsg></xts:exception><xts:exception xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas
/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>processor.executefailed</xts:exceptionCode><xts:exceptionMsg>PRS-
PRO-0504 Beim Erstellen der angeforderten Webseite ist ein Fehler aufgetreten. Bitte wenden Sie sich an Ihren Systemadministrator.</xts:exceptionMsg>
</xts:exception><xts:exception xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types">
<xts:exceptionCode>object.organizercreationfailed</xts:exceptionCode><xts:exceptionMsg>PRS-OBJ-0606 Der Block-Organizer für Block "/cps4/portlets
/sdk/portlet-impl/remote/remote.xts" konnte nicht erstellt werden.</xts:exceptionMsg></xts:exception><xts:exception xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas
/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>block.executionexception</xts:exceptionCode><xts:exceptionMsg>PRS-
BLK-0667 Beim Ausführen des Blocks "request" wurde ein Ausnahmefehler gefunden.</xts:exceptionMsg></xts:exception><xts:exception xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas
/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>interpreter.executionfailed</xts:exceptionCode><xts:exceptionMsg>PRS-
BLI-0727 Ausführung von XTS Interpreter ist fehlgeschlagen.</xts:exceptionMsg></xts:exception><xts:exception xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas
/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>instruction.executefailed</xts:exceptionCode><xts:exceptionMsg>PRS-
INS-1425 Beim Ausführen der Operation "request" ist ein Fehler aufgetreten.</xts:exceptionMsg></xts:exception><xts:exception xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xts="http://developer.cognos.com/schemas
/xts/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"><xts:exceptionCode>interpreter.xtsfault</xts:exceptionCode><xts:exceptionMsg>PRS-BLI-0728
XTS-Fehler zurückgegeben von Fehlerblockausführung.</xts:exceptionMsg><xts:exceptionDetail><fault xmlns:bus="http://developer.cognos.com/schemas
/bibus/2/"><xts:exceptionCode>protocol.url.httpresponseerror</xts:exceptionCode><xts:exceptionMsg>PRS-PRH-0250 Der Zielserver gab einen
HTTP-Fehlercode zurück.</xts:exceptionMsg><xts:exceptionDetail><httpResponse><code>500</code><message>Internal Server Error</message>
</httpResponse></xts:exceptionDetail></fault></xts:exceptionDetail></xts:exception></detail></fault>

#########################################################################

any ideas how to fix?

Kaspatoo

The solution is called "client-config.wsdd"

It is not enough to copy all (used) libraries.
The file "client-config.wsdd" is needes as well.
Just copy it into your sources ordner so that is is deployed in directory classes.

After that I was able to youse <CPS: cognos8connect id="xxx" >

<%
IBaseClass[] namespaces = xxx.query("/directory/*"){...}
%>

That's it!

~ Ready to Close ~