Java Code Examples for org.apache.commons.lang.StringUtils#isNotBlank()

The following examples show how to use org.apache.commons.lang.StringUtils#isNotBlank() . 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
/**
 * Verify multiple value lookup entries are authorized by user to add
 * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#addMultipleValueLookupResults(org.kuali.rice.kns.document.MaintenanceDocument, java.lang.String, java.util.Collection, boolean, org.kuali.rice.kns.bo.PersistableBusinessObject)
 */
@Override
public void addMultipleValueLookupResults(MaintenanceDocument document, String collectionName, Collection<PersistableBusinessObject> rawValues, boolean needsBlank, PersistableBusinessObject bo) {
    AssetLocationGlobal assetLocationGlobal = (AssetLocationGlobal) document.getDocumentBusinessObject();
    Collection<PersistableBusinessObject> allowedAssetsCollection = new ArrayList<PersistableBusinessObject>();
    final String maintDocTypeName =  CamsConstants.DocumentTypeName.ASSET_EDIT;
    GlobalVariables.getMessageMap().clearErrorMessages();
    for (PersistableBusinessObject businessObject : rawValues) {
        Asset asset = (Asset) businessObject;
        if (StringUtils.isNotBlank(maintDocTypeName)) {
            boolean allowsEdit = getBusinessObjectAuthorizationService().canMaintain(asset, GlobalVariables.getUserSession().getPerson(), maintDocTypeName);
            if (allowsEdit) {
                allowedAssetsCollection.add(asset);
            } else {
                GlobalVariables.getMessageMap().putErrorForSectionId(CamsConstants.AssetLocationGlobal.SECTION_ID_EDIT_LIST_OF_ASSETS, CamsKeyConstants.AssetLocationGlobal.ERROR_ASSET_AUTHORIZATION, new String[] { GlobalVariables.getUserSession().getPerson().getPrincipalName(), asset.getCapitalAssetNumber().toString() });
            }
        }
    }     
    super.addMultipleValueLookupResults(document, collectionName, allowedAssetsCollection, needsBlank, bo);
}
 
Example 2
Source Project: youkefu   File: XiaoEUKResultMapper.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
	long totalHits = response.getHits().totalHits();
	List<T> results = new ArrayList<T>();
	for (SearchHit hit : response.getHits()) {
		if (hit != null) {
			T result = null;
			if (StringUtils.isNotBlank(hit.sourceAsString())) {
				result = mapEntity(hit.sourceAsString() , hit , clazz);
			} else {
				result = mapEntity(hit.getFields().values() , hit , clazz);
			}
			setPersistentEntityId(result, hit.getId(), clazz);
			populateScriptFields(result, hit);
			results.add(result);
		}
	}

	return new AggregatedPageImpl<T>(results, pageable, totalHits);
}
 
Example 3
/**
 * {@inheritDoc}
 */
@Override
protected String getMessageRelativeUrl( HttpServletRequest request, String strMessageKey, Object [ ] messageArgs, String strTitleKey )
{
    // Fetch the upload filter site next url
    String strNextUrl = PortalJspBean.getUploadFilterSiteNextUrl( request );

    try
    {
        if ( StringUtils.isNotBlank( strNextUrl ) )
        {
            // If there is a next url from the session, then use this site message
            PortalJspBean.removeUploadFilterSiteNextUrl( request );
            SiteMessageService.setMessage( request, strMessageKey, messageArgs, strTitleKey, null, "", SiteMessage.TYPE_STOP, null, strNextUrl );
        }
        else
        {
            // Otherwise, use the old site message
            SiteMessageService.setMessage( request, strMessageKey, messageArgs, strTitleKey, null, "", SiteMessage.TYPE_STOP );
        }
    }
    catch( SiteMessageException lme )
    {
        return AppPathService.getSiteMessageUrl( request );
    }

    return null;
}
 
Example 4
/**
 * Manipulate fields for search criteria in order to get the results the user really wants.
 *
 * @param fieldValues
 * @return updated search criteria fieldValues
 */
