kBLOG

All things about Life, Oracle Middleware and Technology

May 21, 2012
by agawish
2 Comments

The ultimate guide for beautiful skinning in ADF and WebCenter – Using SASS

This is a cross post with mdlwr blog

 

ADF & SASS

Prologue:

Long time no posts, I’ve been busy coding in the last couple of months, and as the life always do, I really didn’t have much time writting posts, instead I was busy rocking ADF and WebCenter projects.

The Problem:

As all of you ADFers know, skinning in ADF has been pain in the butt, and as Skinning and style is a crucial part for any ADF application, there has to be some way in order to make this work easier.

So Oracle -thankfully- made JDeveloper 11.1.2.x and/or the ADF Skinning application in order to make it easier for ADF developers to write skins effectively with all electors, images editor, preview pane and all this good stuff.

Did it become easier?

No -well a little bit, but not to that extent-, as the selectors of ADF is overwhelming, and as you needed to structure your skin in a prober way but instead you are forced to stay with the one skinning file, so you end up having a css file that has not less than 800 line of styles without comments ofcourse!!!

If you interested in how to make this easier, and if you already know css well and not afraid to learn a new couple of things, then keep reading, you will enjoy it…I guarantee

Continue Reading

December 12, 2011
by agawish
0 comments

Using Groovy to Retrieve Current logged in user name

This is a cross post with mdlwr blog

One tip I found Useful, and I didn’t find enough resources talking about it, is how to populate a value of Entity Attribute or Binding Value with the current logged in user using Groovy

 

Simply use this:
adf.context.securityContext.getUserPrincipal().getName()
Piece of cake :)

October 19, 2011
by agawish
4 Comments

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

