Executes the process and returns the output.

@param   faxJob
The fax job object
@param   command
The command to execute
@param   faxActionType
The fax action type
@return  The process output
483561
protected ProcessOutput executeProcess(FaxJob faxJob,String command,FaxActionType faxActionType)
    {
        if(command==null)
        {
            this.throwUnsupportedException();
        }

        //update command
        String updatedCommand=command;
        if(this.useWindowsCommandPrefix)
        {
            //init buffer
            StringBuilder buffer=new StringBuilder(updatedCommand.length()+this.windowsCommandPrefix.length()+1);
            
            //update command
            buffer.append(this.windowsCommandPrefix);
            buffer.append(" ");
            buffer.append(updatedCommand);
            updatedCommand=buffer.toString();
        }

        //execute process
        ProcessOutput processOutput=ProcessExecutorHelper.executeProcess(this,updatedCommand);

        //validate output (if not valid, an exception should be thrown)
        this.validateProcessOutput(processOutput,faxActionType);
        
        //update fax job
        this.updateFaxJob(faxJob,processOutput,faxActionType);
        
        return processOutput;
    }
991857
protected String createProcessCommandArgumentsForSubmitFaxJob(FaxJob faxJob)
    {
        //get values from fax job
        String targetAddress=faxJob.getTargetAddress();
        String targetName=faxJob.getTargetName();
        String senderName=faxJob.getSenderName();
        File file=faxJob.getFile();
        String fileName=null;
        try
        {
            fileName=file.getCanonicalPath();
        }
        catch(Exception exception)
        {
            throw new FaxException("Unable to extract canonical path from file: "+file,exception);
        }
        String documentName=faxJob.getProperty(WindowsFaxClientSpi.FaxJobExtendedPropertyConstants.DOCUMENT_NAME_PROPERTY_KEY.toString(), null);
        
        //init buffer
        StringBuilder buffer=new StringBuilder();
        
        //create command line arguments
        this.addCommandLineArgument(buffer,Fax4jExeConstants.ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),Fax4jExeConstants.SUBMIT_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE.toString());
        this.addCommandLineArgument(buffer,Fax4jExeConstants.SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),this.faxServerName);
        this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_ADDRESS_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetAddress);
        this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetName);
        this.addCommandLineArgument(buffer,Fax4jExeConstants.SENDER_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),senderName);
        this.addCommandLineArgument(buffer,Fax4jExeConstants.FILE_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),fileName);
        this.addCommandLineArgument(buffer,Fax4jExeConstants.DOCUMENT_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),documentName);
        
        //get text
        String commandArguments=buffer.toString();
        
        return commandArguments;
    }
978838
public FaxJob createFaxJob()
    {
        //create new fax job
        FaxJob faxJob=this.createFaxJobImpl();
        
        //fire event
        this.fireFaxEvent(FaxClientActionEventID.CREATE_FAX_JOB,faxJob);
        
        return faxJob;
    }
690329
protected void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType)
    {
        this.httpResponseHandler.updateFaxJob(faxJob,httpResponse,faxActionType);
    }
191434
public void execute(Runnable command) {
        if (!(command instanceof ClusteredFutureTask)) {
            command = new ClusteredFutureTask<Object>(command, null);
        }
        command.run();
    }
1079329
public synchronized Response doCommandFullResponse(String command) throws CommandFormatException, IOException {
        ModelNode request = cmdCtx.buildRequest(command);
        boolean replacedBytes = replaceFilePathsWithBytes(request);
        OperationResponse response = execute(request, isSlowCommand(command) || replacedBytes);
        return new Response(command, request, response);
    }
1224844
public void resumeFaxJob(FaxJob faxJob)
    {
        //validate fax job ID
        this.invokeFaxJobIDValidation(faxJob);
        
        //invoke action
        this.resumeFaxJobImpl(faxJob);
        
        //fire event
        this.fireFaxEvent(FaxClientActionEventID.RESUME_FAX_JOB,faxJob);
    }
1168278
@Override
    protected String createSuspendFaxJobProcessCommand(FaxJob faxJob)
    {
        //get arguments
        String commandArguments=this.createProcessCommandArgumentsForExistingFaxJob(Fax4jExeConstants.SUSPEND_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE.toString(),faxJob);
        
        //create command
        String command=this.createProcessCommand(commandArguments);
        
        return command;
    }
