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?