Sunday, November 21, 2010

Configuring UCM application in Eclipse IDE

I tried to set up a development environment to create custom Java components for UCM application using Eclipse IDE. There is a step by step procedure available in Bex's book and that should suffice to set up development environment for most people. But somehow I was unable to get it set up and working.

After a lot of trial and error method, I got the Content Server to start from within the IDE. I thought of sharing my experience with those who are new to development of custom Java components.

The following step by step procedure is for UCM 10gR3 and Eclipse version 3.4.2.

First let us create a simple component 'MyFirstComponent' using Component Wizard. Using this component let us change the filename that is displayed to the title entered during check-in.
We can achieve this by writing a filter using validateStandard.

Lets set up the component in Eclipse.

Follow the below steps.
1) Open Eclipse.
2) Windows -> Preferences -> Java Compiler and set it to Java 1.5.
3) File -> New -> Project -> Java Project.
4) Name the project MyFirstComponent and click Next.
5) In the Source tab, click the Browse button which is present at the bottom of the page besides the Default Output Folder text box.
6) In the Folder Selection dialog box, select the project name and click Create New Folder button.
7) In the New Folder dialog box, enter the folder name as classes and click the Advanced>> button.
8) Select the Link to folder in the file system check box. Click browse and browse to the directory ucm/custom/MyFirstComponent/classes. If classes folder is not there, it must be created and then linked.
9) Click OK and set the Default Output Folder to MyFirstComponent/classes.
10) In the Libraries tab, add all the jars needed to be in the class path. Some of the mandatory jars are given below.
ucm/shared/classes/server.zip
ucm/shared/custom/Folders_g/classes.jar
It depends on what all is being used in the components.
11) Click Finish.

Now in the src folder of the project, create a package named myfirstcomponent

Then create the below class file in that package.

package myfirstcomponent;
import intradoc.common.ExecutionContext;
import intradoc.common.ServiceException;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.data.Workspace;
import intradoc.shared.FilterImplementor;

public class MyFilter implements FilterImplementor
{
public int doFilter(Workspace ws, DataBinder binder,
ExecutionContext cxt) throws DataException, ServiceException
{

String title = binder.getLocal("dDocTitle");
String fileName = binder.getLocal("primaryFile");

String newFileName = title + fileName.substring(fileName.lastIndexOf("."));
binder.putLocal("primaryFile",newFileName);

return FilterImplementor.CONTINUE;
}
}

Now build the project, the class file for the above java file, should be created in the path
ucm/custom/MyFirstComponent/classes.

The class file also should be displayed in the classes folder of the proj in Eclipse IDE.

Next configure the above created filter in the component definition file. Open the MyFirstComponent.hda file located in the below location.
ucm/custom/MyFirstComponent/MyFirstComponent.hda

Configure the filters as below.
@ResultSet Filters
4
type
location
parameter
loadOrder
validateStandard
myfirstcomponent.MyFilter
null
1
@end

Select the Project in the Eclipse and click Run Configurations from the Run menu.

Run Configurations dialog box would have opened. Select Java Application from the left menu and click New icon from top.

Give it the name MyServer.
In the Main tab, for the project browse and select our project MyFirstComponent. Then for the Main class enter IdcServer.

In the Arguments tab, in the Working Directory section, select other and enter the below path.
D:\oracle\ucm\server\bin (For you it might be different). You can click FileSystem button and browse and select the directory.

In the Environment tab, click New and enter the following name-value pair
Name : PATH
Value : D:\oracle\ucm\server\shared\os\win32\lib

You can add more libraries, by separating with a semicolon. It purely depends on your project.
Click Apply and Close button.

Now we are all set to start the content server from the IDE. Click Run from the Run menu.

The content server should start in the Eclipse. Now open a browser and type the url for the application. In my case it was http://localhost/idc. Then check-in a file. The filename after check-in should be display the title that was entered during check-in.

To run the in Debug mode, just click Debug from Run menu.

Happy debugging using Eclipse for UCM applications.

Leave your comments if you have any suggestions,corrections or queries. Have a good day..

Saturday, November 6, 2010

Folder Move in Oracle UCM (Stellent)

I would like to share my experience on COLLECTION_MOVE_LOT service of Oracle UCM 10gR3. This is the service which we used for moving folders from one folder to another in our application.

There were few problems when we actually started implementing the move functionality.

First thing is that the folders that were moved and the documents under it did not inherit the metadata values from destination folder. They still retained the same metadata of the source location.

To overcome this issue, a new method was introduced at the end of all methods in COLLECTION_MOVE_LOT service. This new method's purpose is to update the metadata of the moved folders and documents as per the destination collection's metadata. For updation of metadata, we invoked the COLLECTION_UPDATE_META service from this new method.

Let me give an overview of the COLLECTION_UPDATE_META service. The COLLECTION_UPDATE_META service is used to propagate the inheritable metadata of the parent folder to all the child folders and documents under it. The propagation of the metadata to the documents is achieved by invoking the COLLECTION_UPDATE_ALL service from inside the code of the service COLLECTION_UPDATE_META.

So, when the COLLECTION_UPDATE_META service is used along with COLLECTION_MOVE_LOT to propagate the metadata of the destination folder on the folders that got moved, it introduced new problems.

One problem was that although the moved documents' metadata got updated, the web viewable files of all the documents were not physically relocated according to the destination location's account settings. So all the web-viewable files were not accessible after folder move operation. I solved this problem by commenting the code which was invoking the COLLECTION_UPDATE_ALL service and then invoked the UPDATE_DOCINFO service which updates the metadata of the documents plus physically moves the web-viewable files to the correct location.

The other problem was COLLECTION_UPDATE_META service, updates all the folders and documents under a specific folder. But our requirement was to update the metadata of only the folders that got moved and the documents under it. So we had to overwrite the setContentAsCollectionMetadata method which is the method that does the job for the service COLLECTION_UPDATE_META. I just wrote a small logic to propagate the destination folder's metadata only to the folders that got moved and the documents under it.

If you have some inputs, corrections or suggestions on this post, please leave a comment, so that I can improve my application.

Have a good day...