List of usage examples for java.util Collections list
public static <T> ArrayList<T> list(Enumeration<T> e)
From source file:org.opencms.workplace.tools.workplace.logging.CmsLog4JAdminDialog.java
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() *///ww w .ja v a 2 s . c om @Override protected List<CmsListItem> getListItems() { // collect all the values for "Log-channels", "Log-channels-parents" and "Log-channels-level" List<CmsListItem> items = new LinkedList<CmsListItem>(); List<Logger> loggers = getLoggers(); Iterator<Logger> iterator = loggers.iterator(); while (iterator.hasNext()) { Logger logger = iterator.next(); CmsListItem item = getList().newItem(logger.getName()); item.set(COLUMN_CHANNELS, logger.getName()); Category parentLogger = logger.getParent(); if (parentLogger == null) { item.set(COLUMN_PARENT_CHANNELS, ""); } else { item.set(COLUMN_PARENT_CHANNELS, logger.getParent().getName()); } item.set(COLUMN_LOG_LEVEL, String.valueOf(logger.getEffectiveLevel())); String test = ""; @SuppressWarnings("unchecked") List<Appender> appenders = Collections.list(logger.getAllAppenders()); Iterator<Appender> appendersIt = appenders.iterator(); int count = 0; // select the Appender from logger while (appendersIt.hasNext()) { Appender appender = appendersIt.next(); // only use file appenders if (appender instanceof FileAppender) { FileAppender fapp = (FileAppender) appender; String temp = ""; temp = fapp.getFile().substring(fapp.getFile().lastIndexOf(File.separatorChar) + 1); test = test + temp; count++; break; } } @SuppressWarnings("unchecked") List<Appender> parentAppenders = Collections.list(logger.getParent().getAllAppenders()); Iterator<Appender> parentAppendersIt = parentAppenders.iterator(); // if no Appender found from logger, select the Appender from parent logger if (count == 0) { while (parentAppendersIt.hasNext()) { Appender appender = parentAppendersIt.next(); // only use file appenders if (appender instanceof FileAppender) { FileAppender fapp = (FileAppender) appender; String temp = ""; temp = fapp.getFile().substring(fapp.getFile().lastIndexOf(File.separatorChar) + 1); test = test + temp; count++; break; } } } if (count == 0) { @SuppressWarnings("unchecked") List<Appender> rootAppenders = Collections.list(Logger.getRootLogger().getAllAppenders()); Iterator<Appender> rootAppendersIt = rootAppenders.iterator(); // if no Appender found from parent logger, select the Appender from root logger while (rootAppendersIt.hasNext()) { Appender appender = rootAppendersIt.next(); // only use file appenders if (appender instanceof FileAppender) { FileAppender fapp = (FileAppender) appender; String temp = ""; temp = fapp.getFile().substring(fapp.getFile().lastIndexOf(File.separatorChar) + 1); test = test + temp; break; } } } item.set(COLUMN_LOG_FILE, test); items.add(item); } return items; }
From source file:org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataUtil.java
@SuppressWarnings("unchecked") public static Map<String, MetadataField<?>> getDublinCoreProperties(Dictionary configProperties) { Map<String, MetadataField<?>> dublinCorePropertyMapByConfigurationName = new HashMap<String, MetadataField<?>>(); for (Object configObject : Collections.list(configProperties.keys())) { String property = configObject.toString(); if (getDublinCorePropertyName(property).isSome()) { MetadataField<?> dublinCoreProperty = dublinCorePropertyMapByConfigurationName .get(getDublinCorePropertyName(property).get()); if (dublinCoreProperty == null) { dublinCoreProperty = new MetadataField(); }//w w w. j a v a2s . com dublinCoreProperty.setValue(getDublinCorePropertyKey(property).get(), configProperties.get(property).toString()); dublinCorePropertyMapByConfigurationName.put(getDublinCorePropertyName(property).get(), dublinCoreProperty); } } Map<String, MetadataField<?>> dublinCorePropertyMap = new TreeMap<String, MetadataField<?>>(); for (MetadataField dublinCoreProperty : dublinCorePropertyMapByConfigurationName.values()) { dublinCorePropertyMap.put(dublinCoreProperty.getOutputID(), dublinCoreProperty); } return dublinCorePropertyMap; }
From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdmin.java
@Override public List<Service> allRegistryInfo() { List<Service> metatypes = helper.getMetatypes(); for (Service metatype : metatypes) { try {//from w w w .j a va 2 s. c o m List<Configuration> configs = helper.getConfigurations(metatype); List<ConfigurationDetails> configurations = new ArrayList<>(); if (configs != null) { for (Configuration config : configs) { ConfigurationDetails registry = new ConfigurationDetailsImpl(); boolean disabled = config.getPid().endsWith(DISABLED); registry.setId(config.getPid()); registry.setEnabled(!disabled); registry.setFactoryPid(config.getFactoryPid()); if (!disabled) { registry.setName(helper.getName(config)); registry.setBundleName(helper.getBundleName(config)); registry.setBundleLocation(config.getBundleLocation()); registry.setBundle(helper.getBundleId(config)); } else { registry.setName(config.getPid()); } Dictionary<String, Object> properties = config.getProperties(); ConfigurationProperties plist = new ConfigurationPropertiesImpl(); for (String key : Collections.list(properties.keys())) { plist.put(key, properties.get(key)); } registry.setConfigurationProperties(plist); configurations.add(registry); } metatype.setConfigurations(configurations); } } catch (InvalidSyntaxException | IOException e) { LOGGER.info("Error getting registry info:", e); } } Collections.sort(metatypes, (o1, o2) -> ((String) o1.get("id")).compareToIgnoreCase((String) o2.get("id"))); return metatypes; }
From source file:com.iorga.webappwatcher.RequestLogFilter.java
@SuppressWarnings("unchecked") @Override// www .j ava2s.c om public void init(final FilterConfig filterConfig) throws ServletException { // Initializing context final CpuCriticalUsageWatcher cpuCriticalUsageWatcher = new CpuCriticalUsageWatcher(); parametersContext.put(CpuCriticalUsageWatcher.class, cpuCriticalUsageWatcher); final WriteAllRequestsWatcher writeAllRequestsWatcher = new WriteAllRequestsWatcher(); parametersContext.put(WriteAllRequestsWatcher.class, writeAllRequestsWatcher); final RequestDurationWatcher requestDurationWatcher = new RequestDurationWatcher(); parametersContext.put(RequestDurationWatcher.class, requestDurationWatcher); final RetentionLogWritingWatcher retentionLogWritingWatcher = createRetentionLogWritingWatcher(); parametersContext.put(RetentionLogWritingWatcher.class, retentionLogWritingWatcher); final EventLogManager eventLogManager = EventLogManager.getInstance(); parametersContext.put(EventLogManager.class, eventLogManager); systemEventLogger = new SystemEventLogger(); parametersContext.put(SystemEventLogger.class, systemEventLogger); parametersContext.put(RequestLogFilter.class, this); // by default, watch the CPU peaks, the request duration & write all requests to the log eventLogManager.setEventLogWatchers(Sets.newHashSet(cpuCriticalUsageWatcher, requestDurationWatcher, writeAllRequestsWatcher, retentionLogWritingWatcher)); // Reading web.xml filterConfig init-params for (final String parameterName : (List<String>) Collections.list(filterConfig.getInitParameterNames())) { final String value = filterConfig.getInitParameter(parameterName); setParameter(parameterName, value); } // Reading "webappwatcher.properties" parameters try { final Properties properties = new Properties(); final InputStream propertiesStream = getClass().getClassLoader() .getResourceAsStream("webappwatcher.properties"); if (propertiesStream != null) { properties.load(propertiesStream); for (final Entry<Object, Object> property : properties.entrySet()) { setParameter((String) property.getKey(), (String) property.getValue()); } } } catch (final IOException e) { throw new ServletException("Problem while reading webappwatcher.properties file", e); } startServices(); }
From source file:de.alpharogroup.lang.ClassExtensions.java
/** * Gets a list with urls from the given path for all resources. * * @param path/*from www. ja v a 2s . c om*/ * The base path. * @return The resources. * @throws IOException * Signals that an I/O exception has occurred. */ public static List<URL> getResources(final String path) throws IOException { final ClassLoader classLoader = ClassExtensions.getClassLoader(); final List<URL> list = Collections.list(classLoader.getResources(path)); return list; }
From source file:org.archive.modules.fetcher.FetchHTTPTests.java
public void testHttpBindAddress() throws Exception { List<InetAddress> addrList = new ArrayList<InetAddress>(); for (NetworkInterface ifc : Collections.list(NetworkInterface.getNetworkInterfaces())) { if (ifc.isUp()) { for (InetAddress addr : Collections.list(ifc.getInetAddresses())) { if (addr instanceof Inet4Address) { addrList.add(addr);//from ww w. ja v a2s .co m } } } } if (addrList.size() < 2) { fail("unable to test binding to different local addresses: only " + addrList.size() + " addresses available"); } for (InetAddress addr : addrList) { tryHttpBindAddress(addr.getHostAddress()); } }
From source file:com.sunchenbin.store.feilong.core.bean.ConvertUtil.java
/** * ??./*from ww w .ja va2 s . co m*/ * * @param <T> * the generic type * @param enumeration * the enumeration * @return if Validator.isNullOrEmpty(enumeration), return {@link Collections#emptyList()},emptyList???<br> * else return {@link Collections#list(Enumeration)} * @see Collections#emptyList() * @see Collections#EMPTY_LIST * @see Collections#list(Enumeration) * @see EnumerationUtils#toList(Enumeration) * @since 1.0.7 */ public static <T> List<T> toList(final Enumeration<T> enumeration) { if (Validator.isNullOrEmpty(enumeration)) { return Collections.emptyList(); } return Collections.list(enumeration); }
From source file:eu.europa.esig.dss.cades.signature.CadesLevelBaselineLTATimestampExtractor.java
/** * The field unsignedAttrsHashIndex is a sequence of octet strings. Each one contains the hash value of one * instance of Attribute within unsignedAttrs field of the SignerInfo. A hash value for every instance of * Attribute, as present at the time when the corresponding archive time-stamp is requested, shall be included in * unsignedAttrsHashIndex. No other hash values shall be included in this field. * * We check that every hash attribute found in the timestamp token is found if the signerInformation. * * If there is more unsigned attributes in the signerInformation than present in the hash attributes list * (and there is at least the archiveTimestampAttributeV3), we don't report any error nor which attributes are signed by the timestamp. * If there is some attributes that are not present or altered in the signerInformation, we just return some empty sequence to make * sure that the timestamped data will not match. We do not report which attributes hash are present if any. * * If there is not attribute at all in the archive timestamp hash index, that would means we didn't check anything. * * @param signerInformation//w ww. j ava 2 s . co m * @param timestampToken * @return */ @SuppressWarnings("unchecked") private ASN1Sequence getVerifiedUnsignedAttributesHashIndex(SignerInformation signerInformation, TimestampToken timestampToken) throws DSSException { final ASN1Sequence unsignedAttributesHashes = getUnsignedAttributesHashIndex(timestampToken); final ArrayList<DEROctetString> timestampUnsignedAttributesHashesList = Collections .list(unsignedAttributesHashes.getObjects()); AttributeTable unsignedAttributes = CMSUtils.getUnsignedAttributes(signerInformation); final ASN1EncodableVector asn1EncodableVector = unsignedAttributes.toASN1EncodableVector(); for (int i = 0; i < asn1EncodableVector.size(); i++) { final Attribute attribute = (Attribute) asn1EncodableVector.get(i); final DEROctetString derOctetStringDigest = getAttributeDerOctetStringHash(attribute); final ASN1ObjectIdentifier attrType = attribute.getAttrType(); if (timestampUnsignedAttributesHashesList.remove(derOctetStringDigest)) { // attribute present in signature and in timestamp LOG.debug("Attribute {} present in timestamp", attrType.getId()); } else { LOG.debug("Attribute {} not present in timestamp", attrType.getId()); } } if (!timestampUnsignedAttributesHashesList.isEmpty()) { LOG.error("{} attribute hash in Timestamp have not been found in document attributes: {}", timestampUnsignedAttributesHashesList.size(), timestampUnsignedAttributesHashesList); // return a empty DERSequence to screw up the hash return new DERSequence(); } // return the original DERSequence return unsignedAttributesHashes; }
From source file:org.apache.openejb.util.classloader.URLClassLoaderFirst.java
public static boolean shouldSkipJsf(final ClassLoader loader, final String name) { if (!name.startsWith("javax.faces.")) { return false; }/*from ww w .j a v a2 s. c om*/ // using annotation to test to avoid to load more classes with deps final String testClass; if ("javax.faces.bean.RequestScoped".equals(name)) { testClass = "javax.faces.bean.SessionScoped"; } else { testClass = "javax.faces.bean.RequestScoped"; } final String classname = testClass.replace('.', '/') + ".class"; try { final Enumeration<URL> resources = loader.getResources(classname); final Collection<URL> thisJSf = Collections.list(resources); return thisJSf.isEmpty() || thisJSf.size() <= 1; } catch (final IOException e) { return true; } }
From source file:org.apache.hadoop.hive.ql.exec.mr.HadoopJobExecHelper.java
public void localJobDebugger(int exitVal, String taskId) { StringBuilder sb = new StringBuilder(); sb.append("\n"); sb.append("Task failed!\n"); sb.append("Task ID:\n " + taskId + "\n\n"); sb.append("Logs:\n"); console.printError(sb.toString());/*from w w w.ja v a 2s .com*/ for (Appender a : Collections.list((Enumeration<Appender>) LogManager.getRootLogger().getAllAppenders())) { if (a instanceof FileAppender) { console.printError((new Path(((FileAppender) a).getFile())).toUri().getPath()); } } }