11 Replies Latest reply: May 3, 2012 11:32 AM by 906825 RSS

    How to populate the enddate after change in user status

    735019
      Hi,

      I have created an entity adapter to populate start date and end date.

      I have a scheduler that disables user accounts based on following two conditions:

      1. The system date and end date are same.

      2. There is a predefined difference in number of days between start date and end date.

      Now the requirement is that the end date has to be populated with a new value when the user is enabled.

      I have created a process task adapter that computes the new end date.I have created a new task in Xellerate user process and attached this adapter to new task.I have mapped the output of adapter to User definition-End date.This new task has been added as a dependent task in the enable user task.Also in the USR_PROCESS_TRIGGER i have added USR_END_DATE and have provided the adapter name in decode column.

      Now when i try to enable user,the account gets enabled but end date is not populated with new value.
      I am not getting any errors on the either.

      Please let me know if my approach is right.Please guide me.

      Thanks in advance.
        • 1. Re: How to populate the enddate after change in user status
          Rajiv Dewan
          In would be better if you make Trigger on USR_STATUS instead of END Date. No need to make Dependent Task.
          • 2. Re: How to populate the enddate after change in user status
            Sunny.Saxena
            My assumption :: A user is disabled in OIM and you want its end date to be set to a new value, with the enable action.

            I feel that you should not be requiring an entry in the triggers lookup for 'USR_END_DATE' . Also there is a trap over here. If an end date is already set for a user (and this date is passed), then you would not be able to enable that User. So setting a new end-date after enable action doesn't do the work. So one thing you need to tell me is that how are you enabling the user. I am assuming that you are enabling it somehow, but before the DB insert for enable action you should call a pre-insert entity adapter to clear end date of the user. Now enable the user.

            Whay you can now do is try the following:

            1) As the user gets enabled, the DB column for USR_DISABLED will be updated to become '0' from '1'. You can also use the field USR_STATUS. So you can put a trigger over any of these two fields for a task to get invoked. Make an entry as follows:


            code - decode
            USR_DISABLED - Set New End Date

            or

            code - decode
            USR_STATUS - Set New End Date

            2) Now the decode key is the name of your process task and not the adapter. So your process task must be of the name-'Set New End Date'. Map it to your already created adapter which calculates the end date.
            3) Add this process task to the 'Xellerate User' process. This will now set the new end date to the user profile of OIM user.


            Give it a try and see if it works. Let me know.

            Thanks

            Sunny

            Edited by: rajsunny on Nov 26, 2009 1:39 AM
            • 3. Re: How to populate the enddate after change in user status
              735019
              Hi,

              I created a trigger for USR_DISABLE insted of USR_END_DATE and added the process name for decode value in the lookup.When i do this the process to update the enddate is triggered while creating user also.Please find the stack trace :



              11:17:52,155 ERROR [SERVER] Class/Method: tcScheduleItem/checkMultiple Error : Invalid Duplicate in
              ScheduleItem.There are other instances of this milestone in this ORC.
              11:17:52,186 ERROR [ACCOUNTMANAGEMENT] Class/Method: tcUserOperationsBean/enableUser encounter some
              problems: maoRejections:Duplicate schedule item for a task that does not allow multiples.
              11:17:52,186 ERROR [WEBAPP] Class/Method: tcManageUserAction/enableUser encounter some problems: Dup
              licate schedule item for a task that does not allow multiples.
              Thor.API.Exceptions.tcAPIException: Duplicate schedule item for a task that does not allow multiples
              .
              at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.enableUser(Unknown Source)
              at com.thortech.xl.ejb.beans.tcUserOperationsSession.enableUser(Unknown Source)
              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.jboss.invocation.Invocation.performCall(Invocation.java:359)
              at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionConta
              iner.java:237)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI
              nterceptor.java:158)
              at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance
              Interceptor.java:169)
              at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)

              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.
              java:138)
              at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
              at org.jboss.ejb.Container.invoke(Container.java:960)
              at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
              at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
              at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
              at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
              at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
              at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
              at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
              at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:1
              12)
              at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
              at $Proxy734.enableUser(Unknown Source)
              at Thor.API.Operations.tcUserOperationsClient.enableUser(Unknown Source)
              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 Thor.API.Base.SecurityInvocationHandler$1.run(Unknown Source)
              at Thor.API.Security.LoginHandler.jbossLoginSession.runAs(Unknown Source)
              at Thor.API.Base.SecurityInvocationHandler.invoke(Unknown Source)
              at $Proxy786.enableUser(Unknown Source)
              at com.thortech.xl.webclient.actions.tcManageUserAction.enableUser(Unknown Source)
              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.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
              at com.thortech.xl.webclient.actions.tcLookupDispatchAction.execute(Unknown Source)
              at com.thortech.xl.webclient.actions.tcActionBase.execute(Unknown Source)
              at com.thortech.xl.webclient.actions.tcAction.execute(Unknown Source)
              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 org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
              ava:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at com.thortech.xl.webclient.security.SecurityFilter.doFilter(Unknown Source)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
              ava:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
              ava:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.ja
              va:182)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:
              157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja
              va:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:619)

              Also tried with USR_STATUS.But this dosen't work.
              On the GUI i get the following message :

              DOBJ.SCHTM_INVALID_DUP
              Duplicate schedule item for a task that does not allow multiples.

              Please help.
              • 4. Re: How to populate the enddate after change in user status
                Sunny.Saxena
                Please check that the 'Allow Multiple Instances' check box is selected for the process you created. I dont get why this task ic also called during user creation.

                Chek for the above point and if this this doesn't work, try it out by applying the trigger on USR_STATUS field. Just change the code value in the lookup for triggers.

                Thanks

                Sunny
                • 5. Re: How to populate the enddate after change in user status
                  735019
                  I checked the allow multiple instances.Still the date is not being populated.Also the task gets triggered when the user is disabled.How do i ensure that the process is triggered only when user is enabled. Please help

                  Thanks
                  • 6. Re: How to populate the enddate after change in user status
                    Sunny.Saxena
                    Here is my stand on both of your issues. And after selecting the 'Allow Multiple Instances', you would not have got that error. If you see the error then paste your logs here.

                    1) For End-Date or any date field to populate to the User Profile form you need to keep proper check on the format of the date yopu are supplying. Do this with the help of updateUser API. And format your date accordingly. See this forum thread for more details.

                    Not able to update Start/End Date with updateUser API

                    2) The other thing where in your task is invoked for 'Disbale' and 'Enable' action both. For that you can handle this in adapter for the filed name. If the field USR_STATUS is 'Disbaled' then dont do anything. If the value is 'Enabled' then process your logic.

                    Thanks

                    Sunny
                    • 7. Re: How to populate the enddate after change in user status
                      735019
                      Please find the adapter code below:

                      public class RenewEnddate
                      {
                      public static String EndDate(Date sysdate,String usrkey,String oldDisableValue,String newDisableValue)
                      {
                                
                           String c="C";

                           try{
                                
                                ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath
                           ("Discovery.CoreServer");

                                final Hashtable env = config.getAllSettings();
                           
                                tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm","PrivateKey");
                           
                                tcUtilityFactory moFactory = new tcUtilityFactory(env, moSignature);

                           tcUserOperationsIntf userOper = (tcUserOperationsIntf)moFactory.getUtility
                      ("Thor.API.Operations.tcUserOperationsIntf");

                           tcRequestOperationsIntf reqOper = (tcRequestOperationsIntf)moFactory.getUtility     ("Thor.API.Operations.tcRequestOperationsIntf");

                           tcResultSet reqSet = reqOper.getRegistrationUserDetails(Long.parseLong(usrkey));
                           
                           Calendar End= Calendar.getInstance();     

                      if(oldDisableValue.equals("1") && newDisableValue.equals("0")){       
                           
                           End.setTime(sysdate);
                           
                           End.add(Calendar.DATE,15);
                           
                           System.out.println("end date changed");
                                
                           java.sql.Date newEnd=(java.sql.Date)End.getTime();
                           
                                String EndDateStr = newEnd.toString() + " 00:00:00.000";
                           
                           System.out.println("new end date : " + newEnd);
                           
                           Map EndDate = new HashMap();
                           
                           EndDate.put("Users.Start Date", EndDateStr);

                           userOper.updateUser(reqSet, EndDate);
                      }
                           }
                      catch (Exception e){
                           e.printStackTrace();
                      }

                           return c;

                      }
                      }     
                           
                      when i disable the user this process is trigerred.(Any means to stop triggering of this process for disable action?)

                      17:29:29,774 INFO [STDOUT] Running RENEWENDDATE
                      17:29:29,774 INFO [STDOUT] Target Class = adapters.RenewEnddate

                      when i enable the user account the process is triggered again.Also i am getting date cast exception.

                      Thanks
                      • 8. Re: How to populate the enddate after change in user status
                        Rajiv Dewan
                        TRY THIS

                        package com.oim;

                        import java.util.Calendar;
                        import java.util.Date;
                        import java.util.HashMap;
                        import java.util.Hashtable;
                        import java.util.Map;

                        import com.thortech.xl.crypto.tcCryptoUtil;
                        import com.thortech.xl.crypto.tcSignatureMessage;
                        import com.thortech.xl.util.config.ConfigurationClient;

                        import Thor.API.tcResultSet;
                        import Thor.API.tcUtilityFactory;
                        import Thor.API.Operations.tcUserOperationsIntf;

                        public class StatusTrigger {
                             
                             private tcUtilityFactory utilityFactory = null;
                             tcUtilityFactory utilFactory;
                             tcSignatureMessage moSignature = null;
                             
                             
                             
                             public void trigger(String userid, String status){
                                  try{
                                       ConfigurationClient.ComplexSetting config =
                                            ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
                                            final Hashtable env = config.getAllSettings();
                                       
                                                 moSignature = tcCryptoUtil.sign("xelsysadm", "PrivateKey");
                                                 utilFactory = new tcUtilityFactory(env, moSignature);
                                  if(status.equalsIgnoreCase("Enabled")){
                                       
                                  
                                  tcUserOperationsIntf userOperationsIntf = null;
                                  userOperationsIntf = (tcUserOperationsIntf) utilFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
                                  HashMap userMap = new HashMap();

                                  userMap.put("Users.User ID", userid);
                                  tcResultSet userSet = userOperationsIntf.findAllUsers(userMap);
                                  Calendar now = Calendar.getInstance();

                                  now.add(Calendar.DATE,15);
                                       System.out.println("Current date NOW : " + now.get(Calendar.YEAR) + "-"+(now.get(Calendar.MONTH) + 1)+ "-"+ now.get(Calendar.DATE) );
                                  String x = now.get(Calendar.YEAR) +"-"+(now.get(Calendar.MONTH) + 1)+ "-"+ now.get(Calendar.DATE);
                                  
                                       x = x+ " 12:01:00.000000000";
                                  
                                       System.out.println("\n\n\n NOW X is " + x);
                                       Map endDate1 = new HashMap();
                                       endDate1.put("Users.End Date", x);
                                       userOperationsIntf.updateUser(userSet, endDate1);
                                       
                                       System.out.println("DONE");
                                  }
                                  }catch(Exception e){
                                       e.printStackTrace();
                                  }
                             }
                             
                        }
                        • 9. Re: How to populate the enddate after change in user status
                          Sunny.Saxena
                          Yes. The code which Rajiv has pasted should work absolutely fine. Just to add another thing that he has put a check on the USR_STATUS column and your code was doing it for USR_DISABLED. So also make the following changes:

                          1) Update the trigger table for entry of USR_STATUS, let the decode value for 'Process Task' name be as it is.
                          2) Create a new adapter with two arguments-'userId' and 'status'. Map these two fields accordingly.

                          you should be done.

                          Regards

                          Sunny
                          • 10. Re: How to populate the enddate after change in user status
                            735019
                            Thanks rajiv and sunny its working :)
                            • 11. Re: How to populate the enddate after change in user status
                              906825
                              Hi All,

                              I am new to OIM.

                              I want to write custom adapters.

                              please give me some direction on how to write java code for adapter ?
                              Is there any guide available for this ?