This function will cancel an existing fax job.

@param   faxJob
The fax job object containing the needed information
967919
@Override
    protected void cancelFaxJobImpl(FaxJob faxJob)
    {
        //create command
        String command=this.createCancelFaxJobProcessCommand(faxJob);
        
        //execute command
        this.executeProcess(faxJob,command,FaxActionType.CANCEL_FAX_JOB);
    }
1060894
@Override
    protected void suspendFaxJobImpl(FaxJob faxJob)
    {
        //get fax job ID
        int faxJobIDInt=WindowsFaxClientSpiHelper.getFaxJobID(faxJob);

        //invoke fax action
        this.winSuspendFaxJob(this.faxServerName,faxJobIDInt);
    }
868630
protected void suspendFaxJob(HylaFaxJob faxJob,HylaFAXClient client) throws Exception
    {
        //get job
        Job job=faxJob.getHylaFaxJob();
        
        //suspend job
        client.suspend(job);
    }
595940
protected String createSubmitFaxCommand(FaxJob faxJob)
    {
        //init buffer
        StringBuilder buffer=new StringBuilder();
        
        //create command
        buffer.append(this.submitCommand);
        buffer.append(" ");
        buffer.append(this.printQueueParameter);
        buffer.append(" ");
        buffer.append(this.printQueueName);
        buffer.append(" ");
        buffer.append(this.generalParameters);
        buffer.append(" ");
        buffer.append(this.phoneParameter);
        buffer.append("=");
        buffer.append(faxJob.getTargetAddress());
        String targetName=faxJob.getTargetName();
        if((targetName!=null)&&(targetName.length()>0))
        {
            buffer.append(" ");
            buffer.append(this.faxToParameter);
            buffer.append("=\"");
            targetName=SpiUtil.urlEncode(targetName);
            buffer.append(targetName);
            buffer.append("\"");
        }
        buffer.append(" \"");
        buffer.append(faxJob.getFilePath());
        buffer.append("\"");

        //get command
        String command=buffer.toString();
        
        return command;
    }
179350
protected void cancel(String[] args) throws Exception {
		LOG.info("Running 'cancel' command.");

		final Options commandOptions = CliFrontendParser.getCancelCommandOptions();

		final Options commandLineOptions = CliFrontendParser.mergeOptions(commandOptions, customCommandLineOptions);

		final CommandLine commandLine = CliFrontendParser.parse(commandLineOptions, args, false);

		CancelOptions cancelOptions = new CancelOptions(commandLine);

		// evaluate help flag
		if (cancelOptions.isPrintHelp()) {
			CliFrontendParser.printHelpForCancel(customCommandLines);
			return;
		}

		final CustomCommandLine<?> activeCommandLine = getActiveCustomCommandLine(commandLine);

		final String[] cleanedArgs = cancelOptions.getArgs();

		if (cancelOptions.isWithSavepoint()) {
			final JobID jobId;
			final String targetDirectory;

			if (cleanedArgs.length > 0) {
				jobId = parseJobId(cleanedArgs[0]);
				targetDirectory = cancelOptions.getSavepointTargetDirectory();
			} else {
				jobId = parseJobId(cancelOptions.getSavepointTargetDirectory());
				targetDirectory = null;
			}

			if (targetDirectory == null) {
				logAndSysout("Cancelling job " + jobId + " with savepoint to default savepoint directory.");
			} else {
				logAndSysout("Cancelling job " + jobId + " with savepoint to " + targetDirectory + '.');
			}

			runClusterAction(
				activeCommandLine,
				commandLine,
				clusterClient -> {
					final String savepointPath;
					try {
						savepointPath = clusterClient.cancelWithSavepoint(jobId, targetDirectory);
					} catch (Exception e) {
						throw new FlinkException("Could not cancel job " + jobId + '.', e);
					}
					logAndSysout("Cancelled job " + jobId + ". Savepoint stored in " + savepointPath + '.');
				});
		} else {
			final JobID jobId;

			if (cleanedArgs.length > 0) {
				jobId = parseJobId(cleanedArgs[0]);
			} else {
				throw new CliArgsException("Missing JobID. Specify a JobID to cancel a job.");
			}

			logAndSysout("Cancelling job " + jobId + '.');

			runClusterAction(
				activeCommandLine,
				commandLine,
				clusterClient -> {
					try {
						clusterClient.cancel(jobId);
					} catch (Exception e) {
						throw new FlinkException("Could not cancel job " + jobId + '.', e);
					}
				});

			logAndSysout("Cancelled job " + jobId + '.');
		}
	}
20213
public FaxJob submitFaxJob(T inputData)
    {
        if(inputData==null)
        {
            throw new FaxException("Input data not provided.");
        }
        
        //create fax job
        FaxJob faxJob=this.createFaxJob();
        
        //update fax job info
        this.requestParser.updateFaxJobFromInputData(inputData,faxJob);
        
        //create file info
        FileInfo fileInfo=this.requestParser.getFileInfoFromInputData(inputData);
        if(fileInfo==null)
        {
            throw new FaxException("Unable to extract file info from input data.");
        }
        
        //submit fax job
        this.submitFaxJob(faxJob,fileInfo);
        
        return faxJob;
    }
