D2 and D2DownloadServicePlugin issue

Francois Dauberlieu
edited December 3 in Documentum #1

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?

Tagged:

Answers

  • Michael McCollough
    Michael McCollough E Community Moderator

    Saw this and I have not done with the D2DownloadService. I have used D2X3ConfigService plugin to effectively do what you are speaking of and I believe it may be a bit simpler. Also we are in process of ensuring it works with our latest smartview version as well (24.4)

    If you are game to try that instead (not sure why your path is not working correctly but since I had something we had used, thought I woudl share alternative in case you can move quicker with it). Here you can intercept and change the returned download paths. Seems you might be doing a bit more with it but again, just trying to help with something I know of I have used in past.

  • Thanks Michael,

    I'm game. I'll give it a shot and will let you know

  • Unfortunately, that doesn't do the trick for multiple reasons:

    1. The context doesn't include the the objects or at least their id's therefore, I can't get the value of the attribute to generate the path (both when checkin out and in
    2. That generates the .d2_edit_storage.json file in every folders which might be confusing for other apps, by oing it in the
    3. I don't know what event called the getDownloadCheckoutLocation method (I don't want to change the user preferences for example if the user goes to their preferences….)

    By doing it in getFile method of the D2DownloadServicePlugin, that solves those points BUT then I get the folder issue as described in my 1st post.

    By the way, just for my sanity's sake, I decompile the com.emc.d2.web.servlets.ServletUtil class and ran in Debug, I saw that in the com.emc.d2.web.servlets getContentDisposition returns the expected value all properly encoded

    with my initial code, the .d2_edit_storage.json is at the proper location and there is only 1, no matter what document I check out.

    The only thing is that the last character of the path defined in the user's preferences is gone. it seems to me that the browser's plugin (DCMAPP) might be the culprit

  • Michael,

    I looked into the .js files in the DCMAPP install path but there's so many with string and character replacements that I wouldn't know where to begin looking

    If you or one of your team could point me to the right place, I might be able to find a solution…. OR if you guys want to take that offline, I guess you still have my email from the 1st dragon den…..

  • Michael McCollough
    Michael McCollough E Community Moderator

    Since you say there are no object ids in the context, I am assuming you are doing this for Smart View? We did have some work to enable this in Smart View and have 23.4 enabled for it but you will need a couple of hotfixes to use it properly. It should be there/seamless in our 24.4 release that should come in new week or so.

  • No, sorry I didn't mention that earlier, it's Classic 23.4. (also tried in 24.2 but same result)