List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key);
From source file:com.salesmanager.core.util.FileUtil.java
public static String getInternalDownloadFileUrl(int merchantId, long downloadId) throws Exception { Configuration conf = PropertiesUtil.getConfiguration(); MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); MerchantStore store = mservice.getMerchantStore(merchantId); // ***build fileid*** StringBuffer urlconstruct = new StringBuffer(); StringBuffer downloadurl = new StringBuffer(); Calendar endDate = Calendar.getInstance(); endDate.add(Calendar.DATE, conf.getInt("core.product.file.downloadmaxdays", 2)); // add 2 days Date denddate = endDate.getTime(); String sedate = DateUtil.formatDate(denddate); urlconstruct.append(downloadId).append("|").append(sedate).append("|").append(merchantId); String file = EncryptionUtil.encrypt(EncryptionUtil.generatekey(SecurityConstants.idConstant), urlconstruct.toString());/*from ww w .j a v a 2 s .c om*/ downloadurl.append(ReferenceUtil.buildCheckoutUri(store)) .append(conf.getString("core.salesmanager.core.downloadFileAction")).append("?fileId=").append(file) .append("&mod=productfile"); return downloadurl.toString(); }
From source file:com.appeligo.amazon.AmazonService.java
public List<AmazonItem> getKeywordPurchases(String keywords, int maxResults) throws ServiceException { //throttle(); try {/*w w w.j a v a 2 s. com*/ AWSECommerceServicePortType service = getService(); Configuration config = ConfigUtils.getAmazonConfig(); ItemSearch search = new ItemSearch(); search.setAWSAccessKeyId(config.getString("awsId")); search.setAssociateTag(config.getString("associateTag")); ItemSearchRequest[] requests = new ItemSearchRequest[1]; ItemSearchRequest request = new ItemSearchRequest(); request.setSearchIndex("All"); if (log.isInfoEnabled()) { log.info("Searching for keywords: " + keywords); } request.setKeywords(keywords + " -xxx"); request.setResponseGroup(new String[] { "Small", "Images" }); requests[0] = request; search.setRequest(requests); ItemSearchResponse response = service.itemSearch(search); lastServiceCall = System.currentTimeMillis(); checkError(response); Items[] responseList = response.getItems(); Items items = responseList[0]; /////////////////////////////////////////////////////////////////////////////////// // PENDING JMF: I was getting an ocasional NullPointerException here, particularly // when I got no search results from my action, seems reasonable. I added this // defensive check and return an empty list. We may very well want to can some // items to pack into a default list in this case. /////////////////////////////////////////////////////////////////////////////////// if (items != null && items.getItem() != null) { List<AmazonItem> productList = new ArrayList<AmazonItem>(items.getItem().length); for (int i = 0; i < maxResults && i < items.getItem().length; i++) { Item item = items.getItem()[i]; //if (isAllowed(item)) { productList.add(createItem(item)); //} } return productList; } else { return new ArrayList<AmazonItem>(); } } catch (RemoteException e) { throw new ServiceException("Cannot lookup videos.", e.getCause()); } }
From source file:de.chdev.artools.loga.controller.SqlController.java
public SqlController(Configuration keywords, MainController mainController) { this.keywords = keywords; this.mainController = mainController; String regexKey;//from w ww . j a v a2 s. c o m // Define SQL Start Pattern regexKey = keywords.getString("sql.start"); patternSqlStart = Pattern.compile(regexKey); // Define SQL Stop Pattern regexKey = keywords.getString("sql.stop"); patternSqlStop = Pattern.compile(regexKey); // Define SQL Commit Pattern regexKey = keywords.getString("sql.commit"); patternSqlCommit = Pattern.compile(regexKey); }
From source file:keel.Algorithms.Neural_Networks.NNEP_Clas.problem.classification.softmax.SoftmaxClassificationProblemEvaluator.java
/** * <p>/* www . j av a 2 s. co m*/ * Configuration parameters for NeuralNetEvaluator are: * Problem evaluator configuration * org.ayrna.jclec.problem.ProblemEvaluator * * error-function: complex * Error function used for evaluating individuals * </p> */ @SuppressWarnings("unchecked") public void configure(Configuration settings) { // ProblemEvaluator configuration super.configure(settings); // Individual error function try { // Error function classname String errorFunctionClassname = settings.getString("error-function"); // Error function class Class<IErrorFunction<double[][]>> errorFunctionClass = (Class<IErrorFunction<double[][]>>) Class .forName(errorFunctionClassname); // Error function instance IErrorFunction<double[][]> errorFunction = errorFunctionClass.newInstance(); // Set error function setErrorFunction(errorFunction); } catch (ClassNotFoundException e) { throw new ConfigurationRuntimeException("Illegal error function classname"); } catch (InstantiationException e) { throw new ConfigurationRuntimeException("Problems creating an instance of error function", e); } catch (IllegalAccessException e) { throw new ConfigurationRuntimeException("Problems creating an instance of error function", e); } }
From source file:de.hybris.platform.b2bpunchoutaddon.services.impl.DefaultPunchOutUserAuthenticationService.java
/** * Select page that user will be redirected in seamless login, depending on the selected operation. * /*from ww w . j a v a 2 s .c o m*/ * @param punchOutSession * @param request */ private void selectRedirectPage(final PunchOutSession punchOutSession, final HttpServletRequest request) { final Configuration configuration = configurationService.getConfiguration(); final String operation = punchOutSession.getOperation(); if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.CREATE.toString())) { request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE, configuration.getString("b2bpunchoutaddon.redirect.create")); } else if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.EDIT.toString())) { request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE, configuration.getString("b2bpunchoutaddon.redirect.edit")); } else if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.INSPECT.toString())) { request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE, configuration.getString("b2bpunchoutaddon.redirect.inspect")); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.real_code.MichalewiczNonUniformMutation.java
@Override public void configure(Configuration conf) { try {//from w ww. j av a 2 s . c o m super.configure(conf); if (conf.containsKey("B")) { this.b = conf.getDouble("B"); } if (conf.containsKey("Plugin")) { this.plugin = (StopTestPlugin) Class.forName(conf.getString("Plugin")).newInstance(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.kixeye.chassis.support.eureka.MetadataCollector.java
/** * Get metadata from configuration data that does not change. * * @return Map of static meta data//from w w w.j a v a 2 s.c o m */ public Map<String, String> getStaticMetadataMap() { if (staticMetaDataCache == null) { // add eureka.metadata.* properties staticMetaDataCache = new LinkedHashMap<>(); Configuration config = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); for (Iterator<String> iter = config.subset("eureka.metadata").getKeys(); iter.hasNext();) { String key = iter.next(); String value = config.getString("eureka.metadata." + key); staticMetaDataCache.put(key, value); } // add WebSocket port to meta data if available if (DynamicPropertyFactory.getInstance().getBooleanProperty("websocket.enabled", false).get()) { int port = DynamicPropertyFactory.getInstance().getIntProperty("websocket.port", -1).get(); if (port > 0) { staticMetaDataCache.put("websocketPort", "" + port); } } // add secure WebSocket port to meta data if available if (DynamicPropertyFactory.getInstance().getBooleanProperty("secureWebsocket.enabled", false).get()) { int port = DynamicPropertyFactory.getInstance().getIntProperty("secureWebsocket.port", -1).get(); if (port > 0) { staticMetaDataCache.put("secureWebsocketPort", "" + port); } } } return staticMetaDataCache; }
From source file:com.github.rnewson.couchdb.lucene.LuceneServlet.java
private Couch getCouch(final HttpServletRequest req) throws IOException { final String sectionName = new PathParts(req).getKey(); final Configuration section = ini.getSection(sectionName); if (!section.containsKey("url")) { throw new FileNotFoundException(sectionName + " is missing or has no url parameter."); }//from w w w . j av a2 s. com return new Couch(client, section.getString("url")); }
From source file:net.sf.jclal.classifier.MulanClassifier.java
/** * * @param configuration The configuration of Mulan classifier. * *The XML labels supported are://from w w w. j a va 2 s.com * * <ul> * <li> * <b>classifier type= class</b> * <p> * Package: * </p> * mulan.classifier * <p> * Class: All * </p> * If the defined classifier is instance of * mulan.classifier.transformation, then a base-classifier must be * configured * <ul> * <li> * <b>base-classifier type= class</b> * All weka classifier are supported * </li> * </ul> * </li> * </ul> */ @Override public void configure(Configuration configuration) { String classifierError = "classifier type= "; try { // classifier classname String classifierClassname = configuration.getString("classifier[@type]"); classifierError += classifierClassname; // classifier class Class<? extends MultiLabelLearnerBase> classifierClass = (Class<? extends MultiLabelLearnerBase>) Class .forName(classifierClassname); MultiLabelLearnerBase multiLabelClassifier = null; // If the multi label learner is a problem transformation method // then a base classifier must be configured if (TransformationBasedMultiLabelLearner.class.isAssignableFrom(classifierClass)) { String baseError = "base-classifier type= "; try { Configuration conf = configuration.subset("classifier"); // classifier classname String baseClassifier = conf.getString("base-classifier[@type]"); baseError += baseClassifier; // classifier class Class<? extends Classifier> baseClassifierClass = (Class<? extends Classifier>) Class .forName(baseClassifier); // classifier instance Classifier baseClassifierInstance = baseClassifierClass.newInstance(); multiLabelClassifier = classifierClass.getConstructor(new Class<?>[] { Classifier.class }) .newInstance(baseClassifierInstance); } catch (IllegalArgumentException e) { throw new ConfigurationRuntimeException("\nIllegal base classifier: " + baseError, e); } catch (InvocationTargetException e) { throw new ConfigurationRuntimeException("\nIllegal base classifier: " + baseError, e); } catch (SecurityException e) { throw new ConfigurationRuntimeException("\nIllegal base classifier: " + baseError, e); } catch (NoSuchMethodException ex) { Logger.getLogger(MulanClassifier.class.getName()).log(Level.SEVERE, null, ex); } } else { multiLabelClassifier = classifierClass.newInstance(); } // Add this classifier setClassifier(multiLabelClassifier); } catch (ClassNotFoundException e) { throw new ConfigurationRuntimeException("\nIllegal classifier classname: " + classifierError, e); } catch (InstantiationException e) { throw new ConfigurationRuntimeException("\nIllegal classifier classname: " + classifierError, e); } catch (IllegalAccessException e) { throw new ConfigurationRuntimeException("\nIllegal classifier classname: " + classifierError, e); } }
From source file:com.w20e.socrates.process.RunnerFactoryImpl.java
/** * Get the formatter for the given id and locale. Formatters can be shared * among instances.//from w w w .ja va2 s . c om * * @param id * Questionnaire id * @param cfg * configuration for creating the formatter * @return the formatter created. * @throws Exception * whenever the formatter can't be created */ private Formatter getFormatter(final URI id, final Configuration cfg, final Map<String, String> options) throws Exception { if (!this.formatters.containsKey(id)) { LOGGER.fine("Creating new formatter"); Formatter formatter = (Formatter) Class.forName(cfg.getString("formatter.class")).newInstance(); formatter.init(cfg); this.formatters.put(id, formatter); } return this.formatters.get(id); }