Example #1
0
 public function testItIgnoreOldLogs()
 {
     $this->dao->expects($this->once())->method('searchLatestEntryTimestamp')->will($this->returnValue(1389687000));
     $this->dao->expects($this->exactly(3))->method('store');
     $file_importer = new Tuleap\ProFTPd\Xferlog\FileImporter($this->dao, new Tuleap\ProFTPd\Xferlog\Parser(), $this->user_manager, $this->project_manager, '/bla');
     $file_importer->import(__DIR__ . '/_fixtures/xferlog');
 }
Example #2
0
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'pre.php';
require_once __DIR__ . '/../include/autoload.php';
$plugin_manager = PluginManager::instance();
$plugin = $plugin_manager->getPluginByName('proftpd');
if ($plugin && $plugin_manager->isPluginAvailable($plugin)) {
    $file_importer = new Tuleap\ProFTPd\Xferlog\FileImporter(new Tuleap\ProFTPd\Xferlog\Dao(), new Tuleap\ProFTPd\Xferlog\Parser(), UserManager::instance(), ProjectManager::instance(), $plugin->getPluginInfo()->getPropVal('proftpd_base_directory'));
    $file_importer->import($argv[1]);
    echo "{$file_importer->getNbImportedLines()} lines imported" . PHP_EOL;
    $errors = $file_importer->getErrors();
    $nb_errors = count($errors);
    if ($nb_errors) {
        $logger = new BackendLogger();
        echo "{$nb_errors} errors" . PHP_EOL;
        foreach ($errors as $error) {
            $logger->error('[Proftpd][xferlog parse] ' . $error);
            echo "*** ERROR: " . $error . PHP_EOL;
        }
    }
} else {
    echo "*** ERROR: proftpd plugin not available" . PHP_EOL;
}