protected Map<String, String> updateFieldValuesForSearchCriteria(Map<String, String> fieldValues) {
    Map<String, String> newFieldValues = new HashMap<>();
    newFieldValues.putAll(fieldValues);

    // Add wildcard character to start and end of accounts field so users can search for single account
    // within the delimited list of accounts without having to add the wildcards explicitly themselves.
    String accounts = newFieldValues.get(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS);
    if (StringUtils.isNotBlank(accounts)) {
        // only add wildcards if they haven't already been added (for some reason this method gets called twice when generating the pdf report)
        if (!StringUtils.startsWith(accounts, KFSConstants.WILDCARD_CHARACTER)) {
            accounts = KFSConstants.WILDCARD_CHARACTER + accounts;
        }
        if (!StringUtils.endsWith(accounts, KFSConstants.WILDCARD_CHARACTER)) {
            accounts += KFSConstants.WILDCARD_CHARACTER;
        }
    }
    newFieldValues.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS, accounts);

    // Increment to error date by one day so that the correct results are retrieved.
    // Since the error date is stored as both a date and time in the database records with an error date
    // the same as the error date the user enters on the search criteria aren't retrieved without this modification.
    String errorDate = newFieldValues.get(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ERROR_DATE_TO);

    int index = StringUtils.indexOf(errorDate, SearchOperator.LESS_THAN_EQUAL.toString());
    if (index == StringUtils.INDEX_NOT_FOUND) {
        index = StringUtils.indexOf(errorDate, SearchOperator.BETWEEN.toString());
        if (index != StringUtils.INDEX_NOT_FOUND) {
            incrementErrorDate(newFieldValues, errorDate, index);
        }
    } else {
        incrementErrorDate(newFieldValues, errorDate, index);
    }

    return newFieldValues;
}
 
Example 5
protected Map<String, String> getLookupParameters(Document dom, Element configElement, EDLContext edlContext) {
	String lookupParameterDefinition = retrieveLookupParametersString(dom, configElement, edlContext);
	if (StringUtils.isBlank(lookupParameterDefinition)) {
		return Collections.emptyMap();
	}
	StringTokenizer tok = new StringTokenizer(lookupParameterDefinition, ",");
	Map<String, String> lookupParameters = new HashMap<String, String>();
	
	// where all of the field values are stored
	Element currentVersion = VersioningPreprocessor.findCurrentVersion(dom);
	
	while (tok.hasMoreTokens()) {
		String parameterDefinition = tok.nextToken();
		int colonInd = parameterDefinition.indexOf(':');
		if (colonInd == -1) {
			throw new WorkflowRuntimeException("Lookup definition string improperly formatted " + lookupParameterDefinition);
		}
		
		String parameterName = parameterDefinition.substring(colonInd + 1);
		String parameterValuePropertyName = parameterDefinition.substring(0, colonInd);

           XPath xPath = edlContext.getXpath();
           try {
               String parameterValue = xPath.evaluate("//field[@name='" + parameterValuePropertyName + "']/value", currentVersion);
               if (LOG.isDebugEnabled()) {
                   LOG.debug(XmlJotter.jotNode(currentVersion, true));
               }
			if (StringUtils.isNotBlank(parameterValue)) {
				lookupParameters.put(parameterName, parameterValue);
			}
		} catch (XPathExpressionException e) {
			throw new WorkflowRuntimeException(e);
		}
	}
	return lookupParameters;
}
 
Example 6
/**
 * Encode query params of the call back url one by one.
 *
 * @param queryParams String of query params.
 * @return map of the encoded query params.
 */
public static Map<String,String> getEncodedQueryParamMap(String queryParams) {

    Map<String, String> encodedQueryMap = new HashMap<>();
    if (StringUtils.isNotBlank(queryParams)) {
        encodedQueryMap = Arrays.stream(queryParams.split(SPLITTING_CHAR))
                .map(entry -> entry.split(PADDING_CHAR))
                .collect(Collectors.toMap(entry -> Encode.forUriComponent(entry[0]),
                        entry -> Encode.forUriComponent(entry[1])));
    }

    return encodedQueryMap;
}
 
Example 7
@RequestMapping(value = "/resume")
public String resume(HttpServletRequest request,
                    HttpServletResponse response, Model model) {
    String name = request.getParameter("name");
    String group = request.getParameter("group");
    if (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(group)) {
        schedulerCenter.resumeTrigger(new TriggerKey(name, group));
    }
    return "redirect:/manage/quartz/list";
}
 
