List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.baidu.rigel.biplatform.tesseract.node.service.impl.IsNodeServiceImpl.java
@Override public List<Node> getAvailableNodeListByIndexShard(IndexShard idxShard, String clusterName) { if (idxShard == null || StringUtils.isEmpty(idxShard.getNodeKey()) && CollectionUtils.isEmpty(idxShard.getReplicaNodeKeyList())) { throw new IllegalArgumentException(); }//from w w w. ja v a 2s. c o m List<String> nodeKeyList = new ArrayList<String>(); nodeKeyList.add(idxShard.getNodeKey()); nodeKeyList.addAll(idxShard.getReplicaNodeKeyList()); Map<String, Node> nodeMap = getNodeMapByNodeKey(clusterName, nodeKeyList, Boolean.TRUE); List<Node> resultNodeList = new ArrayList<Node>(); if (MapUtils.isNotEmpty(nodeMap)) { resultNodeList.addAll(nodeMap.values()); } return resultNodeList; }
From source file:org.ihtsdo.otf.snomed.service.ConceptLookUpServiceImpl.java
@Override @Cacheable(value = { "conceptHistory" }) public ChangeRecord<Concept> getConceptHistory(String conceptId) throws ConceptServiceException, EntityNotFoundException { LOGGER.debug("getting concept details and history for {} ", conceptId); if (StringUtils.isEmpty(conceptId)) { throw new EntityNotFoundException(String.format("Invalid concept id", conceptId)); }/*from w ww . ja v a 2 s. c om*/ TitanGraph g = null; try { g = factory.getReadOnlyGraph(); Iterable<Vertex> vs = g.getVertices(Properties.sctid.toString(), conceptId); for (Vertex v : vs) { ChangeRecord<Concept> cr = getHistory(v); return cr; } RefsetGraphFactory.commit(g); } catch (Exception e) { LOGGER.error("Error duing concept details fetch", e); RefsetGraphFactory.rollback(g); throw new ConceptServiceException(e); } finally { RefsetGraphFactory.shutdown(g); } throw new EntityNotFoundException( String.format("Concept details not available for given concept id %s", conceptId)); }
From source file:org.carewebframework.shell.plugins.PluginContainer.java
/** * Allows auto-wire to work even if component is not a child of the container. * /*w w w . j a v a2 s . c o m*/ * @param id Component id. * @param component Component to be registered. */ /*package*/void registerId(String id, Component component) { if (!StringUtils.isEmpty(id) && !hasAttribute(id)) { setAttribute(id, component); } }
From source file:au.com.ors.rest.controller.JobAppController.java
/** * Update application status<br/>/*w w w .j a va 2 s .c o m*/ * * @param _appId * application ID * @param status * status to be updated * @return a HATEOAS application object * @throws JobApplicationNotFoundException * @throws JobAppMalformatException * @throws TransformerException */ @RequestMapping(value = "/status/{_appId}", method = RequestMethod.PUT) @ResponseBody public ResponseEntity<JobApplicationResource> updateJobStatus(@PathVariable(value = "_appId") String _appId, @RequestParam(name = "status") String status) throws JobApplicationNotFoundException, JobAppMalformatException, TransformerException { // check application existence JobApplication app = jobAppDao.findById(_appId); if (app == null) { throw new JobApplicationNotFoundException("Job application with _appId=" + _appId + " not found in database, you cannot update its status"); } // check input status if (StringUtils.isEmpty(status)) { throw new JobAppMalformatException("Job application update status: required input status"); } if (!JobAppStatus.contains(status)) { throw new JobAppMalformatException("Job application update status invalid"); } if (!status.equals(app.getStatus())) { // need update app.setStatus(status); jobAppDao.update(app); } JobApplicationResource updatedAppResource = appResourceAssembler.toResource(app); return new ResponseEntity<JobApplicationResource>(updatedAppResource, HttpStatus.OK); }
From source file:org.ihtsdo.otf.refset.api.history.ChangeHistoryController.java
/**To convert string date to {@link DateTime} * @param fromDate/*from ww w.j a v a 2 s . c o m*/ * @return */ private DateTime getFromDate(String fromDate, int daysOffset) { DateTime fromDt = new DateTime().minusDays(daysOffset); if (!StringUtils.isEmpty(fromDate)) { fromDt = FORMATTER.parseDateTime(fromDate); } return fromDt; }
From source file:se.vgregion.usdservice.USDServiceImpl.java
protected static List<Issue> parseIssues(String xml, String fallbackType, String associated) throws RuntimeException { List<Issue> issueList = new ArrayList<Issue>(); try {// w w w.j a va2 s . c om // Parse the XML to get a DOM to query Document doc = parseXml(xml); // Extract USDObject's String xPath = "/UDSObjectList/UDSObject"; NodeList udsObjects = evaluate(xPath, doc, XPathConstants.NODESET); // Iterate over USDObject's to create Issue's for (int i = 1; i < udsObjects.getLength() + 1; i++) { // Get ref_num String refNum = null; if (TYPE_CHANGE_ORDER.equals(fallbackType)) { refNum = extractAttribute(i, "chg_ref_num", XPathConstants.STRING, doc); } else { refNum = extractAttribute(i, "ref_num", XPathConstants.STRING, doc); } // A Issue has to have refNum to be valid if (StringUtils.isEmpty(refNum)) { continue; } Issue issue = resolveIssue(refNum, i, fallbackType, associated, doc); // Add Issue object to list issueList.add(issue); } return issueList; } catch (Exception e) { log.error("Error when trying to parse issue list from XML", e); throw new RuntimeException("Error when trying to parse issue list from XML", e); } }
From source file:burstcoin.jminer.core.CoreProperties.java
private static String asString(String key, String defaultValue) { String value = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : defaultValue; return StringUtils.isEmpty(value) ? defaultValue : value; }
From source file:com.devnexus.ting.web.controller.RegisterController.java
@RequestMapping(value = "/s/registerPageTwo", method = RequestMethod.POST) public String validateDetailsForm(HttpServletRequest request, Model model, @Valid RegistrationDetails registerForm, BindingResult result) { Event currentEvent = businessService.getCurrentEvent(); EventSignup eventSignup = businessService.getEventSignup(); PaymentMethod paymentMethod = PaymentMethod.PAYPAL; prepareHeader(currentEvent, model);/*from ww w.j av a2 s . c o m*/ model.addAttribute("signupRegisterView", new SignupRegisterView(eventSignup)); model.addAttribute("registrationDetails", registerForm); registerForm.setFinalCost(getTotal(registerForm)); registerForm.setEvent(currentEvent); if (result.hasErrors()) { return "register2"; } for (int index = 0; index < registerForm.getOrderDetails().size(); index++) { TicketOrderDetail orderDetails = registerForm.getOrderDetails().get(index); TicketGroup ticketGroup = businessService.getTicketGroup(orderDetails.getTicketGroup()); if (!com.google.common.base.Strings.isNullOrEmpty(orderDetails.getCouponCode()) && ticketGroup.getCouponCodes() != null && ticketGroup.getCouponCodes().size() > 0) { if (!hasCode(ticketGroup.getCouponCodes(), orderDetails.getCouponCode())) { result.addError(new FieldError("registrationDetails", "orderDetails[" + index + "].couponCode", "Invalid Coupon Code.")); } } if (StringUtils.isEmpty(orderDetails.getFirstName())) { result.rejectValue("orderDetails[" + index + "].firstName", "firstName.isRequired", "First Name is required."); } if (StringUtils.isEmpty(orderDetails.getLastName())) { result.rejectValue("orderDetails[" + index + "].lastName", "lastName.isRequired", "Last Name is required."); } if (StringUtils.isEmpty(orderDetails.getEmailAddress())) { result.rejectValue("orderDetails[" + index + "].emailAddress", "emailAddress.isReq uired", "Email Address is required."); } if (StringUtils.isEmpty(orderDetails.getCity())) { result.rejectValue("orderDetails[" + index + "].city", "city.isRequired", "City is required."); } if (StringUtils.isEmpty(orderDetails.getState())) { result.rejectValue("orderDetails[" + index + "].state", "state.isRequired", "State is required."); } if (StringUtils.isEmpty(orderDetails.getCountry())) { result.rejectValue("orderDetails[" + index + "].country", "country.isRequired", "Country is required."); } if (StringUtils.isEmpty(orderDetails.getJobTitle())) { result.rejectValue("orderDetails[" + index + "].jobTitle", "jobTitle.isRequired", "Job Title is required."); } if (StringUtils.isEmpty(orderDetails.getCompany())) { result.rejectValue("orderDetails[" + index + "].company", "company.isRequired", "Company is required."); } } if (result.hasErrors()) { return "register2"; } for (TicketOrderDetail detail : registerForm.getOrderDetails()) { detail.setRegistration(registerForm); } switch (paymentMethod) { case INVOICE: registerForm.setPaymentState(RegistrationDetails.PaymentState.REQUIRES_INVOICE); registerForm.setFinalCost(getTotal(registerForm)); businessService.createPendingRegistrationForm(registerForm); return "index"; case PAYPAL: registerForm.setPaymentState(RegistrationDetails.PaymentState.PAYPAL_CREATED); registerForm.setFinalCost(getTotal(registerForm)); registerForm = businessService.createPendingRegistrationForm(registerForm); String baseUrl = String.format("%s://%s:%d/", request.getScheme(), request.getServerName(), request.getServerPort()); Payment createdPayment = runPayPal(registerForm, baseUrl); return "redirect:" + createdPayment.getLinks().stream().filter(link -> { return link.getRel().equals("approval_url"); }).findFirst().get().getHref(); default: throw new IllegalStateException("The system did not understand the payment type."); } }
From source file:org.ihtsdo.otf.refset.api.history.ChangeHistoryController.java
/**To convert string date to {@link DateTime} * @param toDate/* w ww .ja v a 2s .c om*/ * @return */ private DateTime getToDate(String toDate) { DateTime toDt = new DateTime(); if (!StringUtils.isEmpty(toDate)) { toDt = FORMATTER.parseDateTime(toDate); } return toDt; }
From source file:dk.dma.ais.downloader.QueryService.java
/** * Validates the AIS filter passed along. The filter must adhere to the * grammar defined by the AisLib:/*w ww .j a va 2 s .c o m*/ * https://github.com/dma-ais/AisLib * @param filter the filter to validate * @return the the filter is valid or not */ @RequestMapping(value = "/validate-filter", method = RequestMethod.GET) @ResponseBody public boolean validateFilter(@RequestParam("filter") String filter) { // A blank filter is valid if (StringUtils.isEmpty(filter)) { return true; } // Check if the filter can be parsed try { AisPacketFilters.parseExpressionFilter(filter); log.fine("Successfully parsed filter: " + filter); return true; } catch (Exception e) { log.fine("Failed parsing filter: " + filter + ": " + e); return false; } }