Creates the process command from the fax job data.

@param   faxJob
The fax job object
@return  The process command to execute
183940
@Override
    protected String createSubmitFaxJobProcessCommand(FaxJob faxJob)
    {
        //get arguments
        String commandArguments=this.createProcessCommandArgumentsForSubmitFaxJob(faxJob);
        
        //create command
        String command=this.createProcessCommand(commandArguments);
        
        return command;
    }
1232775
public FaxJobStatus getFaxJobStatus(FaxClientSpi faxClientSpi,ProcessOutput processOutput)
    {
        //get output
        String output=WindowsFaxClientSpiHelper.getOutputPart(processOutput,Fax4jExeConstants.FAX_JOB_STATUS_OUTPUT_PREFIX.toString());

        FaxJobStatus faxJobStatus=null;
        if(output!=null)
        {
            //get fax job status
            faxJobStatus=WindowsFaxClientSpiHelper.getFaxJobStatusFromWindowsFaxJobStatusString(output);
        }

        return faxJobStatus;
    }
1153779
@Override
    protected void submitFaxJobImpl(FaxJob faxJob)
    {
        //get connection
        Connection<MailResourcesHolder> mailConnection=this.getMailConnection();

        //get holder
        MailResourcesHolder mailResourcesHolder=mailConnection.getResource();

        //create message
        Message message=this.createSubmitFaxJobMessage(faxJob,mailResourcesHolder);
        
        //send message
        this.sendMail(faxJob,mailConnection,message);
    }
119776
@Override
    protected void submitFaxJobImpl(FaxJob faxJob)
    {
        try
        {
            this.submitFaxJobViaFaxModem(faxJob);
        }
        catch(RuntimeException exception)
        {
            throw exception;
        }
        catch(Exception exception)
        {
            throw new FaxException("Unable to send fax via fax modem.",exception);
        }
    }
803259
private void winSuspendFaxJob(String serverName,int faxJobID)
    {
        synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK)
        {
            //pre native call
            this.preNativeCall();
            
            //invoke native
            WindowsJNIFaxClientSpi.suspendFaxJobNative(serverName,faxJobID);
        }
    }
1357158
public HTTPRequest createHTTPRequest(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType,FaxJob faxJob)
    {
        FaxJob2HTTPRequestConverterConfigurationConstants templateName=null;
        switch(faxActionType)
        {
            case SUBMIT_FAX_JOB:
                templateName=FaxJob2HTTPRequestConverterConfigurationConstants.SUBMIT_FAX_JOB_TEMPLATE_PROPERTY_KEY;
                break;
            case SUSPEND_FAX_JOB:
                templateName=FaxJob2HTTPRequestConverterConfigurationConstants.SUSPEND_FAX_JOB_TEMPLATE_PROPERTY_KEY;
                break;
            case RESUME_FAX_JOB:
                templateName=FaxJob2HTTPRequestConverterConfigurationConstants.RESUME_FAX_JOB_TEMPLATE_PROPERTY_KEY;
                break;
            case CANCEL_FAX_JOB:
                templateName=FaxJob2HTTPRequestConverterConfigurationConstants.CANCEL_FAX_JOB_TEMPLATE_PROPERTY_KEY;
                break;
            case GET_FAX_JOB_STATUS:
                templateName=FaxJob2HTTPRequestConverterConfigurationConstants.GET_FAX_JOB_STATUS_TEMPLATE_PROPERTY_KEY;
                break;
            default:
                throw new FaxException("Fax action type: "+faxActionType+" not supported.");
        }

        //create HTTP request
        HTTPRequest httpRequest=this.createHTTPRequest(faxClientSpi,faxActionType,templateName,faxJob);
        
        return httpRequest;
    }
707773
public void submitFaxJob(FaxJob faxJob)
    {
        //validate fax job
        this.invokeFaxJobNullValidation(faxJob);

        //validate fax job target address
        String targetAddress=faxJob.getTargetAddress();
        if((targetAddress==null)||(targetAddress.length()==0))
        {
            throw new FaxException("Fax job target address not provided.");
        }

        //validate fax job file
        File file=faxJob.getFile();
        if(file==null)
        {
            throw new FaxException("Fax job file not provided.");
        }
        else if(!file.exists())
        {
            throw new FaxException("Fax job file "+file.getPath()+" does not exist.");
        }
        else if(!file.isFile())
        {
            throw new FaxException("Fax job file "+file.getPath()+" is not a file.");
        }
        else if(file.length()==0)
        {
            throw new FaxException("Fax job file "+file.getPath()+" is empty.");
        }

        //invoke action
        this.submitFaxJobImpl(faxJob);
        
        //fire event
        this.fireFaxEvent(FaxClientActionEventID.SUBMIT_FAX_JOB,faxJob);

        //start monitoring fax job if and only if monitoring is supported and there are existing listeners
        if(this.isFaxMonitorEventsSupported())
        {
            synchronized(this.faxMonitorEventListeners)
            {
                if(!this.faxMonitorEventListeners.isEmpty())
                {
                    //monitor the submitted fax job
                    this.spiFaxJobMonitor.monitorFaxJob(this,faxJob);
                }
            }
        }
    }
661564
public String getSenderName()
    {
        String value=null;
        try
        {
            value=this.JOB.getFromUser();
        }
        catch(Exception exception)
        {
            throw new FaxException("Error while extracting job sender name.",exception);
        }

        return value;
    }
805708
public void updateFaxJobFromInputData(T inputData,FaxJob faxJob)
    {
        if(!this.initialized)
        {
            throw new FaxException("Fax bridge not initialized.");
        }
        
        //get fax job
        this.updateFaxJobFromInputDataImpl(inputData,faxJob);
    }
