Sunday, 25 December 2016

Find Non Repetitive Character in String using java

package it.com.shift.plugin.issue;

import java.util.HashMap;
import java.util.LinkedHashMap;

public class FindNonRepetitvieCharecter {

public static void main(String[] args) {
// TODO Auto-generated method stub
        String name ="krishknaraois";
        System.out.println(printFirstNonRepetingCharacterIterative(name));    
        System.out.println(printFirstNonRepetingCharacterUsingJava(name));
        System.out.println(printFirstNonRepetingCharacterUsingJavaSinglePass(name));
}

private static char printFirstNonRepetingCharacterUsingJavaSinglePass(String name) {
for(char value : name.toCharArray()){
if(name.indexOf(value)==name.lastIndexOf(value)){
return value;
}
     }
return ' ';
}

//Minimum complexity n and maximum complexity n^2
private static char printFirstNonRepetingCharacterUsingJava(String name) {
HashMap<Character,Integer> characters = new LinkedHashMap<Character,Integer>();
for (char literal : name.toCharArray()) {
characters.put(literal, characters.containsKey(literal)?characters.get(literal)+1:1);
}
   for (Character value : characters.keySet()) {
if(characters.get(value)==1){
return value;
}
}
return ' ';
}

//Minimum complexity n and maximum complexity n^2
private static char printFirstNonRepetingCharacterIterative(String name) {
// TODO Auto-generated method stub
for(int i=0;i<name.length();i++){
        for(int j=i+1;j<name.length();j++){
        if(name.charAt(i)== name.charAt(j)){
        break;
        }else if(j+1==name.length()){
        return name.charAt(i);
        }
        }
       }
return ' ';
}

}

Thursday, 22 December 2016

Jquery color box to display help information

<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/dot-luv/jquery-ui.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$("#helpButton").click(function(){
//Initiate color box
 $('#help').colorbox({
    inline : true,
    overlayClose : false,
    maxWidth : '520px',
    maxHeight : '400px',
    width : '95%',
    height : '95%',
    open:true,
    href: "#help"
   });
  });
  });
</script>
</head>
<body>
<a href="#" id="helpButton" class="fa fa-info-circle" >Color Box demo</a>
 
  <div style="display: none;">
       <div id="help">
        <p>
   <span style="font-size: 20px; float: left;">Help</span>
  </p>
    </div>
</div>

</body>
</html>

Output :- 



Dynamic html rendering using handler bars

<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>

