Monday Jul 27, 2015

Migrating huge content repositories using Archiver

I was recently asked to migrate a WebCenter Content repository to a new instance. They had the content exported locally using the Web Archiver applet and they were copying the archive folder to every destination content server file system. The archive folder was ~300 GB in size and it took around ~6 hours to tarball the archive directory and another ~2 hours to copy the tarball to the destination content server and then another ~6 hours to extract the tarball. And this process was repeated every time we wanter to replicate the repository. 

A easier solution may have been to mount a shared volume on the source content server and export the content there. Then you could just mount this shared volume to any destination server and use it for the import. However, the Archiver web applet only allows you to have the archives under the default location in the instance directory, that is [INSTANCE_DIR]/ucm/cs/archives. The key is to run the Archiver from the console as a standalone application. The standalone version of the Archiver application is required to create new collections or browse the local file system to connect to new collections.
  1. After you have identified a location for your archive collection, say /u02/share/archives/abc, create a new file, collection.hda, under the new directory and enter the following lines. Make sure that the IDC_Name parameter does NOT match the IDC_Name for the content server instance.

    @Properties LocalData
    IDC_Name=wcc-ucm
    blDateFormat=M/d{/yy}{ h:mm[:ss]{ a}}!mAM,PM!tAmerica/New_York
    @end
    @ResultSet Archives
    2
    aArchiveName
    aArchiveDescription
    @end

  2. Start the Archiver utility as a standalone application, [DOMAIN_HOME]/ucm/cs/bin/Archiver, go to Options -> Open Archive Collection… and click Browse Local… to create a new collection location. Browse to the newly created directory and select the collection.hda file we just created, /u02/share/archives/abc/collection.hda.
    Open Archive Collection

  3. In the Browse To Archiver Collection, enter the correct paths for the vault and weblayout directories on the current system and click Ok.
    Browse to Archive Collection

  4. Once the new Archive Collection is added to the list, click Open to make it current. You can now create your new archive and export content into it.
  5. After you have completed your content export/import, make sure that you return to Options -> Open Archive Collection… and make the default Archive Collection active.
To IMPORT this archive collection on another content server, make the shared volume available on the target server and follow steps 2-5 to load the collection for import.

Monday May 11, 2015

Rule-based Classification using Oracle Text in WebCenter Content

A major problem facing businesses and institutions today is that of information overload. Sorting out useful documents from documents that are not of interest challenges the ingenuity and resources of both individuals and organizations. Given that WebCenter Content stores all the content for an organization, you would like to classify documents checked into the system.

Oracle Text offers various approaches to document classification. Under rule-based classification, you have a predefined set of categories and you write the classification rules yourself. With supervised classification, Oracle Text creates classification rules based on a set of sample documents that you pre-classify. Finally, with unsupervised classification (also known as clustering), Oracle Text performs all the steps, from writing the classification rules to classifying the documents. WebCenter Content uses Oracle Text as its underlying indexing engine when you use Database FULLTEXT or OracleTextSearch and so we should be able to use the Oracle Text approaches to classification and apply it within Content.

In this post, I will use rule-based classification where we will decide on categories, formulate the rules that define those categories, index the rules and use the MATCHES operator to classify documents.

Rule-based classification is very accurate for small document sets. Results are always based on what you define, because you write the rules which are actually query phrases. However, defining rules can be tedious for large document sets with many categories. As your document set grows, you may need to write correspondingly more rules.

The first step is to really define a list of categories and the corresponding query a document must match to be placed in that category. For the purpose of this example, we will have the following 5 categories. You will notice that the rules are simple phrases delimited by an operand.

Category Rule
Astronomy Jupiter or Earth or star or planet or Orion or Venus or Mercury or Mars or Milky Way or Telescope or astronomer or NASA or astronaut
Paleontology fossils or scientist or paleontologist or dinosaur or Nature
Health stem cells or embryo or health or medical or medicine or World Health Organization or AIDS or HIV or virus or centers for disease control or vaccination
Natural Disasters earthquake or hurricane or tornado
Technology software or computer or Oracle or Apple or Intel or IBM or Microsoft

