Saturday, August 4, 2012

JDeveloper 11.1.1.6 error: Failed to validate the xml content. SchemaLocation: schemaLocation value = 'http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd' must have even number of URI's. Location: unavailable.

We can enjoy next bonus received in the package along with the JDeveloper.
This time it is XML validation error:

Failed to validate the xml content. 
SchemaLocation: schemaLocation value = 
'http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd' 
must have even number of URI's. Location: unavailable.
 

On OTN (https://forums.oracle.com/forums/thread.jspa?threadID=2376404) I found "solution":
"You have wait for the next version". Rrrrrrrrrrr.

PL/SQL How to: find info about tablespaces in oracle database

SELECT dd.tablespace_name tablespace_name, dd.file_name file_name, dd.bytes/1024 TABLESPACE_KB, SUM(fs.bytes)/1024 KBYTES_FREE, MAX(fs.bytes)/1024 NEXT_FREE
FROM sys.dba_free_space fs, sys.dba_data_files dd
WHERE dd.tablespace_name = fs.tablespace_name
AND dd.file_id = fs.file_id
GROUP BY dd.tablespace_name, dd.file_name, dd.bytes/1024
ORDER BY dd.tablespace_name, dd.file_name;

Thursday, July 12, 2012

PL/SQL How to: delete all objects in database schema

The simplest way of course is drop and recreate the user. But if you don't have SYSDBA privileges, to delete all objects in the schema you should:

  1. Prepare a series of DROP statements:
    select 'drop '||object_type||' '|| object_name||  DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';') from user_objects
    as a result, you should get:

  2. Copy a list of DROP statements to command window and run it as Script
  3. Cause of possible errors when deleting cascading objects and so on, you may have to empty recycle bin
    purge recyclebin;
    and repeat described procedure once again.

Friday, May 25, 2012

Accessing Webcenter Content repository using RIDC

My preferable way to access Webcenter Content (former UCM) repository from Java code is RIDC API. To establish RIDC connection you can use below code:

/*The Remote Intradoc Client (RIDC) provides a thin communication API 
for communication with Oracle Content Server. This API removes data 
abstractions to the content server while still providing a wrapper to 
handle connection pooling, security, and protocol specific
Intradoc communication is handled via the content server Intradoc port (typically
4444). This communication method requires a trusted connection between the
client and content*/
IdcClientManager manager = new IdcClientManager (); 

/*idc://localhost:4444 Intradoc communication. Uses the Intradoc port, 
only requires hostname and port number.
idcs://localhost:4433 SSL communication. Uses SSL over the 
Intradoc port; requires extra configuration*/
IdcClient client = manager.createClient("idc://hostname:4444");

/*Configuration of the clients can be done after they are created. Configuration
parameters include setting the socket timeouts, connection pool size, etc. The
configuration is specific to the protocol; if you cast the IdcClient object to the specific
type, you can then retrieve the protocol configuration object for that type.*/
client.getConfig().setSocketTimeout(30000); // 30 seconds
client.getConfig().setConnectionSize(20); // 20 connections

/*RIDC allows Secure Socket Layer (SSL) communication with Oracle Content Server
using the Intradoc communication protocol. To establish SSL connection you must install and enable 
the Security Providers component on the instance of the content server you wish 
to access and configure the content server for SSL communication.*/
client.getConfig().setKeystoreFile ("ketstore/client_keystore"); // keystore file
client.getConfig().setKeystorePassword ("password"); // keystore password
client.getConfig().setKeystoreAlias ("SecureClient"); // keystore aliaa
client.getConfig().setKeystoreAliasPassword ("password"); // keystore alias password

/*All calls to RIDC require some user identity. Optionally, this identity can be
accompanied by credentials as required by the protocol used. The user identity is
represented by the IdcContext object; once created, it can be reused for all subsequent
calls.*/
IdcContext context = new IdcContext("sysadmin");

/*You can also pass identity with passowrd: 
IdcContext userPasswordContext = new IdcContext ("sysadmin", "idc");*/

/*To invoke a service, use the ServiceRequest object, which can be obtained from the
client. Creating a new request will also create a new binder and set the service name in
the binder along with any other default parameters. You can then populate the binder
as needed for the request.*/
DataBinder dataBinder = client.createBinder ();

dataBinder.putLocal ("IdcService", "DOC_INFO_BY_NAME");

dataBinder.putLocal ("dDocName", "123simple");

ServiceResponse response = client.sendRequest (context, dataBinder);

DataBinder responseData = response.getResponseAsBinder ();

String docUrl = responseData.getLocal("DocUrl");