0

I am customizing ICN (IBM Content Navigator) 2.0.3 and my requirement is to restrict user to upload files over 10mb and only allowed files are .pdf or .docx.

I know I have to extend / customize the AddContentItemDialog but there is very less detail on exactly how to do it, or any video on it. I'd appreciate if someone could guide.

Thanks

I installed the development environment but I am not sure how to extend the AddContentItemDialog.

public void applicationInit(HttpServletRequest request,
        PluginServiceCallbacks callbacks) throws Exception {
}

I want to also know how to roll out the changes to ICN.

2 Answers 2

0

This can be easily extended. I would suggest to read the ICN red book for the details on how to do it. But it is pretty standard code.

Regarding rollout the code to ICN, there are two ways: - If you are using plugin: just replace the Jar file on the server location and restart WAS. - If you are using EDS: you need to redeploy the web service and restart WAS.

Hope this helps.

thanks

0

Although there are many ways to do this, one way indeed is tot extend, or augment the AddContentItemDialog as you qouted. After looking at the (rather poor IBM documentation) i figured you could probably use the onAdd event/method

Dojo/Aspect#around allows you to do exactly that, example:

require(["dojo/aspect", "ecm/widget/dialog/AddContentItemDialog"], function(aspect, AddContentItemDialog) {
    aspect.around(AddContentItemDialog.prototype, "onAdd", function advisor(original) {
        return function around() {

            var files = this.addContentItemGeneralPane.getFileInputFiles();
            var containsInvalidFiles = dojo.some(files, function isInvalid(file) {
                var fileName = file.name.toLowerCase();

                var extensionOK = fileName.endsWith(".pdf") || fileName.endsWith(".docx");
                var fileSizeOK = file.size <= 10 * 1024 * 1024;

                return !(extensionOK && fileSizeOK);
            });

            if (containsInvalidFiles) {
                alert("You can't add that :)");
            }else{
                original.apply(this, arguments);
            }

        }
    });
});

Just make sure this code gets executed before the actual dialog is opened. The best way to achieve this, is by wrapping this code in a new plugin.

Now on creating/deploying plugins -> The easiest way is this wizard for Eclipse (see also a repackaged version for newer eclipse versions). Just create a new arbitrary plugin, and paste this javascript code in the generated .js file.

Additionally it might be good to note that you're only limiting "this specific dialog" to upload specific files. It would probably be a good idea to also create a requestFilter to limit all possible uses of the addContent api...

Not the answer you're looking for? Browse other questions tagged or ask your own question.