Next create a new table within WebCenter Content using the Configuration Manager to store the categories and rules.
Create table using Configuration Manager

Create a new view on the table we just created.
Create new View using Configuration Manager

Load the categories and the rules into the table using this view.
List of Categories

Create a new metadata to store the categories. We will auto populate this metadata for a document with the categories that match the document.
Create a new Metadata using Configuration Manager

Enable option lists for the new metadata, select the option list type as Multiselect List and use the view we just created.
Enable Option List for new Metadata

Create a new database index of type CTXSYS.CTXRULE on the rule table.
Create CTXSYS.CTXRULE index in the Database

Create a new database function to return a comma separated list of categories for a document. In my example, I will use the Oracle Text indexes WebCenter Content creates as WebCenter Content is capable of extracting text from a wide variety of content including attachments in emails and files within compressed archives.
Create FUNCTION categorizeDocument in the Database

Run the following script to generate the categories for all documents that were released today. This script will also update the revisions table to mark the document record for update so that the indexer will pick it up the next time it runs.
PL/SQL Code to generate Categories

After running the script, you should see the metadata updated with the categories on the Content Information screen for any document you checked and released today.



NOTE: Please note that these code snippets are examples and should be used for research and demonstration purposes only, as such they are unsupported.

Sunday Mar 22, 2015

Drag and drop file upload using HTML5 (YUI3)

I have seen a lot of ADF applications provide drag and drop file upload capabilities. I was wondering if there was an easy way to have this on the Content Server. If you are familiar with the UI components on the Content Server, you will know that it relies a lot on YUI.

In this example, I will use YUI3 Uploader to provide drag and drop multiple file upload capability on the Content Server. I will create a simple HTML file and check it into the Content Server. Accessing it from the content server using will show a form and you will be able to upload files. If you want to have Content Server like pages, you can modify this HTML file to insert IDOC includes and save it as a HCSP file.
Upload Example Screenshot

I have used the example provided by Yahoo "Example: Multiple Files Uploader with POST Variables and Server Data Retrieval" and modified it to upload files to a Content Server.

First and foremost, you will require the following lines to include YUI3 libraries and stylesheets.
JavaScript and Stylesheet Includes

Second, create a form to capture some metadata. In this example, we will apply these metadata values to all files being uploaded together. You can also move this form to the uploader table to set metadata at the file level.
Metadata Input Form

Third, load the Uploader and the JSON libraries. Also, the Content Server expects the file bytes to be uploaded using the primaryFile field name.
Load YUI Libraries and create Instance

Fourth, set the POST variables or the metadata to be assigned to the files. In this example, we will use the same values for all files. You can have different metadata for individual files too.
Set Metadata as POST Variables

Fifth and finally, once the checkin is complete, we need to parse the JSON data and then display the Content ID.
Process Data returned from the Content Server

You can download the HTML (file_upload.htm) here.

Note:

  • According to the announcement here, Yahoo has stopped development on YUI. However, you should be able to use the concepts used here with other frameworks.
  • If your browser does not support HTML 5, for example IE <= 9, you will need to use the flash component which requires additional configuration not discussed here.
  • This uploader is not supported on iOS devices.

Saturday Mar 07, 2015

RIDC using Oracle Java Stored Procedures

Have you faced a situation where you have a database table filled with content in a BLOB column and you want to migrate them into the Oracle Content Server. If you have and you want to write a PL/SQL procedure to loop through the records and check-in the content directly into the Content Server, you can use the Oracle JVM that is configured with an Oracle Database. Then you can load your RIDC libraries and your RIDC code into the database as schema objects and then write a Java Stored Procedure.

In this example, I will explain how use a table with content in a BLOB column and check them into the Content Server. We will use two approaches, one to save the file to the disk and then checkin, and the other to keep the file in memory and checkin. Note that the in memory solution should not be used with large files.

