Creates an exception from an client id and version.
@param clientId the client id
@param version the client version
@return the exception
517513
public static final ClientVersionNotFoundException clientVersionNotFoundException(String clientId, String version) {
        return new ClientVersionNotFoundException(Messages.i18n.format("clientVersionDoesNotExist", clientId, version)); //$NON-NLS-1$
    }
563203
protected Api getApi(String orgId, String apiId, String version) throws SQLException {
        String apiIdx = getApiId(orgId, apiId, version);
        Api api;
        synchronized (mutex) {
            api = apiCache.get(apiIdx);
        }

        if (api == null) {
            api = super.getApiInternal(orgId, apiId, version);
            synchronized (mutex) {
                if (api != null) {
                    apiCache.put(apiIdx, api);
                }
            }
        }

        return api;
    }
121624
public void setClientId(String clientId) throws HelloSignException {
        if (clientId == null) {
            throw new HelloSignException("Client ID cannot be null");
        }
        this.clientId = clientId.trim();
    }
774004
public static Version parseVersion(String version) {
		if (!Strings.isNullOrEmpty(version)) {
			try {
				return Version.parseVersion(version);
			} catch (Throwable exception) {
				//
			}
		}
		return null;
	}
982074
@Override
	public final void setClientID(String clientID) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
    	{
	        super.setClientID(clientID);
	        try
	        {
	        	ClientIDRegistry.getInstance().register(clientID);
	        }
	        catch (JMSException e)
	        {
	        	this.clientID = null; // Clear client ID
	        	throw e;
	        }
    	}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
24728
public static AddonId from(String name, Version version, Version apiVersion)
   {
      Assert.notNull(name, "Name cannot be null.");
      if (name.trim().isEmpty())
         throw new IllegalArgumentException("Name cannot be empty.");
      Assert.notNull(version, "Version cannot be null.");
      if (version.toString().trim().isEmpty())
         throw new IllegalArgumentException("Version cannot be empty.");

      AddonId id = new AddonId();
      id.name = name;
      id.version = version;
      if (apiVersion == null || apiVersion.toString().trim().isEmpty())
         id.apiVersion = EmptyVersion.getInstance();
      else
         id.apiVersion = apiVersion;
      return id;
   }
1342758
public static Bridge get(final BandwidthClient client, final String id) throws Exception {
        assert(client != null);
    	final String bridgesUri =  client.getUserResourceInstanceUri(BandwidthConstants.BRIDGES_URI_PATH, id);
        final JSONObject jsonObject = toJSONObject(client.get(bridgesUri, null));
        return new Bridge(client, jsonObject);
        
    }
384389
public static final ApiVersionNotFoundException apiVersionNotFoundException(String apiId, String version) {
        return new ApiVersionNotFoundException(Messages.i18n.format("ApiVersionDoesNotExist", apiId, version)); //$NON-NLS-1$
    }
711605
public static Application get(final String id) throws Exception {
        assert(id != null);

        final BandwidthClient client = BandwidthClient.getInstance();
        return Application.get(client ,id);
    }
506927
public static Recording get(final BandwidthClient client, final String id) throws Exception {
    	
        final String recordingsUri = client.getUserResourceUri(BandwidthConstants.RECORDINGS_URI_PATH);
        final String uri = StringUtils.join(new String[]{
                recordingsUri,
                id
        }, '/');
        final JSONObject jsonObject = toJSONObject(client.get(uri, null));
        return new Recording(client, recordingsUri, jsonObject);
    }
687983
public static Application get(final BandwidthClient client, final String id) throws Exception {
        assert(id != null);
        final String applicationUri = client.getUserResourceInstanceUri(BandwidthConstants.APPLICATIONS_URI_PATH, id);
        final JSONObject applicationObj = toJSONObject( client.get(applicationUri, null) );
        
        final Application application = new Application(client, applicationObj);
        return application;
    }
1251424
public Exception getException(int index) {
        Exception exception = null;

        Message message = getError(index);
        if (message != null) {
            if (message instanceof ExceptionMessage) {
                exception = ((ExceptionMessage) message).getCause();
            }
            else if (message instanceof SyntaxErrorMessage) {
                exception = ((SyntaxErrorMessage) message).getCause();
            }
        }
        return exception;
    }
