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

The following are Jave code examples for showing how to use equals() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: AuthoringAction.java   View Source Code Vote up 6 votes
private ActionMessages validate(AuthoringForm sbmtForm, ActionMapping mapping, HttpServletRequest request) {
ActionMessages errors = new ActionMessages();
// if (StringUtils.isBlank(sbmtForm.getTitle())) {
// ActionMessage error = new ActionMessage("error.title.blank");
// errors.add(ActionMessages.GLOBAL_MESSAGE, error);
// }
// define it later mode(TEACHER) skip below validation.
String modeStr = request.getParameter(AttributeNames.ATTR_MODE);
if (StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())) {
    return errors;
}

// Some other validation outside basic Tab.

return errors;
   }
 
Example 2
Project: kaltura-ce-sakai-extension   File: KalturaAPIServiceStub.java   View Source Code Vote up 6 votes
@Override
protected Map<String, Map<String, String>> getPlaylistMetadataFields(String... playlistIds) {
    HashMap<String, Map<String, String>> m;
    if (playlistIds == null) {
        throw new IllegalArgumentException("playlistIds must not be null or empty");
    } else if (playlistIds.length == 0) {
        m = new HashMap<String, Map<String, String>>(0);
    } else {
        m = new HashMap<String, Map<String, String>>(playlistIds.length);
        for (String playlistId : playlistIds) {
            Map<String, String> metadata = new LinkedHashMap<String, String>();
            for (MediaCollection mc : mockCollections) {
                if (StringUtils.equals(mc.getIdStr(), playlistId)) {
                    metadata = mc.extractMetadataMap();
                    break;
                }
            }
            m.put(playlistId, metadata);
        }
    }
    return m;
}
 
Example 3
Project: kaltura-ce-sakai-extension   File: KalturaAPIServiceStub.java   View Source Code Vote up 6 votes
@Override
public KalturaPlaylist getPlaylistByPlaylistId(String playlistId) {
    if (StringUtils.isEmpty(playlistId)) {
        throw new IllegalArgumentException("playlist id must be set");
    }
    KalturaPlaylist playlist = null;
    for (MediaCollection mc : mockCollections) {
        if (StringUtils.equals(mc.getId(), playlistId)) {
            playlist = makeSamplePlaylist(mc);
            break;
        }
    }
    return playlist;
}
 
Example 4
Project: lams   File: AssessmentForm.java   View Source Code Vote up 6 votes
@Override
   public void reset(ActionMapping mapping, HttpServletRequest request) {
String param = mapping.getParameter();
// if it is start page, all data read out from database or current session
// so need not reset checkbox to refresh value!
if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) {
    assessment.setAllowGradesAfterAttempt(false);
    assessment.setAllowOverallFeedbackAfterQuestion(false);
    assessment.setAllowQuestionFeedback(false);
    assessment.setAllowRightAnswersAfterQuestion(false);
    assessment.setAllowWrongAnswersAfterQuestion(false);
    assessment.setDefineLater(false);
    assessment.setShuffled(false);
    assessment.setNumbered(false);
    assessment.setDisplaySummary(false);
    assessment.setReflectOnActivity(false);
}
   }
 
Example 5
Project: dble   File: FilterJoinColumnPusher.java   View Source Code Vote up 6 votes
/**
 * is ER Filter: 1.Filter must be equal(=) 2.Filter must be Column = Column
 * 3.Filter's key and value must be belong different table ex:a.id=b.id true a.id=b.id+1 false
 */
