List of usage examples for org.apache.commons.lang3 ArrayUtils removeElements
public static boolean[] removeElements(final boolean[] array, final boolean... values)
Removes occurrences of specified elements, in specified quantities, from the specified array.
From source file:com.earthblood.tictactoe.strategy.StrategyItem.java
public int execute(int[] selectedXBoxIds, int[] selectedOBoxIds, GameSymbol androidSymbol) { Log.i(Toe.TAG, "Inside: " + getClass().getName()); currentlySelectedBoxes = ArrayUtils.addAll(selectedXBoxIds, selectedOBoxIds); currentlySelectedBoxes = ArrayUtils.removeElements(currentlySelectedBoxes, DEFAULT_ZEROS); availableBoxes = ArrayUtils.removeElements(ALL_BOXES, currentlySelectedBoxes); int boxId = getBoxId(selectedXBoxIds, selectedOBoxIds, androidSymbol); if (ArrayUtils.contains(ALL_BOXES, boxId)) { Log.i(Toe.TAG, "Found: " + boxId); return boxId; } else if (successor != null) { return successor.execute(selectedXBoxIds, selectedOBoxIds, androidSymbol); } else {/*from ww w. j a v a 2 s. c o m*/ return NOT_FOUND; } }
From source file:com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions.java
private boolean togglePermission(Action action, Principal principal, boolean enable) { boolean isAdminAction = isAdminAction(action); boolean result = true; if (isAdminAction) { if (enable) { // If this actions is a permission management action then grant this principal admin privileges to the whole tree. result = JcrAccessControlUtil.addRecursivePermissions(getNode(), JcrAllowableAction.NODE_TYPE, principal, ADMIN_PRIVILEGES); } else {/*from w w w. j a v a 2 s . c om*/ // Remove admin privileges but keep grant privileges if needed isAdminAction = getEnabledActions(principal).stream().allMatch(action::equals); // has non-admin action remaining? final String[] privileges = isAdminAction ? ADMIN_PRIVILEGES : ArrayUtils.removeElements(ADMIN_PRIVILEGES, GRANT_PRIVILEGES); result = JcrAccessControlUtil.removeRecursivePermissions(getNode(), JcrAllowableAction.NODE_TYPE, principal, privileges); } } if (!isAdminAction) { result &= findActionNode(action).map(node -> { if (enable) { return JcrAccessControlUtil.addHierarchyPermissions(node, principal, this.node, GRANT_PRIVILEGES); } else { return JcrAccessControlUtil.removeRecursivePermissions(node, JcrAllowableAction.NODE_TYPE, principal, GRANT_PRIVILEGES); } }).orElseThrow(() -> new AccessControlException( "Not authorized to " + (enable ? "enable" : "disable") + " the action: " + action)); } return result; }
From source file:org.efaps.esjp.accounting.transaction.FieldUpdate_Base.java
/** * Method is executed on update trigger for the account field in the debit * and credit table inside the transaction form. * * @param _parameter Parameter as passed from the eFaps API * @return list for update trigger/*from www .jav a 2s . co m*/ * @throws EFapsException on error */ public Return update4AdditionalDocument(final Parameter _parameter) throws EFapsException { final Return ret = new Return(); final List<Map<String, Object>> list = new ArrayList<>(); final Map<String, Object> map = new HashMap<>(); list.add(map); ret.put(ReturnValues.VALUES, list); final Parameter parameter = ParameterUtil.clone(_parameter); final String[] docs = _parameter.getParameterValues("document"); final String[] addDocs = _parameter.getParameterValues("additionalDocument"); final String[] selectedRow = ArrayUtils.addAll(ArrayUtils.removeElements(docs, addDocs), addDocs); ParameterUtil.setParameterValues(parameter, "selectedRow", selectedRow); final StringBuilder ajs = new StringBuilder(); final StringBuilder tableHtml = new FieldValue().getDocumentFieldSnipplet(parameter, ajs); final StringBuilder js = new StringBuilder().append("var s = \"") .append(StringEscapeUtils.escapeEcmaScript(tableHtml.toString())).append("\";") .append("domConstruct.place(s, \"documentTable\", \"replace\");") .append("topic.publish(\"eFaps/addRowBeforeScript/transactionPositionDebitTable\");\n").append(ajs); InterfaceUtils.appendScript4FieldUpdate(map, InterfaceUtils.wrapInDojoRequire(_parameter, js, DojoLibs.DOMCONSTRUCT, DojoLibs.TOPIC, DojoLibs.ON, DojoLibs.QUERY, DojoLibs.DOM, DojoLibs.NLTRAVERSE)); return ret; }
From source file:org.efaps.esjp.accounting.transaction.FieldUpdate_Base.java
/** * Method is executed on update trigger for the account field in the debit * and credit table inside the transaction form. * * @param _parameter Parameter as passed from the eFaps API * @return list for update trigger/*from w w w . j av a 2 s. c om*/ * @throws EFapsException on error */ public Return update4AdditionalContact(final Parameter _parameter) throws EFapsException { final Return ret = new Return(); final List<Map<String, Object>> list = new ArrayList<>(); final Map<String, Object> map = new HashMap<>(); list.add(map); ret.put(ReturnValues.VALUES, list); final Parameter parameter = ParameterUtil.clone(_parameter); final String[] docs = _parameter.getParameterValues("document"); final String[] addDocs = _parameter.getParameterValues("additionalContact"); final String[] selectedRow = ArrayUtils.addAll(ArrayUtils.removeElements(docs, addDocs), addDocs); ParameterUtil.setParameterValues(parameter, "selectedRow", selectedRow); final StringBuilder ajs = new StringBuilder(); final StringBuilder tableHtml = new FieldValue().getDocumentFieldSnipplet(parameter, ajs); final StringBuilder js = new StringBuilder().append("var s = \"") .append(StringEscapeUtils.escapeEcmaScript(tableHtml.toString())).append("\";") .append("domConstruct.place(s, \"documentTable\", \"replace\");") .append("topic.publish(\"eFaps/addRowBeforeScript/transactionPositionDebitTable\");\n").append(ajs); InterfaceUtils.appendScript4FieldUpdate(map, InterfaceUtils.wrapInDojoRequire(_parameter, js, DojoLibs.DOMCONSTRUCT, DojoLibs.TOPIC, DojoLibs.ON, DojoLibs.QUERY, DojoLibs.DOM, DojoLibs.NLTRAVERSE)); return ret; }
From source file:org.jgrades.monitor.api.aop.CompletenessAspect.java
@Before("anyMethod() && @within(checkDependencies)") public void checkDependencies(CheckSystemDependencies checkDependencies) { SystemDependency[] dependencies = ArrayUtils.removeElements(SystemDependency.values(), checkDependencies.ignored()); systemDependencyService.check(new HashSet<>(Arrays.asList(dependencies))); }
From source file:org.silverpeas.core.notification.user.delayed.DelayedNotificationManagerIT.java
/** * Centralizing assertions// ww w. j a va2 s .c o m * * @param date * @param aimedChannels * @param defaultDelayedNotificationFrequency * @param expectedUsers */ private void assertFindUsersToBeNotified(final Date date, final Set<NotifChannel> aimedChannels, final DelayedNotificationFrequency defaultDelayedNotificationFrequency, final Integer... expectedUsers) { Integer[] notExpectedUsers = new Integer[] { 51, 52, 53, 54, 55, 56 }; final List<Integer> usersToNotify = manager.findUsersToBeNotified(date, aimedChannels, defaultDelayedNotificationFrequency); usersToNotify.retainAll(Arrays.asList(notExpectedUsers)); if (expectedUsers != null && expectedUsers.length > 0) { notExpectedUsers = ArrayUtils.removeElements(notExpectedUsers, expectedUsers); } assertThat(usersToNotify, notNullValue()); if (expectedUsers != null && expectedUsers.length > 0) { assertThat(usersToNotify.toArray(new Integer[] {}), arrayContainingInAnyOrder(expectedUsers)); } if (notExpectedUsers.length > 0) { assertThat(usersToNotify.toArray(new Integer[] {}), not(arrayContainingInAnyOrder(notExpectedUsers))); } }