//Declare the template here 
<script id="movieTemplate" type="text/x-handlebars-template">
<table style="width:100%">
  <tr>
    <th>ReleaseYear</th>
    <th>Director</th>
  </tr>
  {{#each this.movies}}
  <tr>
    <td>{{ReleaseYear}}</td>
    <td>{{Director}}</td>
  </tr>
  {{/each}}
</table>
</script>

<body>
 //Final data will be rendered here
<div id="results"></div>
</body>
<script type="text/javascript">
var data = {}
var movies = [
{ ReleaseYear: "1998", Director: "Francois Girard" },
{ ReleaseYear: "1999", Director: "Stanley Kubrick" },
{ ReleaseYear: "1976", Director: "Mauro Bolognini" }
];
data.movies=movies;
 // Grab the template script
var html = $( "#movieTemplate" ).html();

// Compile the template
var theTemplate = Handlebars.compile(html);

// Pass our data to the template
var theCompiledHtml = theTemplate(data);

//Assign to html div
$('#results').html(theCompiledHtml);
</script>
</html>

Wednesday, 14 December 2016

Java8 new features :- Consumer interface and start of lambda expression

Consumer  interface :- Below you can observe different ways of implementing interface and how consumer interface is used to implement lambda expressions.

interface A {

public void show();
}

class B implements A {

@Override
public void show() {
System.out.println("Typical way of show");
}

}

public class LambdaDemo {

public static void main(String[] args) {
//Approach1 of implementing interface
B b = new B();
b.show();

//Approach2 of implementing interface
new A() {
public void show() {
System.out.println("smart way of show :-"+(1*0.1==0.1));
}
}.show();

//Approach3 of implementing using consumer interface
A obj;
obj = () -> {
System.out.println("show lambda");
};
obj.show();

A obj1;
obj1 = () -> System.out.println("show lambda without braces");
obj1.show();

}

}

Jquery template to dynamicly render html

Jquery Template :- Is utilized to construct html dynamically by passing json

<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
//Declare the template here 
<script id="movieTemplate" type="text/x-jquery-tmpl">
<table style="width:100%">
  <tr>
    <th>ReleaseYear</th>
    <th>Director</th>
  </tr>
  {{each data.movie}}
  <tr>
    <td>${ReleaseYear}</td>
    <td>${Director}</td>
  </tr>
  {{/each}}
</table>
</script>

<body>
 //Final data will be rendered here
<div id="results"></div>
</body>
<script type="text/javascript">
var data = {}
var movies = [
{ ReleaseYear: "1998", Director: "Francois Girard" },
{ ReleaseYear: "1999", Director: "Stanley Kubrick" },
{ ReleaseYear: "1976", Director: "Mauro Bolognini" }
];
data.movie=movies;
//Invocation of template
var html = $( "#movieTemplate" ).tmpl( data ).html();
$('#results').html(html);
</script>
</html>

Sunday, 30 October 2016

Algorithms :- Find maximum in array with the two approaches present in algorithms

      Algorithms has two types of approaches either iterative or recursive. Have a look at below example where we will solve problem in both the approaches.


package com.algorithms.iterative;

public class FindMaxInArray {

public static void main(String[] args) {
          int a[] = {2,42,1 };
          //Iterative approach
          long time = System.currentTimeMillis();
          int max=a[0];
          for(int i=1;i<a.length;i++){
         if(max<a[i]){
         max=a[i];
         }
          }
          System.out.println((System.currentTimeMillis()- time));
          System.out.println("Max value :- "+ max);
         //Recursive approach
          System.out.println("Max value using recursive :- "+ maxArray(a,a.length,1,a[0]));
         
         
}

public static int  maxArray(int[] a,int length,int currentCount,int max){
        if(currentCount>=length){
        return max;
        }  
if(max<a[currentCount]){
        return  maxArray(a,length,currentCount+1,a[currentCount]);
        }else{
        return  maxArray(a,length,currentCount+1,max);
        }
}

}

Tuesday, 4 October 2016

Ext JS button with sub menu

<!DOCTYPE html>
<html>
<head>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
   <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
   <script type="text/javascript">
      Ext.onReady(function() {
          Ext.create({
            xtype:'button',
            text:'OK',
            menu:[{
                 text:'Item 1'
            },{
            text:'Item 2',
             menu :[
               {text:'Sub Item1'},
               {text:'Sub Item2'}
            ]
               }],
            renderTo: Ext.getBody()
          });
      });
   </script>
</head>
<body>
</body>
</html>

Ext Js sample form login page to get started

<!DOCTYPE html>
<html>
<head>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
   <style>
  html, body {
  border: 0;
  padding: 0;
  margin: 0;
  height: 100%;
}

body {
  background: tomato;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
}

form {
  background: white;
  width: 47%;
  box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.7);
  font-family: lato;
  position: relative;
  color: #333;
  border-radius: 10px;
}
form header {
  background: #FF3838;
  padding: 30px 20px;
  color: white;
  font-size: 1.2em;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
}
form label {
  margin-left: 20px;
  display: inline-block;
  margin-top: 30px;
  margin-bottom: 5px;
  position: relative;
}
form label span {
  color: #FF3838;
  font-size: 1.5em;
}
form input {
  display: block;
  width: 78%;
  margin-left: 20px;
  padding: 5px 20px;
  font-size: 1em;
  border-radius: 3px;
  outline: none;
  border: 1px solid #ccc;
}
form .help {
  margin-left: 20px;
  font-size: 0.8em;
  color: #777;
}
form button {
  position: relative;
  margin-top: 30px;
  margin-bottom: 30px;
  left: 50%;
  transform: translate(-50%, 0);
  font-family: inherit;
  color: white;
  background: #FF3838;
  outline: none;
  border: none;
  padding: 5px 15px;
  font-size: 1.3em;
  font-weight: 400;
  border-radius: 3px;
  box-shadow: 0px 0px 10px rgba(51, 51, 51, 0.4);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
form button:hover {
  background: #ff5252;
}

#newForm-innerCt{
  padding-top : 45px;
  padding-left : 161px;
}

#button-1011-btnInnerEl{
  background: #ff5252;
  width:67px;
  height:25px;
  font-size:1.5em;
}

