5 Replies Latest reply on Aug 20, 2014 7:06 PM by Jonathan Hult

    The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.

    975074

      Hi,

      I am trying to execute a subservice from a filter on ValidateStandard and I am getting error below. I have inserted my code here, Can someone please help?

      Thanks,

      Marietta

       

      !csUserEventMessage,sysadmin,192.168.100.101!$!csServiceInWrongContext,UPDATE_DOCINFO_SUB

      intradoc.common.ServiceException: !csServiceInWrongContext,UPDATE_DOCINFO_SUB

      at intradoc.server.ServiceManager.getFullService(ServiceManager.java:252)

      at ottawarmcheckin.UpdateVolumeFieldsFilter.executeService(UpdateVolumeFieldsFilter.java:114)

      at ottawarmcheckin.UpdateVolumeFieldsFilter.doFilter(UpdateVolumeFieldsFilter.java:53)

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

      at intradoc.server.DocServiceHandler.validateStandard(DocServiceHandler.java:1007)

      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.executeSubServiceCode(ServiceRequestImplementor.java:1071)

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

      at helper.HelperService.executeSubServiceCode(HelperService.java:1812)

      at helper.HelperService.executeSubservice(HelperService.java:1648)

      at helper.HelperService.superService(HelperService.java:1553)

      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 helper.HelperService.doAction(HelperService.java:757)

      at helper.HelperService.doActions10g(HelperService.java:383)

      at helper.HelperService.doActions(HelperService.java:119)

      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)

       

      THIS IS MY CODE:

       

      public class UpdateVolumeFieldsFilter implements FilterImplementor{

      public static final String CHECKSUM_FIELDNAME = "xChecksum";
      public static final boolean IS_CHECKSUM_ENABLED = true;

      public int doFilter(Workspace ws, DataBinder binder, ExecutionContext cxt) throws DataException, ServiceException
      {

        String serviceName=binder.getAllowMissing("IdcService");
       
        if( serviceName!=null && serviceName.equalsIgnoreCase("CHECKIN_NEW") ){

         System.out.println("[ UpdateVolumeFieldsFilter ] Setting databinder .....");
        
                  DataBinder updateParams = new DataBinder();
                  updateParams.setEnvironment(SharedObjects.getEnvironment());
                  // Put required parameters in binder for service call
                  updateParams.putLocal("IdcService", "UPDATE_DOCINFO_SUB");
                  updateParams.putLocal("dID", "60538");
                  updateParams.putLocal("dDocName", "055732");
                  updateParams.putLocal("dRevLabel", "1");
                  updateParams.putLocal("dSecurityGroup","Public");
                  updateParams.putLocal("dDocAccount", "0010000009001000002500100012440010001261");
                  updateParams.putLocal("xcomments",  "Testing this");
                  if (IS_CHECKSUM_ENABLED){
                   updateParams.putLocal(CHECKSUM_FIELDNAME,"");
                   updateParams.putLocal("Checksum_FieldName",CHECKSUM_FIELDNAME);
                  }             
                  updateParams.putLocal("createPrimaryMetaFile","1");
                 
                  System.out.println("[ UpdateVolumeFieldsFilter ] before execute service .....");
                 
                  // run the checkin
                  executeService(updateParams, "sysadmin", false);
                 
                  System.out.println("[ UpdateVolumeFieldsFilter ] after execute service .....");

                  // reset the binder for the next item
                  updateParams.clearResultSets();
                  updateParams.getLocalData().clear();
              }

        return CONTINUE;
      }  // close doFilter


          /**
           * Obtain the workspace connector to the database
           */
          public Workspace getSystemWorkspace()
          {
              Workspace workspace = null;
              Provider wsProvider =
                  Providers.getProvider("SystemDatabase");
              if (wsProvider != null)
                  workspace = (Workspace)wsProvider.getProvider();
              return workspace;
          }
         
          /**
           * Obtain information about a user. Only the 'userName' parameter
           * must be non-null.
           */
          public UserData getFullUserData(String userName,
              ExecutionContext cxt, Workspace ws)
              throws DataException, ServiceException
          {
              if (ws == null)
                  ws = getSystemWorkspace();
              UserData userData = UserStorage.
                  retrieveUserDatabaseProfileDataFull(userName,
                      ws, null, cxt, true, true);
              ws.releaseConnection();
              return userData;
          }  
         
         
          /**
           * Execute a service call based on the data in the binder using
           * the credentials of the supplied user
           */
          public void executeService(DataBinder binder, String userName,
              boolean suppressServiceError)
                  throws DataException, ServiceException
          {
              // obtain a connection to the database
              Workspace workspace = getSystemWorkspace();

              // check for an IdcService value
              String cmd = binder.getLocal("IdcService");
              if (cmd == null)
                  throw new DataException("!csIdcServiceMissing");

              // obtain the service definition
              ServiceData serviceData = ServiceManager.getFullService(cmd);
              if (serviceData == null)
                  throw new DataException(LocaleUtils.encodeMessage(
                      "!csNoServiceDefined", null,  cmd));

              // create the service object for this service
              Service service = ServiceManager.createService(
                  serviceData.m_classID, workspace,
                  null, binder, serviceData);

              // obtain the full user data for this user
              UserData fullUserData = getFullUserData(userName,
                  service, workspace);
              service.setUserData(fullUserData);
              binder.m_environment.put("REMOTE_USER", userName);

              ServiceException error = null;
              try
              {
                  // init the service to not send HTML back
                  service.setSendFlags(true, true);

                  // create all the ServiceHandlers and implementors
                  service.initDelegatedObjects();

                  // do a security check
                  service.globalSecurityCheck();

                  // prepare for the service
                  service.preActions();

                  // execute the service
                  service.doActions();
                  //service.doSubService();

                  // do any cleanup
                  service.postActions();

                  // store any new personalization data
                  service.updateSubjectInformation(true);
                  service.updateTopicInformation(binder);
              }
              catch (ServiceException e)
              {
                  error = e;
              }
              finally
              {
                  // Remove all the temp files.
                  service.cleanUp(true);
                  workspace.releaseConnection();
              }

              // handle any error
              if (error != null)
              {
                  if (suppressServiceError)
                  {
                      error.printStackTrace();
                      if (binder.getLocal("StatusCode") == null)
                      {
                          binder.putLocal("StatusCode", String.valueOf(
                              error.m_errorCode));
                          binder.putLocal("StatusMessage",
                              error.getMessage());
                      }
                  }
                  else
                  {
                      throw new ServiceException(error.m_errorCode,
                          error.getMessage());
                  }
              }
          }
         
         
      }

        • 1. Re: The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.
          Jonathan Hult

          I think this is because you are trying to execute a subservice. What happens if you execute UPDATE_DOCINFO instead of UPDATE_DOCINFO_SUB?

           

          Jonathan

          http://jonathanhult.com

          • 2. Re: The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.
            975074

            Hi Jonathan,

            Thanks for your answer!!! If I call UPDATE_DOCINFO, I get error as I believe this service opens a transactions and I cannot call it from a filter in the CHECKIN_NEW as it is alredy in a transaction, thats why I was trying to use the subservice. Basically I need to update some records during checkin, I need the index gets updated as the information I am updating must be searchable and also I need everything in one transation as the update must rollback if the checkin fail and viceversa. Can you help me I am desperately and must finished this asap.

            Thanks!

             

            intradoc.data.DataException: !csJdbcCommitCalledInAutoCommitMode,IdcServerThread-12

            at intradoc.jdbc.JdbcWorkspace.commitTran(JdbcWorkspace.java:1113)

            at intradoc.data.WorkspaceTransactionWrapper.commitTransaction(WorkspaceTransactionWrapper.java:61)

            at intradoc.server.ServiceRequestImplementor.commitTransaction(ServiceRequestImplementor.java:358)

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

            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 helper.HelperService.executeSubServiceCode(HelperService.java:1812)

            at helper.HelperService.executeSubservice(HelperService.java:1648)

            at helper.HelperService.superService(HelperService.java:1553)

            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 helper.HelperService.doAction(HelperService.java:757)

            at helper.HelperService.doActions10g(HelperService.java:383)

            at helper.HelperService.doActions(HelperService.java:119)

            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)

            • 3. Re: The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.
              Bunty

              are you trying to update any security fields? If not, you can try UPDATE_METADATA service.

              other option is to user Timer and call UPDATE_DOCINFO

              • 4. Re: The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.
                975074

                Hi Bunty,

                No, I do not need to update any security fields, I tried to call UPDATE_META but I get similar error , wrong context, do you think there is something wrong with my code?

                 

                intradoc.common.ServiceException: !csServiceInWrongContext,UPDATE_METADATA at intradoc.server.ServiceManager.getFullService(ServiceManager.java:252) at ottawarmcheckin.UpdateVolumeFieldsFilter.executeService(UpdateVolumeFieldsFilter.java:117) at ottawarmcheckin.UpdateVolumeFieldsFilter.doFilter(UpdateVolumeFieldsFilter.java:57) at intradoc.shared.PluginFilters.filter(PluginFilters.java:94) at intradoc.server.DocServiceHandler.validateStandard(DocServiceHandler.java:1007) 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.executeSubServiceCode(ServiceRequestImplementor.java:1071) at intradoc.server.Service.executeSubServiceCode(Service.java:3568) at helper.HelperService.executeSubServiceCode(HelperService.java:1812) at helper.HelperService.executeSubservice(HelperService.java:1648) at helper.HelperService.superService(HelperService.java:1553) 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 helper.HelperService.doAction(HelperService.java:757) at helper.HelperService.doActions10g(HelperService.java:383) at helper.HelperService.doActions(HelperService.java:119) 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) 

                • 5. Re: The service 'UPDATE_DOCINFO_SUB' cannot be executed in this context.
                  Jonathan Hult

                  In the past, upon successful checkin, I have needed to update metadata for another content item.

                   

                  What I did was put a flag and some information in the DataBinder with a checkin filter such as validateStandard.

                   

                  Then I create another class that implements the serviceCleanUp filter (which fires at the end of every service call after transactions are done). In this filter, I can check if this was a checkin, if it was successful and if my data is in the DataBinder. If so, I then do my update metadata logic.

                   

                  http://jonathanhult.com/blog/2012/09/favorite-webcenter-content-filters/

                   

                  Jonathan

                  http://jonathanhult.com