Implementing a Data Change Notification Filter

Write and deploy preprocess and postprocess DCN and Hybrid App DCN filters to SAP Mobile Server.

When specifying filters, add a dcn_filter parameter to the base URL, and to the parameters specified in the DCN request section. The dcn_filter parameter specifies the fully qualified name of the filter class, which must be in a valid CLASSPATH location so SAP Mobile Server can locate it using its fully qualified name.

JSON requires colons to define the object structure, but since colons have a special function in HTTP URLs, use the tilda character "~" instead of colons ":" when implementing the DCN filter, so the JSON dcn_request string can be passed as an HTTP GET or POST parameter:
dcn_request={"pkg"~“TestPackage",
	"messages"~[{"id"~"1","mbo"~"Department","op"~"~upsert",
	"cols"~{"DepartmentID"~"3333",
          "DepartmentName"~“My Department",
		     "DepartmentHeadID"~"501"}}]}

The dcn_request is in a format that is specific to the back end. The filter class can preprocess to the JSON format expected by SAP Mobile Server.

  1. Write the filter. For example:
    import java.util.Map;
    import com.onepage.fw.uwp.shared.uwp.UWPLogger;
    import com.sybase.sup.dcn.DCNFilter;
    
    public class CustomDCNFilter implements DCNFilter
    {
      String preprocess(String blobDCNRequest, Map<String,String> headers) {
    	 	String result = blobDCNRequest.replace(‘~’,’:’);
    	 	return result;
      }
    
      String postprocess(String jsonDCNResult, Map<String,String> responseHeaders) {
    	 	String result = jsonDCNResult.replace(‘:’,’~’);
    	 	return result;
      }
    	
    	public static void main( String[] args ) { }
    }
    
  2. Package your DCN filter class in a JAR file.
  3. Deploy the JAR file to SAP Mobile Server by using the Deployment wizard from SAP Mobile WorkSpace (regular DCN), or manual deployment (Hybrid App DCN):
    • For regular DCN:
      1. Invoke the deployment wizard. For example, right-click in the Mobile Application Diagram and select Deploy Project.
      2. Select the JAR file that contains your DCN filter class files to deploy to SAP Mobile Server in the third screen of the wizard (Package User-defined Classes).
      3. Click Finish after selecting the target SAP Mobile Server.
    • For Hybrid App DCN:
      1. Place the JAR file in SMP_HOME\Servers\UnwiredServer\lib\ext.
      2. Create an empty file named sup.cff in SMP_HOME\Servers\UnwiredServer\bin\private.
  4. Restart SAP Mobile Server.