IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 6 replies
  • Latest Post - ‏2013-07-30T13:47:21Z by YBOT
YBOT
YBOT
8 Posts

Pinned topic ICN 2.0.1 - Create a simple updateProperty Custom action

‏2013-07-28T13:26:15Z | a action custom document's ecmhv ecmsupport for icn property simple updating

Hello everyone,

I try to create a simple new context menu action for FileNet documents that will update the value of a property, but I can't make it work.

I tried two approaches:

1) custom PluginAction + PluginService: the update of the property is performed by the execute Java method of the custom PluginService class.

2) custom PluginAction : the update of the property is performed by the custom javascript function in my custom plugin .js file

For the approach 1, I followed the instructions in the red book, I used on the javascript side a params object in which I define my custom properties, and I call

ecm.model.Request.invokePluginService("CustomPlugin",
            "CustomService",
            params);

The execute java method is called, but I can't retrieve my custom properties using request.getParameter method: I only have null values. Furthermore, I can't also retrieve parameters from the callback object on server side: exception is thrown

For the approach 2, I made the following in my custom javascript function:

    var myItem = items[0];
    myItem.retrievePermissions(function(response) {});
    var myAttributes;
        myAttributes = [
                {

                   // Simple update of the title property with the connected userId
                    DocumentTitle: myItem.getRepository().getUserId()
                }
            ];
        myItem.saveAttributes(
                myAttributes,
                myItem.template,
                myItem.childComponentValues,
                myItem.getPermissions(),
                false,
                function(response) {});
    }
 

But I can't make work the saveAttributes function, I get java.lang.NullPointerException (see full stacktrace below)

It seems that the permissions are null despite of the explicit call to the retrievePermissions function.

Can someone point me in the right direction please?

 

Thank you in advance,

 

28/07/13 14:57:34:267 CEST] 000000a0 SystemOut     O CIWEB Error: [p8admin @ p8server.p8domain.com] com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.updateItem()
java.lang.NullPointerException
    at com.ibm.ecm.util.p8.P8Util.setProperties(P8Util.java:136)
    at com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.updateItem(P8EditAttributesAction.java:285)
    at com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.executeAction(P8EditAttributesAction.java:139)
    at com.ibm.ecm.struts.actions.p8.P8BaseAction.executeBaseAction(P8BaseAction.java:180)
    at com.ibm.ecm.struts.actions.BaseAction.execute(BaseAction.java:176)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at com.ibm.ecm.struts.controller.ControllerServlet.process(ControllerServlet.java:239)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)

