Java Code Examples for org.apache.commons.lang.ArrayUtils#contains()
The following examples show how to use
org.apache.commons.lang.ArrayUtils#contains() .
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
Source File: FolderObserver.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private File getFileByFileExtMap(Map<String, String[]> folderFileExtMap, String filename) { if (StringUtils.isNotBlank(filename) && MapUtils.isNotEmpty(folderFileExtMap)) { String extension = getExtension(filename); if (StringUtils.isNotBlank(extension)) { Set<Entry<String, String[]>> entries = folderFileExtMap.entrySet(); Iterator<Entry<String, String[]>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<String, String[]> entry = iterator.next(); if (ArrayUtils.contains(entry.getValue(), extension)) { return new File(getFile(entry.getKey()) + File.separator + filename); } } } } return null; }
Example 2
Source File: ClientDataValidationService.java From oxAuth with MIT License | 6 votes |
public void checkContent(ClientData clientData, String[] types, String challenge, Set<String> facets) throws BadInputException { if (!ArrayUtils.contains(types, clientData.getTyp())) { throw new BadInputException("Bad clientData: wrong typ " + clientData.getTyp()); } if (!challenge.equals(clientData.getChallenge())) { throw new BadInputException("Bad clientData: wrong challenge"); } if (facets != null && !facets.isEmpty()) { Set<String> allowedFacets = canonicalizeOrigins(facets); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(clientData.getOrigin()); } catch (RuntimeException e) { throw new BadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } }
Example 3
Source File: SliceInformation.java From dawnsci with Eclipse Public License 1.0 | 6 votes |
public SliceND removeDimensionsFromInputSlice(int[] dims) { int newRank = currentSlice.getShape().length-dims.length; Slice[] oSlice = currentSlice.convertToSlice(); int[] oShape = sampling.getShape().clone(); Slice[] newSlice = new Slice[newRank]; int[] newShape = new int[newRank]; int index = 0; for (int i = 0; i < oSlice.length; i++) { if (!ArrayUtils.contains(dims, i)) { newSlice[i] = oSlice[index]; newShape[i] = oShape[index++]; } } return new SliceND(newShape, newSlice); }
Example 4
Source File: ESBTestCaseUtils.java From product-ei with Apache License 2.0 | 6 votes |
public boolean isPriorityExecutorUnDeployed(String backEndUrl, String sessionCookie, String executorName) throws RemoteException { PriorityMediationAdminClient priorityMediationAdminClient = new PriorityMediationAdminClient(backEndUrl, sessionCookie); log.info("waiting " + SERVICE_DEPLOYMENT_DELAY + " millis for Undeployment Priority Executor " + executorName); boolean isExecutorUnDeployed = false; Calendar startTime = Calendar.getInstance(); long time; while ((time = (Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis())) < SERVICE_DEPLOYMENT_DELAY) { String[] executorList = priorityMediationAdminClient.getExecutorList(); if (!ArrayUtils.contains(executorList, executorName)) { isExecutorUnDeployed = true; break; } try { Thread.sleep(500); } catch (InterruptedException e) { //ignore } } return isExecutorUnDeployed; }
Example 5
Source File: CubeDesc.java From Kylin with Apache License 2.0 | 6 votes |
private void initDerivedMap(TblColRef[] hostCols, DeriveType type, DimensionDesc dimension, TblColRef[] derivedCols, String[] extra) { if (hostCols.length == 0 || derivedCols.length == 0) throw new IllegalStateException("host/derived columns must not be empty"); Array<TblColRef> hostColArray = new Array<TblColRef>(hostCols); List<DeriveInfo> infoList = hostToDerivedMap.get(hostColArray); if (infoList == null) { hostToDerivedMap.put(hostColArray, infoList = new ArrayList<DeriveInfo>()); } infoList.add(new DeriveInfo(type, dimension, derivedCols, false)); for (int i = 0; i < derivedCols.length; i++) { TblColRef derivedCol = derivedCols[i]; boolean isOneToOne = type == DeriveType.PK_FK || ArrayUtils.contains(hostCols, derivedCol) || (extra != null && extra[i].contains("1-1")); derivedToHostMap.put(derivedCol, new DeriveInfo(type, dimension, hostCols, isOneToOne)); } }
Example 6
Source File: OrgReviewRoleMaintainableImplTest.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
public void testGetSections_OrgHier_RoleMember_Copy() throws Exception { orgReviewRoleService.saveOrgReviewRoleToKim(orgHierOrgReviewRole); MaintenanceDocument document = createCopyDocument_OrgHier_RoleMember(orgHierOrgReviewRole.getRoleMemberId()); // populate the old side (should be blank) List<Section> oldSections = document.getNewMaintainableObject().getSections(document, null); // populate the new side List<Section> newSections = document.getNewMaintainableObject().getSections(document, document.getNewMaintainableObject()); for ( Section section : newSections ) { for ( Row row : section.getRows() ) { for ( Field field : row.getFields() ) { if ( ArrayUtils.contains(FIELDS_TO_IGNORE, field.getPropertyName()) ) { continue; } if ( field.getPropertyName().equals(OrgReviewRole.DELEGATION_TYPE_CODE) ) { assertEquals( "Delegation type Field should have been hidden: ", Field.HIDDEN, field.getFieldType() ); } else { assertFalse( field.getPropertyName() + " should have been editable and not hidden", field.isReadOnly() || field.getFieldType().equals(Field.HIDDEN) ); } } } } }
Example 7
Source File: DBDatasProcessor.java From sofa-acts with Apache License 2.0 | 5 votes |
/** * Clean db datas. * * @param depTables the dep tables * @param groupIds the group ids */ public void cleanDBDatas(List<VirtualTable> depTables, String... groupIds) { if (depTables == null || depTables.isEmpty()) { return; } for (int i = 0; i < depTables.size(); i++) { //Dynamically assemble SQL and execute according to DO class attribute prefix VirtualTable table = depTables.get(i); if (table == null) { continue; } if ((ArrayUtils.isEmpty(groupIds) && StringUtils.isEmpty(table.getNodeGroup())) || ArrayUtils.contains(groupIds, table.getNodeGroup())) { List<String> fields = filterByColumns(table.getTableName(), table.getTableData() .get(0)); String sql = genDeleteSql(table, fields); Execute(beforeVTableExecuteMethodList, table.getTableName(), table.getNodeGroup()); //Assembly parameter and execution sql doDelete(table, sql, fields); Execute(afterVTableExecuteMethodList, table.getTableName(), table.getNodeGroup()); } } }
Example 8
Source File: Main.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean devMode = ArrayUtils.contains(args, "--dev"); if (devMode) { Config.setupMiniCluster(); } Config.setupConfig(); JettyServer server = new JettyServer(Config.getConsolePort(), devMode).start(); server.join(); if (devMode) { Config.shutdownMiniCluster(); } }
Example 9
Source File: ConditionalRouterIntegrationTest.java From product-ei with Apache License 2.0 | 5 votes |
/** * The test is for dynamically load a xml file from WSO2registry * Test artifacts: synapseconfig/conditional_router/synapse4.xml AND synapseconfig/conditional_router/dynamic_seq1.xml * * @throws Exception */ @Test(groups = { "wso2.esb" }) public void conditionalRouterMediatorWithDynamicSequenceTest() throws Exception { ArtifactReaderUtil artifactReaderUtil = new ArtifactReaderUtil(); // Get an OMElement from xml OMElement omElement = artifactReaderUtil.getOMElement( getESBResourceLocation() + File.separator + "synapseconfig" + File.separator + "filters" + File.separator + "conditional_router" + File.separator + "dynamic_seq1.xml"); // Add dynamic sequence to WSO2registry config/filters/dynamic_seq1 if (ArrayUtils.contains(sequenceAdminServiceClient.getDynamicSequences(), "conf:/filters/dynamic_seq1")) { sequenceAdminServiceClient.deleteDynamicSequence("conf:/filters/dynamic_seq1"); Awaitility.await().pollInterval(500, TimeUnit.MILLISECONDS).atMost( 60, TimeUnit.SECONDS).until(dynamicSequenceExists(sequenceAdminServiceClient. getDynamicSequences(), CONF_FILTERS_DYNAMIC_SEQ_1)); } sequenceAdminServiceClient.addDynamicSequence("conf:filters/dynamic_seq1", setEndpoints(omElement)); //load it to esb loadESBConfigurationFromClasspath("/artifacts/ESB/synapseconfig/filters/conditional_router/synapse4.xml"); OMElement response = axis2Client.sendSimpleStockQuoteRequest(mainSeqUrl, toUrl, "WSO2"); Assert.assertTrue(response.toString().contains("GetQuoteResponse")); Assert.assertTrue(response.toString().contains("WSO2 Company")); sequenceAdminServiceClient.deleteDynamicSequence("conf:/filters/dynamic_seq1"); }
Example 10
Source File: BandFeatureIterator.java From geowave with Apache License 2.0 | 5 votes |
private void init( final boolean nBestScenesByPathRow, final int nBestBands, final Filter cqlFilter) { // wrap the iterator with a feature conversion and a filter (if // provided) final SimpleFeatureType bandType = createFeatureType(sceneIterator.getFeatureType()); iterator = Iterators.concat( Iterators.transform( new FeatureIteratorIterator<>(sceneIterator), new SceneToBandFeatureTransform(bandType))); if (cqlFilter != null) { final String[] attributes = DataUtilities.attributeNames(cqlFilter, bandType); // we can rely on the scene filtering if we don't have to check any // specific band filters if (ArrayUtils.contains(attributes, BAND_ATTRIBUTE_NAME) || ArrayUtils.contains(attributes, SIZE_ATTRIBUTE_NAME) || ArrayUtils.contains(attributes, BAND_DOWNLOAD_ATTRIBUTE_NAME)) { // and rely on the band filter iterator = Iterators.filter(iterator, new CqlFilterPredicate(cqlFilter)); if (nBestBands > 0) { iterator = SceneFeatureIterator.nBestScenes(this, nBestScenesByPathRow, nBestBands); } } } }
Example 11
Source File: PluginSettings.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
public PluginSettings(final Settings settings) { this.settings = settings; this.kibanaIndexMode = settings.get(OPENSHIFT_KIBANA_INDEX_MODE, KibanaIndexMode.DEFAULT_MODE); if (!ArrayUtils.contains(new String[] { UNIQUE, SHARED_OPS, SHARED_NON_OPS }, kibanaIndexMode.toLowerCase())) { this.kibanaIndexMode = UNIQUE; } this.roleStrategy = settings.get(OPENSHIFT_ACL_ROLE_STRATEGY, DEFAULT_ACL_ROLE_STRATEGY); if (!ArrayUtils.contains(new String[] { PROJECT, USER }, roleStrategy.toLowerCase())) { this.kibanaIndexMode = USER; } this.cdmProjectPrefix = settings.get(OPENSHIFT_CONFIG_PROJECT_INDEX_PREFIX, OPENSHIFT_DEFAULT_PROJECT_INDEX_PREFIX); this.defaultKibanaIndex = settings.get(KIBANA_CONFIG_INDEX_NAME, DEFAULT_USER_PROFILE_PREFIX); this.searchGuardIndex = settings.get(SEARCHGUARD_CONFIG_INDEX_NAME, DEFAULT_SECURITY_CONFIG_INDEX); this.kibanaVersion = settings.get(KIBANA_CONFIG_VERSION, DEFAULT_KIBANA_VERSION); this.kbnVersionHeader = settings.get(KIBANA_VERSION_HEADER, DEFAULT_KIBANA_VERSION_HEADER); this.opsIndexPatterns = new HashSet<String>(Arrays.asList(settings.getAsArray(OPENSHIFT_KIBANA_OPS_INDEX_PATTERNS, DEFAULT_KIBANA_OPS_INDEX_PATTERNS))); this.expireInMillis = settings.getAsLong(OPENSHIFT_CONTEXT_CACHE_EXPIRE_SECONDS, DEFAULT_OPENSHIFT_CONTEXT_CACHE_EXPIRE_SECONDS) * 1000; LOGGER.info("Using kibanaIndexMode: '{}'", this.kibanaIndexMode); LOGGER.debug("searchGuardIndex: {}", this.searchGuardIndex); LOGGER.debug("roleStrategy: {}", this.roleStrategy); }
Example 12
Source File: TestUnitHandler.java From sofa-acts with Apache License 2.0 | 5 votes |
/** * DB result check * * @param extMapInfo * @param groupIds */ public void checkExpectDbData(HashMap<String, String> extMapInfo, String... groupIds) { try { ComponentsActsRuntimeContextThreadHold.setContext(this.actsRuntimeContext); actsRuntimeContext.getDbDatasProcessor().updateDataSource(extMapInfo); if (null != actsRuntimeContext.getPrepareData().getExpectDataSet() && actsRuntimeContext.getPrepareData().getExpectDataSet().getVirtualTables() != null) { log.info("Checking DB, tables checked"); for (VirtualTable virtualTable : actsRuntimeContext.getPrepareData() .getExpectDataSet().getVirtualTables()) { if ((ArrayUtils.isEmpty(groupIds) && StringUtils.isEmpty(virtualTable .getNodeGroup())) || ArrayUtils.contains(groupIds, virtualTable.getNodeGroup())) { log.info(virtualTable.getTableName()); } } replaceTableParam(actsRuntimeContext.getPrepareData().getExpectDataSet() .getVirtualTables()); actsRuntimeContext.getDbDatasProcessor().compare2DBDatas( actsRuntimeContext.getPrepareData().getExpectDataSet().getVirtualTables(), groupIds); } else { log.info("None DB expectation"); } } catch (Exception e) { throw new ActsTestException("unknown exception while checking DB", e); } }
Example 13
Source File: BrokerRecipeFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
@Override public boolean accept(ItemTemplate template) { ItemActions actions = template.getActions(); if (actions != null) { CraftLearnAction craftAction = actions.getCraftLearnAction(); if (craftAction != null) { int id = craftAction.getRecipeId(); RecipeTemplate recipeTemplate = DataManager.RECIPE_DATA.getRecipeTemplateById(id); if (recipeTemplate != null && recipeTemplate.getSkillid() == craftSkillId) { return ArrayUtils.contains(masks, template.getTemplateId() / 100000); } } } return false; }
Example 14
Source File: TestLabelFilter.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public boolean shouldRun(final Description description) { TestLabels labels = description.getAnnotation(TestLabels.class); if (labels != null) { return ArrayUtils.contains(labels.value(), label); } return false; }
Example 15
Source File: TestUnitHandler.java From sofa-acts with Apache License 2.0 | 4 votes |
/** * Message check * * @param groupIds */ public void checkExpectEvent(String... groupIds) { try { log.info("Checking Events"); if (!actsRuntimeContext.getPrepareData().getExpectEventSet().getVirtualEventObjects() .isEmpty()) { Map<String, List<Object>> uEventList = EventContextHolder.getBizEvent(); for (VirtualEventObject virtualEventObject : actsRuntimeContext.getPrepareData() .getExpectEventSet().getVirtualEventObjects()) { if ((ArrayUtils.isEmpty(groupIds) && StringUtils.isEmpty(virtualEventObject .getNodeGroup())) || ArrayUtils.contains(groupIds, virtualEventObject.getNodeGroup())) { Map<String, List<Object>> events = EventContextHolder.getBizEvent(); DetailCollectUtils.appendAndLog("Actually intercepted message list is:" + ObjectUtil.toJson(events), log); String expEventCode = virtualEventObject.getEventCode(); String expTopic = virtualEventObject.getTopicId(); Object expPayLoad = virtualEventObject.getEventObject().getObject(); String flag = virtualEventObject.getIsExist(); String key = expEventCode + "|" + ((expTopic == null) ? "" : expTopic); replaceAllParam(expPayLoad, actsRuntimeContext.getParamMap()); if (StringUtils.equals(flag, "N")) { if (StringUtils.isBlank(expEventCode)) { Assert.assertTrue(events == null || events.isEmpty(), "Event detected, but none expectation"); } else if (events.get(key) != null) { Assert.assertTrue(false, "Unexpected event found, with " + "topicId: " + virtualEventObject.getTopicId() + " eventCode" + virtualEventObject.getEventCode() + " "); } } else if (StringUtils.equals(flag, "Y")) { List<Object> payLoads = events.get(key); boolean found = false; if (payLoads == null || payLoads.isEmpty()) { Assert.assertTrue( false, "Specified event not found, with topic:" + virtualEventObject.getTopicId() + " eventCode:" + virtualEventObject.getEventCode() + ""); } else { for (Object obj : payLoads) { if (ObjectCompareUtil.matchObj(obj, expPayLoad, virtualEventObject.getEventObject().getFlags(), actsRuntimeContext.getParamMap())) { found = true; break; } } storeExpEventObj = expPayLoad; } if (!found) { Assert.assertTrue( false, "cannot find event matching the expected payload" + "topicId: " + virtualEventObject.getTopicId() + " eventCode" + virtualEventObject.getEventCode() + "\nThe actual message list is:" + ObjectUtil.toJson(payLoads) + "\nThe expected message is:" + ObjectUtil.toJson(storeExpEventObj) + "\n" + "The error message is:" + ObjectCompareUtil.getReportStr().toString() + "\n"); DetailCollectUtils.appendAndLogColoredError( "The message check fails, and the failure message is:" + "topicId: " + virtualEventObject.getTopicId() + " eventCode" + virtualEventObject.getEventCode() + "\nThe actual message list is:" + ObjectUtil.toJson(payLoads) + "\nThe expected message is:" + ObjectUtil.toJson(storeExpEventObj) + "\n" + "The error message is:" + ObjectCompareUtil.getReportStr().toString() + "\n", log); } } } } } else { log.info("Skip event check in rpc mode"); } } catch (Exception e) { throw new ActsTestException("unknow exception raised while cheking events", e); } }
Example 16
Source File: SuperUserAction.java From rice with Educational Community License v2.0 | 4 votes |
public ActionForward actionRequestApprove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LOG.info("entering actionRequestApprove() ..."); SuperUserForm superUserForm = (SuperUserForm) form; // Retrieve the relevant arguments from the "methodToCall" parameter. String methodToCallAttr = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); superUserForm.setActionTakenRecipientCode(StringUtils.substringBetween(methodToCallAttr, KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL)); superUserForm.setActionTakenNetworkId(StringUtils.substringBetween(methodToCallAttr, KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL)); superUserForm.setActionTakenWorkGroupId(StringUtils.substringBetween(methodToCallAttr, KRADConstants.METHOD_TO_CALL_PARM4_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM4_RIGHT_DEL)); superUserForm.setActionTakenActionRequestId(StringUtils.substringBetween(methodToCallAttr, KRADConstants.METHOD_TO_CALL_PARM5_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM5_RIGHT_DEL)); LOG.debug("Routing super user action request approve action"); boolean runPostProcessorLogic = ArrayUtils.contains(superUserForm.getActionRequestRunPostProcessorCheck(), superUserForm.getActionTakenActionRequestId()); String documentId = superUserForm.getRouteHeader().getDocumentId(); WorkflowDocumentActionsService documentActions = getWorkflowDocumentActionsService(documentId); DocumentActionParameters parameters = DocumentActionParameters.create(documentId, getUserSession(request) .getPrincipalId(), superUserForm.getAnnotation()); documentActions.superUserTakeRequestedAction(parameters, runPostProcessorLogic, superUserForm.getActionTakenActionRequestId()); String messageString; String actionReqest = StringUtils.substringBetween(methodToCallAttr, KRADConstants.METHOD_TO_CALL_PARM6_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM6_RIGHT_DEL); if (actionReqest.equalsIgnoreCase("acknowledge")) { messageString = "general.routing.superuser.actionRequestAcknowledged"; } else if (actionReqest.equalsIgnoreCase("FYI")) { messageString = "general.routing.superuser.actionRequestFYI"; } else if (actionReqest.equalsIgnoreCase("complete")) { messageString = "general.routing.superuser.actionRequestCompleted"; } else if (actionReqest.equalsIgnoreCase("approved")) { messageString = "general.routing.superuser.actionRequestApproved"; } else { messageString = "general.routing.superuser.actionRequestApproved"; } saveDocumentMessage(messageString, request, superUserForm.getDocumentId(), superUserForm.getActionTakenActionRequestId()); LOG.info("exiting actionRequestApprove() ..."); superUserForm.getActionRequests().clear(); initForm(request, form); // If the action request was also an app specific request, remove it from the app specific route recipient list. int removalIndex = findAppSpecificRecipientIndex(superUserForm, superUserForm.getActionTakenActionRequestId()); if (removalIndex >= 0) { superUserForm.getAppSpecificRouteList().remove(removalIndex); } return defaultDispatch(mapping, form, request, response); }
Example 17
Source File: HopRewriteUtils.java From systemds with Apache License 2.0 | 4 votes |
public static boolean isValidOp( OpOp1 input, OpOp1... validTab ) { return ArrayUtils.contains(validTab, input); }
Example 18
Source File: CNodeUnary.java From systemds with Apache License 2.0 | 4 votes |
public boolean isSparseSafeScalar() { return ArrayUtils.contains(new UnaryType[]{ POW2, MULT2, ABS, ROUND, CEIL, FLOOR, SIGN, SIN, TAN, SPROP}, this); }
Example 19
Source File: HopRewriteUtils.java From systemds with Apache License 2.0 | 4 votes |
public static boolean isDataGenOp(Hop hop, OpOpDG... ops) { return (hop instanceof DataGenOp && ArrayUtils.contains(ops, ((DataGenOp)hop).getOp())); }
Example 20
Source File: HopRewriteUtils.java From systemds with Apache License 2.0 | 4 votes |
public static boolean isNary(Hop hop, OpOpN... types) { return ( hop instanceof NaryOp && ArrayUtils.contains(types, ((NaryOp) hop).getOp())); }