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