Wednesday, October 20, 2010

SAP - How to make IScheduleTask configurable

cc.xml co.xml

SAP - dist/PORTAL-INF/config

We are not using NWDI. We use a third-party source code management system.

The dist/PORTAL-INF/config folder was checked into the repository. Later when we did a quick PAR upload, NWDS complained not able to delete the folder.

Tried to find a way to prevent it being checked in, but found no solution.

Finally I found if I define this folder as Derived, it won't give me any trouble.

Thursday, September 16, 2010

Java Write Text into a Image

graph = image.getGraphics();

graph.setColor(aColor);
graph.setFont(aFont);
graph.drawString(text, x-position, y-position);

Friday, September 10, 2010

Some small consideration when design web applications

Sometimes I think to myself, what makes web application different from others? I find a real case when I review a real application.

This application has an edit page, on which user can select "Y" or "N" from a drop list. It also define keys for "Y" and "N" in a message properties file and this application is designed for English only.

I think there are at least two small places that the designer can do better.
  1. use radio button instead of drop down list, this saves one click.
  2. still put real messages in properties files but no need to treat a "Y"/"N" choice as a real message
The reason to put real messages in properties files even for an English only application is to allow business easily change those messages during the whole application life cycle. It will still be an application level change, but you would have much more confidence that a regression test will not be needed.

Monday, August 16, 2010

SAP Portal - Multiple Node Installation of a KM Scheduler Task

In an environment with more than one CM system, you must assign one (any) CM system in the cluster to each scheduler task.

Do not assign a scheduler task to more than one CM system at the same time. In the configuration of a scheduler task, there must be only one entry in the CM Systems parameter.

To balance the load, we recommend assigning all scheduler tasks to one dedicated CM system that runs separate from the load balancer. This separation removes the load caused by running the scheduler tasks from the other nodes and makes them available solely for your users.

Tuesday, July 27, 2010

DOS - Current User Path

%USERPROFILE% = C:\Documents and Settings\{current user}

Wednesday, June 23, 2010

Tips - How to Rename the Suffix of a Group Files on Windows

Very simple, use cmd and go to the directory,

rename *.abc *.xyz

DONE.

Thursday, June 10, 2010

Have fun! World Cup is coming.

Last month a world wide telephone survey was conducted by the U.N.

There was only one question asked: "Would you please give your honest opinion about solutions to the food shortage in the rest of the world?"

This survey was a HUGE failure because of the followings,

1. In Eastern Europe they didn't know what "honest" meant.
2. In Western Europe they didn't know what "shortage" meant.
3. In Africa they didn't know what "food" meant.
4. In China they didn't know what "opinion" meant
5. In the Middle East they didn't know what "solution" meant
6. In South America they didn't know what "please" meant
7. In the USA they didn't know what "the rest of the world" meant
8. In Australia they hung up as soon as they heard the Indian accent.

Wednesday, May 19, 2010

SAP Portal - Internationalization on Room Directory

NetWeaver Collaboration with Enterprise Portal 7.0.18 only supports English and German.

To internationalize it, download com.sap.netweaver.coll.appl.ui.room.par and add

UIRoomdirectoryConsts_es.properties to support Spanish and
UIRoomdirectoryConsts_fr.properties to support French.

Then redeploy the par to EP.

Monday, May 17, 2010

SAP Portal - Promote KM Changes to Next Stage

As I said in my previous posts, we created a new XML form, a couple of new predefined properties, and a new filter. Now we need to promote these changes to next stage.

Portal Content
  • create a transport package and add the changed iView into the package
KM Configuration
  • create a configuration archive and add the following into the archive
  • KM->CM->Form-Based Publishing -> Forms Availability ->Folder Settings, the new folder-form setting
  • KM->CM->Global Services->Property Metadata->Properties, the new metadata
  • KM->CM->Global Services->Property Metadata->Groups, the new metadata group
  • KM->CM->Global Services->Property Structures->Property Groups, the new property group and the all_groups
  • KM->CM->Global Services->Resource List Filters, the new resource list filter
  • KM->CM->Repository Filters, the new filter class
  • KM->CM->User Interface->Settings->Layout Set, the new browser
XML Form
  • copy the new xml form to next stage

Friday, May 07, 2010

SAP Portal - Apply XML Form to KM Folder

System Admin -> System Config -> KM -> CM -> Form-Based Publishing -> Forms Availability -> Folder Settings

