List of usage examples for javax.naming ConfigurationException ConfigurationException
public ConfigurationException(String explanation)
From source file:org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.java
protected CopyCmdAnswer postProcessing(File destFile, String downloadPath, String destPath, DataTO srcData, DataTO destData) throws ConfigurationException { if (destData.getObjectType() == DataObjectType.SNAPSHOT) { SnapshotObjectTO snapshot = new SnapshotObjectTO(); snapshot.setPath(destPath + File.separator + destFile.getName()); CopyCmdAnswer answer = new CopyCmdAnswer(snapshot); return answer; }// ww w . j a v a2 s.co m // do post processing to unzip the file if it is compressed String scriptsDir = "scripts/storage/secondary"; String createTmpltScr = Script.findScript(scriptsDir, "createtmplt.sh"); if (createTmpltScr == null) { throw new ConfigurationException("Unable to find createtmplt.sh"); } s_logger.info("createtmplt.sh found in " + createTmpltScr); String createVolScr = Script.findScript(scriptsDir, "createvolume.sh"); if (createVolScr == null) { throw new ConfigurationException("Unable to find createvolume.sh"); } s_logger.info("createvolume.sh found in " + createVolScr); String script = srcData.getObjectType() == DataObjectType.TEMPLATE ? createTmpltScr : createVolScr; int installTimeoutPerGig = 180 * 60 * 1000; long imgSizeGigs = (long) Math.ceil(destFile.length() * 1.0d / (1024 * 1024 * 1024)); imgSizeGigs++; // add one just in case long timeout = imgSizeGigs * installTimeoutPerGig; String origPath = destFile.getAbsolutePath(); String extension = null; if (srcData.getObjectType() == DataObjectType.TEMPLATE) { extension = ((TemplateObjectTO) srcData).getFormat().getFileExtension(); } else if (srcData.getObjectType() == DataObjectType.VOLUME) { extension = ((VolumeObjectTO) srcData).getFormat().getFileExtension(); } String templateName = UUID.randomUUID().toString(); String templateFilename = templateName + "." + extension; Script scr = new Script(script, timeout, s_logger); scr.add("-s", Long.toString(imgSizeGigs)); // not used for now scr.add("-n", templateFilename); scr.add("-t", downloadPath); scr.add("-f", origPath); // this is the temporary // template file downloaded String result; result = scr.execute(); if (result != null) { // script execution failure throw new CloudRuntimeException("Failed to run script " + script); } String finalFileName = templateFilename; String finalDownloadPath = destPath + File.separator + templateFilename; // compute the size of long size = _storage.getSize(downloadPath + File.separator + templateFilename); DataTO newDestTO = null; if (destData.getObjectType() == DataObjectType.TEMPLATE) { TemplateObjectTO newTemplTO = new TemplateObjectTO(); newTemplTO.setPath(finalDownloadPath); newTemplTO.setName(finalFileName); newTemplTO.setSize(size); newTemplTO.setPhysicalSize(size); newDestTO = newTemplTO; } else { VolumeObjectTO newVolTO = new VolumeObjectTO(); newVolTO.setPath(finalDownloadPath); newVolTO.setName(finalFileName); newVolTO.setSize(size); newDestTO = newVolTO; } return new CopyCmdAnswer(newDestTO); }
From source file:com.wso2telco.proxy.util.DBUtils.java
public static boolean isSPAllowedScope(String scopeName, String clientId) throws ConfigurationException, AuthenticatorException { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null;/*from w ww . j av a2 s. c om*/ String[] scopeValues = scopeName.split("\\s+|\\+"); StringBuilder params = new StringBuilder("?"); for (int i = 1; i < scopeValues.length; i++) { params.append(",?"); } String queryToGetOperatorProperty = "SELECT COUNT(*) AS record_count FROM `sp_configuration` WHERE `client_id`=? AND `config_key`=? AND " + "`config_value` in (" + params + ")"; boolean isSPAllowedScope = false; try { connection = getConnectDBConnection(); preparedStatement = connection.prepareStatement(queryToGetOperatorProperty); preparedStatement.setString(1, clientId); preparedStatement.setString(2, "scope"); for (int i = 0; i < scopeValues.length; i++) { preparedStatement.setString(i + 3, scopeValues[i]); } resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { isSPAllowedScope = resultSet.getInt("record_count") == scopeValues.length; } } catch (SQLException e) { handleException("Error occurred while SP Configurations for ClientId - " + clientId + " and Scope - " + scopeName, e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection, resultSet); } return isSPAllowedScope; }
From source file:com.cloud.agent.AgentShell.java
private void launchAgentFromClassInfo(String resourceClassNames) throws ConfigurationException { String[] names = resourceClassNames.split("\\|"); for (String name : names) { Class<?> impl;//from w w w. java 2 s. co m try { impl = Class.forName(name); final Constructor<?> constructor = impl.getDeclaredConstructor(); constructor.setAccessible(true); ServerResource resource = (ServerResource) constructor.newInstance(); launchAgent(getNextAgentId(), resource); } catch (final ClassNotFoundException e) { throw new ConfigurationException("Resource class not found: " + name + " due to: " + e.toString()); } catch (final SecurityException e) { throw new ConfigurationException( "Security excetion when loading resource: " + name + " due to: " + e.toString()); } catch (final NoSuchMethodException e) { throw new ConfigurationException( "Method not found excetion when loading resource: " + name + " due to: " + e.toString()); } catch (final IllegalArgumentException e) { throw new ConfigurationException( "Illegal argument excetion when loading resource: " + name + " due to: " + e.toString()); } catch (final InstantiationException e) { throw new ConfigurationException( "Instantiation excetion when loading resource: " + name + " due to: " + e.toString()); } catch (final IllegalAccessException e) { throw new ConfigurationException( "Illegal access exception when loading resource: " + name + " due to: " + e.toString()); } catch (final InvocationTargetException e) { throw new ConfigurationException( "Invocation target exception when loading resource: " + name + " due to: " + e.toString()); } } }
From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java
/** * @param delayOpenTime//from ww w .j a v a2 s. c o m * the delayOpenTime to set * @throws ConfigurationException */ void setDelayOpenTime(final int delayOpenTime) throws ConfigurationException { if (delayOpenTime < 0) { throw new ConfigurationException("Illegal delay open time given: " + delayOpenTime); } this.delayOpenTime = delayOpenTime; }
From source file:com.wso2telco.proxy.entity.Endpoints.java
/** * Get the scope param object// ww w.j av a 2s. c o m * * @param scope * @return * @throws AuthenticationFailedException * @throws ConfigurationException */ private ScopeParam getScopeParam(String scope, UserStatus userStatus) throws AuthenticationFailedException, ConfigurationException { Map scopeDetail; try { scopeDetail = DBUtils.getScopeParams(scope); } catch (AuthenticatorException e) { String errMsg = "Error occurred while getting scope parameters from the database for the scope - " + scope; DataPublisherUtil.updateAndPublishUserStatus(userStatus, DataPublisherUtil.UserState.OTHER_ERROR, errMsg); throw new AuthenticationFailedException(errMsg); } if (scopeDetail == null || scopeDetail.isEmpty()) { String errMsg = "Please configure Scope related Parameters properly in scope_parameter table"; DataPublisherUtil.updateAndPublishUserStatus(userStatus, DataPublisherUtil.UserState.CONFIGURATION_ERROR, errMsg); throw new ConfigurationException(errMsg); } //set the scope specific params return (ScopeParam) scopeDetail.get("params"); }
From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java
/** * @param connectRetryTime//from w w w. j a va2 s . co m * the connectRetryTime to set */ void setConnectRetryTime(final int connectRetryTime) throws ConfigurationException { if (connectRetryTime < 0) { throw new ConfigurationException("Illegal connect retry time given: " + connectRetryTime); } this.connectRetryTime = connectRetryTime; }
From source file:com.cloud.agent.AgentShell.java
private void launchAgentFromTypeInfo() throws ConfigurationException { String typeInfo = getProperty(null, "type"); if (typeInfo == null) { s_logger.error("Unable to retrieve the type"); throw new ConfigurationException("Unable to retrieve the type of this agent."); }//from ww w . j av a2s . co m s_logger.trace("Launching agent based on type=" + typeInfo); }
From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java
/** * Check the scope is backChannel allowed * * @param scope scope value//from w w w . jav a 2 s . c o m * @return allowed or not allowed * @throws ConfigurationException on errors */ public static boolean isBackChannelAllowedScope(String scope) throws ConfigurationException, CommonAuthenticatorException { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; boolean isBackChannelAllowed = false; String[] scopeValues = scope.split("\\s+|\\+"); StringBuilder params = new StringBuilder("?"); for (int i = 1; i < scopeValues.length; i++) { params.append(",?"); } String sql = "SELECT is_backchannel_allowed FROM scope_parameter WHERE scope in (" + params + ") ;"; if (log.isDebugEnabled()) { log.debug("Executing the query to check the scope is backChannel allowed: " + sql); } try { connection = getConnectDBConnection(); preparedStatement = connection.prepareStatement(sql); for (int i = 0; i < scopeValues.length; i++) { preparedStatement.setString(i + 1, scopeValues[i]); } resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { isBackChannelAllowed = resultSet.getBoolean("is_backchannel_allowed"); if (!isBackChannelAllowed) { isBackChannelAllowed = false; } } } catch (SQLException e) { handleException("Error occurred while checking the scope is back channel allowed - " + scope, e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection, resultSet); } return isBackChannelAllowed; }
From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java
/** * @param automaticStartInterval/*from w w w . java 2 s . c o m*/ * the automaticStartInterval to set */ void setAutomaticStartInterval(final int automaticStartInterval) throws ConfigurationException { if (automaticStartInterval < 0) { throw new ConfigurationException("Illegal automatic start interval given: " + this.connectRetryTime); } this.automaticStartInterval = automaticStartInterval; }
From source file:com.cloud.baremetal.BareMetalVmManagerImpl.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _name = name;/*from w w w . ja v a 2 s . c om*/ ComponentLocator locator = ComponentLocator.getCurrentLocator(); _configDao = locator.getDao(ConfigurationDao.class); if (_configDao == null) { throw new ConfigurationException("Unable to get the configuration dao."); } Map<String, String> configs = _configDao.getConfiguration("AgentManager", params); _instance = configs.get("instance.name"); if (_instance == null) { _instance = "DEFAULT"; } String workers = configs.get("expunge.workers"); int wrks = NumbersUtil.parseInt(workers, 10); String time = configs.get("expunge.interval"); _expungeInterval = NumbersUtil.parseInt(time, 86400); time = configs.get("expunge.delay"); _expungeDelay = NumbersUtil.parseInt(time, _expungeInterval); _executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UserVm-Scavenger")); _itMgr.registerGuru(Type.UserBareMetal, this); VirtualMachine.State.getStateMachine().registerListener(this); s_logger.info("User VM Manager is configured."); return true; }