The first step is to check if your Oracle Database has Oracle JVM enabled. Usually, it is enabled by default, otherwise, you can find instructions to enable it here.
http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfour.htm#BABEBCJA

The second step is to grant certain permissions to the schema user. In this example, I have created a new user, TEST.

CREATE USER test IDENTIFIED BY <passwd>;
GRANT ALL TO test;
EXEC DBMS_JAVA.GRANT_PERMISSION('TEST', 'java.net.SocketPermission', '*', 'connect, resolve');
EXEC DBMS_JAVA.GRANT_PERMISSION('TEST', 'java.io.FilePermission', '/tmp/file1.txt', 'read, write');

The third step and the most complicated one is to load all the required Java libraries and dependencies as database objects. This will include all the jar files that are in the RIDC library as well as the jars that contain all the classes referenced by the RIDC jars. You can download the RIDC library here. The dependency list is extensive and can be a nightmare to build; but Oracle does provide a tool to make things a bit easier.

The ojvmtc tool enables you to resolve all external references, prior to running the loadjava tool. The ojvmtc tool allows the specification of a classpath that specifies the JARs, classes, or directories to be used to resolve class references. When an external reference cannot be resolved, this tool either produces a list of unresolved references or generated stub classes to allow resolution of the references, depending on the options specified. Generated stub classes throw a java.lang.ClassNotfoundException, if it is referenced at runtime.

Please note that you will need to resolve all the dependencies for the entire modules to work. However, for this article we do not need to resolve all dependencies.

The following command will check for references and will generate stub classes for the classes it did not find. I downloaded and placed the RIDC and other jars in the "jars" directory under my home directory.

