List of usage examples for java.util Collections list
public static <T> ArrayList<T> list(Enumeration<T> e)
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private static String buildCanonicalHeaders(HttpServletRequest request, String[] signedHeaders) { List<String> headers = new ArrayList<>(); for (String header : signedHeaders) { headers.add(header.toLowerCase()); }// w w w . j ava 2 s . com Collections.sort(headers); List<String> headersWithValues = new ArrayList<>(); for (String header : headers) { List<String> values = new ArrayList<>(); StringBuilder headerWithValue = new StringBuilder(); headerWithValue.append(header); headerWithValue.append(":"); for (String value : Collections.list(request.getHeaders(header))) { value = value.trim(); if (!value.startsWith("\"")) { value = value.replaceAll("\\s+", " "); } values.add(value); } headerWithValue.append(Joiner.on(",").join(values)); headersWithValues.add(headerWithValue.toString()); } return Joiner.on("\n").join(headersWithValues); }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private static void addContentMetdataFromHttpRequest(BlobBuilder.PayloadBlobBuilder builder, HttpServletRequest request) {// ww w. jav a 2 s . c o m ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { userMetadata.put(headerName.substring(USER_METADATA_PREFIX.length()), Strings.nullToEmpty(request.getHeader(headerName))); } } builder.cacheControl(request.getHeader(HttpHeaders.CACHE_CONTROL)) .contentDisposition(request.getHeader(HttpHeaders.CONTENT_DISPOSITION)) .contentEncoding(request.getHeader(HttpHeaders.CONTENT_ENCODING)) .contentLanguage(request.getHeader(HttpHeaders.CONTENT_LANGUAGE)) .userMetadata(userMetadata.build()); String contentType = request.getContentType(); if (contentType != null) { builder.contentType(contentType); } long expires = request.getDateHeader(HttpHeaders.EXPIRES); if (expires != -1) { builder.expires(new Date(expires)); } }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private static String buildCanonicalQueryString(HttpServletRequest request) throws UnsupportedEncodingException { // The parameters are required to be sorted List<String> parameters = Collections.list(request.getParameterNames()); Collections.sort(parameters); List<String> queryParameters = new ArrayList<>(); for (String key : parameters) { if (key.equals("X-Amz-Signature")) { continue; }// ww w . java 2 s.c o m // re-encode keys and values in AWS normalized form String value = request.getParameter(key); queryParameters .add(AWS_URL_PARAMETER_ESCAPER.escape(key) + "=" + AWS_URL_PARAMETER_ESCAPER.escape(value)); } return Joiner.on("&").join(queryParameters); }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private void runTimer() { if (interruptTimer != null) { interruptTimer.cancel();/*from w w w . j av a2 s. c o m*/ } interruptTimer = new Timer(); interruptTimer.schedule(new TimerTask() { Hashtable<Long, Integer> oldInterruptRecords; public void run() { try { synchronized (allSeries) { ArrayList<Long> list = Collections.list(InterruptSocketServer.interruptRecords.keys()); Date d = new Date(); // int noOfFrame = getTimeframe() / getSpeed(); oldInterruptRecords = (Hashtable<Long, Integer>) InterruptSocketServer.interruptRecords .clone(); ((InterruptTableModel) jInterruptTable.getModel()).fireTableDataChanged(); for (int x = 0; x < list.size(); x++) { long interuptNoL = list.get(x); int interruptNo = (int) interuptNoL; if (allSeries.get(interruptNo) != null) { TimeSeries series = allSeries.get(interruptNo); List<TimeSeriesDataItem> items = series.getItems(); for (int z = items.size() - 1; z >= 0; z--) { RegularTimePeriod pd = items.get(z).getPeriod(); Calendar cal1 = Calendar.getInstance(); cal1.add(Calendar.MILLISECOND, -1 * getTimeframe()); Calendar cal2 = Calendar.getInstance(); cal2.setTime(pd.getEnd()); if (cal1.after(cal2)) { series.delete(pd); } } series.add(new Millisecond(d), InterruptSocketServer.interruptRecords.get(interuptNoL) - oldInterruptRecords.get(interuptNoL)); // InterruptSocketServer.interruptRecords.put(interuptNoL, 0); } else { TimeSeries newSeries = new TimeSeries("Int 0x" + Integer.toHexString(interruptNo)); interruptDataset.addSeries(newSeries); allSeries.put(interruptNo, newSeries); } } interruptChart.fireChartChanged(); } } catch (Exception ex) { ex.printStackTrace(); } } }, 0, getSpeed()); }
From source file:org.adl.sequencer.impl.ADLSequencer.java
/** * Displays the values of the <code>ADLTOC</code> objects that constitute * table of contents. This method is used for diagnostic purposes. * //from ww w . ja v a 2s. c o m * @param iOldTOC * A List of <code>ADLTOC</code> objects describing the * 'first pass' TOC. * * @param oNewTOC * A List of <code>ADLTOC</code> objects describing the * 'final pass' TOC. * * @return The set of valid activity IDs for 'Choice' navigation requests. */ private Hashtable<String, ActivityNode> getChoiceSet(TreeModel treeModel) { Hashtable<String, ActivityNode> set = null; String lastLeaf = null; if (treeModel != null) { ActivityNode tempNode = null; set = new Hashtable<String, ActivityNode>(); ActivityNode rootNode = (ActivityNode) treeModel.getRoot(); if (rootNode != null) { @SuppressWarnings("unchecked") Enumeration<ActivityNode> breadthFirst = rootNode.breadthFirstEnumeration(); List<ActivityNode> bfList = Collections.list(breadthFirst); // Traverse the breadth-first search backwards for (int i = bfList.size() - 1; i > 0; i--) { tempNode = bfList.get(i); if (tempNode.getDepth() == -1) { if (tempNode.isSelectable()) { set.put(tempNode.getActivity().getID(), tempNode); } } else if (!tempNode.isHidden()) { set.put(tempNode.getActivity().getID(), tempNode); } if (lastLeaf == null) { if (tempNode.isLeaf() && tempNode.isEnabled()) { lastLeaf = tempNode.getActivity().getID(); } } } } } if (lastLeaf != null) { if (_Debug) { System.out.println(" ::--> Setting last leaf --> " + lastLeaf); } mSeqTree.setLastLeaf(lastLeaf); } // If there are no items in the set, there is no TOC. if (set != null && set.isEmpty()) { set = null; } // TODO: JLR -- think we might be able to live without this... 9/10/2007 // If there is only one item in the set, it must be the root -- remove // it // If there is only one item in the set, it is the parent of a // choiceExit == false cluster, it cannot be selected -- no TOC /*if (oNewTOC.size() == 1) { ADLTOC temp = (ADLTOC) oNewTOC.get(0); if (!temp.mIsEnabled) { if (_Debug) { System.out.println(" ::--> Clearing single non-enabled " + " activity"); } oNewTOC.remove(0); } else if (!temp.mLeaf) { if (_Debug) { System.out.println(" ::--> Clearing root activity"); } oNewTOC.remove(0); } }*/ return set; }
From source file:com.netscape.ca.CertificateAuthority.java
private synchronized void readAuthority(LDAPEntry entry) { String nsUniqueId = entry.getAttribute("nsUniqueId").getStringValueArray()[0]; if (deletedNsUniqueIds.contains(nsUniqueId)) { logger.warn("readAuthority: ignoring entry with nsUniqueId '" + nsUniqueId + "' due to deletion"); return;/*from w ww .j a va 2s. com*/ } LDAPAttribute aidAttr = entry.getAttribute("authorityID"); LDAPAttribute nickAttr = entry.getAttribute("authorityKeyNickname"); LDAPAttribute keyHostsAttr = entry.getAttribute("authorityKeyHost"); LDAPAttribute dnAttr = entry.getAttribute("authorityDN"); LDAPAttribute parentAIDAttr = entry.getAttribute("authorityParentID"); LDAPAttribute parentDNAttr = entry.getAttribute("authorityParentDN"); LDAPAttribute serialAttr = entry.getAttribute("authoritySerial"); if (aidAttr == null || nickAttr == null || dnAttr == null) { logger.warn("Malformed authority object; required attribute(s) missing: " + entry.getDN()); return; } AuthorityID aid = new AuthorityID((String) aidAttr.getStringValues().nextElement()); X500Name dn = null; try { dn = new X500Name((String) dnAttr.getStringValues().nextElement()); } catch (IOException e) { logger.warn("Malformed authority object; invalid authorityDN: " + entry.getDN() + ": " + e.getMessage(), e); } String desc = null; LDAPAttribute descAttr = entry.getAttribute("description"); if (descAttr != null) desc = (String) descAttr.getStringValues().nextElement(); /* Determine if it is the host authority's entry, by * comparing DNs. DNs must be serialised in case different * encodings are used for AVA values, e.g. PrintableString * from LDAP vs UTF8String in certificate. */ if (dn.toString().equals(mName.toString())) { logger.debug("Found host authority"); foundHostAuthority = true; this.authorityID = aid; this.authorityDescription = desc; caMap.put(aid, this); return; } BigInteger newEntryUSN = null; LDAPAttribute entryUSNAttr = entry.getAttribute("entryUSN"); if (entryUSNAttr == null) { logger.debug("readAuthority: no entryUSN"); if (!entryUSNPluginEnabled()) { logger.warn("readAuthority: dirsrv USN plugin is not enabled; skipping entry"); log(ILogger.LL_FAILURE, "Lightweight authority entry has no" + " entryUSN attribute and USN plugin not enabled;" + " skipping. Enable dirsrv USN plugin."); return; } else { logger.debug("readAuthority: dirsrv USN plugin is enabled; continuing"); // entryUSN plugin is enabled, but no entryUSN attribute. We // can proceed because future modifications will result in the // entryUSN attribute being added. } } else { newEntryUSN = new BigInteger(entryUSNAttr.getStringValueArray()[0]); logger.debug("readAuthority: new entryUSN = " + newEntryUSN); } BigInteger knownEntryUSN = entryUSNs.get(aid); if (newEntryUSN != null && knownEntryUSN != null) { logger.debug("readAuthority: known entryUSN = " + knownEntryUSN); if (newEntryUSN.compareTo(knownEntryUSN) <= 0) { logger.debug("readAuthority: data is current"); return; } } @SuppressWarnings("unused") X500Name parentDN = null; if (parentDNAttr != null) { try { parentDN = new X500Name((String) parentDNAttr.getStringValues().nextElement()); } catch (IOException e) { logger.warn("Malformed authority object; invalid authorityParentDN: " + entry.getDN() + ": " + e.getMessage(), e); return; } } String keyNick = (String) nickAttr.getStringValues().nextElement(); Collection<String> keyHosts; if (keyHostsAttr == null) { keyHosts = Collections.emptyList(); } else { @SuppressWarnings("unchecked") Enumeration<String> keyHostsEnum = keyHostsAttr.getStringValues(); keyHosts = Collections.list(keyHostsEnum); } AuthorityID parentAID = null; if (parentAIDAttr != null) parentAID = new AuthorityID((String) parentAIDAttr.getStringValues().nextElement()); BigInteger serial = null; if (serialAttr != null) serial = new BigInteger(serialAttr.getStringValueArray()[0]); boolean enabled = true; LDAPAttribute enabledAttr = entry.getAttribute("authorityEnabled"); if (enabledAttr != null) { String enabledString = (String) enabledAttr.getStringValues().nextElement(); enabled = enabledString.equalsIgnoreCase("TRUE"); } try { CertificateAuthority ca = new CertificateAuthority(hostCA, dn, aid, parentAID, serial, keyNick, keyHosts, desc, enabled); caMap.put(aid, ca); entryUSNs.put(aid, newEntryUSN); nsUniqueIds.put(aid, nsUniqueId); } catch (EBaseException e) { logger.warn("Error initialising lightweight CA: " + e.getMessage(), e); } }
From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java
private DefaultComboBoxModel<Object> generateNetworkInterfacesModel() { DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(); try {/*from www .j a va 2s . com*/ List<NetworkInterface> nics = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface nic : nics) { List<InetAddress> addrs = Collections.list(nic.getInetAddresses()); if (addrs.size() > 0 && !nic.isLoopback() && nic.isUp()) { model.addElement(nic); } } } catch (SocketException e) { logger.warn( "An exception occurred while iterating over available network interfaces. Will return unfinished list: ", e); } return model; }
From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java
private DefaultComboBoxModel<Object> generateNetworkAddressModel(NetworkInterface nic) { DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(); List<InetAddress> addrs = Collections.list(nic.getInetAddresses()); for (InetAddress addr : addrs) { if (addr instanceof Inet4Address) { // ignore IPv6 addresses!!! model.addElement(addr);/*from www . j a va 2 s.c o m*/ } } return model; }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Set the datObj into the form but controls * @param dataObj the data object// w ww .j a v a 2 s .c om * @param alreadyInTheList indicates whether this dataObj is already in the list of data objects we are working with */ @SuppressWarnings("unchecked") protected void setDataObj(final Object dataObj, final boolean alreadyInTheList) { // Setting up Carry Forward Object when the object already exists // usually from a search if (dataObj instanceof FormDataObjIFace && ((FormDataObjIFace) dataObj).getId() != null) { carryFwdDataObj = dataObj; } //log.debug("Setting DataObj["+dataObj+"]"); // rods - Added 3/21/08 because switching from the Grid View // back to the Form View causes the "+" button to be disabled and this // is because it thinks it is a newly created object for some reason isNewlyCreatedDataObj = false; // Convert the Set over to a List so the RecordController can be used Object data = dataObj; if (!alreadyInTheList) { if (data instanceof java.util.Set) { origDataSet = (Set) dataObj; List newList = Collections.list(Collections.enumeration(origDataSet)); data = newList; if (newList.size() > 0) { if (newList.get(0) instanceof Comparable<?>) { Collections.sort(newList); } } } } // If there is a formValidator then we set the current object into the formValidator's scripting context // then turn off change notification while the form is filled if (formValidator != null && dataObj != null) { formValidator.addRuleObjectMapping("dataObj", dataObj); } if (selectorCBX != null) { selectorCBX.setEnabled(true); } boolean isList; boolean isVector; // if we do have a list then get the first object or null if (data instanceof Vector) { isList = true; isVector = true; } else if (data instanceof List) { isList = true; isVector = false; } else { isList = false; isVector = false; } for (FVOFieldInfo fieldInfo : controlsById.values()) { if (fieldInfo.isOfType(FormCellIFace.CellType.subview) || fieldInfo.isOfType(FormCellIFace.CellType.iconview)) { MultiView mv = fieldInfo.getSubView(); if (mv != null) { mv.setParentDataObj(null); } else { ((SubViewBtn) fieldInfo.getComp()).setParentDataObj(null); } } /*if (isEditing && fieldInfo.getComp() instanceof EditViewCompSwitcherPanel) { if (isDataValueNew) { ((EditViewCompSwitcherPanel)fieldInfo.getComp()).putIntoEditMode(); } else { ((EditViewCompSwitcherPanel)fieldInfo.getComp()).putIntoViewMode(); } }*/ } // if we do have a list then get the first object or null if (isList) { if (isVector) { list = (Vector) data; } else { list = new Vector<Object>((List<?>) data); } if (list.size() > 0) { this.dataObj = list.get(0); carryFwdDataObj = this.dataObj; //log.debug("Getting DO from list "+this.dataObj.getClass().getSimpleName()+" "+this.dataObj.hashCode()); } else { this.dataObj = null; } // Now tell the RecordController how many Object we have if (rsController != null) { int len = list.size(); if (AppContextMgr.isSecurityOn()) { ensurePermissions(); if (perm.hasNoPerm()) { len = 0; } } rsController.setLength(len); //updateControllerUI(); } // Set the data from the into the form setDataIntoUI(); } else { // OK, it is a single data object this.dataObj = dataObj; if (!alreadyInTheList && (this.list != null && this.dataObj != dataObj)) { this.list = null; } setDataIntoUI(); // Don't remove the rsController if the data is NULL because the next non-null one may be a list // mostly likely it will be if (rsController != null) { if (this.dataObj != null) { // I added this 'if' and I have no idea why the call was here in the first place. - rods // was it here for PaleoContext ????? if (!alreadyInTheList) { //controlPanel.setRSCVisibility(!isEditting); rsController.reset(); // rods - 07/07/08 just moved this into the this 'if' statement // it has already caused problems not being n there. } } else { rsController.clear(); } updateControllerUI(); } } }