.x-btn.x-unselectable.x-btn-default-small{
   margin-left:76px;
   margin-top:15px;
}
   </style>
   <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
   <script type="text/javascript">
      Ext.onReady(function() {
         Ext.create('Ext.form.Panel', {
            id: 'newForm',
            renderTo: 'formId',
            border: true,
            width: 600,
height: 200,
            items: [{
               xtype: 'textfield',
               fieldLabel: 'User Name'
            },{
               xtype: 'textfield',
               fieldLabel: 'Password'
            },{
               xtype: 'button',
               text: 'Login',
  color : '#ff5252',
  background : '#ff5252'
            }]
         });
      });
   </script>
</head>
<body>
<form>
   <header>Login</header>
   <div id = "formId"></div>
 </form>
</body>
</html>

Saturday, 10 September 2016

First apache camel application

Apache Camel :- Is built on top of enterprise integration patterns which does all type heavy lifting working and focusing developers on code logic.It is mainly involved in integration of different services.Like moving a file from location to another by transforming/enriching content of file.

Pre-requisite :- Down load camel jars and have them in build path.

Step1 :- Create a plain java project

Main application :- Where we create camel context and add routes

package com.java.firstCamel;

import org.apache.camel.*;
import org.apache.camel.impl.DefaultCamelContext;

public class MainApp {

public static void main(String args[]) {
RouterBuilder routerBuilder = new RouterBuilder();
CamelContext camelContext = new DefaultCamelContext();
try {
camelContext.addRoutes(routerBuilder);
camelContext.start();
Thread.sleep(5 * 60 * 1000);
camelContext.stop();
} catch (Exception e) {
e.printStackTrace();
}
}

}

Route Builder :- Core logic for route builder to move file form one place to another.

package com.java.firstCamel;

import org.apache.camel.builder.RouteBuilder;

public class RouterBuilder extends RouteBuilder {

@Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("file:/C:/Location1/krishna").process(new LogProcessor()).bean(new Transformer(), "transfromMessage")
.to("file:/C:/Location12");

}

}

Transformer :- Core logic for transforming or modifying in coming data.

package com.java.firstCamel;

public class Transformer {

public String transfromMessage(String message) {
System.out.println("Tranformation executed");
return message.toUpperCase();
}
}

LogProcessor :- To log and verify the result is proper or not

package com.java.firstCamel;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class LogProcessor implements Processor {

@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
System.out.println("Executing log processor :- " + exchange.getIn().getBody(String.class));

}

}


Thursday, 8 September 2016

JMS with active MQ without context loookup

Active MQ :- Is a middle-ware framework where messages are handled in reliable manner without any loss of information. Mainly utilized for distributed environment where information from one JVM need to be passed to another JVM. It has two types of mechanism point to point and publish subscribe mechanism.

Step 1) Download latest active mq.
http://activemq.apache.org/activemq-550-release.html

Step 2) Set JAVA_HOME variable till JDK or JRE.

Step 3) Navigate till bin folder 'C:\apache-activemq-5.5.0-bin\apache-activemq-5.5.0\bin' and start it
using 'activemq'command for previous versions. In newer versions use 'activemq start'.