This is a cross post from mdlwr

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<String> getListOfUsers() throws RuntimeException {
        try {
            List<String> allUsers = new ArrayList<String>();
 
            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<String> getUserGroups(String username) throws RuntimeException {
        try {
            List<String> allUserGroups = new ArrayList<String>();
 
            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<String> getGroupMembers(String groupName) throws RuntimeException {
        try {
            List<String> allGroupMembers = new ArrayList<String>();
 
            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<String> getListOfGroups() throws RuntimeException {
        try {
            List<String> allUsers = new ArrayList<String>();
 
            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 Utilities Class :)

October 2, 2011
by agawish
0 comments

Farewell @notifyme, you were great

Notify Me is closing its services on 4th of October, It’s sad because I was depending on Notify.me in getting me the feeds updates I’m interested in, the Notify Me creator explained his reasons saying:

This is most regrettable news, I have failed to find a business model that can support the service adequately. I’ve mentioned before about a plan to create a subscription however even optimistic projections fall short of anything sustainable.

However He suggested some other alternatives for his service, one of which is very interesting which is ifttt -yes the name is weird, but its a great Service indeed- It’s really a sad news, and I hope for the Notify.Me creator initiate a new service that I’ll sure follow his great ideas

July 16, 2011
by agawish
1 Comment

What is Oracle WebCenter Connect

In my Previous Post I pointed out the new WebCenter Strategy that Oracle Presented, which includes four products

WebCenter Sites – A WEM (Web Experience Management) System which FatWire Acquisition played a great role of making
WebCenter Portal – The old definition of Oracle WebCenter Suite including WebCenter Interaction, WebLogic Portal
WebCenter Content – Which is the new name of Oracle ECM which was acquired from Stellent by Oracle
WebCenter Content – From which I want to point out new information about it

As Oracle says, the WebCenter Connect consists of three major products

 

1- Oracle On Track Communication

This is the main component of Connect which in my mind is going to be a blow in the WebCenter Products, because of it’s structure and paradigm.It uses a different model, than we we would originally think, and that is the ConversationA Conversation  is a way of communication, think of it like an email, a presentation, a chat, document annotations or even a video call, this is all a conversation material, you can make a conversation with a person using those stuff, but further more this conversation is a needed assets in the now application for historical and referencing reason, so it can be categorized into more stuff, like a Task for example, a task can be a set of Conversations that have specific metadata like assigned person and stuff, and the conversation content can be attached files of the task content itself or can be consultation help of this task, or even a voice recording about description of this Task, take this example and expand it to cover Projects, Meetings and more, it’s like the Google Wave project with some cool plugins for browser and Outlook and mobility focused application like iPhone and iPad you have what you need to do things for the enterprise on Go.What will be amazing, is how this capabilities gonna be integrated in the new WebCenter SuiteHere is  some Screen shots of  the product:
     

2- Oracle WebCenter Real-Time Collaboration

This is the old WebCenter Collaboration Server which improves efficiency and productivity by enabling users to connect and collaborate with others via instant messaging, presence, chat rooms, and web and voice conferencing, it’s a key piece for portal if you want to enable rich interaction between users and provide a more connectable Portals, and it’s available as part of the Beehive Product

3- Oracle WebCenter Intelligent Collaboration

Oracle WebCenter Intelligent Collaboration (WebCenter IC) is a unique connection brokering solution that gives employees a way to easily reach out to the most knowledgeable people throughout your organization to get the critical insights and information they need to make smarter business decisions. Unlike other expertise search or expertise location solutions out there, WebCenter IC doesn’t rely on users having to manage profiles, or publish tags that describe their expertise, or even share any information or activities with others. Instead, the WebCenter IC system builds rich, private profiles of all employees and then acts as a broker between a person needing help on a topic and the people that are most knowledgeable about that topic. Without revealing the identity or profiles of those targeted, the system sends them ‘invitations to connect’ and only when the person opts-in to respond is his or her identity revealed.

So now the important question, how those products will fit under the WebCenter Umbrella and play nicely with WebCenter Portal, Sites and Content

July 14, 2011
by agawish
1 Comment

Oracle WebCenter Changes its face…again!

After the migration of BEA AquaLogic Interaction into WebCenter Interaction suite, Oracle made a new advancement after acquiring FatWire, and after the acquisition of Stellent Content Management System, Oracle has announced the WebCenter Suite strategy as follows:

  • WebCenter Sites

    This is the WEM (Web Experience Management) Functionality that Oracle talked about when acquired FatWire, and it’s different that a normal WCM (Web Content Management) see this article, there is no talk of how this feature gonna be from oracle, but soon enough we will know, however oracle defines the product as :Oracle WebCenter sites enables marketers to rapidly create multiple online experiences that strengthen customer engagement. It allows them to reduce maintenance demands on IT while gaining more control over dynamic targeted content to promote customer loyalty and increase revenue.Waiting to see more about WebCenter Sites
  • WebCenter Portal


    This is basically the old WebCenter Suite as we used to know it, including Oracle Weblogic Portal and Oracle WebCenter Interaction suite plus WebCenter Servies, oracle defines the product as:Oracle WebCenter portal is a portal and composite applications solution that delivers intuitive user experiences for the enterprise that are seamlessly integrated with your enterprise applications.
  • WebCenter Content

    This was a shock to me, because this is Oracle ECM in its new name, and hopefully new face.
    This will be the official name for Oracle ECM from now on, so ECM people should get used to it!, and here is the oracle definition of the productOracle WebCenter content provides organizations with a unified repository to house unstructured content, and deliver it to business users in the proper format, and within context of familiar applications to fit the way they work.
  • WebCenter Connect

    Stream Based Conversation System, That’s how oracle made it look like, This is also a new thing that oracle introduces, to know more read this post, or read the definition of the product from Oracle:Oracle WebCenter connect provides an innovative social experience designed to drive collaborative decision making within businesses through a modern web experience and consumer style design that delivers a highly engaging environment to focus productivity.Waiting to see more about this interesting news, don’t you!

July 7, 2011
by agawish
0 comments

Being the Computer guy!

Being a computer guy
I’ve been facing my entire life the problem of being the Computer guy, that when someone knows that I’m into computer, they ask me with a big smile on their face “Please can you help me with the computer, the folders is not organized!” or something like “The Computer is slow, and I only run about 30 programs in parallel!” and If I tried to deny that I’m that “kind” of Computer guy they just thing, that I’m getting away!

I just wanted to say I’m not a computer person, I’m a software person that I know about some aspects of software while there is a huge difference, people don’t get enough asking you about the damaged HDD or the Wireless network is not working, or the internet is slow!

I’M A MIDDLEWARE/SOFTWARE/INTERNET PERSON, I DON’T FIX COMPUTERS!!!

April 3, 2011
by agawish
1 Comment

I’m alive


For the people who still wonder where am I – I doubt there are any! – I’m still alive.

I’m preparing for my wedding ceremony so I won’t be available for the next period, but I hope I can be back to blogging soon.

I’m sorry for people who sent me mails but I didn’t reply, please forgive me but I don’t have any time to spare to answer.

See you soon.

February 13, 2011
by agawish
0 comments

Egypt, The Free Country

Long Live Egypt

“Yaaaaaaaaaah” I never felt this relief before, at last we will build a new Egypt,
at last we will live freely and feel our human rights and
at last Egypt is a Free Country.

The past 18 days were so hard, as I’m not currently in Egypt, I felt so bad not being part in all this, felt so bad that I’m safe here, while my family and my friends are at risk, I felt so bad that I can’t be part of a big change happens to people from inside and reflected on their outer behavior, I felt so bad to realize I’m more patriotic than I could ever imagine, and yet I couldn’t do something about it!

All people who know me knows that I hate political news and News channels, but after thinking about those days I realized that I didn’t change Al-Jazeera channel for those 18 days, waiting for any statement of the President like a child waiting for candy, disappointed when I realized that most of them are not candies, but a mere rotten Hrnkc-حرنكش- but I was jumping in joy as I heard the latest statement of Omar Soliman, GOD I FELT SO HAPPY!

I wish that I could be there, joining the forces of Revolution.

I wish that I could help my family, when thugs attacks were many.

I wish that I could share the happiness of the Egyptian street, in Cairo.

I wish that I could be there, cleaning Al-Tahrir with all the others.

But in the end I’m so proud of being an Egyptian, like never before, and I’m so proud of Egypt, the Free Country.

I’ll leave you with this video that My Brother made: