After configurations migrations today I describe you a precedure to transfer documents and files between two instances of Oracle UCM/WebCenter Content.
I suggest you to have a look at this guide: Content Server - System Migration Guide 10g Release 3 (10.1.3.3.0)
To perform a Document transfer you need (at least) two instances of Oracle UCM with different IDC_Names; as stated in the guide linked above you cannot perform this transfer if instances have the same name because the procedure cannot recognize if you wish to perform a transfer to the local or remote instance.
Local instance will be called Source while remote instance will be called Destination, so we will perform a document transfer from Source to Destination.
Let's start adding an outgoing provider from Source instance which points to Destination instance.
Login Source -> Administration ->Providers -> Outoing -> Add
Set the values according to Destination configuration.
Destination configuration can be seen under Administration -> Configuration for DESTINATION_INSTANCE_NAME -> Show Server Configurations
When done you will be prompted to restart the instance. After UCM restart login to Source instance and under Administration -> Providers you will ses this:
Now it's time to create a new archive to be transferred from Source to Destination.
In Source instance go to Administration -> Admin Applets -> Archiver -> Edit -> Add
Let's populate our archive with documents we need to transfer to Destination. Select the archive you just created and move to Export Data tab, then press Edit button.
Choose wich documents you wish to export.
Then export them with Actions -> Export
We have our archive in Source instance. We need to create an empty archive on Destination instance in which our content will be transferred.In Destination instance go to Administration -> Admin Applets -> Archiver -> Edit -> Add
Make it targetable.Go to Transfer To tab, Edit button, then check "Is targetable" flag.
Finally login to Source instance again, select our archive, Transfer To tab, click Edit button
Select Destination instance and Target archive.
Finally transfer files going to Actions -> Transfer
That's all!!
martedì 10 luglio 2012
lunedì 9 luglio 2012
Oracle UCM: Download Documents from UCM to your PC using RIDC
In this post I provide another functionality to download files from Content Server to your PC using RIDC.
Please note that Perform Documents Check-In using Remote IntraDoC (RIDC) contains the prerequisite code since in this post I don't provide the full java code but just additions.
This is a simple code snippet that downloads a single file from Oracle UCM to your PC.
Add a new method to our already discussed UCMAdapter.java
public InputStream getFile(String username, String documentId) {
ServiceResponse severiceResponse = null;
try {
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
dataBinderReq.putLocal("IdcService", "GET_FILE");
dataBinderReq.putLocal("dID", documentId);
severiceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
InputStream is = severiceResponse.getResponseStream();
System.out.println("GET_FILE size: " + is.available());
return is;
} catch(Exception ex) {
System.out.println("Error GetFile(): " + ex.getMessage());
}
return null;
}//-
Then recreate an empty file Main.java and paste this code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
public class Main {
public static void main(String[] args) {
//EDIT THESE VARIABLES
//ID of the file to retrieve
String docID="6231";
//Where to download file
String fileSaveLocation = "C:\\file.pdf";
//User who performs file download
String username = "weblogic";
//
//Instanciate objects
UCMAdapter ucm = new UCMAdapter();
new Document();
//Download file
try
{
File f=new File(fileSaveLocation);
InputStream inputStream= ucm.getFile(username, docID);
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();
inputStream.close();
System.out.println("\n File correctly created.");
}
catch (IOException e){
System.out.println("\n Error creating file.");
}
}//
}//end class
Note that in the code above you need to set some variables.
docID = "6231"
Is the Document ID of the document we want to download to our PC. You can modify this code in a more elegant way which performs a document search and automatically retrieves Document ID of the file you need to download.
fileSaveLocation = "C:\\file.pdf"
Is the path where you download the file and which kind of file extension you are retrieving...this is a really basic code, you may need to introduce a more sophisticated feature like perform a check of file extension directly from Content Server and automatically set this variable using the appropriate file name and extension based on file extension readed from UCM.
Finally
username = "weblogic"
Is the username who performs file dowload.
That's all!!
Please note that Perform Documents Check-In using Remote IntraDoC (RIDC) contains the prerequisite code since in this post I don't provide the full java code but just additions.
This is a simple code snippet that downloads a single file from Oracle UCM to your PC.
Add a new method to our already discussed UCMAdapter.java
public InputStream getFile(String username, String documentId) {
ServiceResponse severiceResponse = null;
try {
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
dataBinderReq.putLocal("IdcService", "GET_FILE");
dataBinderReq.putLocal("dID", documentId);
severiceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
InputStream is = severiceResponse.getResponseStream();
System.out.println("GET_FILE size: " + is.available());
return is;
} catch(Exception ex) {
System.out.println("Error GetFile(): " + ex.getMessage());
}
return null;
}//-
Then recreate an empty file Main.java and paste this code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
public class Main {
public static void main(String[] args) {
//EDIT THESE VARIABLES
//ID of the file to retrieve
String docID="6231";
//Where to download file
String fileSaveLocation = "C:\\file.pdf";
//User who performs file download
String username = "weblogic";
//
//Instanciate objects
UCMAdapter ucm = new UCMAdapter();
new Document();
//Download file
try
{
File f=new File(fileSaveLocation);
InputStream inputStream= ucm.getFile(username, docID);
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();
inputStream.close();
System.out.println("\n File correctly created.");
}
catch (IOException e){
System.out.println("\n Error creating file.");
}
}//
}//end class
Note that in the code above you need to set some variables.
docID = "6231"
Is the Document ID of the document we want to download to our PC. You can modify this code in a more elegant way which performs a document search and automatically retrieves Document ID of the file you need to download.
fileSaveLocation = "C:\\file.pdf"
Is the path where you download the file and which kind of file extension you are retrieving...this is a really basic code, you may need to introduce a more sophisticated feature like perform a check of file extension directly from Content Server and automatically set this variable using the appropriate file name and extension based on file extension readed from UCM.
Finally
username = "weblogic"
Is the username who performs file dowload.
That's all!!
venerdì 6 luglio 2012
Oracle UCM: Perform Document Search using RIDC
This post is a continuation of the previous post Perform Documents Check-In using Remote IntraDoC (RIDC) and explains how to perform a search among all documents in a Content Server using RIDC library.
For this code I assume you have already all three java classes as stated here:
Perform Documents Check-In using Remote IntraDoC (RIDC)
We need to add a new method to UCMAdapter.java class.
Copy paste this code:
//This method search for all documents in Content Server with a given title
public List<Document> search(String username, String title) {
System.out.println("Search Username: " + username);
ServiceResponse serviceResponse = null;
List<Document> list = new ArrayList<Document>();
try {
StringBuilder query = new StringBuilder();
//If title is not null build the query
if (title != null) {
query.append("dDocTitle <matches> `");
query.append(title);
query.append("`");
}
System.out.println("Search Query: " + query.toString());
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
//Perform the search using IDC Service GET_SEARCH_RESULTS
dataBinderReq.putLocal("IdcService", "GET_SEARCH_RESULTS");
dataBinderReq.putLocal("QueryText", query.toString());
//Display first 100 results
dataBinderReq.putLocal("ResultCount", "100");
serviceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
DataBinder dataBinderRes = serviceResponse.getResponseAsBinder();
DataResultSet resultSet = dataBinderRes.getResultSet("SearchResults");
//Add results to a list
for (DataObject dataObject : resultSet.getRows()) {
Document d = new Document();
d.setContentId(dataObject.get("dDocName"));
d.setDocumentId(dataObject.get("dID"));
d.setOwner(dataObject.get("dDocAuthor"));
d.setTitle(dataObject.get("dDocTitle"));
list.add(d);
}
} catch(Exception ex) {
System.out.println("Error Search: " + ex.getMessage());
} finally {
if (serviceResponse != null) {
serviceResponse.close();
}
}
return list;
}//
To perform a search we need a new main class. Overwrite previously created Main.java with this code:
import java.util.List;
public class Main {
public static void main(String[] args) {
UCMAdapter ucm = new UCMAdapter();
new Document();
//Here we search for all documents with a title of "Document Title". Weblogic is the user who perform the search
List<Document> docs = ucm.search("weblogic", "Document Title");
for (Document item : docs) {
item.getDocumentId();
//As output returns Document ID, Document Title and Document Owner
System.out.println(item.getDocumentId() +" "+ item.getTitle() +" "+ item.getOwner());
}
}
}//
That's all!
For this code I assume you have already all three java classes as stated here:
Perform Documents Check-In using Remote IntraDoC (RIDC)
We need to add a new method to UCMAdapter.java class.
Copy paste this code:
//This method search for all documents in Content Server with a given title
public List<Document> search(String username, String title) {
System.out.println("Search Username: " + username);
ServiceResponse serviceResponse = null;
List<Document> list = new ArrayList<Document>();
try {
StringBuilder query = new StringBuilder();
//If title is not null build the query
if (title != null) {
query.append("dDocTitle <matches> `");
query.append(title);
query.append("`");
}
System.out.println("Search Query: " + query.toString());
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
//Perform the search using IDC Service GET_SEARCH_RESULTS
dataBinderReq.putLocal("IdcService", "GET_SEARCH_RESULTS");
dataBinderReq.putLocal("QueryText", query.toString());
//Display first 100 results
dataBinderReq.putLocal("ResultCount", "100");
serviceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
DataBinder dataBinderRes = serviceResponse.getResponseAsBinder();
DataResultSet resultSet = dataBinderRes.getResultSet("SearchResults");
//Add results to a list
for (DataObject dataObject : resultSet.getRows()) {
Document d = new Document();
d.setContentId(dataObject.get("dDocName"));
d.setDocumentId(dataObject.get("dID"));
d.setOwner(dataObject.get("dDocAuthor"));
d.setTitle(dataObject.get("dDocTitle"));
list.add(d);
}
} catch(Exception ex) {
System.out.println("Error Search: " + ex.getMessage());
} finally {
if (serviceResponse != null) {
serviceResponse.close();
}
}
return list;
}//
To perform a search we need a new main class. Overwrite previously created Main.java with this code:
import java.util.List;
public class Main {
public static void main(String[] args) {
UCMAdapter ucm = new UCMAdapter();
new Document();
//Here we search for all documents with a title of "Document Title". Weblogic is the user who perform the search
List<Document> docs = ucm.search("weblogic", "Document Title");
for (Document item : docs) {
item.getDocumentId();
//As output returns Document ID, Document Title and Document Owner
System.out.println(item.getDocumentId() +" "+ item.getTitle() +" "+ item.getOwner());
}
}
}//
That's all!
giovedì 5 luglio 2012
How To Expand LVM Volume
One of the great features of Oracle Linux is that it uses by default Logical Volume to group physical volumes.
This means that if we ran out of disk space we can add another disk, physical hard drive or virtual disk if we are on a guest VM, and expand the original volume increasing available space.
Log in to your machine and run "df -h" and write somewhere the output it produces:
[root@orcl ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_orcl-lv_root 118G 21G 92G 19% /
/dev/mapper/vg_orcl-lv_home 5.0G 1.7G 3.0G 36% /home
tmpfs 1.5G 0 1.5G 0% /dev/shm
/dev/xvda1 485M 51M 409M 12% /boot
as you can see we have:
Volume Group= vg_orcl
Logical Volume= lv_root and lv_home
Based on what we would like to expand we will use either lv_root or lv_home.
In this post I need to increase disk space for expanding a database tablespace. Since Database is installed on "/u01" directory I need to expand the Logical Volume lv_root which has a mount point of "/".
Power off machine (or VM guest in my case) and attach to it new physical hard drive or virtual disk.
Now we need to boot the machine using a Live CD since we have to do some stuff on partitions and we can't do it if partitions are mounted.
I use RescueLinux which is a pretty small Live CD.
When booted from LiveCD:
[root@orcl ~]# fdisk /dev/sdb (OR /dev/sdc OR /dev/sdd if you add your second or third hard disk)
Press n for creating new partition
Press p for primary
Press 1
Press enter
Press enter
Press t for partition type and choose 8e for LVM
Press w to write changes
[root@orcl ~]# lvm
lvm> pvcreate /dev/sdb1 (OR /dev/sdc1 OR /dev/sdd1 if you add your second or third volume)
Physical volume "/dev/sda1" successfully created
lvm> vgextend vg_orcl /dev/sdb1
Volume group "vg_orcl" successfully extended
lvm> lvextend -l +100%FREE /dev/vg_orcl/lv_root
Extending logical volume lv_root to 250.47 GB
Logical volume lv_root successfully resized
[root@orcl ~]# e2fsck –f /dev/vg_orcl/lv_root
[root@orcl ~]# resize2fs /dev/vg_orcl/lv_root
Reboot and remove LiveCD.
Run "df -h" and if everything went fine you will have increased available disk space on VolumeGroup.
This means that if we ran out of disk space we can add another disk, physical hard drive or virtual disk if we are on a guest VM, and expand the original volume increasing available space.
[root@orcl ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_orcl-lv_root 118G 21G 92G 19% /
/dev/mapper/vg_orcl-lv_home 5.0G 1.7G 3.0G 36% /home
tmpfs 1.5G 0 1.5G 0% /dev/shm
/dev/xvda1 485M 51M 409M 12% /boot
as you can see we have:
Volume Group= vg_orcl
Logical Volume= lv_root and lv_home
Based on what we would like to expand we will use either lv_root or lv_home.
In this post I need to increase disk space for expanding a database tablespace. Since Database is installed on "/u01" directory I need to expand the Logical Volume lv_root which has a mount point of "/".
Power off machine (or VM guest in my case) and attach to it new physical hard drive or virtual disk.
Now we need to boot the machine using a Live CD since we have to do some stuff on partitions and we can't do it if partitions are mounted.
I use RescueLinux which is a pretty small Live CD.
When booted from LiveCD:
[root@orcl ~]# fdisk /dev/sdb (OR /dev/sdc OR /dev/sdd if you add your second or third hard disk)
Press n for creating new partition
Press p for primary
Press 1
Press enter
Press enter
Press t for partition type and choose 8e for LVM
Press w to write changes
[root@orcl ~]# lvm
lvm> pvcreate /dev/sdb1 (OR /dev/sdc1 OR /dev/sdd1 if you add your second or third volume)
Physical volume "/dev/sda1" successfully created
lvm> vgextend vg_orcl /dev/sdb1
Volume group "vg_orcl" successfully extended
lvm> lvextend -l +100%FREE /dev/vg_orcl/lv_root
Extending logical volume lv_root to 250.47 GB
Logical volume lv_root successfully resized
[root@orcl ~]# e2fsck –f /dev/vg_orcl/lv_root
[root@orcl ~]# resize2fs /dev/vg_orcl/lv_root
Reboot and remove LiveCD.
Run "df -h" and if everything went fine you will have increased available disk space on VolumeGroup.
mercoledì 4 luglio 2012
Oracle UCM: Migrate Configurations Between Servers
In this post I will create a configuration bundle which is a file containing most of the Content Server configurations such as metadata fields, workflows, users, etc. and is a pretty useful way to rapidly migrate configurations from one
WebCenter Content server to another. It's pretty valuable as a backup too in case of disater recovery.
In order to save all configurations of an Oracle UCM istance you need to login as administrator.
In menu expand "Config Migration Admin" folder then click "Configuration Templates" -> "Create New Template"
In next screen CHECK "Continue on Error" and click "Content Server Sections" to specify which configurations you want to migrate.
Click all "Section Name" you wish to include in configuration bundle, then remember to save you bundle.
When prompted to save provide a Name and an optional description
CHECK every item you wish to migrate then remember to save modifications
When done select "Export" to convert the export template to a configuration bundle.
To save it to a safe place or to transfer it to a different Oracle installation you need to download it first
If you import it to a different UCM server go to "Config Migration Admin" -> "Upload Bundle", select bundle file
previously exported and CHECK "Force Overwrite"
Go to "Configuration Bundles" select the just uploaded bundle click "Preview"
If everything is as desired click "Import" and wait until configuration completion.
That's all!!
WebCenter Content server to another. It's pretty valuable as a backup too in case of disater recovery.
In order to save all configurations of an Oracle UCM istance you need to login as administrator.
In menu expand "Config Migration Admin" folder then click "Configuration Templates" -> "Create New Template"
In next screen CHECK "Continue on Error" and click "Content Server Sections" to specify which configurations you want to migrate.
Click all "Section Name" you wish to include in configuration bundle, then remember to save you bundle.
When prompted to save provide a Name and an optional description
CHECK every item you wish to migrate then remember to save modifications
When done select "Export" to convert the export template to a configuration bundle.
To save it to a safe place or to transfer it to a different Oracle installation you need to download it first
If you import it to a different UCM server go to "Config Migration Admin" -> "Upload Bundle", select bundle file
previously exported and CHECK "Force Overwrite"
Go to "Configuration Bundles" select the just uploaded bundle click "Preview"
If everything is as desired click "Import" and wait until configuration completion.
That's all!!
martedì 3 luglio 2012
Error: Acquire running lock failed: 256
I recently encountered this problem on a guest VM running on OVM 3.1.1.
The Oracle VM Manager stated machine status as UNKNOWN so I could not start nor stop the VM giving me error while performing any operation on it.
Further investigation above task details returned this error:
Error: Acquire running lock failed: 256
I connected via SSH to one of Oracle VM servers and run the following command:
[root@orclvmsrv1 ~]# xm list
Name ID Mem VCPUs State Time(s)
0004fb00000600007fbdb52a1b566a74 15 4096 1 -b---- 229.6
Domain-0 0 726 12 r----- 62921.7
This command returns all VMs (referred by VM ID) and theyr corresponding state.
For further informations on xm command I suggest you to visit this page: xm man
To stop the guest VM run:
xm shutdown VIRTUAL_MACHINE_ID
In this case:
[root@orclvmsrv1 ~]# xm shutdown 0004fb00000600007fbdb52a1b566a74
The guest VM shutdowns and should be correctly recognized as "Stopped" by VM Manager.
This solved my issue and I was able to start again using VM Manager.
The Oracle VM Manager stated machine status as UNKNOWN so I could not start nor stop the VM giving me error while performing any operation on it.
Further investigation above task details returned this error:
Error: Acquire running lock failed: 256
I connected via SSH to one of Oracle VM servers and run the following command:
[root@orclvmsrv1 ~]# xm list
Name ID Mem VCPUs State Time(s)
0004fb00000600007fbdb52a1b566a74 15 4096 1 -b---- 229.6
Domain-0 0 726 12 r----- 62921.7
This command returns all VMs (referred by VM ID) and theyr corresponding state.
For further informations on xm command I suggest you to visit this page: xm man
To stop the guest VM run:
xm shutdown VIRTUAL_MACHINE_ID
In this case:
[root@orclvmsrv1 ~]# xm shutdown 0004fb00000600007fbdb52a1b566a74
The guest VM shutdowns and should be correctly recognized as "Stopped" by VM Manager.
This solved my issue and I was able to start again using VM Manager.
lunedì 2 luglio 2012
Perform Documents Check-In using Remote IntraDoC (RIDC)
It's a pretty common task to perform document operations using RIDC Libraries.
In this post I provide a sample code to perform a new document chech-in on Oracle WebCenter Content, also known as Universal Content Management or simply "UCM".
In following posts I will increase the set of operations that you will able to perform on WebCenter Content using RIDC.
I use Eclipse for coding.
For using RIDC on a Content Server you need first to download RIDC libraries from here:
http://download.oracle.com/otn/content_management/ContentIntegrationSuite_10gR3_20081218.zip
Open Eclipse and create a new Java Project.
Extract oracle-ridc-client-10g.jar from previously downloaded file and import this library in you Eclipse Project (Right Click on your project --> Properties --> Java Build Path --> Libraries)
Under "src" folder create a new folder called "resources", in this folder create a file named ucm.properties with following content:
UCM_URL=idc://10.0.0.12:4444
The string above rapresents IP Address of your Content Server and IntraDoC port (by default this port is 4444, you have set this value during Content Server initial configuration).
Now create three Java Classes:
1) UCMAdapter.java - The class providing all methods to perform operations on Content Server
2) Document.java - The class which contains document properties
3) Main.java - The main class which will be launched and will invoke methods in UCMAdapter.java
Copy this code in UCMAdaper.java
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;
public class UCMAdapter {
private String IDC_URL = null;
//Retrieving configuration
public UCMAdapter() {
try {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("resources/ucm.properties");
Properties p = new Properties();
p.load(is);
IDC_URL = p.getProperty("UCM_URL");
System.out.println("Load configuration DONE: " + IDC_URL);
} catch(Exception ex) {
System.out.println("Error load configuration: " + ex.getMessage());
}
}//
//This method performs a check-in of a new document in Content Server
public void checkIn(String username, Document doc, InputStream attachment, String contentType) {
ServiceResponse severiceResponse = null;
try {
System.out.println("CheckIn Workflow: title: " + doc.getTitle() + " - type: " + contentType);
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
dataBinderReq.putLocal("IdcService", "CHECKIN_UNIVERSAL");
dataBinderReq.putLocal("dSecurityGroup", doc.getSecurityGroup());
dataBinderReq.putLocal("dDocAccount", "");
dataBinderReq.putLocal("dDocName", doc.getDocumentId());
dataBinderReq.putLocal("dDocType", doc.getDocType());
dataBinderReq.putLocal("dDocAuthor", username);
dataBinderReq.putLocal("dDocTitle", doc.getTitle());
dataBinderReq.putLocal("dCollectionID", doc.getContentId());
dataBinderReq.putLocal("isFinished", "true");
TransferFile tf = new TransferFile(attachment, doc.getTitle(), attachment.available(), contentType);
dataBinderReq.addFile("primaryFile", tf);
severiceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
DataBinder dataBinderResp = severiceResponse.getResponseAsBinder();
} catch(Exception ex) {
System.out.println("Error CheckIn: " + ex.getMessage());
} finally {
if (severiceResponse != null) {
severiceResponse.close();
}
}
}//
}//end class
Copy this in Document.java
public class Document {
private String contentId;
private String documentId;
private String owner;
private String title;
private String doctype;
private String securitygroup;
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getContentId() {
return contentId;
}
public void setDocumentId(String documentId) {
this.documentId = documentId;
}
public String getDocumentId() {
return documentId;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getOwner() {
return owner;
}
public void setDocType(String doctype) {
this.doctype = doctype;
}
public String getDocType() {
return doctype;
}
public void setSecurityGroup(String securitygroup) {
this.securitygroup = securitygroup;
}
public String getSecurityGroup() {
return securitygroup;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}//end class
And finally copy this in Main.java
import java.io.File;
import java.io.FileInputStream;
public class Main {
private static String Username = "weblogic"; //User who performs upload
private static String DocumentID_Read = "This is the title of my document"; //Title of the Document
private static String FolderID_Read = "344543302850000202"; //This is Folder ID, "Folders_G" component needs to be activated in Content Server
private static String DocType_Read = "Document"; //Document Type
private static String SecurityGroup_Read = "Public"; //Security Group of Document
private static String FileLocation = "C:\\file.txt"; //File to upload from your PC
public static void Main() {
try {
//Istantiate UCMAdapter
UCMAdapter ucm = new UCMAdapter();
File f = new File(FileLocation);
FileInputStream fs = new FileInputStream(f);
//Set Document values...
Document d = new Document();
d.setTitle(DocumentID_Read);
d.setDocumentId(DocumentID_Read);
d.setContentId(FolderID_Read);
d.setDocType(DocType_Read);
d.setSecurityGroup(SecurityGroup_Read);
//...perform check-in
ucm.checkIn(Username, d, fs, "text/plain");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
You need to modify Main.java values according to your desired values, then launch it an if everythings went fine you will get the message confirmation for your Check-in!!
That's all!!
In this post I provide a sample code to perform a new document chech-in on Oracle WebCenter Content, also known as Universal Content Management or simply "UCM".
In following posts I will increase the set of operations that you will able to perform on WebCenter Content using RIDC.
I use Eclipse for coding.
For using RIDC on a Content Server you need first to download RIDC libraries from here:
http://download.oracle.com/otn/content_management/ContentIntegrationSuite_10gR3_20081218.zip
Open Eclipse and create a new Java Project.
Extract oracle-ridc-client-10g.jar from previously downloaded file and import this library in you Eclipse Project (Right Click on your project --> Properties --> Java Build Path --> Libraries)
Under "src" folder create a new folder called "resources", in this folder create a file named ucm.properties with following content:
UCM_URL=idc://10.0.0.12:4444
The string above rapresents IP Address of your Content Server and IntraDoC port (by default this port is 4444, you have set this value during Content Server initial configuration).
Now create three Java Classes:
1) UCMAdapter.java - The class providing all methods to perform operations on Content Server
2) Document.java - The class which contains document properties
3) Main.java - The main class which will be launched and will invoke methods in UCMAdapter.java
Copy this code in UCMAdaper.java
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;
public class UCMAdapter {
private String IDC_URL = null;
//Retrieving configuration
public UCMAdapter() {
try {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("resources/ucm.properties");
Properties p = new Properties();
p.load(is);
IDC_URL = p.getProperty("UCM_URL");
System.out.println("Load configuration DONE: " + IDC_URL);
} catch(Exception ex) {
System.out.println("Error load configuration: " + ex.getMessage());
}
}//
//This method performs a check-in of a new document in Content Server
public void checkIn(String username, Document doc, InputStream attachment, String contentType) {
ServiceResponse severiceResponse = null;
try {
System.out.println("CheckIn Workflow: title: " + doc.getTitle() + " - type: " + contentType);
IdcClient client = getIdcClient();
DataBinder dataBinderReq = client.createBinder();
dataBinderReq.putLocal("IdcService", "CHECKIN_UNIVERSAL");
dataBinderReq.putLocal("dSecurityGroup", doc.getSecurityGroup());
dataBinderReq.putLocal("dDocAccount", "");
dataBinderReq.putLocal("dDocName", doc.getDocumentId());
dataBinderReq.putLocal("dDocType", doc.getDocType());
dataBinderReq.putLocal("dDocAuthor", username);
dataBinderReq.putLocal("dDocTitle", doc.getTitle());
dataBinderReq.putLocal("dCollectionID", doc.getContentId());
dataBinderReq.putLocal("isFinished", "true");
TransferFile tf = new TransferFile(attachment, doc.getTitle(), attachment.available(), contentType);
dataBinderReq.addFile("primaryFile", tf);
severiceResponse = client.sendRequest(new IdcContext(username), dataBinderReq);
DataBinder dataBinderResp = severiceResponse.getResponseAsBinder();
} catch(Exception ex) {
System.out.println("Error CheckIn: " + ex.getMessage());
} finally {
if (severiceResponse != null) {
severiceResponse.close();
}
}
}//
}//end class
Copy this in Document.java
public class Document {
private String contentId;
private String documentId;
private String owner;
private String title;
private String doctype;
private String securitygroup;
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getContentId() {
return contentId;
}
public void setDocumentId(String documentId) {
this.documentId = documentId;
}
public String getDocumentId() {
return documentId;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getOwner() {
return owner;
}
public void setDocType(String doctype) {
this.doctype = doctype;
}
public String getDocType() {
return doctype;
}
public void setSecurityGroup(String securitygroup) {
this.securitygroup = securitygroup;
}
public String getSecurityGroup() {
return securitygroup;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}//end class
And finally copy this in Main.java
import java.io.File;
import java.io.FileInputStream;
public class Main {
private static String Username = "weblogic"; //User who performs upload
private static String DocumentID_Read = "This is the title of my document"; //Title of the Document
private static String FolderID_Read = "344543302850000202"; //This is Folder ID, "Folders_G" component needs to be activated in Content Server
private static String DocType_Read = "Document"; //Document Type
private static String SecurityGroup_Read = "Public"; //Security Group of Document
private static String FileLocation = "C:\\file.txt"; //File to upload from your PC
public static void Main() {
try {
//Istantiate UCMAdapter
UCMAdapter ucm = new UCMAdapter();
File f = new File(FileLocation);
FileInputStream fs = new FileInputStream(f);
//Set Document values...
Document d = new Document();
d.setTitle(DocumentID_Read);
d.setDocumentId(DocumentID_Read);
d.setContentId(FolderID_Read);
d.setDocType(DocType_Read);
d.setSecurityGroup(SecurityGroup_Read);
//...perform check-in
ucm.checkIn(Username, d, fs, "text/plain");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
You need to modify Main.java values according to your desired values, then launch it an if everythings went fine you will get the message confirmation for your Check-in!!
That's all!!
Iscriviti a:
Post (Atom)
























