Tuesday, November 23, 2010

Using Bar Graph (Oracle DVT Component): Part II

This blog is continuation of my previous blog Using Bar Graph (Oracle DVT Component): Part I which showed how could we easily use one of the Data Visualization Tool Bar Graph. I will further try to show the ease with which these component can be used to create a varied graph.

Variation I:

In graph we took the example of Salary versus employees. Lets go ahead and extend the same example to add commission to the graph to show something like:


In the graph above red bar displays the commission too along with this. To achieve we can add one more attribute to the View Object acting as the source for this graph and sql for the vo could look like this:
      Select Ename, Sal, comm from EMP

Now we can either edit the Map binding on the page binding to add the commission attribute (comm in this case) to the Bars column or you can delete the old map and drag and drop the view object from data control as Graph (steps are same as mention in the Part I of this blog except addition of commission attribute as shown below).


Variation II:


In the above graph Salary and commission are shown as two seperate bars we can combine them in one bar as below:


To achieve this just select Stacked Bar as the Graph Type and rest remains the same:



So convenient... right?

Using Bar Graph (Oracle DVT Component): Part I

In this blog I would try to show how you can play around with one of the Oracle ADF’s Data Visualization Tool (DVT) Bar Graph. Initially it seems so tough to come up with a graph component and ofcourse making it dynamic so that it displays graph based on current data. [I would be using default HR schema from the Oracle Database.]

1.    Let’s start with creating a Model and ViewController project.
2.    In your model project we would be creating View Object’s (either an Entity Based or SQL based, since we may not be updating the data through graphs a SQL based View Object could be efficient) which would be acting as source for the graphs.  I would be creating SQL based View Object in this entire demo.
3.    Create an Application module with name say ‘AppModule’, this would be used to expose all the view objects to client as Data Control.
4.    Right Click on the ViewController project and click ‘New’. In the New Gallery dialog, select ‘JSF’ under Categories and then select JSF Page under items and click ok.
5.    In Create JSF Page dialog, provide a file name ‘DemoDVT1’, make sure ‘Create as XML Document  (*.jspx)’ is checked and click ok.

        Graph 1: Salary Vs Employee

6.    Create a View Object with the SQL and name it as SalaryVsEmployeeVO.
        Select Ename, Sal from EMP
7.    Add this VO to Application Module AppModule.      
8.    Drag the SalaryVsEmployeeVO from the DataControl and drop to the jspx DemoDVT1 as Graph.


9.    In Component Gallery for the graphs, select ‘Bar’ as Categories for Bar Graph, select Graph Type and a Quick Start Layout and click OK.


10.    In Create Bar Graph wizard drag and drop ‘Sal’ into the Bars input box. You can also select the same from the green ‘+’ sign. Also drag ename column into the X axis input box.


11.    Optionally you can click on the Preview Tab to see how the outcome will look like.
12.    Once done just run the DemoDVT1.jspx page to see the graph which would look similar to one below (there could be some difference based on the data in the EMP table).


13.    This is how you can proceed with working with Bar graph in Oracle ADF.
   
I will continue further on the use of Bar Graph in next part.

Sunday, November 21, 2010

Using Oracle Identity Manager’s Java API's from oimclient.jar

Lately I got chance to work on Oracle Identity Manager and I was trying to access Oracle Identity Manager through Java API’s exposed by this product.  Ofcourse it’s a great product but at same time it too complicated and I guess experts would agree that it’s so easy for a newbie to get lost in the tons and tons of doc even if complexity is put aside. Well I was lost for sure…

Here is the link for the Oracle's Developer Guide for Oracle Identity Manager if you want to go for detail steps and demo code.

Here I will try to put some steps in simple and straight forward way if you are interested to access OIM’s Java API’s.

