JDeveloper Git Extension v1.0.0.1

I started to develop an extension for JDeveloper to be able to connect to Git Versioning System, and so far I had a short success to clone Git Repository to Existing JDeveloper Project (read the article from here)

 

Now I've moved a step further, Now with the extension you can create a new application, with a project name as you wish, and copy the files from repository into your created application.

 

Check the following photos, to illustrate the steps more...

 

It may sound like a small  achievement, but many little confident steps can create a huge leap forward 

 

Again if you dare to try the extension now, download it from here

 

(download)

@JDeveloper #Git Plugin

Oracle-jdev-logo
Git-logo_3

So I love git, and I Love GitHub and since I use them both, and I use JDeveloper I though of developing a plugin for JDeveloper to integrate with Git and GitHub eventually

Here is my Attempt of doing so:

I Introduce to you: JDeveloper Git Extension 1.0.0 Beta Version which works on JDeveloper 11.1.1.5 JDeveloper (Will be working on migrating it to 11.1.2.x soon)

The project is divided into different phases:

Phase #1:  Cloning Git Repository into JDeveloper Project (Completed)

Phase #2:  Provide the Files Action and overlay (To push, pull, commit, checkout, add to ignore list and more ..)

Phase #3:  Provide an Integration with GitHub

 

So Far I've finished Phase #1

It's simple, you simply choose a project > New > General > Projects > Clone Git Repository

And enter the URL of the Git Repository and the select the Project you want to Install the files to

Once you finish, you should recieve a Success Message telling you everything is Good for, a simple refresh to your project you can see all the new files exported from Git.

If you tried to clone to a project that has been already cloned an Error message will popup telling you, you shouldn't do that!

Simple isn't it...

Check out the Photos, and for any one who dares enough to try it download it from here

(download)
Comments and Feedback will be appreciated

mdlwr is now proudly hosted by @posterous

Posterous-logo

I faced some troubles with wordpress, not with wordpress itself, but with the shared hosting, with some malware that was eating it, slowing it down, and sends trojans to anyone who opens it, so I started to look for alternative blogging system, and so the story began...

Tumblr

First Micro-Blogging system I faced, was tumblr, wow -I said- it seemed so slick, so touchy, so... feminine!
I successfully imported my posts from my wordpress to discover that the format sucks in tumblr!!! 
I was fascinated about tumblr, how images, chats and videos can take another curve, but in the other hand mdlwr is about technical blog, which tumblr is not a good choice to have, and I didn't need all the extra post types!! besides the settings is a HARD LINK TO FIND!!!!
It was nice knowing tumblr, but I didn't like how things turned out between the both of us, so I started to looking again to find 

Posterous

I know posterous when it started from @techcrunch, and I realized how genius they were, just to enable some small feature like sending posts from mails, so I created an account, and didn't check it for some time, till now...to realize that it has been rapidly changed, and WOW I might say, they turned it to something great and beautiful, I started to send my posts to mails, changing the dates, fixing the dates, changing the settings, linking with my domain name and enabling the auto-post in no time, and now It's ready!!

Check out my new mdlwr blog, proudly hosted by @posterous 

thanks @posterous for such a great blogging system :)

Creating Utilities to manipulate users in #Weblogic using #JMX and #MBeans

INTRO

First I'd like to apologies for the big absent on my side as I was very busy traveling to KSA for a new freelancing Client, but anyway I hope this article make you forgive me :)

Weblogic is a great Application Server, and the one you can count on for your heavy industrial deployment, load balancing, high availability and clustering.

Not only that but it comes with a great scripting tool WLST and the standardization of accessing its MBeans through JMX

There were an old school approach which would allow you to access MBeans through Weblogic APIs itself like so

