Wednesday, February 8, 2017

Reading EXIF meta data from image files

Extract Exif (Exchangeable image file format) from Images:
http://stackoverflow.com/questions/22352977/how-to-detect-if-image-from-photo-library-was-taken-by-iphone-camera-or-imported
http://chariotsolutions.com/blog/post/take-and-manipulate-photo-with-web-page/
https://github.com/exif-js/exif-js

Tuesday, July 19, 2016

Add the portlet session bean to the Personalization engine

Add the portlet session bean to the Personalization engine
Register the session bean with the Personalization engine. To enable the Personalization engine to leverage data in session bean:
  1. Export the session bean class as a jar file with full class path.
  2. Copy it to <wp>/pzn/v6.0/collections directory on the WebSphere Portal machine.
  3. Restart WebSphere Portal server to load the jar file.
To register the session bean with Personalization:
  1. Create an application object in Personalization.
  2. Session key and class name are required fields for the creation of the application object
  3. Specify the fully qualified class name
Note: Visibility rule uses caching per session so if the visibility rule is meant to use dynamic data, the results will not change based on the dynamic data. To implement visibility rule on dynamic data you need to disable caching.

Same thing can be done using object cache, we can update values in object cache from application and the stored values can be read from the custom pzn SelfInitializationApplicationObject implementation class.

Different technique can be also used to hide the portlet i.e. portlet eventing.

Hide portlet through external class (SelfInitializationApplicationObject): http://wpcertification.blogspot.com/2011/01/how-to-show-or-hide-portal-or-portlet.html

Issue discussed on setting Personalization Attributes from Portlets:
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014177630

Friday, June 17, 2016

Portal v7.0 not starting - Previous initialization was not successful

The problem is that now all of a sudden, the wps application starts before the wps_scheduler application, and that is what is causing the problem. To fix it, check the following:

1. Start the WebSphere_Portal server if it is not already started.
2. Try and access the WAS admin console:

http://<portal hostname>:10042/ibm/console

3. Navigate to Applications -> WebSphere Enterprise Applications
4. Pick the 'wps' application and go to 'Startup Behavior'. Check the
Startup Order. The default value is 10. If you have to change this,
do so now.
5. Go back to 'wps' and click Manage Modules.
6. Click 'WebSphere Portal Server'. It's starting weight should be
10000. If you have to change this, do so now.
7. Back in Manage Modules, click 'WebSphere Portal Server WSRP
Facade'. It's starting weight should be 10000. If you have to change
this, do so now.
8. Back in Manage Modules, click 'WebSphere Portal XmlAccess Facade'.
It's starting weight should also be 10000. Again if you have to change
this, do so now.
9. Now back to the list of applications, pick 'wps_scheduler' and go
to 'Startup Behavior'. It's startup order should also be 10. If you
have to change this, do so now.
10. From wps_scheduler, go to Manage Modules.
11. Click 'WPS Task Scheduler'. It's starting weight should be 5000.
If you have to change this, do so now.
12. Save all changes and restart Portal.

Also verify if <portalserver_dir>\wps.propeties file exists and it has required permission. If required rename that to a different file and created a new wps.properties and copied the contents of it and restarted.

If nothing works then try to backup and redeploy wps.ear: http://www-10.lotus.com/ldd/portalwiki.nsf/xpDocViewer.xsp?lookupName=IBM+WebSphere+Portal+8+Product+Documentation#action=openDocument&res_title=Redeploying_the_portal_EAR_file_wp8&content=pdcontent&sa=true

Font Loading issue when installing font in browser is disable

http://ajax.googleapis.com/ajax/libs/webfont/1.5.3/webfont.js
https://github.com/typekit/webfontloader/issues/160
http://www.techrepublic.com/blog/web-designer/how-to-use-the-google-webfont-loader/
http://stackoverflow.com/questions/7973421/detect-if-font-download-in-ie-is-enabledd

Create a url to change language on Portal

You can use following code to change the language on Portal.
<portal-navigation:url command="ChangeLanguage">
  <portal-navigation:urlParam name="locale" value="<language>"/>