There are two entry points for the OIM, one through OIMClient and other through tcUtilityFactory. Well I cannot comment which is the better but from the Doc OIMClient is ofcourse recommended one. One other thing is coming from the Oracle’s Application Development Framework (ADF), I selected JDeveloper as my tool.
  1. Copy oimclient.zip from OIM Server (OIM_ORACLE_HOME/server/client/ oimclient.zip) to local drive.
  2. Create a Fusion Web Application using JDeveloper.
  3. In the model project go the project properties select Run/Debug/Profile, click Default under Run Configurations and click edit.
  4. Go to the project folder in your JDeveloper Workspace and create two folders as jlib and conf.
  5. Extract the oimclient.jar to any folder and copy all the jars(OimClient.jar, Commons-logging.jar, Eclipselink.jar and Spring.jar) from it to jlib folder that we created in step 4.
  6. Copy the authwl.conf file to conf folder created in step 4.
  7. Go to the project properties for the model project and click on Libraries and Classpath. Click on Add JAR/Directory and add following jars OimClient.jar, Commons-logging.jar, Eclipselink.jar and Spring.jar
  8. Set the Java Options to
    -DXL.HomeDir=PATH\OIM
    -Djava.security.auth.login.config=FILE_PATH\conf\authwl.conf
  9.  Now it’s time to test the API. Create a sample java class and add following method to it.

        public static OIMClient client;
        private static String OIMUserName = "USERNAME";
        private static String OIMPassword = "PASSWORD";
        private static String OIMURL = "t3://OIM_HOSTNAME:OIM_PORT";
        private static String OIMInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";

        public static void loginWithCustomEnv() throws LoginException {
           Hashtable env = new Hashtable();
           env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, OIMInitialContextFactory);
           env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIMURL);
           client = new OIMClient(env);
           client.login(OIMUserName, OIMPassword);
           }

        public static void main(String args[]) {
            try {
                loginWithCustomEnv();
            } catch (LoginException e) {
                e.printStackTrace();
            }
        }
  10. Right Click and run to test the login.
Now you are ready to extend this to any level you want to take to. By the way oimclient.jar comes with the sample code to test the login and create user.

Saturday, November 20, 2010

OIM Error - java.lang.SecurityException Unable to locate a login configuration

While working with one of the ADF custom application and trying to integrate with Oracle Identity Manager (OIM) using the exposed Java API's from oimclient.jar, I was stuck with below error: 

Exception in thread "main" java.lang.SecurityException: Unable to locate a login configuration
at com.sun.security.auth.login.ConfigFile.(ConfigFile.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.security.auth.login.Configuration$3.run(Configuration.java:246)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:241)
at javax.security.auth.login.LoginContext$1.run(LoginContext.java:237)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.init(LoginContext.java:234)
at javax.security.auth.login.LoginContext.(LoginContext.java:403)
at Thor.API.Security.LoginHandler.weblogicLoginHandler.login(weblogicLoginHandler.java:58)
at oracle.iam.platform.OIMClient.login(OIMClient.java:134)
at oracle.iam.platform.OIMClient.login(OIMClient.java:114)
at model.SampleOIMClient.loginWithCustomEnv(SampleOIMClient.java:91)
at model.SampleOIMClient.main(SampleOIMClient.java:155)
Caused by: java.io.IOException: Unable to locate a login configuration


as the error seems pretty obvious, it took more than good time to get through a solution.

To get through this error we need to do setting for config file. When using Java API's from oimclient.jar, program looks for  authwl.conf and this is what needs to be set as Java Options.

-Djava.security.auth.login.config=FILE_PATH\conf\authwl.conf

If you are using JDeveloper here is how you can set the same:
Go to the project properties and select Run/Debug/Profile




Select 'Default' under Run Configuration and click on Edit. Enter the property as Java Options and click ok.




Once done.. you are good to go..

Wednesday, November 10, 2010

Fix for another Auto Suggest Bug .. Suggestion List wipes out the validation

This blog is again to complete my previous blog 'Another Auto Suggest Bug .. Suggestion List wipes out the validation' which points to a bug in functionality of Auto Suggest behavior.
Well Thanks to Oracle, they have fixed the bug but it would be released in Jdev version 11.1.2.0.0.

Monday, November 8, 2010

How to clear Weblogic Cache?

Recently while working with the customization of skin in Oracle Identity Manager(OIM) application I was required to restart the Weblogic server hosting OIM so many times and many a times I found that just bouncing/ restarting server is not enough, we will also need to clean up the cache so that new changes takes effect. Well, I am not a  Weblogic champion as of now, so I went on to google the thing up.. but it took me some time to really figure what to do.. so here is what you need to do in short:

1. Shut down Server.
2. Delete the contents of the folder ORACLE_HOME/user_projects/domains/your_domain/servers/your_server/tmp
You can also delete ORACLE_HOME/user_projects/domains/your_domain/servers/your_server/cache (optional)
3. Restart Server.