MT#15701 API: delete/create domain after changes to DB

Change-Id: I11ebb81643a9df06abfa059f3f1db57a032aaa9b
changes/78/2878/6
Victor Seva 10 years ago committed by Gerhard Jungwirth
parent f1725caa40
commit 39cb08bd74

@ -206,17 +206,6 @@ sub POST :Allow {
last;
}
try {
unless($c->config->{features}->{debug}) {
$self->xmpp_domain_reload($c, $resource->{domain});
$self->sip_domain_reload($c);
}
} catch($e) {
$c->log->error("failed to activate domain: $e"); # TODO: user, message, trace, ...
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to activate domain.");
last;
}
last unless $self->add_create_journal_item_hal($c,sub {
my $self = shift;
my ($c) = @_;
@ -225,6 +214,21 @@ sub POST :Allow {
$guard->commit;
try {
unless($c->config->{features}->{debug}) {
$self->xmpp_domain_reload($c, $resource->{domain});
my (undef, $xmlrpc_res) = $self->sip_domain_reload($c);
if (!defined $xmlrpc_res || $xmlrpc_res < 1) {
die "XMLRPC failed";
}
}
} catch($e) {
$c->log->error("failed to activate domain: $e. Domain created"); # TODO: user, message, trace, ...
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to activate domain. Domain was created");
$c->response->header(Location => sprintf('/%s%d', $c->request->path, $billing_domain->id));
last;
}
$c->response->status(HTTP_CREATED);
$c->response->header(Location => sprintf('/%s%d', $c->request->path, $billing_domain->id));
$c->response->body(q());

@ -122,6 +122,8 @@ sub DELETE :Allow {
$domain->delete;
$guard->commit;
try {
unless($c->config->{features}->{debug}) {
$self->xmpp_domain_disable($c, $domain);
@ -132,8 +134,6 @@ sub DELETE :Allow {
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to deactivate domain.");
last;
}
$guard->commit;
$c->response->status(HTTP_NO_CONTENT);
$c->response->body(q());

@ -144,7 +144,15 @@ sub create :Chained('dom_list') :PathPart('create') :Args() {
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/domain'));
}
$self->_sip_domain_reload($c);
my (undef, $xmlrpc_res) = $self->_sip_domain_reload($c);
if (!defined $xmlrpc_res || $xmlrpc_res < 1) {
NGCP::Panel::Utils::Message->error(
c => $c,
desc => $c->loc('Failed to activate domain. Domain was created.'),
);
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/domain'));
}
NGCP::Panel::Utils::Message->info(
c => $c,
desc => $c->loc('Domain successfully created'),
@ -392,7 +400,7 @@ sub load_preference_list :Private {
sub _sip_domain_reload {
my ($self, $c) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
my ($res) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
<?xml version="1.0" ?>
<methodCall>
<methodName>domain.reload</methodName>
@ -400,7 +408,7 @@ sub _sip_domain_reload {
</methodCall>
EOF
return 1;
return ref $res ? @{ $res } : ();
}
__PACKAGE__->meta->make_immutable;

@ -145,7 +145,7 @@ sub item_by_id {
sub sip_domain_reload {
my ($self, $c) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
my ($res) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
<?xml version="1.0" ?>
<methodCall>
<methodName>domain.reload</methodName>
@ -153,7 +153,7 @@ sub sip_domain_reload {
</methodCall>
EOF
return 1;
return ref $res ? @{ $res } : ();
}
sub xmpp_domain_reload {

Loading…
Cancel
Save