Sunday, May 29, 2011

Testing webpage on Mobile's emulator


Here is the list of emulators for testing webpages on handheld devices -

Devices
Emulator
Comment
iPhone/iPad
Can be used to test webpages for both iPhone and iPad.
Hotkey to switch to modes : ctrl-2
Blackberry
Different emulators has to be downloaded for different models
Android
All the versions are available for testing through a single installer
Symbian
All Nokia models are available to test

Even for testing on iPad we can consider Safari browser.

To make sure html markup is valid and it is compatible for mobile, we may use following w3 org service - http://validator.w3.org/mobile

Friday, May 27, 2011

Remote Device Access Services

The remote device access services enable access to a live device over the Internet. This offers a possibility for the developers to reduce the effort on testing, demoing and content & application development. In addition it promotes collaboration among colleagues in remote locations.
There are two services which are promoted by Forum Nokia:

Forum Nokia Virtual Developer Lab

DeviceAnywhere is an award-winning product that provides convenient and cost-effective end-to-end solutions for mobile content development, monitoring, testing and deployment – enabling application developer to bring better content to market faster than ever before. Its unique Direct-to-Device™ technology provides access to real handsets in live global networks, from anywhere. DeviceAnywhere currently supports 1500 devices on over 25 different carrier networks worldwide, with locations in the U.S., U.K., Canada, France, Germany, and Japan. To learn more about DeviceAnywhere visit www.deviceanywhere.com.

Remote Device Access

Remote Device Access (RDA) is a service that allows developers to test their mobile applications and services remotely on various Nokia devices based on Symbian OS. The main features of the service are remote controlling a device, installing and running applications, transferring files, and analyzing log files in real-time. RDA is an Internet-based solution and the basic requirements for using the service are a Forum Nokia user account, a standard Web browser, and Java Web Start (comes typically with JRE; version 5.0 or newer is required). Usage is free of charge for all Forum Nokia members. To learn more visit - RDA »

Thursday, May 26, 2011

Convert PDF to SWF


