Sunday, 8 June 2014

Web application bridge in websphere portal 8

Web application bridge :- Using this we can iframe any application in a portlet . So that we can view any external application in portal.

Step 1 :- First we should login to portal associated was console admin and change the context of below application to /



Step 2 :- Now click on the application and then click on context root for web modules


Step 3 :- Change the context to / and click on ok


Step 4 :- Restart the wp.vwat.servlet.ear for which we modified context in above screen

Step 5 :- Now login to portal admin console and then click on virtual web application manager



Step 6 :- Now click on new and make a new application category and then application component



Step 7 :- Now create new component under above category

Step 8 :- Enter below details


Context root :- You should cover all the context with coma separated value

Step 9 :- Now click save and navigate to a page where you want this website to be displayed and click on edit page properties set profile as full as given below and click on save



Step 10 :- Now add web dock portlet to the page


Step 11 :- Now click on edit shared settings as given below


Step 12 :- Now enter below details and click save


Step 13 :-  Now click save website will be displayed if you configured the context's correctly otherwise 500 proxy error will come


Saturday, 7 June 2014

Explore tagging and rating in Portal 8

Tagging and rating :- First we have to tag a portlet then this tag will be visible under tag center there you can give rating for the page. Below we can see this process

Step 1 :- Login to application and navigate to any page and then click on actions and the select tag as given  below



Step 2 :- Enter the tag values with space as delimiter


Step 3 :- Now click on save


Step 4 :- Now close it and click on Tag center page at the top

Step 5 :-  Now click on any one of the underlined tags you will be navigated to corresponding page where you can rate the content in the page

Step 6 :- Now you can go back to page select rate from actions and rate it

Step 7 :- Now you can go to search center and check it by clicking on tag

Explore manage pages in websphere portal 8

Manage Pages :- Its a portlet using which we can create pages and child pages alternate way is through xml access. Now from portal 8 we can create a new project and it will be in sync with wcm . This project and go through the approval process before getting published. Below you can find how to create new project and go through approval process

Step 1 :- Login as administrator and click on Published site and then click on create new project as given below

Step 2 :- Now enter below details for the new project , set approvals and then click on save



Step 3 :-  Now click on more you can create a child page or sibiling page


Step 4 :- Now create a page at same level i mean at sibling level

Step 5 :- Now you can add a Feed portlet or Article portlet and give feed url for Feed Portlet

Step  6 :- Now click on more actions and select Preview as user impersonate and look at the page and stop impersonating

Step 7 :- Now you can change style or layout and then final push. Until you publish remaining users will be seeing it as draft page




Creating virtual portal in websphere portal 8

Virtual portal :- Its a copy of portal with limited capabilities. People create multiple virtual portals to host different set of applications like account,finance,health care each of them having different url and different navigation structure.

Example{Below urls will be redirected to corresponding virtual portal depending on config} :-
http://localhost:10039/wps/portal/finance
http://localhost:10039/wps/portal/accounts
http://localhost:10039/wps/portal/healthcare


Step 1 :- Now login to websphere portal admin console and click on manage virtual portals under Virtual-Portals as given below




Step 2 :- Now click on create new virtual portal button on right hand side and fill below details


Virtual post hostname :- You can give a domain name and map to same ip address as base portal
Context  :- This is the value you case use it after wps/portal if it is hospitality then wps/portal/hospitality

Step 3 :- Now click ok virtual portal will be created. It will take some time.



Step 4 :- Now you can access your virtual portal two ways
                A) http://localhost:10039/wps/portal/accounts {By default this redirects to B}
                B) http://accountstest:10039/wps/portal



Monday, 2 June 2014

Command Cache implementation in portal

Command Cache :- This is used as a place holder for data and replace it at a particular interval as desired .

 Step 1:- First you need to check whether your web-sphere portal is capable of caching the data



Step 2 :- Now click on Dynamic cache service under container services and check whether below check box is selected



Step 3 :- 
  1. Create a Java class that extends CacheableCommandImpl class, this class provides logic to cache data by providing life cycle for your class. The CacheableCommandImpl is abstract class so in order to make a concrete class you will have to override  its isReadyToCallExecute() and performExecute() method

  2. The CacheableCommandImpl class provides life cycle for the cache-able object, it will call the isReadyToCallExecute()method of your class to check if your class is ready to execute. You can use this method to check if your data access part is ready. If it is not ready you can write custom code to return false

  3. The performExecute() method of your class is the place were you will be having your custom code to get data . In my example class name is CachableContent
//Class code
package com.ibm.cachableClass;

import java.util.Random;

import com.ibm.websphere.command.CacheableCommandImpl;

