@Override
    public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException {
        final String sourceMethod = "unregisterMBean";
        checkConnection();
        if (name == null)
            throw new RuntimeOperationsException(new IllegalArgumentException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.OBJECT_NAME_NULL)));
        else if (name.isPattern())
            throw new InstanceNotFoundException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.OBJECT_NAME_PATTERN, name));

        URL mbeanURL = null;
        HttpsURLConnection connection = null;
        try {
            // Get URL for MBean
            mbeanURL = getMBeanURL(name);

            // Get connection to server
            connection = getConnection(mbeanURL, HttpMethod.DELETE);
        } catch (IOException io) {
            throw getRequestErrorException(sourceMethod, io, mbeanURL);
        }

        // Check response code from server
        int responseCode = 0;
        try {
            responseCode = connection.getResponseCode();
        } catch (ConnectException ce) {
            recoverConnection(ce);
            // Server is down; not a client bug
            throw ce;
        }

        switch (responseCode) {
            case HttpURLConnection.HTTP_NO_CONTENT:
                // Clean up cached URLs
                purgeMBeanURLs(name);
                return;
            case HttpURLConnection.HTTP_BAD_REQUEST:
            case HttpURLConnection.HTTP_INTERNAL_ERROR:
                try {
                    // Server response should be a serialized Throwable
                    throw getServerThrowable(sourceMethod, connection);
                } catch (MBeanRegistrationException mbr) {
                    throw mbr;
                } catch (InstanceNotFoundException inf) {
                    throw inf;
                } catch (IOException io) {
                    throw io;
                } catch (Throwable t) {
                    throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.UNEXPECTED_SERVER_THROWABLE), t);
                }
            case HttpURLConnection.HTTP_UNAUTHORIZED:
            case HttpURLConnection.HTTP_FORBIDDEN:
                throw getBadCredentialsException(responseCode, connection);
            case HttpURLConnection.HTTP_GONE:
            case HttpURLConnection.HTTP_NOT_FOUND:
                IOException ioe = getResponseCodeErrorException(sourceMethod, responseCode, connection);
                recoverConnection(ioe);
                throw ioe;
            default:
                throw getResponseCodeErrorException(sourceMethod, responseCode, connection);
        }
    }
@ Override public void unregisterMBean ( ObjectName name ) throws InstanceNotFoundException , MBeanRegistrationException , IOException { final String sourceMethod = "unregisterMBean" ; checkConnection ( ) ; if ( name == null ) throw new RuntimeOperationsException ( new IllegalArgumentException ( RESTClientMessagesUtil . getMessage ( RESTClientMessagesUtil . OBJECT_NAME_NULL ) ) ) ; else if ( name . isPattern ( ) ) throw new InstanceNotFoundException ( RESTClientMessagesUtil . getMessage ( RESTClientMessagesUtil . OBJECT_NAME_PATTERN , name ) ) ; URL mbeanURL = null ; HttpsURLConnection connection = null ; try { mbeanURL = getMBeanURL ( name ) ; connection = getConnection ( mbeanURL , HttpMethod . DELETE ) ; } catch ( IOException io ) { throw getRequestErrorException ( sourceMethod , io , mbeanURL ) ; } int responseCode = 0 ; try { responseCode = connection . getResponseCode ( ) ; } catch ( ConnectException ce ) { recoverConnection ( ce ) ; throw ce ; } switch ( responseCode ) { case HttpURLConnection . HTTP_NO_CONTENT : purgeMBeanURLs ( name ) ; return ; case HttpURLConnection . HTTP_BAD_REQUEST : case HttpURLConnection . HTTP_INTERNAL_ERROR : try { throw getServerThrowable ( sourceMethod , connection ) ; } catch ( MBeanRegistrationException mbr ) { throw mbr ; } catch ( InstanceNotFoundException inf ) { throw inf ; } catch ( IOException io ) { throw io ; } catch ( Throwable t ) { throw new IOException ( RESTClientMessagesUtil . getMessage ( RESTClientMessagesUtil . UNEXPECTED_SERVER_THROWABLE ) , t ) ; } case HttpURLConnection . HTTP_UNAUTHORIZED : case HttpURLConnection . HTTP_FORBIDDEN : throw getBadCredentialsException ( responseCode , connection ) ; case HttpURLConnection . HTTP_GONE : case HttpURLConnection . HTTP_NOT_FOUND : IOException ioe = getResponseCodeErrorException ( sourceMethod , responseCode , connection ) ; recoverConnection ( ioe ) ; throw ioe ; default : throw getResponseCodeErrorException ( sourceMethod , responseCode , connection ) ; } }
{@inheritDoc}