977526
private void unregisterClient(ActionBean action) throws ActionException {
        if (!securityContext.hasPermission(PermissionType.clientAdmin, action.getOrganizationId()))
            throw ExceptionFactory.notAuthorizedException();

        ClientVersionBean versionBean;
        List<ContractSummaryBean> contractBeans;
        try {
            versionBean = orgs.getClientVersion(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion());
        } catch (ClientVersionNotFoundException e) {
            throw ExceptionFactory.actionException(Messages.i18n.format("ClientNotFound")); //$NON-NLS-1$
        }
        try {
            contractBeans = query.getClientContracts(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion());
        } catch (StorageException e) {
            throw ExceptionFactory.actionException(Messages.i18n.format("ClientNotFound"), e); //$NON-NLS-1$
        }

        // Validate that it's ok to perform this action - client must be Ready.
        if (versionBean.getStatus() != ClientStatus.Registered) {
            throw ExceptionFactory.actionException(Messages.i18n.format("InvalidClientStatus")); //$NON-NLS-1$
        }

        Client client = new Client();
        client.setOrganizationId(versionBean.getClient().getOrganization().getId());
        client.setClientId(versionBean.getClient().getId());
        client.setVersion(versionBean.getVersion());

        // Next, unregister the client from *all* relevant gateways.  This is done by
        // looking up all referenced APIs and getting the gateway information for them.
        // Each of those gateways must be told about the client.
        try {
            storage.beginTx();
            Map<String, IGatewayLink> links = new HashMap<>();
            for (ContractSummaryBean contractBean : contractBeans) {
                ApiVersionBean svb = storage.getApiVersion(contractBean.getApiOrganizationId(),
                        contractBean.getApiId(), contractBean.getApiVersion());
                Set<ApiGatewayBean> gateways = svb.getGateways();
                if (gateways == null) {
                    throw new PublishingException("No gateways specified for API: " + svb.getApi().getName()); //$NON-NLS-1$
                }
                for (ApiGatewayBean apiGatewayBean : gateways) {
                    if (!links.containsKey(apiGatewayBean.getGatewayId())) {
                        IGatewayLink gatewayLink = createGatewayLink(apiGatewayBean.getGatewayId());
                        links.put(apiGatewayBean.getGatewayId(), gatewayLink);
                    }
                }
            }
            storage.commitTx();
            for (IGatewayLink gatewayLink : links.values()) {
                gatewayLink.unregisterClient(client);
                gatewayLink.close();
            }
        } catch (Exception e) {
            storage.rollbackTx();
            throw ExceptionFactory.actionException(Messages.i18n.format("UnregisterError"), e); //$NON-NLS-1$
        }

        versionBean.setStatus(ClientStatus.Retired);
        versionBean.setRetiredOn(new Date());

        try {
            storage.beginTx();
            storage.updateClientVersion(versionBean);
            storage.createAuditEntry(AuditUtils.clientUnregistered(versionBean, securityContext));
            storage.commitTx();
        } catch (Exception e) {
            storage.rollbackTx();
            throw ExceptionFactory.actionException(Messages.i18n.format("UnregisterError"), e); //$NON-NLS-1$
        }

        log.debug(String.format("Successfully registered Client %s on specified gateways: %s", //$NON-NLS-1$
                versionBean.getClient().getName(), versionBean.getClient()));
    }
14873
private void addClientId(String clientId) {
        //Sometimes the client Id will be null. For instance in the case QueueConnectionFactory, there is no default client Id specified in metatype.xml.
        if (clientId == null)
            return; //do nothing

        ConcurrentHashMap<String, Integer> clientIdTable = JmsFactoryFactoryImpl.getClientIdTable();

        if (clientIdTable.containsKey(clientId)) {
            clientIdTable.put(clientId, clientIdTable.get(clientId).intValue() + 1);
        } else {
            clientIdTable.put(clientId, 1);
        }

    }
1244934
public static Control createInstance(ControlVersion version)
    {
        switch (version)
        {
            case _0_24:
                return new Control0_24();

            case _0_25:
                return new Control0_25();

            default:
                throw new IllegalArgumentException("Unknown control version: " + version);
        }
    }
183525
public static boolean isClientAbortException(IOException e) {
		
		String exceptionClassName = e.getClass().getName();
		return exceptionClassName.endsWith(".EofException")
				|| exceptionClassName.endsWith(".ClientAbortException");
	}
942471
public ClientBuilderForConnector forServer(String uri, @Nullable String version) {
        configBuilder.withDockerHost(URI.create(uri).toString())
                .withApiVersion(version);
        return this;
    }