Search in sources :

Example 61 with Enumeration

use of java.util.Enumeration in project gitblit by gitblit.

the class GitServlet method init.

@Override
public void init(final ServletConfig config) throws ServletException {
    gitFilter.init(new FilterConfig() {

        @Override
        public String getFilterName() {
            return gitFilter.getClass().getName();
        }

        @Override
        public String getInitParameter(String name) {
            return config.getInitParameter(name);
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return config.getInitParameterNames();
        }

        @Override
        public ServletContext getServletContext() {
            return config.getServletContext();
        }
    });
    init();
}
Also used : Enumeration(java.util.Enumeration) ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig)

Example 62 with Enumeration

use of java.util.Enumeration in project gocd by gocd.

the class PluginController method addRequestHeaders.

private void addRequestHeaders(HttpServletRequest request, DefaultGoPluginApiRequest apiRequest) {
    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String header = (String) headerNames.nextElement();
        String value = request.getHeader(header);
        apiRequest.addRequestHeader(header, value);
    }
}
Also used : Enumeration(java.util.Enumeration)

Example 63 with Enumeration

use of java.util.Enumeration in project camel by apache.

the class RestSwaggerServlet method init.

@Override
public void init(final ServletConfig config) throws ServletException {
    super.init(config);
    Map<String, Object> parameters = new HashMap<String, Object>();
    Enumeration en = config.getInitParameterNames();
    while (en.hasMoreElements()) {
        String name = (String) en.nextElement();
        Object value = config.getInitParameter(name);
        parameters.put(name, value);
    }
    // when using servlet then use the cors filter to enable cors
    if (parameters.get("cors") != null) {
        LOG.warn("Use RestSwaggerCorsFilter when uisng this Servlet to enable CORS");
        parameters.remove("cors");
    }
    support.initSwagger(swaggerConfig, parameters);
    // allow to configure these options from the servlet config as well
    Object pattern = parameters.remove("apiContextIdPattern");
    if (pattern != null) {
        apiContextIdPattern = pattern.toString();
    }
    Object listing = parameters.remove("apiContextIdListing");
    if (listing != null) {
        apiContextIdListing = Boolean.valueOf(listing.toString());
    }
}
Also used : Enumeration(java.util.Enumeration) HashMap(java.util.HashMap)

Example 64 with Enumeration

use of java.util.Enumeration in project jaggery by wso2.

the class JaggeryAppListener method isJaggeryApp.

/**
     * check whether webapp is jaggery app or not
     *
     * @param context Context of the jaggery app
     * @return boolean
     */
private boolean isJaggeryApp(Context context) {
    Path appBase = getAppBase(context);
    String path;
    if (context.getDocBase().contains(WAR_EXTENSION)) {
        try {
            if (!appBase.endsWith("/")) {
                path = appBase + File.separator + context.getDocBase();
            } else {
                path = appBase + context.getDocBase();
            }
            ZipFile zip = new ZipFile(path);
            for (Enumeration e = zip.entries(); e.hasMoreElements(); ) {
                ZipEntry entry = (ZipEntry) e.nextElement();
                if (entry.getName().toLowerCase().contains(JAGGERY_CONF)) {
                    return true;
                }
            }
        } catch (IOException e) {
            log.error("Error in processing the zip file", e);
        }
    } else {
        Path filepath = Paths.get(appBase + context.getPath() + File.separator + JAGGERY_CONF);
        return Files.exists(filepath);
    }
    return false;
}
Also used : Path(java.nio.file.Path) Enumeration(java.util.Enumeration) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException)

Example 65 with Enumeration

use of java.util.Enumeration in project XobotOS by xamarin.

the class LogFactory method getResources.

/**
     * Given a filename, return an enumeration of URLs pointing to
     * all the occurrences of that filename in the classpath.
     * <p>
     * This is just like ClassLoader.getResources except that the
     * operation is done under an AccessController so that this method will
     * succeed when this jarfile is privileged but the caller is not.
     * This method must therefore remain private to avoid security issues.
     * <p>
     * If no instances are found, an Enumeration is returned whose
     * hasMoreElements method returns false (ie an "empty" enumeration).
     * If resources could not be listed for some reason, null is returned.
     */
private static Enumeration getResources(final ClassLoader loader, final String name) {
    PrivilegedAction action = new PrivilegedAction() {

        public Object run() {
            try {
                if (loader != null) {
                    return loader.getResources(name);
                } else {
                    return ClassLoader.getSystemResources(name);
                }
            } catch (IOException e) {
                if (isDiagnosticsEnabled()) {
                    logDiagnostic("Exception while trying to find configuration file " + name + ":" + e.getMessage());
                }
                return null;
            } catch (NoSuchMethodError e) {
                // this case.
                return null;
            }
        }
    };
    Object result = AccessController.doPrivileged(action);
    return (Enumeration) result;
}
Also used : Enumeration(java.util.Enumeration) PrivilegedAction(java.security.PrivilegedAction) IOException(java.io.IOException)

Aggregations

Enumeration (java.util.Enumeration)1418 IOException (java.io.IOException)247 ArrayList (java.util.ArrayList)183 File (java.io.File)122 Vector (java.util.Vector)98 Properties (java.util.Properties)97 HashMap (java.util.HashMap)96 List (java.util.List)89 URL (java.net.URL)74 HashSet (java.util.HashSet)71 Map (java.util.Map)71 Hashtable (java.util.Hashtable)70 Iterator (java.util.Iterator)70 Set (java.util.Set)67 InputStream (java.io.InputStream)62 ZipEntry (java.util.zip.ZipEntry)62 ServletContext (javax.servlet.ServletContext)55 ZipFile (java.util.zip.ZipFile)51 FileInputStream (java.io.FileInputStream)48 ServletException (javax.servlet.ServletException)46