diff --git a/lib/NGCP/Panel/Controller/Domain.pm b/lib/NGCP/Panel/Controller/Domain.pm index 382b868a67..626cdd6ebd 100644 --- a/lib/NGCP/Panel/Controller/Domain.pm +++ b/lib/NGCP/Panel/Controller/Domain.pm @@ -11,6 +11,7 @@ use NGCP::Panel::Utils::Message; use NGCP::Panel::Utils::Navigation; use NGCP::Panel::Utils::Prosody; use NGCP::Panel::Utils::Preferences; +use NGCP::Panel::Utils::XMLDispatcher; sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) { my ($self, $c) = @_; @@ -402,8 +403,7 @@ sub load_preference_list :Private { sub _sip_domain_reload { my ($self, $c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my ($res) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my ($res) = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>domain.reload</methodName> diff --git a/lib/NGCP/Panel/Controller/Logout.pm b/lib/NGCP/Panel/Controller/Logout.pm index 176876c21a..5ba8b46522 100644 --- a/lib/NGCP/Panel/Controller/Logout.pm +++ b/lib/NGCP/Panel/Controller/Logout.pm @@ -1,8 +1,10 @@ package NGCP::Panel::Controller::Logout; use NGCP::Panel::Utils::Generic qw(:all); -use Moose; -BEGIN { extends 'Catalyst::Controller'; } +use strict; +use warnings; + +use parent 'Catalyst::Controller'; =head1 NAME diff --git a/lib/NGCP/Panel/Controller/Root.pm b/lib/NGCP/Panel/Controller/Root.pm index 76181d14ec..9758a78da8 100644 --- a/lib/NGCP/Panel/Controller/Root.pm +++ b/lib/NGCP/Panel/Controller/Root.pm @@ -1,8 +1,10 @@ package NGCP::Panel::Controller::Root; use NGCP::Panel::Utils::Generic qw(:all); -use Moose; -BEGIN { extends 'Catalyst::Controller' } +use warnings; +use strict; + +use parent 'Catalyst::Controller'; use Scalar::Util qw(blessed); use NGCP::Panel::Utils::DateTime qw(); diff --git a/lib/NGCP/Panel/Controller/Sound.pm b/lib/NGCP/Panel/Controller/Sound.pm index bb77e578ea..4901aecb2f 100644 --- a/lib/NGCP/Panel/Controller/Sound.pm +++ b/lib/NGCP/Panel/Controller/Sound.pm @@ -10,7 +10,6 @@ use NGCP::Panel::Form; use File::Type; use File::Slurp; use File::Basename; -use NGCP::Panel::Utils::XMLDispatcher; use NGCP::Panel::Utils::Sounds; use NGCP::Panel::Utils::Navigation; use NGCP::Panel::Utils::Sems; diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index d1eb0c0cc0..f4ef8c0caf 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -26,7 +26,6 @@ use NGCP::Panel::Utils::Kamailio; use NGCP::Panel::Utils::Events; use NGCP::Panel::Utils::ProfilePackages qw(); -use NGCP::Panel::Utils::XMLDispatcher; use UUID; =head1 NAME diff --git a/lib/NGCP/Panel/Field/AliasNumber.pm b/lib/NGCP/Panel/Field/AliasNumber.pm index d7d05f2d8d..87c3cfe2e4 100644 --- a/lib/NGCP/Panel/Field/AliasNumber.pm +++ b/lib/NGCP/Panel/Field/AliasNumber.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::AliasNumber; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Repeatable'; diff --git a/lib/NGCP/Panel/Field/BillingNetwork.pm b/lib/NGCP/Panel/Field/BillingNetwork.pm index 0bcd1bb880..e1a854c9f9 100644 --- a/lib/NGCP/Panel/Field/BillingNetwork.pm +++ b/lib/NGCP/Panel/Field/BillingNetwork.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::BillingNetwork; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/BillingProfile.pm b/lib/NGCP/Panel/Field/BillingProfile.pm index e2fc6c553d..f82966ad2b 100644 --- a/lib/NGCP/Panel/Field/BillingProfile.pm +++ b/lib/NGCP/Panel/Field/BillingProfile.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::BillingProfile; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/BillingZone.pm b/lib/NGCP/Panel/Field/BillingZone.pm index 60258bdbfb..66a551e510 100644 --- a/lib/NGCP/Panel/Field/BillingZone.pm +++ b/lib/NGCP/Panel/Field/BillingZone.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::BillingZone; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/Contact.pm b/lib/NGCP/Panel/Field/Contact.pm index 9d32a55cc6..4babb3e77c 100644 --- a/lib/NGCP/Panel/Field/Contact.pm +++ b/lib/NGCP/Panel/Field/Contact.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Contact; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ContactNoReseller.pm b/lib/NGCP/Panel/Field/ContactNoReseller.pm index c1c89a3fb1..5fe0b01122 100644 --- a/lib/NGCP/Panel/Field/ContactNoReseller.pm +++ b/lib/NGCP/Panel/Field/ContactNoReseller.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ContactNoReseller; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ContactWithReseller.pm b/lib/NGCP/Panel/Field/ContactWithReseller.pm index d3ddf318dc..538521321f 100644 --- a/lib/NGCP/Panel/Field/ContactWithReseller.pm +++ b/lib/NGCP/Panel/Field/ContactWithReseller.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ContactWithReseller; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/Contract.pm b/lib/NGCP/Panel/Field/Contract.pm index 80131d537a..5bb7d8935a 100644 --- a/lib/NGCP/Panel/Field/Contract.pm +++ b/lib/NGCP/Panel/Field/Contract.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Contract; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ContractBalance.pm b/lib/NGCP/Panel/Field/ContractBalance.pm index fe2c7fea65..6a33ca7a55 100644 --- a/lib/NGCP/Panel/Field/ContractBalance.pm +++ b/lib/NGCP/Panel/Field/ContractBalance.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ContractBalance; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/Country.pm b/lib/NGCP/Panel/Field/Country.pm index 740fc9a687..93bb4e4c71 100644 --- a/lib/NGCP/Panel/Field/Country.pm +++ b/lib/NGCP/Panel/Field/Country.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Country; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/CustomerContract.pm b/lib/NGCP/Panel/Field/CustomerContract.pm index 8dcead4d61..37361076a0 100644 --- a/lib/NGCP/Panel/Field/CustomerContract.pm +++ b/lib/NGCP/Panel/Field/CustomerContract.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::CustomerContract; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/DataTable.pm b/lib/NGCP/Panel/Field/DataTable.pm index 3642328b69..1496a7376c 100644 --- a/lib/NGCP/Panel/Field/DataTable.pm +++ b/lib/NGCP/Panel/Field/DataTable.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::DataTable; -use Moose; use HTML::FormHandler::Moose; use Template; use JSON; diff --git a/lib/NGCP/Panel/Field/DatePicker.pm b/lib/NGCP/Panel/Field/DatePicker.pm index c75e45a347..eeb68bbe4e 100644 --- a/lib/NGCP/Panel/Field/DatePicker.pm +++ b/lib/NGCP/Panel/Field/DatePicker.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::DatePicker; -use Moose; use HTML::FormHandler::Moose; use Template; extends 'HTML::FormHandler::Field'; diff --git a/lib/NGCP/Panel/Field/DateTime.pm b/lib/NGCP/Panel/Field/DateTime.pm index 160dfcf8b8..5832413f82 100644 --- a/lib/NGCP/Panel/Field/DateTime.pm +++ b/lib/NGCP/Panel/Field/DateTime.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::DateTime; -use Moose; use HTML::FormHandler::Moose; use Sipwise::Base; extends 'HTML::FormHandler::Field::Text'; diff --git a/lib/NGCP/Panel/Field/Device.pm b/lib/NGCP/Panel/Field/Device.pm index 782e183b67..33f1e59bef 100644 --- a/lib/NGCP/Panel/Field/Device.pm +++ b/lib/NGCP/Panel/Field/Device.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Device; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/DeviceConfig.pm b/lib/NGCP/Panel/Field/DeviceConfig.pm index 1ccadbebe1..85dfe255e3 100644 --- a/lib/NGCP/Panel/Field/DeviceConfig.pm +++ b/lib/NGCP/Panel/Field/DeviceConfig.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::DeviceConfig; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/Domain.pm b/lib/NGCP/Panel/Field/Domain.pm index 5413817248..141cc99d17 100644 --- a/lib/NGCP/Panel/Field/Domain.pm +++ b/lib/NGCP/Panel/Field/Domain.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Domain; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/EmailList.pm b/lib/NGCP/Panel/Field/EmailList.pm index c7fc0f8188..c087688bd2 100644 --- a/lib/NGCP/Panel/Field/EmailList.pm +++ b/lib/NGCP/Panel/Field/EmailList.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::EmailList; -use Moose; use HTML::FormHandler::Moose; use Email::Valid; use Sipwise::Base; diff --git a/lib/NGCP/Panel/Field/EmailTemplate.pm b/lib/NGCP/Panel/Field/EmailTemplate.pm index 8aba9cfd11..8d669c254d 100644 --- a/lib/NGCP/Panel/Field/EmailTemplate.pm +++ b/lib/NGCP/Panel/Field/EmailTemplate.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::EmailTemplate; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/EmergencyMappingContainer.pm b/lib/NGCP/Panel/Field/EmergencyMappingContainer.pm index 2f5c9b6c72..d8ae35e39b 100644 --- a/lib/NGCP/Panel/Field/EmergencyMappingContainer.pm +++ b/lib/NGCP/Panel/Field/EmergencyMappingContainer.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::EmergencyMappingContainer; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/IPAddress.pm b/lib/NGCP/Panel/Field/IPAddress.pm index bbc4b3f929..11451b22fd 100644 --- a/lib/NGCP/Panel/Field/IPAddress.pm +++ b/lib/NGCP/Panel/Field/IPAddress.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::IPAddress; -use Moose; use HTML::FormHandler::Moose; use Data::Validate::IP qw(is_ipv4 is_ipv6); extends 'HTML::FormHandler::Field::Text'; diff --git a/lib/NGCP/Panel/Field/Identifier.pm b/lib/NGCP/Panel/Field/Identifier.pm index 1cf5066fae..4c433dd1d0 100644 --- a/lib/NGCP/Panel/Field/Identifier.pm +++ b/lib/NGCP/Panel/Field/Identifier.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Identifier; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Text'; diff --git a/lib/NGCP/Panel/Field/Interval.pm b/lib/NGCP/Panel/Field/Interval.pm index 4b4ab87968..0732cb68f2 100644 --- a/lib/NGCP/Panel/Field/Interval.pm +++ b/lib/NGCP/Panel/Field/Interval.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Interval; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/InvoiceTemplate.pm b/lib/NGCP/Panel/Field/InvoiceTemplate.pm index 4054576e79..22f9f382e7 100644 --- a/lib/NGCP/Panel/Field/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Field/InvoiceTemplate.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::InvoiceTemplate; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/LnpCarrier.pm b/lib/NGCP/Panel/Field/LnpCarrier.pm index b1e0186161..d1d248fc3d 100644 --- a/lib/NGCP/Panel/Field/LnpCarrier.pm +++ b/lib/NGCP/Panel/Field/LnpCarrier.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::LnpCarrier; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/MonthPicker.pm b/lib/NGCP/Panel/Field/MonthPicker.pm index 27c42d74c4..a2c248d0ee 100644 --- a/lib/NGCP/Panel/Field/MonthPicker.pm +++ b/lib/NGCP/Panel/Field/MonthPicker.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::MonthPicker; -use Moose; use HTML::FormHandler::Moose; use Template; extends 'HTML::FormHandler::Field'; diff --git a/lib/NGCP/Panel/Field/NumRangeAPI.pm b/lib/NGCP/Panel/Field/NumRangeAPI.pm index c96bac1371..121c55da4a 100644 --- a/lib/NGCP/Panel/Field/NumRangeAPI.pm +++ b/lib/NGCP/Panel/Field/NumRangeAPI.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::NumRangeAPI; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Text'; has 'min_start' => (isa => 'Int', default => 0, is => 'rw'); diff --git a/lib/NGCP/Panel/Field/NumberStatusSelect.pm b/lib/NGCP/Panel/Field/NumberStatusSelect.pm index d0bdfe2387..d66ca67707 100644 --- a/lib/NGCP/Panel/Field/NumberStatusSelect.pm +++ b/lib/NGCP/Panel/Field/NumberStatusSelect.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::NumberStatusSelect; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/PbxCustomerContract.pm b/lib/NGCP/Panel/Field/PbxCustomerContract.pm index cf351ca1c3..d830ea8f5d 100644 --- a/lib/NGCP/Panel/Field/PbxCustomerContract.pm +++ b/lib/NGCP/Panel/Field/PbxCustomerContract.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::PbxCustomerContract; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/PbxGroup.pm b/lib/NGCP/Panel/Field/PbxGroup.pm index 557af05f90..e58364f14a 100644 --- a/lib/NGCP/Panel/Field/PbxGroup.pm +++ b/lib/NGCP/Panel/Field/PbxGroup.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::PbxGroup; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/PbxGroupAPI.pm b/lib/NGCP/Panel/Field/PbxGroupAPI.pm index dbea453d50..05b73907d2 100644 --- a/lib/NGCP/Panel/Field/PbxGroupAPI.pm +++ b/lib/NGCP/Panel/Field/PbxGroupAPI.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::PbxGroupAPI; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field'; diff --git a/lib/NGCP/Panel/Field/PbxGroupMemberAPI.pm b/lib/NGCP/Panel/Field/PbxGroupMemberAPI.pm index d55a363f7a..c18eb72148 100644 --- a/lib/NGCP/Panel/Field/PbxGroupMemberAPI.pm +++ b/lib/NGCP/Panel/Field/PbxGroupMemberAPI.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::PbxGroupMemberAPI; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field'; diff --git a/lib/NGCP/Panel/Field/Product.pm b/lib/NGCP/Panel/Field/Product.pm index e5d9e800b3..915f7e20fb 100644 --- a/lib/NGCP/Panel/Field/Product.pm +++ b/lib/NGCP/Panel/Field/Product.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Product; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ProfileNetwork.pm b/lib/NGCP/Panel/Field/ProfileNetwork.pm index cdd955abac..9b957e9e4e 100644 --- a/lib/NGCP/Panel/Field/ProfileNetwork.pm +++ b/lib/NGCP/Panel/Field/ProfileNetwork.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ProfileNetwork; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ProfilePackage.pm b/lib/NGCP/Panel/Field/ProfilePackage.pm index 9274377d77..5035716df3 100644 --- a/lib/NGCP/Panel/Field/ProfilePackage.pm +++ b/lib/NGCP/Panel/Field/ProfilePackage.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ProfilePackage; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/Regexp.pm b/lib/NGCP/Panel/Field/Regexp.pm index fc82a700cb..96eeb2cfe5 100644 --- a/lib/NGCP/Panel/Field/Regexp.pm +++ b/lib/NGCP/Panel/Field/Regexp.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Regexp; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Text'; diff --git a/lib/NGCP/Panel/Field/Reseller.pm b/lib/NGCP/Panel/Field/Reseller.pm index 63c2140789..8a09253017 100644 --- a/lib/NGCP/Panel/Field/Reseller.pm +++ b/lib/NGCP/Panel/Field/Reseller.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Reseller; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ResellerContract.pm b/lib/NGCP/Panel/Field/ResellerContract.pm index be397ef32a..f4360064af 100644 --- a/lib/NGCP/Panel/Field/ResellerContract.pm +++ b/lib/NGCP/Panel/Field/ResellerContract.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::ResellerContract; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/ResellerStatusSelect.pm b/lib/NGCP/Panel/Field/ResellerStatusSelect.pm index fc418b9fb0..31734402bc 100644 --- a/lib/NGCP/Panel/Field/ResellerStatusSelect.pm +++ b/lib/NGCP/Panel/Field/ResellerStatusSelect.pm @@ -1,5 +1,5 @@ package NGCP::Panel::Field::ResellerStatusSelect; -use Moose; +use HTML::FormHandler::Moose; use Sipwise::Base; extends 'HTML::FormHandler::Field::Select'; diff --git a/lib/NGCP/Panel/Field/RewriteRuleAPI.pm b/lib/NGCP/Panel/Field/RewriteRuleAPI.pm index c825b15341..358f7b89cf 100644 --- a/lib/NGCP/Panel/Field/RewriteRuleAPI.pm +++ b/lib/NGCP/Panel/Field/RewriteRuleAPI.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::RewriteRuleAPI; -use Moose; use HTML::FormHandler::Moose; extends 'NGCP::Panel::Field::RewriteRule'; diff --git a/lib/NGCP/Panel/Field/SubscriberDestinationSet.pm b/lib/NGCP/Panel/Field/SubscriberDestinationSet.pm index eca26b3c8b..0c9419f277 100644 --- a/lib/NGCP/Panel/Field/SubscriberDestinationSet.pm +++ b/lib/NGCP/Panel/Field/SubscriberDestinationSet.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::SubscriberDestinationSet; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/SubscriberLockSelect.pm b/lib/NGCP/Panel/Field/SubscriberLockSelect.pm index 10d2b8fcfa..37bb9ebfb0 100644 --- a/lib/NGCP/Panel/Field/SubscriberLockSelect.pm +++ b/lib/NGCP/Panel/Field/SubscriberLockSelect.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::SubscriberLockSelect; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/SubscriberPbxGroup.pm b/lib/NGCP/Panel/Field/SubscriberPbxGroup.pm index 300ffceb99..eca4deab7f 100644 --- a/lib/NGCP/Panel/Field/SubscriberPbxGroup.pm +++ b/lib/NGCP/Panel/Field/SubscriberPbxGroup.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::SubscriberPbxGroup; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/SubscriberProfile.pm b/lib/NGCP/Panel/Field/SubscriberProfile.pm index 176cbb442f..b179f24b6c 100644 --- a/lib/NGCP/Panel/Field/SubscriberProfile.pm +++ b/lib/NGCP/Panel/Field/SubscriberProfile.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::SubscriberProfile; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/SubscriberProfileSet.pm b/lib/NGCP/Panel/Field/SubscriberProfileSet.pm index 94416afbee..1c58bb28eb 100644 --- a/lib/NGCP/Panel/Field/SubscriberProfileSet.pm +++ b/lib/NGCP/Panel/Field/SubscriberProfileSet.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::SubscriberProfileSet; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/SubscriberSourceSet.pm b/lib/NGCP/Panel/Field/SubscriberSourceSet.pm index b3a6aad9c8..b072c0bc9f 100644 --- a/lib/NGCP/Panel/Field/SubscriberSourceSet.pm +++ b/lib/NGCP/Panel/Field/SubscriberSourceSet.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::SubscriberSourceSet; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/SubscriberStatusSelect.pm b/lib/NGCP/Panel/Field/SubscriberStatusSelect.pm index 8ca1eeba1f..0d9e5317f9 100644 --- a/lib/NGCP/Panel/Field/SubscriberStatusSelect.pm +++ b/lib/NGCP/Panel/Field/SubscriberStatusSelect.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::SubscriberStatusSelect; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/SubscriberTimeSet.pm b/lib/NGCP/Panel/Field/SubscriberTimeSet.pm index 18d5e78c8f..028d90dfa4 100644 --- a/lib/NGCP/Panel/Field/SubscriberTimeSet.pm +++ b/lib/NGCP/Panel/Field/SubscriberTimeSet.pm @@ -1,6 +1,6 @@ package NGCP::Panel::Field::SubscriberTimeSet; -use Moose; use Sipwise::Base; +use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Select'; sub build_options { diff --git a/lib/NGCP/Panel/Field/TimezoneSelect.pm b/lib/NGCP/Panel/Field/TimezoneSelect.pm index 6cb347bba9..2f9007c864 100644 --- a/lib/NGCP/Panel/Field/TimezoneSelect.pm +++ b/lib/NGCP/Panel/Field/TimezoneSelect.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::TimezoneSelect; -use Moose; use HTML::FormHandler::Moose; use NGCP::Panel::Utils::DateTime; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Field/URI.pm b/lib/NGCP/Panel/Field/URI.pm index 00622afc79..0a6fb54558 100644 --- a/lib/NGCP/Panel/Field/URI.pm +++ b/lib/NGCP/Panel/Field/URI.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::URI; -use Moose; use Sipwise::Base; use HTML::FormHandler::Moose; diff --git a/lib/NGCP/Panel/Field/Voucher.pm b/lib/NGCP/Panel/Field/Voucher.pm index bee328f015..4752e9aeb0 100644 --- a/lib/NGCP/Panel/Field/Voucher.pm +++ b/lib/NGCP/Panel/Field/Voucher.pm @@ -1,5 +1,4 @@ package NGCP::Panel::Field::Voucher; -use Moose; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; diff --git a/lib/NGCP/Panel/Role/API/Domains.pm b/lib/NGCP/Panel/Role/API/Domains.pm index 8cac6db157..86ecc6101e 100644 --- a/lib/NGCP/Panel/Role/API/Domains.pm +++ b/lib/NGCP/Panel/Role/API/Domains.pm @@ -140,8 +140,7 @@ sub item_by_id { sub sip_domain_reload { my ($self, $c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my ($res) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my ($res) = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>domain.reload</methodName> diff --git a/lib/NGCP/Panel/Role/API/Preferences.pm b/lib/NGCP/Panel/Role/API/Preferences.pm index e56f5b030c..5bb58b43f5 100644 --- a/lib/NGCP/Panel/Role/API/Preferences.pm +++ b/lib/NGCP/Panel/Role/API/Preferences.pm @@ -15,7 +15,6 @@ use Safe::Isa qw($_isa); use Data::Validate::IP qw/is_ipv4 is_ipv6/; use NGCP::Panel::Utils::Preferences; use NGCP::Panel::Utils::Prosody; -use NGCP::Panel::Utils::XMLDispatcher; sub get_form { my ($self, $c) = @_; diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Grandstream.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Grandstream.pm index 6255187528..bc00731451 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Grandstream.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Grandstream.pm @@ -53,19 +53,19 @@ sub unregister_content { return $self->{unregister_content}; } -override 'parse_rpc_response_page' => sub { +around 'parse_rpc_response_page' => sub { my($self, $page) = @_; my $res = JSON::from_json($page); return $res; }; -override 'parse_rpc_response' => sub { +around 'parse_rpc_response' => sub { my($self,$rpc_response) = @_; return $rpc_response; }; #Todo: unify it with snome and vendor version somehow and move to VendorRPC.pm -override 'extract_response_description' => sub { +around 'extract_response_description' => sub { my($self,$rpc_value) = @_; my $res = ''; diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm index c85c9f6aee..dae5ad2a9e 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm @@ -1,7 +1,7 @@ package NGCP::Panel::Utils::DeviceBootstrap::Panasonic; use strict; -use Moose; +use Moo; use Data::Dumper; extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorRPC'; @@ -44,7 +44,7 @@ sub unregister_content { return $self->{unregister_content}; } -override 'process_bootstrap_uri' => sub { +around 'process_bootstrap_uri' => sub { my($self,$uri) = @_; $uri = super($uri); $uri = $self->bootstrap_uri_mac($uri); diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Polycom.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Polycom.pm index c972c10a08..f91c17df5e 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Polycom.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Polycom.pm @@ -4,13 +4,14 @@ use strict; use URI::Escape; use XML::Mini::Document;; use Data::Dumper; -use Moose; +use Moo; +use Types::Standard qw(Str); extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorRPC'; has 'register_subscriber_content' => ( is => 'rw', - isa => 'Str', + isa => Str, accessor => '_register_subscriber_content', ); sub rpc_server_params{ @@ -81,14 +82,14 @@ sub unregister_content { </request>"; return $self->{unregister_content}; } -override 'parse_rpc_response_page' => sub { +around 'parse_rpc_response_page' => sub { my($self, $page) = @_; my $xmlDoc = XML::Mini::Document->new(); $xmlDoc->parse($page); my $ref = $xmlDoc->toHash(); return $ref; }; -override 'parse_rpc_response' => sub { +around 'parse_rpc_response' => sub { my($self, $rpc_response) = @_; my $c = $self->params->{c}; my $ret = 0; diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm index a5f89e9157..2cd2b45c32 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm @@ -1,7 +1,7 @@ package NGCP::Panel::Utils::DeviceBootstrap::Snom; use strict; -use Moose; +use Moo; use Data::Dumper; extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorRPC'; @@ -50,7 +50,7 @@ sub unregister_content { </methodCall>"; return $self->{unregister_content}; } -override 'extract_response_description' => sub { +around 'extract_response_description' => sub { my($self,$rpc_value) = @_; my $c = $self->params->{c}; my $res = ''; @@ -70,7 +70,7 @@ override 'extract_response_description' => sub { return $res; }; -override 'process_bootstrap_uri' => sub { +around 'process_bootstrap_uri' => sub { my($self,$uri) = @_; $uri = super($uri); $uri = $self->bootstrap_uri_mac($uri); @@ -78,7 +78,7 @@ override 'process_bootstrap_uri' => sub { return $self->content_params->{uri}; }; -override 'bootstrap_uri_mac' => sub { +around 'bootstrap_uri_mac' => sub { my($self, $uri) = @_; if ($uri !~/\{mac\}$/){ if ($uri !~/\/$/){ diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm index dbbb2088a4..57b4b253d0 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm @@ -7,29 +7,30 @@ use Net::HTTPS::Any qw/https_post/; use RPC::XML::ParserFactory 'XML::LibXML'; use RPC::XML; use Data::Dumper; -use Moose; +use Moo; +use Types::Standard qw(HashRef Str); has 'params' => ( is => 'rw', - isa => 'HashRef', + isa => HashRef, ); has 'content_params' => ( is => 'rw', - isa => 'HashRef', + isa => HashRef, ); has 'rpc_server_params' => ( is => 'rw', - isa => 'HashRef', + isa => HashRef, accessor => '_rpc_server_params', ); has 'register_content' => ( is => 'rw', - isa => 'Str', + isa => Str, accessor => '_register_content', ); has 'unregister_content' => ( is => 'rw', - isa => 'Str', + isa => Str, accessor => '_unregister_content', ); diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Yealink.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Yealink.pm index f53200a212..b9028ff635 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Yealink.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Yealink.pm @@ -1,13 +1,14 @@ package NGCP::Panel::Utils::DeviceBootstrap::Yealink; use strict; -use Moose; +use Moo; +use Types::Standard qw(Str); use Digest::MD5 qw/md5_hex/; extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorRPC'; has 'register_model_content' => ( is => 'rw', - isa => 'Str', + isa => Str, accessor => '_register_model_content', ); sub rpc_server_params{ @@ -74,7 +75,7 @@ sub register_model_content { return $self->{register_model_content}; } -override 'process_bootstrap_uri' => sub { +around 'process_bootstrap_uri' => sub { my($self,$uri) = @_; $uri = super($uri); $self->content_params->{uri} = $uri; diff --git a/lib/NGCP/Panel/Utils/Kamailio.pm b/lib/NGCP/Panel/Utils/Kamailio.pm index 209e08fe81..1c9b17817a 100644 --- a/lib/NGCP/Panel/Utils/Kamailio.pm +++ b/lib/NGCP/Panel/Utils/Kamailio.pm @@ -9,8 +9,7 @@ sub delete_location_contact { my ($c, $prov_subscriber, $contact) = @_; my $aor = $prov_subscriber->username . '@' . $prov_subscriber->domain->domain; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>ul.rm_contact</methodName> @@ -28,8 +27,7 @@ sub delete_location { my ($c, $prov_subscriber) = @_; my $aor = $prov_subscriber->username . '@' . $prov_subscriber->domain->domain; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>ul.rm</methodName> @@ -54,8 +52,7 @@ sub create_location { } $flags //= 0; $cflags //= 0; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>ul.add</methodName> @@ -77,8 +74,7 @@ EOF sub flush { my ($c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>ul.flush</methodName> @@ -90,8 +86,7 @@ EOF sub trusted_reload { my ($c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my ($ret) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my ($ret) = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>permissions.trustedReload</methodName> diff --git a/lib/NGCP/Panel/Utils/Peering.pm b/lib/NGCP/Panel/Utils/Peering.pm index 75767862e8..fb1432682f 100644 --- a/lib/NGCP/Panel/Utils/Peering.pm +++ b/lib/NGCP/Panel/Utils/Peering.pm @@ -7,8 +7,7 @@ use warnings; sub _sip_lcr_reload { my(%params) = @_; my($c) = @params{qw/c/}; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>lcr.reload</methodName> @@ -21,8 +20,7 @@ EOF sub _sip_dispatcher_reload { my ($self, $c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my ($res) = $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + my ($res) = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>dispatcher.reload</methodName> diff --git a/lib/NGCP/Panel/Utils/Rewrite.pm b/lib/NGCP/Panel/Utils/Rewrite.pm index 7e9b166268..8116828f23 100644 --- a/lib/NGCP/Panel/Utils/Rewrite.pm +++ b/lib/NGCP/Panel/Utils/Rewrite.pm @@ -7,8 +7,7 @@ use NGCP::Panel::Utils::XMLDispatcher; sub sip_dialplan_reload { my ($c) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF ); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, <<EOF ); <?xml version="1.0" ?> <methodCall> <methodName>dialplan.reload</methodName> diff --git a/lib/NGCP/Panel/Utils/Security.pm b/lib/NGCP/Panel/Utils/Security.pm index f2234aaa5e..46fe4ce666 100644 --- a/lib/NGCP/Panel/Utils/Security.pm +++ b/lib/NGCP/Panel/Utils/Security.pm @@ -8,7 +8,6 @@ use NGCP::Panel::Utils::DateTime; sub list_banned_ips { my ( $c ) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; my $xml_parser = XML::LibXML->new(); my $ip_xml = <<'EOF'; @@ -21,7 +20,7 @@ sub list_banned_ips { </methodCall> EOF - my $ip_res = $dispatcher->dispatch($c, "loadbalancer", 1, 1, $ip_xml); + my $ip_res = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "loadbalancer", 1, 1, $ip_xml); my @ips = (); for my $host (grep {$$_[1]} @$ip_res) { @@ -40,7 +39,6 @@ EOF sub list_banned_users { my ( $c, %params ) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; my $xml_parser = XML::LibXML->new(); my $user_xml = <<'EOF'; @@ -53,7 +51,7 @@ sub list_banned_users { </methodCall> EOF - my $user_res = $dispatcher->dispatch($c, "loadbalancer", 1, 1, $user_xml); + my $user_res = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "loadbalancer", 1, 1, $user_xml); my @users = (); my $usr = {}; for my $host (grep {$$_[1]} @$user_res) { @@ -97,7 +95,6 @@ sub ip_unban { my ( $c, $ip ) = @_; my $decoder = URI::Encode->new; $ip = $decoder->decode($ip); - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; my $xml = <<"EOF"; <?xml version="1.0" ?> @@ -110,14 +107,13 @@ sub ip_unban { </methodCall> EOF - $dispatcher->dispatch($c, "loadbalancer", 1, 1, $xml); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "loadbalancer", 1, 1, $xml); } sub user_unban { my ( $c, $user ) = @_; my $decoder = URI::Encode->new; $user = $decoder->decode($user); - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; my @keys = ($user.'::auth_count', $user.'::last_auth'); foreach my $key (@keys) { @@ -132,7 +128,7 @@ sub user_unban { </methodCall> EOF - $dispatcher->dispatch($c, "loadbalancer", 1, 1, $xml); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "loadbalancer", 1, 1, $xml); } } diff --git a/lib/NGCP/Panel/Utils/Sems.pm b/lib/NGCP/Panel/Utils/Sems.pm index ac14b474fa..e1f79b2400 100644 --- a/lib/NGCP/Panel/Utils/Sems.pm +++ b/lib/NGCP/Panel/Utils/Sems.pm @@ -37,8 +37,6 @@ sub create_peer_registration { $all = 0; } - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $c->log->debug("creating peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'"); my $sid = $prov_subscriber->id; @@ -52,7 +50,7 @@ sub create_peer_registration { $transport = $outbound_sock->{transport}; } - my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", $all, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.createRegistration</methodName> @@ -75,7 +73,7 @@ EOF # remove reg from successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($c, $$ret[0], 1, 1, <<EOF); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, $$ret[0], 1, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.removeRegistration</methodName> @@ -104,8 +102,6 @@ sub update_peer_registration { $all = 0; } - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $c->log->debug("trying to update peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'"); my $sid = $prov_subscriber->id; @@ -126,7 +122,7 @@ sub update_peer_registration { $c->log->debug("+++++++++++++++++++ uuid=$uuid"); $c->log->debug("+++++++++++++++++++ contact=$contact"); - my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", $all, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.updateRegistration</methodName> @@ -149,7 +145,7 @@ EOF # undo update on successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($c, $$ret[0], 1, 1, <<EOF); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, $$ret[0], 1, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.updateRegistration</methodName> @@ -182,15 +178,13 @@ sub delete_peer_registration { $all = 0; } - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $c->log->debug("trying to delete peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'"); my $sid = $prov_subscriber->id; my $uuid = $prov_subscriber->uuid; my $contact = $c->config->{sip}->{lb_ext}; - my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", $all, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.removeRegistration</methodName> @@ -209,7 +203,7 @@ EOF # remove reg from successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($c, $ret[0], 1, 1, <<EOF); + NGCP::Panel::Utils::XMLDispatcher::dispatch($c, $ret[0], 1, 1, <<EOF); <?xml version="1.0"?> <methodCall> <methodName>db_reg_agent.createRegistration</methodName> @@ -252,9 +246,7 @@ sub clear_audio_cache { sub _clear_audio_cache_service { my ($c, $service, $sound_set_id, $handle_name) = @_; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - - my @ret = $dispatcher->dispatch($c, $service, 1, 1, <<EOF ); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, $service, 1, 1, <<EOF ); <?xml version="1.0"?> <methodCall> <methodName>postDSMEvent</methodName> @@ -310,8 +302,7 @@ sub dial_out { my $caller_domain = $prov_subscriber->domain->domain; my $caller_password = $prov_subscriber->password; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch($c, "appserver", 0, 1, <<EOF ); + my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", 0, 1, <<EOF ); <?xml version="1.0"?> <methodCall> <methodName>dial_auth_b2b</methodName> @@ -348,9 +339,8 @@ sub party_call_control { @{$data}{qw(caller callee callid status token)}; my $service = 'appserver'; - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my @ret = $dispatcher->dispatch($c, $service, 1, 1, <<EOF ); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, $service, 1, 1, <<EOF ); <?xml version="1.0"?> <methodCall> <methodName>postDSMEvent</methodName> diff --git a/lib/NGCP/Panel/Utils/XMLDispatcher.pm b/lib/NGCP/Panel/Utils/XMLDispatcher.pm index 1d5cf45e58..3573127fb1 100644 --- a/lib/NGCP/Panel/Utils/XMLDispatcher.pm +++ b/lib/NGCP/Panel/Utils/XMLDispatcher.pm @@ -1,22 +1,13 @@ package NGCP::Panel::Utils::XMLDispatcher; use Sipwise::Base; -use NGCP::Schema; use Net::HTTP; use Errno; -use Moose; - -has 'schema' => ( - is => 'rw', - isa => 'DBIx::Class::Schema', - default => sub { return NGCP::Schema->connect() }, -); - sub dispatch { - my ($self, $c, $target, $all, $sync, $body) = @_; + my ($c, $target, $all, $sync, $body, $schema) = @_; - my $schema = $self->schema; + $schema //= $c->model('DB'); $c->log->info("dispatching to target $target, all=$all, sync=$sync"); $c->log->debug("dispatching body $body"); @@ -87,14 +78,14 @@ sub dispatch { next; } - $self->_queue(join("::", "%TG%", $meth, $ip, $port, $path, $hostid), $body); + _queue(join("::", "%TG%", $meth, $ip, $port, $path, $hostid), $body, $schema); push(@ret, [$hostid, -1]); } if (!$all) { # failure on all hosts $sync and return; - $self->_queue($target, $body); + _queue($target, $body, $schema); return [$target, -1]; } @@ -102,9 +93,9 @@ sub dispatch { } sub _queue { - my ($self, $target, $body) = @_; + my ($target, $body, $schema) = @_; - $self->schema->resultset('xmlqueue')->create({ + $schema->resultset('xmlqueue')->create({ target => $target, body => $body, ctime => \"unix_timestamp()", @@ -113,22 +104,22 @@ sub _queue { } sub queuerunner { - my ($self) = @_; + my ($schema) = @_; for (;; sleep(1)) { - my $row = $self->_dequeue; + my $row = _dequeue($schema); $row or next; - my @ret = $self->dispatch($row->target, 0, 1, $row->body); + my @ret = dispatch(undef, $row->target, 0, 1, $row->body, $schema); - @ret and $self->_unqueue($row->id); + @ret and _unqueue($row->id, $schema); } } sub _dequeue { - my ($self) = @_; + my ($schema) = @_; - my $row = $self->schema->resultset('xmlqueue')->search({ + my $row = $schema->resultset('xmlqueue')->search({ next_try => {'<=' => \'unix_timestamp()'}, },{ order_by => 'id' @@ -145,13 +136,11 @@ sub _dequeue { } sub _unqueue { - my ($self, $id) = @_; + my ($id, $schema) = @_; - $self->schema->resultset('xmlqueue')->find($id)->delete; + $schema->resultset('xmlqueue')->find($id)->delete; } -no Moose; - 1; =head1 NAME diff --git a/tools_bin/ngcp-emergency-mode b/tools_bin/ngcp-emergency-mode index cd5492c595..e719b377c4 100755 --- a/tools_bin/ngcp-emergency-mode +++ b/tools_bin/ngcp-emergency-mode @@ -233,11 +233,10 @@ foreach my $redis_host(@redis_hosts) { } } - my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; my $c = DummyController->new; foreach my $tag(@nonpriotags) { DEBUG "Tearing down normal call tag $tag for call id $tag2cid{$tag}..."; - my @ret = $dispatcher->dispatch($c, "appserver", 1, 1, <<EOF); + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", 1, 1, <<EOF); <?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>di</methodName>