Extending the Issue Service

There are 2 parts to having feedback sent to the customer's server instead of Metova's.

1. Have an IssueService that points to your servers.

This is done by extending IssueService and creating a new sendProblemReport method.

In this new CustomerIssueService, you'll create a request that has any parameters that you need. An example of a standard request with the default parameters (device ID, email, log entries, etc.) is below.

    /**
     * Sends a problem report via HTTP request to Customer's web-services.
     * @param email  reporter's email address.
     * @param problem  description of the problem.
     */
    public static void sendProblemReport( String email, String problem ) {

        log.info( "Creating http post request for feedback" );
        HttpMultipartPostRequest request = new HttpMultipartPostRequest( "http://www.customerdomain.com/services/blackberry/feedback" );
        request.addParameter( "deviceExternalId", MobileDevice.instance().getDeviceId() );
        request.addParameter( "versionCode", MobileApplication.instance().getVersion().toString() );
        request.addPart( new Part( "device", "device", "application/xml", DeviceUtility.getDeviceXml().getBytes() ) );
        request.addParameter( "description", problem );
        request.addParameter( "email", email );
		//Adds the permissions to the log file
        MetovaLogPosterUtils.addApplicationPermissions();
		//Adds the log file to the request as a file
        MetovaLogPosterUtils.addLogEntries( request );
		//Adds the queue entries to the request as a file
        MetovaLogPosterUtils.addQueueEntries( request );

		//Set Streaming network path - this can be a large request.  An alternative is to use chunking.
        request.setNetworkPathBehavior( StreamingNetworkPathBehavior.ID );

        QueueManager queueManager = ManagedUiApplication.getManagedUiApplication().getQueueManager();
		//FeedbackConfirmationResponseCallback displays a simple dialog after the feedback succeeds or fails
        queueManager.enqueue( METOVA_PROBLEM_REPORT_QUEUE, new Entry( request, FeedbackConfirmationResponseCallback.class ) );

        if ( log.isDebugEnabled() ) {

            log.debug( "Done dending feedback" );
        }
    }

2. Have your submit feedback popup use the new issue service.

Extend ProblemReportPopupScreen and override the onOk method to call your new issue service. This can also be used to pass in any other variables you'd like to your custom issue service.

public class FeedbackPopupScreen extends ProblemReportPopupScreen {

    protected void onOk() {

        final String email = getEmailField().getBasicEditField().getText();
        final String problem = getProblemField().getText();

        if ( !Text.isNull( email ) && !Text.isNull( problem ) ) {
			//Close the problem report screen
            synchronized (Application.getEventLock()) {
                Screens.popScreen( this );
            }
			//Submit the feedback in a new thread
            Timers.runNow( new ThreadPoolDelegatingRunnable() {

                public void onRun() {

                    ProblemReportEmailStore.instance().load().setEmail( email );
                    ProblemReportEmailStore.instance().commit();
                    CustomerIssueService.sendProblemReport( email, problem );
                }
            } );
        }
        else {

            Dialog.alert( "You must enter an email address and description before submitting feedback." );
        }
    }
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© 2011 Metova, Inc.