25 sept 2012

Using WebCenter REST API from Java

Most WebCenter services are available over REST access. In this example app we will try to connect to our development Spaces instance and get the list of spaces for the user.

The REST API supports two kind of different authentication, depending where you use the Java code. If you are creating a taskflow to be deployed on same domain of the spaces node, you should use "OIT" auth, this kind of auth does not need the user password on each request to the server.

Instead, if your code is outside of the weblogic domain, you must send (user + password) on each request.

This sample app have a boolean flag to enable "development-mode" that means connection from outside of weblogic domain (for example my local JDeveloper).

Keep in mind that on each request you should have the URL access to your REST API, to generate that URL you need before the userToken.

//Get the client connnection
RESTUtils rest = new RESTUtils();
rest.setDevelopmentMode(true);

//Get weblogic user token
String userToken = rest.getUserToken();

//Creation of endpoint URL
//Sample URL: http://owc:8888/rest/api/spaces?utoken=FMgUQjBKZ96NGgwGdlZrX-WJACJ4_w**
URL endpoint = new URL(RESOURCE_INDEX + UTOKEN + userToken);

//Establishing connection
HttpURLConnection connection = rest.getConnection(endpoint);

This is the sample output of the app after executing the class WCSpaces.java

5-sep-2012 10:34:33 webcenter.rest.RESTUtils getUserToken
INFO: Obtaining user token
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: We are connecting in development mode
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: Auth sent:Basic d2VibG9naWM6T3JhY2xlMTFn
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: Finished development connection to http://owc:8888/rest/api/resourceIndex
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getUserToken
INFO: Obtained token:FMgUQjBKZ96NGgwGdlZrX-WJACJ4_w**
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: We are connecting in development mode
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: Auth sent:Basic d2VibG9naWM6T3JhY2xlMTFn
25-sep-2012 10:34:33 webcenter.rest.RESTUtils getConnection
INFO: Finished development connection to http://owc:8888/rest/api/spaces?utoken=FMgUQjBKZ96NGgwGdlZrX-WJACJ4_w**
25-sep-2012 10:34:33 webcenter.rest.WCSpaces getSpaces
INFO: Space displayName:blog
25-sep-2012 10:34:33 webcenter.rest.WCSpaces getSpaces
INFO: Space displayName:test
Process exited with exit code 0.



As you see, both "displayName" of the spaces are obtained.

Here is the sample app for download.

And finally the Oracle Documentation about REST

11 sept 2012

Disable component resizing in Oracle Composer

When using Oracle Composer sometimes apper an icon under componentes that allows resizing in runtime.

Check this image






As you see, appears an icon at the botton-right of the component with an appaerance of a triangle. This icon/behaviour can be disabled editing TaskFlow properties and disabling the option.


This action should be performed every time we add a new TaskFlow so is quite annoying.

To disable all resizing behaviour in our portal we have to modify our adf-config.xml file including this lines

  <customizableComponentsSecurity xmlns="http://xmlns.oracle.com/adf/faces/customizable/config">
    <enableSecurity value="true"/>
    <actionsCategory>
      <actionCategory name="personalizeActionsCategory" value="true"></actionCategory>
      <actionCategory name="editActionsCategory" value="true"/>
      <actions>
        <action name="showResizer" value="false"/>
      </actions>
    </actionsCategory>
  </customizableComponentsSecurity>

After this modification, the components won't show the "resize" icon any more.


Sources: Oracle Documentation