public class CachableContent extends CacheableCommandImpl {
private static final long serialVersionUID = 6243454554964886940L;
private int randomValue = 1;
private int ComputedValue = 0;

public CachableContent(int value) {
this.randomValue = value;
// TODO Auto-generated constructor stub
}

@Override
public boolean isReadyToCallExecute() {
// TODO Auto-generated method stub
return true;
}

@Override
public void performExecute() throws Exception {
System.out.println("enterring into perform execute");
//We will get updated computed value for every 60 seconds
setComputedValue(randomValue+randomValue);
// TODO Auto-generated method stub

}

public int getRandomValue() {
return randomValue;
}

public void setRandomValue(int randomValue) {
this.randomValue = randomValue;
}

public int getComputedValue() {
return ComputedValue;
}

public void setComputedValue(int computedValue) {
ComputedValue = computedValue;
}

}

Step 4 :-  Now create a portlet to access the CachableContent


package com.ibm.cachableportlet;

import java.io.*;
import javax.portlet.*;

import com.ibm.cachableClass.CachableContent;

/**
 * A sample portlet
 */
public class CachablePortlet extends javax.portlet.GenericPortlet {
/**
* @see javax.portlet.Portlet#init()
*/
public void init() throws PortletException{
super.init();
}

/**
* Serve up the <code>view</code> mode.
* @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// Set the MIME type for the render response
response.setContentType(request.getResponseContentType());

CachableContent cc = new CachableContent();
                //will actually call the perform execute method
                cc.execute();
int randValue = cc.getRandomValue();
//Depending on the time you set this will be refreshed
response.getWriter().println("CachablePortlet#doView()"+randValue);
}

/**
* Serve up the <code>edit</code> mode.
* @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// TODO: auto-generated method stub
}

/**
* Serve up the <code>help</code> mode.
* @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// TODO: auto-generated method stub
}

/**
* Process an action request.
* @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
*/
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
// TODO: auto-generated method stub
}

}


Step 5 :-  Now create the cachespec.xml to specify the time and place it under web-inf like below



<?xml version="1.0" ?>
<!DOCTYPE cache SYSTEM "cachespec.dtd">
<cache>
  <cache-entry>
    <class> command</class>
       <sharing-policy>not-shared</sharing-policy>
       <name> com.ibm.cachableClass.CachableContent.class</name>
       <cache-id>
          <component type="method" id="getRandomValue">
             <required>true</required >
          </component>
          <priority>1</priority>
             <timeout>60</timeout >
          </cache-id>
   </cache-entry>
</cache>

               Mention the method you are calling and the time interval in which it should refresh. Now the random number will be regenerated for every 60 seconds.


Step 6 :- Deploy this in the portal server and observe the change of number for every 60 second. If you do a refresh of the page

Sunday, 1 June 2014

Dynaacache in websphere portal


Steps to implement dynacache :- 
                              Dynacache is a place to store data . We can store objects and use them when ever required for future use. WebSphere will be responsible for maintaining and managing these objects. We can change the configurations from was admin console.

Step 1 :-   Create or check existing cache instance in websphere portal . If it doesn't exist create one. Navigate to below location in was console




Step 2 :-  Now click on object cache instances and create a new one


Step 3 :- Click save and then check for newly created cache instance then restart the portal server




Step 4 :- Now create a portlet and write code to lookup for service object to access dynacache object

package com.ibm.dynacacheportlet;

import java.io.*;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.portlet.*;

import com.ibm.websphere.cache.DistributedMap;

/**
 * A sample portlet
 */
public class DynacachePortlet extends javax.portlet.GenericPortlet {
/**
* @see javax.portlet.Portlet#init()
*/
//Distributed map which consists of all stored objects
private DistributedMap appCache = null;
public void init() throws PortletException{
super.init();
InitialContext ctx;

        try {
            ctx = new InitialContext();
            appCache = (DistributedMap) ctx.lookup("tutorialCache");
        } catch (NamingException e) {
            // TODO need to change the exception handling...
            e.printStackTrace();
        }
}

/**
* Serve up the <code>view</code> mode.
*
* @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// Set the MIME type for the render response
System.out.println("enterring");
response.setContentType(request.getResponseContentType());
appCache.put("Name", "renault");
String mapValue = (String) appCache.get("Name");
System.out.println("String value :- "+ mapValue);
response.getWriter().println("DynacachePortlet#doView()"+ mapValue);
}

/**
* Serve up the <code>edit</code> mode.
*
* @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// TODO: auto-generated method stub
}

/**
* Serve up the <code>help</code> mode.
*
* @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// TODO: auto-generated method stub
}

/**
* Process an action request.
*
* @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
*/
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
// TODO: auto-generated method stub
}

}






Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...