List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.verification.impl.DefaultAddressVerificationResultHandler.java
@Override public boolean handleResult(final AddressVerificationResult verificationResult, final AddressData newAddress, final Model model, final RedirectAttributes redirectModel, final Errors bindingResult, final boolean customerBypass, final String successMsg) { if (verificationResult != null) { if (isResultUnknown(verificationResult)) { // Unknown error. Services are likely down. return false; }/*from w ww . ja va 2s.c o m*/ if (resultHasSuggestedAddresses(verificationResult)) { model.addAttribute("inputAddress", newAddress); model.addAttribute("customerBypass", Boolean.valueOf(customerBypass)); model.addAttribute("suggestedAddresses", verificationResult.getSuggestedAddresses()); model.addAttribute("saveInAddressBook", Boolean.valueOf(newAddress.isVisibleInAddressBook())); return true; } else if (resultHasErrors(verificationResult)) { addFieldErrorsToBindingResult(verificationResult.getErrors(), bindingResult); GlobalMessages.addErrorMessage(model, "address.error.formentry.invalid"); return true; } else { // The address was successfully verified by Cybersource. Inform the user and proceed. return false; } } return false; }
From source file:org.wicketstuff.gmap.api.GLatLng.java
@Override public String getJSconstructor() { return new Constructor("google.maps.LatLng").add(BigDecimal.valueOf(lat).toString()) .add(BigDecimal.valueOf(lng).toString()).add(Boolean.valueOf(unbounded)).toJS(); }
From source file:io.amient.yarn1.YarnClient.java
/** * This method should be called by the implementing application static main * method. It does all the work around creating a yarn application and * submitting the request to the yarn resource manager. The class given in * the appClass argument will be run inside the yarn-allocated master * container.//from w w w. j a v a 2 s.co m */ public static void submitApplicationMaster(Properties appConfig, Class<? extends YarnMaster> masterClass, String[] args, Boolean awaitCompletion) throws Exception { log.info("Yarn1 App Configuration:"); for (Object param : appConfig.keySet()) { log.info(param.toString() + " = " + appConfig.get(param).toString()); } String yarnConfigPath = appConfig.getProperty("yarn1.site", "/etc/hadoop"); String masterClassName = masterClass.getName(); appConfig.setProperty("yarn1.master.class", masterClassName); String applicationName = appConfig.getProperty("yarn1.application.name", masterClassName); log.info("--------------------------------------------------------------"); if (Boolean.valueOf(appConfig.getProperty("yarn1.local.mode", "false"))) { YarnMaster.run(appConfig, args); return; } int masterPriority = Integer.valueOf( appConfig.getProperty("yarn1.master.priority", String.valueOf(YarnMaster.DEFAULT_MASTER_PRIORITY))); int masterMemoryMb = Integer.valueOf(appConfig.getProperty("yarn1.master.memory.mb", String.valueOf(YarnMaster.DEFAULT_MASTER_MEMORY_MB))); int masterNumCores = Integer.valueOf( appConfig.getProperty("yarn1.master.num.cores", String.valueOf(YarnMaster.DEFAULT_MASTER_CORES))); String queue = appConfig.getProperty("yarn1.queue"); Configuration yarnConfig = new YarnConfiguration(); yarnConfig.addResource(new FileInputStream(yarnConfigPath + "/core-site.xml")); yarnConfig.addResource(new FileInputStream(yarnConfigPath + "/hdfs-site.xml")); yarnConfig.addResource(new FileInputStream(yarnConfigPath + "/yarn-site.xml")); for (Map.Entry<Object, Object> entry : appConfig.entrySet()) { yarnConfig.set(entry.getKey().toString(), entry.getValue().toString()); } final org.apache.hadoop.yarn.client.api.YarnClient yarnClient = org.apache.hadoop.yarn.client.api.YarnClient .createYarnClient(); yarnClient.init(yarnConfig); yarnClient.start(); for (NodeReport report : yarnClient.getNodeReports(NodeState.RUNNING)) { log.debug("Node report:" + report.getNodeId() + " @ " + report.getHttpAddress() + " | " + report.getCapability()); } log.info("Submitting application master class " + masterClassName); YarnClientApplication app = yarnClient.createApplication(); GetNewApplicationResponse appResponse = app.getNewApplicationResponse(); final ApplicationId appId = appResponse.getApplicationId(); if (appId == null) { System.exit(111); } else { appConfig.setProperty("am.timestamp", String.valueOf(appId.getClusterTimestamp())); appConfig.setProperty("am.id", String.valueOf(appId.getId())); } YarnClient.distributeResources(yarnConfig, appConfig, applicationName); String masterJvmArgs = appConfig.getProperty("yarn1.master.jvm.args", ""); YarnContainerContext masterContainer = new YarnContainerContext(yarnConfig, appConfig, masterJvmArgs, masterPriority, masterMemoryMb, masterNumCores, applicationName, YarnMaster.class, args); ApplicationSubmissionContext appContext = app.getApplicationSubmissionContext(); appContext.setApplicationName(masterClassName); appContext.setResource(masterContainer.capability); appContext.setPriority(masterContainer.priority); appContext.setQueue(queue); appContext.setApplicationType(appConfig.getProperty("yarn1.application.type", "YARN")); appContext.setAMContainerSpec(masterContainer.createContainerLaunchContext()); log.info("Master container spec: " + masterContainer.capability); yarnClient.submitApplication(appContext); ApplicationReport report = yarnClient.getApplicationReport(appId); log.info("Tracking URL: " + report.getTrackingUrl()); if (awaitCompletion) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (!yarnClient.isInState(Service.STATE.STOPPED)) { log.info("Killing yarn application in shutdown hook"); try { yarnClient.killApplication(appId); } catch (Throwable e) { log.error("Failed to kill yarn application - please check YARN Resource Manager", e); } } } }); float lastProgress = -0.0f; while (true) { try { Thread.sleep(10000); report = yarnClient.getApplicationReport(appId); if (lastProgress != report.getProgress()) { lastProgress = report.getProgress(); log.info(report.getApplicationId() + " " + (report.getProgress() * 100.00) + "% " + (System.currentTimeMillis() - report.getStartTime()) + "(ms) " + report.getDiagnostics()); } if (!report.getFinalApplicationStatus().equals(FinalApplicationStatus.UNDEFINED)) { log.info(report.getApplicationId() + " " + report.getFinalApplicationStatus()); log.info("Tracking url: " + report.getTrackingUrl()); log.info("Finish time: " + ((System.currentTimeMillis() - report.getStartTime()) / 1000) + "(s)"); break; } } catch (Throwable e) { log.error("Master Heart Beat Error - terminating", e); yarnClient.killApplication(appId); Thread.sleep(2000); } } yarnClient.stop(); if (!report.getFinalApplicationStatus().equals(FinalApplicationStatus.SUCCEEDED)) { System.exit(112); } } yarnClient.stop(); }
From source file:de.dal33t.powerfolder.util.ConfigurationLoader.java
private static boolean dropFolderSettings(Properties p) { boolean drop = Boolean.valueOf(ConfigurationEntry.CONFIG_DROP_FOLDER_SETTINGS.getDefaultValue()); String owStr = p.getProperty(ConfigurationEntry.CONFIG_DROP_FOLDER_SETTINGS.getConfigKey()); try {/*w w w . j ava 2 s . c o m*/ drop = Boolean.parseBoolean(owStr); } catch (Exception e) { LOG.warning("Unable to parse pre-config drop folders settings value. Problem value: " + owStr + ". Now using: " + drop + ". " + e); } return drop; }
From source file:net.datenwerke.transloader.primitive.WrapperConverter.java
private static boolean booleanValue(Object wrapper) { return Boolean.valueOf(wrapper.toString()).booleanValue(); }
From source file:io.personium.engine.rs.DebugResource.java
/** * .//from w ww. j av a 2 s .c o m * @param useDebug JavaScript ???????? * @throws PersoniumEngineException PersoniumEngine */ public DebugResource(@QueryParam("useScriptDebug") final String useDebug) throws PersoniumEngineException { // http://xxx/yy?useScriptDebug=true ?????useScriptDebug????useDebug? super(); this.useScriptDebug = Boolean.valueOf(useDebug); log.info("Create DebugResource. useScriptDebug=" + this.useScriptDebug); }
From source file:org.ff4j.services.featurestore.FeatureStoreServicesStepDef.java
@Given("^the following features are cached$") public void the_following_features_are_cached(List<FeaturePojo> features) throws Throwable { for (FeaturePojo featurePojo : features) { Feature feature = new Feature(featurePojo.getUid(), Boolean.valueOf(featurePojo.getEnable()), featurePojo.getDescription(), featurePojo.getGroup(), Arrays.asList(featurePojo.getPermissions().split(","))); ((FF4jCacheProxy) ff4j.getFeatureStore()).getCacheManager().putFeature(feature); }//from w w w. ja v a2s. c o m }
From source file:net.acesinc.convergentui.ConvergentUIResponseFilter.java
@Override public Object run() { String origBody = contentManager.getDownstreamResponse(); if (origBody == null || origBody.isEmpty()) { return null; }/*from www . j a v a 2s. c om*/ String composedBody = null; log.trace("Response from downstream server: " + origBody); Document doc = Jsoup.parse(origBody); if (hasReplaceableElements(doc)) { log.debug("We have replaceable elements. Let's get em!"); Elements elementsToUpdate = doc.select("div[data-loc]"); for (Element e : elementsToUpdate) { StringBuilder content = new StringBuilder(); String location = e.dataset().get("loc"); String fragmentName = e.dataset().get("fragment-name"); String cacheName = e.dataset().get("cache-name"); boolean useCaching = !Boolean.valueOf(e.dataset().get("disable-caching")); boolean failQuietly = Boolean.valueOf(e.dataset().get("fail-quietly")); URL url = null; try { url = new URL(location); String protocol = url.getProtocol(); String service = url.getHost(); log.debug("Fetching content at location [ " + location + " ] with cacheName = [ " + cacheName + " ]"); try { RequestContext context = RequestContext.getCurrentContext(); ContentResponse response = contentManager.getContentFromService(location, cacheName, useCaching, context); log.trace(response.toString()); if (!response.isError()) { Object resp = response.getContent(); if (String.class.isAssignableFrom(resp.getClass())) { String subContentResponse = (String) resp; //TODO You better trust the source of your downstream HTML! // String cleanedContent = Jsoup.clean(subContentResponse, Whitelist.basic()); //this totally stripped the html out... Document subDocument = Jsoup.parse(subContentResponse); if (fragmentName != null) { Elements fragments = subDocument .select("div[data-fragment-name=\"" + fragmentName + "\"]"); if (fragments != null && fragments.size() > 0) { if (fragments.size() == 1) { Element frag = fragments.first(); //need to see if there are images that we need to replace the urls on Elements images = frag.select("img"); for (Element i : images) { String src = i.attr("src"); if (src.startsWith("/") && !src.startsWith("//")) { i.attr("src", "/cui-req://" + protocol + "://" + service + src); } //else what do we do about relative urls? } content.append(frag.toString()); } else { for (Element frag : fragments) { content.append(frag.toString()).append("\n\n"); } } } else { log.debug("Found no matching fragments for [ " + fragmentName + " ]"); if (failQuietly) { content.append("<div class='cui-error'></div>"); } else { content.append( "<span class='cui-error'>Failed getting content from remote service. Possible reason in reponse below</span>"); content.append(subDocument.toString()); } } } else { //take the whole thing and cram it in there! content.append(subDocument.toString()); } } else { //not text... if (!failQuietly) { content.append( "<span class='cui-error'>Failed getting content from remote service. Reason: content was not text</span>"); } else { content.append("<div class='cui-error'></div>"); } } } else { if (!failQuietly) { content.append( "<span class='cui-error'>Failed getting content from remote service. Reason: " + response.getMessage() + "</span>"); } else { content.append("<div class='cui-error'></div>"); } } //now append it to the page if (!content.toString().isEmpty()) { e.html(content.toString()); } } catch (Throwable t) { if (!failQuietly) { e.html("<span class='cui-error'>Failed getting content from remote service. Reason: " + t.getMessage() + "</span>"); } log.warn("Failed replacing content", t); } } catch (MalformedURLException ex) { log.warn("location was invalid: [ " + location + " ]", ex); if (!failQuietly) { content.append( "<span class='cui-error'>Failed getting content from remote service. Reason: data-loc was an invalid location.</span>"); } else { content.append("<div class='cui-error'></div>"); } } } composedBody = doc.toString(); } else { log.debug("Document has no replaeable elements. Skipping"); } try { addResponseHeaders(); if (composedBody != null && !composedBody.isEmpty()) { writeResponse(composedBody, getMimeType(RequestContext.getCurrentContext())); } else { writeResponse(origBody, getMimeType(RequestContext.getCurrentContext())); } } catch (Exception ex) { log.error("Error sending response", ex); } return null; }
From source file:com.machak.idea.plugins.tomcat.config.ApplicationComponent.java
@Override public void loadState(final Element element) { String show = element.getAttributeValue(SHOW_DIALOG_ATTRIBUTE); if (StringUtils.isNotBlank(show)) { showDialog = Boolean.valueOf(show); }//from w w w. ja v a 2 s. c o m tomcatDirectory = element.getAttributeValue(TOMCAT_DIR_ATTRIBUTE); }
From source file:org.jasig.portlet.attachment.controller.AttachmentsController.java
private ModelAndView createModelAndView(final PortletRequest request, final String view) { final Map<String, Object> model = new HashMap<String, Object>(); final PortletPreferences prefs = request.getPreferences(); final boolean usePortalJsLibs = Boolean.valueOf(prefs.getValue(USE_PPORTAL_JS_LIBS_PREFERENCE, "true")); // default is true model.put("usePortalJsLibs", usePortalJsLibs); final String portalJsNamespace = prefs.getValue(PPORTAL_JS_NAMESPACE_PREFERENCE, "up"); // Matches the current convention in uPortal model.put("portalJsNamespace", portalJsNamespace); return new ModelAndView(view, model); }