Implementing a Data Change Notification Filter

Write and deploy preprocess and postprocess DCN and WF-DCN filters to Unwired 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 Unwired 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 Unwired 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 Unwired Server by using the Deployment wizard from Unwired WorkSpace:
    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 Unwired Server in the third screen of the wizard (Package User-defined Classes).
    3. Click Finish after selecting the target Unwired Server.
      Note: Alternatively, you can bypass step b when deploying the DCN filter class JAR file to Unwired Server:
      1. Place the JAR file in <UnwiredPlatform_InstallDir>\UnwiredPlatform\Servers\UnwiredServer\lib\ext.
      2. At a command prompt, run: <UnwiredPlatform_InstallDir>\Unwired Platform\Servers\UnwiredServer\bin\configure-mms.bat <hostname>.
  4. Restart Unwired Server.