Example 8
@Override
public Object convertToDto(final Object object, final BeanFactory beanFactory) {

    final ProductTypeAttrDTO dto = (ProductTypeAttrDTO) object;
    final VoProductTypeAttrNavigationRanges ranges = new VoProductTypeAttrNavigationRanges();
    if (StringUtils.isNotBlank(dto.getRangeNavigation())) {
        final List<VoProductTypeAttrNavigationRange> voRanges = new ArrayList<>();
        final RangeList rangeList = xStreamProvider.fromXML(dto.getRangeNavigation());
        if (rangeList.getRanges() != null) {
            for (final RangeNode item : rangeList.getRanges()) {
                final VoProductTypeAttrNavigationRange range = new VoProductTypeAttrNavigationRange();
                range.setRange(item.getFrom().concat("-").concat(item.getTo()));
                final List<DisplayValue> displayValues = item.getI18n();
                final List<MutablePair<String, String>> names = new ArrayList<>();
                if (displayValues != null) {
                    for (final DisplayValue displayValue : displayValues) {
                        names.add(MutablePair.of(displayValue.getLang(), displayValue.getValue()));
                    }
                }
                if (!names.isEmpty()) {
                    range.setDisplayVals(names);
                }
                voRanges.add(range);
            }
        }
        if (!voRanges.isEmpty()) {
            ranges.setRanges(voRanges);
        }
    }
    return ranges;
}
 
Example 9
Source Project: sofa-acts   File: ConfigrationFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Load the configuration from the configuration file.
 *
 * default the ats-config.properties file is chosen.
 */
public static void loadFromConfig(String confName) {
    if (log.isInfoEnabled()) {
        log.info("loading configuration [" + confName + "]");
    }

    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();

    URL atsConfigUrl = currentClassLoader.getResource(confName);

    if (atsConfigUrl == null) {
        log.error("can not find ats config [" + confName + "]!");
        return;
    }

    Properties atsProperties = new Properties();
    try {
        atsProperties.load(atsConfigUrl.openStream());
    } catch (Exception e) {
        log.error("can not find ats config [" + confName + "] details [" + e.getMessage() + "]");
        return;
    }

    Set<Map.Entry<Object, Object>> entrySet = atsProperties.entrySet();
    for (Map.Entry<Object, Object> entry : entrySet) {
        Object keyObject = entry.getKey();
        Object valueObject = entry.getValue();
        String envConfigValue = System.getProperty(ATS_CONFIG_SYSENV_PREFIX
                                                   + keyObject.toString());
        if (StringUtils.isNotBlank(envConfigValue)) {
            configImpl.setProperty(keyObject.toString(), envConfigValue);
        } else {
            configImpl.setProperty(keyObject.toString(), valueObject.toString());
        }
    }
}
 
Example 10
Source Project: carbon-identity   File: SCIMUserManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the full group with all the details including users.
 *
 * @param groupName
 * @return
 * @throws CharonException
 * @throws org.wso2.carbon.user.core.UserStoreException
 * @throws IdentitySCIMException
 */
private Group getGroupWithName(String groupName)
        throws CharonException, org.wso2.carbon.user.core.UserStoreException,
        IdentitySCIMException {

    String userStoreDomainName = IdentityUtil.extractDomainFromName(groupName);
    if(!isInternalOrApplicationGroup(userStoreDomainName) && StringUtils.isNotBlank(userStoreDomainName) &&
            !isSCIMEnabled(userStoreDomainName)){
        throw new CharonException("Cannot retrieve group through scim to user store " + ". SCIM is not " +
                "enabled for user store " + userStoreDomainName);
    }

    Group group = new Group();
    group.setDisplayName(groupName);
    String[] userNames = carbonUM.getUserListOfRole(groupName);

    //get the ids of the users and set them in the group with id + display name
    if (userNames != null && userNames.length != 0) {
        for (String userName : userNames) {
            String userId = carbonUM.getUserClaimValue(userName, SCIMConstants.ID_URI, null);
            group.setMember(userId, userName);
        }
    }
    //get other group attributes and set.
    SCIMGroupHandler groupHandler = new SCIMGroupHandler(carbonUM.getTenantId());
    group = groupHandler.getGroupWithAttributes(group, groupName);
    return group;
}
 
Example 11
private String replace(String json,String url,String userName,String passWord,String column){
    if(StringUtils.isNotBlank(url)){
        json = json.replaceAll(FlinkerJobConfigConstant.JDBCURL, url);
    }
    if(StringUtils.isNotBlank(userName)){
        json = json.replaceAll(FlinkerJobConfigConstant.USERNAME,userName);
    }
    if(StringUtils.isNotBlank(passWord)){
        json = json.replaceAll(FlinkerJobConfigConstant.PASSWORD,passWord);
    }
    if(StringUtils.isNotBlank(column)){
        json = json.replaceAll(FlinkerJobConfigConstant.COLUMN,column);
    }
    return json;
}
 