import weblogic.management.Helper;
import weblogic.management.MBeanHome;
public class UseHelper {
    public static void main(String[] args) {
        String url = "t3://localhost:7001";
        String username = "weblogic";
        String password = "weblogic";
        String msName = "MS1";
        MBeanHome localHome = null;
        try {
            localHome = (MBeanHome)Helper.getMBeanHome(username, password, url,
                       msName);
            System.out.println("Local MBeanHome for" + localHome +
                       " found using the Helper class");
        } catch (IllegalArgumentException iae) {
            System.out.println("Illegal Argument Exception: " + iae);
        }
    }
}

But as you write this in your JDeveloper or favorite Editor, you will realize that this has been deprecated!

So the better alternative, and the hard way around it is to use JMX

THE DEFINITION

JMX(Java Management Extension) is a technology that represents a universal, open technology for management, and monitoring applications, system objects, devices (e. g. printers) and service oriented networks. Those resources are represented by objects called MBeans (for Managed Beans)

So Enough with the definitions, lets get to work.

THE UTILITY CLASS

What we want here is accessing Weblogic MBeans to get Users for DefaultAuthenticator -Default authenticator on Weblogic and Get Users, Groups and doing some manipulation like adding, editing, deleting and reset password for users in Weblogic Default Authenticator -You can edit it to suit your need but remember if the authenticator is read only you will get exceptions trying to alter users.

So lets get Started, first by checking MBeans Reference We will realize that in Order to access the Users we have to go this path:

  • Configuration MBeans
    • Domain Configuration MBeans
      • Security Configuration MBean
        • Default Realm (Attribute of Security Configuration MBean and an instance of RealmMBean)
          • AuthenticationProviders (Attribute of Default Realm and an instance of AuthenticationProviderMBean[])

So How do we do that, let's start write some code

THE INITIALIZATION CODE

We will start my making a connection to Weblogic Server instance, and then drill down to AuthenticationProviderMBean(s)
Remember this is a utilities Class, that's why all of my methods will be static

/****** DEFINING SOME STATIC VARIABLES ********/
public static final String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
public static final String MBEAN_SERVER = "weblogic.management.mbeanservers.domainruntime";
public static final String JNDI_ROOT = "/jndi/";
public static final String DEFAULT_PROTOCOL = "t3";
public static final String PROTOCOL_PROVIDER_PACKAGES = "weblogic.management.remote";
//This how we get our DomainRuntimeService, this is where DomainConfigurationMBeans exists
public static final String DOMAIN_MBEAN_NAME = "com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean";
private static MBeanServerConnection connection;
private static ObjectName defaultAuthenticator;
private static ObjectName[] authenticationProviders;
private static String authenticatorName="DefaultAuthenticator";

Okay, now we defined it, let's drill down to our AuthenticationProviders

