Monday, 6 July 2015

WebSphere portal scripting interface

Portal Scripting Interface :-  Using this interface we can write scripts which can automate the process of configurations. Developers can create these scripts and provide it to deployment team , So that the dependency between two teams will be decreasing.

Two languages used for scripting :- We will have a look at Jython it will be easy to understand because its close to programming language
1) Jython (Object.method(arg1, arg2))
2) Jacl ($Object method arg1 arg2)

Jython :- Its a scripting language which is used on wsadmin tool to perform portal operations.Closely related to object oriented concepts and uses portal script beans to perform operations.

The available beans are:- 
Portal
Content
Layout
Portlet
Look
Access
PacList
Application
ArchivedApplication
ApplicationCategory
TemplateCategory
Publish

Sample script :-  UpdateLayout.py
# login to portal
Portal.login("wpsadmin","wpsadmin")
print " 1. login done."
# select page
Content.select(Content.find("all","uniquename","wp.test.page"))
print " 2. page selected"
# search portlet
portletA = Portlet.find("portlet", "name", "Struts Standard Stock Quote")
print " 3. portlet found: " + portletA
# create a vertical container
Layout.create("container", "vertical", "select")
print " 4. vertical container created."
# create a control with the portlet
Layout.create("control", portletA)
58
print " 5. create control with stock portlet."
# logout again
Portal.logout()
print " 6. logout."
print
print " Processing done."

where “#” denotes a comment, “print” prints a message to the command line

Sequence of the script is:-
Login
Locate the page
Create a container on the page to hold the portlet
Put the portlet into the container
Logout

Invoke the script to set the layout for the new test page:-
./wpscript.sh -user wpsadmin -password wpsadmin -lang jython -f
UpdateLayout.py

No comments:

Post a Comment

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