</portal-navigation:url>
 
There was a problem with this when navigational state is cleared. 
This happens if  bookmarks to friendly URLs are used for navigation or 
the navigational state is cleared intentionally.
 
You can this technique to store language value in cookie temporarily and 
It sets the locale information, if no locale information can be 
found in the navigational state.
 
Configure cookie support language using this 
url: http://www-01.ibm.com/support/docview.wss?uid=swg1PM17679
 

Content decompress (Base64 + Zlib)

I wanted to decompress data getting send to GSA (google search appliance) to verify the actual content. Google Search Appliance uses Base64 encode and Zlib compress technique which improves performance, because less data is sent across the network.

Here is link on GSA Content Compression: https://www.google.com/support/enterprise/static/gsa/docs/admin/72/gsa_doc_set/feedsguide/feedsguide.html#1074587

There is api provides by Java that can be used to  compress and decompress data using the java.util.zip package. - http://www.oracle.com/technetwork/articles/java/compress-1565076.html

To decode base64 string you can use class org.apache.commons.codec.binary.Base64 provided by apache commons library.

code snippet that follows:  
String string = "SmF2YWNvZGVnZWVrcw==";
// Get bytes from string
byte[] byteArray = Base64.decodeBase64(string.getBytes());
// Print the decoded array
System.out.println(Arrays.toString(byteArray));


To decompress zlib content you can use Java Byte Array Using Inflater
code snippet that follows: 
public static byte[] decompress(byte[] data) throws IOException, DataFormatException {
    Inflater inflater = new Inflater();  
    inflater.setInput(data); 
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); 
    byte[] buffer = new byte[1024]; 
    while (!inflater.finished()) { 
        int count = inflater.inflate(buffer); 
        outputStream.write(buffer, 0, count); 
    } 
    outputStream.close(); 
    byte[] output = outputStream.toByteArray(); 
    LOG.debug("Original: " + data.length); 
    LOG.debug("Compressed: " + output.length); 
    return output; 
}  

Here is the reference link: https://dzone.com/articles/how-compress-and-uncompress


Download complete source code: https://app.box.com/s/w2wyffurcwdpeetouk56kg2tmg40wjtl

Monday, June 13, 2016

How to set Ephox Edit Live editor as default WCM editor?

Below are the simple steps to changes the WCM editor from default rich text to Ephox edit Live. First of all you have to download Ephox edit live from https://greenhouse.lotus.com/ and install the same application on to your portal server if not already installed.
  • Login to WAS Console.
  • Navigate to Applications->Application Types -> WebSphere enterprise applications.
  • Click on Install and select the .ear file you downloaded and click Next. Keep the default options keep going to next pages.
  • Make sure you select websphere_portal as the server not server1 while installing the .ear and finish the installation and save the configuration.
  • Start the application if its not already started.
  • Login to portal as administrator and navigate to WCM Authoring portlet -> Preferences > Configure.
  • Expand the Rich Text Options section , select Custom Editor in the drop down and enter the following in the text box "/wps/ephox/;jsp/html/EditLiveJavaEditor.jsp"and click OK.
  • Now navigate to WCM Authoring portlet -> Preferences > Edit Shared Settings.
  • Expand the RichTextOptions section , select Custom Editor in the drop down and enter the following in the text box "/wps/ephox/;jsp/html/EditLiveJavaEditor.jsp"and click OK.
  • Now go to any content item that uses rich text and you can see its using ephox edit live edit instead of IBM's default RTE.
  •  You can easily toggle between the design view and code view in the bottom left corner.
 Ephox edit Live is a Java Editor and Java Runtime is required on wcm author's machine to be able to use this applet in a browser.

Ephox has also released a javascript based rich text editor that you can apply on WebSphere Portal 8.5.0.0 with CF06 or higher.
Here is some more info on this: https://greenhouse.lotus.com/plugins/plugincatalog.nsf/assetDetails.xsp?action=editDocument&documentId=86189C1DAC5B1D3B85257E4500199F1B

