@Override public String getName() { return this.delegate.getName(); }
public void init(WebAppContext webAppContext) throws IOException { String railsRootDirName = webAppContext.getInitParameter("rails.root").replaceAll("/WEB-INF/", ""); String assetsDir = webAppContext.getWebInf().addPath(String.format("%s/public/assets/", railsRootDirName)).getName(); handler.setAssetsDir(assetsDir); }
@Override protected void doResponseHeaders(HttpServletResponse response, Resource resource, String mimeType) { if (mimeType == null && resource.getName().endsWith(".css")) mimeType = "text/css"; super.doResponseHeaders(response, resource, mimeType); // modify the caching strategy of ResourceHandler setCaching(response, this.expiresSeconds); }
/** * Get jars from WebAppContext.getExtraClasspath as resources * * @param context the context to find extra classpath jars in * @return the list of Resources with the extra classpath, or null if not found * @throws Exception if unable to find the extra classpath jars */ protected List<Resource> findExtraClasspathJars(WebAppContext context) throws Exception { if (context == null || context.getExtraClasspath() == null) return null; List<Resource> jarResources = new ArrayList<Resource>(); StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;"); while (tokenizer.hasMoreTokens()) { Resource resource = context.newResource(tokenizer.nextToken().trim()); String fnlc = resource.getName().toLowerCase(Locale.ENGLISH); int dot = fnlc.lastIndexOf('.'); String extension = (dot < 0 ? null : fnlc.substring(dot)); if (extension != null && (extension.equals(".jar") || extension.equals(".zip"))) { jarResources.add(resource); } } return jarResources; }
@Override public URL getResource(String path) throws MalformedURLException { Resource resource=WebAppContext.this.getResource(path); if (resource==null || !resource.exists()) return null; // Should we go to the original war? if (resource.isDirectory() && resource instanceof ResourceCollection && !WebAppContext.this.isExtractWAR()) { Resource[] resources = ((ResourceCollection)resource).getResources(); for (int i=resources.length;i-->0;) { if (resources[i].getName().startsWith("jar:file")) return resources[i].getURI().toURL(); } } return resource.getURI().toURL(); }
String fnlc = file.getName().toLowerCase(Locale.ENGLISH); int dot = fnlc.lastIndexOf('.'); String extension = (dot < 0 ? null : fnlc.substring(dot));
if(LOG.isDebugEnabled()) LOG.debug("addJar - {}", fn); String fnlc=fn.getName().toLowerCase(Locale.ENGLISH);
String fullname = webInfJar.getName(); int i = fullname.indexOf(".jar"); int j = fullname.lastIndexOf("/", i);
@Override public String getName() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) { String name = r.getName(); if(name!=null) return name; } return null; }
public String getWeakETag(String suffix) { try { StringBuilder b = new StringBuilder(32); b.append("W/\""); String name=getName(); int length=name.length(); long lhash=0; for (int i=0; i<length;i++) lhash=31*lhash+name.charAt(i); B64Code.encode(lastModified()^lhash,b); B64Code.encode(length()^lhash,b); b.append(suffix); b.append('"'); return b.toString(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public String getName() { return base.getName(); }
@Override public String getName() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) { String name = r.getName(); if(name!=null) return name; } return null; }
@Override public String getName() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) { String name = r.getName(); if(name!=null) return name; } return null; }
@Override public String getName() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) { String name = r.getName(); if(name!=null) return name; } return null; }
@Override public String getName() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) { String name = r.getName(); if(name!=null) return name; } return null; }
private static void printList(ArrayList<> list){ for(String s : list){ System.out.println(s + ", "); } } private static void printList(ArrayList<> list){ for(Resource r : list){ System.out.println(r.getName() + ", "); } }
/** * Constructs a KeyStore using the specified filename and password */ protected static KeyStore buildKeyStore(Resource resource, String password) { try { return CertificateUtils.getKeyStore(resource, "JKS", null, password); } catch (Exception ex) { throw new IllegalStateException("Unable to build KeyStore from resource: " + resource.getName(), ex); } }
/** * @return */ public String getDirectory() { return getConfigurationDir().getName(); }
/** * @return the directory * @deprecated use {@link #setContextsDir(String)} */ @Deprecated public String getDirectory() { return getConfigurationDir().getName(); }
private String compileCoffee(Resource resource) { try { return coffeeScript.compile(IOUtils.toString(resource.getInputStream(), "UTF-8")); } catch (Exception e) { return buildsJavaScriptToWriteFailureHtml.build("CoffeeScript Error: failed to compile <code>" + resource.getName() + "</code>. <br/>Error message:<br/><br/><code>" + e.getMessage() + "</code>"); } }