Create a FM_News_Form

Thursday, May 06, 2010

SAP Portal - Use Properties in XML Form

I found almost zero documents on this subject. I figured it out finally with some common sense and some luck.

I configured some predefined properties to my KM documents. After it, I needed to create a XML form and use these properties for users to create such documents.

Here is what I had done.
  1. Open an existing News form and save as my own project, called FM_News.
  2. At the left side, select the Data Model, right click on Properties and select Reload Properties
  3. At the editor area, add a label ABC, add three check boxes A, B, and C
  4. Add a label DE, add two radio boxes, D and E
  5. Define A - Caption A, Name ABC, Value A, Property Reference /Properties/default:ABC
  6. Define B - Caption B, Name ABC, Value B, Property Reference /Properties/default:ABC
  7. Define C - Caption C, Name ABC, Value C, Property Reference /Properties/default:ABC
  8. Define D - Caption D, Name DE, Value D, Property Reference /Properties/default:DE
  9. Define E - Caption E, Name DE, Value E, Property Reference /Properties/default:DE
  10. Note: check box for multiple selection and radio box for single selection, XML Form Builder may warn you to use Combo Box instead, ignore it.
  11. Save and generate.

Tuesday, April 27, 2010

SAP Portal - XML Forms Builder

This builder is under the Content Management tab of Content Manager role.

After every change to the form, save the project and generate the project.

This generation, my understanding, is to publish the change to portal.

To move the change to QAS or PRD, copy its xml files from \usr\sap\[sid]\SYS\global\config\cm\etc\xmlforms to QAS or PRD servers.

Wednesday, March 17, 2010

SAP Portal - How to Configure Predefined Properties for KM Documents

We use KM Navigation iView to broadcast news which are posted in KM repository.

We need to separate them by Field and by Language.

Configuration,
  1. System Adminsitration -> System Configuration -> Knowledge Management -> Content Management -> Global Services -> Property Metadata -> Groups
  2. New
  3. Global Services -> Property Metadata -> Properties
  4. New - Unique ID = NewsGroup-Field, Property ID = Field, Namespace Alias = default, Group = NewsGroup, Mandatory = Yes, Multi-Valued = Yes, Maintainable = Yes, Default Value = Field1, Allowed Values(csv) = Field1,Field2,Field3
  5. New - Unique ID = NewsGroup-Language, Property ID = Language, Namespace Alias = default, Group = NewsGroup, Mandatory = Yes, Multi-Valued = No, Maintainable = Yes, Default Value = English, Allowed Values(csv) = English,French
  6. Global Services -> Property Structures -> Property Groups
  7. New
  8. Global Services -> Property Structures -> Property Groups, select all_groups and Edit
  9. Add the newly created NewsOptions to Group Items and OK
  10. Content Administration -> KM Content, select a document and open its Details
  11. Settings -> Properties -> NewsGroup tab
  12. Done

SAP Portal - Namespaces

System Administration > System Configuration > Knowledge Management > Content Management > Global Services > Property Metadata > Namespaces

We usually use the default, http://sapportals.com/xmlns/cm.

Tuesday, March 16, 2010

SAP Portal - Obtain Property from IResource

If, for example, you have created a pre-defined property for KM document, called it "MyProperty", you can obtain its value after obtain an IResource object.
IPropertyName myPropertyName = PropertyName.getPN("http://sapportals.com/xmlns/cm", "MyProperty");
IProperty myProperty = resource.getProperty(myPropertyName);
if (myProperty != null) {
String myPropertyValue = myProperty.getStringValue();
}
Easy?

Now what if the MyProperty is Multi-Valued? Here is the code.
List values = property.getValues();
for (Iterator valuesIterator = values.iterator(); valuesIterator.hasNext();) {
String element = (String) valuesIterator.next();
}

SAP Portal - Obtain IUser from IResource

Add com.sap.portal.usermanagement/lib/com.sap.security.api.ep5.jar to classpath.

then,
IResource resource = ...;
IResourceContext context = resource.getContext();
IUser user = context.getUser();
IUser is deprecated since it is a EP5 user. However, UME user is not available for KM. So, no choice.

By the way, to obtain the Locale
Locale locale = context.getLocale()

Thursday, March 11, 2010

