Accessing reports in OBIEE from a Java Program - java

I am developing an Java application using Netbeans which will fetch reports from the BI server on OBIEE 10G and display it to the client using the Java application. Can anyone suggest me appropriate steps to do this and also how to begin with it.

First of all, you will fetch the report from Presentation Services and not from BI server. BI server is a database with only SELECT statement whereas Presentation Service uses this SELECT to create and format reports.
To integrate report from BI Presentation service within a other application, you can use:
the web services: http://docs.oracle.com/cd/E23943_01/bi.1111/e16364/methods.htm#i1008939
or the GO Url: http://docs.oracle.com/cd/E23943_01/bi.1111/e16364/apiwebintegrate.htm#CACCHBHC
The links goes to the same documentation (Integrator's Guide). This is written for 11g but it will also works in 10g.
Cheers
Nico

Your question is not clear; Are you trying to invoke a Java method from OBIEE?
If yes:
You can do this by creating an Agent which is linked to an Action. The Action can invoke a java method(in an EJB). By hooking the Agent to the Action, you can schedule it as a job.

While it is possible to use the webservices and the GO url to create your web app, it is a very hard way to do so. If you have a choice, use the latest JDeveloper 11g and then, use these steps to drag and drop your Answers Reports or Dashboards to the .jspx page. It's simple, can be done in minutes rather than days provided you are familiar with JDeveloper.
EDIT: If you still want to use Netbeans, here's a snippet of code to get you started. Remember to read and understand the HtmlViewService SOAP API in the OBIEE integration doc before taking it to production.
import oracle.bi.services.soap.*
SAWSessionParameters sessionParams = new SAWSessionParameters();
sessionParams.setUserAgent("Mozilla/...."); //Copy the exact agent from your Firefox menu Help > About
javax.xml.rpc.ServiceFactory factory = ServiceFactory.newInstance();
SAWSessionServiceSoap sessionService = ((SAWSessionService) factory.loadService(SAWSessionService.class)).getSAWSessionServiceSoap();
HtmlViewServiceSoap htmlService = ((HtmlViewService) factory.loadService(HtmlViewService.class)).getHtmlViewService();
AuthResult authResult = sessionService.logonex("replace_with_your_username", "replace_with_your_password", sessionParams); //You should reuse the session for multiple HTTP Requests from the same user
String sessionID = authResult.getSessionID();
StartPageParams pageParams = new StartPageParams();
pageParams.setIdsPrefix("replace_with_your_prefix");
String pageID = htmlService.startPage(pageParams, sessionID);
ReportRef report = new ReportRef();
report.setReportPath("replace_with_full_path_to_your_report");
htmlService.addReportToPage(pageID, "replace_with_your_report_name", report, null, null, null, sessionID);
String reportHTML = htmlService.getHtmlForReport(pageID, "replace_with_your_report_name", sessionID);
System.out.println(reportHTML); //Here's the report that you are looking for
htmlService.endPage(pageID, sessionID);

Related

Getting all users from Openfire server using smack 4.2.2

Well, I'm trying to get all users from Openfire server using Smack, unfortunately I don't know how - I'm using Smack 4.2.2.
UserSearchManager usm= new UserSearchManager(connection);
DomainBareJid domainJid =
JidCreate.domainBareFrom(connection.getServiceName());
Form searchForm = usm.getSearchForm(domainJid);
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", "*");
ReportedData data = usm.getSearchResults(answerForm, domainJid);
if (data.getRows() != null) {
for (ReportedData.Row row: data.getRows()) {
for (String jid:row.getValues("jid")) {
System.out.println(jid);
}
}
}
This code doesn't work because of:
java.lang.IllegalArgumentException: Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once
You can't get all users through XEP-0055: Jabber Search, just can be used with a filter you sure that the users don't have it (like a special character). Only way I know is to use Rest API Plugin of openfire. You can read more about this plugin from the link. Good luck.
Error is obvious. Either you did not connect at least once (or got disconnected and did not reconnect) or your username is wrong.
Maybe you are trying to connect without local jid. Please check this explanation of XMPP address formats:
https://xmpp.org/rfcs/rfc6122.html#addressing-localpart
hope you have solved the problem. I got my code working with this little change
DomainBareJid domainJid =
JidCreate.domainBareFrom("search." + connection.getServiceName());
in your openfire go to Plugins and select available-plugins > then choose rest Api > then you can use following url to Get All users in Group:
http://localhost:9090/plugins/restapi/v1/users
Note: All Rest EndPoints you can find in following link:
https://www.igniterealtime.org/projects/openfire/plugins/1.2.1/restAPI/readme.html

How to programmatically logout from websphere portal 8.5 application using Java code?

I have a websphere portal application running very well. The current logout command is available in default theme.
I wanted to know how to logout the portal from java/spring source code? Can we call the same command method e.g. "logout" from server side java code?
I have functionality of change password. After change password, I want to logout user.
Below is the list of items which you need to try from your portlet
final PortletStateManager mgr = getPortletStateManager(request, response);
urlFactory = mgr.getURLFactory();
url = urlFactory.newURL(com.ibm.portal.state.Constants.EMPTY_COPY); //If no state from the current request to be preserved
LogoutActionAccessorFactory logoutFct = mgr.getAccessorFactory(LogoutActionAccessorFactory.class);
LogoutActionAccessorController logoutCtrl = logoutFct.newLogoutActionController(url.getState());logoutCtrl.dispose();
finalUrl = url.writeDispose(new StringWriter()).toString();
The same can be done from a Servlet also. You will see corresponding AccessorFactory and AccessorController in the portal documentation.
EDITED
PortletStateManager is obtained from PortletStateManagerService which again is obtained from PortletServiceHome using a JNDI lookup.
The right way to find out this is by going through the Java docs of Portal. Refer the interface PortletStateManagerService. The comment section clearly tells how to get it.
You can fine the Java docs of Portal here <portal-install-root>\WebSphere\PortalServer\doc\Javadoc\spi_docs

Reading GET/POST requests from the Browser on JAVA

I need to find a way of reading GET/POST requests from the WEB browser(Network) and retrieve the information like Status, Domain, Size, IP and the most important Timeline.
The main purpose of this is to measure requests count after each action on the WEB page and their execution time. Also this will help me to know if any requests(AJAX/JavaScript) are executing before I want to perform any actions on the WEB page.
Could you please help me with solution?
Assuming you don't want to tie yourself to a particular browser (via plugins or particular dev toolbars), need to capture responses from interactive user events (i.e. via simulated use of a website in a real browser, not dynamically created HTTP calls), and need to automate this, then a proxy server is the way to go.
Something like Browsermob can be set up as a proxy for all Selenium traffic. It can capture the entire content of all requests and responses, and let you generate you a (cross-browser) HAR file that you can then persist, visualise, or query via an API.
Obviously you could automate this, schedule the Selenium test runs, and either produce your own custom metrics with your own Java code; pipe the HAR into a JSON-savvy database for querying (say Elasticsearch) and visualisation, or just save the HARs for offline querying and diffing.
Some example code from the tests:
[...]
proxy.newHar("Test");
HttpGet get = new HttpGet(getLocalServerHostnameAndPort() + "/a.txt?foo=bar&a=1%262");
client.execute(get);
Har har = proxy.getHar();
HarLog log = har.getLog();
List<HarEntry> entries = log.getEntries();
HarEntry entry = entries.get(0);
HarRequest req = entry.getRequest();
[...]
Alternatively you can visualise the output by obtaining the HAR in string form and pasting into http://www.softwareishard.com/har/viewer/. That should give you something that looks very similar to the Network tab, but in a format that's easier to export, screenshot, and print.
Chrome comes with devtools by itself. Just hit 'F12'.
https://developer.chrome.com/devtools
Postman, it's useful for testing web services and API
https://www.getpostman.com/

Java Google datastore async calls

I do not want to block threads in my application and so I am wondering are calls to the the Google Datastore async? For example the docs show something like this to retrieve an entity:
// Key employeeKey = ...;
LookupRequest request = LookupRequest.newBuilder().addKey(employeeKey).build();
LookupResponse response = datastore.lookup(request);
if (response.getMissingCount() == 1) {
throw new RuntimeException("entity not found");
}
Entity employee = response.getFound(0).getEntity();
This does not look like an async call to me, so it is possible to make aysnc calls to the database in Java? I noticed App engine has some libraries for async calls in its Java API, but I am not using appengine, I will be calling the datastore from my own instances. As well, if there is an async library can I test it on my local server (for example app engine's async library I could not find a way to set it up to use my local server for example I this library can't get my environment variables).
In your shoes, I'd give a try to Spotify's open-source Asynchronous Google Datastore Client -- I have not personally tried it, but it appears to meet all of your requirements, including being able to test on your local server. Please give it a try and let us all know how well it meets your needs, so we can all benefit and learn -- thanks!

How to get user details from Websphere UserRegistry

How to fetch the user's other details from AD after logging into the application using LDAP registry configured in WebSphere server. I have Java EE application, which is using the single sign on. I want to get the other details like email, office location of the user which is configured in Active Directory. How do I get that?
// Retrieves the default InitialContext for this server.
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
// Retrieves the local UserRegistry object.
com.ibm.websphere.security.UserRegistry reg = (com.ibm.websphere.security.UserRegistry) ctx
.lookup("UserRegistry");
From this registry, is there chance to get it?
In WebSphere Application Server you can access User Registry information -and modify it- thorugh the Virtual Member Manager componente an its API.
There's plenty of documentation and samples on IBM Infocenter. From there, the code snippet to get the properties of an entity like a user:
DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_PERSON_ACCOUNT);
entity.createDataObject(DO_IDENTIFIER).set(PROP_UNIQUE_NAME,
"uid=SalesManager,cn=users,dc=yourco,dc=com");
DataObject propCtrl = SDOHelper.createControlDataObject(root, null, DO_PROPERTY_CONTROL);
propCtrl.getList(PROP_PROPERTIES).add("sn");
propCtrl.getList(PROP_PROPERTIES).add("uid");
propCtrl.getList(PROP_PROPERTIES).add("cn");
propCtrl.getList(PROP_PROPERTIES).add("telephoneNumber");
propCtrl.getList(PROP_PROPERTIES).add("createTimestamp");
root = service.get(root);
To get the service instance that communicates with the registry you need first to execute the Programming Prerequisites of the API. I stringly suggest you to review the Infocenter documentation.
I wrote an article about exactly that question:
http://veithen.github.io/2012/12/13/retrieving-custom-user-attributes-from.html
Note that the conclusion is compatible with what Carlos wrote: you have to use VMM.

Categories