Skip to content

Commit

Permalink
[IM] IX-F member export - give a user friend message rather than a 50…
Browse files Browse the repository at this point in the history
…0 response if ixfid is missing
  • Loading branch information
barryo committed Jun 19, 2020
1 parent 874bb31 commit 7286616
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/Exceptions/Utils/ExportException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@
*/

use Exception;
//use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use IXP\Utils\View\Alert\Alert;
use IXP\Utils\View\Alert\Container as AlertContainer;

class ExportException extends Exception {}
class ExportException extends Exception {

final public function render()
{
AlertContainer::push( $this->getMessage(), Alert::DANGER );
return redirect()->to('');
}
}
24 changes: 23 additions & 1 deletion app/Utils/Export/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,29 @@ private function getIXPInfo( $version )
if( $infra->getIxfIxId() ) {
$i[ 'ixf_id' ] = intval( $infra->getIxfIxId() );
} else if( $version >= self::EUROIX_JSON_VERSION_0_7 ) {
throw new ExportException( "IX-F ID is required for IX-F Export Schema >=v0.7. Set this under Infrastructures." );

// The IX-F ID is officially required for >= v0.7 of the schema.
// This shouldn't prevent the IX_F exporter from working though if someone wishes to pull the
// information regardless of that being set.
//
// Two options for this:

// first pass an ixfid for **every** infrastructure that does not have one
// e.g. http://ixp-inex.ldev/api/v4/member-export/ixf/1.0?ixfid_1=30&ixfid_2=31&ixfid_3=30
if( request('ixfid_' . $infra->getId(), false ) ) {
$i[ 'ixf_id' ] = intval( request( 'ixfid_' . $infra->getId() ) );
}

// second, just ignore it and set it to zero:
// http://ixp-inex.ldev/api/v4/member-export/ixf/1.0?ignore_missing_ixfid=1
else if( request('ignore_missing_ixfid', false ) ) {
$i[ 'ixf_id' ] = 0;
}

// by default, we will throw an exception:
else {
throw new ExportException( "The IX-F ID is a required parameter for IX-F Export Schema >=v0.7. Set this in IXP Manager in the 'Infrastructures' management page." );
}
}

$i['ixp_id'] = $infra->getId(); // referenced in member's connections section
Expand Down

0 comments on commit 7286616

Please sign in to comment.