Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
1,392

Extension framework is a cool feature which could be implemented for validating any data inputs on an attribute and throw custom error at UI level.


The document at SDN is pretty straight forward but there are some practical challenges that one may face depending on the service pack and version of netweaver developer studio installed. And scope here is to provide few tips to overcome such issues.


SDN doc provide steps for netweaver developer studio 7.0, 7.1 but both versions have 32 bit installable only so if your operation system is 64 bit then you should find some workaround may be a virtual PC or some vmware to have such set it up.


Better one can go for netweaver developer studio 7.3 external distribution zip format.


Make sure to have the appropriate java runtime environment set and do necessary software updates.


The steps for generating deployment SAP EAR file is almost similar as given at the SDN doc for developer studio 7.1. Also API guides (extfwk_javadoc.zip) are located in 'DesigntimeComponents\Misc' installable folder of identity center components.


To avoid dependency one can follow the suggestions implementing the methods as provided here


So something like below ...


package com.test.validationhandler

import com.sap.idm.extension.ITaskProcessing;

import com.sap.idm.extension.IdMFactory;

import com.sap.idm.extension.TaskProcessingAdapter;

import com.sap.idm.extension.IdMExtensionException;

import com.sap.idm.extension.api.IdMLoadData;

import com.sap.idm.extension.api.Entry;

import com.sap.idm.extension.api.IdMReference;

import com.sap.idm.extension.api.IdMSubmitData;

import com.sap.idm.extension.api.IdMValue;

import com.sap.idm.extension.api.IdMValueChange;

import com.sap.idm.extension.api.Task;

import java.util.HashMap;

import java.util.Locale;

import java.util.Map;

import com.sap.tc.logging.*;

public class ValidationHandler extends TaskProcessingAdapter {

        

    private Map validatorByTaskGuid = new HashMap();

    private static final String TASKGUID_UI_1 = "B1YA5808-CDDD-4407-8P76-7ED111109DPO";

    private static final String TASKGUID_UI_2 = "GUYA5808-CDDD-1237-9P70-7ED200109DAE";

    private static final String EXCEPTION_1  = "Exception to throw at UI";

    private static final Location loc = Location.getLocation("com.test.validationhandler");

    public ValidationHandler()  {

        validatorByTaskGuid.put(TASKGUID_UI_1,CLASS1);                       

        validatorByTaskGuid.put(TASKGUID_UI_2,CLASS1);

    }

 

    static {

        loc.setEffectiveSeverity(Severity.PATH);

        loc.addLog(new ConsoleLog());

    }

    public IdMValue[] onLoad(Locale locale, int subjectMSKEY, int objectMSKEY, Task task, IdMLoadData data) throws IdMExtensionException {

        String guid = task.getGUID();

        loc.infoT("Executing Validation Handler for Task :"+guid);

        ITaskProcessing  itp = (ITaskProcessing)validatorByTaskGuid.get(guid);

        if(itp == null) {  

            return null; 

        }

        else {    

            return itp.onLoad(locale,subjectMSKEY,objectMSKEY,task,data); 

        }

    }

    public IdMValueChange[] onSubmit(Locale locale, int subjectMSKEY, int objectMSKEY, Task task, IdMSubmitData data) throws IdMExtensionException {

       String guid = task.getGUID();

       loc.infoT("Executing Validation Handler for Task :"+guid);

       ITaskProcessing  itp = (ITaskProcessing)validatorByTaskGuid.get(guid);

       if(itp == null) {  

            return null; 

        }

        else {    

            return itp.onSubmit(locale,subjectMSKEY,objectMSKEY,task,data);  

        }

    }

    private ITaskProcessing CLASS1 = new ITaskProcessing() {  

        

        public IdMValue[] onLoad(Locale locale, int subjectMSKEY, int objectMSKEY, Task task, IdMLoadData data) throws IdMExtensionException {     

            loc.entering();

            loc.infoT("Executing CLASS1:onLoad()");

            // How to instantiate IdMReference object ?

              IdMReference[] priv = IdMFactory.getInstance().getEntryFactory().getPrivileges(locale, subjectMSKEY,1);

                                         

            //some logic throwing exception (EXCEPTION_1)

            return null;

        }

        public IdMValueChange[] onSubmit(Locale arg0, int arg1, int arg2,Task arg3, IdMSubmitData arg4) throws IdMExtensionException {

        return null;

        }

    };

}

Labels in this area