import java.io.IOException;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
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.serialize.HdaBinderSerializer;
import oracle.stellent.ridc.protocol.ServiceResponse;
public class TestRIDCSearch {
public static void main(String[] args) {
IdcClientManager manager = new IdcClientManager();
try {
IdcClient idcClient = manager.createClient("idc://localhost:4444");
IdcContext userContext = new IdcContext("sysadmin");
HdaBinderSerializer serializer = new HdaBinderSerializer("UTF-8", idcClient.getDataFactory());
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_SEARCH_RESULTS");
/*The easiest way to figure out the QueryText expected by the content server is to execute the query using the content server search screen
in the native UI and trace that call. Gather full verbose, system audit trace using the following trace sections:
system, requestaudit, searchquery, searchcache
This should be the following output:
>searchquery/6 03.25 14:24:41.285 IdcServer-826 preparedQueryText: ( dDocName `test` dSecurityGroup `Public` dInDate >= `3/25/15 12:00 AM` )*/
/*NOTE: UCM limits the ResultCount value according to the MaxResults configuration setting for Content Server.
* To increase the MaxResults setting, add the setting MaxResults=<integer> in config.cfg*/
dataBinder.putLocal("QueryText", "dDocName `test` dSecurityGroup `Public` dInDate >= `3/25/15 12:00 AM`");
serializer.serializeBinder(System.out, dataBinder);
ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
DataBinder responseData = response.getResponseAsBinder();
serializer.serializeBinder(System.out, responseData);
DataResultSet resultSet = responseData.getResultSet("SearchResults");
for (DataObject dataObject : resultSet.getRows()) {
System.out.println("Title is: " + dataObject.get("dDocTitle"));
}
} catch (IdcClientException ice) {
ice.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Showing posts with label RIDC. Show all posts
Showing posts with label RIDC. Show all posts
Monday, October 26, 2015
UCM: GET_SEARCH_RESULTS using RIDC
Wednesday, June 10, 2015
UCM: Checkin new content inside a framework folder using RIDC
public class CheckinFrameworkRIDC {
public static void main(String[] args) {
IdcClientManager manager = new IdcClientManager();
try {
// Creating a new IdcClient Connection using idc protocol
//IdcClient idcClient = manager.createClient("idc://localhost:4444");
//IdcContext userContext = new IdcContext("sysadmin");
// Creating a new IdcClient Connection using HTTP protocol
IdcClient idcClient = manager.createClient("http://localhost:16200/cs/idcplg");
IdcContext userContext = new IdcContext("weblogic", "welcome1");
HdaBinderSerializer serializer = new HdaBinderSerializer("UTF-8", idcClient.getDataFactory());
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "CHECKIN_NEW");
dataBinder.putLocal("dDocTitle", "Framework Folder Testing");
dataBinder.putLocal("dDocType", "Document");
dataBinder.putLocal("dSecurityGroup", "Public");
dataBinder.addFile("primaryFile", new File("C:\\samplefile.txt"));
dataBinder.putLocal("doFileCopy", "true");
dataBinder.putLocal("dDocAuthor", "weblogic");
// Either fParentGUID or parentFolderPath/fParentPath needs to be passed. Meatadata defaults are copied from the folder except SecurityGroup and Account
//dataBinder.putLocal("fParentGUID", "5B0AC7C33BF951078772DFF757535B99");
dataBinder.putLocal("fParentPath", "/Contribution Folders/ElPiju/Straw Bale/resources");
serializer.serializeBinder(System.out, dataBinder);
ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
DataBinder responseData = response.getResponseAsBinder();
serializer.serializeBinder(System.out, responseData);
} catch (IdcClientException ice) {
ice.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Sunday, April 5, 2015
RIDC: Download files in ZIP format
public static void main(String[] args) throws IOException {
IdcClientManager manager = new IdcClientManager();
try {
IdcClient idcClient = manager.createClient("idc://localhost:4444");
IdcContext userContext = new IdcContext("weblogic");
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_ZIP_BUNDLE");
dataBinder.putLocal("pkg:dDocName1", "HY000227");
dataBinder.putLocal("pkg:dDocName0", "HY000001");
// dataBinder.putLocal("pkg:Rendition1", "Primary");
// dataBinder.putLocal("pkg:Rendition0", "Web");
dataBinder.putLocal("bundleKeys", "pkg:dDocName,pkg:Rendition");
ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
InputStream is = response.getResponseStream();
FileOutputStream fos = new FileOutputStream("bundle.zip");
int read = 0;
byte[] bytes = new byte[1024];
while ((read = is.read(bytes)) != -1) {
fos.write(bytes, 0, read);
}
} catch (IdcClientException ice) {
ice.printStackTrace();
}
}
UCM: Delete a folder and all the contents inside it
Use COLLECTION_DELETE_LOT service.
NOTE: This service works for Folders_G and not for Framework Folders component.
NOTE: This service works for Folders_G and not for Framework Folders component.
DataBinder serviceBinder = idcClient.createBinder();
serviceBinder.putLocal("IdcService", "COLLECTION_DELETE_LOT");
serviceBinder.putLocal("collectionselect0", "true");
serviceBinder.putLocal("fromCollectionisLink0", "0");
serviceBinder.putLocal("fromdCollectionID0", "814720879757000011");//child folder which we want to delete
serviceBinder.putLocal("fromhasCollectionID0", "1");
ServiceResponse response = idcClient.sendRequest(userContext, serviceBinder);
DataBinder responseBinder = response.getResponseAsBinder();
UCM: CHECKIN_NEW service using RIDC to upload a file
SCENARIO: This is an ADF application where the user will enter metadata fields about the content file, upload the content in UCM. The application will call the CHECKIN_NEW service using RIDC. On successful upload, it will display a message.
PREREQUISITES: Set IntradocServerPort=4444 in the intradoc.cfg file, if it is not present.
Append *.*.*.* to SocketHostAddressSecurityFilter parameter in config.cfg file, to enable connection via RIDC API remote connection.
This sample application was created using JDev 11.1.1.7. This is the main code:
Download RIDCCheckin.rar, the sample application from the file cabinet.
PREREQUISITES: Set IntradocServerPort=4444 in the intradoc.cfg file, if it is not present.
Append *.*.*.* to SocketHostAddressSecurityFilter parameter in config.cfg file, to enable connection via RIDC API remote connection.
This sample application was created using JDev 11.1.1.7. This is the main code:
public void onFileUpload(ActionEvent actionEvent) {
try {
IdcClientManager manager = new IdcClientManager();
IdcClient idcClient =
manager.createClient("idc://192.168.2.8:4444");
IdcContext userContext = new IdcContext("sysadmin");
UploadedFile uploadedFile = (UploadedFile)file.getValue();
DataBinder serviceBinder = idcClient.createBinder();
serviceBinder.putLocal("IdcService", "CHECKIN_NEW"); //CHECKIN_UNIVERSAL
serviceBinder.putLocal("dDocType", dDocType);
serviceBinder.putLocal("dDocTitle", dDocTitle);
serviceBinder.putLocal("dDocAuthor",
ADFContext.getCurrent().getSecurityContext().getUserName());
serviceBinder.putLocal("dSecurityGroup", "Public");
try {
serviceBinder.addFile("primaryFile",
new TransferFile(uploadedFile.getInputStream(),
uploadedFile.getFilename(),
uploadedFile.getLength()));
} catch (IOException e) {
throw new UCMException("Primary File Error: " +
e.getMessage());
}
ServiceResponse response =
idcClient.sendRequest(userContext, serviceBinder);
DataBinder responseBinder = response.getResponseAsBinder();
System.out.println(responseBinder);
DataObject localData = responseBinder.getLocalData();
if (localData.get("StatusCode").equals("0")) {
addFacesMessage(FacesMessage.SEVERITY_INFO,
localData.get("StatusMessage"));
}
} catch (IdcClientException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
}
Download RIDCCheckin.rar, the sample application from the file cabinet.
Subscribe to:
Posts (Atom)