Показаны сообщения с ярлыком websphere portal 7. Показать все сообщения
Показаны сообщения с ярлыком websphere portal 7. Показать все сообщения

четверг, 18 июня 2015 г.

WebSphere Portal 7 webdav theme resources

First, to upload theme static resources to portal use webdav url:
http://<host>:10039/wps/mycontenthandler/dav/themelist.

Second, to make modifications in uploaded theme static resources use the following url:
http://<host>:10039/wps/mycontenthandler/dav/fs-type1.

Maybe, this will save up some time.

четверг, 25 сентября 2014 г.

Java zip file creation.

I had a task: get the files from database, create the zip file from them and serve the file to user.

The most tricky part of this process is to combine files into zip archive.

On my developer's computer I use windows 7  + Oracle JDK, on the test site we have Cent os and Websphere portal 7.

I have successfully wrote the code, tested it on developer's computer and deployed to test system. I have been surprised by the behavior of the code.
The code is as simple as:
 
ZipOutputStream zipStream = ...
ZipEntry zipEntry = new ZipEntry(zipEntryName);
zipStream.putNextEntry(zipEntry);
zipStream.closeEntry();
zipStream.finish();
zipStream.close();
 
My zip file contains entries made of Cyrillic symbols. But when I had got the file from test system I have found out that the filenames in zip archive have been corrupted.  On developer's computer everything worked fine.

The question is in encoding. I suggest that IBM JRE uses the system encoding for encoding the entry names in archive. Java 7 has the constructor
ZipOutputStream(OutputStream out, Charset charset) 
which accept charset for entry names encoding. But WebSphere Portal comes with java 6.

After googling I have found out the project Apache commons-compress project. It allows you to create zip files with specified zip entries encoding like the following:
zos = new ZipArchiveOutputStream(os);
zos.setEncoding("UTF-8");
zos.setFallbackToUTF8(true);
zos.setUseLanguageEncodingFlag(true);


Change the code to use commons-compress and I could produce identical results on developer's and test computers. Happy coding!

вторник, 9 сентября 2014 г.

WebSphere portal 7. com.ibm.websphere.security.auth.WSLoginFailedException. Problems with LTPA token on cluster.

During exploitation the Websphere Portal 7 cluster we encountered the following problems:
  • The exception is com.ibm.websphere.security.auth.WSLoginFailedException: Validation of LTPA token failed due to invalid keys or token type 
  • The exception is com.ibm.websphere.security.auth.WSLoginFailedException: Token expiration Date.

пятница, 6 июня 2014 г.

WebSphere Portal 7. Export url mappings with XMLAccess

If you have to move url mappings between your prod and test WebSphere Portal environments, then you can do it like the following. If you have virtual portal then export you url mapping:

<request build="wp7002_132_01" type="export" version="7.0.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0_2.xsd">
<portal action="locate">

<url-mapping-context action="locate" label="virtual_portal_name">
<url-mapping-context action="export" label="mapping1" />
</url-mapping-context>
</portal>
</request>





Command for export:
xmlaccess -in exportscript.xml -user wpsadmin -password wpsadmin -url http://localhost:10039/wps/config/virtual_portal_name -out script_out.xml




Use the same command for importing that file or use portal admin console to import the xml file.

четверг, 22 мая 2014 г.

Use PUMA API from within WebSphere Portal 7 and WebSphere Application Server 7

There is a moment when you need to create users from within portal or application server. PUMA API allows you to do management work with you users.

The crucial interface for working with PUMA API is PumaHome.

Portal
In portlet you will use instance of com.ibm.portal.um.portletservice.PumaHome which you get from com.ibm.portal.portlet.service.PortletServiceHome like this:

pumaHome = psh.getPortletService(com.ibm.portal.um.portletservice.PumaHome.class);


Instance of com.ibm.portal.portlet.service.PortletServiceHome you can obtain from JNDI lookup by name "portletservice/com.ibm.portal.um.portletservice.PumaHome".

In Spring one can do it like this:    <jee:jndi-lookup id="userManagement" jndi-name="portletservice/com.ibm.portal.um.portletservice.PumaHome" resource-ref="true"></jee:jndi-lookup>

Application Server
If you want to manage users from WebSphere Application Server, then you should use instance of com.ibm.portal.um.PumaHome which you can get from JNDI lookup by name "portal:service/usermanagement/Puma".

вторник, 6 мая 2014 г.

WebSphere Application Server 7\Websphere Portal Server 7. Download files containing non-ASCII characters (Cyrillic example).

