validate parameter and execute the format.

@param  TstampTask $tstamp reference to task
@throws BuildException
189973
public function execute(TstampTask $tstamp, $d, $location)
    {
        if (empty($this->propertyName)) {
            throw new BuildException("property attribute must be provided", $location);
        }

        if (empty($this->pattern)) {
            throw new BuildException("pattern attribute must be provided", $location);
        }

        $oldlocale = "";
        if (!empty($this->locale)) {
            $oldlocale = setlocale(LC_ALL, 0);
            setlocale(LC_ALL, $this->locale);
        }

        $savedTimezone = date_default_timezone_get();
        if (!empty($this->timezone)) {
            date_default_timezone_set($this->timezone);
        }

        $value = strftime($this->pattern, $d);
        $tstamp->prefixProperty($this->propertyName, $value);

        if (!empty($this->locale)) {
            // reset locale
            setlocale(LC_ALL, $oldlocale);
        }

        if (!empty($this->timezone)) {
            date_default_timezone_set($savedTimezone);
        }
    }
256235
private function check_timestamp($timestamp)
    {
        if (!$timestamp) {
            throw new Twitter_OAuthException(
                'Missing timestamp parameter. The parameter is required'
            );
        }

        // verify that timestamp is recentish
        $now = time();
        if (abs($now - $timestamp) > $this->timestamp_threshold) {
            throw new Twitter_OAuthException(
                "Expired timestamp, yours $timestamp, ours $now"
            );
        }
    }
159291
protected function checkTimestamp($timestamp)
    {
        if (!$timestamp) {
            throw new OAuthException(
                'Missing timestamp parameter. The parameter is required'
            );
        }
        
        // verify that timestamp is recentish
        $now = time();
        if (abs($now - $timestamp) > $this->timestamp_threshold) {
            throw new OAuthException(
                "Expired timestamp, yours $timestamp, ours $now"
            );
        }
    }
849280
protected function check_timestamp($timestamp) {
    if( ! $timestamp )
      throw new OAuthException(
        'Missing timestamp parameter. The parameter is required'
      );
    
    // verify that timestamp is recentish
    $now = time();
    if (abs($now - $timestamp) > $this->timestamp_threshold) {
      throw new OAuthException(
        "Expired timestamp, yours $timestamp, ours $now"
      );
    }
  }
514786
public function main()
    {
        if ($this->propertyName === null) {
            throw new BuildException("You must specify a value for propertyName attribute.");
        }

        if ($this->message === "") {
            throw new BuildException("You must specify a message for input task.");
        }

        if ($this->validargs !== null) {
            $accept = preg_split('/[\s,]+/', $this->validargs);

            // is it a boolean (yes/no) inputrequest?
            $yesno = false;
            if (count($accept) == 2) {
                $yesno = true;
                foreach ($accept as $ans) {
                    if (!StringHelper::isBoolean($ans)) {
                        $yesno = false;
                        break;
                    }
                }
            }
            if ($yesno) {
                $request = new YesNoInputRequest($this->message, $accept);
            } else {
                $request = new MultipleChoiceInputRequest($this->message, $accept);
            }
        } else {
            $request = new InputRequest($this->message);
        }

        // default default is curr prop value
        $request->setDefaultValue($this->project->getProperty($this->propertyName));
        $request->setPromptChar($this->promptChar);
        $request->setHidden($this->hidden);

        // unless overridden...
        if ($this->defaultValue !== null) {
            $request->setDefaultValue($this->defaultValue);
        }

        $this->project->getInputHandler()->handleInput($request);

        $value = $request->getInput();

        if ($value !== null) {
            $this->project->setUserProperty($this->propertyName, $value);
        }
    }
