Friday, August 9, 2013

Getting content path IBM WCM API

DocumentIdIterator contentIterator = workspace.findByType(DocumentTypes.Content);
while(contentIterator.hasNext())
    {   
        contentId = contentIterator.nextId();
    System.out.println(workspace.getPathById(contentId, false, false));
    }

Tuesday, August 6, 2013

Running syndicator from IBM WCM API

try
{
 Context ic = null;
 System.out.println("----------------------JNDI Connection Syndicator---------------------");
 Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, "iiop://localhost:10035");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
ic = new InitialContext(env);
SyndicationService syndicationService = (SyndicationService) ic.lookup("portal:service/wcm/SyndicationService");

System.out.println("Context starting at: " + ic.getNameInNamespace());

Workspace workspace = WCM_API.getRepository().getWorkspace( );

Syndicator synd = syndicationService.getSyndicatorByName(workspace, "DEV2INT-TestSydContent");

 System.out.println("Syndicator Name :--"+synd.getName());

System.out.println("Syndicator Status :-"+synd.getStatus());

synd.setEnabled(true, workspace);
 synd.update();
SyndicationStatus syndStatus = synd.getStatus();
 while(syndStatus.isRunning()) {
 System.out.println("Updating");
}
synd.setEnabled(false, workspace);
 }catch(Exception e) {
 e.printStackTrace();
}

Sunday, August 4, 2013

Checking Cross Referencing of contents in IBM WCM Libraries

try

{

Repository repository = WCM_API.getRepository();

Workspace workspace = repository.getWorkspace(request.getUserPrincipal());
String libname="Test-library";

workspace.setCurrentDocumentLibrary(workspace.getDocumentLibrary(libNames));

DocumentIdIterator contentIterator = workspace.findByType(DocumentTypes.Content);

DocumentId contentId = null;

while(contentIterator.hasNext())

{

contentId = contentIterator.nextId();

ArrayList<String> arrayList = new ArrayList<String>();

Reference []ref =workspace.getReferencesFrom(contentId);

for(int i=0 ; i< ref.length ;i++)

{

String refLibName = ref[i].getRefererDocumentId().getContainingLibrary().getName();
System.out.println("--------------Referenced Library Name-------------"+refLibName);

}
}
}

Monday, July 9, 2012

org.omg.CORBA.NO_PERMISSION Exception


Whenever we are hitting ejb service from portal which is deployed on different WAS , and if we face the below stack trace:---

Exception = org.omg.CORBA.NO_PERMISSION
Source = com.ibm.ws.naming.jndicos.CNContextImpl.doLookup
probeid = 1489
Stack Dump = org.omg.CORBA.NO_PERMISSION:
>> SERVER (id=64e777ef, host=SVHJ0898.ideaconnect.com) TRACE START:
>>    org.omg.CORBA.NO_PERMISSION: Subject is null.  Authentication Failed.  vmcid: 0x49424000  minor code: 300  completed: No
>> at com.ibm.ISecurityLocalObjectBaseL13Impl.PrincipalAuthFailReason.map_auth_fail_to_minor_code(PrincipalAuthFailReason.java:88)
>> at com.ibm.ISecurityLocalObjectBaseL13Impl.CSIServerRIBase.authenticateSecurityTokens(CSIServerRIBase.java:2815)
>> at com.ibm.ISecurityLocalObjectBaseL13Impl.CSIServerRI.receive_request(CSIServerRI.java:622)
>> at com.ibm.rmi.pi.InterceptorManager.invokeInterceptor(InterceptorManager.java:631)
>> at com.ibm.rmi.pi.InterceptorManager.iterateServerInterceptors(InterceptorManager.java:535)
>> at com.ibm.rmi.pi.InterceptorManager.iterateReceiveRequest(InterceptorManager.java:777)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:616)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:480)
>> at com.ibm.rmi.iiop.ORB.process(ORB.java:512)
>> at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571)
>> at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2680)
>> at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2543)
>> at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
>> at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
>> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1560)
>> SERVER (id=64e777ef, host=SVHJ0898.ideaconnect.com) TRACE END.
  vmcid: 0x49424000  minor code: 300  completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)


1.Go To Security of the WAS.
2.Then go to global security on clicking Secure administration, applications, and infrastructure.
3. Go To Authentication mechanisms and expiration
Export the keys and import them to the Portal WAS.
Restart Portal server .


Thursday, June 14, 2012

calling ajax in jsr 286

I have created a sample portlet to show the suggestion by calling ajax:-









The sample jsp for calling the ajax as above is:


<%@page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1" session="false"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineObjects />
<script type="text/javascript">
  function createXMLHttpRequestObject() {
    var xmlHttp;
    try {
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
      } catch (e) {
      }
    }
    if (!xmlHttp)
      alert("Error creating the XMLHttpRequest object.");
    else
      return xmlHttp;
  }
  var xmlHttp = createXMLHttpRequestObject();
 
 
  function makeResourceCall(str){
 
 
  if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
 
    if (xmlHttp){
    var newvalue ="Harish"+str;
 
      try{
      var url ="<portlet:resourceURL></portlet:resourceURL>?txtValue="+str;
   
        xmlHttp.open("GET", url, true);
        xmlHttp.onreadystatechange = handleRequestStateChange;
       
        xmlHttp.send(null);
      }catch (e){
        alert("Can't connect to server:\n" + e.toString());
      }
    }
  }

  function handleRequestStateChange(){
    if (xmlHttp.readyState == 4){
      if (xmlHttp.status == 200){
     
      if(xmlHttp.responseText == "")
      {
      document.getElementById("txtHint").style.display="none";
      }
      else
      {
       document.getElementById("txtHint").style.display="block";
       document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
       }
      }
    }
  }
</script>

Enter Name<input type="text" name="txtValue" onkeyup="JavaScript:makeResourceCall(this.value)" >


 <!-- <p>Suggestions: <span id="txtHint"></span></p>  -->

<TEXTAREA name="annotationTxt" rows="10" cols="30" style="overflow:hidden;" id="txtHint" maxlength="235"></TEXTAREA>

<script>
function onload()
{
 document.getElementById("txtHint").style.display="none";
}
onload();
</script>


Onkeyup I am calling makeResourceCall and from makeResourceCall function calling <portlet:resourceURL>
From this the control will go the portlet class and will call the serverResource method:

 public void serveResource(ResourceRequest request, ResourceResponse response)
     throws PortletException, IOException {
     System.out.println("Entering ValidationCacheSamplePortlet.serveResource()");
     response.setContentType("text/html");
     System.out.println("String input value"+request.getParameter("txtValue"));
     inserRec rec = new inserRec();
     List list = rec.getData(request.getParameter("txtValue"));
    
    for (Iterator iterator = list.iterator(); iterator.hasNext();) 
    {
    HibernateprjPojo pojo = (HibernateprjPojo) iterator.next();
response.getWriter().println(pojo.getName());
In the serve resource method I am making a hibernate call and fetching the related values for txtValue.
From the getwritter the result will be shown in the drop down box.


Hidden portal page

To create a hidden portal page , first create a page and give it a proper unique name .
Export the portal page and save the xml.
Edit the xml and add the parameter


<parameter name="com.ibm.portal.Hidden" type="string" update="set"><![CDATA[true]]></parameter>
As shown below:-





<?xml version="1.0" encoding="UTF-8"?>
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" build="wp6101_115_01" type="update" version="6.1.0.1" xsi:noNamespaceSchemaLocation="PortalConfig_6.1.0.xsd">
    <portal action="locate">
      
       
        <content-node action="locate" domain="rel" objectid="6_20DO18N3Q4IL40ITIA32AM2085"/>
        <content-node action="update" active="true" allportletsallowed="true" content-parentref="6_20DO18N3Q4IL40ITIA32AM2085" create-type="explicit" domain="rel" objectid="6_20DO18N3QCKQ40ITNC79MH00O6" ordinal="200" type="page" uniquename="ibm.home.test">
            <supported-markup markup="html" update="set"/>
            <localedata locale="en">
                <title>test2</title>
            </localedata>
<parameter name="com.ibm.portal.Hidden" type="string" update="set"><![CDATA[true]]></parameter>
            <parameter name="com.ibm.portal.IgnoreAccessControlInCaches" type="string" update="set"><![CDATA[false]]></parameter>
            <parameter name="com.ibm.portal.bookmarkable" type="string" update="set"><![CDATA[Yes]]></parameter>
            <parameter name="com.ibm.portal.remote-cache-expiry" type="string" update="set"><![CDATA[0]]></parameter>
            <parameter name="com.ibm.portal.remote-cache-scope" type="string" update="set"><![CDATA[NON-SHARED]]></parameter>
            <access-control externalized="false" owner="uid=wpsadmin,o=defaultWIMFileBasedRealm" private="false"/>
            <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_20DO18N3QCKQ40ITNC79MH00O1" ordinal="100" orientation="H" skinref="undefined" type="container" width="undefined">
                <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_20DO18N3QCKQ40ITNC79MH00O5" ordinal="100" orientation="V" skinref="undefined" type="container" width="undefined"/>
                <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_20DO18N3QCKQ40ITNC79MH00O3" ordinal="200" orientation="V" skinref="undefined" type="container" width="undefined"/>
            </component>
        </content-node>
    </portal>
    <status element="all" result="ok"/>
</request>







Tuesday, June 12, 2012

Shared Libraries for portal project

For creating a shared library open the WAS console and create a shared variable:


















After giving the path of your shared library go to

ApplicationServer> WebSphere_Portal> and select java and process Management and select the class loader

and chhose the shared library reference.












and in the shared reference select your shared library reference:












Restart your server and deploy your war file , it will automatically take references of your jars .