Hi all,
I am getting an exception whenever i try to access get() and move() method.
Actuallty,
- DFS does not return anything upon calling the get method of Object Service.
It fails at following statement: dataPackage = objectService.get(objectIdentitySet, operationOptions);
Error message being returned is “Operation output generation failed: could not retrieve data for identity: dm_document where r_object_id = '0901eb908000870b'”.
If operationOptions is set as null, then it returns the file properties, but not the contents.
- Move Files: DFS does not move the contents as per the mentioned parameters.
If fails at following statement: DataPackage dataPackage = objectService.move(identitySet, fromLocation, toLocation, new DataPackage(), null);
Error message being returned is “'Move' operation failed for object: XXXX"
Here are the two metod that i have written:
private
void MoveFiles(List<string> sourceFileList, string targetFolderLocation)
{
try
{
ObjectServicePortClient objectService = new ObjectServicePortClient();
OperationContextScope scope = new OperationContextScope(objectService.InnerChannel);
ServiceContextHeader scx = new ServiceContextHeader();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.repositoryName =
ConfigurationManager.AppSettings["Repository"].ToString();
repoId.userName =
ConfigurationManager.AppSettings["DocumentumUsername"].ToString();
repoId.password =
ConfigurationManager.AppSettings["DocumentumPassword"].ToString();
scx.AddRepositoryIdentity(repoId);
OperationContext.Current.OutgoingMessageHeaders.Add(scx);
string strTargetLoc = "/DFSCabinet1";
string targetLocPathString = strTargetLoc + targetFolderLocation;
string sourceObjectPathString = string.Empty;
string sourceLocPathString = "/DFSCabinet2";
string sourceFolder = string.Empty;
foreach (string sourceFilePath in sourceFileList)
{
sourceFolder = sourceLocPathString + sourceFilePath.Split(
'/')[0];//From Folder name
sourceObjectPathString = sourceLocPathString + sourceFilePath;
// from folder + filename
ObjectPath objPath = new ObjectPath();
objPath.path = sourceObjectPathString;
ObjectIdentity docToCopy = new ObjectIdentity();
docToCopy.Item = objPath;
docToCopy.valueType =
ObjectIdentityType.OBJECT_PATH;
docToCopy.valueTypeSpecified =
true;
docToCopy.repositoryName =
ConfigurationManager.AppSettings["Repository"].ToString();
ObjectIdentitySet identitySet = new ObjectIdentitySet();
identitySet.Identities =
new ObjectIdentity[1];
identitySet.Identities[0] = docToCopy;
ObjectPath fromFolderPath = new ObjectPath();
fromFolderPath.path = sourceFolder;
ObjectIdentity fromFolderPathIdentity = new ObjectIdentity();
fromFolderPathIdentity.Item = fromFolderPath;
fromFolderPathIdentity.valueType =
ObjectIdentityType.OBJECT_PATH;
fromFolderPathIdentity.valueTypeSpecified =
true;
fromFolderPathIdentity.repositoryName =
ConfigurationManager.AppSettings["Repository"].ToString();
ObjectLocation fromLocation = new ObjectLocation();
fromLocation.Identity = fromFolderPathIdentity;
ObjectPath toFolderPath = new ObjectPath();
toFolderPath.path = targetLocPathString;
ObjectIdentity toFolderIdentity = new ObjectIdentity();
toFolderIdentity.Item = toFolderPath;
toFolderIdentity.valueType =
ObjectIdentityType.OBJECT_PATH;
toFolderIdentity.valueTypeSpecified =
true;
toFolderIdentity.repositoryName =
ConfigurationManager.AppSettings["ASI_Repository"].ToString();
ObjectLocation toLocation = new ObjectLocation();
toLocation.Identity = toFolderIdentity;
OperationOptions operationOptions = null;
DataPackage dataPackage = objectService.move(identitySet, fromLocation, toLocation, new DataPackage(), operationOptions);
}
}
catch
{
throw;
}
}
private
string SaveFiletoSharedPath(string docObectID, string
surrogateID)
{
string fileName = string
.Empty;
try
{
Qualification qualification = new Qualification
();
qualification.String =
"dm_document where r_object_id = '0901eb908000870b'";
qualification.qualificationValueType =
QualificationValueType
.STRING;
qualification.qualificationValueTypeSpecified =
true
;
ObjectIdentity objectIdentity = new ObjectIdentity
();
objectIdentity.valueType =
ObjectIdentityType
.QUALIFICATION;
objectIdentity.valueTypeSpecified =
true
;
objectIdentity.Item = qualification;
objectIdentity.repositoryName =
ConfigurationManager.AppSettings["Repository"
].ToString();
ObjectIdentitySet objectIdentitySet = new ObjectIdentitySet
();
objectIdentitySet.Identities =
new ObjectIdentity
[1];
objectIdentitySet.Identities[0] = objectIdentity;
ContentProfile contentProfile = new ContentProfile
();
contentProfile.formatFilter =
FormatFilter
.SPECIFIED;
contentProfile.format =
"pdf"
;
contentProfile.formatFilterSpecified =
true
;
OperationOptions operationOptions = new OperationOptions
();
operationOptions.Profiles =
new Profile
[1];
operationOptions.Profiles[0] = contentProfile;
ServiceContextHeader scx = new ServiceContextHeader
();
RepositoryIdentity repoId = new RepositoryIdentity
();
repoId.repositoryName =
ConfigurationManager.AppSettings["Repository"
].ToString();
repoId.userName =
ConfigurationManager.AppSettings["DocumentumUsername"
].ToString();
repoId.password =
ConfigurationManager.AppSettings["DocumentumPassword"
].ToString();
scx.AddRepositoryIdentity(repoId);
ObjectServicePortClient objectService = new ObjectServicePortClient
();
OperationContextScope scope = new OperationContextScope
(objectService.InnerChannel);
OperationContext
.Current.OutgoingMessageHeaders.Add(scx);
DataPackage dataPackage = null
;
dataPackage = objectService.get(objectIdentitySet, operationOptions);
foreach (Content content in
dataPackage.DataObjects[0].Contents)
{
Property
[] properties = dataPackage.DataObjects[0].Properties.Properties;
foreach (Property property in
properties)
{
if (property.name == "object_name"
)
{
StringProperty sProperty = property as StringProperty
;
if (sProperty != null && !string
.IsNullOrEmpty(sProperty.Value))
{
fileName = sProperty.Value;
break
;
}
}
}
if (content.format == "pdf"
)
{
fileName =
Path.ChangeExtension(fileName, "pdf"
);
}
if (!Directory.Exists(ConfigurationManager.AppSettings["SharedFolder"
].ToString() + surrogateID))
{
Directory.CreateDirectory(ConfigurationManager.AppSettings["SharedFolder"
].ToString() + surrogateID);
}
fileName =
Path.Combine(ConfigurationManager.AppSettings["SharedFolder"
].ToString() + surrogateID, fileName);
if (File
.Exists(fileName))
{
File
.Delete(fileName);
}
if (content is BinaryContent
)
{
BinaryContent bContent = content as BinaryContent
;
FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess
.ReadWrite);
fileStream.Write(bContent.Value, 0, bContent.Value.Length);
}
break
;
}
return
fileName;
}
catch
{
throw
;
Please help me out to resolve this issue. Thnks in advance
} } }
awsd