8 Replies Latest reply on Jul 1, 2013 8:10 AM by Jörg Hoh

    Inbox Notification from Workflow

    mizakr

      Hi,

      I've got a problem with Inbox Notification.

      I want to inform an author about all steps during the workflow process (activated, deactivated, terminated) using Inbox Notification (not e-mail!)

      I found a class InboxManagerImpl (method createMessage) so I create a method in ParticipantStepChooser class:

       

      void sendTheNotification(WorkflowSession session) throws IOException {

      com.day.cq.wcm.notification.inbox.impl.MessageImpl message = (MessageImpl) new InboxManagerImpl().createMessage(session.getUser());

      message.setReason("Workflow has been Terminated");

      message.save();

      }

       

      but after it, on my OSGi Console in CQ5, in the section Bundles I have sth like this:

      com.day.cq.wcm.notification.inbox -- Cannot be resolved
      com.day.cq.wcm.notification.inbox.impl -- Cannot be resolved

       

      Can someone help me?

      Question: How to create an Inbox Message (in Notification Inbox) using Java code?

       

      Regards

      Michal

        • 1. Re: Inbox Notification from Workflow
          Sham HC Level 7

          Hi Michal,

           

              You can't call implementation class. Get the reference of inboxmanager and then create message.  Ex:-

           

           

              /** @scr.reference */

              private InboxManager inboxManager;

             

             

              final Message msg = this.inboxManager.createMessage(....);

           

          Thanks,

          Sham

          • 2. Re: Inbox Notification from Workflow
            mizakr Level 1

            Hi Sham,

            it's not working: in Web Console I still get a message that

            com.day.cq.wcm.notification.inbox -- Cannot be resolved

            .

            my code:

             

            import java.io.IOException;

            import com.day.cq.security.Authorizable;

            import com.day.cq.wcm.notification.inbox.InboxManager;

            import com.day.cq.wcm.notification.inbox.Message;

             

            public class MessageCreator {

             

                private InboxManager inboxManager;

             

                public void sendMessage(Authorizable user, String reason) throws IOException {

             

                    final Message msg = this.inboxManager.createMessage(user);

                    msg.setReason(reason);

                    msg.save();

                }

            }

             

            any others idea?

            • 3. Re: Inbox Notification from Workflow
              Jörg Hoh Adobe Employee

              Obviously your bundle does not provide the necessary import statements. Pleas check your maven setup (if you have one), that you have the proper dependencies declared.

               

              Jörg

              • 4. Re: Inbox Notification from Workflow
                Sham HC Level 7

                Hi Michal,

                 

                   Along with fixing Jörg update, in your code use reference for inboxManager.

                 

                Thanks,

                Sham

                • 5. Re: Inbox Notification from Workflow
                  mizakr Level 1

                  hey guys,

                  maven dependency for notification:

                   

                  <dependency>

                    <groupId>com.day.cq.wcm</groupId>

                    <artifactId>cq-wcm-notification</artifactId>

                  </dependency>

                   

                  I checked dependency in CQ5:

                  when I'm looking for "com.day.cq.wcm.notification.inbox.InboxManager" I get:

                  com.day.cq.wcm.notification.inboxNOT EXPORTED

                  what does it mean? :/

                   

                  Sham:

                  what you mean when you say "in your code use reference for inboxManager"?

                  • 6. Re: Inbox Notification from Workflow
                    Jörg Hoh Adobe Employee

                    That's because the bundle cq-wcm-notifications has this export list:

                     

                    Exported Packages

                    com.day.cq.wcm.notification,version=0.0.0

                    com.day.cq.wcm.notification.email,version=0.0.0

                     

                    It does not export the package com.day.cq.wcm.notification.inbox.InboxManager.

                     

                    (In CQ 5.5 this package is documented in the API docs, but that's probably an error, in 5.6 it is not contained in the official API docs anymore. On the other hand there is a service "InboxManager" available on CQ 5.5 ...)

                     

                    I recommend you to file a Daycare ticket to report this mismatch and to ask if that's a bundle problem (missing export statement) or if this service is not considered as public API.

                     

                    kind regards,

                    Jörg

                     

                     

                    ps: Sham recommended you to write

                     

                    @Reference

                    InboxManager inboxMgr;

                    • 7. Re: Inbox Notification from Workflow
                      maruthid Level 1

                      Hi Jorg,

                       

                      I am also having same issue in CQ5.5.2. Since OOTB bundle is not exporting can we export from our pom.xml?

                      If we export it is resolving but illegal argument error is coming.

                      Below is the error stack.

                       

                      01.07.2013 12:49:59.328 *ERROR* [OsgiInstallerImpl] com.aaa.dam.abc.core.OURCustomDamCore [com.aaa.dam.abc.services.workflow.impl.CustomWorkFlowStep] The unbindInboxManager method has thrown an exception (java.lang.IllegalArgumentException: argument type mismatch) java.lang.IllegalArgumentException: argument type mismatch

                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                at java.lang.reflect.Method.invoke(Method.java:597)

                                at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:227)

                                at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)

                                at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:591)

                                at org.apache.felix.scr.impl.helper.BaseMethod$NotResolved.invoke(BaseMethod.java:548)

                                at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:472)

                                at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager. java:1129)

                                at org.apache.felix.scr.impl.manager.DependencyManager.unbind(DependencyManager.java:993)

                                at org.apache.felix.scr.impl.manager.DependencyManager.close(DependencyManager.java:880)

                                at org.apache.felix.scr.impl.manager.ImmediateComponentManager.disposeImplementationObject(I mmediateComponentManager.java:268)

                                at org.apache.felix.scr.impl.manager.ImmediateComponentManager.deleteComponent(ImmediateComp onentManager.java:135)

                                at org.apache.felix.scr.impl.manager.DelayedComponentManager.deleteComponent(DelayedComponen tManager.java:67)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager$Satisfied.deactivate(AbstractC omponentManager.java:1223)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractCom ponentManager.java:339)

                                at org.apache.felix.scr.impl.manager.DependencyManager.serviceRemoved(DependencyManager.java :346)

                                at org.apache.felix.scr.impl.manager.DependencyManager.serviceChanged(DependencyManager.java :253)

                                at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat cher.java:871)

                                at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java :733)

                                at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662 )

                                at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3765)

                                at org.apache.felix.framework.Felix.access$000(Felix.java:80)

                                at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:722)

                                at org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:130)

                                at org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.jav a:129)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterComponentService(Abs tractComponentManager.java:565)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager$Satisfied.deactivate(AbstractC omponentManager.java:1222)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager.disposeInternal(AbstractCompon entManager.java:358)

                                at org.apache.felix.scr.impl.manager.AbstractComponentManager.dispose(AbstractComponentManag er.java:197)

                                at org.apache.felix.scr.impl.config.ImmediateComponentHolder.disposeComponents(ImmediateComp onentHolder.java:356)

                                at org.apache.felix.scr.impl.BundleComponentActivator.dispose(BundleComponentActivator.java: 307)

                                at org.apache.felix.scr.impl.Activator.disposeComponents(Activator.java:329)

                                at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:196)

                                at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatc her.java:807)

                                at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java :729)

                                at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)

                                at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3754)

                                at org.apache.felix.framework.Felix.stopBundle(Felix.java:2199)

                                at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:958)

                                at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:945)

                                at org.apache.sling.installer.core.impl.tasks.BundleUpdateTask.execute(BundleUpdateTask.java :88)

                                at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.jav a:733)

                                at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:247)

                                at java.lang.Thread.run(Thread.java:680)

                      • 8. Re: Inbox Notification from Workflow
                        Jörg Hoh Adobe Employee

                        You cannot export private packages of another bundle. And as stated above: please contact Daycare support if the documentation of the InboxManager as public API is an error, or if the missing export statement in the OSGI bundle is the problem.

                         

                         

                         

                        kind regards,

                        Jörg