Example 12
Source Project: das   File: SelectCoditonBuilder.java    License: Apache License 2.0 5 votes vote down vote up
public SelectCoditonBuilder likeRight(String key, String val) {
    if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)) {
        val = val.trim();
        and().append(TAB + key, "like '%" + val + "'");
    }
    return this;
}
 
Example 13
@Nullable
@Override
public SuggestedNameInfo getSuggestedNames(PsiElement psiElement, PsiElement psiElement1, Set<String> set) {

    if(!(psiElement instanceof Parameter)) {
        return null;
    }

    List<String> filter = ContainerUtil.filter(PhpNameSuggestionUtil.variableNameByType((Parameter) psiElement, psiElement.getProject(), false), s -> !StringUtil.containsChar(s, '\\'));

    if(filter.size() == 0) {
        return null;
    }

    for (String item : filter) {

        for(String end: TRIM_STRINGS) {

            // ending
            if(item.toLowerCase().endsWith(end)) {
                item = item.substring(0, item.length() - end.length());
            }

            // remove starting
            if(item.toLowerCase().startsWith(end)) {
                item = WordUtils.uncapitalize(item.substring(end.length()));
            }
        }

        if(StringUtils.isNotBlank(item)) {
            set.add(item);
        }
    }

    return null;
}
 
Example 14
public CallType(String value) {
    this();
    if (StringUtils.isNotBlank(value)) {
        String[] elements = value.split(SEPARATOR);
        if (elements.length == 2) {
            callDetails.put(DEST_NUM, new StringType(elements[1]));
            callDetails.put(ORIG_NUM, new StringType(elements[0]));
        }
    }
}
 
Example 15
public static String redColorLabelHtml(String msg){
	if(StringUtils.isNotBlank(msg)){
		return String.format("<html><font style='color:red'>%s</font></html>", msg);
	}
	return null;
}
 
Example 16
@SuppressWarnings("serial")
public void init(final Set<AuftragsPositionVO> orderPositions)
{
  final RepeatingView positionsRepeater = new RepeatingView("pos");
  add(positionsRepeater);
  if (orderPositions != null) {
    final Iterator<AuftragsPositionVO> it = orderPositions.iterator();
    int orderNumber = -1;
    StringBuffer buf = new StringBuffer();
    Link<String> link = null;
    BigDecimal totalPersonDays = BigDecimal.ZERO;
    AuftragsPositionVO previousOrderPosition = null;
    while (it.hasNext() == true) {
      final AuftragsPositionVO orderPosition = it.next();
      if (orderPosition.getAuftragNummer() != null && orderNumber != orderPosition.getAuftragNummer().intValue()) {
        orderNumber = orderPosition.getAuftragNummer();
        final WebMarkupContainer item = new WebMarkupContainer(positionsRepeater.newChildId());
        positionsRepeater.add(item);
        final Label separatorLabel = new Label("separator", ", ");
        if (previousOrderPosition != null) {
          // Previous order position finished.
          addTitleAttribute(link, previousOrderPosition, totalPersonDays, buf);
          buf = new StringBuffer();
          totalPersonDays = BigDecimal.ZERO;
        } else {
          separatorLabel.setVisible(false); // Invisible for first entry.
        }
        previousOrderPosition = orderPosition;
        item.add(separatorLabel);
        link = new Link<String>("link") {
          @Override
          public void onClick()
          {
            final PageParameters params = new PageParameters();
            params.add(AbstractEditPage.PARAMETER_KEY_ID, String.valueOf(orderPosition.getAuftragId()));
            final AuftragEditPage page = new AuftragEditPage(params);
            page.setReturnToPage((AbstractSecuredPage) getPage());
            setResponsePage(page);
          };
        };
        item.add(link);
        link.add(new Label("label", String.valueOf(orderPosition.getAuftragNummer())));
      } else {
        buf.append("\n");
      }
      buf.append("#").append(orderPosition.getNumber()).append(" (");
      if (orderPosition.getPersonDays() != null) {
        buf.append(NumberFormatter.format(orderPosition.getPersonDays()));
        totalPersonDays = totalPersonDays.add(orderPosition.getPersonDays());
      } else {
        buf.append("??");
      }
      final String title = StringUtils.defaultString(orderPosition.getTitel());
      buf.append(" ").append(getString("projectmanagement.personDays.short")).append("): ").append(title);
      if (orderPosition.getStatus() != null) {
        if (StringUtils.isNotBlank(title) == true) {
          buf.append(", ");
        }
        buf.append(getString(orderPosition.getStatus().getI18nKey()));
      }
      if (it.hasNext() == false && link != null) {
        addTitleAttribute(link, orderPosition, totalPersonDays, buf);
      }
    }
  }
}
 
