0 Replies Latest reply on Dec 12, 2008 10:21 PM by 675392

    Java Collaboration Suite API - Common Problems......and Solutions!

      , Hi all,

      I'd just like to share some of the issues I've come across in my first try at using the Java Collaboration Suite API (including the Accelerator Kit).

      In short,

      The Good: I've succeeded in getting a working application, and the code doesn't look half bad.
      The Bad: Man was it a pain to get to this point.

      Here are a few notes about what I've found, what can be improved by oracle, and hopefully it will help others.

      1. The initial setup went smoothly. I included the Jar's from the web kit, and was able to successfully connect using OCDConnectionFactory.CreateConnection. This first attempt didn't use the Accelerator Kit, as at the time I didn't even know it existed. As soon as I started to try any examples from Oracle, code snippets wouldn't even compile (usually due to FDKUtils and FDKSession) and I couldn't find out why. After exhaustive research, I found that the Accelerator Kit here (http://www.oracle.com/technology/products/cs/developer/contentservicesdev/contenservicesdevkit.html), but it is not a library in the lib. After even further research, I found a very interesting thing. If you click on the link I've shown, you will see 2 versions of the Accelerator Kit: The recent link just includes the kit as a bunch of classes. I found it kind of ugly to include those in my project. However, if you click on the older link you will find a jar called "content-ws-helper.jar". This is actually the Accelerator Kit in a JAR (yet without any documentation anywhere on this).

      2. When using the accelerator toolkit, the connection string you use to connect changes. It no longer should have "ws" at the end. Don't believe this is documented anywhere! So if your connection string is http://server:8888/content/ws it should be changed to http://server:8888/content/

      </strong>3. Most of the examples given are appreciated, but they are also impossible to read. Methods should not be hundreds of lines of code long! Here is a handy method that I seem to be using quite often (at least in my use cases).

      private Item getFolder(String path) throws OCSServiceException {
      try {
      FileManager fm = Managers.getFileManager(fdkSession);
      Item workspace = fm.resolvePath(path, null);
      CommonManager commonM = Managers.getCommonManager(fdkSession);
      workspace = commonM.getItem(workspace.getId(), attributeRequest);
      return workspace;
      } catch (Exception e) {
      LOGGER.error(e.getMessage(), e);
      throw new OCSServiceException("Exception getting folder");

      The key is the attributeRequest class variable. This is the object that changes depending on what properties I want to retreive regarding that folder. A commonly used one for getting categories is:

      attributeRequest = FdkUtils.newAttributeRequestArray(Attributes.CATEGORY_CONFIGURATION,
      new AttributeRequest[]{

      By seperating this out, It gets rid of a ton of the speghetti like code that you see in most of the examples and on the forums.

      For example, this thread helped me in category updates for folders http://kr.forums.oracle.com/forums/thread.jspa?threadID=495959
      , but as the post at the bottom states, this should not be the difficult. My method, which performs a similar method, is as follows:

      public void updateFolderCategory(String path, String categoryName, String categoryAttributeName, Object value ) throws OCSServiceException {
      try {
      CategoryService cs = new CategoryServiceImpl();
      long categoryId = cs.getCustomCategory(categoryName).getId();
      long attributeId = cs.getCustomAttribute(categoryName, categoryAttributeName).getId();
      NamedValue[] attOverride = new NamedValue[]{
      new NamedValue(Attributes.ATTRIBUTE_OVERRIDE_ATTRIBUTE, new Long(attributeId)),
      new NamedValue(Attributes.ATTRIBUTE_OVERRIDE_CATEGORY_CLASS, new Long(categoryId)),
      new NamedValue(Attributes.ATTRIBUTE_OVERRIDE_DEFAULT, value),

      NamedValue[] categoryConfigurationAttributes = new NamedValue[]{
      new NamedValue(Attributes.ATTRIBUTE_OVERRIDE, attOverride)
      Item folder = getFolder(path);
      Managers.getCategoryManager(fdkSession).setCategoryConfiguration(folder.getId(), categoryConfigurationAttributes);
      LOGGER.info("Updated folder category definition");
      } catch (Exception e) {
      LOGGER.error(e.getMessage(), e);
      throw new OCSServiceException("Exception updating category");
      } finally {

      I hope this information helps someone, and I'd appreciate if anyone can also add input or critique my approach. I also hope that there is someone else out there who is still using the API and hasn't given up yet!