List of usage examples for org.apache.commons.lang3 StringUtils stripToEmpty
public static String stripToEmpty(final String str)
Strips whitespace from the start and end of a String returning an empty String if null input.
This is similar to #trimToEmpty(String) but removes whitespace.
From source file:nl.knaw.huygens.timbuctoo.model.neww.WWPerson.java
@Override public Map<String, String> getClientRepresentation() { Map<String, String> data = Maps.newTreeMap(); addItemToRepresentation(data, "id", getId()); String name = defaultName().getShortName(); addItemToRepresentation(data, "name", StringUtils.stripToEmpty(name).isEmpty() ? getTempName() : name); addItemToRepresentation(data, "gender", getGender()); addItemToRepresentation(data, "birthDate", getBirthDate() != null ? getBirthDate().getFromYear() : null); addItemToRepresentation(data, "deathDate", getDeathDate() != null ? getDeathDate().getFromYear() : null); addRelationToRepresentation(data, "residenceLocation", "hasResidenceLocation"); return data;//from w w w .j ava 2 s .com }
From source file:org.apache.falcon.entity.FeedHelper.java
public static String normalizePartitionExpression(String part1, String part2) { String partExp = StringUtils.stripToEmpty(part1) + "/" + StringUtils.stripToEmpty(part2); partExp = partExp.replaceAll("//+", "/"); partExp = StringUtils.stripStart(partExp, "/"); partExp = StringUtils.stripEnd(partExp, "/"); return partExp; }
From source file:org.drombler.acp.core.action.spi.MenuDescriptor.java
public static MenuDescriptor createMenuDescriptor(MenuType menuType, Bundle bundle) { return new MenuDescriptor(StringUtils.stripToNull(menuType.getId()), OSGiResourceBundleUtils.getPackageResourceStringPrefixed(menuType.getPackage(), menuType.getDisplayName(), bundle), StringUtils.stripToEmpty(menuType.getPath()), menuType.getPosition()); }
From source file:org.drombler.acp.core.action.spi.MenuEntryDescriptor.java
public static MenuEntryDescriptor createMenuEntryDescriptor(MenuEntryType menuEntryType) { return new MenuEntryDescriptor(StringUtils.stripToNull(menuEntryType.getActionId()), StringUtils.stripToEmpty(menuEntryType.getPath()), menuEntryType.getPosition()); }
From source file:org.drombler.acp.core.action.spi.ToggleMenuEntryDescriptor.java
public static ToggleMenuEntryDescriptor createRadioMenuEntryDescriptor(ToggleMenuEntryType menuEntryType) { return new ToggleMenuEntryDescriptor(StringUtils.stripToNull(menuEntryType.getActionId()), StringUtils.stripToNull(menuEntryType.getToggleGroupId()), StringUtils.stripToEmpty(menuEntryType.getPath()), menuEntryType.getPosition()); }
From source file:org.openehealth.ipf.commons.ihe.xua.BasicXuaProcessor.java
/** * Extracts ITI-40 XUA user name from the SAML2 assertion contained * in the given CXF message, and stores it in the ATNA audit dataset. * * @param message source CXF message. * @param headerDirection direction of the header containing the SAML2 assertion. * @param auditDataset target ATNA audit dataset. *///from w w w . j av a2s . co m public void extractXuaUserNameFromSaml2Assertion(SoapMessage message, Header.Direction headerDirection, WsAuditDataset auditDataset) { Assertion assertion = null; // check whether someone has already parsed the SAML2 assertion Object o = message.getContextualProperty(XUA_SAML_ASSERTION); if (o instanceof Assertion) { assertion = (Assertion) o; } // extract SAML assertion the from WS-Security SOAP header if (assertion == null) { Element assertionElem = extractAssertionElementFromCxfMessage(message, headerDirection); if (assertionElem == null) { assertionElem = extractAssertionElementFromDom(message); } if (assertionElem == null) { return; } Unmarshaller unmarshaller = SAML_UNMARSHALLER_FACTORY.getUnmarshaller(assertionElem); try { assertion = (Assertion) unmarshaller.unmarshall(assertionElem); } catch (UnmarshallingException e) { log.warn("Cannot extract SAML assertion from the WS-Security SOAP header", e); return; } message.getExchange().put(XUA_SAML_ASSERTION, assertion); } // set ATNA XUA userName element String userName = ((assertion.getSubject() != null) && (assertion.getSubject().getNameID() != null)) ? assertion.getSubject().getNameID().getValue() : null; String issuer = (assertion.getIssuer() != null) ? assertion.getIssuer().getValue() : null; if (StringUtils.isNoneEmpty(issuer, userName)) { String spProvidedId = StringUtils.stripToEmpty(assertion.getSubject().getNameID().getSPProvidedID()); auditDataset.setUserName(spProvidedId + '<' + userName + '@' + issuer + '>'); } // collect purposes of use, user role codes, and the patient ID for (AttributeStatement statement : assertion.getAttributeStatements()) { for (Attribute attribute : statement.getAttributes()) { if (PURPOSE_OF_USE_ATTRIBUTE_NAME.equals(attribute.getName())) { extractCodes(attribute, PURPOSE_OF_USE_ELEMENT_NAME, auditDataset.getPurposesOfUse()); } else if (SUBJECT_ROLE_ATTRIBUTE_NAME.equals(attribute.getName())) { extractCodes(attribute, SUBJECT_ROLE_ELEMENT_NAME, auditDataset.getUserRoles()); } else if (PATIENT_ID_ATTRIBUTE_NAME.equals(attribute.getName())) { List<XMLObject> attributeValues = attribute.getAttributeValues(); if ((attributeValues != null) && (!attributeValues.isEmpty()) && (attributeValues.get(0) != null) && (attributeValues.get(0).getDOM() != null)) { auditDataset.setXuaPatientId(attributeValues.get(0).getDOM().getTextContent()); } } } } }
From source file:org.xlrnet.metadict.core.util.FormatUtils.java
@NotNull private static String formatLanguage(@NotNull Language language) { String displayName = StringUtils.strip(language.getDisplayName()); String dialectDisplayName = StringUtils.stripToEmpty(language.getDialectDisplayName()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(WordUtils.capitalize(displayName)); if (StringUtils.isNotEmpty(dialectDisplayName)) stringBuilder.append(" (").append(WordUtils.capitalize(dialectDisplayName)).append(")"); return stringBuilder.toString(); }
From source file:org.xlrnet.metadict.web.resources.QueryResource.java
private Response internalExecuteQuery(@NotNull String dictionaryString, @NotNull String queryRequest, @Nullable String grouping, @Nullable String ordering, boolean bidirectional) { GroupingType groupingType = Enums/*from ww w . ja v a 2 s. com*/ .getIfPresent(GroupingType.class, StringUtils.stripToEmpty(grouping).toUpperCase()) .or(GroupingType.NONE); OrderType orderType = Enums.getIfPresent(OrderType.class, StringUtils.stripToEmpty(ordering).toUpperCase()) .or(OrderType.RELEVANCE); List<BilingualDictionary> dictionaries; try { dictionaries = BilingualDictionaryUtils.resolveDictionaries(dictionaryString, bidirectional); } catch (IllegalArgumentException e) { return Response .ok(new ResponseContainer<>(ResponseStatus.MALFORMED_QUERY, "Malformed dictionary query", null)) .build(); } catch (UnsupportedDictionaryException e) { return Response.ok(new ResponseContainer<>(ResponseStatus.ERROR, "Unsupported dictionary", null)) .build(); } if (dictionaries.size() == 0) return Response .ok(new ResponseContainer<>(ResponseStatus.ERROR, "No matching dictionaries found", null)) .build(); QueryResponse queryResponse; try { queryResponse = this.queryService .executeQuery(this.queryService.createNewQueryRequestBuilder().setQueryString(queryRequest) .setQueryDictionaries(dictionaries).setAutoDeriveMonolingualLanguages(true) .setGroupBy(groupingType).setOrderBy(orderType).build()); } catch (Exception e) { LOGGER.error("An internal core error occurred", e); return Response.ok(new ResponseContainer<>(ResponseStatus.INTERNAL_ERROR, "An internal error occurred: " + e.getMessage(), null)).build(); } return Response.ok(new ResponseContainer<>(ResponseStatus.OK, null, queryResponse)).build(); }