Step 4) http://121.0.0.1:8161/admin to access the admin console.

Step 5) Now create a dynamic web application and create sender and receiver classes to produce and consume message.

Sender :-  Run sender it will use default broker url and creates a queue with name ''PRACTICEQUEUE" and sends a message.




Receiver :- It receives message from default broker URL("failover://tcp://localhost:61616") and prints out to console. 


  

Tuesday, 6 September 2016

Basic linux commands

Linux :- Its est open source operating system available in outside world. I has many file systems like ext4 etc unlikely to windows(FAT32/NTFS)

. -> Represents current directory in Linux
.. -> Represents parent directory


killall - Will force fully kill the application with no traces left. 'An instance of firefox is already open' is a real time example to use the command(Usage- killall thunar)- In this command i am closing file manager.

ls - Will list all files in current directory(Usage- ls) in addition to it 'ls -r' lists all sub directories also.'ls -all' displays the permissions also. 'ls -a' to see all hidden files.

touch - will create files (Usage - touch file1.txt file2.txt) - creates two files. If you want to create one file then you can use graphical console else you need to created many files then 'touch' is the best command.When you touch files it will change the timestamp of files which is very helpful for backup files.

which - this command is used to find where does the current installed application is.(Usage- which google-chrome)

ping- To check whether a particular site is reachable from your system(Usage - ping www.google.com -c 3)

cat - It opens up text files to view the information in it(Usage - cat /etc/fstbs). If the file is very big file this command might not be appropriate. Advanced usage  - cat /etc/fstbs | more.'cat > test.text' will provide a provision to add more or edit the file. 'cat file1 file2 > file3' to form a new file 'file3'.

less - More advanced command compared to above where there are many privileges for page navigation.(Usage - less /etc/fstbs)

blkid - Lists all drives (Usage - sudo blkid)

su - simulate the login as other user (Usage - su krishna)- will log me into krishna machine. By typing exit you can logout.This provides an alternative way of 'switching users' via GUI.

reboot - It wil restart the system (Usage - su reboot)

shutdown - Will shutdown the system (Usage - su shutdown -h 15)- It will shutdown the machine after 15 mins, 'su shutdown -c' will ignore the previous command if you change your mind regarding shutdown.

cd - change directory.

date - displays current date (Usage - date)

cal - current month calendar(Usage - cal 2015) - displays full 2015 calendar

uptime - will display how many user ave logged in currently (Usage - uptime)

w - provides who all have been logged in (Usage - w)

whoami - displays which user is currently logged into the terminal (Usage - whoami)

uname -a - displays kernel information (Usage - uname -a)

mkdir - to create directory (Usage - mkdir vfx)

pwd - displays what is your current directory. So that you can navigate to required directory.

ifconfig - Displays current ip information

mv - to move the file to a different directory (Usage - mv filename directoryName). This can be used for rename also (Usage - mv oldfFileName newFIleName)

cp - copy file to a different directory (Usage - cp filename directoryName)

rm - Is used to remove directory

rm -r - This command is used to remove directory (Usage - rm -r directoryName)

man - manual which provides help to construct the command (Usage - man mv)

top - Display the processes similar to task manager. (Usage - top)

history - Displays all previously entered commands (Usage - history)













Friday, 19 August 2016

Quick sort


Iterative approach:-

public class QuickSort {

public static void main(String args[]){
int numbers[] = {-1,10,8,4,12};
int number = numbers.length;

}

private static void sort(int[] numbers,int number){
int low =0;
int i =0;
int high = number-1;
while(low<high){
int pivot = numbers[low + (high-low)/2];
 while(numbers[low]<pivot){
 low++;
 }
 while(numbers[low]>pivot){
 high--;
 }
 if(low<=high){
 exchange(low,high,numbers);
 low++;
 high--;
 }
}
if(i<high){

}


}
private static void exchange(int low, int high,int[] numbers) {
// TODO Auto-generated method stub
int temp = numbers[low];
numbers[low] = numbers[high];
numbers[high] = numbers[temp];
}
}