767032
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('log');
        $command
            ->setOption('stat', $this->getStat())
            ->setOption('name-status', $this->isNameStatus())
            ->setOption('no-merges', $this->isNoMerges())
            ->setOption('format', $this->getFormat());

        if (null !== $this->getMaxCount()) {
            $command->setOption('max-count', $this->getMaxCount());
        }

        if (null !== $this->getDate()) {
            $command->setOption('date', $this->getDate());
        }

        if (null !== $this->getSince()) {
            $command->setOption('since', $this->getSince());
        }

        if (null !== $this->getUntil()) {
            $command->setOption('until', $this->getUntil());
        }

        $command->addDoubleDash(true);
        if (null !== $this->getPaths()) {
            $command->addDoubleDash(false);
            $paths = explode(PATH_SEPARATOR, $this->getPaths());
            foreach ($paths as $path) {
                $command->addArgument($path);
            }
        }

        $this->log('git-log command: ' . $command->createCommandString(), Project::MSG_INFO);

        try {
            $output = $command->execute();
        } catch (Exception $e) {
            throw new BuildException('Task execution failed', $e);
        }

        if (null !== $this->outputProperty) {
            $this->project->setProperty($this->outputProperty, trim($output));
        }

        $this->log(
            sprintf('git-log: commit log for "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-log output: ' . trim($output), Project::MSG_INFO);
    }
153106
private static function validateTimestamp($timestamp) {

        $check = (is_int($timestamp) || is_float($timestamp))
            ? $timestamp
            : (string) (int) $timestamp;

        return  ($check === $timestamp)
            AND ( (int) $timestamp <=  PHP_INT_MAX)
            AND ( (int) $timestamp >= ~PHP_INT_MAX);
    }
1101084
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }
        if (null === $this->getBranchname()) {
            throw new BuildException('"branchname" is required parameter');
        }

        // if we are moving branch, we need to know new name
        if ($this->isMove() || $this->isForceMove()) {
            if (null === $this->getNewBranch()) {
                throw new BuildException('"newbranch" is required parameter');
            }
        }

        $client = $this->getGitClient(false, $this->getRepository());

        $command = $client->getCommand('branch');

        if (version_compare($client->getGitVersion(), '2.15.0', '<')) {
            $command->setOption('set-upstream', $this->isSetUpstream());
        } elseif ($this->isSetUpstreamTo()) {
            $command->setOption('set-upstream-to', $this->getSetUpstreamTo());
        }

        $command
            ->setOption('no-track', $this->isNoTrack())
            ->setOption('force', $this->isForce());
        if ($this->isNoTrack() == false) {
            $command->setOption('track', $this->getTrack());
        }

        // check extra options (delete, move)
        foreach ($this->extraOptions as $option => $flag) {
            if ($flag) {
                $command->setOption($option, true);
            }
        }

        $command->addArgument($this->getBranchname());

        if (null !== $this->getStartPoint()) {
            $command->addArgument($this->getStartPoint());
        }

        if (null !== $this->getNewBranch()) {
            $command->addArgument($this->getNewBranch());
        }

        $this->log('git-branch command: ' . $command->createCommandString(), Project::MSG_INFO);

        try {
            $output = $command->execute();
        } catch (Exception $e) {
            throw new BuildException(
                'Task execution failed with git command "' . $command->createCommandString() . '""',
                $e
            );
        }

        $this->log(
            sprintf('git-branch: branch "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-branch output: ' . str_replace('\'', '', trim($output)), Project::MSG_INFO);
    }
1084148
protected function setExpiresAtFromTimeStamp($timeStamp)
    {
        $dt = new \DateTime();
        $dt->setTimestamp($timeStamp);
        $this->expiresAt = $dt;
    }
617787
@Override
   public void execute() throws BuildException 
   {
      ClassLoader oldCL = SecurityActions.getThreadContextClassLoader();
      try 
      {
         SecurityActions.setThreadContextClassLoader(SecurityActions.getClassLoader(ValidatorTask.class));

         Validation.validate(new File(getRarFile()).toURI().toURL(), 
            getOutputDir(), getCommandLine().getClasspath().list());
      }
      catch (Throwable t) 
      {
         throw new BuildException(t.getMessage(), t);
      }
      finally
      {
         SecurityActions.setThreadContextClassLoader(oldCL);
      }
   }