private static boolean isPossibleERJoinColumnFilter(PlanNode node, Item ifilter) {
    if (!(ifilter instanceof ItemFuncEqual))
        return false;
    ItemFuncEqual filter = (ItemFuncEqual) ifilter;
    Item column = filter.arguments().get(0);
    Item value = filter.arguments().get(1);
    if (column != null && column instanceof ItemField && value != null && value instanceof ItemField) {
        Pair<TableNode, ItemField> foundColumn = PlanUtil.findColumnInTableLeaf((ItemField) column, node);
        Pair<TableNode, ItemField> foundValue = PlanUtil.findColumnInTableLeaf((ItemField) value, node);
        if (foundColumn != null && foundValue != null) {
            String columnTable = foundColumn.getValue().getTableName();
            String valueTable = foundValue.getValue().getTableName();
            // the table must be different
            return !StringUtils.equals(columnTable, valueTable);
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
Example 6
Project: Hydrograph   File: OutputAdditionalParametersWidget.java   View Source Code Vote up 5 votes
private boolean isAnyUpdate(Map<String, Object> oldMap, Map<String, Object> newMap) {
	for(Entry< String , Object> entry:oldMap.entrySet()){
		if(!StringUtils.equals((String)newMap.get(entry.getKey()), (String)entry.getValue())){
			return true;
		}
	}
	return false;
}
 
Example 7
Project: ymate-module-oauth   File: OAuth.java   View Source Code Vote up 5 votes
@Override
public IOAuthAccessResourceHelper resourceHelper(final String accessToken, final String openId) throws Exception {
    return new IOAuthAccessResourceHelper() {

        private OAuthClientUser _clientUserVO = __moduleCfg.getTokenStorageAdapter().findUserByAccessToken(accessToken);

        @Override
        public OAuthClient getOAuthClient() {
            throw new UnsupportedOperationException();
        }

        @Override
        public OAuthClientUser getOAuthClientUser() {
            return _clientUserVO;
        }

        @Override
        public boolean isExpiredAccessToken() {
            return System.currentTimeMillis() - _clientUserVO.getLastModifyTime() >= _clientUserVO.getExpiresIn() * 1000;
        }

        @Override
        public boolean checkAccessToken() {
            return _clientUserVO != null && (!StringUtils.isNotBlank(openId) || StringUtils.equals(_clientUserVO.getId(), openId));
        }

        @Override
        public boolean checkScope(String scope) {
            return StringUtils.contains(_clientUserVO.getScope(), scope);
        }
    };
}
 
Example 8
Project: Hydrograph   File: HiveFieldDialogHelper.java   View Source Code Vote up 5 votes
/**
 * 
 * Compares available fields and selected partition key fields for 
 *   hive input and output components. 
 * 
 */
public boolean compare_fields(TableItem[] items,List<String> sourceFieldsList)
{
	ListIterator<String> t_itr,s_itr;
	boolean is_equal=true;
	
	List<String> target_fields = new ArrayList<String>();
	if(items.length > 0){
		for (TableItem tableItem : items){
			target_fields.add((String) tableItem.getText());
		}
	
	
	List<String> source_field = new ArrayList<String>(sourceFieldsList);
	
	t_itr=target_fields.listIterator(target_fields.size());
	s_itr = source_field.listIterator(source_field.size());
	
	
	while(t_itr.hasPrevious() & s_itr.hasPrevious()){
		if(StringUtils.equals(s_itr.previous(),t_itr.previous())){
			is_equal=true;
		}
		else{
			is_equal=false;
			break;
		}
	}
	}
	return is_equal;
	
}
 
Example 9
Project: kaltura-ce-sakai-extension   File: MediaService.java   View Source Code Vote up 5 votes
/**
 * Saves or updates a large set of items in a location in a single transaction
 * 
 * @param locationId [OPTIONAL] if null or empty then the location in the items/collections are used, 
 *     if set then this overrides any location in the items or collections
 * @param library the items to save in the library for the location
 * @param collections the collections (and items within) to save in the location (this will not remove items)
 * @return the results of the save operation
 * @throws IllegalArgumentException if the locationId is not set AND the item/collection location ids are also not set
 */
public SaveResults saveInLocation(String locationId, Collection<MediaItem> library, Collection<MediaCollection> collections) {
    if (log.isDebugEnabled()) {
        log.debug("saveInLocation(locationId=" + locationId + ", library, collections)");
    }
    // set SaveResults data
    SaveResults saveResults = new SaveResults();
    saveResults.locationId = locationId;
    saveResults.collectionsCount = collections.size();
    saveResults.itemsCount = library.size();
    saveResults.libraryItems = (List<MediaItem>) library;
    saveResults.collections = (List<MediaCollection>) collections;
    // save each collection as a playlist with entries
    for (MediaCollection mc : collections) {
        List<String> entryIds = new ArrayList<String>();
        Map<String, Map<String, String>> metadata = new LinkedHashMap<String, Map<String, String>>();
        for (MediaItem mi : library) {
            // only add items that are members of the collection
            if (StringUtils.equals(mc.getIdStr(), mi.getCollectionId())) {
                String entryId = mi.getKalturaId();
                entryIds.add(entryId);
                metadata.put(entryId, mi.extractMetaDataMap());
            }
        }
        // update each playlist with the entries and metadata
        kalturaAPIService.saveUpdatedKalturaPlaylist(mc.getKalturaPlaylist());
        kalturaAPIService.updateKalturaPlaylistEntries(mc.getKalturaPlaylist(), entryIds, false, metadata);
    }
    return saveResults;
}
 
Example 10
Project: Hydrograph   File: ELTGraphicalEditor.java   View Source Code Vote up 5 votes
private void setMainGraphDirty(boolean dirty) {
	if(container.getLinkedMainGraphPath()!=null && container.isCurrentGraphSubjob()){
		for(IEditorReference editorReference:PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()){
			if(StringUtils.equals(editorReference.getTitleToolTip(), container.getLinkedMainGraphPath())){
				if(editorReference.getEditor(false) instanceof ELTGraphicalEditor);
				((ELTGraphicalEditor)editorReference.getEditor(false)).setDirty(true);
			}
		}
		
	}
}
 
Example 11
Project: Hydrograph   File: CustomEditActionProvider.java   View Source Code Vote up 5 votes
private ActionContributionItem getPasteContribution(IContributionItem[] items) {
	for (IContributionItem contributionItem : items) {
		if (StringUtils.equals(contributionItem.getId(),PASTE_ACTION_ID)) {
			return (ActionContributionItem) contributionItem;
		}
	}
	return null;
}
 
Example 12
Project: jfrog-idea-plugin   File: ComponentDetailImpl.java   View Source Code Vote up 5 votes
@Override
public boolean equals(Object obj) {
    if (obj == null || obj.getClass() != getClass()) {
        return false;
    }
    return StringUtils.equals(toString(), obj.toString());
}
 
Example 13
Project: Hydrograph   File: DropDownWidget.java   View Source Code Vote up 5 votes
@Override
public boolean isWidgetValid() {
		if(StringUtils.equals(combo.getText(), Constants.PARAMETER))
		{	
		 return validateAgainstValidationRule(text.getText());
		}
		return true;
}
 
Example 14
Project: hadoop   File: QueueCapacities.java   View Source Code Vote up 5 votes
public float getCapacity(String label) {
  if (StringUtils.equals(label, RMNodeLabelsManager.NO_LABEL) && isRoot) {
    return 1f;
  }
  
  return _get(label, CapacityType.CAP);
}
 
Example 15
Project: lams   File: SpreadsheetForm.java   View Source Code Vote up 5 votes
@Override
   public void reset(ActionMapping mapping, HttpServletRequest request) {
String param = mapping.getParameter();
//if it is start page, all data read out from database or current session
//so need not reset checkbox to refresh value!
if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) {
    spreadsheet.setLockWhenFinished(false);
    spreadsheet.setDefineLater(false);
    spreadsheet.setLearnerAllowedToSave(true);
    spreadsheet.setMarkingEnabled(false);
    spreadsheet.setReflectOnActivity(false);
}
   }
 
Example 16
Project: Hydrograph   File: SchemaPropagation.java   View Source Code Vote up 5 votes
/**
 * This method propagates component's schema-map to its successor components.
 * Made for External Schema updater
 * 
 * @param component
 * @param schemaMap
 * @param isExtrenalSchemaUpdator
 */
public void continuousSchemaPropagation(Component component, Map<String, ComponentsOutputSchema> schemaMap, boolean isExternalSchemaUpdator) {
	LOGGER.debug("Initiating recursive schema propagation");

	if (component != null && schemaMap != null)
		if (StringUtils.equals(Constants.SUBJOB_COMPONENT_CATEGORY, component.getCategory()))
			appplySchemaToTargetComponentsFromSchemaMap(component, schemaMap, Constants.FIXED_OUTSOCKET_ID, isExternalSchemaUpdator);
		else
			appplySchemaToTargetComponentsFromSchemaMap(component, schemaMap, null, isExternalSchemaUpdator);

	flushLinkLists();
}
 
Example 17
Project: dble   File: ItemField.java   View Source Code Vote up 5 votes
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (!(obj instanceof ItemField))
        return false;
    ItemField other = (ItemField) obj;
    return StringUtils.equals(getTableName(), other.getTableName()) &&
            StringUtils.equalsIgnoreCase(getItemName(), other.getItemName());
}
 
Example 18
Project: Hydrograph   File: CommentBoxEditor.java   View Source Code Vote up 5 votes
private void validateAndCloseCommentEditor(StyledText styledText) {
	commentFigure.setText(styledText.getText(),commentBoxModel);

	if (!StringUtils.equals(styledText.getText(), commentBoxModel.getLabelContents())) {
		commentBoxModel.setLabelContents(styledText.getText());
		((ELTGraphicalEditor) commentFigure.getComponentCanvas()).setDirty(true);
	}

	shell.close();
}
 
Example 19
Project: Yidu   File: RegisterAction.java   View Source Code Vote up 4 votes
/**
 * 用户注册
 * 
 * @return 显示页面
 */
@Transactional
public String register() {
    logger.info("RegisterAction register started.");
    // 密码检查
    if (!StringUtils.equals(password, repassword)) {
        addActionError(getText("errors.repassword"));
        return FREEMARKER;
    }

    userService.lockTUser();

    // 重复检查
    UserSearchBean searchBean = new UserSearchBean();
    searchBean.setLoginid(loginid);
    searchBean.setDeleteflag(false);
    List<TUser> userList = this.userService.find(searchBean);
    if (Utils.isDefined(userList)) {
       addActionError(this.getText("errors.duplicated", new String[] { this.getText("label.user.loginid") }));
        return FREEMARKER;
    }

    // 邮箱重复检查
    searchBean = new UserSearchBean();
    searchBean.setEmail(email);
    searchBean.setDeleteflag(false);
    userList = this.userService.find(searchBean);
    if (Utils.isDefined(userList)) {
        addActionError(this.getText("errors.duplicated", new String[] { this.getText("label.user.email") }));
        return FREEMARKER;
    }

    TUser user = new TUser();
    BeanUtils.copyProperties(this, user);
    user.setDeleteflag(false);
    user.setRegdate(new Date());
    user.setPassword(Utils.convert2MD5(password));
    user.setType(YiDuConstants.UserType.NORMAL_USER);
    user.setModifytime(new Date());

    // 是否开启邮箱验证
    if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_MAIL_AUTH, false)) {
        // 开启的话发邮件结束
        MailUtils.sendMail(email, getText("reg.mail.title", new String[] { getText("label.system.name") }),
                creatContent(), false);
        addActionMessage(getText("message.mail.auth"));
        user.setMailtoken(Utils.convert2MD5(loginid + password + email));
        user.setActivedflag(false);
        // 注册用户登录
        this.userService.save(user);

        return FREEMARKER_MESSAGE;
    } else {

        user.setActivedflag(true);
        // 注册用户登录
        this.userService.save(user);
        // 未开启的话,直接登录
        LoginManager.doLogin(user);
        // 登录处理
        logger.debug("RegisterAction register normally end.");
        return REDIRECT;
    }
}
 