SAP Portal - Enable Debugging on NWDS

  1. Ask your BASIS team to enable the debugging on portal server. It is fairly easy. If they need more than 20 minutes, they lie.
  2. Let them tell you the message server host and port.
  3. In your NWDS (7.0), Window > Preferences > SAP J2EE Engine.
  4. Select the remote one and enter the message server host and port.
  5. Open the J2EE Engine view, the remote server shall show you green stuff, locate the sever0 and write down the debug port
  6. Run > Debug... and create a new Remote Java Application
  7. Set the host name to your portal server, port number to the debug port you just wrote down
  8. Click Debug. Note, only one debug is allowed. If you want to debug on another project, disconnect the current debug, create and start another one.
  9. Done!

SAP Portal - Deploy Resource List Filter

  1. Deploy the par contains the Filter to portal.
  2. Logon Portal
  3. System Admin > System Configuration > Knowledge Management > Content Management > Global Services > Resource List Filters
  4. New
  5. Back to Content Management, then User Interface, Settings, Collection Grid Renderer Settings
  6. Select a Renderer, Duplicate
  7. Enable advanced option, select the newly created ResourceListFilter from drop down list
  8. Back to User Interface, then Layout Set, select a layout and duplicate
  9. Select the newly created Collection Renderer and save
  10. Create a KM Navigate iView and set its layout set to the newly created one
  11. DONE!

SAP Portal - Create a Resource List Filter