1254761
protected void submitFaxJobViaFaxModem(FaxJob faxJob) throws Exception
    {
        //get type
        String type=faxJob.getProperty(FaxJobExtendedPropertyConstants.DATA_TYPE_FAX_JOB_PROPERTY_KEY.toString(),"TEXT");

        //get common values
        int width=Integer.parseInt(faxJob.getProperty(FaxJobExtendedPropertyConstants.WIDTH_FAX_JOB_PROPERTY_KEY.toString(),null));
        int height=Integer.parseInt(faxJob.getProperty(FaxJobExtendedPropertyConstants.HEIGHT_FAX_JOB_PROPERTY_KEY.toString(),null));
        int imageType=Integer.parseInt(faxJob.getProperty(FaxJobExtendedPropertyConstants.IMAGE_TYPE_FAX_JOB_PROPERTY_KEY.toString(),String.valueOf(BufferedImage.TYPE_INT_RGB)));

        //create image
        BufferedImage image=new BufferedImage(width,height,imageType);
        
        //create fax producer
        Object faxProducer=null;
        if(type.equalsIgnoreCase("PDF"))
        {
            //get type
            Class<?> classDefinition=ReflectionHelper.getType("com.java4less.rfax.PDFFaxProducer");

            //create fax producer
            faxProducer=ReflectionHelper.createInstance(classDefinition);
            
            ReflectionHelper.invokeMethod(classDefinition,faxProducer,"setPDFFile",new Class[]{String.class},new Object[]{faxJob.getFilePath()});
            Field field=ReflectionHelper.getField(classDefinition,"pageImage");
            field.set(faxProducer,image);
        }
        else if(type.equalsIgnoreCase("TEXT"))
        {
            //get type
            Class<?> classDefinition=ReflectionHelper.getType("com.java4less.rfax.TextFaxProducer");

            //create fax producer
            faxProducer=ReflectionHelper.createInstance(classDefinition);
            
            String text=IOHelper.readTextFile(faxJob.getFile());
            Field field=ReflectionHelper.getField(classDefinition,"text");
            field.set(faxProducer,text);
            field=ReflectionHelper.getField(classDefinition,"pageImage");
            field.set(faxProducer,image);
            ReflectionHelper.invokeMethod(classDefinition,faxProducer,"prepare",null,null);
        }
        else
        {
            throw new FaxException("Unsupported type provided: "+type);
        }

        //init fax modem
        Class<?> faxModemClassDefinition=ReflectionHelper.getType("com.java4less.rfax.FaxModem");
        Object faxModem=ReflectionHelper.createInstance(faxModemClassDefinition);
        ReflectionHelper.invokeMethod(faxModemClassDefinition,faxModem,"setPortName",new Class[]{String.class},new Object[]{this.portName});
        Field field=ReflectionHelper.getField(faxModemClassDefinition,"faxClass");
        field.set(faxModem,Integer.valueOf(this.faxClass));

        //send fax
        Class<?> faxProducerClassDefinition=ReflectionHelper.getType("com.java4less.rfax.FaxProducer");
        ReflectionHelper.invokeMethod(faxModemClassDefinition,faxModem,"open",new Class[]{faxProducerClassDefinition},new Object[]{faxProducer});
        boolean faxSent=((Boolean)ReflectionHelper.invokeMethod(faxModemClassDefinition,faxModem,"sendFax",new Class[]{String.class},new Object[]{faxJob.getTargetAddress()})).booleanValue();
        
        //release fax modem
        ReflectionHelper.invokeMethod(faxModemClassDefinition,faxModem,"close",null,null);
        
        if(!faxSent)
        {
            field=ReflectionHelper.getField(faxModemClassDefinition,"lastError");
            String lastError=(String)field.get(faxModem);
            throw new FaxException("Error while sending fax. Error: "+lastError);
        }
    }
1157979
public static void validateFaxJobID(String faxJobID)
    {
        if((faxJobID==null)||(faxJobID.length()==0))
        {
            throw new FaxException("Fax job ID not provided.");
        }
        int faxJobIDInt=Integer.parseInt(faxJobID);
        WindowsFaxClientSpiHelper.validateFaxJobID(faxJobIDInt);
    }
87663
@VisibleForTesting
  boolean runProcess(List<String> auroraCmd, StringBuilder stdout, StringBuilder stderr) {
    int status =
        ShellUtils.runProcess(auroraCmd.toArray(new String[auroraCmd.size()]),
            stderr != null ? stderr : new StringBuilder());

    if (status != 0) {
      LOG.severe(String.format(
          "Failed to run process. Command=%s, STDOUT=%s, STDERR=%s", auroraCmd, stdout, stderr));
    }
    return status == 0;
  }
324081
@Override
    protected String createGetStatusFaxJobProcessCommand(FaxJob faxJob)
    {
        //get arguments
        String commandArguments=this.createProcessCommandArgumentsForExistingFaxJob(Fax4jExeConstants.GET_STATUS_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE.toString(),faxJob);
        
        //create command
        String command=this.createProcessCommand(commandArguments);
        
        return command;
    }
1083865
public static CommandResult execCommand(String command, boolean isRoot) {
        return execCommand(new String[]{command}, isRoot, true);
    }
1012832
public static int getFaxJobID(FaxJob faxJob)
    {
        if(faxJob==null)
        {
            throw new FaxException("Fax job not provided.");
        }

        //get fax job ID
        String faxJobID=faxJob.getID();
        WindowsFaxClientSpiHelper.validateFaxJobID(faxJobID);
        int faxJobIDInt=Integer.parseInt(faxJobID);

        return faxJobIDInt;
    }
884001
@Override
    protected void cancelFaxJobImpl(FaxJob faxJob)
    {
        String name=VBSFaxClientSpi.VBS_WIN_XP_CANCEL_SCRIPT;
        if(this.useWin2kAPI)
        {
            name=VBSFaxClientSpi.VBS_WIN_2K_CANCEL_SCRIPT;
        }

        //invoke script
        this.invokeExistingFaxJobAction(name,faxJob,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);
    }
715060
private Object executeAjaxCalls(FacesContext context, String command) {
		Object result = null;
		int pos = command.indexOf("ajax:");
		while (pos >= 0) { // the command may contain several AJAX and
							// JavaScript calls, in arbitrary order

			String el = command.substring(pos + "ajax:".length());
			if (el.contains("javascript:")) {
				int end = el.indexOf("javascript:");
				el = el.substring(0, end);
			}
			el = el.trim();
			while (el.endsWith(";")) {
				el = el.substring(0, el.length() - 1).trim();
			}

			if (context.isProjectStage(ProjectStage.Development)) {
				checkELSyntax(el, context.getELContext());
			}
			ValueExpression vex = evalAsValueExpression("#{" + el + "}");
			try {
				result = vex.getValue(context.getELContext());
			} catch (javax.el.PropertyNotFoundException ex) {
				MethodExpression mex = evalAsMethodExpression("#{" + el + "}");
				result = mex.invoke(context.getELContext(), null);
			}

			// look for the next AJAX call (if any)
			pos = command.indexOf("ajax:", pos + 1);
		}
		return result;
	}