[28/07/13 14:57:34:267 CEST] 000000a0 SystemOut     O CIWEB Error: [p8admin @ p8server.p8domain.com] com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.updatePermissions()
java.lang.NullPointerException
    at com.ibm.ecm.util.p8.P8Permission.getPermissionsFromJSON(P8Permission.java:189)
    at com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.updatePermissions(P8EditAttributesAction.java:343)
    at com.ibm.ecm.struts.actions.p8.P8EditAttributesAction.executeAction(P8EditAttributesAction.java:142)
    at com.ibm.ecm.struts.actions.p8.P8BaseAction.executeBaseAction(P8BaseAction.java:180)
    at com.ibm.ecm.struts.actions.BaseAction.execute(BaseAction.java:176)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at com.ibm.ecm.struts.controller.ControllerServlet.process(ControllerServlet.java:239)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)
 

  • DavidGautier
    DavidGautier
    47 Posts
    ACCEPTED ANSWER

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T13:16:30Z  
    • YBOT
    • ‏2013-07-30T12:36:41Z

    Hello David,

    No you misunderstood my need: many users can subscribe the document, but only few authoring users can create new versions that will trigger the mail notification.

    Besides, I don't want to change the current behaviour as we have the same one with WorkplaceXT, and there will be a transition period during which users will subscribe through the WorkplaceXT, and other users will subscribe through the Content Navigator.

    Regards,
    Yohann

    You just need to add the new value like this:

     

    var properties = [
                                  {"name": "DocumentTitle",

                                  "value" : item.getRepository().getUserId()

    } ];
    item.saveAttributes(
                        properties,
                        item.template,
                        null,
                        null,
                        false,
                      callback
                );

    I f the user have rights to edit properties then it should works.

  • damorris
    damorris
    825 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-29T17:24:11Z  

    There is a trend on the recent posts :-)  Why do you need such an action?  ICN already lets you edit properties - why do you need a new action?  What unique feature is it that you need?

  • YBOT
    YBOT
    8 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T09:26:59Z  

    Thank you for your answer Dana.

    We need such an action to implement a "subscribe" functionality to enable users to be notified by email when a new version of the document is released.
    For this, we use a multi-valued property on the document that is filled with the names of the users interested in notifications. On checkin, a code module retrieves the list of the interested users and send them an email.
    To mask the complexity of this implementation to the end user, we want to implement that subscribe function that will automatically fill this multi-valued property with the login of the connected user, instead of letting him manually fill that property.

    No end user interface is required, and we already implemented that action in WorkplaceXT so that we now want to reproduce this behaviour in ICN.

    Do you have a hint about the fact that the retrievePermissions function doesn't work or about the usage of the saveAttributes function?

     

    Thank you in advance,

    Yohann

  • DavidGautier
    DavidGautier
    47 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T10:17:31Z  
    • YBOT
    • ‏2013-07-30T09:26:59Z

    Thank you for your answer Dana.

    We need such an action to implement a "subscribe" functionality to enable users to be notified by email when a new version of the document is released.
    For this, we use a multi-valued property on the document that is filled with the names of the users interested in notifications. On checkin, a code module retrieves the list of the interested users and send them an email.
    To mask the complexity of this implementation to the end user, we want to implement that subscribe function that will automatically fill this multi-valued property with the login of the connected user, instead of letting him manually fill that property.

    No end user interface is required, and we already implemented that action in WorkplaceXT so that we now want to reproduce this behaviour in ICN.

    Do you have a hint about the fact that the retrievePermissions function doesn't work or about the usage of the saveAttributes function?

     

    Thank you in advance,

    Yohann

    Hi,

    You need to add the user who updates the document in a multi value property when this user promotes a version right ?

    Maybe you should try with a preprocessor to retrieve the new user and add it to your multi valued property. I'm not sure about the fact that preprocessor catch promote events but if they do; this is definitely the best way (IMO ;) ) to do it.

    Regards,

  • YBOT
    YBOT
    8 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T12:36:41Z  

    Hello David,

    No you misunderstood my need: many users can subscribe the document, but only few authoring users can create new versions that will trigger the mail notification.

    Besides, I don't want to change the current behaviour as we have the same one with WorkplaceXT, and there will be a transition period during which users will subscribe through the WorkplaceXT, and other users will subscribe through the Content Navigator.

    Regards,
    Yohann

  • DavidGautier
    DavidGautier
    47 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T13:16:30Z  
    • YBOT
    • ‏2013-07-30T12:36:41Z

    Hello David,

    No you misunderstood my need: many users can subscribe the document, but only few authoring users can create new versions that will trigger the mail notification.

    Besides, I don't want to change the current behaviour as we have the same one with WorkplaceXT, and there will be a transition period during which users will subscribe through the WorkplaceXT, and other users will subscribe through the Content Navigator.

    Regards,
    Yohann

    You just need to add the new value like this:

     

    var properties = [
                                  {"name": "DocumentTitle",

                                  "value" : item.getRepository().getUserId()

    } ];
    item.saveAttributes(
                        properties,
                        item.template,
                        null,
                        null,
                        false,
                      callback
                );

    I f the user have rights to edit properties then it should works.

  • YBOT
    YBOT
    8 Posts

    Re: ICN 2.0.1 - Create a simple updateProperty Custom action

    ‏2013-07-30T13:47:21Z  

    Your solution works! the problem was simply coming from the syntax of the properties array,
    and I was dazzled by the fact that the item.retrievePermissions was returning null values and I thought it was the origin of the NullPointerException

    Merci David! :)