static {
        try {
            String host = "127.0.0.1";
            String port = "7101";
            String username = "weblogic";
            String password = "weblogic1";
            Hashtable h = new Hashtable();
            JMXServiceURL serviceURL;

            serviceURL =
                    new JMXServiceURL(DEFAULT_PROTOCOL, host, Integer.valueOf(port).intValue(),
                                      "/jndi/weblogic.management.mbeanservers.domainruntime");

            h.put("java.naming.security.principal", username);
            h.put("java.naming.security.credentials", password);
            h.put("jmx.remote.protocol.provider.pkgs",
                  "weblogic.management.remote");

            //Creating a JMXConnector to connect to JMX
            JMXConnector connector =
                JMXConnectorFactory.connect(serviceURL, h);

            connection = connector.getMBeanServerConnection();

            /****
              We Get Objects by creating ObjectName with it's Qualified name.
              The constructor take a String of the full Qualified name of the MBean
              We then use connection to get Attribute out of this ObjectName but specifying a String of
              this Attribute
              *****/

            ObjectName configurationMBeans=
                new ObjectName(DOMAIN_MBEAN_NAME);
            ObjectName domain =
                (ObjectName)connection.getAttribute(configurationMBeans, "DomainConfiguration");

            ObjectName security =
                (ObjectName)connection.getAttribute(domain, "SecurityConfiguration");

            ObjectName realm =
                (ObjectName)connection.getAttribute(security, "DefaultRealm");

            authenticationProviders =
                    (ObjectName[])connection.getAttribute(realm,
                                                          "AuthenticationProviders");

            for (int i = 0; i < authenticationProviders.length; i++) {
                String name =
                    (String)connection.getAttribute(authenticationProviders[i],
                                                    "Name");

                if (name.equals(authenticatorName))
                    defaultAuthenticator = authenticationProviders[i];
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

WOHOO you've done a great step, you now have a reference to the defaultAuthenticator MBean, now you can make operations on users and Groups

DEEP INSIDE DEFAULTAUTHENTICATORMBEAN

If you looked at the reference of DefaultAuthenticatorMBean which is a subclass of AuthenticationProviderMBean you will realize the following:

Attributes

Operations

Now I guess you know what do we need to do right, Excellent so lets get it done

THE USER/GROUP MANIPULATION

public static boolean addUser(String username, String psw, String desc) {
        try {
            /** As of connection.getAttribute you can use connection.invoke to invoke an action
                It Takes ObjectName, String OperationName, Object[] Parameters, and String[] Parameters
                Definition
            **/
            connection.invoke(defaultAuthenticator, "createUser",
                              new Object[] { username, psw, desc },
                              new String[] { "java.lang.String",
                                             "java.lang.String",
                                             "java.lang.String" });

            return true;
        } catch (Exception e) {
            return false;
            //throw new RuntimeException(e);
        }
    }

    public static boolean removeUser(String username) {
        try {
            if (!username.equalsIgnoreCase("weblogic")) {
                connection.invoke(defaultAuthenticator, "removeUser",
                                  new Object[] { username },
                                  new String[] { "java.lang.String" });
            }

            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public static boolean resetUserPassword(String username,
                                            String newPassword) {
        try {
            if (!username.equalsIgnoreCase("weblogic")) {
                connection.invoke(defaultAuthenticator, "resetUserPassword",
                                  new Object[] { username, newPassword },
                                  new String[] { "java.lang.String",
                                                 "java.lang.String" });
            }

            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

           /** As of connection.getAttribute you can use connection.invoke to invoke an action
                It Takes ObjectName, String OperationName, Object[] Parameters, and String[] Parameters
                Definition, It returns an Object we cast it to Boolean, you can know all about function from
                MBeans Reference
            **/
    public static boolean isUserExists(String currentUser) throws RuntimeException {
        try {
            boolean userExists =
                ((Boolean)connection.invoke(defaultAuthenticator, "userExists",
                                            new Object[] { currentUser },
                                            new String[] { "java.lang.String" })).booleanValue();

            return userExists;
        } catch (Exception ex) {
throw new RuntimeException(ex);
        }
    }

    public static boolean isGroupExists(String currentGroup) throws RuntimeException {
        try {
            boolean gourpExists =
                ((Boolean)connection.invoke(defaultAuthenticator,
                                            "groupExists",
                                            new Object[] { currentGroup },
                                            new String[] { "java.lang.String" })).booleanValue();

            return gourpExists;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    /** This one is tricky, You first obtain a String cursor of the Iterator of Users, then you check if
        It have current, while true we invoke another function called "getCurrentName" which returns the name
        of the user, then I call advance function for the cursor to move forward, and invoke haveCurrent again
        and assign it to the same boolean I entered the while with (In order to get out of it!)
    **/
    public static List getListOfUsers() throws RuntimeException {
        try {
            List allUsers = new ArrayList();

            String cursor =
                (String)connection.invoke(defaultAuthenticator, "listUsers",
                                          new Object[] { "*",
                                                         Integer.valueOf(9999) },
                                          new String[] { "java.lang.String",
                                                         "java.lang.Integer" });

            boolean haveCurrent =
                ((Boolean)connection.invoke(defaultAuthenticator,
                                            "haveCurrent",
                                            new Object[] { cursor },
                                            new String[] { "java.lang.String" })).booleanValue();

            while (haveCurrent) {
                String currentName =
                    (String)connection.invoke(defaultAuthenticator,
                                              "getCurrentName",
                                              new Object[] { cursor },
                                              new String[] { "java.lang.String" });

                allUsers.add(currentName);
                connection.invoke(defaultAuthenticator, "advance",
                                  new Object[] { cursor },
                                  new String[] { "java.lang.String" });

                haveCurrent =
                        ((Boolean)connection.invoke(defaultAuthenticator, "haveCurrent",
                                                    new Object[] { cursor },
                                                    new String[] { "java.lang.String" })).booleanValue();
            }

            return allUsers;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    public static List getUserGroups(String username) throws RuntimeException {
        try {
            List allUserGroups = new ArrayList();

            String cursor =
                (String)connection.invoke(defaultAuthenticator, "listMemberGroups",
                                          new Object[] { username },
                                          new String[] { "java.lang.String"});

            boolean haveCurrent =
                ((Boolean)connection.invoke(defaultAuthenticator,
                                            "haveCurrent",
                                            new Object[] { cursor },
                                            new String[] { "java.lang.String" })).booleanValue();

            while (haveCurrent) {
                String currentName =
                    (String)connection.invoke(defaultAuthenticator,
                                              "getCurrentName",
                                              new Object[] { cursor },
                                              new String[] { "java.lang.String" });

                allUserGroups.add(currentName);

                connection.invoke(defaultAuthenticator, "advance",
                                  new Object[] { cursor },
                                  new String[] { "java.lang.String" });

                haveCurrent =
                        ((Boolean)connection.invoke(defaultAuthenticator, "haveCurrent",
                                                    new Object[] { cursor },
                                                    new String[] { "java.lang.String" })).booleanValue();
            }

            return allUserGroups;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    public static List getGroupMembers(String groupName) throws RuntimeException {
        try {
            List allGroupMembers = new ArrayList();

            String cursor =
                (String)connection.invoke(defaultAuthenticator, "listGroupMembers",
                                          new Object[] { groupName, "*", new java.lang.Integer(0) },
                                          new String [] { "java.lang.String", "java.lang.String", "java.lang.Integer" });

            boolean haveCurrent =
                ((Boolean)connection.invoke(defaultAuthenticator,
                                            "haveCurrent",
                                            new Object[] { cursor },
                                            new String[] { "java.lang.String" })).booleanValue();

            while (haveCurrent) {
                String currentName =
                    (String)connection.invoke(defaultAuthenticator,
                                              "getCurrentName",
                                              new Object[] { cursor },
                                              new String[] { "java.lang.String" });

                allGroupMembers.add(currentName);

                connection.invoke(defaultAuthenticator, "advance",
                                  new Object[] { cursor },
                                  new String[] { "java.lang.String" });

                haveCurrent =
                        ((Boolean)connection.invoke(defaultAuthenticator, "haveCurrent",
                                                    new Object[] { cursor },
                                                    new String[] { "java.lang.String" })).booleanValue();
            }

            return allGroupMembers;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    public static List getListOfGroups() throws RuntimeException {
        try {
            List allUsers = new ArrayList();

            String cursor =
                (String)connection.invoke(defaultAuthenticator, "listGroups",
                                          new Object[] { "*",
                                                         Integer.valueOf(9999) },
                                          new String[] { "java.lang.String",
                                                         "java.lang.Integer" });

            boolean haveCurrent =
                ((Boolean)connection.invoke(defaultAuthenticator,
                                            "haveCurrent",
                                            new Object[] { cursor },
                                            new String[] { "java.lang.String" })).booleanValue();

            while (haveCurrent) {
                String currentName =
                    (String)connection.invoke(defaultAuthenticator,
                                              "getCurrentName",
                                              new Object[] { cursor },
                                              new String[] { "java.lang.String" });

                allUsers.add(currentName);

                connection.invoke(defaultAuthenticator, "advance",
                                  new Object[] { cursor },
                                  new String[] { "java.lang.String" });

                haveCurrent =
                        ((Boolean)connection.invoke(defaultAuthenticator, "haveCurrent",
                                                    new Object[] { cursor },
                                                    new String[] { "java.lang.String" })).booleanValue();
            }

            return allUsers;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
And that's it, Enjoy your Weblogic Utility Class :)

Creating Oracle UCM Portlet in easy steps

I recently faced a requirements when the customer needed to display a custom portlet of Oracle UCM specific Document Type in WebCenter Interaction, and those who don't know WebCenter Interaction aka WCI aka AquaLogic User Interaction aka ALUI, should read about it!

Anyway so I went through UCM Content Portlet Suite (CPS), and I found the search but, the customer wanted a thumbnail (Rendition) of the document to be displayed!

After searching online I found an amazing article on different ways to integrate WebCenter application with Oracle ECM, of course the author was talking about Oracle WebCenter not Oracle WebCenter Interaction -There are differences, huge ones!- but one of the ways specifically interested me, that is using JSON output of the UCM services to be parsed using Javascript and do the work needed.

So HTML pages, can display content from UCM using Javascript and JSON Parsing, COOL!

So instantly -actually 2 weeks later!- I started to dig out how to deal with this JSON object returned, and how can I use it to fulfill my needs.

The author of the Video/Article gave 2 simple examples, Showing the folder structure of the UCM and to search UCM, using the Ajax way!

So as I wanted to get the result of a specific document type, so I was interested in his last example,

1- How can I tune his search query to give me what I need?,

2- How can I actually get the rendition of the file? and

3- How can I know the image path using the rendition?

All that questions poped-up, along with other questions like security concerns and other stuff -those other stuff still unsolved pieces!-, and here is the results...

1- How can I tune his search query to give me what I need?

 I answered that question by watching the behavior of the UCM site itself, how can it gets documents of a specific document type, and I found it was by using
(dDocType+<matches>+`requested Document Type`)

that was easy!

And I figured out some other things like Sort order and Sort field (I wanted them to be sorted descending by date!) using the following
SortField=dInDate&SortOrder=Desc

Neat!

So now what, well I discovered a little bit of a problem, that the query only displays 20 items by default!, and I wanted the whole list, I found a variable called ResultCount, setting it to -1 didn't help me out, so I gave it a very very long number! like this
ResultCount=9999999
But I use
ResultCount=1 in case I'm getting the last item only!

Okay great, so now we are ready to go, the final path to  request my search is like the following:
idcurl+"?IdcService=GET_SEARCH_RESULTS&QueryText=(dDocType++`"+documentDocType+"`)&ResultCount=9999999&SortField=dInDate&SortOrder=Desc&IsJson=1Of course the documentDocType is my javascript value that determines the document type

So now I have a JSON object with all documents in the "DocumentDocType" Document Type, so now I made a search to give me exactly what I need, time for Question 2

2- How can I actually get the rendition of the file?

That was actually simple, as I was searching the JSON Object returned I found two interesting columns "Rendition1" at column #16 and "Rendition2" at column #17 -It's count depends on the number of rendition you give for the specific document type, and that first one "Rendition1" returned with "t" letter or "g" ("t" for images that has the extensions "jpg","png","pmp","tiff" and also is for documents rendition, "g" is for images that has the extension "gif"), Great now I have the rendition? NO YOU DON'T!

what does the letter "t" or "g" help me achieving in here?!!, so that bring me to the last question

3- How can I know the image path using the rendition?

So I took a little breath, and came back to UCM to see the displayed thumbnail images, and I found the image property to be as the following: docname@t~1.jpg or docname@g~1.gif , so I was like guyz seriously!!!

so what is this!!, lets put it that way

docname@rendition~version.renditionExtension
So Okay, now what?
well it was easy after that, giving a javascript file to remove the real extension of the file download url, and replace it with the above code
So the final result was like this

var version=data.ResultSets.SearchResults.rows[i][8];
var rendition=data.ResultSets.SearchResults.rows[i][17].toLowerCase();
var docUrl=data.ResultSets.SearchResults.rows[i][21];
var docName=
var extension=".jpg";
if(rendition=="g")
extension=".gif";
var imageUrl=ucmurl+docUrl.substring(0,docUrl.indexOf('.'))+"@"+rendition+"~"+version+extension;

Okay, so I added just one line of code for fail back rendition to show a not-fount image like the following

if(rendition==""){
imageUrl="/not-found-image.jpg";

So that's great, Now I have the url of the image #column 21 and I have the Rendition image, viewing is so easy using the following in javascript

$('#thePortlet').append("
<a href="&quot;+ucmurl+docUrl+&quot;" target="_blank">"+


"<img src="&quot;+imageUrl+&quot;" border="0" alt="" />
"+
+docTitle+"</a>
");

and in HTML file as the following

<div id="thePortlet"></div>
, and here are the results application -don't mind the look!-

Ucm

There is one thing thou!

It won't work if the ucmurl has "http://" in it, it only works on IE, as the rest of browsers prohibits cross domain JSON calls, so I went around this thing with creating a servlet that does the JSON calling, while in the Javascript I called the servlet!

Enjoy, and looking forward for your comments

Oracle Open World 2010, and Oracle Fusion Applications!

After a long time of silence, I figured out that this blog should be continued as Oracle Open World started, with more news about Oracle Fusion and Cloud Computing.

Oracle Open World 2010

Here is a summary of what has been said so far:

1. Oracle Exalogic

Larry Ellison showed the most recent hardware machine combining the force of both Oracle software and (now Oracle) Sun hardware. The machine is specifically designed to host applications and function as a private cloud.

Because the ExaLogic ‘elastic cloud’ machine is build upon Oracle’s virtualization software, it combines the possibilities for creating your own cloud computing instance, within your firewall.

ExaLogic offers the possibility to upgrade or patch all running virtual machines on it with one single file, which brings a lot of question only time can answer it!

The new ExaLogic, beside being pretty impressive machine, really has the potential of bringing the cloud to the enterprise, the key to all this is Virtualization. Most enterprises probably don’t want their data in ‘unknown’ data centers. But they do want the flexibility offered by the cloud. Off course other virtualization products offer that, but now Oracle has it all, in one package, Especially the combination of the hardware, the virtualization software and the Coherence software really (could) make it happen, and I always wondered how the Middle East minds will accept hosting their applications on a remote cloud, how can they accept the concept, but now they Don't have to!  (Some parts quoted from whitehorses.com)

2. Unbreakable Enterprise Kernel (EEK)

Oracle announced that it will distribute it's own Linux kernel, Unbreakable Enterprise Kernel, in addition to continuing a Red Hat-compatible offering. The upshot here is optimizing OS performance for the Exalogic Elastic Cloud server mentioned above. So now Oracle customers will be able to choose between Oracle-branded Red Hat and Oracle's fork off the Red Hat kernel.

3. Oracle Fusion Applications

Boy now we are talking, now that Oracle established a robust Middleware (Oracle Fusion Middleware) they started creating applications on top of that, so that all it's application including their SIEBEL, E-Business Suite, JD Edwards and PeopleSoft to be based on Oracle Fusion Middleware and of course that offers a great integration capabilities with one Framework to Develop it All concept!

Ellison announced that the first release of Fusion Applications will generally available in the first quarter of 2011, with seven suites of 100 different products. Customers will be able to purchase individual products or a full suite. The lineup consists of Financials, Project Portfolio Management, Human Capital Management, Procurement, Customer Relationship Management, GRC (Governance, Risk and Compliance), and Supply Chain Management (which includes the app getting my vote for the best acronym - Distributed Order Orchestration or "DOO").

Here are some Photo:

Oracle Fusion Apps Oracle Fusion Apps
More photos can be found here

Stay tuned on this blog, soon there will be some articles about ECM, SOA, IDM, WebCenter and lots of ADF