There are many articles on Resource List Filter on web but few discussed how to create it in NWDS. Here are my steps on NWDS 7.0.
  1. Create a Portal Application in NWDS.
  2. Right click the project, New > Other... > Repository Framework 7.1.5 > Repository Filter Wizard
  3. Select NW04, check off Generate classpath (the generation didn't work for me), enter class name and package name
  4. A NamespaceFilter is created. It is not what I want. So I replace the class with the following source

import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.repository.IProperty;
import com.sapportals.wcm.repository.IResource;
import com.sapportals.wcm.repository.IResourceList;
import com.sapportals.wcm.repository.PropertyName;
import com.sapportals.wcm.repository.service.layout.customizing.IParameters;
import com.sapportals.wcm.service.resourcelistfilter.IResourceListFilter;

/**
* @version 1.0
*/
public class NotificationFilter implements IResourceListFilter {

/**
* Returns a new instance of the resource list filter.
*/
public IResourceListFilter getNewInstance() {
return new NotificationFilter();
}

/**
* Filters the resource list
*/
public void filterResourceList(IResourceList list, IParameters parameters) throws WcmException {
IResource resource = null;
IProperty prop = null;
for (int i = list.size() - 1; i >= 0; i--) {
resource = list.get(i);
prop = resource.getProperty(PropertyName.createContentLength());
if (prop != null && prop.getLongIntValue() > 102400) { // remove resources greater than 100kB
list.remove(resource);
}
}
}

}


I have downloaded all 7.0.18 libraries to a local directory and defined it as PORTAL_HOME. So here is my project classpath.
  • ECLIPSE_HOME/plugins/com.sap.ep.applicationDevelopment_7.00/prtapi.jar
  • PORTAL_HOME/com.sap.netweaver.bc.util/lib/bc.util.public_api.jar
  • PORTAL_HOME/com.sap.km.cm.service/lib/km.shared.service.resourcelistfilter_api.jar
  • PORTAL_HOME/com.sap.netweaver.bc.rf/lib/bc.rf.framework_api.jar
  • PORTAL_HOME/com.sap.km.cm.repository.service.base/lib/km.shared.repository.service.layout_api.jar
  • PORTAL_HOME/com.sap.netweaver.bc.crt/lib/bc.crt_api.jar
Done.

Friday, March 05, 2010

J2C Bean and Team Development

IBM wizard uses XDoclet to generate J2C source from COBOL copybook. That's cool. It keeps the annotation in the source code. That's alright.

What bothers us is that every time any member checks out the code from team repository, it regenerates the same code and stamps a new timestamp on the code. After a while, it shows a lot of versions in the repository but actually nothing has been changed.

Our solution is to enable XDoclet builder on only one developer's workspace and disable everybody else. This is far from savvy but it seems no other options.

What if we really need to use XDoclet for other purposes? I can only guess IBM lab architectures have never used their own tool in any real-life and serious projects.

What has Spring IDE done to XML Editor?

I don't know.

My Rational Software Architect is 7.5.5. Every time after I installed the Spring IDE plugin, the XML Editor failed to open.

Anyone has the same problem?

Wednesday, February 03, 2010

Spring and Tiles

I have tried Spring 3.0.0 + Tiles 2.2.1, 3.0.0 + 2.1.4, 2.5.6 + 2.2.1, 2.5.6 + 2.1.4, none worked.

I went back to Spring 2.5.5 + Tiles 2.0.5. So far, this is the only combination works for me.

Copy to WEB-INF/lib, all from Spring 2.5.5 download,
  • commons-beanutils.jar
  • commons-digester.jar
  • commons-collections.jar
  • spring-aop.jar
  • spring-beans.jar
  • spring-context.jar
  • spring-context-support.jar
  • spring-core.jar
  • spring-jdbc.jar
  • spring-tx.jar
  • spring-web.jar
  • spring-webmvc.jar
  • tiles-api-2.0.5.jar
  • tiles-core-2.0.5.jar
  • tiles-jsp-2.0.5.jar

Thursday, January 21, 2010

When You Upgrade Struts

Sometimes, the application server won't recompile your JSP pages and you may receive errors like,
java.lang.NoClassDefFoundError: org.apache.struts.taglib.tiles.InsertTag
It misleads you to a classpath issue, but it is not.

All you need to do is to clean up the temp directory of this application.

Monday, January 18, 2010

SAP Portal - Steps to Create a Collaboration Room

My goal is to create a collaboration room in SAP Enterprice Portal. It shall display all documents in a KM directory assigned to this room. Same way like KM Navigation iView.

Users have asked to control the initial state of each folder, for example, expanded or collapsed, however, I am not sure if it is deliverable under NW EP 7.0.

Normally I would start from an existing room template by duplicating it, but this time, I want to start from the beginning, for readers including myself.

Here are my steps.

Part 1, create template workset

  1. Content Administration -> Portal Content -> com.sap.ip.collaboration -> Worksets
  2. Create a new workset under Worksets, name it e.g. MyColl_Room_v1
  3. Add Portal Content/com.sap.ip.collaboration/TemplatesAndPartContent/TemplateSpecific/Team Template/Pages/Documents and Links to MyColl_Room_v1 as delta link
  4. Add Portal Content/com.sap.ip.collaboration/TemplatesAndPartContent/Generic/Pages/Admin: Room to MyColl_Room_v1 as delta link, if only for users current requirements, Admin: Member would be enough, but for future growth, Admin: Room is usually a good choice
  5. Add Portal Content/com.sap.ip.collaboration/RoomPartContent/Generic/Pages/Documents to MyColl_Room_v1 as delta link
  6. Right click the Documents and select Edit
  7. Remove the Document iView inside the Documents page
  8. Add Portal Content/Content Provided by SAP/End User Content/Standard Portal Users/iViews/com.sap.km.iviews/URL Access/KM Navigation iView to the Documents page
  9. Save and close, part 1 done.

Part 2, create room template

  1. Content Administration -> Collaboration Content -> Room Template Administration
  2. Click the New Template button
  3. Name the new room template MyColl_Room_v2
  4. Give any appropriate description
  5. Specify any appropriate owner
  6. Select Private as it is the requirement
  7. Check on Fixed Room Type
  8. Select MyColl_Room_v2 as the Workset
  9. Click Next
  10. Remove the Public role as I don't need it
  11. Set Initial Role to Member and Admin Role to Admin
  12. Check Admin for all three pages, Member for only the RoomDocuments
  13. Add one external parameters, Docu_Folder_Path
  14. Skip the Extensions
  15. Complete mappings, see the mappings table
  16. Skip the Permissions
  17. Finish

Mappings table

  • com_sap_netweaver_coll_information_roomid -> room_id
  • customEntryPointDescrption -> room_description
  • customEntryPointFolderPath -> Docu_Folder_Path
  • customEntryPointName -> room_name
  • path -> Docu_Folder_Path
  • roomid -> room_id
  • StartUri -> Docu_Folder_Path
  • XFProjectPath -> roomstructure_rid
  • com_sap_netweaver_coll_roomquicklaunch_roomid -> room_id
  • com_sap_netweaver_coll_maintenance_roomid -> room_id

Part 3, create the collaboration room

  1. Content Administration -> Collaboration Content -> Room Creation
  2. Name it MyColl_Room_v1_001
  3. Any appropriate description, owner, categories
  4. Select MyColl_Room_v1 as Template
  5. Set the Docu_Folder_Path to the designated KM Folder
  6. Keep default for all rest.
  7. Finish