1149036
private function check_timestamp($timestamp)
    {
        if( ! $timestamp )
            throw new Exception(
                'Missing timestamp parameter. The parameter is required'
            );

        // verify that timestamp is recentish
        $now = time();
        if (abs($now - $timestamp) > $this->timestamp_threshold) {
            throw new Exception(
                "Expired timestamp, yours $timestamp, ours $now"
            );
        }
    }
837102
private function execute() {

		if(false === $this -> getExecuted()) {

			foreach($this -> rules as $rule) {

				$file = $this -> getFile($rule -> field, $rule -> prefix);

				//Execute custom extended validator
				if($rule -> closure) {

					if(false === call_user_func($rule -> closure, $rule -> field, $file)) {

						$this -> setPasses(false);

						$instance = $this -> getMessageInstance();
						$instance :: setFieldnames([$rule -> field]);
						$instance :: setError($rule -> prefix, $rule -> field, $rule -> message);
					}

					continue;
				}

				//Execute build in validator
				$class = $this -> getRuleClass($rule -> rule);
				$class = new $class();

				//Set rule data
				$class -> setField($rule -> field);
				$class -> setFile($file);
				$class -> setPrefix($rule -> prefix);
				$class -> setParameters($rule -> parameters);

				//Check if rule passes
				if(false === $this -> isRequired($rule -> field, $file) && false === $class -> isValid()) {

					$this -> setPasses(false);
					$this -> setErrorMessage($rule, $class);
				}
			}

			$this -> setExecuted(true);
		}
	}
1162518
protected function validate()
    {
        if ($this->descriptor === null || $this->scripts === null || $this->package === null) {
            throw new BuildException(
                'The deployment tool needs at least the project descriptor, '
                . 'the scripts folder and package folder to be set.'
            );
        } elseif ($this->lint !== false && $this->phpbin === null) {
            throw new BuildException('You set the lint option but not the path to the php executable.');
        }

        parent::validate();

        if ($this->lint !== false) {
            $this->arguments .= '--lint ';
        }

        if ($this->source !== null) {
            $this->arguments .= "--src-dir=$this->source ";
        }

        if ($this->output !== null) {
            $this->arguments .= "--output-dir=$this->output ";
        }

        if ($this->phpbin !== null) {
            $this->arguments .= "--php-exe=$this->phpbin ";
        }

        $this->arguments .= "--scripts-dir=$this->scripts ";
        $this->arguments .= "--package-descriptor=$this->descriptor ";
        $this->arguments .= $this->package;
    }
