List of usage examples for org.apache.commons.lang StringUtils defaultIfBlank
public static String defaultIfBlank(String str, String defaultStr)
Returns either the passed in String, or if the String is whitespace, empty ("") or null
, the value of defaultStr
.
From source file:meta.proyecto.base.ProyectoMaven.java
/** * @return the version */ public String getVersion() { return StringUtils.defaultIfBlank(_version, getDefaultVersion()); }
From source file:ips1ap101.lib.core.db.util.DBUtils.java
public static String getProperErrorMessage(String message) { String join = getConstraintMessageJoin(message, ""); String trim = StringUtils.trimToEmpty(StringUtils.substringBefore(message, WHERE)); return StringUtils.defaultIfBlank(join, trim); }
From source file:com.adaptris.core.metadata.PasswordEncodeMetadataFilter.java
private String style() { return StringUtils.defaultIfBlank(getStyle(), Password.PORTABLE_PASSWORD); }
From source file:com.thoughtworks.go.server.security.BasicAuthenticationFilter.java
@Override public void doFilterHttp(HttpServletRequest httpRequest, HttpServletResponse httpResponse, FilterChain chain) throws IOException, ServletException { // if bitbucket webhook, don't basic auth, the rails controller will handle this. if (StringUtils.defaultIfBlank(httpRequest.getHeader("User-Agent"), "").startsWith("Bitbucket-Webhooks/")) { chain.doFilter(httpRequest, httpResponse); return;/*w w w.jav a 2 s.c o m*/ } try { isProcessingBasicAuth.set(true); super.doFilterHttp(httpRequest, httpResponse, chain); } catch (Exception e) { LOG.error(e.toString()); // NPE and others do not have messages, their types are important too LOG.debug(e.getMessage(), e); handleException(httpRequest, httpResponse, e); } finally { isProcessingBasicAuth.set(false); } }
From source file:io.kahu.hawaii.util.json.JsonHelper.java
public static void add(JSONObject json, String key, Object value, boolean useParsedValue) throws JSONException { if (value == null) { json.put(key, ""); } else if (value instanceof JSONObject || value instanceof JSONArray) { json.put(key, value);// ww w .java 2s . com } else if (value instanceof Collection<?>) { Collection<?> values = (Collection<?>) value; JSONArray array = new JSONArray(); for (Object v : values) { array.put(v); } json.put(key, array); } else if (value instanceof Number) { json.put(key, value); } else { json.put(key, StringUtils.defaultIfBlank(value.toString(), "")); } }
From source file:elaborate.editor.export.mvn.MVNConversionResult.java
public MVNConversionResult(final Project project, final Status logger, final String baseURL) { this.logger = logger; this.baseURL = baseURL + "/projects/" + project.getName(); Map<String, String> projectMetadata = project.getMetadataMap(); this.title = projectMetadata.get(ProjectMetadataFields.PUBLICATION_TITLE); if (StringUtils.isEmpty(this.title)) { logger.addError("project has no publication title, using project title"); this.title = project.getTitle(); }/*from w w w . jav a 2 s.c om*/ this.sigle = project.getName().toUpperCase(); if (StringUtils.isEmpty(this.sigle)) { logger.addError("project has no name"); } this.place = StringUtils.defaultIfBlank(projectMetadata.get(ProjectMetadataFields.MVN_PLACENAME), ""); this.institution = StringUtils.defaultIfBlank(projectMetadata.get(ProjectMetadataFields.MVN_INSTITUTION), ""); this.idno = StringUtils.defaultIfBlank(projectMetadata.get(ProjectMetadataFields.MVN_IDNO), ""); }
From source file:io.kamax.mxisd.threepid.notification.PlaceholderNotificationGenerator.java
protected String populateForInvite(IThreePidInviteReply invite, String input) { ThreePid tpid = new ThreePid(invite.getInvite().getMedium(), invite.getInvite().getAddress()); String senderName = invite.getInvite().getProperties().getOrDefault("sender_display_name", ""); String senderNameOrId = StringUtils.defaultIfBlank(senderName, invite.getInvite().getSender().getId()); String roomName = invite.getInvite().getProperties().getOrDefault("room_name", ""); String roomNameOrId = StringUtils.defaultIfBlank(roomName, invite.getInvite().getRoomId()); return populateForCommon(input, tpid).replace("%SENDER_ID%", invite.getInvite().getSender().getId()) .replace("%SENDER_NAME%", senderName).replace("%SENDER_NAME_OR_ID%", senderNameOrId) .replace("%INVITE_MEDIUM%", tpid.getMedium()).replace("%INVITE_ADDRESS%", tpid.getAddress()) .replace("%ROOM_ID%", invite.getInvite().getRoomId()).replace("%ROOM_NAME%", roomName) .replace("%ROOM_NAME_OR_ID%", roomNameOrId); }
From source file:adalid.core.wrappers.ArtifactWrapper.java
public String getDottedAlias() { String string = StringUtils.defaultIfBlank(_artifact.getAlias(), _artifact.getName()); return StrUtils.getLowerCaseIdentifier(string, '.'); }
From source file:jenkins.plugins.office365connector.ActionableBuilder.java
private List<PotentialAction> pullRequestActionable() { List<PotentialAction> potentialActions = new ArrayList<>(); Job job = run.getParent();/*ww w. j a va 2 s . c om*/ SCMHead head = SCMHead.HeadByItem.findHead(job); if (head instanceof ChangeRequestSCMHead) { String pronoun = StringUtils.defaultIfBlank(head.getPronoun(), Messages.Office365ConnectorWebhookNotifier_ChangeRequestPronoun()); String viewHeader = Messages.Office365ConnectorWebhookNotifier_ViewHeader(pronoun); String titleHeader = Messages.Office365ConnectorWebhookNotifier_TitleHeader(pronoun); String authorHeader = Messages.Office365ConnectorWebhookNotifier_AuthorHeader(pronoun); ObjectMetadataAction oma = job.getAction(ObjectMetadataAction.class); if (oma != null) { String urlString = oma.getObjectUrl(); PotentialAction viewPRPotentialAction = new PotentialAction(viewHeader, urlString); potentialActions.add(viewPRPotentialAction); factsBuilder.addFact(titleHeader, oma.getObjectDisplayName()); } ContributorMetadataAction cma = job.getAction(ContributorMetadataAction.class); if (cma != null) { String contributor = cma.getContributor(); String contributorDisplayName = cma.getContributorDisplayName(); String author = StringUtils.defaultIfBlank(cma.getContributor(), cma.getContributorDisplayName()); if (StringUtils.isNotBlank(contributor) && StringUtils.isNotBlank(contributorDisplayName)) author = String.format("%s (%s)", cma.getContributor(), cma.getContributorDisplayName()); factsBuilder.addFact(authorHeader, author); } } return potentialActions; }
From source file:com.adaptris.core.mail.MetadataMailHeaders.java
@Override public void handle(MimeMessage mime, AdaptrisMessage msg) throws MessagingException { Set<MetadataElement> metadata = new HashSet<MetadataElement>(); Enumeration headers = mime.getAllHeaders(); String pfx = StringUtils.defaultIfBlank(getPrefix(), ""); while (headers.hasMoreElements()) { Header h = (Header) headers.nextElement(); metadata.add(new MetadataElement(pfx + h.getName(), h.getValue())); }/*from ww w. j av a 2 s . c o m*/ msg.setMetadata(filter().filter(metadata).toSet()); }