Recursive approach :- 

public class QuickSort {

public static void main(String[] args) {
int[] xyz = { 5, 2, 4, 8, 1, 5, 3 };
if (xyz != null && xyz.length > 0) {
quickSort(xyz, 0, xyz.length - 1);
} else {
System.out.println("Empty array");
}
printArray(xyz);
}

private static void printArray(int[] xyz) {
for (int i = 0; i < xyz.length; i++) {
System.out.println(xyz[i]);
}
}

private static void quickSort(int[] xyz, int low, int high) {
if (low < high) {
int pi = calculatePartion(xyz, low, high);
quickSort(xyz, low, pi - 1);
quickSort(xyz, pi + 1, high);
}
}

private static int calculatePartion(int[] xyz, int low, int high) {
int pivot = xyz[high];
int i = low;
for (int j = low; j < high; j++) {
if (xyz[j] <= pivot) {
swap(xyz, j, i);
i = i + 1;
}
}
swap(xyz, i, high);
return i;
}

private static void swap(int[] xyz, int i, int placeHodler) {
int temp = xyz[placeHodler];
xyz[placeHodler] = xyz[i];
xyz[i] = temp;
}


}

Member fixer


Steps to enable member fixer :-

Step 1: Set up the below properties in the WAS Admin Console  under Resource environment providers > WCM WCMConfigService > Custom properties: If already present check for the correct values
· connect.businesslogic.module.memberfixer.autoload : false
· connect.businesslogic.module.memberfixer.class: com.aptrix.pluto.security.MemberFixerModule
· connect.businesslogic.module.memberfixer.remoteaccess: true

Step 2: Make property user.cache.enable  : false  in the WAS Admin console under the same path as mentioned in Step 1

Step 3: Stop the DealerPathMDB application through WAS Admin console

Step 4: Disabled the syndication if any running or enabled on the environment.

Step 5: Ask WPS team to run the cleanup user task. Details are present in the attached email. Check for the output and it should have any specific group which we are setting up on library.

Step 6: Bounce the server.

Step 7: Set the log level to info in the Administration tab in Enable tracing section

Step 8: Run the Member Fixer Command on the browser: Details can be found under the SharePoint link
   
     
Step 9: Check logs to see  the details on the command run.

Post member fixer tasks :-

Step 1 :- Start DealerPathMDB application through WAS Admin console

Step 2 :- Verify security groups at library level if they are missing please add then manually



ML specific links for content

ML Notification: Subject [Multi-locale Item Created Notification - fr]
An item has been created/modified by the author in the _en library. As per the Multi-locale processing settings, a link to this item has been added to the _fr library.

The path of the item is <a href="http://localhost:10039/wps/myportal/VirtualPath/Applications/Content/Authoring/?wcmAuthoringAction=read&docid=com.ibm.workplace.wcm.api.WCM_ContentLink/efd0f7da-3fc1-4762-bb9a-7402d74c246c/f962ddf7-17aa-4b75-ac11-2ca22a0043ce/DRAFT">library_content_fr/SA-My_DealerPath/A1339.2.1/SA-Human_Resources/efd0f7da-3fc1-4762-bb9a-7402d74c246c</a>.
[8/19/15 19:52:38:490 IST] 000001b7 MLNotificatio I   ML Notification: Subject [Multi-locale Item Created Notification - de]
An item has been created/modified by the author in the _en library. As per the Multi-locale processing settings, a link to this item has been added to the _de library.

The path of the item is <a href="http://localhost:10039/wps/myportal/VirtualPath/Applications/Content/Authoring/?wcmAuthoringAction=read&docid=com.ibm.workplace.wcm.api.WCM_ContentLink/efd0f7da-3fc1-4762-bb9a-7402d74c246c/1e92f778-c25f-4864-b5c9-12bee876a16a/DRAFT">library_content_de/SA-My_DealerPath/A1339.2.1/SA-Human_Resources/efd0f7da-3fc1-4762-bb9a-7402d74c246c</a>.
[8/19/15 19:52:40:278 IST] 000001b7 MLNotificatio I   ML Notification: Subject [Multi-locale Item Created Notification - ru]
An item has been created/modified by the author in the j_en library. As per the Multi-locale processing settings, a link to this item has been added to the _ru library.