297041
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }
        if (null === $this->getBranchname()) {
            throw new BuildException('"branchname" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('checkout');
        $command
            ->setOption('no-track', $this->isNoTrack())
            ->setOption('q', $this->isQuiet())
            ->setOption('force', $this->isForce())
            ->setOption('b', $this->isCreate())
            ->setOption('B', $this->isForceCreate())
            ->setOption('m', $this->isMerge());
        if ($this->isNoTrack()) {
            $command->setOption('track', $this->isTrack());
        }

        $command->addArgument($this->getBranchname());

        if (null !== $this->getStartPoint()) {
            $command->addArgument($this->getStartPoint());
        }

        $this->log('git-checkout command: ' . $command->createCommandString(), Project::MSG_INFO);

        try {
            $output = $command->execute();
        } catch (Exception $e) {
            throw new BuildException('Task execution failed.', $e);
        }

        $this->log(
            sprintf('git-checkout: checkout "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-checkout output: ' . str_replace('\'', '', trim($output)), Project::MSG_INFO);
    }
1358550
public function main()
    {
        if ('apigen' !== $this->executable && !is_file($this->executable)) {
            throw new BuildException(sprintf('Executable %s not found', $this->executable), $this->getLocation());
        }

        if (!empty($this->options['config'])) {
            // Config check
            if (!is_file($this->options['config'])) {
                throw new BuildException(
                    sprintf(
                        'Config file %s doesn\'t exist',
                        $this->options['config']
                    ),
                    $this->getLocation()
                );
            }
        } else {
            // Source check
            if (empty($this->options['source'])) {
                throw new BuildException('Source is not set', $this->getLocation());
            }
            // Destination check
            if (empty($this->options['destination'])) {
                throw new BuildException('Destination is not set', $this->getLocation());
            }
        }

        // Source check
        if (!empty($this->options['source'])) {
            foreach ($this->options['source'] as $source) {
                if (!file_exists($source)) {
                    throw new BuildException(sprintf('Source %s doesn\'t exist', $source), $this->getLocation());
                }
            }
        }

        // Execute ApiGen
        exec(
            escapeshellcmd($this->executable) . ' ' . escapeshellcmd($this->action) . ' ' . $this->constructArguments(),
            $output,
            $return
        );

        $logType = 0 === $return ? Project::MSG_INFO : Project::MSG_ERR;
        foreach ($output as $line) {
            $this->log($line, $logType);
        }
    }
77500
public static function main($task)
    {
        $methodName = "main";
        $dispatchable = null;
        try {
            if ($task instanceof Dispatchable) {
                $dispatchable = $task;
            } elseif ($task instanceof UnknownElement) {
                $ue = $task;
                $realThing = $ue->getRealThing();
                if ($realThing != null && $realThing instanceof Dispatchable && $realThing instanceof Task) {
                    $dispatchable = $realThing;
                }
            }
            if ($dispatchable != null) {
                $mName = null;

                $name = trim($dispatchable->getActionParameterName());
                if (empty($name)) {
                    throw new BuildException(
                        "Action Parameter Name must not be empty for Dispatchable Task."
                    );
                }
                $mName = "get" . ucfirst($name);
                try {
                    $c = new ReflectionClass($dispatchable);
                    $actionM = $c->getMethod($mName);
                    $o = $actionM->invoke($dispatchable);
                    $methodName = trim((string) $o);
                    if (empty($methodName)) {
                        throw new ReflectionException();
                    }
                } catch (ReflectionException $re) {
                    throw new BuildException(
                        "Dispatchable Task attribute '" . $name . "' not set or value is empty."
                    );
                }
                $executeM = $c->getMethod($methodName);
                $executeM->invoke($dispatchable);

                if ($task instanceof UnknownElement) {
                    $task->setRealThing(null);
                }
            } else {
                try {
                    $refl = new ReflectionClass($task);
                    $executeM = $refl->getMethod($methodName);
                } catch (ReflectionException $re) {
                    throw new BuildException("No public " . $methodName . "() in " . get_class($task));
                }
                $executeM->invoke($task);
                if ($task instanceof UnknownElement) {
                    $task->setRealThing(null);
                }
            }
        } catch (ReflectionException $e) {
            throw new BuildException($e);
        }
    }
407449
public function main()
    {
        $message = $this->getMessage();
        if ($message === '') {
            throw new BuildException('"message" is a required parameter');
        }

        $user = $this->getUser();

        $clone = $this->getFactoryInstance('commit');
        $msg = sprintf("Commit: '%s'", $message);
        $this->log($msg, Project::MSG_INFO);
        $clone->setQuiet($this->getQuiet());
        $clone->setMessage($message);

        if (trim($user) === "") {
            throw new BuildException('"user" parameter can not be set to ""');
        }
        if ($user !== null) {
            $clone->setUser($user);
            $this->log("Commit: user = '$user'", Project::MSG_VERBOSE);
        }

        if ($this->repository === '') {
            $project = $this->getProject();
            $dir = $project->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }
        $this->log('DIR:' . $dir, Project::MSG_INFO);
        $this->log('REPO: ' . $this->repository, Project::MSG_INFO);
        $cwd = getcwd();
        chdir($dir);

        try {
            $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
            $output = $clone->execute();
            if ($output !== '') {
                $this->log($output);
            }
        } catch (Exception $ex) {
            $msg = $ex->getMessage();
            $this->log("Exception: $msg", Project::MSG_INFO);
            $p = strpos($msg, 'hg returned:');
            if ($p !== false) {
                $msg = substr($msg, $p + 13);
            }
            chdir($cwd);
            throw new BuildException($msg);
        }
        chdir($cwd);
    }