Java Code Examples for org.apache.commons.lang3.StringUtils#EMPTY
The following examples show how to use
org.apache.commons.lang3.StringUtils#EMPTY .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: azure-cosmosdb-java File: SessionContainer.java License: MIT License | 6 votes |
public String resolveGlobalSessionToken(RxDocumentServiceRequest request) { ConcurrentHashMap<String, ISessionToken> partitionKeyRangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(request); if (partitionKeyRangeIdToTokenMap != null) { return SessionContainer.getCombinedSessionToken(partitionKeyRangeIdToTokenMap); } return StringUtils.EMPTY; }
Example 2
Source Project: vjtools File: ExceptionUtil.java License: Apache License 2.0 | 6 votes |
/** * 拼装 短异常类名: 异常信息 <-- RootCause的短异常类名: 异常信息 */ public static String toStringWithRootCause(@Nullable Throwable t) { if (t == null) { return StringUtils.EMPTY; } final String clsName = ClassUtils.getShortClassName(t, null); final String message = StringUtils.defaultString(t.getMessage()); Throwable cause = getRootCause(t); StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message); if (cause != t) { sb.append("; <---").append(toStringWithShortName(cause)); } return sb.toString(); }
Example 3
Source Project: jackdaw File: JPredicateCodeGenerator.java License: Apache License 2.0 | 5 votes |
private CodeBlock createInitializer( final JPredicateType type, final boolean reverse, final boolean nullable, final TypeName predicateTypeName, final Element element, final TypeElement typeElement ) { final String operation = reverse ? "!" : StringUtils.EMPTY; final String caller = ModelUtils.getCaller(element); final String nullableGuard = nullable ? "input != null && " : StringUtils.EMPTY; switch (type) { case JAVA: case GUAVA: return CodeBlock.builder().add( SourceTextUtils.lines( "new $T() {", "@Override", "public boolean apply(final $T input) {", "return " + nullableGuard + operation + "input.$L;", "}", "}" ), predicateTypeName, typeElement, caller ).build(); case COMMONS: return CodeBlock.builder().add( SourceTextUtils.lines( "new $T() {", "@Override", "public boolean evaluate(final $T input) {", "return " + nullableGuard + operation + "(($T) input).$L;", "}", "}" ), predicateTypeName, Object.class, typeElement, caller ).build(); default: throw new UnsupportedOperationException(); } }
Example 4
Source Project: openemm File: PatternScheduleBuilderService.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public List<TimeScheduledEntry> parse(String parameter) { if (parameter == null) { return Collections.emptyList(); } Map<String, TimeScheduledEntry> entries = new HashMap<>(); for (String value : parameter.split(SEMICOLON)) { String day, scheduledTime; String[] dayTime = value.split(COLON); if (dayTime.length == 2) { day = dayTime[0]; scheduledTime = formatTime(dayTime[1], toFormat, fromFormat); } else { day = StringUtils.EMPTY; scheduledTime = formatTime(dayTime[0], toFormat, fromFormat); } TimeScheduledEntry entry = entries.get(day); if (entry == null) { entry = toTimeScheduledEntry(reverseWeekDays.get(day), scheduledTime); entries.put(day, entry); } else { List<ScheduledTime> times = entry.getScheduledTime(); ScheduledTime time = new ScheduledTime(); time.setTime(scheduledTime); time.setActive(true); times.add(time); } entry.setScheduledInterval(new ScheduledInterval(1)); } return new ArrayList<>(entries.values()); }
Example 5
Source Project: olingo-odata4 File: Demo.java License: Apache License 2.0 | 5 votes |
@PUT @Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM }) @Path("/{entitySetName}({entityId})/$value") @Override public Response replaceMediaEntity( @Context final UriInfo uriInfo, @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, @PathParam("entitySetName") final String entitySetName, @PathParam("entityId") final String entityId, final String value) { return super.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, value); }
Example 6
Source Project: olingo-odata4 File: Services.java License: Apache License 2.0 | 5 votes |
@GET @Path("/ComputerDetail({entityId})") public Response getComputerDetail( @Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @PathParam("entityId") final String entityId, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format); final Response internal = getEntityInternal( uriInfo.getRequestUri().toASCIIString(), accept, "ComputerDetail", entityId, format, null, null); if (internal.getStatus() == 200) { InputStream entity = (InputStream) internal.getEntity(); try { if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { entity = utils.getValue().addOperation(entity, "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications", uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications"); } return utils.getValue().createResponse( uriInfo.getRequestUri().toASCIIString(), entity, internal.getHeaderString("ETag"), utils.getKey()); } catch (Exception e) { LOG.error("Error retrieving entity", e); return xml.createFaultResponse(accept, e); } } else { return internal; } }
Example 7
Source Project: zeppelin File: ZeppelinhubRestApiHandler.java License: Apache License 2.0 | 5 votes |
private String sendToZeppelinHubWithoutResponseBody(Request request) throws IOException { request.send(new Response.CompleteListener() { @Override public void onComplete(Result result) { Request req = result.getRequest(); LOG.info("ZeppelinHub {} {} returned with status {}: {}", req.getMethod(), req.getURI(), result.getResponse().getStatus(), result.getResponse().getReason()); } }); return StringUtils.EMPTY; }
Example 8
Source Project: ja-micro File: RpcCallException.java License: Apache License 2.0 | 5 votes |
private static String getMessage(JsonObject object) { String message = StringUtils.EMPTY; if (object.has(MESSAGE)) { message = object.get(MESSAGE).getAsString(); } else if (object.has(DETAIL)) { message = object.get(DETAIL).getAsString(); } return message; }
Example 9
Source Project: commons-configuration File: XPathExpressionEngine.java License: Apache License 2.0 | 5 votes |
/** * {@inheritDoc} This implementation creates an XPATH expression that * selects the given node (under the assumption that the passed in parent * key is valid). As the {@code nodeKey()} implementation of * {@link org.apache.commons.configuration2.tree.DefaultExpressionEngine * DefaultExpressionEngine} this method does not return indices for nodes. * So all child nodes of a given parent with the same name have the same * key. */ @Override public <T> String nodeKey(final T node, final String parentKey, final NodeHandler<T> handler) { if (parentKey == null) { // name of the root node return StringUtils.EMPTY; } else if (handler.nodeName(node) == null) { // paranoia check for undefined node names return parentKey; } else { final StringBuilder buf = new StringBuilder(parentKey.length() + handler.nodeName(node).length() + PATH_DELIMITER.length()); if (parentKey.length() > 0) { buf.append(parentKey); buf.append(PATH_DELIMITER); } buf.append(handler.nodeName(node)); return buf.toString(); } }
Example 10
Source Project: olingo-odata4 File: AbstractUtilities.java License: Apache License 2.0 | 4 votes |
public Response createResponse( final String location, final InputStream entity, final String etag, final Accept accept, final Response.Status status) { final Response.ResponseBuilder builder = Response.ok(); if (StringUtils.isNotBlank(etag)) { builder.header("ETag", etag); } if (status != null) { builder.status(status); } int contentLength = 0; String contentTypeEncoding = StringUtils.EMPTY; if (entity != null) { try { final InputStream toBeStreamedBack; if (Accept.JSON == accept || Accept.JSON_NOMETA == accept) { toBeStreamedBack = Commons.changeFormat(entity, accept); } else { toBeStreamedBack = entity; } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(toBeStreamedBack, bos); IOUtils.closeQuietly(toBeStreamedBack); contentLength = bos.size(); builder.entity(new ByteArrayInputStream(bos.toByteArray())); contentTypeEncoding = ";odata.streaming=true;charset=utf-8"; } catch (IOException ioe) { LOG.error("Error streaming response entity back", ioe); } } builder.header("Content-Length", contentLength); builder.header("Content-Type", (accept == null ? "*/*" : accept.toString()) + contentTypeEncoding); if (StringUtils.isNotBlank(location)) { builder.header("Location", location); } return builder.build(); }
Example 11
Source Project: warnings-ng-plugin File: SourceDirectory.java License: MIT License | 4 votes |
@NonNull @Override public String getDisplayName() { return StringUtils.EMPTY; }
Example 12
Source Project: sakai File: ImportController.java License: Educational Community License v2.0 | 4 votes |
@RequestMapping(value = "/importConfirmation") public String showImportConfirmation(Model model, Map<String, List<String>> importedGroupMap) { log.debug("showImportConfirmation() called with {} items to import.", importedGroupMap.entrySet().size()); Optional<Site> siteOptional = sakaiService.getCurrentSite(); if (!siteOptional.isPresent()) { return GroupManagerConstants.REDIRECT_MAIN_TEMPLATE; } Site site = siteOptional.get(); // List of groups of the site, excluding the ones which GROUP_PROP_WSETUP_CREATED property is false. List<Group> groupList = (List<Group>) site.getGroups().stream().filter(group -> group.getProperties().getProperty(Group.GROUP_PROP_WSETUP_CREATED) != null && Boolean.valueOf(group.getProperties().getProperty(Group.GROUP_PROP_WSETUP_CREATED)).booleanValue()).collect(Collectors.toList()); // Variable definition that will be sent to the model Map<String, Boolean> importedGroups = new HashMap<String, Boolean>(); Map<String, String> nonExistingMemberMap = new HashMap<String, String>(); Map<String, String> nonMemberMap = new HashMap<String, String>(); Map<String, String> existingMemberMap = new HashMap<String, String>(); Map<String, String> newMemberMap = new HashMap<String, String>(); boolean membershipErrors = false; //For each entry we must process the members and catalogue them for (Entry<String, List<String>> importedGroup : importedGroupMap.entrySet()) { StringJoiner nonExistingUsers = new StringJoiner(", "); StringJoiner nonMemberUsers = new StringJoiner(", "); StringJoiner existingMembers = new StringJoiner(", "); StringJoiner newMembers = new StringJoiner(", "); String groupTitle = importedGroup.getKey(); Optional<Group> existingGroupOptional = groupList.stream().filter(g -> groupTitle.equalsIgnoreCase(g.getTitle())).findAny(); // The UI shows a message if the group already exists. importedGroups.put(groupTitle, Boolean.valueOf(existingGroupOptional.isPresent())); List<String> importedGroupUsers = importedGroup.getValue(); //For every imported user, check if exists, if is member of the site, if already a member or is new. for (String userEid : importedGroupUsers) { Optional<User> userOptional = sakaiService.getUserByEid(userEid); // The user doesn't exist in Sakai. if (!userOptional.isPresent()) { nonExistingUsers.add(userEid); membershipErrors = true; continue; } User user = userOptional.get(); String userDisplayName = String.format("%s (%s)", user.getDisplayName(), user.getEid()); //The user is not a member of the site. if (site.getMember(user.getId()) == null) { nonMemberUsers.add(userDisplayName); membershipErrors = true; continue; } if (existingGroupOptional.isPresent()) { Group existingGroup = existingGroupOptional.get(); if (existingGroup.getMember(user.getId()) != null) { //The user is already member of the group existingMembers.add(userDisplayName); } else { //The user is not member of the group newMembers.add(userDisplayName); } } else { //The group does not exist so the user is new to that group newMembers.add(userDisplayName); } } //Add the catalogued users to the maps. nonExistingMemberMap.put(groupTitle, nonExistingUsers.toString()); nonMemberMap.put(groupTitle, nonMemberUsers.toString()); existingMemberMap.put(groupTitle, existingMembers.toString()); newMemberMap.put(groupTitle, newMembers.toString()); } //Fill the model model.addAttribute("importedGroups", importedGroups); model.addAttribute("membershipErrors", membershipErrors); model.addAttribute("nonExistingMemberMap", nonExistingMemberMap); model.addAttribute("nonMemberMap", nonMemberMap); model.addAttribute("existingMemberMap", existingMemberMap); model.addAttribute("newMemberMap", newMemberMap); //Serialize as json the group map to send it back to the controller after the confirmation. ObjectMapper objectMapper = new ObjectMapper(); String importedGroupMapJson = StringUtils.EMPTY; try { importedGroupMapJson = objectMapper.writer().writeValueAsString(importedGroupMap); } catch (JsonProcessingException e) { log.error("Fatal error serializing the imported group map.", e); } model.addAttribute("importedGroupMap", importedGroupMapJson); return GroupManagerConstants.IMPORT_CONFIRMATION_TEMPLATE; }
Example 13
Source Project: syncope File: AbstractPasswordRuleConf.java License: Apache License 2.0 | 4 votes |
public AbstractPasswordRuleConf() { this(StringUtils.EMPTY); setName(getClass().getName()); }
Example 14
Source Project: osmanthus File: RuleException.java License: Apache License 2.0 | 4 votes |
public RuleException() { super(StringUtils.EMPTY); this.code = INTERNAL_ERROR_CODE; this.msg = StringUtils.EMPTY; }
Example 15
Source Project: WiFiAnalyzer File: InRangePredicateTest.java License: GNU General Public License v3.0 | 4 votes |
private WiFiDetail makeWiFiDetail(int frequency) { WiFiSignal wiFiSignal = new WiFiSignal(frequency + 20, frequency, WiFiWidth.MHZ_20, -10, true); return new WiFiDetail("SSID", "BSSID", StringUtils.EMPTY, wiFiSignal, WiFiAdditional.EMPTY); }
Example 16
Source Project: azure-cosmosdb-java File: RxDocumentClientImpl.java License: MIT License | 4 votes |
public RxDocumentClientImpl(URI serviceEndpoint, String masterKeyOrResourceToken, List<Permission> permissionFeed, ConnectionPolicy connectionPolicy, ConsistencyLevel consistencyLevel, Configs configs) { this(serviceEndpoint, masterKeyOrResourceToken, connectionPolicy, consistencyLevel, configs); if (permissionFeed != null && permissionFeed.size() > 0) { this.resourceTokensMap = new HashMap<>(); for (Permission permission : permissionFeed) { String[] segments = StringUtils.split(permission.getResourceLink(), Constants.Properties.PATH_SEPARATOR.charAt(0)); if (segments.length <= 0) { throw new IllegalArgumentException("resourceLink"); } List<PartitionKeyAndResourceTokenPair> partitionKeyAndResourceTokenPairs = null; PathInfo pathInfo = new PathInfo(false, StringUtils.EMPTY, StringUtils.EMPTY, false); if (!PathsHelper.tryParsePathSegments(permission.getResourceLink(), pathInfo, null)) { throw new IllegalArgumentException(permission.getResourceLink()); } partitionKeyAndResourceTokenPairs = resourceTokensMap.get(pathInfo.resourceIdOrFullName); if (partitionKeyAndResourceTokenPairs == null) { partitionKeyAndResourceTokenPairs = new ArrayList<>(); this.resourceTokensMap.put(pathInfo.resourceIdOrFullName, partitionKeyAndResourceTokenPairs); } PartitionKey partitionKey = permission.getResourcePartitionKey(); partitionKeyAndResourceTokenPairs.add(new PartitionKeyAndResourceTokenPair( partitionKey != null ? partitionKey.getInternalPartitionKey() : PartitionKeyInternal.Empty, permission.getToken())); logger.debug("Initializing resource token map , with map key [{}] , partition key [{}] and resource token", pathInfo.resourceIdOrFullName, partitionKey != null ? partitionKey.toString() : null, permission.getToken()); } if(this.resourceTokensMap.isEmpty()) { throw new IllegalArgumentException("permissionFeed"); } String firstToken = permissionFeed.get(0).getToken(); if(ResourceTokenAuthorizationHelper.isResourceToken(firstToken)) { this.firstResourceTokenFromPermissionFeed = firstToken; } } }
Example 17
Source Project: cs-actions File: HttpClientTest.java License: Apache License 2.0 | 4 votes |
@Test public void execute_requestIsValid_success() throws Exception { //Arrange final String returnResult = "return result"; final String exception = StringUtils.EMPTY; final String statusCode = "status code"; final String responseHeaders = "response headers"; final String returnCode = "return code"; Map<String, String> rawResponse = new HashMap<>(); rawResponse.put(HttpClientOutputNames.RETURN_RESULT, returnResult); rawResponse.put(HttpClientOutputNames.EXCEPTION, exception); rawResponse.put(HttpClientOutputNames.STATUS_CODE, statusCode); rawResponse.put(HttpClientOutputNames.RESPONSE_HEADERS, responseHeaders); rawResponse.put(HttpClientOutputNames.RETURN_CODE, returnCode); HttpClientAction httpClientActionMock = PowerMockito.mock(HttpClientAction.class); PowerMockito.whenNew(HttpClientAction.class).withAnyArguments().thenReturn(httpClientActionMock); when(httpClientActionMock.execute(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(SerializableSessionObject.class), any(GlobalSessionObject.class))).thenReturn(rawResponse); HttpClientResponse.Builder httpClientResponseBuilderSpy = new HttpClientResponse.Builder(); httpClientResponseBuilderSpy = PowerMockito.spy(httpClientResponseBuilderSpy); when(httpClientResponseBuilderSpy.build()).thenReturn(null); PowerMockito.whenNew(HttpClientResponse.Builder.class).withAnyArguments().thenReturn(httpClientResponseBuilderSpy); //Act HttpClient.execute(httpRequestMock); //Assert verify(httpClientActionMock).execute(eq(url), eq(tlsVersion), eq(allowedCyphers), eq(authType), eq(preemptiveAuth.toString()), eq(username), eq(password), eq(kerberosConfigFile), eq(kerberosLoginConfFile), eq(kerberosSkipPortForLookup), eq(proxyHost), eq(proxyPort.toString()), eq(proxyUsername), eq(proxyPassword), eq(trustAllRoots.toString()), eq(x509HostnameVerifier), eq(trustKeystore), eq(trustPassword), eq(keystore), eq(keystorePassword), eq(connectTimeout.toString()), eq(socketTimeout.toString()), eq(useCookies.toString()), eq(keepAlive.toString()), eq(connectionsMaxPerRoute.toString()), eq(connectionsMaxTotal.toString()), eq(headers), eq(responseCharacterSet), eq(destinationFile.toAbsolutePath().toString()), eq(followedRedirects.toString()), eq(queryParams), eq(queryParamsAreURLEncoded.toString()), eq(queryParamsAreFormEncoded.toString()), eq(formParams), eq(formParamsAreURLEncoded.toString()), eq(sourceFile.toAbsolutePath().toString()), eq(body), eq(contentType), eq(requestCharacterSet), eq(multipartBodies), eq(multipartBodiesContentType), eq(multipartFiles), eq(multipartFilesContentType), eq(multipartValuesAreURLEncoded.toString()), eq(chunkedRequestEntity.toString()), eq(method), eq(httpClientCookieSession), eq(httpClientPoolingConnectionManager) ); verify(httpClientResponseBuilderSpy).returnResult(returnResult); verify(httpClientResponseBuilderSpy).exception(exception); verify(httpClientResponseBuilderSpy).statusCode(statusCode); verify(httpClientResponseBuilderSpy).responseHeaders(responseHeaders); verify(httpClientResponseBuilderSpy).returnCode(returnCode); }
Example 18
Source Project: cyberduck File: IRODSSession.java License: GNU General Public License v3.0 | 4 votes |
public URIEncodingIRODSAccount(final String user, final String password, final String home, final String region, final String resource) { super(host.getHostname(), host.getPort(), StringUtils.isBlank(user) ? StringUtils.EMPTY : user, password, home, region, resource); this.setUserName(user); }
Example 19
Source Project: AEM-Rules-for-SonarQube File: HtlStringOptionVisitor.java License: Apache License 2.0 | 4 votes |
@Override public String evaluate(PropertyAccess propertyAccess) { return StringUtils.EMPTY; }
Example 20
Source Project: lb-karaf-examples-jpa File: Item.java License: Apache License 2.0 | 4 votes |
public Item() { this(StringUtils.EMPTY,StringUtils.EMPTY); }