public function validate($schema = '')
    {
        $forced = $this->valid;
        $this->valid = true;

        try {
            switch ($this->sourceType) {
                case self::SOURCE_FILE:
                if (!file_exists($this->source)) {
                        throw new Exception("File " . $this->source . " not found.");
                    }
                    if (!is_readable($this->source)) {
                        throw new Exception("Unable to read file " . $this->source);
                    }
                    if (!preg_match("/\.zip$/", basename($this->source))) {
                        throw new Exception("Wrong file extension in " . $this->source . ", zip extension is expected");
                    }
                    if (!tao_helpers_File::securityCheck($this->source)) {
                        throw new Exception($this->source . " seems to contain some security issues");
                    }
                    break;

                case self::SOURCE_FLYFILE:
                    /** @var File $this->source */
                    if (! $this->source->exists()) {
                        throw new Exception('Source file does not exists ("' . $this->source->getBasename() . '").');
                    }
                    if (!preg_match("/\.zip$/", $this->source->getBasename())) {
                        throw new Exception('Wrong file extension in ' . $this->source->getBasename() . ', zip extension is expected.');
                    }
                    if (! $this->content = $this->source->read()) {
                        throw new Exception('Unable to read file ("' . $this->source->getBasename() . '").');
                    }
                    break;

                default:
                    throw new Exception("File cannot be handled by package parser.");
                    break;
            }
        } catch (Exception $e) {
            if ($forced) {
                throw $e;
            } else {
                $this->addError($e);
            }
        }

        if ($this->valid && !$forced) {
            $this->valid = false;
            $this->valid = $this->isValidArchive();
        }

        return $this->valid;
    }