<dbhome>/bin/ojvmtc -list ~/jars/oracle.ucm.ridc-11.1.1.jar -classpath ~/jars/*.jar -jar dummy.jar -bootclasspath <dbhome>/jdk/jre/lib/rt.jar:<dbhome>/jdk/jre/lib/jce.jar:<dbhome>/jdk/jre/lib/jsse.jar

Now we are ready to load all these libraries into our schema. Run the following command to load all the jar files.

<dbhome>/bin/loadjava -verbose -resolve -user test/<passwd> ~/jars/*.jar

The fourth step is to write your Java class, compile and load it into your database schema. I will use the two methods below to checkin content.

// This method will take the file path and checkin the file
public static String checkinFile(String fPath) {
String dDocName = "";
try {
manager = new IdcClientManager();
client = (IdcClient<IdcClientConfig, Protocol, Connection>) manager.createClient("idc://10.0.0.5:4444");

IdcContext userContext = new IdcContext("sysadmin");
DataBinder binder = client.createBinder();
binder.putLocal("IdcService", "CHECKIN_NEW");
binder.putLocal("dDocTitle", "Test File - ABC000001");
binder.putLocal("dDocType", "Document");
binder.putLocal("dSecurityGroup", "Public");
binder.putLocal("dDocAccount", "");
binder.addFile("primaryFile", new TransferFile(new File(fPath)));
ServiceResponse response = client.sendRequest(userContext, binder);
DataBinder responsebinder = response.getResponseAsBinder();
dDocName = responsebinder.getLocal("dDocName");
client = null;
manager = null;
} catch (Exception e) {
// Nothing to do
dDocName = e.getLocalizedMessage();
}
return dDocName;
}
// This method will take a BLOB field and checkin in memory
public static String checkinBlob(BLOB bFile, String filename) {
String dDocName = "";
try {
manager = new IdcClientManager();
client = (IdcClient<IdcClientConfig, Protocol, Connection>) manager.createClient("idc://10.0.0.5:4444");

// Read the BLOB and create a Input Stream
// Make sure that the files are small as we are using in memory
byte[] filearray = bFile.getBytes(1, (int) bFile.length());
ByteArrayInputStream stream = new ByteArrayInputStream(filearray);

IdcContext userContext = new IdcContext("sysadmin");
DataBinder binder = client.createBinder();
binder.putLocal("IdcService", "CHECKIN_NEW");
binder.putLocal("dDocTitle", "Test File - ABC000002");
binder.putLocal("dDocType", "Document");
binder.putLocal("dSecurityGroup", "Public");
binder.putLocal("dDocAccount", "");
binder.addFile("primaryFile", new TransferFile(stream, filename, bFile.length()));
ServiceResponse response = client.sendRequest(userContext, binder);
DataBinder responsebinder = response.getResponseAsBinder();
dDocName = responsebinder.getLocal("dDocName");
client = null;
manager = null;
} catch (Exception e) {
// Nothing to do
dDocName = e.getLocalizedMessage();
}

return dDocName;
}

Run the following command to load the class file.

<dbhome>/bin/loadjava -verbose -f -resolve -user test/<passwd> ~/jars/CheckinFileIntoContentServer.class

Oracle DB Commands

The fifth step is to create PL/SQL functions that use the Java methods from the class we just loaded.

  CREATE
      OR
 REPLACE
FUNCTION test.checkinFile(fPath IN VARCHAR2)
  RETURN VARCHAR2
      AS LANGUAGE JAVA
    NAME 'com.oracle.justin.wcc.CheckinFileIntoContentServer.checkinFile(java.lang.String) return java.lang.String';

  CREATE
      OR
 REPLACE
FUNCTION test.checkinBlob(bFile IN BLOB, filename IN VARCHAR2)
  RETURN VARCHAR2
      AS LANGUAGE JAVA
    NAME 'com.oracle.justin.wcc.CheckinFileIntoContentServer.checkinBlob(oracle.sql.BLOB, java.lang.String) return java.lang.String';

The sixth step is to create and insert two rows with content into the table.

CREATE TABLE TEST.blob_table (
  fileid INTEGER NOT NULL,
  filename VARCHAR2(255) NOT NULL,
  filedata BLOB
);

The seventh and the final step is to loop through the table and checkin the files.

  -- Save the file to a temporary location
  -- and checkin the file
  SELECT filename,
         filedata
    INTO filename,
         vblob
    FROM blob_table
   WHERE fileid = 1;
  lbloblen := DBMS_LOB.getlength(vblob);
  lfile := UTL_FILE.FOPEN('TEMP_DIR', 'file1.txt', 'w', 32767);
  WHILE lpos < lbloblen LOOP
    DBMS_LOB.READ(vblob, lamount, lpos, lbuffer);
    UTL_FILE.PUT_RAW(lfile, lbuffer, TRUE);
    lpos := lpos + lamount;
  END LOOP;
  UTL_FILE.FCLOSE(lfile);
  DBMS_OUTPUT.PUT_LINE ('dDocname: ' || CHECKINFILE('/tmp/' || filename));

  -- IN MEMORY file checkin
  SELECT filename,
         filedata
    INTO filename,
         vblob
    FROM blob_table
   WHERE fileid = 2;
   DBMS_OUTPUT.PUT_LINE ('dDocname: ' || CHECKINBLOB(vblob, filename));

After the PL/SQL is executed, you should see two files in your Content Server with metadata that was coded in the Java class.

You can download the source files below:

NOTE: Please note that these code snippets should be used for development and testing purposes only, as such it is unsupported and should not be used on production environments.

Sunday Feb 08, 2015

RIDC using Jython Scripts

Jython is an implementation of Python for the JVM. Jython takes the Python programming language syntax and enables it to run on the Java platform. This allows seamless integration with the use of Java libraries and other Java-based applications. Plus it helps to have a loosely typed interpreted language as it makes writing code much faster.

I have written a set of scripts to execute some core Content Server services to check-in, update, delete content items and to browse, create, delete, link items using FrameworkFolders. You can download the scripts here.

JythonWCCAllExampleScripts.zip

Checkin new Content and a Revision
Update Metadata
Delete a single revision and all revisions
FrameworkFolders: Create Folder
FrameworkFolders: Create Shortcuts
FrameworkFolders: Browse Folders
FrameworkFolders: Copy Items
FrameworkFolders: Move Items
FrameworkFolders: Delete Items
FrameworkFolders: Propagate Metadata
FrameworkFolders: Remove (unfile) content from a folder

NOTE: Please note that these code snippets should be used for development and testing purposes only, as such it is unsupported and should not be used on production environments.

Tuesday Feb 03, 2015

Using Access Control Lists in WebCenter Content

WebCenter Content offers a comprehensive security model using its traditional Security Groups and Account metadata fields. Each content item is assigned to a security group, and if accounts are enabled then content items can also be assigned to an account. Users are assigned a certain level of permission (Read, Write, Delete, or Admin) for each security group and account, which enables them to work with a content item only to the extent that they have permissions to the item's security group and account.

At times, these constructs do not meet the requirements and you have to look at additional security options available within the Content Server. I prefer to choose one or more options in the order listed below. In my opinion, as you start moving down the list, the computational overheard on the Content Server increases (User ACL puts the most overhead).
  1. Security Groups and Roles
  2. Accounts
  3. Supplemental Markings (Records Management)
  4. NeedToKnow Component
  5. Role ACL
  6. Group ACL
  7. Oracle Entitlement Server
  8. User ACL
Follow the instructions below to setup Access Control Lists on your Content Server and configure them.
  1. Login to the Content Server as an Administrator.
  2. Navigate to the Administration -> Admin Server -> General Configuration page.
  3. Under the Additional Configuration Variables section, add the following lines. You can also add the lines directly to the <INSTANCE_HOME>/cs/config/config.cfg file.
    UseEntitySecurity=true
    SpecialAuthGroups=<comma separated list of security groups>
    # ZonedSecurityFields=xClbraUserList,xClbraAliasList,xClbraRoleList
    AllowQuerySafeUserColumns=true
    # AccessListPrivilegesGrantedWhenEmpty=true
  4. Restart the Content Server.
  5. Login to the Content Server as an Administrator.
  6. Navigate to the Administration -> Admin Applets -> User Admin applet.
  7. Go to the Aliases tab, and add aliases for the groups that you want to list in the Group Access List metadata. Note that the Group Access List metadata is really a Alias Access List and does NOT correspond to a LDAP group but a Content Server internal Alias.
  8. If you want to use LDAP groups, for your ACLs, you will need to enable the RoleEntityACL component. This component is already installed but needs to be enabled. Restart the Content Server after this change.
  9. Navigate to the Administration -> Admin Applets -> Configuration Manager applet.
  10. Go to the Views tab and locate the ExternalRolesView view. Add the LDAP groups that you want to use for the Role ACL to this list.
NOTE: The User Access List type-ahead field will only display users that have logged into the Content Server at least once. The Group Access List type-ahead field will only display Aliases defined in the Content Server. The Role Access List type-ahead field will only display groups defined in the ExternalRolesView view. You will need to make sure that a corresponding group with the same name exists in LDAP.

Monday Oct 13, 2014

How to: Using the ComponentTool utility to manage Content Server components

I have been asked multiple times, primarily by people who want to implement some sort of a MWaaS for WebCenter Components, how to install and/or enable WebCenter Content Components using a script.

One of the tools you can use to script this activity is the ComponentTool utility, which is installed by default. The executable is located in the <domainhome>/ucm/cs/bin/ directory. The ComponentTool component enables administrators to use a command line to install, enable, and disable components.

I have listed the options and commands available with the ComponentTool utility in the table below:

Activity Command
Enable a Component ComponentTool [-v|-vv] [-t trace_section ] --enable <component_name>

For example,
   <DomainHome>/ucm/cs/bin/ComponentTool -vv --enable ContentFolios
Disable a Component ComponentTool [-v|-vv] [-t trace_section ] --disable <component_name>

For example,
   <DomainHome>/ucm/cs/bin/ComponentTool -v --disable ContentFolios
List Components ComponentTool [-v|-vv] [-t trace_section ] --list-enabled|--list-disabled|--list
Install a New Component ComponentTool [-v|-vv] [-t trace_section ] --install <component_name>.hda|<component_name>.zip [ --preferences <component_name_prefs>.hda ]

For example,
   <DomainHome>/ucm/cs/bin/ComponentTool -vv --install /tmp/sccomponent01.zip
Help ComponentTool [-v|-vv] [-t trace_section ] --help

Thursday Jul 03, 2014

iOS app for WebCenter Content

I have the habit of browsing through the Apple AppStore on my iPhone to discover new apps and give them a try. I usually look for new games but today I thought I will try the app for WebCenter Content. Finding the app was straight forward; I just needed to search for WebCenter Content and a few apps popped up. The first one from Oracle is what I was looking for.

I open the app to get a login screen. It requires a username, password and the URL of the content server you want to connect to. I used the URL in the format http[s]://hostname[:port]/cs/idcplg and soon enough was connected to it.

The app itself is fairly simple, with basic functions for searching (includes full-text), browsing and viewing documents with native device support. I have compiled a few screenshots of the app.

[Read More]

Monday Jun 16, 2014

How to: Skip the WebCenter Content Post-Installation Configuration page

Ever wondered how to perform the Content Post-Installation Configuration silently. I am referring to the additional configuration step just after completing the WebLogic domain configuration. When you start the Content managed server for the first time, you are required to specify the instance location and several other parameters. After entering these values, the managed servers needs to be restarted.

Post Installation Configuration Page for Content Server

What if there was a way you could start the managed server for the first time and begin using the application? Well there is; just follow the instructions below:

  1. After you have created the domain configuration, with one content managed server in my case, do not start the Content managed server yet.
  2. Create a new file, <DOMAIN_HOME>/ucm/cs/bin/autoinstall.cfg. This is the file that gets created once you submit the Post-Installation Configuration page.
  3. This file contains the configuration entries that you enter on the post install page for your instance. Edit the autoinstall.cfg file to add the following mandatory entries:
    • IDC_Name=<name>
    • IDC_ID=<id>
    • AutoInstallComplete=true
  4. Edit the autoinstall.cfg file to append one or more entries to configure your instance.
    • IntradocDir=<path>
    • VaultDir=<path>/vault
    • WeblayoutDir=<path>/weblayout
  5. Start the Content managed server now and log in.

Refer to the IDOC Script Reference Guide for information on these parameters and to discover other parameters that you can use.

NOTE: Please note that these instructions should be used for development and testing purposes only.

Monday Jun 09, 2014

FrameworkFolders support for WebCenter Portal

Oracle WebCenter Content Server includes components that provide a hierarchical folder interface, similar to a conventional file system, for organizing and managing some or all of the content in the repository. We used Contribution Folders (folders_g) which is being replaced by the new Folders (FrameworkFolders) component. The newer FrameworkFolders component fixes a number of limitations that folders_g had and adds a ton of new features. If you have played with the WebCenter Content mobile app, you will notice that it uses FrameworkFolders too.

WebCenter Portal requires the use of the folders_g component. Given the fact that folders_g and FrameworkFolders component do not go well together and must never be enabled together on any system, you could never use the new features if you planned to use integrate Content with Portal. I still remember presenting a demo with a colleague for a client and he was showing off the mobile capabilities in Portal (which are pretty impressive by the way) and was getting all the glory; while I was sitting back wanting to show off the Content app but could not (no FrameworkFolders).

Not any more; Oracle has released bundle patches for both WebCenter Content and Portal in April 2014 which bring home the support for FrameworkFolders. These patches will bring these products to version 11.1.1.8.3.

You can enable support for FrameworkFolders on new Content and Portal installations where the folders_g component has never been enabled using the following patches:

  • Download and apply the WebCenter Content MLR05 patch 18448219.
  • Download and apply the WebCenter Portal BP3 patch 18085041.
  • Download and apply the WebCenterConfigure component patch 18387955. Before applying this patch on the Content Server ensure that WebCenter Content MLR03 patch 18448219 has already been applied.

You can find detailed instructions on how to enable FrameworkFolders support in the Oracle® Fusion Middleware Installation Guide for Oracle WebCenter Portal 11g Release 1 (11.1.1.8.3).

There may be another bundle patches release (version 11.1.1.8.4) for many FMW products (including WebCenter Portal) in July 2014 which could further enhance the FrameworkFolders support.

Saturday Jun 07, 2014

A strong component keeps everything together

Most of the times you implement a WebCenter Content based system, you require some sort of customization. Sometimes these customizations need a Java class or two, or libraries (for example, the JavaMail API), or Database Objects (like new tables, views, indexes, etc).

I have seen that libraries and Database Objects are usually put in place using manual steps. This means that the library jar files are copied to one of the common classes directory (set in the Content CLASSPATH variable) and/or the database scripts are executed manually. I have also seen people place the custom Java classes in the common classes directory.

While this may seem like an easy solution, think about a scenario where you need to disable or uninstall the component or if you have to upgrade or migrate the system. You have to keep these manual steps documented and execute them every time you encounter the above scenarios. It is very common that some of these manual steps are missed when you have multiple teams and people working on the system.

Here are a few points to ponder upon:

  • Place all your custom Java classes within your component. Create a new directory, say ${COMPONENT_DIR}/classes, and place your code there. You can choose to bundle all your classes into a jar or you can place the entire class directory structure. Add a path entry to the Build Settings so that it is bundled with the component when you build it. You also need to update the Custom Class Path and the Custom Class Path Load Order under the Advanced Build Settings. This will ensure that the system CLASSPATH is updated to add this new directory.
  • Create a new component for any new library that you want to add. Add the appropriate path entries to the Build Settings so that it is bundled with the component when you build it. You also need to update the Custom Class Path, Custom Class Path Load Order and/or the Custom Library Path under the Advanced Build Settings. Enter a comma separated list of features that this component will provide. When you create other components that will use the features exposed by this component, make sure that you specify a dependency to this library component by specifying the comma separated list of features in the Advanced Build Settings.
  • The component wizard allows you to create custom install/uninstall Java code. The wizard will create a install filter class when you check the “Has Install” checkbox on the “Install/Uninstall Settings” tab. Consider using this filter class to create database objects when you install the component and drop the objects when you uninstall the component. If you do a lot of custom component development, consider creating a install/uninstall Java class, which can execute queries defined within the component.

To sum up, whenever you write a new custom component, make sure that you bundle everything within the component.

Tuesday May 13, 2014

How to: Create a Custom Component to build a new Content Server page and modify the System Menu

The Oracle Content Server provides a framework to create and/or modify functionality through components. Almost everything within the Content Server can be customized using components right from the user interfaces like the checkin screens, to the core content server functionality (involves Java programming).

The best way to create and modify components is to use the Component Wizard utility which is shipped along with the content server. The Component Wizard provides all the tools and resources required to create components as well as bundle them for deployment to different content servers. You may also use Mozilla Firefox with the Web Developer extension, for creating/modifying user interfaces as it is a wonderful tool to check your JavaScripts and CSS. Although, components can be created without the Wizard, I would highly recommend it as it makes the life of the developer easy.

In this post, I will demonstrate how to add a new Navigation Menu item to the content server. The new menu item will display a new content server page that will execute a service to run a query to fetch the list of content types available within the Content Server. After creating and installing the custom component, the Content Server will show additional menus for the new page created (as shown in the screenshot below).


Create a Resource - HTML Include/String to add the new Menu Item

  1. Start the Component Wizard. On the Component List dialog, click on the Add... button.

  2. Name the new component as SampleComponent01 and keep the rest of the values as is.

  3. Click Ok to create the component and open it up in the Component Wizard.
  4. Add a new resource to add the new menu item. Under the Resource Definition tab, click on the Add... button.
  5. In the Add resource dialog, select the Resource - HTML Include/String Type. Accept the defaults for all the other fields.

  6. Click Next.
  7. In the Add HTML Resource Include/String dialog, create a Data Include. This is the new way to edit navigation items in 11g. Please note that prior to 11g, the NavBuilder JavaScript API was used to tweak the navigation items which is now deprecated in 11g. The new method takes advantage of a new data table construct in 11g Idoc Script called Dynamic Data Tables. These allow you to create tables of data in Idoc Script and dynamically change them as opposed to the static table definitions. This is useful for data that changes frequently and may be user specific like the navigation menu.
  8. Select the Data Include checkbox.
  9. Click Finish.
  10. This will create the resource file and will open it up in the Text Editor for editing.
  11. Enter the following code and save the file. The file will look like the image below. Alternatively, you can also use the wizard to create these data includes. The section on the right hand side allows you to create these includes. I prefer the Text Editor method as it is faster.
  12. To view the results, enable the component and restart the Content Server. Go to Options -> Enable and restart the Content Server.
  13. Log in to the Content Server to view the changes.

Create a Query to fetch the list of Content Types

  1. Return to the Component Wizard.
  2. Under the Resource Definition tab, click on the Add... button.
  3. In the Add resource dialog, select the Query Type. Accept the defaults for all the other fields.
  4. Click Next.
  5. In the Add Query Table Information click Next.
  6. In the Add Query dialog, enter the Name and the Query. Here you can also specify parameters for the query just like you would create a PreparedStatement in Java. The query should have "?" for the parameters. Specify the parameters in the Parameters section below. The sequence of the parameters is defined by the order in the Parameters list.
  7. Click Finish.
  8. You can add more queries to the file by directly editing the file or using the wizard options on the right hand side.

Create a Template to display the Resultset

  1. In the Component Wizard, create a template. A template is nothing but a page that will display the final results of a service call. We will create the template before we create the service.
  2. Before starting with the template, we need to layout the page. What we are trying to do here is display the content types as a table. Since we will be executing a query, we need a resultset to loop through the results. Let us say that the resultset name is SC01DOCTYPES for now.
  3. Under the Resource Definition tab, click on the Add... button.
  4. In the Add resource dialog, select the Template Type. Accept the defaults for all the other fields.
  5. In the Add Template Table Information dialog, keep the default details as is and click Next.

  6. In the Add IntradocTemplate dialog, enter the details as given below:
  7. Click Finish.
  8. Click on the Launch Editor... button on the right hand side to open up the newly created template and make the changes shown below.
  9. Save the File and close the external editor. Note that we are looping through the resultset name that we had decided earlier.

Create a Service to execute the query and populate the Resultset

  1. In the Component Wizard, create a new service. This service will execute the query created above and will redirect the results to the new template. The results of the query will be populated into a RESULTSET named above, that is SC01DOCTYPES.
  2. Under the Resource Definition tab, click on the Add... button.
  3. In the Add resource dialog, select the Service Type. Accept the defaults for all the other fields.
  4. In the Add Service Table Information dialog, keep the default data and click Next.
  5. In the Add Service dialog, enter the details as shown below.
  6. In the Actions section, click on the Add... button and fill in the details as shown below. Note that the parameter field has the Resultset name. This will allow the service to populate the query results into a resultset with this name.
  7. Click Ok and Ok again to create the Service.
  8. Restart the Content Server.

Use existing HTML includes to build a standard Content Server page

  1. Return to the Component Wizard and select the template from the Resource Definition list.
  2. Select the SC01_CONTENT_TYPES template from the right hand side box and click on the Launch editor... button at the bottom.
  3. This opens up the template in the text editor. Update the code to include the the following.
  4. What we have done here is include a set to predefined system includes that are used to build any content server page.
  5. Restart the content server.
  6. Log in to the Content Server to view the component in action. Just use the link, http://localhost:16200/cs/idcplg?IdcService=SC01_GET_DOCTYPES(make sure that you replace localhost:16200 with the hostname and port of your instance) and view the page to see the results.
About

Welcome to my blog. I use this site to share my experience as well as tips and tricks on Oracle Fusion Middleware products.

Contributors

Search

Archives
« August 2015
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     
Today