List of usage examples for org.apache.commons.lang StringUtils defaultIfEmpty
public static String defaultIfEmpty(String str, String defaultStr)
Returns either the passed in String, or if the String is empty or null
, the value of defaultStr
.
From source file:biblivre3.administration.reports.BaseBiblivreReport.java
protected Chunk getBoldChunk(String text) { Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, "")); chunk.setFont(boldFont); return chunk; }
From source file:biblivre3.administration.reports.BaseBiblivreReport.java
protected Chunk getSmallFontChunk(String text) { Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, "")); chunk.setFont(smallFont);// ww w. jav a 2 s .c o m return chunk; }
From source file:com.adaptris.core.jms.JmsProducerImpl.java
protected void logLinkedException(String prefix, Exception e) { if (!(e instanceof JMSException)) return;/* w w w . j ava 2s . c om*/ JMSException je = (JMSException) e; currentLogger().warn("JMSException caught [{}], [{}]", StringUtils.defaultIfEmpty(prefix, ""), e.getMessage()); if (je.getLinkedException() != null) { currentLogger().trace("Linked Exception available..."); currentLogger().trace(je.getLinkedException().getMessage(), je.getLinkedException()); } else { currentLogger().trace("No Linked Exception available"); } }
From source file:com.fiveamsolutions.nci.commons.util.MailUtils.java
/** * @param fromAddress the fromAddress to set *///from w w w .j av a 2 s . c om public static void setFromAddress(String fromAddress) { MailUtils.fromAddress = StringUtils.defaultIfEmpty(fromAddress, DEFAULT_FROM_ADDRESS); }
From source file:info.magnolia.objectfactory.configuration.ComponentProviderConfigurationBuilder.java
protected ComponentConfiguration getObserved(ComponentDefinition definition) { ConfiguredComponentConfiguration configuration = new ConfiguredComponentConfiguration(); configuration.setType(classForName(definition.getType())); configuration/*ww w . jav a 2 s . c o m*/ .setWorkspace(StringUtils.defaultIfEmpty(configuration.getWorkspace(), RepositoryConstants.CONFIG)); configuration.setPath(definition.getPath()); configuration.setObserved(true); configuration.setScope(definition.getScope()); configuration.setLazy(parseLazyFlag(definition)); return configuration; }
From source file:biblivre3.administration.reports.BaseBiblivreReport.java
protected Chunk getHeaderChunk(String text) { Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, "")); chunk.setFont(headerFont);//from w w w . j a v a 2 s . c om return chunk; }
From source file:com.thoughtworks.go.server.controller.SimplePipelineWizardController.java
@RequestMapping(value = "/admin/pipelines/management.json", method = RequestMethod.POST) public ModelAndView createPipeline(@RequestParam(value = "name") String pipelineName, @RequestParam(value = "pipelineGroup", required = false) String pipelineGroup, @RequestParam(value = "scm", required = false) String scm, @RequestParam(value = "url") String url, @RequestParam(value = "username", required = false) String username, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "builder", required = false) String builder, @RequestParam(value = "buildfile", required = false) String buildfile, @RequestParam(value = "target", required = false) String target, @RequestParam(value = "source", required = false) String[] src, @RequestParam(value = "dest", required = false) String[] dest, @RequestParam(value = "artifactType", required = false) String[] type, @RequestParam(value = "command", required = false) String command, @RequestParam(value = "arguments", required = false) String arguments, @RequestParam(value = "useTickets", required = false) Boolean useTickets, @RequestParam(value = "view", required = false) String view, @RequestParam(value = "branch", required = false) String branch, @RequestParam(value = "projectPath", required = false) String projectPath, @RequestParam(value = "domain", required = false) String domain, HttpServletResponse response) { ValidationBean validationBean = getPipelineBean(pipelineName).validate(); if (!validationBean.isValid()) { return JsonAction.jsonBadRequest(validationBean).createView(); }/* w ww . j a v a 2 s . c o m*/ validationBean = Validator.PIPELINEGROUP.validate(pipelineGroup); if (!validationBean.isValid()) { return JsonAction.jsonBadRequest(validationBean).createView(); } CaseInsensitiveString currentUserName = currentUser().getUsername(); if (!securityService.isUserAdmin(currentUser()) && !securityService.isUserAdminOfGroup(currentUserName, pipelineGroup)) { String message = String.format("User '%s' is not authorised to add pipelines to pipeline group %s", currentUserName, pipelineGroup); JsonMap jsonMap = new JsonMap(); jsonMap.put("error", message); return JsonAction.jsonBadRequest(jsonMap).createView(); } MaterialConfig materialConfigsBean = materialFactory.getMaterial(scm, url, username, password, useTickets, view, branch, projectPath, domain); PipelineBean bean = new PipelineBean(pipelineName.trim(), materialConfigsBean, builder, buildfile, target, src, dest, type, command, arguments); pipelinePauseService.pause(pipelineName, "Under construction", currentUser()); goConfigService.addPipeline(bean.getPipelineConfig(), StringUtils.defaultIfEmpty(pipelineGroup, DEFAULT_GROUP)); return JsonAction.jsonCreated(ValidationBean.valid("Pipeline successfully created.")).respond(response); }
From source file:com.autentia.tnt.manager.contacts.PositionManager.java
private PositionChange getProvinceChange(Position position) { String previous = ""; String now = ""; Position changes = position.getChanges(); // no vamos a compara la entidad (su ID) vamos a hacerlo // por el nombre de la provincia, ya que aunque sea la misma entidad (mismo ID) // si durante la edicin del puesto ha cambiado el nombre de la entidad // no est de ms reflejarlo if (changes.getProvince() != null) { previous = StringUtils.defaultIfEmpty(changes.getProvince().getName(), ""); }/*from w w w . j a v a2 s . com*/ if (position.getProvince() != null) { now = StringUtils.defaultIfEmpty(position.getProvince().getName(), ""); } return getChange(position, FIELD_PROVINCE, previous, now); }
From source file:com.cloudera.impala.analysis.TupleDescriptor.java
/** * Checks that this tuple is materialized and has a mem layout. Throws if this tuple * is not executable, i.e., if one of those conditions is not met. *//*from ww w . j a v a 2 s . c o m*/ public void checkIsExecutable() { Preconditions.checkState(isMaterialized_, String.format("Illegal reference to non-materialized tuple: debugname=%s alias=%s tid=%s", debugName_, StringUtils.defaultIfEmpty(getAlias(), "n/a"), id_)); Preconditions.checkState(hasMemLayout_, String.format("Missing memory layout for tuple: debugname=%s alias=%s tid=%s", debugName_, StringUtils.defaultIfEmpty(getAlias(), "n/a"), id_)); }
From source file:info.magnolia.cms.filters.InterceptFilter.java
/** * Request and Response here is same as received by the original page so it includes all post/get data. Sub action * could be called from here once this action finishes, it will continue loading the requested page. * @throws RepositoryException/* w w w. j a v a 2 s . c om*/ * @throws LoginException */ public void intercept(HttpServletRequest request, HttpServletResponse response) throws LoginException, RepositoryException { final AggregationState aggregationState = MgnlContext.getAggregationState(); String action = request.getParameter(INTERCEPT); String repository = request.getParameter(PARAM_REPOSITORY); String nodePath = request.getParameter(PARAM_PATH); String handle = aggregationState.getHandle(); String channel = aggregationState.getChannel().getName(); if (repository == null) { repository = aggregationState.getRepository(); } if (repository == null) { repository = RepositoryConstants.WEBSITE; } final Session session = MgnlContext.getJCRSession(repository); if (ACTION_PREVIEW.equals(action)) { // preview mode (button in main bar) String preview = request.getParameter(MGNL_PREVIEW_ATTRIBUTE); log.debug("preview request parameter value is {} ", preview); if (preview != null) { if (Boolean.parseBoolean(preview)) { MgnlContext.setAttribute(MGNL_PREVIEW_ATTRIBUTE, Boolean.TRUE, Context.SESSION_SCOPE); MgnlContext.setAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, channel, Context.SESSION_SCOPE); } else { MgnlContext.removeAttribute(MGNL_PREVIEW_ATTRIBUTE, Context.SESSION_SCOPE); MgnlContext.removeAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, Context.SESSION_SCOPE); } } else { MgnlContext.removeAttribute(MGNL_PREVIEW_ATTRIBUTE, Context.SESSION_SCOPE); MgnlContext.removeAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, Context.SESSION_SCOPE); } } else if (ACTION_NODE_DELETE.equals(action)) { // delete paragraph try { Node page = session.getNode(handle); session.removeItem(nodePath); MetaDataUtil.updateMetaData(page); session.save(); } catch (RepositoryException e) { log.error("Exception caught: {}", e.getMessage(), e); } } else if (ACTION_NODE_SORT.equals(action)) { // sort paragraphs try { String pathSelected = request.getParameter(PARAM_PATH_SELECTED); String pathTarget = request.getParameter(PARAM_PATH_TARGET); String pathParent = StringUtils.substringBeforeLast(pathSelected, "/"); String srcName = StringUtils.substringAfterLast(pathSelected, "/"); String destName = StringUtils.substringAfterLast(pathTarget, "/"); String order = StringUtils.defaultIfEmpty(request.getParameter("order"), "before"); if (StringUtils.equalsIgnoreCase(destName, "mgnlNew")) { destName = null; } Node parent = session.getNode(pathParent + srcName); if ("before".equals(order)) { NodeUtil.orderBefore(parent, destName); } else { NodeUtil.orderAfter(parent, destName); } Node page = session.getNode(handle); MetaDataUtil.updateMetaData(page); session.save(); } catch (RepositoryException e) { log.error("Exception caught: {}", e.getMessage(), e); } } else { log.warn("Unknown action {}", action); } }