List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:com.nextep.designer.synch.services.impl.ReverseSynchronizationService.java
@Override public void updateIntoView(IWorkspace view, IComparisonItem updatedItem, IReverseSynchronizationContext context) { Assert.notNull(context, SynchMessages.getString("synch.reverse.noContextError")); //$NON-NLS-1$ final Map<IReference, IReference> extRefMap = context.getSourceReferenceMapping(); final IVersionable<?> viewTarget = (IVersionable<?>) updatedItem.getTarget(); final IVersionable<?> updated = (IVersionable<?>) updatedItem.getSource(); final Collection<IVersionable<?>> toImport = context.getVersionablesToImport(); final Collection<IComparisonItem> updatedItems = context.getVersionableItemsMap().values(); // Replacing dependencies to link to current view (should not be useful since we do this // later)./*from ww w .ja v a 2s . c om*/ replaceComparisonReference(updatedItem, extRefMap); // We cannot import elements which already have checkouts, so we skip them. if (viewTarget.getVersion().getStatus() != IVersionStatus.CHECKED_IN) { toImport.remove(updated); LOGGER.warn(MessageFormat.format(SynchMessages.getString("synch.reverse.ignoredCheckedOut"), //$NON-NLS-1$ NameHelper.getQualifiedName(updated))); return; } // Building imported reference list final List<IReference> importedRefs = buildImportedRefs(updatedItems); for (IVersionable<?> v : toImport) { if (v instanceof IReferenceContainer) { final IReferenceContainer refContainer = (IReferenceContainer) updated; importedRefs.addAll(refContainer.getReferenceMap().keySet()); } if (v instanceof IReferenceable) { importedRefs.add(((IReferenceable) updated).getReference()); } } if (updated instanceof IReferencer) { // Building target view contained references list final Collection<IReference> viewRefs = view.getReferenceMap().keySet(); // Checking that every dependency is either in the view or in the import set if (!isDependenciesGranted(updatedItem, importedRefs, viewRefs, context)) { return; } // for(IReference r : referencer.getReferenceDependencies()) { // if(!importedRefs.contains(r) && !viewRefs.contains(r)) { // final Object o = VersionHelper.getReferencedItem(r); // log.warn(Designer.getInstance().getQualifiedName(updated) + // " has not been imported because it depends on the non-imported object: " + // Designer.getInstance().getQualifiedName(o)); // toImport.remove(updated); // return null; // } // } } // Checking external references which would be created by the removal of one item // Collection<IReferencer> deletedReferencers = new ArrayList<IReferencer>(); // fillDeletedReferencersList(Arrays.asList( new IComparisonItem[] {updatedItem}), // deletedReferencers); checkRecursiveDeletions(context, updatedItem); performUpdate(updatedItem, context); }
From source file:grails.plugins.DefaultGrailsPluginManager.java
public Collection<GrailsPlugin> getPluginObservers(GrailsPlugin plugin) { Assert.notNull(plugin, "Argument [plugin] cannot be null"); Collection<GrailsPlugin> c = pluginToObserverMap.get(plugin.getName()); // Add any wildcard observers. Collection<GrailsPlugin> wildcardObservers = pluginToObserverMap.get("*"); if (wildcardObservers != null) { if (c != null) { c.addAll(wildcardObservers); } else {//from w w w.j a va 2 s.com c = wildcardObservers; } } if (c != null) { // Make sure this plugin is not observing itself! c.remove(plugin); return c; } return Collections.emptySet(); }
From source file:org.zanata.action.ProjectHomeAction.java
/** * Get a list of the display name for every project-related role for a * person.//from www . j av a2s . c o m */ public Collection<String> projectRoleDisplayNames(HPerson person) { final Collection<ProjectRole> rolesForPerson = getMemberRoles().get(person); Collection<ProjectRole> roles; if (rolesForPerson == null) { roles = Lists.newArrayList(); } else { roles = Lists.newArrayList(rolesForPerson); } // Maintainer role includes TranslationMaintainer privileges, so do not // show the lower-permission role. if (roles.contains(Maintainer)) { roles.remove(TranslationMaintainer); } // Wrapped in a concrete collection because the lazy collection returned // by transform causes errors when it is used directly in a jsf // template. return Lists.newArrayList(Collections2.transform(roles, new Function<ProjectRole, String>() { @Override public String apply(ProjectRole role) { return projectRoleDisplayName(role); } })); }
From source file:org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.EnforceVariablesVisitor.java
@Override public ILogicalOperator visitGroupByOperator(GroupByOperator op, Collection<LogicalVariable> varsToRecover) throws AlgebricksException { Set<LogicalVariable> liveVars = new HashSet<>(); VariableUtilities.getLiveVariables(op, liveVars); varsToRecover.removeAll(liveVars);//from w w w . j ava 2 s . c o m // Maps group by key variables if the corresponding expressions are VariableReferenceExpressions. for (Pair<LogicalVariable, Mutable<ILogicalExpression>> keyVarExprRef : op.getGroupByList()) { ILogicalExpression expr = keyVarExprRef.second.getValue(); if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression varExpr = (VariableReferenceExpression) expr; LogicalVariable sourceVar = varExpr.getVariableReference(); updateVarMapping(sourceVar, keyVarExprRef.first); varsToRecover.remove(sourceVar); } } for (LogicalVariable varToRecover : varsToRecover) { // This limits the visitor can only be applied to a nested logical plan inside a Subplan operator, // where the varsToRecover forms a candidate key which can uniquely identify a tuple out of the nested-tuple-source. op.getDecorList().add(new Pair<LogicalVariable, Mutable<ILogicalExpression>>(null, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(varToRecover)))); } return visitsInputs(op, varsToRecover); }
From source file:com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl.java
@Override public void excludeItem(T item) { checkNotNullArgument(item, "item is null"); backgroundWorker.checkUIAccess();//from w w w .j a va 2 s . c o m checkState(); checkPermission(); Collection<T> collection = getCollection(); if (collection != null) { if (this.item != null && this.item.equals(item)) { setItem(null); } doNotModify = true; try { collection.remove(item); MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty != null) item.setValue(inverseProperty.getName(), null); // detach listener only after setting value to the link property detachListener(item); fireCollectionChanged(Operation.REMOVE, Collections.singletonList(item)); } finally { doNotModify = false; } } }
From source file:it.cnr.icar.eric.server.query.ReferenceResolverImpl.java
@SuppressWarnings("rawtypes") private Collection checkForDuplicates(Collection refObjects, Collection results) { log.trace("start: checkForDuplicates"); @SuppressWarnings("unchecked") Collection resultsWithNoDups = new ArrayList(results); if (refObjects != null && results != null) { Iterator resultsItr = results.iterator(); while (resultsItr.hasNext()) { Object obj = resultsItr.next(); RegistryObjectType ro = null; if (obj instanceof RegistryObjectType) { ro = (RegistryObjectType) obj; String roId = ro.getId(); Iterator refItr = refObjects.iterator(); while (refItr.hasNext()) { RegistryObjectType refRO = (RegistryObjectType) refItr.next(); if (refRO.getId().equalsIgnoreCase(roId)) { resultsWithNoDups.remove(ro); }//from w w w . java 2s . co m } } } } log.trace("end: checkForDuplicates"); return resultsWithNoDups; }
From source file:org.wso2.carbon.identity.authenticator.saml2.sso.SAML2SSOAuthenticator.java
/** * Provision/Create user on the server(SP) and update roles accordingly * * @param username//from w w w . j av a 2s . co m * @param realm * @param xmlObject * @throws UserStoreException * @throws SAML2SSOAuthenticatorException */ private void provisionUser(String username, UserRealm realm, XMLObject xmlObject) throws UserStoreException, SAML2SSOAuthenticatorException { AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance(); AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration .getAuthenticatorConfig(AUTHENTICATOR_NAME); if (authenticatorConfig != null) { Map<String, String> configParameters = authenticatorConfig.getParameters(); boolean isJITProvisioningEnabled = false; if (configParameters .containsKey(SAML2SSOAuthenticatorBEConstants.PropertyConfig.JIT_USER_PROVISIONING_ENABLED)) { isJITProvisioningEnabled = Boolean.parseBoolean(configParameters .get(SAML2SSOAuthenticatorBEConstants.PropertyConfig.JIT_USER_PROVISIONING_ENABLED)); } if (isJITProvisioningEnabled) { String userstoreDomain = null; if (configParameters.containsKey( SAML2SSOAuthenticatorBEConstants.PropertyConfig.PROVISIONING_DEFAULT_USERSTORE)) { userstoreDomain = configParameters .get(SAML2SSOAuthenticatorBEConstants.PropertyConfig.PROVISIONING_DEFAULT_USERSTORE); } UserStoreManager userstore = null; // TODO : Get userstore from asserstion // TODO : remove user store domain name from username if (userstoreDomain != null && !userstoreDomain.isEmpty()) { userstore = realm.getUserStoreManager().getSecondaryUserStoreManager(userstoreDomain); } // If default user store is invalid or not specified use primary user store if (userstore == null) { userstore = realm.getUserStoreManager(); } String[] newRoles = getRoles(xmlObject); // Load default role if asserstion didnt specify roles if (newRoles == null || newRoles.length == 0) { if (configParameters.containsKey( SAML2SSOAuthenticatorBEConstants.PropertyConfig.PROVISIONING_DEFAULT_ROLE)) { newRoles = new String[] { configParameters .get(SAML2SSOAuthenticatorBEConstants.PropertyConfig.PROVISIONING_DEFAULT_ROLE) }; } } if (newRoles == null) { newRoles = new String[] {}; } if (log.isDebugEnabled()) { log.debug("User " + username + " contains roles : " + Arrays.toString(newRoles) + " as per response and (default role) config"); } // addingRoles = newRoles AND allExistingRoles Collection<String> addingRoles = new ArrayList<String>(); Collections.addAll(addingRoles, newRoles); Collection<String> allExistingRoles = Arrays.asList(userstore.getRoleNames()); addingRoles.retainAll(allExistingRoles); if (userstore.isExistingUser(username)) { // Update user Collection<String> currentRolesList = Arrays.asList(userstore.getRoleListOfUser(username)); // addingRoles = (newRoles AND existingRoles) - currentRolesList) addingRoles.removeAll(currentRolesList); Collection<String> deletingRoles = new ArrayList<String>(); deletingRoles.addAll(currentRolesList); // deletingRoles = currentRolesList - newRoles deletingRoles.removeAll(Arrays.asList(newRoles)); // Exclude Internal/everyonerole from deleting role since its cannot be deleted deletingRoles.remove(realm.getRealmConfiguration().getEveryOneRoleName()); // Check for case whether superadmin login if (userstore.getRealmConfiguration().isPrimary() && username.equals(realm.getRealmConfiguration().getAdminUserName())) { boolean isSuperAdminRoleRequired = false; if (configParameters.containsKey( SAML2SSOAuthenticatorBEConstants.PropertyConfig.IS_SUPER_ADMIN_ROLE_REQUIRED)) { isSuperAdminRoleRequired = Boolean.parseBoolean(configParameters.get( SAML2SSOAuthenticatorBEConstants.PropertyConfig.IS_SUPER_ADMIN_ROLE_REQUIRED)); } // Whether superadmin login without superadmin role is permitted if (!isSuperAdminRoleRequired && deletingRoles.contains(realm.getRealmConfiguration().getAdminRoleName())) { // Avoid removing superadmin role from superadmin user. deletingRoles.remove(realm.getRealmConfiguration().getAdminRoleName()); log.warn( "Proceeding with allowing super admin to be logged in, eventhough response doesn't include superadmin role assiged for the superadmin user."); } } if (log.isDebugEnabled()) { log.debug("Deleting roles : " + Arrays.toString(deletingRoles.toArray(new String[0])) + " and Adding roles : " + Arrays.toString(addingRoles.toArray(new String[0]))); } userstore.updateRoleListOfUser(username, deletingRoles.toArray(new String[0]), addingRoles.toArray(new String[0])); if (log.isDebugEnabled()) { log.debug("User: " + username + " is updated via SAML authenticator with roles : " + Arrays.toString(newRoles)); } } else { userstore.addUser(username, generatePassword(username), addingRoles.toArray(new String[0]), null, null); if (log.isDebugEnabled()) { log.debug("User: " + username + " is provisioned via SAML authenticator with roles : " + Arrays.toString(addingRoles.toArray(new String[0]))); } } } else { if (log.isDebugEnabled()) { log.debug("User provisioning diabled"); } } } else { if (log.isDebugEnabled()) { log.debug("Cannot find authenticator config for authenticator : " + AUTHENTICATOR_NAME); } throw new SAML2SSOAuthenticatorException( "Cannot find authenticator config for authenticator : " + AUTHENTICATOR_NAME); } }
From source file:org.kuali.kra.award.awardhierarchy.sync.helpers.AwardSyncHelperBase.java
/** * Applies the xmlExport keys and values to the object. This will recursively descend the tree of objects defined in the * xmlExport by calling {@link #setValuesOnSyncable}. * @param object// w w w.ja va2 s. c om * @param change * @param attrName * @param xmlExport * @throws NoSuchFieldException * @throws IllegalAccessException * @throws InvocationTargetException * @throws ClassNotFoundException * @throws NoSuchMethodException * @throws InstantiationException */ @SuppressWarnings("unchecked") protected void applySyncChange(PersistableBusinessObject object, AwardSyncChange change, String attrName, AwardSyncXmlExport xmlExport) throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, InstantiationException { Object propertyValue = getPropertyValue(object, attrName); if (propertyValue instanceof Collection) { Collection items = (Collection) propertyValue; PersistableBusinessObject matchedBo = getAwardSyncUtilityService().findMatchingBo(items, xmlExport.getKeys()); Map<String, Object> values = xmlExport.getValues(); if (StringUtils.equals(change.getSyncType(), AwardSyncType.ADD_SYNC.getSyncValue())) { if (matchedBo == null) { if (xmlExport.isAddIfNotFound()) { matchedBo = createNewItem(change, xmlExport); items.add(matchedBo); } } else { setValuesOnSyncable(matchedBo, values, change); } } else if (StringUtils.equals(change.getSyncType(), AwardSyncType.DELETE_SYNC.getSyncValue())) { items.remove(matchedBo); } } else if (StringUtils.equals(change.getSyncType(), AwardSyncType.ADD_SYNC.getSyncValue())) { if (propertyValue != null && !getAwardSyncUtilityService() .doKeyValuesMatch((PersistableBusinessObject) propertyValue, xmlExport.getKeys())) { if (xmlExport.isAddIfNotFound()) { Object newObject = createNewItem(change, xmlExport); Method setter = getPropertyDescriptor(object, attrName).getWriteMethod(); setter.invoke(object, newObject); } } else { setValuesOnSyncable((PersistableBusinessObject) propertyValue, xmlExport.getValues(), change); } } else if (propertyValue != null && getAwardSyncUtilityService() .doKeyValuesMatch((PersistableBusinessObject) propertyValue, xmlExport.getKeys())) { Method setter = getPropertyDescriptor(object, attrName).getWriteMethod(); setter.invoke(object, (Object[]) null); } }
From source file:eu.medsea.mimeutil.detector.OpendesktopMimeDetector.java
private Collection lookupMagicData(byte[] data) { Collection mimeTypes = new ArrayList(); int listOffset = getMagicListOffset(); int numEntries = content.getInt(listOffset); int offset = content.getInt(listOffset + 8); for (int i = 0; i < numEntries; i++) { String mimeType = compareToMagicData(offset + (16 * i), data); if (mimeType != null) { mimeTypes.add(mimeType);/* w ww .ja va 2s . co m*/ } else { String nonMatch = getMimeType(content.getInt(offset + (16 * i) + 4)); mimeTypes.remove(nonMatch); } } return mimeTypes; }
From source file:com.tesora.dve.sql.schema.PETable.java
public void removeKey(SchemaContext sc, PEKey pek) { checkLoaded(sc);//from w ww. ja v a 2s . c o m // also, at this point, clear the key flags on the columns // but only if the column is now truly not a key MultiMap<PEColumn, PEKey> colByKey = new MultiMap<PEColumn, PEKey>(); for (PEKey k : keys) { if (k.isForeign()) continue; // doesn't matter for (PEKeyColumnBase pekc : k.getKeyColumns()) { colByKey.put(pekc.getColumn(), k); } } for (PEColumn pec : colByKey.keySet()) { Collection<PEKey> vals = colByKey.get(pec); vals.remove(pek); // now look at the remaining keys, and figure out the key parts boolean isPrimary = false; boolean isUnique = false; boolean isKey = !vals.isEmpty(); for (PEKey ipek : vals) { if (ipek.getConstraint() == ConstraintType.PRIMARY) isPrimary = true; if (ipek.getConstraint() == ConstraintType.UNIQUE) isUnique = true; } if (!isPrimary) pec.clearPrimaryKeyPart(); if (!isUnique) pec.clearUniqueKeyPart(); if (!isKey) pec.clearKeyPart(); } keys.remove(pek); }