You can use swftools (http://www.swftools.org/) to convert pdf to swf.
Installer available for Windows and Linux. http://www.swftools.org/download.html
Here is some sample example of how to use swftools - http://www.quiss.org/swftools/pdf2swf_usage.html

After conversion of pdf to swf you can use flash player to view in a webpage (http://flexpaper.devaldi.com/). Flexpaper is free to use.

Here sample code snippet -
private static String Pdf2SwfExecutablePath="C:\\Program Files\\SWFTools\\pdf2swf.exe";
private ByteArrayOutputStream convertPdfToSwf(ByteArrayOutputStream pdfOutput) throws IOException {
        ByteArrayOutputStream swfByte = new ByteArrayOutputStream();

        // Temporary file name
        String destPDF = tmpdir + System.getProperty("file.separator") + new java.util.Date().getTime() + "_out.pdf";
        String destSWF = tmpdir + System.getProperty("file.separator") + new java.util.Date().getTime() + "_out.swf";
        File destPDFFile = new File(destPDF);
        File destSWFFile = new File(destSWF);

        FileOutputStream pdfFile = new FileOutputStream(destPDFFile);
        pdfFile.write(pdfOutput.toByteArray());
        pdfFile.close();

        Runtime r = Runtime.getRuntime();
        Process p = null;
        String cmd = new String("\"" + Pdf2SwfExecutablePath + "\" \"" + destPDF + "\" -o \"" + destSWF + "\" -f -T 9 -t -s storeallcharacters");
        try {
            p = r.exec(cmd);
            SwfConverterProcessWatcher w = new SwfConverterProcessWatcher(p);
            w.start();
        } catch (Exception e) {
            System.out.println("error executing " + cmd);
        }

        FileInputStream swfFile = new FileInputStream(destSWFFile);
        for (int ch; (ch = swfFile.read()) != -1;)
            swfByte.write(ch);
        swfFile.close();
        swfByte.close();

        // Delete temporary files
        destPDFFile.delete();
        destSWFFile.delete();

        return swfByte;
    }

public class SwfConverterProcessWatcher {
    private Process process;
    private Thread end;
    private Thread out;
    private boolean stopped = false;

    public SwfConverterProcessWatcher(Process theProcess) {
        this.process = theProcess;
        end = new Thread() {
            @Override
            public void run() {
                try {
                    process.waitFor();
                } catch (Throwable e) {
                } finally {
                    stopped = true;
                }
            }
        };
        out = new Thread() {
            @Override
            public void run() {
                String read;
                BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
                while (!stopped) {
                    try {
                        read = in.readLine();
                        if (read == null) {
                            break;
                        }
                    } catch (Throwable e) {
                        break;
                    }
                }
            }
        };
    }

    public void start() {
        end.start();
        out.start();
        try {
            end.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

Portlet caching issue may occurred when calling portletResponse.getPortletOutputStream()

If portlet caching is enabled and you calling portletResponse.getPortletOutputStream() it will throw exceptions.
To resolve this -
1) Either disabled the portlat caching and restart the portal server
2) Install the fix pack http://www-01.ibm.com/support/docview.wss?uid=swg1PK93614

OpenOfficeConverter using Java

You can possible convert any document to pdf or presentation file to swf using OpenOffice Service and JOD Api.
Download Openoffice installer from following url - http://download.openoffice.org/other.html

Openoffice must be installed on machine where WebServer/AppServer is running and Openoffice service must be started/listening.
To start Openoffice service use following command :
    * for Linux: /path/to/openoffice/program/soffice.bin -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"
    * for Mac OS X: /path/to/openoffice.app/Contents/!MacOS/soffice.bin -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"
    * for Windows: soffice.exe -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"

To know more about OO service visit - http://code.google.com/p/openmeetings/wiki/OpenOfficeConverter

JOD Api Link - http://www.artofsolving.com/opensource/jodconverter

Online Document Viewer Analysis


1.       Adeptol On Premise - http://www.ajaxdocumentviewer.com/
•How does transformation take place (serverside, clientside, API)
                Serverside
•What would be the rough steps (impact) to implement the product into our Portal environment. e.g. how does it integrate with WCM? Do we need additional storage? What about documents coming from Domino?
                Document can be manually uploaded into server or just url of document which is accessible to the adeptol server. I am not sure about how converted document will be visible to the client, whether it will directly write response to http or provide url to access the converted document. The same storage information is not available on the website.
•Pros and Cons like: browser dependencies, manual steps, looks, speed etc.
                Support for more than 300 Document Types including Microsoft Office 2007 documents (docx, xlsx, pptx), Office 2000 (doc, xls, ppt), Open Office (odt, sxw, ods, sxc. odp, sxi, odg), Images (jpg, bmp, png, gif, tiff), Adobe PDF etc. AJAX Document Viewer allows an unlimited number of users to convert any format of Microsoft Word, Excel and PowerPoint documents to PDF & SWF on a server. Quick and easy conversion of most of the document to an Adobe ® Flash ® (SWF). AJAX Document Viewer is based on Multiple Tenancy Concept resulting in faster conversion rates and performance as multiple users can access the server at the same time and get various documents converted simultaneously. Professional Edition Viewer is a light weight flash control. They are many options/control available in flash viewer like (thumbnail of each pages in left, Viewer with Custom Skin Color, Viewer with Navigation Turned Off, Viewer with custom buttons, Localize viewer to any language)
•What would roughly be the cost for licensing. Per server, per user
                Need to inquiry with sales.

Java OpenDocument Converter opensource, converts documents between different office formats and the transformation will take place on server side.
It leverages OpenOffice.org, which provides arguably the best import/export filters for OpenDocument. To work with this api the open-office must be installed in websphere server.
We can write a Servlet that will take document or document url as input and produce pdf binary data, this way we don't need additional storage to store document on server.
Once converted into pdf we can use iframe or embed tag to show pdf document in a browser. Here pdf plugins is required in a browser.
Conversion time depends on the size of the documents.

If we want to escape pdf pluings dependency then once documents are converted into pdf we can again convert pdf document to swf files by (openoffice api or through swftools http://www.swftools.org/). Here additional temporary storage is required to convert document from pdf to swf. After conversion of pdf to swf we can use flash player to view in a webpage (http://flexpaper.devaldi.com/). Flexpaper is free to use but it is not hundred percent reliable.

3.       ImageMAKER Development - http://www.conversionserver.com/
The Document Conversion software controls file conversion to TIFF, TXT and JPEG by first launching the file owner application (e.g. Word, Excel, Netscape), then instructing the owner application to print the document using Windows shell commands.

Doesn't support UNIX and LINUX.
Modules provided: Server Based Document Rendering Engine
   NT 4.0 and Windows 2000 fax print driver with support software.
   ImageMAKER Cover Page Generator.

RasterMaster® for the Java™ Platform is the premier Java Imaging and Conversion SDK, toolkit, and library in the industry.
Provides true cross-platform compatibility and web support - written entirely in Java
Price: $2500 and up + Distribution Licensing 

Macromedia FlashPaper 2 lets you easily convert any printable document (such as a Microsoft PowerPoint, Word, or Excel document) to a FlashPaper SWF file or a Portable Document Format (PDF) file.
Conversion will take place on server side. Extra storage is required into server.
Adobe stopped promoting this product, so there is very less product information available and I guess integration with java is not available.

Scribd ipaper - http://www.scribd.com/ipaper?phpsessid=42c47e75419baa0e5e493bbbe5cf86ae
iPaper is a rich document format built for the web. Built with Adobe Flash, iPaper will display documents in the same way regardless of whether you're using Windows, MacOS, or Linux.

Retrieve LTPA token for establishing SSO connection

Here is sample code :
String serverName=request.getServerName();
            String domainName=serverName.indexOf(".")!=-1? (serverName.substring(serverName.indexOf("."))):serverName;
            String ltpaTokenCookie="";
            Cookie cokkies[]=request.getCookies();
            //retrieving ltpatoken cookie info and forming the ltpatoken cookie string
            for(Cookie cookie:cokkies) {
                if(cookie.getName().equalsIgnoreCase("LTPATOKEN")) {
                    ltpaTokenCookie=cookie.getName()+"="+cookie.getValue()+((cookie.getMaxAge()>0) ? "; expires=" + cookie.getMaxAge():"") +("; Domain=" + domainName);
                    break;
                }
            }
           
            URLConnection docConnection = new URL(inputDocumentURL).openConnection();
            docConnection.setRequestProperty("Cookie", ltpaTokenCookie);