The path of the item is <a href="http://localhost:10039/wps/myportal/VirtualPath/Applications/Content/Authoring/?wcmAuthoringAction=read&docid=com.ibm.workplace.wcm.api.WCM_ContentLink/efd0f7da-3fc1-4762-bb9a-7402d74c246c/622f7493-2638-4ea7-9b00-d2c42f3c9c83/DRAFT">library_content_ru/SA-My_DealerPath/A1339.2.1/SA-Human_Resources/efd0f7da-3fc1-4762-bb9a-7402d74c246c</a>

Portal WCM tech links

Process for Cur :- Create an adapter which connects to your required database and then get the xml in was understandable format.

Wcm Advanced cache :- 
https://www.ibm.com/developerworks/community/blogs/portalops/entry/customizing_the_wcm_advanced_cache_key17?lang=en

WCM best practicses :-
http://www-10.lotus.com/ldd/portalwiki.nsf/dx/07162008083719PMWEB2RD.htm

Category Picker :- 
http://www-01.ibm.com/support/knowledgecenter/SS3JLV_8.0.0/wcm/wcm_dev_elements_taxonomy_selectiontrees.dita

Preview :-
https://www.ibm.com/developerworks/community/blogs/portalops/entry/best_practice_for_wcm_preview_server_topology4?lang=en

Portal support doc views :-
http://www-01.ibm.com/support/docview.wss?uid=swg21260098
http://www-01.ibm.com/support/docview.wss?uid=swg21417365
http://www-01.ibm.com/support/docview.wss?uid=swg21377025
Remove invalid ldap users :- 
http://www-01.ibm.com/support/docview.wss?uid=swg21377025
Soft Groups :- 
http://www-01.ibm.com/support/docview.wss?uid=swg27036224
Resolving mixed case issue :-
http://www-01.ibm.com/support/docview.wss?uid=swg21614035
Cleanup of users :-

PZN Best Practices :-
http://www-10.lotus.com/ldd/portalwiki.nsf/dx/personalization-best-practices

Tuning Guide link :-
http://www-10.lotus.com/ldd/portalwiki.nsf/dx/IBM_WebSphere_Portal_V_8.0
_Performance_Tuning_Guide

Viewing Cache settings :- 
http://hostname:port/wps/wcm/connect?MOD=ExportCacheSettings&processLibr
aries=false 

run-wcm-admin-task-export-cache-settings ConfigEngine task as described 
in the product documentation here. And send me the SystemOut.log file.

Prinicipal informaion cache :-
http://www-01.ibm.com/support/docview.wss?uid=swg24014207

WCM Support tool :-
http://it.delhigovt.nic.in/writereaddata/Odr20146113.pdf

Search custom seedlist:-
https://www-10.lotus.com/ldd/portalwiki.nsf/dx/Extend_WebSphere_Portal_WCM_Seedlist_with_Custom_Metadata

JMS in portal :-
http://www-01.ibm.com/support/docview.wss?uid=swg27036467&aid=1

Usage of Eval function in Javascript

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
//You can append this div via ajax
<div id="check">
var x= {
radioButtonNeeded:'True',
dealerId:'230208',
machineDescValue:'D110 Lawn Tractor',
docRefNumb:'',
pinNum:'1GX0110DHFJ289384',
machineCodeValue:'0816GX',
settlementNumb:'',
settlmentDT:'21-Mar-2016',
orderEntryDT:'04-Dec-2015',
showDialogueName:'confirmSettlmentManually'
}
</div>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

<script>
//Will make sure javascript variable is available after this method call
eval($('#check')[0].innerHTML);