About Rich Text editor options on WCM: https://www.ibm.com/support/knowledgecenter/SS3JLV_8.0.0/wcm/wcm_config_authoringportlet_richtext.html

Thursday, February 4, 2016

OptimizeCacheIdIncrements custom property

Problem statement:
cacheid (first 4char of jsessionid) in cluster env was getting update after 2hours of session inactivity however we had 24hrs of session inactivity set in application server. Due to this some of the applications which were dependent on session was throwing unexpected exception. Users were required to clear their cookies to resolve the issue.
We wanted to know why it was getting updated and if there is a way to stop this activity from occurring?

Solution:
set custom property OptimizeCacheIdIncrements parameter to true

Set the OptimizeCacheIdIncrements custom property to true to make the session manager assess whether the in-memory session for a web module is older than the copy in persistent store. Setting this property resolves the continually increasing cache ID.
If HTTP session management is configured to use session persistence and the user's browser session is moving back and forth across multiple web applications you might see extra persistent store activity as the in-memory sessions for a web module are refreshed from the persistent store. As a result, the cache IDs are continually increasing and the in-memory session attributes are overwritten by those of the persistent copy. Set this property to true if you want to prevent the cache IDs from continually increasing.
If the configuration is a cluster, ensure that the system times of each cluster member is identical as possible.

Reference link: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.nd.doc/info/ae/ae/rprs_custom_properties.html%23OptimizeCacheIdIncrements?lang=en


Using Application Server>URL resources to manage J2EE property files and external service url

Use following code to retrieve url resource using jndi
InitialContext initCtx = new InitialContext();
URL url = (java.net.URL) initCtx.lookup(jndi);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();

With this method you can either enter web service url in resource field or properties file path.

Note: You need to restart the server to lookup the url resource from code.

Reference link: http://www.ibm.com/developerworks/websphere/library/techarticles/0502_botzum/0502_botzum.html

How to access authentication alias from WebSphere Application Server> J2C

You can use the following code to obtain credentials from J2C authentication data entry:

import com.ibm.wsspi.security.auth.callback.Constants;
import com.ibm.wsspi.security.auth.callback.WSMappingCallbackHandlerFactory;
import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;

Map map = new HashMap();
map.put(Constants.MAPPING_ALIAS, "YOUR_J2C_DATA_ALIAS");
CallbackHandler callbackHandler = WSMappingCallbackHandlerFactory.getInstance().getCallbackHandler(map, null);

LoginContext loginContext = new LoginContext("DefaultPrincipalMapping", callbackHandler);
loginContext.login();

Subject subject = loginContext.getSubject();
Set credentials = subject.getPrivateCredentials();

PasswordCredential passwordCredential = (PasswordCredential) credentials.iterator().next();

String user = passwordCredential.getUserName();
String password = new String(passwordCredential.getPassword());

Reference link: http://stackoverflow.com/questions/4663534/how-to-access-authentication-alias-from-ejb-deployed-to-websphere-6-1/6355992#6355992

Wednesday, July 8, 2015

Translate portal to myportal when user is logged in

The Problem

Suppose you have a public-facing site for anonymous portal users. But suppose also that the same site also has some private resources requiring users to authenticate for access.
  • In this scenario, an authenticated user will be logged out if they try to access a public resource that has the anonymous context in the URL (i.e. /wps/portal/... instead of /wps/myportal/...).
  • BUT, we cannot just make all of our links contain /wps/myportal to get around the issue because then anonymous users will be prompted to login even if the resource is public.
  • What we need is a way to let links to public resources contain the anonymous context (/wps/portal/...), but we need to automatically transform that into (/wps/myportal) if the user happens to be logged in.

The Solution

There is a configuration option that does exactly this! Here's how you enable it on WPS 7 or greater.
  • In the Deployment Manager or WAS console, navigate to Resource environment providers > WP ConfigService > Custom properties</li>
  • Look for the property 'uri.home.substitution'. If it's not already in the list, add the property (as type java.lang.String) and set the value to 'true'. If it's already in the list, just set the value to true.</li>
  • Apply and save your changes to the master configuration. In a stand-alone environment, you then need to restart your server. In a clustered environment, you need to synchronize the nodes and then restart the cluster.</li>

