File file = new File("E:\\filepath"+fileName);
context,
serviceModule,
contextRoot);
ObjectIdentity objIdentity = new ObjectIdentity(repositoryName);
DataObject dataObject = new DataObject(objIdentity,"dm_document");
PropertySet properties = dataObject.getProperties();
properties.set("object_name", fileName);
FileContent fileContent = new FileContent();
fileContent.setLocalPath(file.getAbsolutePath());
dataObject.getContents().add(fileContent);
PropertyProfile propertyProfile = new PropertyProfile();
propertyProfile.setFilterMode(PropertyFilterMode.ALL);
OperationOptions operationOptions = new OperationOptions();
operationOptions.setProfile(propertyProfile);
DataPackage newFilePropertiesInfo = objectService.create(new DataPackage(dataObject), operationOptions);
Sol--1--If you want to push content to a specific location pointed by file path, the standard way is to create a location object(dm_location) pointed by that file path,Then create file store pointing to that location object. Once it is done, you can push content either by setting a_storage_type attribute on each instance of dm_document or by creating an assignment policy with the appropriate rules to push content to that storage(create assingment with appropriate rules dones that automatically).
Sol--2--
I guess you are looking to create the content in specific cabinet/folder in docbase.
I am a newbie to DFS coding. So I will try.
I think you can add a relationship between document and folder dataObjects like this:
public void addChildObject(DataObject folder, DataObject childDoc)
{
folder.getRelationships().add(
new ObjectRelationship(childDoc, Relationship.RELATIONSHIP_FOLDER, Relationship.ROLE_CHILD)
);
}
{
String query = "select r_object_id from dm_folder where any r_folder_path = 'folderName'; // Of the form'/" + cabinetName + "/<your_path>"' Take care of nasty single quotes in the folder name.
PassthroughQuery query = new PassthroughQuery(Arrays.asList("YourDocbase"), queryString);
QueryExecution execution = new QueryExecution();
// create default OperationOptions using getQueryService().getServiceContext()
QueryResult result = getQueryService().execute(query, execution, null);
return result.getDataObjects().get(0);
}
sysObject.setRepeatingString("r_folder_path",0,"your_path");
operation.setDestinationFolderId("folder_id_from_query");
DFC is giving an error message "r_folder_path is not updateable'. Any ideas how to resolve it?
ReplyDelete