List of usage examples for org.apache.commons.lang ArrayUtils removeElement
public static short[] removeElement(short[] array, short element)
Removes the first occurrence of the specified element from the specified array.
From source file:org.nuxeo.ecm.automation.core.operations.document.DocumentPermissionHelper.java
/** * @param acp The ACP to modify//www . j a v a 2 s. co m * @param aclName the name of the ACL to target * @param principalName the name of the principal (user or group) * @return true if something has changed on the document security * */ public static boolean removePermission(ACP acp, String aclName, String principalName) { boolean securityHasChanged = false; ACL acl = acp.getACL(aclName); if (acl != null) { ACE[] acEs = acl.getACEs(); for (ACE ace : acEs) { if (ace.getUsername().equals(principalName)) { acEs = (ACE[]) ArrayUtils.removeElement(acEs, ace); securityHasChanged = true; } } acl.setACEs(acEs); } // in order to clear the cache if (securityHasChanged) { acp.addACL(acl); } return securityHasChanged; }
From source file:org.openaion.gameserver.services.BrokerService.java
/** * // w ww. ja v a 2 s.c o m * @param player * @param itemUniqueId */ public void buyBrokerItem(Player player, int itemUniqueId) { boolean isEmptyCache = getFilteredItems(player).length == 0; Race playerRace = player.getCommonData().getRace(); BrokerItem buyingItem = getRaceBrokerItems(playerRace).get(itemUniqueId); if (buyingItem == null) return; synchronized (buyingItem) { if (buyingItem == null || buyingItem.isSold() || buyingItem.isSettled()) { if (buyingItem != null && buyingItem.getItem() != null) PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300647, new DescriptionId(buyingItem.getItem().getNameID()))); return; } if (player.getObjectId() == buyingItem.getSellerId()) { PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400750)); return; } if (player.getInventory().isFull()) { PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300654)); return; } long price = buyingItem.getPrice(); if (player.getInventory().getKinahItem().getItemCount() < price) { PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300759)); return; } getRaceBrokerItems(playerRace).remove(itemUniqueId); putToSettled(playerRace, buyingItem, true); if (!isEmptyCache) { BrokerItem[] newCache = (BrokerItem[]) ArrayUtils.removeElement(getFilteredItems(player), buyingItem); getPlayerCache(player).setBrokerListCache(newCache); } boolean decreaseResult = player.getInventory().decreaseKinah(price); if (!decreaseResult) return; Item boughtItem = player.getInventory().putToBag(buyingItem.getItem()); // create save task BrokerOpSaveTask bost = new BrokerOpSaveTask(buyingItem, boughtItem, player.getInventory().getKinahItem(), player.getObjectId()); saveManager.add(bost); PacketSendUtility.sendPacket(player, new SM_INVENTORY_UPDATE(boughtItem, true)); PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(boughtItem, 2)); showRequestedItems(player, getPlayerCache(player).getBrokerMaskCache(), getPlayerCache(player).getBrokerSortTypeCache(), getPlayerCache(player).getBrokerStartPageCache()); } }
From source file:org.openbravo.erpCommon.ad_reports.MInOutTraceReports.java
private MInOutTraceReportsData[] processData(VariablesSecureApp vars, MInOutTraceReportsData[] data, String strIn, String strmProductIdGlobal, Hashtable<String, Integer> calculated, Vector<Integer> count) throws ServletException { if (data == null || data.length == 0) { return data; }// www . j av a 2 s .c om for (int i = 0; i < data.length; i++) { data[i].html = processChilds(vars, data[i].mAttributesetinstanceId, data[i].mProductId, data[i].mLocatorId, strIn, true, strmProductIdGlobal, calculated, count); if ("".equals(data[i].html)) { // Delete data[i] from array data = (MInOutTraceReportsData[]) ArrayUtils.removeElement(data, data[i]); i--; } } return data; }
From source file:org.polymap.core.runtime.SessionContext.java
public static void removeProvider(ISessionContextProvider provider) { providers = (ISessionContextProvider[]) ArrayUtils.removeElement(providers, provider); }
From source file:org.sparkcommerce.core.web.processor.ToggleFacetLinkProcessor.java
@Override @SuppressWarnings("unchecked") protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {/* w ww.j a va 2 s . c o m*/ Map<String, String> attrs = new HashMap<String, String>(); SparkRequestContext blcContext = SparkRequestContext.getSparkRequestContext(); HttpServletRequest request = blcContext.getRequest(); String baseUrl = request.getRequestURL().toString(); Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap()); Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration()) .parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName)); SearchFacetResultDTO result = (SearchFacetResultDTO) expression.execute(arguments.getConfiguration(), arguments); String key = facetService.getUrlKey(result); String value = facetService.getValue(result); String[] paramValues = params.get(key); if (ArrayUtils.contains(paramValues, facetService.getValue(result))) { paramValues = (String[]) ArrayUtils.removeElement(paramValues, facetService.getValue(result)); } else { paramValues = (String[]) ArrayUtils.add(paramValues, value); } params.remove(ProductSearchCriteria.PAGE_NUMBER); params.put(key, paramValues); String url = ProcessorUtils.getUrl(baseUrl, params); attrs.put("href", url); return attrs; }
From source file:org.structr.core.entity.AbstractRelationship.java
public void removePermission(final Permission permission) { String[] allowed = getPermissions(); if (!ArrayUtils.contains(allowed, permission.name())) { return;/*from www . ja va2 s . com*/ } setAllowed((String[]) ArrayUtils.removeElement(allowed, permission.name())); }
From source file:org.talend.core.hadoop.version.custom.HadoopCustomVersionDefineDialog.java
/** * DOC ycbai Comment method "getDisplayTypes". * // w w w . j a v a 2 s . c om * @return Types({@link ECustomVersionType}) array which you want to display in this dialog. */ protected ECustomVersionType[] getDisplayTypes() { // filter ALL and PIG ECustomVersionType[] values = ECustomVersionType.values(); Object[] removeElement = ArrayUtils.removeElement(values, ECustomVersionType.ALL); // removeElement = ArrayUtils.removeElement(removeElement, ECustomVersionType.PIG); return (ECustomVersionType[]) removeElement; }
From source file:org.talend.designer.core.ui.editor.properties.controllers.ColumnListController.java
/** * // w ww . j av a 2 s.co m * <p> * You can fill the filter as the format below: * </p> * <l> <li>CUSTOM_COLUMNS:col1</li> <li>CUSTOM_COLUMNS:col1, col2, ...</li> <li>CUSTOM_COLUMNS:*</li> <li> * CUSTOM_COLUMNS:REGEXP:any regular expressions</li> <li>NONE_CUSTOM_COLUMNS:col1</li> <li> * NONE_CUSTOM_COLUMNS:col1, col2, ...</li> <li>NONE_CUSTOM_COLUMNS:*</li> <li>NONE_CUSTOM_COLUMNS:REGEXP:any * regular expressions</li> <li>REGEXP:any regular expressions</li> <li>col1</li> <li>col1,col2, ...</li> <li>*</li> * </l> * * <br> * You can refer to {@link ColumnListControllerTest } to know how does this method work. </br> <br> * DOC ycbai Comment method "filterColumns". * * @param param * @param curColumnNameList * @param curColumnValueList * @param customColMap * @return */ private static List<String[]> filterColumns(IElementParameter param, String[] curColumnNameList, String[] curColumnValueList, Map<String, Boolean> customColMap) { List<String[]> updatedColumns = new ArrayList<String[]>(); String[] columnNameList = curColumnNameList; String[] columnValueList = curColumnValueList; String filterColumns = param.getFilter(); if (filterColumns != null) { // Hide all filter columns. try { String[] tmpColumnNameList = new String[curColumnNameList.length]; System.arraycopy(curColumnNameList, 0, tmpColumnNameList, 0, tmpColumnNameList.length); String filter = filterColumns; boolean onlyFilterCustom = false; if (filter.startsWith(FILTER_PREFIX_CUSTOM)) { filter = filter.substring(FILTER_PREFIX_CUSTOM.length()); onlyFilterCustom = true; } boolean onlyFilterNoneCustom = false; if (filter.startsWith(FILTER_PREFIX_NONE_CUSTOM)) { filter = filter.substring(FILTER_PREFIX_NONE_CUSTOM.length()); onlyFilterNoneCustom = true; } boolean unlimited = !onlyFilterCustom && !onlyFilterNoneCustom; boolean hasReg = false; if (filter.startsWith(FILTER_PREFIX_REGEXP)) { filter = filter.substring(FILTER_PREFIX_REGEXP.length()); hasReg = true; } boolean filterAll = false; if (filter.equals(FILTER_ALL)) { filterAll = true; } if (hasReg) { Perl5Matcher matcher = new Perl5Matcher(); Perl5Compiler compiler = new Perl5Compiler(); Pattern pattern = compiler.compile(filter); for (String colName : tmpColumnNameList) { if (!matcher.matches(colName, pattern) && (onlyFilterCustom && customColMap.get(colName) || onlyFilterNoneCustom && !customColMap.get(colName) || unlimited)) { columnNameList = (String[]) ArrayUtils.removeElement(columnNameList, colName); columnValueList = (String[]) ArrayUtils.removeElement(columnValueList, colName); } } } else { if (filterAll) { for (String colName : tmpColumnNameList) { if (onlyFilterCustom && customColMap.get(colName) || onlyFilterNoneCustom && !customColMap.get(colName) || unlimited) { columnNameList = (String[]) ArrayUtils.removeElement(columnNameList, colName); columnValueList = (String[]) ArrayUtils.removeElement(columnValueList, colName); } } } else { String[] filterColumnsArray = filter.split(FILTER_SEPARATOR); for (String colName : filterColumnsArray) { if (onlyFilterCustom && customColMap.get(colName) || onlyFilterNoneCustom && !customColMap.get(colName) || unlimited) { columnNameList = (String[]) ArrayUtils.removeElement(columnNameList, colName); columnValueList = (String[]) ArrayUtils.removeElement(columnValueList, colName); } } } } } catch (Exception e) { log.warn(Messages.getString("ColumnListController.invalidRegx", param.getName()), e); //$NON-NLS-1$ } } updatedColumns.add(columnNameList); updatedColumns.add(columnValueList); return updatedColumns; }
From source file:org.tldgen.TldDoclet.java
private static License convertLicense() { try {// w ww . j a va2 s . co m if (license == null) { return License.NONE; } return License.valueOf(license.toUpperCase()); } catch (IllegalArgumentException e) { try { File f = new File(license); if (!f.exists() || !f.isFile()) { String licenseNames = StringUtils .join(ArrayUtils.removeElement(License.values(), License.CUSTOM), ", "); throw new IllegalArgumentException("Invalid license. Available licenses are: " + licenseNames + ", or any valid file location."); } String licenseHeader = FileUtils.readFileToString(f); License license = License.CUSTOM; license.setLicenseHeader(licenseHeader); return license; } catch (IOException e1) { throw new RuntimeException(e1); } } }
From source file:org.wso2.carbon.appfactory.tenant.mgt.beans.UserInfoBean.java
public UserInfoBean(String userName, String firstName, String lastName, String email, String displayName, String[] roles) {// ww w. ja v a 2 s . c o m this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.email = email; this.displayName = displayName; String everyOneRoleName = AppFactoryTenantMgtUtil.getRealmService().getBootstrapRealmConfiguration() .getEveryOneRoleName(); if (ArrayUtils.contains(roles, everyOneRoleName)) { this.roles = (String[]) ArrayUtils.removeElement(roles, everyOneRoleName); } else { this.roles = roles; } }