</script>

</body>
</html>

Tuesday, 5 July 2016

Copy content from one location to another location via WCM API

Agenda :- How to copy the content from location to other location via custom workflow using WCM API.


Step1 :- Create a custom workflow action where you have to move contents from one location to another location

Document document1 = ws.copy(document.getId(), docid);

Parameter1 :- 'document.getId()' this is the document which need to be copied to some other location.
Parameter2 :- docid this is document id of sitearea when the document need to be copied. You can utilize workspace methods like getByName or findByPath to retrieve the site area documentId.


ws - workspace object


Step2 :- You can verify the newly created content by printing the title of new content(document1.getTitle()).


Note :- There is one more optional overloaded parameter CopyOptions using which properties of copied contents can be modified for example changing author of the copied content.

Understanding JMS in websphere application server and integrate with WCM

JMS :- In a laymen terms we can send messages asking it to store. Later concern person will consume it. By which we can create a intermediate layer where messages can be stored asynchronously and consumed later for further use.

WCM :- Messages or events that can be captured from WCM. We will apply above JMS concepts to catch below events

Item events:
Item created
Item updated
Item moved
Item deleted

Syndication events:
Starting
Stopping

Pre-render events:
Starting
Stopping

Command to enable it :-
./ConfigEngine.sh create-wcm-jms-resources -DPortalAdminId=username -DPortalAdminPwd=password -DuseRemoteEndPoints=true/false


Suggested links :-
http://www-01.ibm.com/support/docview.wss?uid=swg27036467&aid=1

Rendering plugin adding parameters to plugin WCM

Rendering Plugin :- By implementing RenderingPlugin new plugin can be created in WCM. But to include parameters into the plugin implementing RenderingPlugin alone is not sufficient. Need to
implement RenderingPluginDefinition also which internally implements RenderingPlugin.


New methods need to be implemented:-
@Override
public List<RenderingPluginParameter> getParameters() {
ArrayList arrayList = new ArrayList();
    //add all parameters required in the list
arrayList .add(new EmbededURLFormatterPlugin.URLRenderingPluginParameter("parameterName").required(Required.REQUIRED));
return arrayList ;
}


New class that need to be created :- For sever versions lower than 8.5
public class RenderingPluginTypes
implements RenderingPluginType
{
public static final RenderingPluginTypes URL_RENDERING_PLUGIN_TYPE = new RenderingPluginTypes();

public String getDescription(Locale paramLocale)
{
  return "URL_PLUGIN_TYPE_DESCRIPTION";
}

public ListModel<Locale> getLocales()
{
  return null;
}

public String getTitle(Locale paramLocale)
{
  return "URL_PLUGIN_TYPE_TITLE";
}

public String getName()
{
  return "URL";
}
}


Final output:- Try opening any editor in wcm then insert the plugin which provides below output depending on your plugin name.

[Plugin:pluginName parameterName=""] [/Plugin:pluginName]

Sunday, 27 March 2016

Library displays as locked in administration tab of portal

Unlocking a library:-
A library can become locked when a long running task, such as restoring all content items in a library, fails to unlock the library. In the rare event where a library becomes locked, you can use the unlock library tool to unlock the library.

Set below properties in WCM WCMConfigService WebSphereApplication Server administration console:
connect.businesslogic.module.unlocklibrary.class=com.aptrix.pluto.security.UnlockLibraryModule
connect.businesslogic.module.unlocklibrary.remoteaccess=true
connect.businesslogic.module.unlocklibrary.autoload=false

Procedure to unlock:-
Log in to the portal as an administrator.
To unlock a library, enter the following URL in the browser:
http://hostname.yourco.com:port_number/wps/wcm/connect?MOD=UnlockLibrary&library=libraryname

Tuesday, 22 March 2016

Modifying people picker portlet to pick user-id also as part of search


Modified value:- 
pickerPeopleSearchAttribute  = cn,displayName,sn,uid

Default value: cn,displayName,sn,givenName  