967919
@Override
    protected void cancelFaxJobImpl(FaxJob faxJob)
    {
        //create command
        String command=this.createCancelFaxJobProcessCommand(faxJob);
        
        //execute command
        this.executeProcess(faxJob,command,FaxActionType.CANCEL_FAX_JOB);
    }
839506
protected Object[] setupSubmitFaxJobInput(FaxJob faxJob)
    {
        //init list
        List<Object> inputList=new LinkedList<Object>();
        
        //set fax server information
        inputList.add(this.faxServerName);

        //set fax values
        File file=faxJob.getFile();
        inputList.add(file);
        String documentName=faxJob.getProperty(FaxJobExtendedPropertyConstants.DOCUMENT_NAME_FAX_JOB_PROPERTY_KEY.toString(),null);
        if((documentName==null)||(documentName.length()==0))
        {
            documentName=file.getName();
        }
        inputList.add(documentName);

        if(this.useWin2kAPI)
        {
            //set target information
            inputList.add(faxJob.getTargetAddress());
            inputList.add(faxJob.getTargetName());

            //set sender information
            inputList.add(faxJob.getSenderName());
            inputList.add(faxJob.getSenderFaxNumber());
        }
        else
        {
            FaxJobPriority priority=faxJob.getPriority();
            String valueStr="fptNORMAL";
            if(priority!=null)
            {
                switch(priority)
                {
                    case LOW_PRIORITY:
                        valueStr="fptLOW";
                        break;
                    case MEDIUM_PRIORITY:
                        valueStr="fptNORMAL";
                        break;
                    case HIGH_PRIORITY:
                        valueStr="fptHIGH";
                        break;
                }
            }
            inputList.add(valueStr);

            //set target information
            inputList.add(faxJob.getTargetAddress());
            inputList.add(faxJob.getTargetName());

            //set sender information
            inputList.add(faxJob.getSenderName());
            inputList.add(faxJob.getSenderFaxNumber());
            inputList.add(faxJob.getSenderEmail());
        }
        
        //convert to array
        int size=inputList.size();
        Object[] input=inputList.toArray(new Object[size]);
        
        return input;
    }
1071142
protected String formatTemplate(String template,FaxJob faxJob)
    {
        return SpiUtil.formatTemplate(template,faxJob,null,false,true);
    }
948470
@Override
    protected void cancelFaxJobImpl(FaxJob faxJob)
    {
        //get fax job
        HylaFaxJob hylaFaxJob=(HylaFaxJob)faxJob;
        
        //get client
        HylaFAXClient client=this.getHylaFAXClient();

        try
        {
            this.cancelFaxJob(hylaFaxJob,client);
        }
        catch(FaxException exception)
        {
            throw exception;
        }
        catch(Exception exception)
        {
            throw new FaxException("General error.",exception);
        }
    }
159107
protected void updateFaxJobFromRequestImpl(HTTPRequest request,FaxJob faxJob,Map<String,String> queryStringMap)
    {
        //set priority
        String value=queryStringMap.get("priority");
        if(value!=null)
        {
            FaxJobPriority priority=FaxJobPriority.valueOf(value);
            faxJob.setPriority(priority);
        }

        //set target address
        value=queryStringMap.get("target_address");
        if(value==null)
        {
            throw new FaxException("Target address not provided in query string.");
        }
        faxJob.setTargetAddress(value);

        //set target name
        value=queryStringMap.get("target_name");
        if(value!=null)
        {
            faxJob.setTargetName(value);
        }

        //set sender name
        value=queryStringMap.get("sender_name");
        if(value!=null)
        {
            faxJob.setSenderName(value);
        }

        //set sender fax number
        value=queryStringMap.get("sender_fax_number");
        if(value!=null)
        {
            faxJob.setSenderFaxNumber(value);
        }

        //set sender email
        value=queryStringMap.get("sender_email");
        if(value!=null)
        {
            faxJob.setSenderEmail(value);
        }
        
        Iterator<Entry<String,String>> iterator=queryStringMap.entrySet().iterator();
        Entry<String,String> entry=null;
        String key=null;
        String propertyPrefix="property:";
        int propertyPrefixLength=propertyPrefix.length();
        while(iterator.hasNext())
        {
            //get next entry
            entry=iterator.next();
            
            //get next key
            key=entry.getKey();

            if(key.startsWith(propertyPrefix))
            {
                if(key.length()>propertyPrefixLength)
                {
                    //get key
                    key=key.substring(propertyPrefixLength);
                    
                    //get value
                    value=entry.getValue();
                    
                    //set property
                    faxJob.setProperty(key,value);
                }
            }
        }
    }
426887
@Override
    protected void updateFaxJobFromInputDataImpl(HTTPRequest inputData,FaxJob faxJob)
    {
        //get parameters text as map
        Map<String,String> queryStringMap=this.convertParametersTextToMap(inputData);

        //update fax job
        this.updateFaxJobFromRequestImpl(inputData,faxJob,queryStringMap);
    }
711962
private static String getFileParameterValue(FaxJob faxJob)
    {
        String value=null;
        File file=faxJob.getFile();
        if(file!=null)
        {
            try
            {
                //read file (only text files supported)
                value=IOHelper.readTextFile(faxJob.getFile());
            }
            catch(IOException exception)
            {
                throw new FaxException("Error while reading file.",exception);
            }
        }
    
        return value;
    }
1298687
private String winGetFaxJobStatus(String serverName,int faxJobID)
    {
        String status=null;
        synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK)
        {
            //pre native call
            this.preNativeCall();
            
            //invoke native
            status=WindowsJNIFaxClientSpi.getFaxJobStatusNative(serverName,faxJobID);
        }
        
        return status;
    }