1174674
public void monitorFaxJob(FaxClientSpi faxClientSpi,FaxJob faxJob)
    {
        if(faxClientSpi==null)
        {
            throw new FaxException("Fax client SPI not provided.");
        }
        if(faxJob==null)
        {
            throw new FaxException("Fax job not provided.");
        }
        String id=faxJob.getID();
        if((id==null)||(id.length()==0))
        {
            throw new FaxException("Missing fax job ID in provided fax job.");
        }
        
        //monitor fax job
        this.monitorFaxJobImpl(faxClientSpi,faxJob);
        
    }
1100378
@Override
    protected void updateFaxJobFromInputDataImpl(String[] inputData,FaxJob faxJob)
    {
        //get amount
        int amount=inputData.length;

        if((amount%2)==0)
        {
            String argument=null;
            String key=null;
            String value=null;
            String propertyPrefix="-property:";
            int propertyPrefixLength=propertyPrefix.length();
            for(int index=0;index<inputData.length;index=index+2)
            {
                //get next argument and value
                argument=inputData[index];
                value=inputData[index+1];

                if(argument.equals("-priority"))
                {
                    FaxJobPriority priority=FaxJobPriority.valueOf(value);
                    faxJob.setPriority(priority);
                }
                else if(argument.equals("-target_address"))
                {
                    faxJob.setTargetAddress(value);
                }
                else if(argument.equals("-target_name"))
                {
                    faxJob.setTargetName(value);
                }
                else if(argument.equals("-sender_name"))
                {
                    faxJob.setSenderName(value);
                }
                else if(argument.equals("-sender_fax_number"))
                {
                    faxJob.setSenderFaxNumber(value);
                }
                else if(argument.equals("-sender_email"))
                {
                    faxJob.setSenderEmail(value);
                }
                else if(argument.startsWith(propertyPrefix))
                {
                    if(argument.length()>propertyPrefixLength)
                    {
                        //get key
                        key=argument.substring(propertyPrefixLength);
                        
                        //set property
                        faxJob.setProperty(key,value);
                    }
                }
                else if(!argument.equals("-file"))
                {
                    throw new FaxException("Invalid input provided, unsupported argument: "+argument);
                }
            }
        }
        else
        {
            throw new FaxException("Invalid input provided, expected even number of arguments.");
        }
    }
130764
protected FaxJobStatus[] pollForFaxJobStatuesImpl(FaxJob[] faxJobs)
    {
        //get amount
        int amount=faxJobs.length;
        
        //init array
        FaxJobStatus[] faxJobStatuses=new FaxJobStatus[amount];

        FaxJob faxJob=null;
        FaxJobStatus faxJobStatus=null;
        for(int index=0;index<amount;index++)
        {
            //get next fax job
            faxJob=faxJobs[index];
            
            //set default
            faxJobStatus=FaxJobStatus.UNKNOWN;

            if(faxJob!=null)
            {
                try
                {
                    faxJobStatus=this.getFaxJobStatus(faxJob);
                }
                catch(RuntimeException exception)
                {
                    //ignore errors as this method should not throw any exception
                }
            }

            //set default
            if(faxJobStatus==null)
            {
                faxJobStatus=FaxJobStatus.UNKNOWN;
            }
            
            //put in output array
            faxJobStatuses[index]=faxJobStatus;
        }
        
        return faxJobStatuses;
    }
461809
public void cancelJob(CancelJobRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getJobId(), "The parameter jobId should not be null or empty string.");

        InternalRequest internalRequest = this.createRequest(
                request, HttpMethodName.PUT, JOB, request.getJobId());
        internalRequest.addParameter("cancel", null);

        this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
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);
                }
            }
        }
    }
410099
private synchronized void remove(final String jobIdentifier) {
    final RunningJobImpl result = this.jobs.remove(jobIdentifier);
    if (null == result) {
      throw new RuntimeException("Trying to remove a RunningJob that is unknown: " + jobIdentifier);
    }
  }
803259
private void winSuspendFaxJob(String serverName,int faxJobID)
    {
        synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK)
        {
            //pre native call
            this.preNativeCall();
            
            //invoke native
            WindowsJNIFaxClientSpi.suspendFaxJobNative(serverName,faxJobID);
        }
    }
1035930
@Override
    protected void cancelFaxJobImpl(FaxJob faxJob)
    {
        //get connection
        Connection<MailResourcesHolder> mailConnection=this.getMailConnection();

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

        //create message
        Message message=this.createCancelFaxJobMessage(faxJob,mailResourcesHolder);
        
        //send message
        this.sendMail(faxJob,mailConnection,message);
    }
1090252
public function cancelJob($job)
    {
        $jobId = Utilities::getEntityId(
            $job,
            'WindowsAzure\MediaServices\Models\Job'
        );
        $jobIdEncoded = urlencode($jobId);

        $method = Resources::HTTP_GET;
        $headers = [];
        $postParams = [];
        $queryParams = [];
        $path = "CancelJob?jobid='{$jobIdEncoded}'";
        $statusCode = Resources::STATUS_NO_CONTENT;

        $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode
        );
    }
690329
protected void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType)
    {
        this.httpResponseHandler.updateFaxJob(faxJob,httpResponse,faxActionType);
    }
325801
@Override
  public void abortJob(JobContext context, JobStatus.State state)
  throws IOException {
    cleanupJob(context);
  }