Procedure
1.     Log on to the WebSphere® Integrated Solutions Console.

2.     Click Resources > Resource Environment > Resource Environment Providers.

3.     Find and click the WP PeopleService resource environment provider. The resource environment provider name is case-sensitive.

4.     Click custom properties.

5.     Click the custom properties page and configure the values for following property:

6.     pickerPeopleSearchAttribute  = cn,displayName,sn,uid

7.     Restart IBM® WebSphere Portal server to reflect the changes.

Friday, 12 February 2016

Exporting cache information in Portal

When you run the export cache settings task, a summary of your cache settings is generated and set to the SystemOut.log. 
This includes the type of cache being used, and how it is being applied. For example, basic caching per session, or data caching per site.

Running the export cache settings task :-
Windows
ConfigEngine.bat run-wcm-admin-task-export-cache-settings -DWasPassword=password -DPortalAdminId=username -DPortalAdminPwd=password -Dlibrary=MyLibrary -DinheritPerms=apply -DlibSecurity=true

You can also display your cache settings in a browser using the following URL:-
http://hostname:port/wps/wcm/connect?MOD=ExportCacheSettings&processLibraries=false

Saturday, 30 January 2016

JSONP approach

$.ajax({

url: 'url',
jsonpCallback: "JSON_CALLBACK",
dataType: 'jsonp',
contentType: 'text/plain',
success: function(json) {
console.log(json);
 alert("Success"); },
error: function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);

alert('Failed!'); },
});

Context :- When JSONP is used for cross domain calls we need to send a parameter '&callback=JSON_CALLBACK ' in this case can we need to alter the output from server to return result wrapped with JSON_CALL

Friday, 29 January 2016

Personalization properties updating cache information

Navigate to below location and pick this  PersonalizationService.properties file from below location.
wp_profile\PortalServer\config\config\services

rulesEngine.cache.timeout=300  :- Update the amount of seconds it should be cached

Monday, 18 January 2016

Websphere portal debug puma issues

Puma trace string :-   To debug any puma related issues please add below trace string in portal administration .


com.ibm.wps.puma.*=all:com.ibm.wps.services.puma.*=all:com.ibm.wps.command.puma.*=all:com.ibm.wps.um.*=all:com.ibm.ws.wim.*=all:com.ibm.websphere.wim.*=all:com.ibm.wsspi.wim.*=all:com.ibm.ws.security.*=all:com.ibm.wps.engine.Servlet=all:

Tuesday, 12 January 2016

Propagation and inheritence differences and clarification websphere portal wcm

Creating a role block - 

  1. On the initial Resource Permissions screen, click the appropriate resource type.
  2. If necessary, search for the appropriate resource instance.
  3. Click the appropriate Assign Access icon.
  4. To create a propagation block, remove the check mark from the appropriate Allow Propagation checkbox. Children of the resource will no longer inherit any assignments for this role type.
  5. To create an inheritance block, remove the check mark from the appropriate Allow Inheritance checkbox. This resource will no longer inherit any assignments for this role type from the parent resource.
  6. Click OK.


Removing a role block-

  1. On the initial Resource Permissions screen, click the appropriate resource type.
  2. If necessary, search for the appropriate resource instance.
  3. Click the appropriate Assign Access icon.
  4. To remove a propagation block, click the appropriate Allow Propagation checkbox so that a check mark appears. Children of the resource will now inherit all assignments for this role type.
  5. To remove an inheritance block, click the appropriate Allow Inheritance checkbox so that a check mark appears. The resource will now inherit all assignments for this role type from the parent resource.
  6. Click OK.

Monday, 11 January 2016

Collecting version info in WebSphere portal IBM

Version info :- Latest version of portal and fix packs applied for product can be found in this log file. To generate this log run below command and pick it from the mentioned location.


Command :- \IBM\WebSphere\PortalServer\bin WPVersionInfo.bat

Location :-  \IBM\WebSphere\wp_profile\PortalServer\log

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...