Oracle® Fusion Middleware Services Reference Guide for Oracle Universal Content Management 11g Release 1 (11.1.1) Part Number E11011-01 |
|
|
View PDF |
This example application calls five services and defines six private functions:
These services are called and a serialized HDA string is built for each:
CHECKOUT_BY_NAME
CHECKIN_UNIVERSAL
DOC_INFO
GET_FILE
These parameters for CHECKIN_UNIVERSAL are defined:
doFileCopy
dDocName
dDocTitle
dDocType
dSecurityGroup
dDocAuthor
dDocAccount
primaryFile
The GET_TABLE service is called and this parameter is defined:
tableName
These private functions are defined:
getNativeFilePath
checkOutByName
checkinUniversal
getDocInfo
getFile
parseResultSet
This sample is in Visual Basic.
' Defines a private function. Private Function getNativeFilePath() As String Dim idccmd As IdcCommandX Dim str As String Dim res Dim dID As String, dExtension As String, dDocType As String, dDocAccount As String dID = "2" dExtension = "pdf" dDocType = "acc" dDocAccount = "" ' Builds a serialized HDA string. str = "@Properties LocalData" + vbCrLf str = str + "dID=" + dID + vbCrLf str = str + "dExtension=" + dExtension + vbCrLf str = str + "dDocType=" + dDocType + vbCrLf str = str + "dDocAccount=" + dDocAccount + vbCrLf str = str + "@end" + vbCrLf Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\st ellent\bin") res = idccmd.computeNativeFilePath(str) Open "c:\newdoc.txt" For Binary Access Write As #1 Put #1, , str Put #1, , res Close #1 MsgBox (res) End Function ' Defines a private function. Private Function checkOutByName(ByVal dDocName As String) As String Dim idccmd As IdcCommandX Dim idcService As String, str As String Dim res ' Calls a service and builds a serialized HDA string. idcService = "CHECKOUT_BY_NAME" str = "@Properties LocalData" + vbCrLf str = str + "IdcService=" + idcService + vbCrLf str = str + "dDocName=" + dDocName + vbCrLf str = str + "@end" + vbCrLf ' In an actual application the return codes need to be handled. For this example, the service is called while there is no content with that specific dDocName. Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") res = idccmd.executeCommand(str) End Function ' Defines a private function. Private Function checkinUniversal(ByVal doFileCopy As String, ByVal dDocName As String, ByVal dDocTitle As String, ByVal dDocType As String, ByVal dSecurityGroup As String, ByVal dDocAuthor As String, ByVal dDocAccount As String, ByVal primaryFile As String) As String ' Builds a serialized HDA string. Dim idccmd As IdcCommandX Dim idcService, res, str As String ' Calls a service and builds a serialized HDA string. idcService = "CHECKIN_UNIVERSAL" str = "@Properties LocalData" + vbCrLf str = str + "IdcService=" + idcService + vbCrLf str = str + "doFileCopy=" + doFileCopy + vbCrLf str = str + "dDocName=" + dDocName + vbCrLf str = str + "dDocTitle=" + dDocTitle + vbCrLf str = str + "dDocType=" + dDocType + vbCrLf str = str + "dSecurityGroup=" + dSecurityGroup + vbCrLf str = str + "dDocAuthor=" + dDocAuthor + vbCrLf str = str + "dDocAccount=" + dDocAccount + vbCrLf str = str + "primaryFile=" + primaryFile + vbCrLf str = str + "@end" + vbCrLf ' exec hda... Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") res = idccmd.executeCommand(str) MsgBox (CStr(res)) End Function ' Defines a private function. Private Function getDocInfo(ByVal dID As String) As String Dim idccmd As IdcCommandX Dim idcService As String, str As String Dim res ' Calls a service and builds a serialized HDA string. idcService = "DOC_INFO" str = "@Properties LocalData" + vbCrLf str = str + "IdcService=" + idcService + vbCrLf str = str + "dID=" + dID + vbCrLf str = str + "@end" + vbCrLf ' exec hda.... Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") res = idccmd.executeCommand(str) MsgBox (res) End Function ' Defines a private function. Private Function getFile(ByVal dID As String, ByVal dDocName As String, ByVal RevisionSelectionMethod As String, ByVal Rendition As String) Dim idccmd As IdcCommandX Dim idcService, str As String Dim res As Variant Dim fileName As String Dim fileSize As Long Dim indexStop As Integer ' Calls a service and builds a serialized HDA string. idcService = "GET_FILE" str = "@Properties LocalData" + vbCrLf str = str + "IdcService=" + idcService + vbCrLf str = str + "dDocName=" + dDocName + vbCrLf str = str + "dID=" + dID + vbCrLf If (RevisionSelectionMethod = "Specific" Or RevisionSelectionMethod = "Latest" Or RevisionSelectionMethod = "LatestReleased") Then ' Ignore dDocName and use dID instead. str = str + "RevisionSelectionMethod=" + RevisionSelectionMethod + vbCrLf End If If (Revision = "Primary" Or Revision = "Web" Or Revision = "Alternate") Then str = str + "Revision=" + Revision + vbCrLf End If str = str + "@end" + vbCrLf ' exec hda... Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") res = idccmd.executeCommand(str) Open "c:\newdoc.txt" For Binary Access Write As #1 Put #1, , res Close #1 MsgBox (Len(res)) ' chop at filename= and store fileName indexStop = InStr(res, "filename=") tmpStr = (Mid(res, indexStop)) indexStop = InStr(tmpStr, Chr(13)) fileName = Mid(tmpStr, 10, indexStop - 10) MsgBox (fileName) ' MsgBox (CStr(Asc(Mid(tmpStr, 2, 1)))) ' chop at Content-length: and store fileSize tmpStr = Mid(tmpStr, indexStop) indexStop = InStr(tmpStr, "Content-Length: ") tmpStr = (Mid(tmpStr, indexStop)) indexStop = InStr(tmpStr, Chr(10)) fileSize = CLng(Mid(tmpStr, 17, indexStop - 17)) MsgBox (CStr(fileSize)) MsgBox (Len(res)) End Function Private Sub cmdAddUser_Click() frmAddUser.Show End Sub Private Sub cmdCheckin_Click() Dim idcService As String, doFileCopy As String, dDocName As String Dim dDocTitle As String, dDocType As String, dSecurityGroup As String Dim dDocAuthor As String, dDocAccount As String, primayFile As String ' Calls a service and defined parameters. idcService = "CHECKIN_UNIVERSAL" doFileCopy = "1" dDocName = "myDocNameNewh" dDocTitle = "myDocTitleb" dDocType = "ADACCT" dSecurityGroup = "Public" dDocAuthor = "Jennifer" dDocAccount = "" primaryFile = "c:/junk_b.doc" ' In an actual application check for errors. ' Lock the file in order to upload a new revision. Call checkOutByName(CStr(dDocName)) ' If the dDocName is not in the system, it gets added as first revision ' by the CHECKIN_UNIVERSAL call. Call checkinUniversal(doFileCopy, dDocName, dDocTitle, dDocType, dSecurityGroup, dDocAuthor, dDocAccount, primaryFile) End Sub Private Sub cmdDocInfo_Click() Call getDocInfo("269") End Sub Private Sub cmdDownload_Click() Call ba End Sub Private Sub cmdGetFile_Click() Call getFile("14", "", "", "") End Sub Private Sub cmdGetNativeFile_Click() Call getNativeFilePath End Sub Private Sub Command1_Click() Dim idccmd As IdcCommandX Dim res, str Open "c:\adduser.txt" For Append As #1 Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") str = "@Properties LocalData" + vbCrLf + "IdcService=ADD_USER" + vbCrLf + "dName=Jennifer" + vbCrLf + "dFullName=Jennifer Smith" + vbCrLf + "dPassword=password" + vbCrLf + "dEmail=email@email.com" + vbCrLf + "dUserAuthType=LOCAL" + vbCrLf + "@end" + vbCrLf + "@ResultSet UserAttribInfo" + vbCrLf + "2" + vbCrLf + "dUserName" + vbCrLf + "AttributeInfo" + vbCrLf + "Jennifer" + vbCrLf + "role,admin,15" + vbCrLf + "@end" + vbCrLf res = idccmd.executeCommand(str) Print #1, res Close #1 End Sub Private Sub Command2_Click() Dim idccmd As IdcCommandX Dim res, str Dim myRS As String Dim idcService, tableName As String idcService = "GET_TABLE" tableName = "Accounts" Open "c:\a_getsec.txt" For Append As #1 Set idccmd = New IdcCommandX res = idccmd.init("sysadmin", "c:\stellent\bin") str = "@Properties LocalData" + vbCrLf + "IdcService=" + idcService + vbCrLf + "tableName=" + tableName + vbCrLf + "@end" + vbCrLf myRS = idccmd.executeCommand(str) ' Parse out the results set. Call parseResultSet(myRS, tableName) Print #1, res Close #1 End Sub ' Calls a private function. Private Function parseResultSet(strResultsSet As String, strSearchString As String) As String Dim indexStop As Integer Dim tmpStr As String Dim numberOfRows As Integer Dim numberOfElementsInSet As Integer Dim resultElement() MsgBox (strResultsSet) ' Start of results set. indexStop = InStr(strResultsSet, "@ResultSet " & strSearchString) ' Check for error (0 index) before moving on. tmpStr = (Mid(strResultsSet, indexStop)) MsgBox (tmpStr) ' Determine how many data lines are in the HTA file. indexStop = InStr(tmpStr, "@end") For i = 1 To indexStop If (Mid(tmpStr, i, 1) = Chr(10)) Then numberOfRows = numberOfRows + 1 End If Next i numberOfRows = numberOfRows - 2 ' Remove the first line of data. ' Find first line that identifies the ResultsSet indexStop = InStr(tmpStr, Chr(10)) tmpStr = (Mid(tmpStr, indexStop + 1)) ' Get number of elements in record set, chop the line off the record set... indexStop = InStr(tmpStr, Chr(10)) numberOfElementsInSet = CInt((Mid(tmpStr, 1, indexStop))) tmpStr = (Mid(tmpStr, indexStop + 1)) ' Set storage array. ReDim resultElement((numberOfRows / numberOfElementsInSet), numberOfElementsInSet) Dim junk As String ' Populate array from HTA dataset For i = 1 To (numberOfRows / numberOfElementsInSet) For j = 1 To numberOfElementsInSet indexStop = InStr(tmpStr, Chr(10)) resultElement(i, j) = Mid(tmpStr, 1, indexStop - 1) tmpStr = (Mid(tmpStr, indexStop + 1)) junk = junk + resultElement(i, j) Next j Next i MsgBox (junk) parseResultSet = "je" End Function ' Set storage array. Sub ba() Dim b() As Byte 'This byte array will capture the file Dim strURL As String ' URL string Dim strDest As String ' Destination File ' Set the strURL to a valid address. 'strURL = "http://localhost/cs/idcplg?IdcService=GET_FILE&dID=14" 'strDest = "C:\myjunk.html" strURL = "localhost" b() = Inet1.OpenURL(strURL, icByteArray) 'Open strDest For Binary Access Write As #1 'Put #1, , b() 'Close #1 End Sub