List of usage examples for java.util List listIterator
ListIterator<E> listIterator();
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java
public String generateHtml(List nonListedVVs, List availableValidVaues, String questionIdSeq) { StringBuffer selectHtml = new StringBuffer( "<select class=\"" + selectClassName + "\" name=\"" + selectName + "\"> \n"); StringBuffer optionHtml = (StringBuffer) pageContext.getAttribute(questionIdSeq + "validValueOptionBuffer"); ///* w w w .ja v a2 s. co m*/ //The options are cached since they dont change for the same question // if (optionHtml != null) { return selectHtml.toString() + optionHtml.toString(); } optionHtml = new StringBuffer(); ListIterator avalilableVVsListIterate = nonListedVVs.listIterator(); while (avalilableVVsListIterate.hasNext()) { FormValidValue fvv = (FormValidValue) avalilableVVsListIterate.next(); int index = availableValidVaues.indexOf(fvv); optionHtml.append("<option value=\"" + index + "\">" + fvv.getLongName() + "</option> \n"); } optionHtml.append("</select>"); pageContext.setAttribute(questionIdSeq + "validValueOptionBuffer", optionHtml); return selectHtml.toString() + optionHtml.toString(); }
From source file:org.codice.ddf.condpermadmin.PermissionActivator.java
@Override public void grantPermission(String bundle, String permission) throws Exception { synchronized (this) { // use the parsed policy to make it easier to parse the permission string final ParsedPolicy parsedPolicy = new Parser(false).parse(new StringReader( String.format("grant codebase \"file:/%s\" { permission %s; }", bundle, permission))); final List<ParsedPolicyEntry> grantEntries = parsedPolicy.getGrantEntries(); final List<ConditionalPermissionInfo> allGrantInfos = new ArrayList<>(); final ConditionalPermissionUpdate conditionalPermissionUpdate = conditionalPermissionAdmin .newConditionalPermissionUpdate(); buildConditionalPermissionInfo(grantEntries, allGrantInfos, ConditionalPermissionInfo.ALLOW); final ConditionalPermissionInfo grantInfo = allGrantInfos.get(0); final List<ConditionalPermissionInfo> conditionalInfos = conditionalPermissionUpdate .getConditionalPermissionInfos(); boolean added = false; // see if we can find one conditional permission for the exact same permission // if we do, let's just add this new bundle to the list as opposed to adding a // brand new conditional permission for (final ListIterator<ConditionalPermissionInfo> i = conditionalInfos.listIterator(); i.hasNext();) { final ConditionalPermissionInfo permInfo = i.next(); if (Objects.equals(grantInfo.getAccessDecision(), permInfo.getAccessDecision()) && Arrays.equals(grantInfo.getPermissionInfos(), permInfo.getPermissionInfos())) { final ConditionInfo[] conditions = permInfo.getConditionInfos(); if ((conditions != null) && (conditions.length == 1) && BUNDLE_NAME_CONDITION.equals(conditions[0].getType())) { final String[] bundles = conditions[0].getArgs(); final String[] newBundles = new String[bundles.length + 1]; System.arraycopy(bundles, 0, newBundles, 0, bundles.length); newBundles[bundles.length] = bundle; final ConditionalPermissionInfo newPermInfo = conditionalPermissionAdmin .newConditionalPermissionInfo(permInfo.getName(), new ConditionInfo[] { new ConditionInfo(BUNDLE_NAME_CONDITION, newBundles) }, permInfo.getPermissionInfos(), permInfo.getAccessDecision()); i.set(newPermInfo);/*from w w w . j av a2 s . c om*/ added = true; break; } } } if (!added) { // if priority is to grant then insert at the top, otherwise insert before // the last entry which always reference an all-permission to deny final int index = (priorityResult == Priority.GRANT) ? 0 : conditionalInfos.size() - 1; conditionalInfos.add(index, grantInfo); } conditionalPermissionUpdate.commit(); } }
From source file:org.apache.ranger.biz.RangerTagDBRetriever.java
private List<RangerTagResourceMap> getAllTagResourceMaps() { List<XXTagResourceMap> xTagResourceMaps = daoMgr.getXXTagResourceMap() .findForServicePlugin(xService.getId()); ListIterator<XXTagResourceMap> iterTagResourceMap = xTagResourceMaps.listIterator(); List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>(); while (iterTagResourceMap.hasNext()) { XXTagResourceMap xTagResourceMap = iterTagResourceMap.next(); if (xTagResourceMap != null) { RangerTagResourceMap tagResourceMap = new RangerTagResourceMap(); tagResourceMap.setId(xTagResourceMap.getId()); tagResourceMap.setGuid(xTagResourceMap.getGuid()); tagResourceMap.setCreatedBy(lookupCache.getUserScreenName(xTagResourceMap.getAddedByUserId())); tagResourceMap.setUpdatedBy(lookupCache.getUserScreenName(xTagResourceMap.getUpdatedByUserId())); tagResourceMap.setCreateTime(xTagResourceMap.getCreateTime()); tagResourceMap.setUpdateTime(xTagResourceMap.getUpdateTime()); tagResourceMap.setResourceId(xTagResourceMap.getResourceId()); tagResourceMap.setTagId(xTagResourceMap.getTagId()); ret.add(tagResourceMap);//w w w . j a v a 2s . c o m } } return ret; }
From source file:com.oneops.daq.dao.LogDao.java
/** * Gets the log data.//from w ww . ja va 2 s . co m * * @param req the req * @return the log data */ public GetLogDataResponse getLogData(GetLogDataRequest req) { // Long start = new Long(req.getStart()); Long start = Long.valueOf(req.getStart()); // Long end = new Long(req.getEnd()); Long end = Long.valueOf(req.getEnd()); int maxColumns = 10000; GetLogDataResponse resp = new GetLogDataResponse(req); List<LogData> logData = new ArrayList<LogData>(); try { long startTime = System.currentTimeMillis(); MultigetSliceQuery<byte[], com.eaio.uuid.UUID, String> multigetSliceQuery = HFactory .createMultigetSliceQuery(keyspace, bytesSerializer, timeuuidSerializer, stringSerializer); multigetSliceQuery.setColumnFamily(LOG_DATA_CF); List<byte[]> keys = new ArrayList<byte[]>(); // can be null=all or debug, info, warn, error, fatal String levelList = req.getLevelList(); List<String> levels = null; if (levelList == null || levelList.equalsIgnoreCase("all")) { levels = Arrays.asList(allLogLevels); } else { levels = Arrays.asList(levelList.split(",")); } // String keyBase = new Long(req.getCi_id()).toString(); String keyBase = Long.valueOf(req.getCi_id()).toString(); String classList = req.getClassList(); List<String> classes = null; if (classList == null) { classes = Arrays.asList(basicLogClasses); } else { classes = Arrays.asList(levelList.split(",")); } for (String logClass : classes) { /* if ( logClass.equalsIgnoreCase("all") ) { for (int j=0; j<basicLogClasses.length; j++) { classes.add(basicLogClasses[j]); } continue; } */ for (String level : levels) { /* if ( level.contains("+") ) { String startingLevel = logClass.replace("+",""); Boolean logLevelPassed = false; for (int j=0; j<allLogTypes.length; j++) { String lc = allLogTypes[j]; if (lc.equalsIgnoreCase(startingLevel)) { logLevelPassed = true; } if (logLevelPassed) { levels.add(lc); } } continue; } */ logger.debug("appending level:" + level); keys.add((keyBase + ":" + logClass + ":" + level).getBytes()); } } multigetSliceQuery.setKeys(keys); UUID startUuid = new UUID(start, UUIDGen.getClockSeqAndNode()); UUID endUuid = new UUID(end, UUIDGen.getClockSeqAndNode()); multigetSliceQuery.setRange(startUuid, endUuid, false, maxColumns); logger.debug("start:" + start + " end:" + end + " for: " + keyBase + ":" + levelList); QueryResult<Rows<byte[], UUID, String>> result = multigetSliceQuery.execute(); Rows<byte[], UUID, String> rows = result.get(); long endTime = System.currentTimeMillis(); long cassDuration = endTime - startTime; // put the by-metric results into 1 csv-like table (time,metric1,metric2,etc) // ... should find faster way to do this, but still 10x faster than gwt DataTable serialization int rowCount = 0; for (Row<byte[], UUID, String> row : rows) { String rowName = new String(row.getKey()); String[] keyParts = rowName.split(":"); String logClass = keyParts[1]; String level = keyParts[2]; List<HColumn<UUID, String>> cols = row.getColumnSlice().getColumns(); Iterator<HColumn<UUID, String>> listIter = cols.listIterator(); while (listIter.hasNext()) { HColumn<UUID, String> c = (HColumn<UUID, String>) listIter.next(); LogData logEntry = new LogData(); UUID uuid = c.getName(); logEntry.setTimestamp(uuid.getTime()); logEntry.setMessage(c.getValue()); logEntry.setLevel(level); logEntry.setLogClass(logClass); logData.add(logEntry); rowCount++; } } resp.setLogData(logData); endTime = System.currentTimeMillis(); long duration = endTime - startTime; logger.debug("getLogData took: " + duration + " ms (cass query:" + cassDuration + " ms) returning:" + rowCount + " rows"); } catch (HectorException he) { he.printStackTrace(); } return resp; }
From source file:br.com.ingenieux.mojo.beanstalk.env.ReplaceEnvironmentMojo.java
/** * Prior to Launching a New Environment, lets look and copy the most we can * * @param curEnv current environment// www . j av a 2 s. c om */ private void copyOptionSettings(EnvironmentDescription curEnv) throws Exception { /** * Skip if we don't have anything */ if (null != this.optionSettings && this.optionSettings.length > 0) { return; } DescribeConfigurationSettingsResult configSettings = getService() .describeConfigurationSettings(new DescribeConfigurationSettingsRequest() .withApplicationName(applicationName).withEnvironmentName(curEnv.getEnvironmentName())); List<ConfigurationOptionSetting> newOptionSettings = new ArrayList<ConfigurationOptionSetting>( configSettings.getConfigurationSettings().get(0).getOptionSettings()); ListIterator<ConfigurationOptionSetting> listIterator = newOptionSettings.listIterator(); while (listIterator.hasNext()) { ConfigurationOptionSetting curOptionSetting = listIterator.next(); boolean bInvalid = harmfulOptionSettingP(curEnv.getEnvironmentId(), curOptionSetting); if (bInvalid) { getLog().info(format("Excluding Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); listIterator.remove(); } else { getLog().info(format("Including Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); } } Object __secGroups = project.getProperties().get("beanstalk.securityGroups"); if (null != __secGroups) { String securityGroups = StringUtils.defaultString(__secGroups.toString()); if (!StringUtils.isBlank(securityGroups)) { ConfigurationOptionSetting newOptionSetting = new ConfigurationOptionSetting( "aws:autoscaling:launchconfiguration", "SecurityGroups", securityGroups); newOptionSettings.add(newOptionSetting); getLog().info(format("Including Option Setting: %s:%s['%s']", newOptionSetting.getNamespace(), newOptionSetting.getOptionName(), newOptionSetting.getValue())); } } /* * Then copy it back */ this.optionSettings = newOptionSettings.toArray(new ConfigurationOptionSetting[newOptionSettings.size()]); }
From source file:com.taobao.gecko.service.impl.GeckoHandler.java
private boolean removeDisconnectedConnection(final String group) { // connection) final List<Connection> currentConnList = this.remotingController.getRemotingContext() .getConnectionsByGroup(group); Connection disconnectedConn = null; if (currentConnList != null) { synchronized (currentConnList) { final ListIterator<Connection> it = currentConnList.listIterator(); while (it.hasNext()) { final Connection currentConn = it.next(); if (!currentConn.isConnected()) { disconnectedConn = currentConn; break; } else { // // if (!((DefaultConnection) currentConn).isReady() && !currentConn.getGroupSet().isEmpty()) { this.notifyConnectionReady((DefaultConnection) currentConn); }//from ww w .j av a 2 s .c om } } } } if (disconnectedConn != null) { return currentConnList.remove(disconnectedConn); } else { return false; } }
From source file:org.sakaiproject.poll.service.impl.PollListManagerImpl.java
public List<Option> getVisibleOptionsForPoll(Long pollId) { List<Option> options = getOptionsForPoll(pollId); //iterate and remove deleted options for (Iterator<Option> i = options.listIterator(); i.hasNext();) { Option o = i.next();//ww w. j a v a2 s. c om if (o == null || o.getDeleted()) { i.remove(); } } return options; }
From source file:com.alibaba.napoli.gecko.service.impl.GeckoHandler.java
private boolean removeDisconnectedConnection(final String group) { // ???connection??) final List<Connection> currentConnList = this.remotingController.getRemotingContext() .getConnectionsByGroup(group); Connection disconnectedConn = null; if (currentConnList != null) { synchronized (currentConnList) { final ListIterator<Connection> it = currentConnList.listIterator(); while (it.hasNext()) { final Connection currentConn = it.next(); if (!currentConn.isConnected()) { disconnectedConn = currentConn; break; } else { // ????? // ??? if (!((DefaultConnection) currentConn).isReady() && !currentConn.getGroupSet().isEmpty()) { this.notifyConnectionReady((DefaultConnection) currentConn); }// w w w . j a va2 s . c o m } } } } if (disconnectedConn != null) { return currentConnList.remove(disconnectedConn); } else { return false; } }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
private Map<GraphicNode, List<GraphicNode>> extractAssignments(List list) { Map<GraphicNode, List<GraphicNode>> map = new HashMap<GraphicNode, List<GraphicNode>>(); GraphicNode current, last;//www .j a v a2s . c om Stack<GraphicNode> path = new Stack<GraphicNode>(); for (ListIterator i = list.listIterator(); i.hasNext();) { current = (GraphicNode) i.next(); if (current.getLevel() == 1) { path.clear(); path.push(current); continue; } while ((last = path.peek()).getLevel() >= current.getLevel()) path.pop(); if (current.isAssignment()) { GraphicNode task = path.peek(); List<GraphicNode> ass = map.get(task); if (ass == null) { ass = new LinkedList<GraphicNode>(); map.put(task, ass); } ass.add(current); i.remove(); } path.push(current); } return map; }
From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java
/** * Add directories to playlistUI./*from w ww . jav a2 s . c o m*/ * @param folderList */ public void addDirs(List folderList) { if (folderList.size() > 0) { ListIterator it = folderList.listIterator(); while (it.hasNext()) { addDir((File) it.next()); } } }