Quantcast
Channel: Jive Syndication Feed

Host SAPUI5 on NetWeaver Java 7.3 Server !!!

$
0
0

Disclaimer - This blog is for beginners likeme... Moreover, the approach I took may not be the best one - I just followed what seems feasible at the moment. There may be alternate and better way to do the same

--------------------------------------------------------------------------

 

This all started while I was playing around with SAPUI5 a few days back. To run a simple UI5 application, I had to install a Tomcat 6 Server and host the SAPUI5 Libraries on it. I could add a "little bit" more to the application by displaying Sales Order Headers and Item Details retrieved from the SAP Hosted Demo Gateway Systems using RESTful Services and oData Channel. I did face lot of road blocks, but Thanks to Experts Simon Kempand Abhilash Gampa who helped me with their inputs and I finally could fix the application to run successfully.


<If you would like to to see the dicussion thread - here is the link Access denied Error for sap-ui-core.js in IE8 !

 

Next curiosity was to host the SAPUI5 libraries on the NetWeaver Java Server 7.3 version and develop UI5 applications which will run on top of the SAP Java Server itself. Well this blog narrates the experience of how far I could go with UI5 and the Java 7.3 Engine.

 

So lets get started...:)

 

Host the SAPUI5 Framework on NetWeaver Java Server 7.3

 

I wanted to host the libraries in a location so that these are out of the Portal "IRJ" J2EE application and can be called accessed thru anonymous users. A more direct URL like - http://server:port/sapui5 and which does not use the IRJ Alias. But what is the folder location to get to the Java Application Sever Start Page? Well, a little bit of investigation of the Server Load (http://hostname:port/startPage) led me to the following location on the Server File System

 

/usr/sap/<SID>/J00/j2ee/cluster/apps/sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root20-Jul-12 4-29-52 PM.jpg20-Jul-12 4-31-25 PM.jpg

 

Extract all the contents of the SAPUI5 zip file that you have downdloaded from SDN to a folder (in my case its sapui5), under this "root" folder


Lets try accessing the SAPUI5 Home page from the Server by using the URL http://server:port/sapui5

06-Aug-12 1-12-00 PM.jpg

 

There we go, SAPUI5 running on the NetWeaver 7.3 Java Server.

 

Go further by running the Sales Order UI5 application which I hosted on the Tomcat Server. I created a folder structure inside sapui5 folder so as to segregate the HTML and JS files.

06-Aug-12 1-29-35 PM.jpg

 

And Run the Sales Order Application on 7.3 JAVA Sever

06-Aug-12 1-31-17 PM.jpg

<P.S - Using IE9 to run this application, faced issues with IE8>

 

Next try would be to run this application inside PoD (Portal on Device). Already tried running this, but SAPUI5 does not seem to render and work well inside PoD at the moment. Probably some work around might help...

 

So go on, and play around with SAPUI5 on the NetWeaver 7.3 Java server itself.

 

As always, feedback is most welcome !

 

Sandip Agarwalla




Blog it Forward – Sandip Agarwalla

$
0
0
Blog it Forward – Sandip Agarwalla I am starting this with a “Thank you” to Simon Kemp who added me in this BIF chain. It was nice of him to hand over the baton to me, though we have communicated only few times in SCN over the last 4-5

How to add reference to SAP provided JARs in PDK, Web Dynpro JAVA on NWDS 7.3

$
0
0

It’s never too late:


As the famous quote goes, I am starting off with the same belief.  I have been a member of SCN Community for close to 8 years!!! And this is going to be my First BLOG. I can’t believe all this time I have been so much of an ACTIVE Listener & Passive Contributor on SCN. Though I used to contribute to the Portal, WDJ forums but it was minimal – partially because of my inertia and partly because of time constraint.

 

The day the new SCN was launched few months back, it instantly caught my eye and I immediately started exploring the new features and all. I got lot of bumpy roads and issues even reported some of the issues to SCN Support (scn.sap.com/thread/3143114). I felt I could help improving the SCN even though it’s very small by contributing/reporting actively in any way. That sort of gave me a new meaning and the zeal of Contributing to SCN.

 