Example 20
Project: Hydrograph   File: Component.java   View Source Code Vote up 4 votes
/**
 * Validates all the properties of component and updates its validity status accordingly.
 *  
 * @return properties 
 */
public Map<String, Object> validateComponentProperties(boolean isJobImported) {
	boolean componentHasRequiredValues = Boolean.TRUE;
	hydrograph.ui.common.component.config.Component component = XMLConfigUtil.INSTANCE.getComponent(this.getComponentName());
	Map<String, Object> properties=this.properties;
	for (Property configProperty : component.getProperty()) {
		Object propertyValue = properties.get(configProperty.getName());
		
		List<String> validators = ComponentCacheUtil.INSTANCE.getValidatorsForProperty(this.getComponentName(), configProperty.getName());
		
		IValidator validator = null;
		for (String validatorName : validators) {
			try {
				validator = (IValidator) Class.forName(Constants.VALIDATOR_PACKAGE_PREFIX + validatorName).newInstance();
			} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
				logger.error("Failed to create validator", e);
				throw new RuntimeException("Failed to create validator", e);
			}
			boolean status = validator.validate(propertyValue, configProperty.getName(),new SchemaData().getInputSchema(this),
					isJobImported);
			//NOTE : here if any of the property is not valid then whole component is not valid 
			if(status == false){
				componentHasRequiredValues = Boolean.FALSE;
			}
		}
	}
	
	if (!componentHasRequiredValues && properties.get(Component.Props.VALIDITY_STATUS.getValue()) == null)
		properties.put(Component.Props.VALIDITY_STATUS.getValue(), Component.ValidityStatus.WARN.name());
	else if (!componentHasRequiredValues
			&& StringUtils.equals((String) properties.get(Component.Props.VALIDITY_STATUS.getValue()),
					Component.ValidityStatus.WARN.name()))
		properties.put(Component.Props.VALIDITY_STATUS.getValue(), Component.ValidityStatus.WARN.name());
	else if (!componentHasRequiredValues
			&& StringUtils.equals((String) properties.get(Component.Props.VALIDITY_STATUS.getValue()),
					Component.ValidityStatus.ERROR.name()))
		properties.put(Component.Props.VALIDITY_STATUS.getValue(), Component.ValidityStatus.ERROR.name());
	else if (!componentHasRequiredValues
			&& StringUtils.equals((String) properties.get(Component.Props.VALIDITY_STATUS.getValue()),
					Component.ValidityStatus.VALID.name()))
		properties.put(Component.Props.VALIDITY_STATUS.getValue(), Component.ValidityStatus.ERROR.name());
	else if (componentHasRequiredValues)
		properties.put(Component.Props.VALIDITY_STATUS.getValue(), Component.ValidityStatus.VALID.name());
	return properties;
}