List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:jp.primecloud.auto.process.ComponentProcess.java
public void configure(Long farmNo) { Farm farm = farmDao.read(farmNo);/*from w ww. j a v a 2 s. c om*/ if (BooleanUtils.isTrue(farm.getComponentProcessing())) { // ?????????? if (log.isDebugEnabled()) { String message = MessageUtils.format("Component is being configured.(farmNo={0})", farmNo); log.debug(message); } return; } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100011", farmNo)); } // farm.setComponentProcessing(true); farmDao.update(farm); try { // ??? ComponentProcessContext context = createContext(farmNo); List<Component> components = null; if (!context.getRunningInstanceNos().isEmpty()) { // ??? puppetComponentProcess.createNodeManifest(context); components = getComponents(farmNo); } // ????? if (!context.getRunningInstanceNos().isEmpty()) { for (int i = 0; i < components.size(); i++) { Component component = components.get(i); // ? LoggingUtils.setComponentNo(component.getComponentNo()); LoggingUtils.setComponentName(component.getComponentName()); startPuppet(components.get(i), context); // ??????? LoggingUtils.setComponentNo(null); LoggingUtils.setComponentName(null); } } // ??? if (!context.getTargetLoadBalancerNos().isEmpty()) { // List<Callable<Void>> callables = new ArrayList<Callable<Void>>(); final Map<String, Object> loggingContext = LoggingUtils.getContext(); for (final Long loadBalancerNo : context.getTargetLoadBalancerNos()) { Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { LoggingUtils.setContext(loggingContext); try { loadBalancerProcess.configure(loadBalancerNo); } catch (Exception e) { log.error(e.getMessage(), e); // TODO: throw e; } finally { LoggingUtils.removeContext(); } return null; } }; callables.add(callable); } try { List<Future<Void>> futures = executorService.invokeAll(callables); // ??? List<Throwable> throwables = new ArrayList<Throwable>(); for (Future<Void> future : futures) { try { future.get(); } catch (ExecutionException e) { throwables.add(e.getCause()); } catch (InterruptedException ignore) { } } // ?? if (throwables.size() > 0) { throw new MultiCauseException(throwables.toArray(new Throwable[throwables.size()])); } } catch (InterruptedException e) { } } // ????? if (!context.getRunningInstanceNos().isEmpty()) { for (int i = components.size() - 1; i >= 0; i--) { Component component = components.get(i); // ? LoggingUtils.setComponentNo(component.getComponentNo()); LoggingUtils.setComponentName(component.getComponentName()); stopPuppet(components.get(i), context); // ??????? LoggingUtils.setComponentNo(null); LoggingUtils.setComponentName(null); } } } finally { // farm = farmDao.read(farmNo); farm.setComponentProcessing(false); farmDao.update(farm); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100012", farmNo)); } }
From source file:de.hybris.platform.catalog.job.diff.impl.NewCategoryCatalogVersionDiffFinder.java
@Override protected boolean shouldProcess(final CompareCatalogVersionsCronJobModel cronJobModel) { return BooleanUtils.isTrue(cronJobModel.getSearchNewCategories()); }
From source file:jp.primecloud.auto.api.component.StopAllComponent.java
/** * * ?(ALL)/*from ww w. j ava 2 s .c o m*/ * @param farmNo ? * @param isStopInstance ?? true:???false:??? * @return StopComponentResponse */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public StopAllComponentResponse stopComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_IS_STOP_INSTANCE) String isStopInstance) { StopAllComponentResponse response = new StopAllComponentResponse(); try { // ? // FarmNo ApiValidate.validateFarmNo(farmNo); // IsStopInstance ApiValidate.validateIsStopInstance(isStopInstance); // ? Farm farm = farmDao.read(Long.parseLong(farmNo)); if (farm == null) { // ???? throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo); } // ??? List<Component> components = componentDao.readByFarmNo(Long.parseLong(farmNo)); List<Long> componentNos = new ArrayList<Long>(); for (Component component : components) { if (BooleanUtils.isTrue(component.getLoadBalancer())) { //???? continue; } componentNos.add(component.getComponentNo()); } // ? if (StringUtils.isEmpty(isStopInstance)) { processService.stopComponents(Long.parseLong(farmNo), componentNos); } else { processService.stopComponents(Long.parseLong(farmNo), componentNos, Boolean.parseBoolean(isStopInstance)); } response.setSuccess(true); } catch (Throwable e) { String message = ""; if (e instanceof AutoException || e instanceof AutoApplicationException) { message = e.getMessage(); } else { message = MessageUtils.getMessage("EAPI-000000"); } log.error(message, e); response.setMessage(message); response.setSuccess(false); } return response; }
From source file:com.opengamma.web.portfolio.WebPortfolioResource.java
@PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_HTML)/*w w w . jav a 2s .c o m*/ public Response putHTML(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) { PortfolioDocument doc = data().getPortfolio(); if (doc.isLatest() == false) { return Response.status(Status.FORBIDDEN).entity(getHTML()).build(); } name = StringUtils.trimToNull(name); DocumentVisibility visibility = BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE; if (name == null) { FlexiBean out = createRootData(); out.put("err_nameMissing", true); String html = getFreemarker().build(HTML_DIR + "portfolio-update.ftl", out); return Response.ok(html).build(); } URI uri = updatePortfolio(name, visibility, doc); return Response.seeOther(uri).build(); }
From source file:gov.nih.nci.cabig.caaers.service.migrator.EvaluateAndInitiateReportConverter.java
public ExpeditedAdverseEventReport convert(EvaluateAndInitiateInputMessage evaluateInputMessage, AdverseEventReportingPeriod repPeriod, SaveAndEvaluateAEsOutputMessage response) { Timestamp now = new Timestamp(System.currentTimeMillis()); ExpeditedAdverseEventReport aeSrcReport = new ExpeditedAdverseEventReport(); for (AdverseEvent adverseEvent : repPeriod.getAdverseEvents()) { if (isTrue(adverseEvent.getRequiresReporting()) || (!isTrue(adverseEvent.isRetired()) && isTrue(adverseEvent.getReported()))) { aeSrcReport.addAdverseEventUnidirectional(adverseEvent); }/*ww w.j ava2 s. c o m*/ } aeSrcReport.setExternalId(evaluateInputMessage.getReportId()); aeSrcReport.setReporter(utility.convertReporter(evaluateInputMessage.getReporter())); aeSrcReport.setPhysician(utility.convertPhysician(evaluateInputMessage.getPhysician())); aeSrcReport.setCreatedAt(now); aeSrcReport.setReportingPeriod(repPeriod); List<Report> reports = new ArrayList<Report>(); aeSrcReport.setReports(reports); if (CollectionUtils.isNotEmpty(response.getRecommendedActions())) { for (RecommendedActions action : response.getRecommendedActions()) { Report report = new Report(); report.setReportDefinition(reportDefinitionDao.getByName(action.getReport())); if (BooleanUtils.isTrue(evaluateInputMessage.isWithdrawReport()) || StringUtils.equalsIgnoreCase("Withdraw", action.getAction())) { report.setWithdrawnOn(now); } report.setCaseNumber(evaluateInputMessage.getReportId()); reports.add(report); } } return aeSrcReport; }
From source file:de.hybris.platform.catalog.job.diff.impl.RemovedCategoryCatalogVersionDiffFinder.java
@Override protected boolean shouldProcess(final CompareCatalogVersionsCronJobModel cronJobModel) { return BooleanUtils.isTrue(cronJobModel.getSearchMissingCategories()); }
From source file:com.baasbox.BBConfiguration.java
public static boolean getComputeMetrics() { if (computeMetrics == null) computeMetrics = (!StringUtils.isEmpty(configuration.getString(ROOT_PASSWORD)) && BooleanUtils.isTrue(configuration.getBoolean(CAPTURE_METRICS))); return computeMetrics; }
From source file:de.hybris.platform.marketplaceintegrationbackoffice.widgets.MarketplaceEditorAreaController.java
@Override @ViewEvent(componentID = COMP_ID_SAVE_BTN, eventName = Events.ON_CLICK) public void saveObject() throws ObjectSavingException { if (isModelValueChanged()) { try {/* w ww . j a va 2s. co m*/ final Context ctx = new DefaultContext(); ctx.addAttribute(ObjectFacade.CTX_DISABLE_CRUD_COCKPIT_EVENT_NOTIFICATION, Boolean.TRUE); final Object savedObject = getObjectFacade().save(getCurrentObject(), ctx); getModel().setValue(MODEL_CURRENT_OBJECT, savedObject); final Map<String, EventListener<Event>> afterSaveListeners = EditorAreaRendererUtils .getAfterSaveListeners(getModel()); if (afterSaveListeners != null) { for (final EventListener<Event> listener : afterSaveListeners.values()) { try { listener.onEvent(new Event("afterSave")); } catch (final Exception e) // NOPMD, zk specific { throw new ObjectSavingException(String.valueOf(getCurrentObject()), e); } } } final Object currentObject = getCurrentObject(); sendOutput(SOCKET_OUTPUT_OBJECT_SAVED, currentObject); handleObjectSavingSuccess(currentObject); publishCRUDCockpitEventNotification(ObjectFacade.OBJECT_UPDATED_EVENT, currentObject); if (BooleanUtils.isTrue(getValue(MODEL_INPUT_OBJECT_IS_NEW, Boolean.class))) { setObject(currentObject); } else { resetValueChangedState(); updateWidgetTitle(); } } catch (final ObjectSavingException ex) { handleObjectSavingException(ex); } } }
From source file:jp.primecloud.auto.api.instance.StartInstance.java
/** * * ?// w ww .ja va2 s . c o m * * @param farmNo ? * @param instanceNo ? * @param isStartService true:?false:????null:??? * * @return StartInstanceResponse */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public StartInstanceResponse startInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_INSTANCE_NO) String instanceNo, @QueryParam(PARAM_NAME_IS_START_SERVICE) String isStartService) { StartInstanceResponse response = new StartInstanceResponse(); try { // ? // FarmNo ApiValidate.validateFarmNo(farmNo); // InstanceNo ApiValidate.validateInstanceNo(instanceNo); // IsStartService ApiValidate.validateIsStartService(isStartService); // ? Instance instance = instanceDao.read(Long.parseLong(instanceNo)); if (instance == null || BooleanUtils.isTrue(instance.getLoadBalancer())) { // ???? or ???? throw new AutoApplicationException("EAPI-100000", "Instance", PARAM_NAME_INSTANCE_NO, instanceNo); } if (BooleanUtils.isFalse(instance.getFarmNo().equals(Long.valueOf(farmNo)))) { //????? throw new AutoApplicationException("EAPI-100022", "Instance", farmNo, PARAM_NAME_INSTANCE_NO, instanceNo); } // ??(????) InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (InstanceStatus.STOPPED != status) { // ?????? throw new AutoApplicationException("EAPI-100006", instanceNo); } Platform platform = platformDao.read(instance.getPlatformNo()); PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); AwsInstance awsInstance = awsInstanceDao.read(Long.parseLong(instanceNo)); AzureInstance azureInstance = azureInstanceDao.read(Long.parseLong(instanceNo)); boolean vpc = false; String subnetId = null; boolean subnetErrFlg; if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { // ?? vpc = platformAws.getVpc(); subnetId = awsInstance.getSubnetId(); subnetErrFlg = processService.checkSubnet(platform.getPlatformType(), vpc, subnetId); if (subnetErrFlg == true) { // EC2+VPC???????????? throw new AutoApplicationException("EAPI-100033", instance.getInstanceName()); } } if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // ?? subnetId = azureInstance.getSubnetId(); subnetErrFlg = processService.checkSubnet(platform.getPlatformType(), vpc, subnetId); if (subnetErrFlg == true) { // ??????????? throw new AutoApplicationException("EAPI-100033", instance.getInstanceName()); } // ? boolean startupErrFlg; startupErrFlg = processService.checkStartup(platform.getPlatformType(), azureInstance.getInstanceName(), azureInstance.getInstanceNo()); if (startupErrFlg == true) { // ???????????? // ?No??? throw new AutoApplicationException("EAPI-100038", instance.getInstanceName()); } } // ?? List<Long> instanceNos = new ArrayList<Long>(); instanceNos.add(Long.parseLong(instanceNo)); if (StringUtils.isEmpty(isStartService)) { processService.startInstances(Long.parseLong(farmNo), instanceNos); } else { processService.startInstances(Long.parseLong(farmNo), instanceNos, Boolean.parseBoolean(isStartService)); } response.setSuccess(true); } catch (Throwable e) { String message = ""; if (e instanceof AutoException || e instanceof AutoApplicationException) { message = e.getMessage(); } else { message = MessageUtils.getMessage("EAPI-000000"); } log.error(message, e); response.setMessage(message); response.setSuccess(false); } return response; }
From source file:jp.primecloud.auto.api.instance.StartAllInstance.java
/** * * ?(ALL) ??????/*from w w w . ja v a 2s . co m*/ * * @param farmNo ? * @param isStartService true:?false:????null:??? * * @return StartAllInstanceResponse */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public StartAllInstanceResponse startAllInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_IS_START_SERVICE) String isStartService) { StartAllInstanceResponse response = new StartAllInstanceResponse(); try { // ? // FarmNo ApiValidate.validateFarmNo(farmNo); // IsStartService ApiValidate.validateIsStartService(isStartService); // ? // Farm farm = farmDao.read(Long.parseLong(farmNo)); if (farm == null) { // ????? throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo); } // ? List<Long> instanceNos = new ArrayList<Long>(); List<Instance> instances = instanceDao.readByFarmNo(Long.parseLong(farmNo)); for (Instance instance : instances) { if (BooleanUtils.isTrue(instance.getLoadBalancer())) { //? continue; } InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (InstanceStatus.STOPPED == status) { //????? instanceNos.add(instance.getInstanceNo()); } } // ?? if (StringUtils.isEmpty(isStartService)) { processService.startInstances(Long.parseLong(farmNo), instanceNos); } else { processService.startInstances(Long.parseLong(farmNo), instanceNos, Boolean.parseBoolean(isStartService)); } response.setSuccess(true); } catch (Throwable e) { String message = ""; if (e instanceof AutoException || e instanceof AutoApplicationException) { message = e.getMessage(); } else { message = MessageUtils.getMessage("EAPI-000000"); } log.error(message, e); response.setMessage(message); response.setSuccess(false); } return response; }