Since then I was kind of regularly helping out people on Discussion Forums in Web Dynpro Java, KM, Portal, BPM etc etc and now here I am writing off my very first blog on SCN, hope it will be a smooth ride and will be accepted by the community. I am thrilled and apprehensive at the same time about writing this stuff on SCN.

 

There is always THE First Time.


Summary:


This blog shows how to reference external JAR files (provided by SAP) in WDJ/PDK project developed in NWDS 7.3 platform.  Off late I have been seen lot of queries regarding moving the Portal PDK, WD Java Custom applications to the new Portal 7.3 Platforms. Lot of issues regarding porting the applications to the new server, JAR files are not referenced, Class Not found exceptions, API not compatible issue and all.

There are few excellent blogs already written on how to get started on 7.3 Development by @Kumar Prashant, my blog just complements it by showing the details steps on how to add the dependency for SAP JARs.

 

Though, you can always reference external JAR files provided by SAP (e.g. com.sap.security.api.jar, ) by putting them in the LIB folder of your project source files (probably you have done that way in 7.0). However, this is not an optimal solution and more so when SAP provides all these JAR in the form of DC Public Parts. So all you need to do is just add the Public Part reference for these Jar files, and you are good to go for the development.

 

This is how you can add the dependencies to the JARs.

 

Open up the DC project,

1.jpg

 

It looks to have reference issue with UME API which is available in com.sap.security.api.JAR file. I can get the Jar file from Server add it in the LIB folder, and fix the issue. This may not be possible always since lot of APIs have changed or removed in 7.3 platforms. So a better way would be to look for if SAP DC is available.

 

Go to Development Infrastructure Perspective and Component Browser

 

Ths  This will list down your local SCAs and also the default ones provided by SAP. These SCA contain the indivisual DCs, JARs which required for different kind of Developments e.g. Portal, WDJ, BPM, Security, AII, KM, GP, at all.

 

Right Click on your custom DC and hit Component Properties

 

This should open up a window like this,                     

 

Click on the Dependencies Tab on top, and click Add

 

This is THE place to find all your JARs, DCs and dependencies. For my case, I need to look for com.sap.security.api.jar

I know the above required JAR file is contained in the following DC – tc/je/usermanagement/api

 

So I select the same, click next to configure the dependency. 

 

Click Finish and then OK on the next Pop-up

 

That’s all, you are done. Now go back to your custom DC perspective to see it you really can refer the com.sap.security.api JAR. Hit CTRL+SPACE, and I can refer to the required Classes indeed.

 

Use the SAP DCs where ever possible for JAR reference, makes life easier. Only when there are Non SAP JARs (POI, JXL) , you can go for a LIB folder approach or a custom Library DC approach.

 

Epilogue:

 

I hope you liked reading it and it will be useful to you. Any comments & suggestions on the technology topic or my blogging style are accepted.

 

I aim to become an ACTIVE Contributor,  Try contributing as much I can to the community which has done so many Positive Things to my Professional Career over the last 8.5+ years.

 

Cheers to SCN!!! Long Live….

 

Regards

Sandip Agarwalla

Retrieve Portal Objects from PCD in 7.3 Version

$
0
0

This blog shows how to retrieve PCD Objects (iViews/Pages/Roles etc) from a PCD Folder on the Portal 7.3 version using Custom Java Code.

 

First some Concepts - The Portal Content Directory (PCD) is the main repository for portal content, both delivered with the portal and created by administrators. The PCD contains a hierarchy of folders, each of which can contain semantic objects, such as iViews, pages and roles. The PCD is stored in the portal database and is accessed via the PCD Generic Layer (GL), and provides APIs to enable applications to perform look ups and modify the PCD Objects.

 

Each provider defines the logic for returning Java objects when querying a specific portal semantic object. A semantic object is defined by its com.sap.portal.pcd.gl.ObjectClass property.  When a lookup is performed on an object, the PCD checks the object class attribute to determine which object provider to use for creating/Editing a Java object from the set of attributes.Below table shows the respective GL property for different Semantic Objects like iViews, Pages etc

