Hi there,
D2 is configured to use the Documentum Client Manager. And the default checkout and view path are defined in D2-Config for all users. The Checkout path is C:\D2\Checked
Now, the requirement. For a specific document type and format, when checking out a document, we need to add a subfolder to the check out path with a value from an attribute (project number). We have this requirement because we use a 3rd party app which is absolutely NOT flexible and allow us only to configure the root path (C:\D2\Checked) and requires the project number to be the last folder.
I generated a D2 plugin in which I created a D2DownloadServicePlugin in which I override the D2DownloadService getFile method
public DownloadFile getFile(Context context, String id, String formatName, int pageNumber, String pageModifier, String eventName) throws Exception
{
D2fsContext d2fsContext = (D2fsContext) context;
IDfSession session = d2fsContext.getSession();
ParameterParser parameterParser = d2fsContext.getParameterParser();
if (eventName.equals(D2DownloadProfile.DownloadAction.EDIT.toString()))
{
IDfSysObject sysObject = (IDfSysObject) d2fsContext.getObject(id);
// If the document is not one we need to process, we use the original getFile method
if (!sysObject.getContentType().equalsIgnoreCase("mycontent"))
{
this.LOG.debug("Not a My content document, using original method");
return super.getFile(context, id, formatName, pageNumber, pageModifier, eventName);
}
if (!sysObject.getTypeName().equalsIgnoreCase("mydoc"))
{
this.LOG.debug("Not a My Document, using original method");
return super.getFile(context, id, formatName, pageNumber, pageModifier, eventName);
}
if (sysObject.getString("project_number").isEmpty())
{
this.LOG.debug("No Project Number, using original method");
return super.getFile(context, id, formatName, pageNumber, pageModifier, eventName);
}
IDfFormat format = session.getFormat(sysObject.getContentType());
// We generate the file name with the sub-path
String fileName = "\\" + sysObject.getString("projectnumber") + "\\" + DfObjectUtilCore.getCompatibleFilenameForWindows(sysObject, format.getDOSExtension());
this.LOG.debug("File name= " + fileName);
File inputFile = new File(sysObject.getFileEx2(null, sysObject.getContentType(), pageNumber, pageModifier, false));
FileInputStream fis = new FileInputStream(inputFile);
DownloadFile result = new DownloadFile(fileName, fis, inputFile.length(), format.getMIMEType());
return result;
}
else
{
return super.getFile(context, id, formatName, pageNumber, pageModifier, eventName);
}
}
Now, when I look in the log, the file name is properly set to \projnumb\****.****
However, on the client, I see that my file has been put in C:\d2\checke\projnumb instead of
C:\d2\checked\projnumb
IT seems like the last letter of the check out path defined in t he preferences has been removed.
instead of \\ for the path delimiter, I tried all sort of encoding possible to make it HTML compliant but then the file is set in c:\d2\checked and it name includes the encoding….
Any idea?