protected Response migrateIncomingPhoneNumbers(String targetAccountSid,
            MultivaluedMap<String, String> data,
            MediaType responseType,
            UserIdentityContext userIdentityContext) {
        Account effectiveAccount = userIdentityContext.getEffectiveAccount();
        permissionEvaluator.secure(effectiveAccount,
                "RestComm:Modify:IncomingPhoneNumbers",
                userIdentityContext);
        try {
            Account targetAccount = accountsDao.getAccount(targetAccountSid);
            // this is to avoid if mistakenly provided super admin account as targetAccountSid
            // if this check is not in place and someone mistakenly provided super admin
            // then all accounts and sub account in platform will be impacted
            if (targetAccount == null) {
                return status(NOT_FOUND).entity("Account not found").build();
            }
            if (targetAccount.getParentSid() == null) {
                return status(BAD_REQUEST).entity("Super Admin account numbers can not be migrated. Please provide a valid account sid").build();
            } else {
                String organizationSidStr = data.getFirst("OrganizationSid");
                if (organizationSidStr == null) {
                    return status(BAD_REQUEST).entity("OrganizationSid cannot be null").build();
                }
                Sid organizationSid = null;
                try {
                    organizationSid = new Sid(organizationSidStr);
                } catch (IllegalArgumentException iae) {
                    return status(BAD_REQUEST).entity("OrganizationSid is not valid").build();
                }
                Organization destinationOrganization = organizationsDao.getOrganization(organizationSid);
                if (destinationOrganization == null) {
                    return status(NOT_FOUND).entity("Destination organization not found").build();
                }
                migrateNumbersFromAccountTree(targetAccount, destinationOrganization);
                return status(OK).build();
            }
        } catch (Exception e) {
            logger.error("Exception while performing migrateIncomingPhoneNumbers: ", e);
            return status(INTERNAL_SERVER_ERROR).build();
        }
    }
protected Response migrateIncomingPhoneNumbers ( String targetAccountSid , MultivaluedMap < String , String > data , MediaType responseType , UserIdentityContext userIdentityContext ) { Account effectiveAccount = userIdentityContext . getEffectiveAccount ( ) ; permissionEvaluator . secure ( effectiveAccount , "RestComm:Modify:IncomingPhoneNumbers" , userIdentityContext ) ; try { Account targetAccount = accountsDao . getAccount ( targetAccountSid ) ; if ( targetAccount == null ) { return status ( NOT_FOUND ) . entity ( "Account not found" ) . build ( ) ; } if ( targetAccount . getParentSid ( ) == null ) { return status ( BAD_REQUEST ) . entity ( "Super Admin account numbers can not be migrated. Please provide a valid account sid" ) . build ( ) ; } else { String organizationSidStr = data . getFirst ( "OrganizationSid" ) ; if ( organizationSidStr == null ) { return status ( BAD_REQUEST ) . entity ( "OrganizationSid cannot be null" ) . build ( ) ; } Sid organizationSid = null ; try { organizationSid = new Sid ( organizationSidStr ) ; } catch ( IllegalArgumentException iae ) { return status ( BAD_REQUEST ) . entity ( "OrganizationSid is not valid" ) . build ( ) ; } Organization destinationOrganization = organizationsDao . getOrganization ( organizationSid ) ; if ( destinationOrganization == null ) { return status ( NOT_FOUND ) . entity ( "Destination organization not found" ) . build ( ) ; } migrateNumbersFromAccountTree ( targetAccount , destinationOrganization ) ; return status ( OK ) . build ( ) ; } } catch ( Exception e ) { logger . error ( "Exception while performing migrateIncomingPhoneNumbers: " , e ) ; return status ( INTERNAL_SERVER_ERROR ) . build ( ) ; } }
@param targetAccountSid
@param data
@param responseType
@return