question: public void processConnection ( DataInputStream dis , DataOutputStream dosParam ) throws IOException , Exception { GZIPOutputStream gzip = new GZIPOutputStream ( new BufferedOutputStream ( dosParam ) ) ; DataOutputStream dos = new DataOutputStream ( gzip ) ; byte responseStatus = ResponseStatus . STATUS_ERROR ; try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; String name = dis . readUTF ( ) ; String pw = dis . readUTF ( ) ; String serializer = dis . readUTF ( ) ; @ SuppressWarnings ( "unused" ) String locale = dis . readUTF ( ) ; byte action = dis . readByte ( ) ; Context . openSession ( ) ; try { Context . authenticate ( name , pw ) ; } catch ( ContextAuthenticationException ex ) { responseStatus = ResponseStatus . STATUS_ACCESS_DENIED ; } if ( responseStatus != ResponseStatus . STATUS_ACCESS_DENIED ) { DataOutputStream dosTemp = new DataOutputStream ( baos ) ; if ( action == ACTION_DOWNLOAD_PATIENTS ) downloadPatients ( String . valueOf ( dis . readInt ( ) ) , dosTemp , serializer , false ) ; else if ( action == ACTION_DOWNLOAD_SS_PATIENTS ) downloadPatients ( String . valueOf ( dis . readInt ( ) ) , dosTemp , serializer , true ) ; else if ( action == ACTION_DOWNLOAD_COHORTS ) PatientDownloadManager . downloadCohorts ( dosTemp , serializer ) ; else if ( action == ACTION_DOWNLOAD_SAVED_SEARCHES ) PatientDownloadManager . downloadSavesSearches ( dosTemp , serializer ) ; else if ( action == ACTION_DOWNLOAD_FORMS ) XformDownloadManager . downloadXforms ( dosTemp , serializer ) ; else if ( action == ACTION_UPLOAD_FORMS ) submitXforms ( dis , dosTemp , serializer ) ; else if ( action == ACTION_DOWNLOAD_USERS ) UserDownloadManager . downloadUsers ( dosTemp , serializer ) ; else if ( action == ACTION_DOWNLOAD_USERS_AND_FORMS ) downloadUsersAndForms ( dosTemp , serializer ) ; else if ( action == ACTION_DOWNLOAD_FILTERED_PATIENTS ) downloadPatients ( dis . readUTF ( ) , dis . readUTF ( ) , dosTemp , serializer ) ; responseStatus = ResponseStatus . STATUS_SUCCESS ; } dos . writeByte ( responseStatus ) ; if ( responseStatus == ResponseStatus . STATUS_SUCCESS ) dos . write ( baos . toByteArray ( ) ) ; dos . close ( ) ; gzip . finish ( ) ; } catch ( Exception ex ) { log . error ( ex . getMessage ( ) , ex ) ; try { dos . writeByte ( responseStatus ) ; dos . flush ( ) ; gzip . finish ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } finally { Context . closeSession ( ) ; } }
target:  Called when a new connection has been received. Failures are not handled in this class as different servers (BT,SMS, etc) may want to handle them differently.