List of usage examples for javax.naming ConfigurationException ConfigurationException
public ConfigurationException(String explanation)
From source file:com.wso2telco.proxy.util.DBUtils.java
/** * Get operators' MSISDN header properties. * * @return operators' MSISDN header properties map. * @throws SQLException on errors//from w w w . ja va 2 s .co m * @throws NamingException on errors */ public static Map<String, List<MSISDNHeader>> getOperatorsMSISDNHeaderProperties() throws SQLException, NamingException { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; Map<String, List<MSISDNHeader>> operatorsMSISDNHeadersList = new HashMap<String, List<MSISDNHeader>>(); String queryToGetOperatorProperty = "SELECT DISTINCT operatorId, LOWER(operatorName) AS operatorName FROM " + "operators_msisdn_headers_properties prop LEFT JOIN operators op ON op.ID=prop.operatorId"; try { connection = getConnectDBConnection(); preparedStatement = connection.prepareStatement(queryToGetOperatorProperty); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { int operatorId = resultSet.getInt(AuthProxyConstants.OPERATOR_ID); String operatorName = resultSet.getString(AuthProxyConstants.OPERATOR_NAME); //Get msisdn properties of the operator. List<MSISDNHeader> msisdnHeaderList = getMSISDNPropertiesByOperatorId(operatorId, operatorName); operatorsMSISDNHeadersList.put(operatorName, msisdnHeaderList); } } catch (SQLException e) { throw new SQLException("Error occurred while retrieving operator MSISDN properties of operators : ", e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection, resultSet); } return operatorsMSISDNHeadersList; }
From source file:com.cloud.baremetal.networkservice.BaremetalKickStartPxeResource.java
private Answer execute(PrepareKickstartPxeServerCommand cmd) { com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); try {/*from w w w . j ava 2 s .c o m*/ sshConnection.connect(null, 60000, 60000); if (!sshConnection.authenticateWithPassword(_username, _password)) { s_logger.debug("SSH Failed to authenticate"); throw new ConfigurationException( String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password)); } String copyTo = String.format("%s/%s", _tftpDir, cmd.getTemplateUuid()); String script = String.format("python /usr/bin/prepare_kickstart_kernel_initrd.py %s %s %s", cmd.getKernel(), cmd.getInitrd(), copyTo); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); } String kernelPath = String.format("%s/vmlinuz", cmd.getTemplateUuid()); String initrdPath = String.format("%s/initrd.img", cmd.getTemplateUuid()); script = String.format("python /usr/bin/prepare_kickstart_bootfile.py %s %s %s %s %s %s", _tftpDir, cmd.getMac(), kernelPath, initrdPath, cmd.getKsFile(), cmd.getMac()); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); } s_logger.debug("Prepare kickstart PXE server successfully"); return new Answer(cmd, true, "Success"); } catch (Exception e) { s_logger.debug("Prepare for kickstart server failed", e); return new Answer(cmd, false, e.getMessage()); } finally { if (sshConnection != null) { sshConnection.close(); } } }
From source file:com.cloud.network.resource.NuageVspResourceConfiguration.java
private void verifyNotEmpty(String name, String value) throws ConfigurationException { if (StringUtils.isEmpty(value)) { throw new ConfigurationException("Unable to find " + name); }/*from w ww . ja va2s . c o m*/ }
From source file:com.cloud.network.resource.NuageVspResourceConfiguration.java
private int verifyInRange(String name, String value, int min, int max) throws ConfigurationException { verifyNotEmpty(name, value);// w ww . jav a 2 s. c o m int parsedValue; try { parsedValue = Integer.parseInt(value); } catch (NumberFormatException ex) { throw new ConfigurationException(name + " has to be between " + min + " and " + max); } if ((parsedValue < min) || (parsedValue > max)) { throw new ConfigurationException(name + " has to be between " + min + " and " + max); } return parsedValue; }
From source file:com.cloud.agent.AgentShell.java
private void loadProperties() throws ConfigurationException { final File file = PropertiesUtil.findConfigFile("agent.properties"); if (file == null) { throw new ConfigurationException("Unable to find agent.properties."); }//from www . j a v a2s.co m s_logger.info("agent.properties found at " + file.getAbsolutePath()); try { _properties.load(new FileInputStream(file)); } catch (final FileNotFoundException ex) { throw new CloudRuntimeException("Cannot find the file: " + file.getAbsolutePath(), ex); } catch (final IOException ex) { throw new CloudRuntimeException("IOException in reading " + file.getAbsolutePath(), ex); } }
From source file:com.cloud.baremetal.networkservice.BaremetalPingPxeResource.java
protected Answer execute(PrepareCreateTemplateCommand cmd) { com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); try {//from w w w . j a v a 2 s . c om sshConnection.connect(null, 60000, 60000); if (!sshConnection.authenticateWithPassword(_username, _password)) { s_logger.debug("SSH Failed to authenticate"); throw new ConfigurationException( String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password)); } String script = String.format( "python /usr/bin/prepare_tftp_bootfile.py backup %1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s", _tftpDir, cmd.getMac(), _storageServer, _share, _dir, cmd.getTemplate(), _cifsUserName, _cifsPassword, cmd.getIp(), cmd.getNetMask(), cmd.getGateWay()); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new Answer(cmd, false, "prepare for creating template failed, command:" + script); } s_logger.debug("Prepare for creating template successfully"); return new Answer(cmd, true, "Success"); } catch (Exception e) { s_logger.debug("Prepare for creating baremetal template failed", e); return new Answer(cmd, false, e.getMessage()); } finally { if (sshConnection != null) { sshConnection.close(); } } }
From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java
/** * Update user details in Back Channeling Scenario : update oauth code * * @param correlationId unique ID of the request * @param token access token/*w w w.java2 s . c o m*/ */ public static void updateTokenInBackChannel(String correlationId, String token) throws ConfigurationException, CommonAuthenticatorException { Connection connection = null; PreparedStatement preparedStatement = null; String updateUserDetailsQuery = "update backchannel_request_details set access_token=? where correlation_id=?"; try { connection = getConnectDBConnection(); if (log.isDebugEnabled()) { log.debug("Executing the query " + updateUserDetailsQuery); } preparedStatement = connection.prepareStatement(updateUserDetailsQuery); preparedStatement.setString(1, token); preparedStatement.setString(2, correlationId); preparedStatement.executeUpdate(); } catch (SQLException e) { handleException("Error occurred while updating user details for : " + correlationId + "in " + "BackChannel Scenario.", e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection); } }
From source file:com.cloud.network.resource.PaloAltoResource.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { try {//from w w w .java2 s. c o m _name = (String) params.get("name"); if (_name == null) { throw new ConfigurationException("Unable to find name"); } _zoneId = (String) params.get("zoneId"); if (_zoneId == null) { throw new ConfigurationException("Unable to find zone"); } _ip = (String) params.get("ip"); if (_ip == null) { throw new ConfigurationException("Unable to find IP"); } _username = (String) params.get("username"); if (_username == null) { throw new ConfigurationException("Unable to find username"); } _password = (String) params.get("password"); if (_password == null) { throw new ConfigurationException("Unable to find password"); } _publicInterface = (String) params.get("publicinterface"); if (_publicInterface == null) { throw new ConfigurationException("Unable to find public interface."); } _privateInterface = (String) params.get("privateinterface"); if (_privateInterface == null) { throw new ConfigurationException("Unable to find private interface."); } _publicZone = (String) params.get("publicnetwork"); if (_publicZone == null) { throw new ConfigurationException("Unable to find public zone"); } _privateZone = (String) params.get("privatenetwork"); if (_privateZone == null) { throw new ConfigurationException("Unable to find private zone"); } _virtualRouter = (String) params.get("pavr"); if (_virtualRouter == null) { throw new ConfigurationException("Unable to find virtual router"); } _threatProfile = (String) params.get("patp"); _logProfile = (String) params.get("palp"); _guid = (String) params.get("guid"); if (_guid == null) { throw new ConfigurationException("Unable to find the guid"); } _numRetries = NumbersUtil.parseInt((String) params.get("numretries"), 1); _timeoutInSeconds = NumbersUtil.parseInt((String) params.get("timeout"), 300); // Open a socket and login if (!refreshPaloAltoConnection()) { throw new ConfigurationException("Unable to open a connection to the Palo Alto."); } // check that the threat profile exists if one was specified if (_threatProfile != null) { try { boolean has_profile = getThreatProfile(_threatProfile); if (!has_profile) { throw new ConfigurationException("The specified threat profile group does not exist."); } } catch (ExecutionException e) { throw new ConfigurationException(e.getMessage()); } } // check that the log profile exists if one was specified if (_logProfile != null) { try { boolean has_profile = getLogProfile(_logProfile); if (!has_profile) { throw new ConfigurationException("The specified log profile does not exist."); } } catch (ExecutionException e) { throw new ConfigurationException(e.getMessage()); } } // get public interface type try { _publicInterfaceType = getInterfaceType(_publicInterface); if (_publicInterfaceType.equals("")) { throw new ConfigurationException( "The specified public interface is not configured on the Palo Alto."); } } catch (ExecutionException e) { throw new ConfigurationException(e.getMessage()); } // get private interface type try { _privateInterfaceType = getInterfaceType(_privateInterface); if (_privateInterfaceType.equals("")) { throw new ConfigurationException( "The specified private interface is not configured on the Palo Alto."); } } catch (ExecutionException e) { throw new ConfigurationException(e.getMessage()); } _pingManagementProfile = "Ping"; try { ArrayList<IPaloAltoCommand> cmdList = new ArrayList<IPaloAltoCommand>(); managePingProfile(cmdList, PaloAltoPrimative.ADD); boolean status = requestWithCommit(cmdList); } catch (ExecutionException e) { throw new ConfigurationException(e.getMessage()); } return true; } catch (Exception e) { throw new ConfigurationException(e.getMessage()); } }
From source file:com.cloud.network.resource.NuageVspResourceConfiguration.java
public void validate() throws ConfigurationException { verifyNotNull("name", _name); verifyNotNull("guid", _guid); verifyNotNull("zone", _zoneId); verifyNotNull("hostname", _hostName); verifyNotNull("CMS username", _cmsUser); verifyNotNull("CMS password", _cmsUserPassword); verifyNotEmpty("API version", _apiVersion); try {/*from w w w . j a va2s . c o m*/ new NuageVspApiVersion(_apiVersion); } catch (IllegalArgumentException e) { throw new ConfigurationException("Incorrect API version"); } verifyNotEmpty("number of retries", _retryCount); verifyNotEmpty("retry interval", _retryInterval); }
From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java
/** * @param clientConfig/*from ww w . j a v a 2 s . c om*/ * the clientConfig to set * @throws ConfigurationException */ void setClientConfig(ClientConfiguration clientConfig) throws ConfigurationException { if (clientConfig == null) { throw new ConfigurationException("null client configuration not allowed"); } if (!(clientConfig instanceof BgpClientPortConfigurationDecorator)) { clientConfig = new BgpClientPortConfigurationDecorator(clientConfig); } this.clientConfig = clientConfig; }