Example 17
Source Project: ranger   File: RangerPluginInfo.java    License: Apache License 2.0 4 votes vote down vote up
@JsonIgnore
public Long getLastPolicyUpdateTime() {
	String updateTimeString = getInfo().get(RANGER_ADMIN_LAST_POLICY_UPDATE_TIME);
	return StringUtils.isNotBlank(updateTimeString) ? Long.valueOf(updateTimeString) : null;
}
 
Example 18
/**
 * This API is used to send password recovery confirmation over defined channels like email/sms
 *
 * @param recoveryInitiatingRequest It can be sent optional property parameters over email based on email template. (required)
 * @param type                      Notification Type (optional)
 * @param notify                    If notify&#x3D;true then, notifications will be internally managed. (optional)
 * @return String
 * @throws ApiException if fails to make API call
 */
public String recoverPasswordPost(RecoveryInitiatingRequest recoveryInitiatingRequest, String type, Boolean notify) throws ApiException {
    Object localVarPostBody = recoveryInitiatingRequest;

    // verify the required parameter 'recoveryInitiatingRequest' is set
    if (recoveryInitiatingRequest == null) {
        throw new ApiException(400, "Missing the required parameter 'recoveryInitiatingRequest' when calling recoverPasswordPost");
    }

    String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    if (StringUtils.isNotBlank(recoveryInitiatingRequest.getUser().getTenantDomain())) {
        tenantDomain = recoveryInitiatingRequest.getUser().getTenantDomain();
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/recover-password".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "type", type));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "notify", notify));


    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<String> localVarReturnType = new GenericType<String>() {
    };
    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 19
/**
 * This simple initial implementation just calls  
 * {@link #getRoleMembersFromApplicationRole(String, String, Map<String, String>)} and checks the results.
 *
 */
   @Override
public boolean hasDerivedRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, Map<String, String> qualification) {
    if (StringUtils.isBlank(principalId)) {
           throw new RiceIllegalArgumentException("principalId was null or blank");
       }

       if (groupIds == null) {
           throw new RiceIllegalArgumentException("groupIds was null or blank");
       }

       if (StringUtils.isBlank(namespaceCode)) {
           throw new RiceIllegalArgumentException("namespaceCode was null or blank");
       }

       if (StringUtils.isBlank(roleName)) {
           throw new RiceIllegalArgumentException("roleName was null or blank");
       }

       if (qualification == null) {
           throw new RiceIllegalArgumentException("qualification was null or blank");
       }

       if ( !isDerivedRoleType() ) {
		throw new UnsupportedOperationException( this.getClass().getName() + " is not an application role." );
	}
	// if principal ID given, check if it is in the list generated from the getPrincipalIdsFromApplicationRole method
	if ( StringUtils.isNotBlank( principalId ) ) {
	    List<RoleMembership> members = getRoleMembersFromDerivedRole(namespaceCode, roleName, qualification);
	    for ( RoleMembership rm : members ) {
	    	if ( StringUtils.isBlank( rm.getMemberId() ) ) {
	    		continue;
	    	}
	        if ( MemberType.PRINCIPAL.equals(rm.getType()) ) {
	            if ( rm.getMemberId().equals( principalId ) ) {
	                return true;
	            }
	        } else { // groups
	            if ( groupIds != null 
	                    && groupIds.contains(rm.getMemberId())) {
	                return true;
	            }
	        }
		}
	}
	return false;
}
 
Example 20
/**
 * Retrieves a {@code View} instance that is of the given type based on
 * the index key
 *
 * @param viewTypeName - type name for the view
 * @param indexKey - Map of index key parameters, these are the parameters the
 * indexer used to index the view initially and needs to identify
 * an unique view instance
 * @return View instance that matches the given index or Null if one is not
 *         found
 */
public View getViewByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey) {
    String viewId = getViewIdByTypeIndex(viewTypeName, indexKey);
    if (StringUtils.isNotBlank(viewId)) {
        return getViewById(viewId);
    }

    return null;
}