In portlet applications there is often a need to download files.
Nowadays people want to exchange files named in languages other then english.
In this post I want to describe how to download files, which contain russian characters in their names.

As you know in portlet environment one need to use ResourceResponse class to output any content to the client.

Before you output the content to the client you need to set proper http headers on response.
For file downloading you have to set header Content-disposition: attachment; filename="your file name".

HTTP specification RFC2616 prohibits the use of non-ASCII symbols in HTTP headers, but that doesn't mean you can violate this rule.

RFC2231 provides the mechanism to specify the character set before the attribute, like this filename*=utf-8''uri_encoded_filename.

If you implement this solution you might found out that sometimes Firefox allows you to save the file with the given filename and other times Firefox will allow you to save the file with blank filename.

If you look at the response in sniffer like wireshark you can find out that your header Content-disposition: attachment; filename="your file name" had been magically transferred to Content-disposition: attachment; filename=""some_junk. That's why Firefox asks you save file with a blank name.

I had find out the following workaround: prepend the "your file name" with exclamation mark, so this is the result:
Content-disposition:attachment;  filename="!" + fileName+ "\"; filename*=utf-8''" + encodedFilename

After this modification the server no longer breaks your intentions and doesn't modify your header to Content-disposition: attachment; filename=""some_junk.

This behavior I found out on WAS 7.0.0.21.

вторник, 28 января 2014 г.

WebSphere Portal. Run XmlAccess on remote hosts.

If you want to automate the configuration and deployment task on WebSphere Portal, eventually, you will use XmlAccess.

IBM provides ant task called XmlAccess. My goal is to achieve the invokation of configuration tasks on remote machine from my machine. I use Windows 7 and ant 1.8.4 . Remote installations of WebSphere Portal use Linux.

пятница, 29 ноября 2013 г.

WebSphere Portal 7. Longrunning tasks in portlets.

Sometimes operations in portlets can take a long time to complete, like a report generating task. It is better not to execute such tasks in a synchronous way, because :
  • they block the web container thread, which slows down user satisfaction;
  • make the appearance of application to freeze;
  • the task can take up time of no more then request timeout;
  • you cannot cancel the task;
  • you don't see the progress of your task.

пятница, 25 октября 2013 г.

Spring Portlet MVC 3 on WebSphere Portal 7 cookbook

Here are my personal experience of Spring Portlet MVC 3 on WebSphere Portal 7.
  1. Spring profiles feature is not working in portlet environment.
  2. If your portlet use session for anonymous user, then you can enable it with container-runtime-option feature in portlet.xml like this:
         <container-runtime-option>
            <name>com.ibm.portal.public.session</name>
            <value>true</value>
        </container-runtime-option>
  3. Using client side aggregation and file upload doesn't work together. Switch you page to server side aggregation mode.
  4. When you first time add the event processing feature to portlets and deploy them to portal then you better switch the client side aggregation to server side aggregation. If you don't do this, then you cannot setup wires between your portlets.
  5. If you want your spring portlet to work in client side aggregation, then in your "form:form" tag set attribute htmlEscape="false".
  6. If you use Spring JDBC on WebSphere Portal  then  set connection extractor on your jdbc template like this:
    <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor" />. This is especially useful if you need to work with special database types and\or stored procedures.
  7. Spring JDBC. Use jndi to create the datasource like this in application context:
    <jee:jndi-lookup id="myDataSource" jndi-name="jdbc/myds" cache="true" resource-ref="true" lookup-on-startup="false" proxy-interface="javax.sql.DataSource" />
  8. If you use JNDI resources in portlet then declare them in ibm-web-bnd.xml file like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-bnd
        xmlns="http://websphere.ibm.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
        version="1.0">
        <virtual-host name="default_host" />
        <resource-ref name="jdbc/mydb" binding-name="jdbc/mydb" />
    </web-bnd>
    Also don't forget to declare it in web.xml:
     <resource-ref>
        <res-ref-name>jdbc/mydb</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
        <mapped-name>jdbc/mydb</mapped-name>
      </resource-ref>
  9. When declare portlet.xml use the following declaration:
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
        version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
            http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
        id="myportlet.war">.
    Take a look at id attribute. This is how WebSphere Portal distinguishes your war files on portal.
  10. When work with AJAX use @ResourceMapping annotation extensively.
  11. Use spring portlet mvc mock objects for unit testing your controllers.
  12. Use @ExceptionHandler annotation to process exceptions in controller.
  13. Some other interesting information can be found http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html .
Update 24.11.2013:
When using @ResourceMapping  method you can return string, that will map to the jsp, so you can conveniently serve jsp content.