Summary

The uri.home.substitution option determines whether a public URL should be translated to a protected URL if a user session exists. It is false by default and can be set to <em>true</em>.


Reference Link: https://wiki.base22.com/display/btg/Translate+portal+to+myportal+when+user+is+logged+in

Sunday, February 22, 2015

POC: Piece of Content URL

Passing query parameters to JSR-286 portlets using existing IBM WebSphere Portal capabilities at http://www.lotus.com/ldd/portalwiki.nsf/page.xsp?documentId=0971A3B3CE4F3AEA852578800051E2C7&action=openDocument

Sample Code for PortletPocService in Websphere Portal Server  at
 http://ourwebsphereportal.blogspot.com/2011/10/sample-code-for-portletpocservice-in.html

To pass render or action parameter you need to create DeeplinkResolver project.

Friday, January 30, 2015

Disable managed-pages feature to share wcm library with virtual portal

Portal v8 and above maintains their own wcm library and wcm library can't be shared between base portal and virtual portals until manages-page feature is disabled.

Run the disable-managed-pages task from the WebSphere/ConfigEngine directory.

ConfigEngine.bat disable-managed-pages -DPortalAdminPwd=wpsadmin -DWasPassword=wpsadmin


More Info: http://infolib.lotus.com/resources/portal/8.0.0/doc/nl_NL/PT800ACD002/wcm/wcm_config_mngpages_disable.html

Thursday, January 29, 2015

WebSphere 8 Auto Deploy

You need setup monitor directory to automatically deploy application.
 Log in to the Admin console and click "Global deployment Settings" from the Applications section of the Left-Hand-Side navigation menu.
 
Refer these link :
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/urun_app_global_deployment.html
http://www.webspheretools.com/sites/webspheretools.nsf/docs/WebSphere%208%20Auto%20Deploy

Wednesday, January 28, 2015

Enable session on anonymous pages



Enable public sessions for portal. The reason is that the theme/portlet needs a valid session for its run time, and by default, sessions are not enabled on anonymous pages in the portal. By default, sessions are only created when a user authenticates and logs in to the portal.
Enable public sessions by setting the parameter public.session to true (String type) in the portal "WP NavigatorService > Custom properties > New" in the WebSphere Integrated Solutions Console.

Tuesday, January 27, 2015

Cannot start Rational Application Developer - possible workspace corruption

Possible workspace corruption. (E.g. after a RAD crash, due to machine shutdown, etc.)

Resolving the problem

There are several possible workarounds to try to recover from this error:
  • The simplest workaround to try is to delete (or rename) the file workbench.xml which is found in your workspace in the
    .metadata\.plugins\org.eclipse.ui.workbench folder.

    Deleting workbench.xml forces RAD to resort back to the default perspective.

  • If the above action does not resolve the problem, the next workaround to try is to run rationalsdp.exe -clean This action forces RAD to reconfigure all the plugins (see link below for additional information).
  • You could try to see if the Eclipse Workspace Re-builder tool might help. (See the link under Related information referencing a technote explaining this tool).

If none of these options succeed in helping you recover from a workspace corruption error, you must start a new workspace.

Source Link - http://www-01.ibm.com/support/docview.wss?uid=swg21242350

Friday, September 26, 2014

Tuesday, September 23, 2014

URL generation services - WebSphere Portal v8.0

Some important urls around :

1) http://wpcertification.blogspot.com/2010/07/using-portletstatemanagerservice-for.html

2) http://www-10.lotus.com/ldd/portalwiki.nsf/dx/08042009092603AMWEBHRU.htm

3) http://www-10.lotus.com/ldd/portalwiki.nsf/xpDocViewer.xsp?lookupName=IBM+WebSphere+Portal+Express+8+Product+Documentation#action=openDocument&res_title=URL_generation_services_exp8&content=pdcontent&sa=true 

4) http://www.ibm.com/developerworks/websphere/library/techarticles/0612_behl/0612_behl.html