1 Reply Latest reply: Nov 20, 2013 11:00 PM by Jonathan Hult RSS

    Executing a service from a ServiceHandler

    975074

      Hi,

      I need to update a custom field in table ExtItems and I am trying to call the service EDIT_EXTERNAL_ITEM to save the field, when I call the getRequestImplementor().executeServiceTopLevelSimple I am getting error attcahed at the end. Can somebody please help me to identify what I am doing wrong? Here is my code:

       

      public class AddressLookUpServiceHandler extends ServiceHandler {

      /** This method executes a service.

              */

             private void executeService(final DataBinder serviceBinder, final String serviceName) throws ServiceException

             {     

                    System.out.println("executing service");   

                    try {

                                 System.out.println("Calling service " + serviceName + ": " + serviceBinder.getLocalData().toString());          

                                 System.out.println("getUserData: " + m_service.getUserData().toString());

                                 // Execute service

                                 m_service.getRequestImplementor().executeServiceTopLevelSimple(serviceBinder, serviceName, m_service.getUserData());

                                 System.out.println("Finished calling service");

                    } catch (final DataException e) {

                           System.out.println("Something went wrong executing service " + serviceName);          

                           e.printStackTrace(System.out);          

                           throw new ServiceException("Something went wrong executing service 2" + serviceName, e);

                    }

                           finally {

                                 System.out.println("End executeService");     

                           }

             }

       

      public void linkAddressesbyFileID()  throws DataException, ServiceException, NumberFormatException

             {

                    String currentlistofIDs=null;

                    String newlistofIDs = m_binder.getLocal("xFileAddress");

                    String fileID = m_binder.getLocal("dID");

                   

                    System.out.println("OttawaRMSAddressLookUp - fileID is: " + fileID);

                    System.out.println("OttawaRMSAddressLookUp - newlistofIDs: " + newlistofIDs);

                   

                    String sql = "SELECT XFILEADDRESS FROM EXTITEMS WHERE DID="+fileID;

                    System.out.println("OttawaRMSAddressLookUp - sql: "+sql);

                   

                    try {

                           ResultSet rsFileRecord = m_workspace.createResultSetSQL(sql);

                           try{

                                 if(rsFileRecord!=null && !rsFileRecord.isEmpty()){

                                        currentlistofIDs=rsFileRecord.getStringValueByName("XFILEADDRESS");

                                 }

                           } catch (NumberFormatException e) {

                                 SystemUtils.err(e, "OttawaRMSAddressLookUp [getting current FileIDs]" + e.getMessage());

                           }

             } catch (DataException e) {

                    SystemUtils.err(e, "OttawaRMSAddressLookUp [getting recordset extitems ]" + e.getMessage());

             }

                   

                    System.out.println("OttawaRMSAddressLookUp - currentlistofIDs: " + currentlistofIDs);

       

                    // HashSet contains the list of address IDs that were added and also the existing ones

                    // this is the list of IDs will be saved in the xFileAddress field

                    HashSet<Integer> ids = new HashSet<Integer>();

                   

                    //parsing new Address IDs list and copy into the HashSet

                    if(newlistofIDs != null && newlistofIDs != ""){

                           parseStringOfIDs(ids, newlistofIDs);

                    }

                    //parsing already linked Address IDs and copy into the HashSet

                    if(currentlistofIDs != null && currentlistofIDs != ""){

                           System.out.println("OttawaRMSAddressLookUp - entre a parse currentlistofIDs");

                           parseStringOfIDs(ids, currentlistofIDs);

                    }

       

                    Iterator<Integer> iteratorOfIds= ids.iterator();

                    newlistofIDs = "";

                    while(iteratorOfIds.hasNext()){

                           newlistofIDs += iteratorOfIds.next()+",";

                    }

                    System.out.println("The size of the hashset is:" + ids.size());

                    System.out.println("The new list is:" + newlistofIDs);

                   

                    // prepare a binder for the service requests

                    DataBinder serviceBinder = new DataBinder();

                   

                    // prepare the external item data

                    //serviceBinder.putLocal("IdcService", "EDIT_EXTERNAL_ITEM");

                    serviceBinder.putLocal("dID", fileID);

                    serviceBinder.putLocal("xFileAddress", newlistofIDs);

                    serviceBinder.putLocal("dSource", "Physical");

       

                    // run the EDIT_EXTERNAL_ITEM

                    executeService(serviceBinder, "EDIT_EXTERNAL_ITEM");

       

             }

       

      }

       

      Error I am getting:

       

      system 11.19 16:37:00.771 IdcServerThread-13 null-exception stack

      java.lang.NullPointerException

      at pcmExtensions.PCMFilter.doFilter(PCMFilter.java:31)

      at intradoc.shared.PluginFilters.filter(PluginFilters.java:94)

      at externalhelper.ErmHandler.getExternalItemInfoEx(ErmHandler.java:9974)

      at externalhelper.ErmHandler.getExternalItemInfo(ErmHandler.java:9918)

      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:585)

      at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)

      at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)

      at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)

      at intradoc.server.Service.doCodeEx(Service.java:490)

      at relatedcontent.RelatedExternalServiceHandler.getExternalItemInfo(RelatedExternalServiceHandler.java:32)

      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:585)

      at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)

      at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)

      at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)

      at intradoc.server.Service.doCodeEx(Service.java:490)

      at intradoc.server.Service.doCode(Service.java:472)

      at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)

      at intradoc.server.Service.doAction(Service.java:452)

      at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)

      at intradoc.server.Service.doActions(Service.java:447)

      at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1071)

      at intradoc.server.Service.executeSubServiceCode(Service.java:3568)

      at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942)

      at intradoc.server.Service.executeServiceEx(Service.java:3563)

      at intradoc.server.Service.executeService(Service.java:3547)

      at intradoc.server.Service.doSubService(Service.java:3536)

      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:585)

      at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)

      at intradoc.common.ClassHelperUtils.executeMethodEx(ClassHelperUtils.java:279)

      at intradoc.common.ClassHelperUtils.executeMethod(ClassHelperUtils.java:264)

      at intradoc.server.Service.doCodeEx(Service.java:507)

      at intradoc.server.Service.doCode(Service.java:472)

      at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)

      at intradoc.server.Service.doAction(Service.java:452)

      at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)

      at intradoc.server.Service.doActions(Service.java:447)

      at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1121)

      at intradoc.server.Service.executeActions(Service.java:433)

      at intradoc.server.ServiceRequestImplementor.doRequestInternalEx(ServiceRequestImplementor.java:722)

      at intradoc.server.ServiceRequestImplementor.executeServiceTopLevelSimple(ServiceRequestImplementor.java:832)

      at OttawaRMSAddressLookUp.AddressLookUpServiceHandler.executeService(AddressLookUpServiceHandler.java:83)

      at OttawaRMSAddressLookUp.AddressLookUpServiceHandler.linkAddressesbyFileID(AddressLookUpServiceHandler.java:155)

      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:585)

      at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)

      at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)

      at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)

      at intradoc.server.Service.doCodeEx(Service.java:490)

      at intradoc.server.Service.doCode(Service.java:472)

      at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)

      at intradoc.server.Service.doAction(Service.java:452)

      at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)

      at intradoc.server.Service.doActions(Service.java:447)

      at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1121)

      at intradoc.server.Service.executeActions(Service.java:433)

      at intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:635)

      at intradoc.server.Service.doRequest(Service.java:1707)

      at intradoc.server.ServiceManager.processCommand(ServiceManager.java:359)

      at intradoc.server.IdcServerThread.run(IdcServerThread.java:197)