Wednesday, November 18, 2015

dm_check_password is returning "dm_check_password: Result = (245) = (DM_CHKPASS_BAD_LOGIN)"

If dm_check_password is returning "dm_check_password: Result = (245) = (DM_CHKPASS_BAD_LOGIN)" and it's permissions are ok, check the following: 

1) Check to check the permissions. They should be the following:
-rwsr-s--- 1 root dmadmins 11076 May 1 09:01 dm_check_password
2) If the permission is correct, check if the file system, which contains the Documentum software, is mounted with the nosuid option set.
You can check this for example in Solaris with the command 'mount'.
3) The correct output for the command mount should look like below.
/export/starfish6 on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on Thu Oct 10 07:09:08 2002 

If you see nosuid in the output it will ignore the sticky bit (rws) on that particular file system and the dm_check_password will not work. 

Please ask you UNIX administrator for further assistance if you need help to remount the file system using the setuid flag. 


can log in thru API on the Content Server but not through webtop or DA.

can log in thru API on the Content Server but not through webtop or DA.

checked to make sure root_task had been run, it had
checked ownership of the dm_check_password and it's cohorts and they were fine,
the mount point was mounted correctly 

dm_check_password DOES fail though with the DM_CHKPASS_BAD_LOGIN error (Result = (245)

Cause
dmadmin (installation owner account) is not being logged into directly, but being su'ed to...and without a password


Resolution
Unix admin must assign a password to the installation owner account (example:dmadmin)

Sunday, June 7, 2015

ARM Report issue

Issue:


I’m not able to gain access to the QD Dashboard Report, located under Analysis Reports tabs, as shown below?

The following comment appears on a separate window: The item '/ARMInstance1/CustomReports/QD' cannot be found. (rsItemNotFound)”

 
Solution :
 
This is a know issue when there are spaces in the name for the report creating some problems with the URLs.  As a work around each report needs to have a description added or the spaces removed from the title.  It may be a good idea to do both, the description will be displayed to the end user not the title.  You can do this under the manage menu option for the report in /reports (hover over the report name for the menu to pop up). 

 

Once this has been done you'll need to remove the report from the quick launch menu group in ARM, save, and the add the report back into the group again.

Tuesday, March 31, 2015

DFS Consumer in DOTNET

Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Text
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports IDataAccess.ContextRegistryServiceReference
Imports IDataAccess.ObjectServiceReference
Imports IDataAccess.QueryServiceReference
Imports IDataAccess.SearchServiceReference
Imports System.ServiceModel
Imports System.Configuration
Imports System.Net
Imports System.IO

Namespace Documentum

Public Class DocumentStorageCustomDAL
Implements IDocumentStorageCustomDAL

Public Sub DeleteDocByStorageId(ByVal storageId As String) Implements IDataAccess.Documentum.IDocumentStorageCustomDAL.DeleteDocByStorageId
Try
Dim objectService As New ObjectServicePortClient("ObjectServicePort")

' Find a document to return
Dim q As New ObjectServiceReference.Qualification()
q.String = "dm_document WHERE r_object_id = '" & storageId & "'"
q.qualificationValueType = ObjectServiceReference.QualificationValueType.STRING
q.qualificationValueTypeSpecified = True

' Set the identity
Dim objectIdentity As New ObjectServiceReference.ObjectIdentity()
objectIdentity.valueType = ObjectServiceReference.ObjectIdentityType.QUALIFICATION
objectIdentity.valueTypeSpecified = True
objectIdentity.Item = q
objectIdentity.repositoryName = ConfigurationManager.AppSettings("repositoryName")
Dim objectIdentitySet As New IDataAccess.ObjectServiceReference.ObjectIdentitySet()
objectIdentitySet.Identities = New ObjectServiceReference.ObjectIdentity(0) {}
objectIdentitySet.Identities(0) = objectIdentity

' Specify the format to return (used when multiple renditions exist)
' FormatFilter.ANY should return the default format
Dim contentProfile As New IDataAccess.ObjectServiceReference.ContentProfile()
contentProfile.formatFilter = ObjectServiceReference.FormatFilter.ANY
'contentProfile.format = "crtext";
'contentProfile.format = "pdf"
'contentProfile.formatFilterSpecified = True

Dim operationOptions As New ObjectServiceReference.OperationOptions()
operationOptions.Profiles = New IDataAccess.ObjectServiceReference.Profile(0) {}
operationOptions.Profiles(0) = contentProfile

Dim dataPackage As ObjectServiceReference.DataPackage = Nothing

Using scope As New OperationContextScope(objectService.InnerChannel)
' Add the correct SOAP header

' Use the ServiceContext
Dim scx As New ServiceContextHeader()
Dim repoId As New RepositoryIdentity()
repoId.repositoryName = ConfigurationManager.AppSettings("repositoryName")
repoId.userName = ConfigurationManager.AppSettings("username")
repoId.password = ConfigurationManager.AppSettings("password")
scx.AddRepositoryIdentity(repoId)

OperationContext.Current.OutgoingMessageHeaders.Add(scx)
' Make the call
objectService.delete(objectIdentitySet, operationOptions)

End Using
Catch ex As SqlException

End Try
End Sub

Public Sub UpdateDocumentByStorageId(ByVal storageId As String, ByVal document As Byte()) Implements IDataAccess.Documentum.IDocumentStorageCustomDAL.UpdateDocumentByStorageId
Try

Catch ex As SqlException

End Try
End Sub


Public Sub DeleteDocByStorageId(ByVal storageIds As List(Of System.String)) Implements IDataAccess.Documentum.IDocumentStorageCustomDAL.DeleteDocByStorageIds

End Sub

Public Function UploadDocument(ByVal pdfDoc As DocumentStorageEntity) As String Implements IDataAccess.Documentum.IDocumentStorageCustomDAL.UploadDocument
Dim rObjectID As String = String.Empty
Try

Dim objectService As ObjectServicePortClient
objectService = New ObjectServicePortClient("ObjectServicePort")
Dim oi As ObjectServiceReference.ObjectIdentity
oi = New ObjectServiceReference.ObjectIdentity()
oi.repositoryName = ConfigurationManager.AppSettings("repositoryName").ToString()
Dim o As ObjectServiceReference.DataObject
o = New ObjectServiceReference.DataObject
o.Identity = oi
o.type = pdfDoc.ObjectType
Dim pp As ObjectServiceReference.PropertyProfile
pp = New ObjectServiceReference.PropertyProfile
pp.filterMode = ObjectServiceReference.PropertyFilterMode.ALL
Dim tp As ObjectServiceReference.ContentTransferProfile
tp = New ObjectServiceReference.ContentTransferProfile
tp.transferMode = ObjectServiceReference.ContentTransferMode.BASE64

Dim operationOptions As ObjectServiceReference.OperationOptions
operationOptions = New ObjectServiceReference.OperationOptions
Dim profile(2) As ObjectServiceReference.Profile
operationOptions.Profiles = profile
operationOptions.Profiles(0) = pp
operationOptions.Profiles(1) = tp
Dim pset As ObjectServiceReference.PropertySet
pset = New ObjectServiceReference.PropertySet

Dim doN As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
doN.name = "object_name"
doN.Value = pdfDoc.ObjectName

Dim dLN As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dLN.name = "locationnum"
dLN.Value = pdfDoc.LocationNumber

Dim dCN As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dCN.name = "contractnum"
dCN.Value = pdfDoc.ContractNumber

Dim dPN As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dPN.name = "purchasername"
dPN.Value = pdfDoc.PurchaseName

Dim dDN As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dDN.name = "deceasedname"
dDN.Value = pdfDoc.DeceasedName

Dim dDT As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dDT.name = "documenttype"
dDT.Value = pdfDoc.DocumentType

Dim dCT As ObjectServiceReference.StringProperty = New ObjectServiceReference.StringProperty
dCT.name = "contracttype"
dCT.Value = pdfDoc.ContractType

Dim ps As ObjectServiceReference.Property() = {doN, dLN, dCN, dPN, dDN, dDT, dCT}

pset.Properties = ps
o.Properties = pset
Dim dhc As ObjectServiceReference.DataHandlerContent
dhc = New ObjectServiceReference.DataHandlerContent
dhc.format = pdfDoc.ContentType
dhc.Value = pdfDoc.ReadDocument

o.Contents = New ObjectServiceReference.Content(0) {}
o.Contents(0) = dhc

Dim packageIn As ObjectServiceReference.DataPackage
packageIn = New ObjectServiceReference.DataPackage

Dim dataObjects() As ObjectServiceReference.DataObject = {o}

packageIn.DataObjects = dataObjects

Dim packageOut As ObjectServiceReference.DataPackage

Using scope As New ServiceModel.OperationContextScope(objectService.InnerChannel)

' Use the ServiceContext
Dim scx As New ServiceContextHeader()
Dim repoId As New RepositoryIdentity()
repoId.repositoryName = ConfigurationManager.AppSettings("repositoryName").ToString()
repoId.userName = ConfigurationManager.AppSettings("userName").ToString()
repoId.password = ConfigurationManager.AppSettings("password").ToString()
scx.AddRepositoryIdentity(repoId)
OperationContext.Current.OutgoingMessageHeaders.Add(scx)
Try
If objectService.State = CommunicationState.Created Then
packageOut = objectService.create(packageIn, operationOptions)
Dim retObj As ObjectServiceReference.ObjectId = TryCast(packageOut.DataObjects(0).Identity.Item, ObjectServiceReference.ObjectId)
rObjectID = retObj.id
End If
Catch ex As Exception
Return ex.Message
End Try
Return rObjectID
End Using

Catch ex As Exception

End Try
Return rObjectID
End Function


Public Function GetDocByObjectId(ByVal ObjectID As String) As GetFileData
Dim response As New GetFileData()
Try
Dim objectService As New ObjectServicePortClient("ObjectServicePort")

' Find a document to return
Dim q As New ObjectServiceReference.Qualification()
q.String = "dm_document WHERE r_object_id = '" & ObjectID & "'"
q.qualificationValueType = ObjectServiceReference.QualificationValueType.STRING
q.qualificationValueTypeSpecified = True

' Set the identity
Dim objectIdentity As New ObjectServiceReference.ObjectIdentity()
objectIdentity.valueType = ObjectServiceReference.ObjectIdentityType.QUALIFICATION
objectIdentity.valueTypeSpecified = True
objectIdentity.Item = q
objectIdentity.repositoryName = ConfigurationManager.AppSettings("repositoryName")
Dim objectIdentitySet As New IDataAccess.ObjectServiceReference.ObjectIdentitySet()
objectIdentitySet.Identities = New ObjectServiceReference.ObjectIdentity(0) {}
objectIdentitySet.Identities(0) = objectIdentity

' Specify the format to return (used when multiple renditions exist)
' FormatFilter.ANY should return the default format
Dim contentProfile As New IDataAccess.ObjectServiceReference.ContentProfile()
contentProfile.formatFilter = ObjectServiceReference.FormatFilter.SPECIFIED
'contentProfile.format = "txt"
contentProfile.format = "pdf"
contentProfile.formatFilterSpecified = True

Dim operationOptions As New ObjectServiceReference.OperationOptions()
operationOptions.Profiles = New IDataAccess.ObjectServiceReference.Profile(0) {}
operationOptions.Profiles(0) = contentProfile

Dim dataPackage As ObjectServiceReference.DataPackage = Nothing

Using scope As New OperationContextScope(objectService.InnerChannel)
' Add the correct SOAP header
' Use the ServiceContext
Dim scx As New ServiceContextHeader()
Dim repoId As New RepositoryIdentity()
repoId.repositoryName = ConfigurationManager.AppSettings("repositoryName")
repoId.userName = ConfigurationManager.AppSettings("username")
repoId.password = ConfigurationManager.AppSettings("password")
scx.AddRepositoryIdentity(repoId)
OperationContext.Current.OutgoingMessageHeaders.Add(scx)
' Make the call
dataPackage = objectService.get(objectIdentitySet, operationOptions)
End Using

' Dump the content to a file
' If Not dataPackage.DataObjects(0).Contents Is Nothing Then
For Each content As ObjectServiceReference.Content In dataPackage.DataObjects(0).Contents
Dim p As ObjectServiceReference.Property() = dataPackage.DataObjects(0).Properties.Properties
Dim fileName As String = "File"

' Set the filename to the object_name
For Each prop As ObjectServiceReference.Property In p
If prop.name = "object_name" Then
Dim sp As ObjectServiceReference.StringProperty = TryCast(prop, ObjectServiceReference.StringProperty)
If sp IsNot Nothing AndAlso String.IsNullOrEmpty(sp.Value) = False Then
fileName = sp.Value
Exit For
End If
End If
Next

' Check the format here
If content.format = "crtext" Then
fileName = IO.Path.ChangeExtension(fileName, "txt")
End If
If content.format = "pdf" Then
fileName = IO.Path.ChangeExtension(fileName, "pdf")
End If

' Put the file on the desktop
' fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName);
' If ACS is used, the returned content will be UrlContent. If it's not used, the returned
' content will be BinaryContent
If TypeOf content Is IDataAccess.ObjectServiceReference.BinaryContent Then
'AddText("The content was returned as BinaryContent");
Dim binContent As IDataAccess.ObjectServiceReference.BinaryContent = DirectCast(content, IDataAccess.ObjectServiceReference.BinaryContent)
'SaveBytesToFile(binContent.Value, fileName);
'AddText("The file has been saved here: " + fileName);
Dim s As String = binContent.format()
response.ID = ObjectID
response.ObjectName = fileName
response.FileContents = binContent.Value
response.ErrorNo = False
'response.Extn = content.format
Return response
ElseIf TypeOf content Is IDataAccess.ObjectServiceReference.UrlContent Then
Dim urlContent As IDataAccess.ObjectServiceReference.UrlContent = DirectCast(content, IDataAccess.ObjectServiceReference.UrlContent)
'AddText("The content was returned as UrlContent.");
' AddText("The URL is: " + urlContent.url);
Dim url As New Uri(urlContent.url)
response.ID = ObjectID
response.ObjectName = fileName
response.FileContents = SaveUrlContentToByte(url)
response.ErrorNo = False
response.Extn = content.format
'AddText("The file has been saved here: " + fileName);
Return response
End If

Exit For
Next

response.ErrorNo = True
response.ErrorDetails = "All processing finshed but no data was found."

Return response
'Else
'response.ErrorDetails = "Document Object Not Found"
'response.ErrorNo = True
'End If

Catch ex As Exception
response.ErrorNo = True
response.ErrorDetails = ex.Message
Return response
End Try
End Function


Public Function SaveUrlContentToByte(ByVal url As Uri) As Byte()
Try
' Get the content from the ACS server
' Dim stream As IO.Stream = Nothing
Dim fstream As FileStream = Nothing
Dim response As HttpWebResponse = Nothing

Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
response = DirectCast(request.GetResponse(), HttpWebResponse)
Using stream = response.GetResponseStream()
Dim buffer As Byte() = New Byte(32767) {}

Using ms As New MemoryStream()
While True
Dim read As Integer = stream.Read(buffer, 0, buffer.Length)
If read <= 0 Then
Return ms.ToArray()
End If
ms.Write(buffer, 0, read)
End While
End Using
End Using
Catch ex As Exception
' AddText(ex.Message);
Return Nothing
End Try
End Function


Public Function GetDocByStorageId(ByVal storageId As String) As DocumentStorageEntity Implements IDataAccess.Documentum.IDocumentStorageCustomDAL.GetDocByStorageId
Dim documentStorage As DocumentStorageEntity
Try

Catch ex As SqlException

End Try
Return documentStorage
End Function

Partial Friend Class SQLServerDocumentStorageCustomDALConstants
Public Const storageId As String = "StorageId"
Public Const ID As String = "ID"
Public Const DeleteDocByStorageId As String = "DeleteDocByStorageId"
Public Const UploadDoc As String = "UploadDoc"
Public Const GetDocByStorageId As String = "GetDocByStorageId"
Public Const UserId As String = "UserId"
Public Const Document As String = "Document"
Public Const ContentType As String = "ContentType"
Public Const CreatedDate As String = "CreatedDate"
Public Const UpdatedDate As String = "UpdatedDate"
Public Const DocumentName As String = "DocumentName"
Public Const UpdateDocByStorageId As String = "UpdateDocByStorageId"
End Class

Public Function GetExtensionofFile(ByVal objectId As String) As String
Dim response As New GetFileData()
Try
Dim objectService As New ObjectServicePortClient("ObjectServicePort")

' Find a document to return
Dim q As New ObjectServiceReference.Qualification()
'q.String = "dm_document WHERE r_object_id = '" & objectId & "'"
q.String = "dm_format WHERE r_object_id = '" & objectId & "'"

q.qualificationValueType = ObjectServiceReference.QualificationValueType.STRING
q.qualificationValueTypeSpecified = True

' Set the identity
Dim objectIdentity As New ObjectServiceReference.ObjectIdentity()
objectIdentity.valueType = ObjectServiceReference.ObjectIdentityType.QUALIFICATION
objectIdentity.valueTypeSpecified = True
objectIdentity.Item = q
objectIdentity.repositoryName = ConfigurationManager.AppSettings("repositoryName")
Dim objectIdentitySet As New IDataAccess.ObjectServiceReference.ObjectIdentitySet()
objectIdentitySet.Identities = New ObjectServiceReference.ObjectIdentity(0) {}
objectIdentitySet.Identities(0) = objectIdentity

' Specify the format to return (used when multiple renditions exist)
' FormatFilter.ANY should return the default format

Dim contentProfile As New IDataAccess.ObjectServiceReference.ContentProfile()
contentProfile.formatFilter = ObjectServiceReference.FormatFilter.ANY
'contentProfile.format = "txt"
'contentProfile.format = "pdf"
contentProfile.formatFilterSpecified = True

Dim operationOptions As New ObjectServiceReference.OperationOptions()
operationOptions.Profiles = New IDataAccess.ObjectServiceReference.Profile(0) {}
operationOptions.Profiles(0) = contentProfile

Dim dataPackage As ObjectServiceReference.DataPackage = Nothing

Using scope As New OperationContextScope(objectService.InnerChannel)
' Add the correct SOAP header
' Use the ServiceContext
Dim scx As New ServiceContextHeader()
Dim repoId As New RepositoryIdentity()
repoId.repositoryName = ConfigurationManager.AppSettings("repositoryName")
repoId.userName = ConfigurationManager.AppSettings("username")
repoId.password = ConfigurationManager.AppSettings("password")
scx.AddRepositoryIdentity(repoId)
OperationContext.Current.OutgoingMessageHeaders.Add(scx)
' Make the call
dataPackage = objectService.get(objectIdentitySet, operationOptions)
End Using

Dim fileName As String = String.Empty
' Dump the content to a file
' If Not dataPackage.DataObjects(0).Contents Is Nothing Then
For Each content As ObjectServiceReference.Content In dataPackage.DataObjects(0).Contents
Dim p As ObjectServiceReference.Property() = dataPackage.DataObjects(0).Properties.Properties

' Set the filename to the object_name
For Each prop As ObjectServiceReference.Property In p
If prop.name = "dos_extension" Then
Dim sp As ObjectServiceReference.StringProperty = TryCast(prop, ObjectServiceReference.StringProperty)
If sp IsNot Nothing AndAlso String.IsNullOrEmpty(sp.Value) = False Then
fileName = sp.Value
Exit For
End If
End If
Next

' Check the format here
If content.format = "crtext" Then
fileName = IO.Path.ChangeExtension(fileName, "txt")
End If
If content.format = "pdf" Then
fileName = IO.Path.ChangeExtension(fileName, "pdf")
End If
Exit For
Next
Return fileName
Catch ex As Exception

End Try

End Function

Public Structure GetFileData

Public ErrorNo As Boolean

Public ErrorDetails As String

Public ID As String

Public ObjectName As String

Public FileContents As Byte()

Public Extn As String

End Structure

End Class
End Namespace


--- This is another class with in that business layer


' This sample code has been built using EMC Documentum Foundation Services (DFS)
' version 6.5 SP1, Visual Studio 2008 and .NET 3.5 (Windows Communication Foundation
' "v2" and LINQ to XML--System.Xml.Linq). It is not supported by EMC.
'
' In order to build and run this sample you must have DFS 6.5 SP1 (i.e. its web
' services) properly deployed (e.g. into a JEE application server such as JBoss
' 4.2.2).
'
' The primary intent of this sample code is to demonstrate direct-to-WSDL consumption
' of DFS using standard Microsoft tools (Visual Studio) and frameworks (WCF).
'
' Please visit the EMC Developer Network for more on DFS:
' https://community.emc.com/community/edn/documentum
Imports System.Collections.Generic
Imports System.Globalization
Imports System.ServiceModel.Channels
Imports System.Xml
Imports System.Xml.Serialization

Imports System.IO
Imports System.Xml.Linq

Imports IDataAccess.ContextRegistryServiceReference

Namespace Documentum
Friend Class ServiceContextHeader
Inherits MessageHeader
Private ReadOnly repositoryIdentities As New List(Of RepositoryIdentity)()
Private contentTransferProfile As ContentTransferProfile

Public Sub AddRepositoryIdentity(ByVal rid As RepositoryIdentity)
If rid Is Nothing Then
Exit Sub
End If

repositoryIdentities.Add(rid)
End Sub

Public Sub AddContentTransferProfile(ByVal ctp As ContentTransferProfile)
If ctp Is Nothing Then
Exit Sub
End If

contentTransferProfile = ctp
End Sub

Protected Overloads Overrides Sub OnWriteHeaderContents(ByVal writer As XmlDictionaryWriter, ByVal messageVersion As MessageVersion)
' If there are no ids, do nothing
If repositoryIdentities.Count < 1 Then
Exit Sub
End If

' Add ids to the ServiceContext
Dim serviceContext As New ServiceContext()
serviceContext.Identities = New Identity(repositoryIdentities.Count - 1) {}
For x As Integer = 0 To repositoryIdentities.Count - 1
serviceContext.Identities(x) = repositoryIdentities(x)
Next

' If there is a ContentTransferProfile, add it
If contentTransferProfile IsNot Nothing Then
serviceContext.Profiles = New ContentTransferProfile(0) {}
serviceContext.Profiles(0) = contentTransferProfile
End If

' Serialize the objects to XML
Dim doc As XDocument = Nothing
Using sw As New StringWriter(CultureInfo.CurrentCulture)
Dim xs As New XmlSerializer(GetType(ServiceContext))
xs.Serialize(sw, serviceContext)
doc = XDocument.Load(New StringReader(sw.ToString()))
End Using

' Add Identities to the ServiceContext header
For Each el As XElement In doc.Descendants(XName.[Get]("Identities", "http://context.core.datamodel.fs.documentum.emc.com/"))
Dim r As XmlReader = XmlReader.Create(New StringReader(el.ToString()))
writer.WriteNode(r, True)
Next

' Add Profiles to the ServiceContext header
If serviceContext.Profiles IsNot Nothing Then
For Each el As XElement In doc.Descendants(XName.[Get]("Profiles", "http://context.core.datamodel.fs.documentum.emc.com/"))
Dim r As XmlReader = XmlReader.Create(New StringReader(el.ToString()))
writer.WriteNode(r, False)
Next
End If
End Sub

Public Overloads Overrides ReadOnly Property Name() As String
Get
Return "ServiceContext"
End Get
End Property

Public Overloads Overrides ReadOnly Property [Namespace]() As String
Get
Return "http://context.core.datamodel.fs.documentum.emc.com/"
End Get
End Property
End Class
End Namespace


--- create a webpage... and paste this code

Imports IDataAccess.Documentum
Imports System.IO
Imports System.Configuration



Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub btnSendDocument_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSendDocument.Click

Try
Dim objEntity As New DocumentStorageEntity
Dim objFile As New FileInfo(fuBrowse.FileName)
objEntity.ObjectName = txtLocationNum.Text + "-" + txtContractNum.Text + "-" + txtDocumentType.Text
objEntity.ObjectType = "customercontract"
If fuBrowse.HasFile Then
objEntity.ReadDocument = fuBrowse.FileBytes()
Else
Return
End If
objEntity.LocationNumber = txtLocationNum.Text
objEntity.ContractNumber = txtContractNum.Text
objEntity.PurchaseName = txtPurName.Text
objEntity.DeceasedName = txtDeceasedName.Text
objEntity.DocumentName = fuBrowse.FileName
objEntity.ContentType = "pdf" 'objFile.Extension
objEntity.ContractType = "Trust Contract"
objEntity.DocumentType = txtDocumentType.Text
Dim objDocument As New DocumentStorageCustomDAL
lblDocumentId.Text = "Document Id is:- " + objDocument.UploadDocument(objEntity)

Catch ex As Exception
Response.Write(ex.ToString())
End Try

End Sub

Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGetDoc.Click
Try
Dim objDocument As New DocumentStorageCustomDAL
Dim objGetFile As DocumentStorageCustomDAL.GetFileData
objGetFile = objDocument.GetDocByObjectId(txtGetDoc.Text)
If (objGetFile.ErrorNo = False) Then
Dim url As String = AppDomain.CurrentDomain.BaseDirectory & "GetFile." & objGetFile.Extn
Using binWriter As New BinaryWriter(File.Open(url, FileMode.Create))
binWriter.Write(objGetFile.FileContents)
End Using
System.Diagnostics.Process.Start(url)
End If
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub

Protected Sub btnDeleteDoc_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDeleteDoc.Click

Try
Dim objDocument As New DocumentStorageCustomDAL
Dim fileExt As String
fileExt = objDocument.GetExtensionofFile(txtGetDoc.Text)
lblDocumentId.Text = fileExt

'objDocument.DeleteDocByStorageId(txtGetDoc.Text)
'lblDocumentId.Text = txtGetDoc.Text + " Deleted Successfully"
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub
End Class


Wednesday, March 25, 2015

DQL

DQL to create user
create “dm_user” object
set client_capability=2,
set default_folder=’’,
set home_docbase=’’,
set mailto:user_address=’a@abc.com’,
set user_os_domain=’’,
set user_name=’’,
set user_os_name=’’,
set user_privileges=0;
2. DQL to execute stored procedure (works for all supported DBMSes)
execute exec_sql with query=’execute my_sp_test ”123”,”prasad” ‘;
3. Running DQL in batch mode
a. Create a dql file
b. Run the following from command prompt
$idql docbasename -Uusername -Ppassword -Rtest.dql
Example command
C:\Documentum\product\5.3\bin>idql32 docbasename-Uusername -Ppassword -RC:
\test.dql
test.dql would contain something like this
go
go
4. DQL to Get all Files under a Particular Cabinet
select r_object_id, object_name from dm_document(all) where folder(’/Cabinet name’, descend);
The above DQL gives all versions. To get only current versions
select * from dm_document where folder (’/Cabinet name’, descend)
5. DQL to get total number of documents and folders under a cabinet
SELECT count(*) as cnt, ‘Docs’ as category FROM dm_document(all)
WHERE FOLDER (’/Cabinet Name’,DESCEND)
UNION
SELECT count(*) as cnt, ‘Folders’ as category FROM dm_folder
WHERE FOLDER (’/Cabinet Name’,DESCEND)
6. DQL to find whether a document is a part of virtual document
SELECT object_name,r_object_id FROM dm_sysobject
WHERE r_object_id IN
(SELECT parent_id FROM dmr_containment
WHERE component_id = (SELECT i_chronicle_id FROM dm_sysobject WHERE r_object_id = ‘’))
7. Repeating attributes
Repeated attribute queries are always a fun. I am going to present here more repeated attribute queries. But for starters, recognize the importance of ANY keyword
select r_folder_path from dm_folder where object_name
=’myFolder’ and any r_folder_path =’/Cabinet Name/test’;
8. DQL to find object type of a document
select r_object_type from dm_document where object_name=’ObjectName’;
9. DQL for index
Following query creates index
EXECUTE make_index WITH type_name=’dmi_workitem’,attribute=’r_workflow_id’
Using the query below, one can find out whether index has been succesfully created or alternatively whether the index exists or not
Select r_object_id,index_type,attribute,attr_count,data_space from dmi_index where index_type in (select r_object_id from dm_type where name=’dmi_workitem’);
10. DQL to see sessions
execute show_sessions
11. Enable FTDQL
SELECT
r_object_id,
score,
text,
object_name,
r_object_type,
r_lock_owner,
owner_name,
r_link_cnt,
r_is_virtual_doc,
r_content_size,
a_content_type,
i_is_reference,
r_assembled_from_id,
r_has_frzn_assembly,
a_compound_architecture,
i_is_replica,
r_policy_id,acl_name,
r_creation_date,
r_modify_date,
subject
FROM
custom_document
WHERE
(custom_attr1 = ’search1′ AND
(custom_attr2 = ’search2′ AND
)) AND
(a_is_hidden = FALSE)
ENABLE
(FTDQL)
12. DQL to get current date, time
select DATE(now) as systime from dm_server_config;
13. DQL to list all available templates in Webpublisher
select * from my_document where folder(’/WebPublisher Configuration/Content Templates/myTemplates’,descend) and any r_version_label =’Approved’;
14. DQL to list objects having duplicate names
SELECT object_name, count(*) FROM dm_document
GROUP BY object_name
HAVING count(*) > 1
ORDER BY object_name
15. Clear INBOX
delete dmi_queue_item objects where delete_flag=0
16. DQL to retrieve all required attributes of a particular type
SELECT attr_name FROM dmi_dd_attr_info WHERE type_name=’dm_document’ AND is_required 0
17. DQL to list workflow attachments
select r_component_id, r_component_name from dmi_wf_attachment where r_workflow_id = ‘’
18. If your statistics are not up to date, database may choose a very inefficient execution plan. Be sure toupdate statistics often. It is recommended that you use the dm_UpdateStatistics job as it will calculateextended statistics on particular tables and columns which provide additional performance benefits. If the DBA uses their own scripts to calculate the statistics, then these enhancements will not be available.
19.Use the script “dctm_indexes_by_table.sql” to generate a list of all indexes on Documentum tables, ordered by table name. (Available from http://developer.documentum.com.)
Use the script “dctm_indexes_by_index.sql” to generate a list of all indexes on Documentum tables,
ordered by index name. (Available from http://developer.documentum.com.)
20.It is strongly recommended that all indexes on Documentum base tables be created from within Documentum and not at the database level.
There are two reasons for this:
The internal conversion process from DQL to SQL will check for the presence of a dmi_index object for repeating valued attributes and will generate different SQL according to what it finds.
If indexes are created directly through SQL*Plus, then Documentum will not know anything about them and will assume it is unindexed. This may result in a less efficient SQL query.
Secondly, if the indexes are created from within Documentum, and they are inadvertently dropped, the dm_DBWarning job will automatically recreate them at next execution.
The syntax for creating new indexes is as follows:
In DQL:
EXECUTE make_index WITH type_name=object_type,
attribute=attribute_name{,attribute=attribute_name,…)
or
Using APIs:
dmAPIGet(”apply,session,NULL,MAKE_INDEX,TYPE_NAME,S,object_type,ATTRIBUTE,S
,attribute_name(,ATTRIBUTE,S,attribute_name,…}
These indexes will be created in the tablespace identified by the index_store server.ini parameter.
Be sure to create the index on the appropriate type table.
For example, although ‘keywords’ is an attribute of the dm_document type, it is actually inherited from ‘keywords’ from the dm_sysobject type.
Drop the Index if Necessary
If there is no performance improvement, OR the optimizer is not using the new index, drop it using:
EXECUTE drop_index [[FOR] dmi_index_id] [WITH name = index_name]
or
dmAPIGet(”apply,session,dmi_index_id,DROP_INDEX [,NAME,S,index_name]“)
21. Using the iapi utility and the trace API you can generate log information that contains the SQL resulting from a DQL query.
This is useful when it is a DQL query that is performing poorly and you wish to test using a nonsuperuser account. Non-query type APIs are not traced.
Here is an example of tracing a simple DQL query.
trace,c,10,,DM_QUERY.
More on TKPROF here
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm
22. DQL Hints
SELECT object_name FROM dm_document ENABLE (RETURN_TOP 10)
For DB2, performance can be improved using
SELECT object_name FROM dm_document ENABLE (RETURN_TOP 10, OPTIMIZE_TOP 10)
The FETCH_ALL_RESULTS N hint fetches all the results from the database
immediately and closes the cursor. The hint does not affect the execution plan,
but may free up database resources more quickly.
To fetch all the results, set N to 0.
On SQL Server, it is recommended that you use SQL_DEF_RESULT_SETS
instead of the FETCH_ALL_RESULTS hint. SQL_DEF_RESULTS_SETS
provides the same benefits and is the recommended way to access SQL Server
databases.
Passthrough hints are hints that are passed to the RDBMS server. They are not
handled by Content Server.
To include a passthrough hint, you must identify the database for which the
hint is valid. To identify the target database, keywords precede the hints. The
valid keywords are: ORACLE, SQL_SERVER, SYBASE, and DB2. For
example, the following statement includes passthrough hints for SQL Server:
SELECT “r_object_id” FROM “dm_document”
WHERE “object_name” =’test’
ENABLE SQL_SERVER(’ROBUST PLAN’,’FAST 4’,’ROBUST PLAN’)
For portability, you can include passthrough hints for multiple databases in
one statement. The entire list of hints must be enclosed in parentheses. The
syntax is:
(database_hint_list {,database_hint_list})
where database_hint_list is:
db_keyword(’hint’{,’hint})
db_keyword is one of the valid keywords identifying a database. hint is any hint
valid on the specified database.
For example:
SELECT object_name FROM dm_document doc dm_user u
WHERE doc.r_creator_name = u.user_name ENABLE
(ORACLE(’RULE’,’PARALLEL’), SYBASE(’AT ISOLATION READ
UNCOMMITTED’),SQL_SERVER(’LOOP JOIN’,’FAST 1’)
Use FETCH_ALL_RESULTS if you want to reduce the resources used by the
database server by quickly closing cursors. On SQL Server, try
FETCH_ALL_RESULTS if using SQL_DEF_RESULT_SETS did not improve
query performance.
23. If the table is registered, check with the owner of the registered table, or a Documentum superuser, about giving you access to the table.
You will need at least a BROWSE permit on the registered table object in order to access it. If the table has not yet been registered, check with the table’s owner about registering it. Note that you must have READ access to the dm_registered object for this table in order to access it in any way (SELECT, INSERT, UPDATE, DELETE).
Note that if you specified the special dm_dbo document base owner, the first parameter will hold the actual name of the document base owner.
24. DQL to list docbrokers
execute list_targets
25. DQL to list worrkflow information
select task_name, task_state, actual_start_date, dequeued_date from dmi_queue_item where router_id = ‘workflowId’
26. Query to find active workflows, supervisors of the workflows
select r_object_id, object_name, title, owner_name,r_object_type, r_creation_date, r_modify_date, a_content_type from dm_document where r_object_id in(select r_component_id from dmi_package where r_workflow_id in (select r_object_id from dm_workflow where r_runtime_state = 1))
27. Though this is not DQL, I thought of mentioning here as it most widely used DFC operation
sysObject.queue (”dm_autorender_win31?, _
“rendition”, _
0, _
False, _
dueDate, _
“rendition_req_ps_pdf”)
28. To find ACLs related to dm_sysobject:
select r_object_id as obj_id, object_name from
dm_sysobject (all)
where acl_name =” and
acl_domain = ”
To find ACLs as the default ACL of a user:
select user_name from dm_user where acl_name=”
To find ACLs associated with a type:
select r_object_id, r_type_name from dmi_type_info where acl_domain=” and acl_name=”
When these queries do not return any related objects and you still cannot delete the ACL, use tracing:
In the Message Tester or IAPI, execute the command: apply,c,NULL,SQL_TRACE,LEVEL,I,1
Then, try to delete the ACL that is causing problem.
Turn off tracing by executing:
apply,c,NULL,SQL_TRACE,LEVEL,I,0
Examine the session log for the trace output, located in $DOCUMENTUM/dba/log//
Excerpt of the session log:
[DM_ACL_E_DESTROY_IN_USE]error: “Failed to destroy the ACL ‘Documentum Users’ in domain ‘dbabep’ because it is in use.”
[DM_SESSION_I_SESSION_QUIT]info: “Session 01000dcb80010ccf quit.”
Run the following query from Oracle SQL:
select r_object_id from dm_sysobject_s where acl_domain =’dbabep’ and acl_name =’Documentum Users’ union select r_object_id from dm_user_s where acl_domain = ‘dbabep’ and acl_name =’Documentum Users’ union select r_object_id from dmi_type_info_s where acl_domain =’dbabep’ and acl_name =’Documentum Users’
It will return the r_object_id value = 09000dcb800362c4.
Run the following query from IDQL:
select object_name
from dm_sysobject
where r_object_id=’09000dcb800362c4′
If the above query returned nothing, then this object cannot be accessed by any Documentum WorkSpace method, only via SQL in the underlying Oracle database. The following entries must be deleted at the RDBMS level: dm_sysobject_s and dm_sysobject_r tables; there are no entries in the dmi_object table
29. List of object types and corresponding identifiers. Helpful when reading the code.
00 dmi_audittrail_attrs
03 dm_type
05 dmr_containment
06 dmr_content
08 dm_application
08 dm_job
08 dm_procedure
08 dm_query
08 dm_script
08 dm_smart_list
09 dm_document
0b dm_folder
0c dm_cabinet
0d dm_assembly
10 dm_method
11 dm_user
12 dm_group
19 dm_registered
1f dmi_index
26 dmi_registry
27 dm_format
28 dm_filestore
28 dm_store
2c dm_distributedstore
2e dmi_type_info
2f dm_dump_record
30 dmi_dump_object_record
31 dm_load_record
32 dmi_load_object_record
37 dm_relation
3a dm_location
3b dm_fulltext_index
3c dm_docbase_config
3d dm_server_config
40 dm_blobstore
41 dm_note
45 dm_acl
46 dm_policy
49 dmi_package
4a dmi_workitem
4c dm_activity
4d dm_workflow
53 dm_literal_expr
5e dm_federation
5f dm_audittrail_acl
5f dm_audittrail_group
5f dm_audittrail
66 dm_alias_set
6a dmi_dd_attr_info
0b dm_taxonomy
0b dm_xml_application
6b dm_display_config
20 dmi_sequence
30. Job scheduler Query
SELECT ALL r_object_id, a_next_invocation
FROM dm_job
WHERE (
(run_now = 1)
OR ( (is_inactive = 0)
AND ( ( a_next_invocation <= DATE(’now’)
AND a_next_invocation IS NOT NULLDATE )
OR ( a_next_continuation DATE(’now’))
OR (expiration_date IS NULLDATE))
AND ( (max_iterations = 0)
OR (a_iterations Template Properties
3) Under Template Audit Trail Setting, select option ‘Always On’ – Audit trail data for each instance will be available and saved at workflow completions.
31. In a workflow, a performer can enter comments while he/she is performing the task. And those comments are carried to the next performer in this workflow. When using WebPublisher workflow report to review the workflow instances, and in workflow history, you are only able to get the truncated comments back from WP’s interface. Especially for those already aborted workflow instances, there is no way that you can get the complete comments back from WP’s GUI. In some cases, those comments are very important to our customers and they need to find a way to get those comments back.
Here is the steps to get those comments back:
==
1) Identify the workflow from the dm_workflow table, get the r_object_id of the workflow:
select r_object_id, object_name from dm_workflow where object_name = ‘your work flow name’
2) Identify the notes that are carried by this workflow:
select r_note_id from dmi_package where r_workflow_id = ‘ the object id of the workflow’
3) Get the content id of each of those note ids returned:
select r_object_id from dmr_content where any parent_id = ‘the note id’
4) Go to DA, Administration->Job Management->Administration, use the “GET_PATH” method to find out the path of the files which stores the comments.
32. Query to get all documents expired in previous 1 month
SELECT s.r_object_id, s.object_name, DATETOSTRING(”r.a_expiration_date”,’mm/dd/yyyy’) as creation_date
FROM dm_sysobject_s s, dm_sysobject_r r
WHERE s.r_object_id = r.r_object_id
AND s.r_object_type = ‘dm_document’
AND DATEDIFF(month,”r.a_expiration_date”,DATE(NOW)) >= 0
AND DATEDIFF(month,”r.a_expiration_date”,DATE(NOW)) <= 1
AND r.r_version_label = ‘Expired’
ORDER BY 3
33. DQL to find all the folders in a Cabinet, where the folders are contentless
SELECT f1.object_name, f1.r_object_id, f1.r_folder_path
FROM dm_folder f1
WHERE FOLDER(’/Cabinetname’,descend)
AND NOT EXISTS (SELECT f2.object_name FROM dm_sysobject f2 WHERE ANY f2.i_folder_id = f1.r_object_id)
ORDER BY object_name
34. Find Super Groups and sub groups
select distinct r_object_id, group_name as super_groups
from dm_group_sp where group_name not in (select gs.group_name
from dm_group_r gr, dm_group_s gs
where gr.r_object_id = gs.r_object_id
group by gs.group_name
having count(gr.i_supergroups_names) > 1)
union
select distinct r_object_id, group_name as sub_groups
from dm_group_sp where group_name in (select gs.group_name
from dm_group_r gr, dm_group_s gs
where gr.r_object_id = gs.r_object_id
group by gs.group_name
having count(gr.i_supergroups_names) > 1) ;
35. DQL for finding all checked out documents in a docbase
select * from dm_document where (r_lock_owner is not nullstring or r_lock_owner ” or r_lock_owner ‘ ‘)
36.DQL to list the users who has access to particular folder path
SELECT i_all_users_names FROM dm_group
WHERE group_name IN (SELECT r_accessor_name FROM dm_acl
WHERE object_name IN (SELECT acl_name FROM dm_folder
WHERE ANY r_folder_path = ‘/folderpath’))
ORDER BY i_all_users_names
37. Query to find out what user signed off on what document
SELECT “audited_obj_id” FROM “dm_audittrail” WHERE
“event_name” = ‘dm_signoff’ AND
“user_name” = ‘tom’ AND
substr (”audited_obj_id”, 1, 2) = ‘09’AND
“time_stamp” >= DATE(’01/01/1998′, ‘dd/mm/yy’) AND
“time_stamp” SELECT object_name, r_version_label FROM dm_sysobject where any r_version_label in (’WIP’) and r_object_id not in (select r_object_id from dm_sysobject where any r_version_label in (’Staging’, ‘Approved’, ‘Expired’) )
39. Query to get all expired documents in previous month
SELECT s.r_object_id, s.object_name, DATETOSTRING(”r.a_expiration_date”,’mm/dd/yyyy’) as creation_date
FROM dm_sysobject_s s, dm_sysobject_r r
WHERE s.r_object_id = r.r_object_id
AND s.r_object_type = ‘dm_document’
AND DATEDIFF(month,”r.a_expiration_date”,DATE(NOW)) >= 0
AND DATEDIFF(month,”r.a_expiration_date”,DATE(NOW)) <= 1
AND r.r_version_label = ‘Expired’
ORDER BY 3
0. Query to find the file system path location of a document
select doc.r_object_id, doc.object_name, MFILE_URL(”,-1,”) as mypath,doc.i_folder_id from dm_document doc
where
——————————————————————
Thursday, March 22, 2007
DQL Tips
————————————————————————————-
*** get CURRENT TIME on server ***
select DATE(NOW) as systime from dm_server_config
————————————————————————————-
*** get the implicit version label ***
select s.r_object_id,s.object_name,r.r_version_label from dm_sysobject s, dm_sysobject_r r where r.r_object_id = s.r_object_id and
r.i_position = -1
————————————————————————————-
*** include r_object_id to remove blank rows
select object_name, r_object_id, a_expiration_date from dfas_common where folder(‘/Raj Srinivasan’) and any a_expiration_date is not nulldate
————————————————————————————-
*** select documents with pdf renditions (optimized for performance) ***
select * from dm_document where exists(select * from dmr_content where any parent_id=dm_document.r_object_id and full_format=’pdf’)
————————————————————————————-
*** select all documents that have nulldate in repeating attribute
select object_name from dfas_common where folder(‘/Raj Srinivasan) and r_object_id NOT IN (select r_object_id from dfas_common where folder(‘/Raj Srinivasan’) and any a_expiration_date is not nulldate)
————————————————————————————-
*** select all documents that have nulldate in repeating attribute or a_expiration_date has past
select count(*) from dfas_common where folder(‘/content/Corporate Resources/Human Resources’,descend) and (any a_expiration_date <
date(today) or (r_object_id NOT IN (select r_object_id from dfas_common where folder('/content/Corporate Resources/Human Resources',descend)
and any a_expiration_date is not nulldate)))
————————————————————————————-
*** select folderpath with filename
select distinct s.object_name, fr.r_folder_path from dm_sysobject (all)
s,dm_sysobject_r sr,dm_folder_r fr where sr.i_position = -1 and
sr.r_object_id = s.r_object_id and fr.r_object_id = sr.i_folder_id and
fr.i_position = -1 and fr.r_folder_path like '/ChemNet/%'
order by fr.r_folder_path,s.object_name
————————————————————————————-
*** empty folders ***
SELECT r_object_id,r_folder_path FROM dm_folder f WHERE r_object_id NOT IN
(SELECT distinct i_folder_id FROM dm_sysobject WHERE any i_folder_id = f.r_object_id and folder('/content',descend)) and folder('/content',descend)
————————————————————————————-
*** NULL a_effective_date ***
select object_name from dfas_common where folder('/images', descend) and r_object_id NOT IN (select r_object_id from dfas_common where folder('/images', descend) and any a_effective_date is not nulldate)
————————————————————————————-
*** select component from workitem ***
select
r_component_id
from
dmi_package p
where
exists (select r_object_id
from dmi_workitem w
where
w.r_object_id = and
w.r_workflow_id = p.r_workflow_id and
w.r_act_seq_no = p.r_act_seq_no)
————————————————————————————-
*** select renditions ***
SELECT s.object_name, f.dos_extension
FROM dm_dbo.dm_sysobject_s s, dm_dbo.dmr_content_r c, dm_dbo.dm_format_s f
WHERE (c.parent_id = s.r_object_id)
and (c.i_format = f.r_object_id)
AND c.page=0 AND f.dos_extension ‘xml’
AND folder(‘/whatever’)
————————————————————————————-
*** find workflow given document ***
select * from dm_workflow where r_object_id in (select r_workflow_id from dmi_package where any r_component_id in (select r_object_id from
dm_sysobject (all) where i_chronicle_id in (select i_chronicle_id from dm_sysobject where r_object_id=”))) and r_runtime_state=’1′
————————————————————————————-
*** return only inherited attributes ***
SELECT attr_name FROM dmi_dd_attr_info WHERE type_name = ‘my_custom_type’ AND attr_name NOT IN
(SELECT attr_name FROM dmi_dd_attr_info WHERE type_name = ‘dm_document’)
————————————————————————————-
Documents that are uploaded in to docbase b/w Aug 2004 and Oct 2004
select a.r_object_id,a.r_creation_date,a.r_modify_date,b.user_group_name
from dm_document a, dm_user b
where (a.r_creation_date >= Date(’08/01/2004′,’mm/dd/yyyy’) and a.r_creation_date 0
————————————————————————————-
Subject: Why do we create four views for each subtype?
Note: For example the type dm_document has four views:
dm_document_sp
dm_document_sv
dm_document_rp
dm_document_rv
The two _sp and _rp views are used by DQL and the two
_sv and _rv views are used by the Object Manager.
Also, the _sp and _sv views are for single (non-repeating) attributes, while the _rv and _rp views are for repeating attibutes.
————————————————————————————-
Label Text of the either Sytem Type or Custom Type
select label_text from dm_nls_dd_info where parent_id in
(select r_object_id from dm_aggr_domain where type_name = ‘field_type’)
Results:
Content Location
Keywords Category
Business Unit Owner
————————————————————————————-
DQL to list all documents attributes and their associated folder path
select s.object_name, fr.r_folder_path
from dm_document s, dm_sysobject_r sr,
dm_folder_r fr
where s.i_is_deleted = 0
and sr.i_position = -1
and sr.r_object_id = s.r_object_id
and fr.r_object_id = sr.i_folder_id
and FOLDER(‘/ChemNet’, descend)
and fr.r_folder_path like ‘/ChemNet/%’
order by fr.r_folder_path,s.object_name
————————————————————————————-
*** Web cabinet of a content ***
SELECT object_name FROM dm_cabinet
WHERE r_object_id IN (SELECT i_cabinet_id FROM dm_folder
WHERE r_object_id IN (SELECT i_folder_id FROM dm_document (ALL)
WHERE object_name like ‘test%’)) AND r_object_type=’wcm_channel’
OR
select r_object_id, object_name from wcm_channel where r_object_id in
(select i_ancestor_id from dm_folder where r_object_id in
(select i_folder_id from dm_sysobject where object_name = ‘test’))
————————————————————————————-
*** To get the first level folders from the cabinets ***
select object_name from dm_folder where any i_folder_id in (select r_object_id from dm_cabinet where object_name=’Cabinets’)
————————————————————————————-
*** To show the previous Active content ***
select r_object_id,i_chronicle_id,DATETOSTRING(DATE(TODAY),’ddmmyyyy’) as sysdate from dm_document (ALL) where object_name like ‘test%’ and
FOLDER(‘/ChemNet/ChemonicsProcess/Bidding’) and
any r_version_label = ‘Active’
————————————————————————————-
To find the folders for particular group for specified permission
select for write object_name from dm_folder where acl_name IN (select object_name from dm_acl where any r_accessor_name = ‘dm_world’) and folder(‘/ChemNet’,descend)
or
select object_name from dm_folder where acl_name IN (select object_name from dm_acl where any r_accessor_name = ‘dm_world’ and any r_accessor_permit = ‘7’) and folder(‘/ChemNet’,descend)
1 – NONE
2 – BROWSE
3 – READ
4 – RELATE
5 – VERSION
6 – WRITE
7 – DELTE
————————————————————————————-
DFC to insert rows into registered table
public static IDfCollection execQuery(String queryString, IDfSession session)
throws DfException{
IDfCollection col = null; //Collection for the result
IDfClientX clientx = new DfClientX();
IDfQuery q = clientx.getQuery(); //Create query object
q.setDQL(queryString); //Give it the query
// example queryString: “insert into dm_dbo.your_registered_table
(field1, [field]) values(,[
col = q.execute(session, IDfQuery.DF_EXEC_QUERY);
System.out.println(“Query executed.”);
return col;
}
————————————————————————————-
How to avoid redundancy for this simple query?
select distinct d.object_name,sys.authors from dm_document d, dm_sysobject_r sys
where folder (‘/xyz/xyz_first’) and
d.r_object_id = sys.r_object_id and
(sys.i_position=-1 or (sys.i_position<=-2 and sys.authors is not null))


Sunday, March 15, 2015

Deployment Steps for BOCS

Deployment Steps for BOCS
Follow these generic steps to deploy the Documentum Branch Office Caching Services patch.
To deploy the Patch:
1. Stop the JBoss Server.
2. Backup the following file to revert to the original installed product: is the root directory of BOCS webapp installation. For example, with JBoss it would be: %DOCUMENTUM_HOME%\jboss4.2.0\server\DctmServer_MethodServer\deploy\bocs.ear\ APP-INF\lib · /APP-INF/lib/common.jar as common.jar.BAK
· /APP-INF/lib/web.jar as web.jar.BAK
· /APP-INF/lib/jmx.jar as jmx.jar.BAK
· /APP-INF/lib/dfc.jar as dfc.jar.BAK
 · /APP-INF/lib/ucf-server-api.jar as ucf-server-api.BAK
· /APP-INF/lib/ucf-server-impl.jar as ucf-server-impl.BAK
· /APP-INF/classes/app_osgi_config.properties as app_osgi_config.properties.bak
3. Place the provided jars in the following directory:
 /APP-INF/lib/
 · common.jar
· web.jar
· jmx.jar
· dfc.jar
· ucf-server-api.jar
 · ucf-server-impl.jar
 4. Place the provided properties file in the following directory: /APP-INF/classes/
 · app_osgi_config.properties
5. Clear the JBoss cache present in the following path: %DOCUMENTUM_HOME%\\server\DctmServer_MethodServer\ tmp
 6. Clear Felix cache by clearing the following directory: 
%DOCUMENTUM_HOME%\\server\felix-cache

7. Start the JBoss server.

Sunday, March 8, 2015

DFS Sample Checkin and Checkout Operations

/**
 *
 */
package dfs;


import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.codehaus.groovy.ant.FileScanner;


import com.documentum.xms.core.recipe.config.PropertySet;
import com.emc.documentum.fs.datamodel.core.DataObject;
import com.emc.documentum.fs.datamodel.core.DataPackage;
import com.emc.documentum.fs.datamodel.core.ObjectIdentity;
import com.emc.documentum.fs.datamodel.core.ObjectIdentitySet;
import com.emc.documentum.fs.datamodel.core.ObjectPath;
import com.emc.documentum.fs.datamodel.core.OperationOptions;
import com.emc.documentum.fs.datamodel.core.Qualification;
import com.emc.documentum.fs.datamodel.core.ReferenceRelationship;
import com.emc.documentum.fs.datamodel.core.Relationship;
import com.emc.documentum.fs.datamodel.core.VersionInfo;
import com.emc.documentum.fs.datamodel.core.VersionStrategy;
import com.emc.documentum.fs.datamodel.core.content.FileContent;
import com.emc.documentum.fs.datamodel.core.content.RenditionType;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.datamodel.core.profiles.ContentProfile;
import com.emc.documentum.fs.datamodel.core.profiles.FormatFilter;
import com.emc.documentum.fs.datamodel.core.profiles.PageFilter;
import com.emc.documentum.fs.datamodel.core.profiles.PageModifierFilter;
import com.emc.documentum.fs.rt.ServiceException;
import com.emc.documentum.fs.rt.ServiceInvocationException;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.emc.documentum.fs.services.core.CoreServiceException;
import com.emc.documentum.fs.services.core.client.IObjectService;
import com.emc.documentum.fs.services.core.client.IVersionControlService;
import com.emc.documentum.fs.services.core.impl.ObjectService;

/**
 * @author mpoli_fujitsu
 *
 */
public class SimpleClient {
public static final String repositoyName="XXXX";
public static final String userName="XXX";
public static final String passWord="XXXX";
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ContextFactory contextfact= ContextFactory.getInstance();
IServiceContext seriveContext=contextfact.newContext();
RepositoryIdentity repid=new RepositoryIdentity();
repid.setRepositoryName(repositoyName);
repid.setPassword(passWord);
repid.setUserName(userName);
seriveContext.addIdentity(repid);
IObjectService ios=ServiceFactory.getInstance().getRemoteService(IObjectService.class, seriveContext,"core","http://abcdf:9080/services");
String file="D:/CTS_6.7_installation.pdf";
/* String folderPath="/Test";
//createWithContentDefaultContext(file,ios);
DataPackage obj= createAndLinkToFolder(folderPath,ios,file);
List<DataObject> dataObjects = obj.getDataObjects();

for (DataObject dObj : dataObjects)
{
com.emc.documentum.fs.datamodel.core.properties.PropertySet docProperties = dObj.getProperties();
String objectId = dObj.getIdentity().getValueAsString();
System.out.println(objectId);
}*/

//System.out.println(ps.get("r_object_id").getValueAsObject());
Qualification qualification=new Qualification("dm_document where r_object_id='09021e3c80036e0c'");
ObjectIdentity targetObjectIdentity=new ObjectIdentity(qualification,"XXXX");
checkin(targetObjectIdentity,file);
/*ObjectIdentitySet objidset=new ObjectIdentitySet(targetObjectIdentity);
OperationOptions opts=new OperationOptions();
DataPackage datapack=ios.get(objidset, opts);*/
/*Iterator itr=datapack.getDataObjects().iterator();

while(itr.hasNext())
{
System.out.println("success");
DataObject dobj=(DataObject)itr.next();
com.emc.documentum.fs.datamodel.core.properties.PropertySet ps=dobj.getProperties();
System.out.println(ps.get("object_name").getValueAsString());
System.out.println("title"+ps.get("title").getValueAsString());
ps.set("title","new title addedd");


}*/

}
public static DataPackage createWithContentDefaultContext(String filePath,IObjectService ios)
throws ServiceException
{
File testFile = new File(filePath);
if (!testFile.exists())
{
throw new RuntimeException("Test file: " +
testFile.toString() +
" does not exist");
}
ObjectIdentity objIdentity = new ObjectIdentity(repositoyName);
DataObject dataObject = new DataObject(objIdentity, "dm_document");
com.emc.documentum.fs.datamodel.core.properties.PropertySet properties = dataObject.getProperties();
properties.set("object_name", "MyImage");
properties.set("title", "MyImage");
properties.set("a_content_type", "gif");
dataObject.getContents().add(new FileContent(testFile.getAbsolutePath(), "pdf"));
OperationOptions operationOptions = null;
return ios.create(new DataPackage(dataObject), operationOptions);

}
public static DataPackage createAndLinkToFolder(String folderPath,IObjectService ios,String filePath)
{
try
{
File testFile = new File(filePath);
if (!testFile.exists())
{
throw new RuntimeException("Test file: " +testFile.toString() +" does not exist");
}
// create a contentless document to link into folder
String objectName = testFile.getName();
ObjectIdentity sampleObjId = new ObjectIdentity(repositoyName);
DataObject sampleDataObject = new DataObject(sampleObjId, "dm_document");
sampleDataObject.getProperties().set("object_name", objectName);
sampleDataObject.getContents().add(new FileContent(testFile.getAbsolutePath(), "pdf"));

// add the folder to link to as a ReferenceRelationship
ObjectPath objectPath = new ObjectPath(folderPath);
ObjectIdentity<ObjectPath> sampleFolderIdentity = new ObjectIdentity<ObjectPath>(objectPath, repositoyName);
ReferenceRelationship sampleFolderRelationship = new ReferenceRelationship();
sampleFolderRelationship.setName(Relationship.RELATIONSHIP_FOLDER);
sampleFolderRelationship.setTarget(sampleFolderIdentity);
sampleFolderRelationship.setTargetRole(Relationship.ROLE_PARENT);
sampleDataObject.getRelationships().add(sampleFolderRelationship);
// create a new document linked into parent folder

OperationOptions operationOptions = null;
DataPackage dataPackage = new DataPackage(sampleDataObject);
ios.create(dataPackage, operationOptions);

//  System.out.println("before create"+);
return ios.create(dataPackage, operationOptions);
}
catch (ServiceException e)
{
throw new RuntimeException(e);
}

}
public static DataPackage checkout(ObjectIdentity objIdentity)
throws ServiceException
{
ContextFactory contextfact= ContextFactory.getInstance();
IServiceContext seriveContext=contextfact.newContext();
RepositoryIdentity repid=new RepositoryIdentity();
repid.setRepositoryName(repositoyName);
repid.setPassword(passWord);
repid.setUserName(userName);
seriveContext.addIdentity(repid);
IVersionControlService versionControlService=ServiceFactory.getInstance().getRemoteService(IVersionControlService.class, seriveContext,"core","http://abcdf::9080/services");
ObjectIdentitySet objIdSet = new ObjectIdentitySet();
objIdSet.getIdentities().add(objIdentity);
OperationOptions operationOptions = null;
DataPackage resultDp;
try
{
resultDp = versionControlService.checkout(objIdSet, operationOptions);

}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println("Checkout successful");
List<VersionInfo> vInfo = versionControlService.getVersionInfo(objIdSet);
VersionInfo versionInfo = vInfo.get(0);
System.out.println("Printing version info for " + versionInfo.getIdentity());
System.out.println("isCurrent is " + versionInfo.isCurrent());
System.out.println("Version is " + versionInfo.getVersion());
System.out.println("Symbolic labels are: ");
for (String label : versionInfo.getSymbolicLabels())
{
System.out.println(label);
}
//versionControlService.cancelCheckout(objIdSet);
//System.out.println("Checkout cancelled");
return resultDp;
}
public static DataPackage checkin(ObjectIdentity objIdentity, String newContentPath)
throws Exception
{
ContextFactory contextfact= ContextFactory.getInstance();
IServiceContext seriveContext=contextfact.newContext();
RepositoryIdentity repid=new RepositoryIdentity();
repid.setRepositoryName(repositoyName);
repid.setPassword(passWord);
repid.setUserName(userName);
seriveContext.addIdentity(repid);
IVersionControlService versionControlService=ServiceFactory.getInstance().getRemoteService(IVersionControlService.class, seriveContext,"core","http://abcdf::9080/services");
ObjectIdentitySet objIdSet = new ObjectIdentitySet();
objIdSet.getIdentities().add(objIdentity);
OperationOptions operationOptions = new OperationOptions();
ContentProfile contentProfile = new ContentProfile(FormatFilter.ANY, null,PageFilter.ANY,-1,PageModifierFilter.ANY,null);
operationOptions.setContentProfile(contentProfile);
DataPackage checkinPackage = versionControlService.checkout(objIdSet, operationOptions);
DataObject checkinObj = checkinPackage.getDataObjects().get(0);
checkinObj.setContents(null);
FileContent newContent = new FileContent();
newContent.setLocalPath(newContentPath);
// newContent.setRenditionType(RenditionType.PRIMARY);
newContent.setFormat(getExtension(newContentPath));
checkinObj.getContents().add(newContent);
boolean retainLock = false;
List<String> labels = new ArrayList<String>();
labels.add("CURRENT");
DataPackage resultDp;
try
{
resultDp = versionControlService.checkin(checkinPackage,VersionStrategy.NEXT_MINOR,retainLock,labels,operationOptions);
}
catch (ServiceException sE)
{
sE.printStackTrace();
throw new RuntimeException(sE);
}
return resultDp;
}
private static final String getExtension(final String FPATH) {
//final String FPATH = "/home/mem/index.html";
   Filename myHomePage = new Filename(FPATH, '/', '.');
   System.out.println("Extension = " + myHomePage.extension());
   System.out.println("Filename = " + myHomePage.filename());
   System.out.println("Path = " + myHomePage.path());
   return myHomePage.extension();
}
}
class Filename {
 private String fullPath;
 private char pathSeparator, extensionSeparator;

 public Filename(String str, char sep, char ext) {
   fullPath = str;
   pathSeparator = sep;
   extensionSeparator = ext;
 }

 public String extension() {
   int dot = fullPath.lastIndexOf(extensionSeparator);
   return fullPath.substring(dot + 1);
 }

 public String filename() { // gets filename without extension
   int dot = fullPath.lastIndexOf(extensionSeparator);
   int sep = fullPath.lastIndexOf(pathSeparator);
   return fullPath.substring(sep + 1, dot);
 }

 public String path() {
   int sep = fullPath.lastIndexOf(pathSeparator);
   return fullPath.substring(0, sep);
 }
}