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:controllers.CodeHistoryApp.java
@IsAllowed(Operation.READ) public static Result show(String ownerName, String projectName, String commitId) throws IOException, UnsupportedOperationException, ServletException, GitAPIException, SVNException, NoSuchMethodException { Project project = Project.findByOwnerAndProjectName(ownerName, projectName); PlayRepository repository = RepositoryService.getRepository(project); Commit commit = null;/*from ww w .ja v a2 s . co m*/ try { commit = repository.getCommit(commitId); } catch (org.eclipse.jgit.errors.MissingObjectException e) { return notFound(ErrorViews.NotFound.render("error.notfound.commit", project)); } if (commit == null) { return notFound(ErrorViews.NotFound.render("error.notfound.commit", project)); } Commit parentCommit = repository.getParentCommitOf(commitId); List<CommentThread> threads = CommentThread.findByCommitId(CommentThread.find, project, commitId); String selectedBranch = StringUtils.defaultIfBlank(request().getQueryString("branch"), "HEAD"); String path = StringUtils.defaultIfBlank(request().getQueryString("path"), ""); if (project.vcs.equals(RepositoryService.VCS_SUBVERSION)) { String patch = repository.getPatch(commitId); if (patch == null) { return notFound(ErrorViews.NotFound.render("error.notfound", project)); } List<CommitComment> comments = CommitComment.find.where().eq("commitId", commitId) .eq("project.id", project.id).order("createdDate").findList(); return ok(svnDiff.render(project, commit, parentCommit, patch, comments, selectedBranch, path)); } else { List<FileDiff> fileDiffs = repository.getDiff(commitId); if (fileDiffs == null) { return notFound(ErrorViews.NotFound.render("error.notfound", project)); } return ok(diff.render(project, commit, parentCommit, threads, selectedBranch, fileDiffs, path)); } }
From source file:adalid.core.wrappers.ArtifactWrapper.java
public String getWordyAlias() { String string = StringUtils.defaultIfBlank(_artifact.getAlias(), _artifact.getName()); return StrUtils.getWordyString(string); }
From source file:net.duckling.ddl.web.controller.JoinPublicTeamController.java
@RequestMapping public ModelAndView display(HttpServletRequest request) { VWBContext context = VWBContext.createContext(request, UrlPatterns.JOIN_PUBLIC_TEAM); ModelAndView mv = layout(".aone.portal", context, "/jsp/aone/team/joinPublicTeam.jsp"); List<Team> teamList = teamService.getAllPublicAndProtectedTeam(0, 0); int totalNum = teamList.size(); int pageSize = 20; int currPageNum = Integer.parseInt(StringUtils.defaultIfBlank(request.getParameter("pageNum"), "1")); PageNum pageNum = new PageNum(currPageNum, totalNum, pageSize); teamList = teamService.getAllPublicAndProtectedTeam(pageNum.getOffset(), pageSize); List<String> creatorNames = new ArrayList<String>(); if (null != teamList && teamList.size() > 0) { for (Team team : teamList) { SimpleUser user = aoneUserService.getSimpleUserByUid(team.getCreator()); String username = (null == user) ? "" : user.getName(); creatorNames.add(username);//from w w w . j a v a 2 s. c om } } mv.addObject("teamList", teamList); mv.addObject("creatorNames", creatorNames); if (isAuthUser(request, context)) { prepareAuthUserData(context, mv, teamList); } mv.addObject(LynxConstants.PAGE_TITLE, ""); mv.addObject("teamUrl", generatTeamUrl(teamList)); mv.addObject("pageNum", pageNum); return mv; }
From source file:com.sonicle.webtop.core.bol.js.JsDomain.java
public JsDomain(DomainEntity o) throws URISyntaxException { domainId = o.getDomainId();//from w w w. j a va 2 s .c o m internetName = o.getInternetName(); enabled = o.getEnabled(); description = o.getDescription(); userAutoCreation = o.getUserAutoCreation(); dirScheme = o.getDirUri().getScheme(); dirHost = o.getDirUri().getHost(); dirPort = URIUtils.getPort(o.getDirUri()); dirAdmin = o.getDirAdmin(); dirPassword = o.getDirPassword(); dirConnSecurity = StringUtils.defaultIfBlank(EnumUtils.getName(o.getDirConnSecurity()), "null"); dirCaseSensitive = o.getDirCaseSensitive(); dirPasswordPolicy = o.getDirPasswordPolicy(); if (o.getDirParameters() instanceof ParamsLdapDirectory) { ParamsLdapDirectory params = (ParamsLdapDirectory) o.getDirParameters(); ldapLoginDn = params.loginDn; ldapLoginFilter = params.loginFilter; ldapUserDn = params.userDn; ldapUserFilter = params.userFilter; ldapUserIdField = params.userIdField; ldapUserFirstnameField = params.userFirstnameField; ldapUserLastnameField = params.userLastnameField; ldapUserDisplayNameField = params.userDisplayNameField; } else { ldapLoginDn = null; ldapLoginFilter = null; ldapUserDn = null; ldapUserFilter = null; ldapUserIdField = null; ldapUserFirstnameField = null; ldapUserLastnameField = null; ldapUserDisplayNameField = null; } }
From source file:guru.nidi.ramlproxy.report.ReportFormat.java
private static String content(RamlMessage message, String encoding) throws UnsupportedEncodingException { return message.getContent() == null ? "No content" : new String(message.getContent(), StringUtils.defaultIfBlank(encoding, Charset.defaultCharset().name())); }
From source file:com.iyonger.apm.web.service.RegionService.java
/** * check Region and Update its value.// w w w .j ava 2 s . com */ public void checkRegionUpdate() { if (!config.isInvisibleRegion()) { try { HashSet<AgentIdentity> newHashSet = Sets.newHashSet(agentManager.getAllAttachedAgents()); final String regionIP = StringUtils.defaultIfBlank(config.getCurrentIP(), NetworkUtils.DEFAULT_LOCAL_HOST_ADDRESS); cache.put(getCurrent(), new RegionInfo(regionIP, config.getControllerPort(), newHashSet)); } catch (Exception e) { LOGGER.error("Error while updating regions. {}", e.getMessage()); } } }
From source file:com.openshift.internal.restclient.model.ReplicationController.java
@Override public Collection<IEnvironmentVariable> getEnvironmentVariables(String containerName) { String name = StringUtils.defaultIfBlank(containerName, ""); ModelNode specContainers = get(SPEC_TEMPLATE_CONTAINERS); if (specContainers.isDefined()) { List<ModelNode> containers = specContainers.asList(); if (!containers.isEmpty()) { Optional<ModelNode> opt = containers.stream().filter(n -> name.equals(asString(n, NAME))) .findFirst();/*ww w . jav a 2s . c o m*/ ModelNode node = opt.isPresent() ? opt.get() : containers.get(0); ModelNode envNode = get(node, ENV); if (envNode.isDefined()) { return envNode.asList().stream().map(n -> new EnvironmentVariable(n, propertyKeys)) .collect(Collectors.toList()); } } } return Collections.emptyList(); }
From source file:net.di2e.ecdr.commons.query.QueryConfigurationImpl.java
@Override public String getDefaultResponseFormat() { return StringUtils.defaultIfBlank(defaultResponseFormatCustom, defaultResponseFormat); }
From source file:net.di2e.ecdr.search.transform.atom.AtomOGCTransformer.java
protected void addLinksToEntry(Entry entry, CDRMetacard metacard, String format, Map<String, Serializable> properties) { if (metacard.hasThumbnail()) { if (getThumbnailActionProvider() != null) { Action action = getThumbnailActionProvider().getAction(metacard); if (action != null && action.getUrl() != null) { entry.addLink(action.getUrl().toString(), SearchConstants.LINK_REL_ICON, getThumbnailMimeType().getBaseType(), action.getTitle(), null, metacard.getThumbnailLength()); }/*w ww .j a v a 2s.c o m*/ } } if (getResourceActionProvider() != null && metacard.hasResource()) { Action action = getResourceActionProvider().getAction(metacard); if (action != null && action.getUrl() != null) { entry.addLink(action.getUrl().toString(), Link.REL_ENCLOSURE, metacard.getResourceMIMETypeString(), action.getTitle(), null, metacard.getResourceSizeLong()); } // If there is no explicit resource then the metadata serves as // the product/resource so include a link to it here } else if (getMetadataActionProvider() != null) { Action action = getMetadataActionProvider().getAction(metacard); if (action != null && action.getUrl() != null) { entry.addLink(action.getUrl().toString(), Link.REL_ENCLOSURE, "text/xml", "View Product", null, -1); } } if (getViewMetacardActionProvider() != null) { Action action = getViewMetacardActionProvider().getAction(metacard); if (action != null && action.getUrl() != null) { String transformFormat = (String) properties.get(SearchConstants.METACARD_TRANSFORMER_NAME); if (StringUtils.isBlank(transformFormat)) { transformFormat = StringUtils.defaultIfBlank(format, CDR_ATOM_TRANSFORMER_ID); } entry.addLink(action.getUrl().toString() + "?transform=" + transformFormat, Link.REL_SELF, AtomResponseConstants.ATOM_MIME_TYPE, "View Atom Entry", null, -1); entry.addLink(action.getUrl().toString(), Link.REL_ALTERNATE, "text/xml", action.getTitle(), null, -1); } } }
From source file:ips1ap101.lib.base.util.TimeUtils.java
public static String getDateFormat() { String string = BundleWebui.getTrimmedToNullString("DateTimeConverter.date.pattern"); String format = StringUtils.defaultIfBlank(string, DEFAULT_DATE_FORMAT); return format; }