The below diagram shows the Process Flow when you do a look up on the PCD

18-Jul-12 1-52-35 PM.jpg

Source for the Above Section**:SAP Materials and SAP Help Web Sites

 

Ok then, enough of Concepts. Lets straight way dive into the source code. Here are the steps.

 

1) Create the custom DC project

     Create and set up a custom DC thru NWDS. In my case, its a WD Java DC, but you can very well use PDK/JAVA EE DC

    

         
2) Add the DC dependency for JAR files for PCD GL, JNDI etc APIs

     Open up Development Infrastructure Perspective, locate your DC and open up the DC Component Properties. Then Click on "Dependecies" Tab.

     Add the required DCs by clicking on ADD button. The JAR DCs you would need for referencing the PCD GL, JNDI etc are highlighted in the right hand side Image.

     

    

 


3) Source Code to retrieve Objects

     Add the following source code in the Java class

        

 

 

  1.     try
  2.           IUser usr = UMFactory.getUserFactory().getUserByLogonID("Test_Admin");           
  3.           Hashtable env = new Hashtable(); 
  4.           env.put(Context.INITIAL_CONTEXT_FACTORY,IPcdContext.PCD_INITIAL_CONTEXT_FACTORY); 
  5.           env.put(Context.SECURITY_PRINCIPAL, usr); 
  6.           env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);           
  7.  
  8.           InitialContext ctx = null;           
  9.           List<String> iViewList =null;         
  10.           DirContext dirCtx = null
  11.  
  12.           ctx = new InitialContext(env); 
  13.           //IAdminBase result =(IAdminBase)ctx.lookup(objectName); 
  14.           dirCtx = (DirContext) ctx.lookup("pcd:portal_content/test_pcd"); 
  15.  
  16.           //set the search controls to find only the iviews           
  17.           PcdSearchControls pcs = new PcdSearchControls(); 
  18.           pcs.setReturningObjFlag(false); 
  19.           pcs.setSearchScope(PcdSearchControls.SUBTREE_WITH_UNIT_ROOTS_SCOPE);           
  20.           dirCtx.addToEnvironment(Constants.APPLY_ASPECT_TO_CONTEXTS,Constants.APPLY_ASPECT_TO_CONTEXTS); 
  21.  
  22.           NamingEnumeration<SearchResult> ne;         
  23.           //ne = dirCtx.search("","(com.sapportals.portal.pcd.gl.IPcdName=com.sapportals.portal.iview)",pcs);           
  24.           ne = dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.iview)",pcs); 
  25.  
  26.          // fetching iviews         
  27.           iViewList = new ArrayList<String>(); 
  28.  
  29.           while(ne.hasMoreElements()) 
  30.           { 
  31.               IPcdSearchResult searchResult = (IPcdSearchResult)ne.nextElement();  
  32.               String location = "pcd:portal_content/test_pcd/" + searchResult.getName(); 
  33.               //Get the full pcd path of the iview.  
  34.               wdComponentAPI.getMessageManager().reportSuccess("-->iView::"+location); 
  35.               //iViewList.add(location); 
  36.           }  
  37.           } catch (NamingException e) { 
  38. //            // TODO Auto-generated catch block 
  39.               wdComponentAPI.getMessageManager().reportSuccess("Look Up Error::"+e.getMessage()); 
  40.          } 
  41.           catch (Exception e1){ 
  42.              wdComponentAPI.getMessageManager().reportSuccess("Error2::"+e1.getMessage()); 
  43.        }

 

 

4) Validation of Results

    A quick check to see if the code really gets all the iViews from the specified folder including sub folders as well

 

     

 

 

 

 

 

And, here we go - we could successfully fetch the iViews from the specified Folder. The Source Code can be extended to fetch Pages/Roles as well by modifying the ObjectClass property to Page or Role

 

com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.page

 

Hope the blog would be useful to you. Comments/Suggestions are welcome...

 

Sandip Agarwalla





Latest Images