Clean up code with Copilot #134
7 changed files with 73 additions and 73 deletions
|
@ -115,13 +115,13 @@ public class Main {
|
|||
File[] files = dir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
String n = name.toLowerCase();
|
||||
return n.endsWith(".jar") || n.endsWith(".zip"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
return n.endsWith(".jar") || n.endsWith(".zip");
|
||||
}
|
||||
});
|
||||
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
jarlist.add(new URL("file:" + files[i].getAbsolutePath())); //$NON-NLS-1$
|
||||
jarlist.add(new URL("file:" + files[i].getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class Main {
|
|||
addJars(jarlist, libdir);
|
||||
|
||||
// add all jar files from the lib/ext directory
|
||||
addJars(jarlist, new File(libdir, "ext")); //$NON-NLS-1$
|
||||
addJars(jarlist, new File(libdir, "ext"));
|
||||
|
||||
URL[] urls = new URL[jarlist.size()];
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class Main {
|
|||
// try to get Helma installation directory
|
||||
if (installDir == null) {
|
||||
URL launcherUrl = ClassLoader.getSystemClassLoader()
|
||||
.getResource("helma/main/launcher/Main.class"); //$NON-NLS-1$
|
||||
.getResource("helma/main/launcher/Main.class");
|
||||
|
||||
// this is a JAR URL of the form
|
||||
// jar:<url>!/{entry}
|
||||
|
|
|
@ -603,11 +603,11 @@ public class RequestTrans implements Serializable {
|
|||
|
||||
StringTokenizer tok;
|
||||
|
||||
if (auth.startsWith("Basic ")) { //$NON-NLS-1$
|
||||
if (auth.startsWith("Basic ")) {
|
||||
tok = new StringTokenizer(new String(Base64.decodeBase64(auth.substring(6))),
|
||||
":"); //$NON-NLS-1$
|
||||
":");
|
||||
} else {
|
||||
tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":"); //$NON-NLS-1$
|
||||
tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":");
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -714,7 +714,7 @@ public final class ResponseTrans extends Writer implements Serializable {
|
|||
// if (contentType != null)
|
||||
// digest.update (contentType.getBytes());
|
||||
byte[] b = this.digest.digest(this.response);
|
||||
this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\"";
|
||||
// only set response to 304 not modified if no cookies were set
|
||||
if (reqtrans.hasETag(etag) && countCookies() == 0) {
|
||||
response = new byte[0];
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
|
||||
String appName = (String) e.nextElement();
|
||||
|
||||
if ((appName.indexOf(".") == -1) && //$NON-NLS-1$
|
||||
if ((appName.indexOf(".") == -1) &&
|
||||
(this.applications.get(appName) == null)) {
|
||||
AppDescriptor appDesc = new AppDescriptor(appName);
|
||||
appDesc.start();
|
||||
|
@ -149,7 +149,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
|
||||
String appName = (String) e.nextElement();
|
||||
|
||||
if (appName.indexOf(".") == -1) { //$NON-NLS-1$
|
||||
if (appName.indexOf(".") == -1) {
|
||||
String appValue = this.props.getProperty(appName);
|
||||
|
||||
if (appValue != null && appValue.length() > 0) {
|
||||
|
@ -208,7 +208,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
*/
|
||||
public Object execute(String method, @SuppressWarnings("rawtypes") Vector params)
|
||||
throws Exception {
|
||||
int dot = method.indexOf("."); //$NON-NLS-1$
|
||||
int dot = method.indexOf(".");
|
||||
|
||||
if (dot == -1) {
|
||||
throw new Exception("Method name \"" + method +
|
||||
|
@ -224,7 +224,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
Application app = (Application) this.xmlrpcHandlers.get(handler);
|
||||
|
||||
if (app == null) {
|
||||
app = (Application) this.xmlrpcHandlers.get("*"); //$NON-NLS-1$
|
||||
app = (Application) this.xmlrpcHandlers.get("*");
|
||||
// use the original method name, the handler is resolved within the app.
|
||||
method2 = method;
|
||||
}
|
||||
|
@ -239,32 +239,32 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
private String getMountpoint(String mountpoint) {
|
||||
mountpoint = mountpoint.trim();
|
||||
|
||||
if ("".equals(mountpoint)) { //$NON-NLS-1$
|
||||
return "/"; //$NON-NLS-1$
|
||||
} else if (!mountpoint.startsWith("/")) { //$NON-NLS-1$
|
||||
return "/" + mountpoint; //$NON-NLS-1$
|
||||
if ("".equals(mountpoint)) {
|
||||
return "/";
|
||||
} else if (!mountpoint.startsWith("/")) {
|
||||
return "/" + mountpoint;
|
||||
}
|
||||
|
||||
return mountpoint;
|
||||
}
|
||||
|
||||
private String joinMountpoint(String prefix, String suffix) {
|
||||
if (prefix.endsWith("/") || suffix.startsWith("/")) { //$NON-NLS-1$//$NON-NLS-2$
|
||||
if (prefix.endsWith("/") || suffix.startsWith("/")) {
|
||||
return prefix+suffix;
|
||||
}
|
||||
return prefix+"/"+suffix; //$NON-NLS-1$
|
||||
return prefix+"/"+suffix;
|
||||
}
|
||||
|
||||
private String getPathPattern(String mountpoint) {
|
||||
if (!mountpoint.startsWith("/")) { //$NON-NLS-1$
|
||||
mountpoint = "/"+mountpoint; //$NON-NLS-1$
|
||||
if (!mountpoint.startsWith("/")) {
|
||||
mountpoint = "/"+mountpoint;
|
||||
}
|
||||
|
||||
if ("/".equals(mountpoint)) { //$NON-NLS-1$
|
||||
return "/"; //$NON-NLS-1$
|
||||
if ("/".equals(mountpoint)) {
|
||||
return "/";
|
||||
}
|
||||
|
||||
if (mountpoint.endsWith("/")) { //$NON-NLS-1$
|
||||
if (mountpoint.endsWith("/")) {
|
||||
return mountpoint.substring(0, mountpoint.length()-1);
|
||||
}
|
||||
|
||||
|
@ -335,56 +335,56 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
AppDescriptor(String name) {
|
||||
ResourceProperties conf = ApplicationManager.this.props.getSubProperties(name + '.');
|
||||
this.appName = name;
|
||||
this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName)); //$NON-NLS-1$
|
||||
this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName));
|
||||
this.pathPattern = getPathPattern(this.mountpoint);
|
||||
this.staticDir = conf.getProperty("static"); //$NON-NLS-1$
|
||||
this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint", //$NON-NLS-1$
|
||||
joinMountpoint(this.mountpoint, "static"))); //$NON-NLS-1$
|
||||
this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
String home = conf.getProperty("staticHome"); //$NON-NLS-1$
|
||||
this.staticDir = conf.getProperty("static");
|
||||
this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint",
|
||||
joinMountpoint(this.mountpoint, "static")));
|
||||
this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex"));
|
||||
String home = conf.getProperty("staticHome");
|
||||
if (home == null) {
|
||||
this.staticHome = new String[] {"index.html", "index.htm"}; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
this.staticHome = new String[] {"index.html", "index.htm"};
|
||||
} else {
|
||||
this.staticHome = StringUtils.split(home, ","); //$NON-NLS-1$
|
||||
this.staticHome = StringUtils.split(home, ",");
|
||||
}
|
||||
this.protectedStaticDir = conf.getProperty("protectedStatic"); //$NON-NLS-1$
|
||||
this.protectedStaticDir = conf.getProperty("protectedStatic");
|
||||
|
||||
this.cookieDomain = conf.getProperty("cookieDomain"); //$NON-NLS-1$
|
||||
this.sessionCookieName = conf.getProperty("sessionCookieName"); //$NON-NLS-1$
|
||||
this.protectedSessionCookie = conf.getProperty("protectedSessionCookie"); //$NON-NLS-1$
|
||||
this.uploadLimit = conf.getProperty("uploadLimit"); //$NON-NLS-1$
|
||||
this.uploadSoftfail = conf.getProperty("uploadSoftfail"); //$NON-NLS-1$
|
||||
this.debug = conf.getProperty("debug"); //$NON-NLS-1$
|
||||
String appDirName = conf.getProperty("appdir"); //$NON-NLS-1$
|
||||
this.cookieDomain = conf.getProperty("cookieDomain");
|
||||
this.sessionCookieName = conf.getProperty("sessionCookieName");
|
||||
this.protectedSessionCookie = conf.getProperty("protectedSessionCookie");
|
||||
this.uploadLimit = conf.getProperty("uploadLimit");
|
||||
this.uploadSoftfail = conf.getProperty("uploadSoftfail");
|
||||
this.debug = conf.getProperty("debug");
|
||||
String appDirName = conf.getProperty("appdir");
|
||||
this.appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName);
|
||||
String dbDirName = conf.getProperty("dbdir"); //$NON-NLS-1$
|
||||
String dbDirName = conf.getProperty("dbdir");
|
||||
this.dbDir = (dbDirName == null) ? null : getAbsoluteFile(dbDirName);
|
||||
this.servletClassName = conf.getProperty("servletClass"); //$NON-NLS-1$
|
||||
this.servletClassName = conf.getProperty("servletClass");
|
||||
|
||||
// got ignore dirs
|
||||
this.ignoreDirs = conf.getProperty("ignore"); //$NON-NLS-1$
|
||||
this.ignoreDirs = conf.getProperty("ignore");
|
||||
|
||||
// read and configure app repositories
|
||||
ArrayList<Repository> repositoryList = new ArrayList<>();
|
||||
Class<?>[] parameters = { String.class };
|
||||
for (int i = 0; true; i++) {
|
||||
String repositoryArgs = conf.getProperty("repository." + i); //$NON-NLS-1$
|
||||
String repositoryArgs = conf.getProperty("repository." + i);
|
||||
|
||||
if (repositoryArgs != null) {
|
||||
// lookup repository implementation
|
||||
String repositoryImpl = conf.getProperty("repository." + i + //$NON-NLS-1$
|
||||
".implementation"); //$NON-NLS-1$
|
||||
String repositoryImpl = conf.getProperty("repository." + i +
|
||||
".implementation");
|
||||
if (repositoryImpl == null) {
|
||||
// implementation not set manually, have to guess it
|
||||
if (repositoryArgs.endsWith(".zip")) { //$NON-NLS-1$
|
||||
if (repositoryArgs.endsWith(".zip")) {
|
||||
repositoryArgs = findResource(repositoryArgs);
|
||||
repositoryImpl = "helma.framework.repository.ZipRepository"; //$NON-NLS-1$
|
||||
} else if (repositoryArgs.endsWith(".js")) { //$NON-NLS-1$
|
||||
repositoryImpl = "helma.framework.repository.ZipRepository";
|
||||
} else if (repositoryArgs.endsWith(".js")) {
|
||||
repositoryArgs = findResource(repositoryArgs);
|
||||
repositoryImpl = "helma.framework.repository.SingleFileRepository"; //$NON-NLS-1$
|
||||
repositoryImpl = "helma.framework.repository.SingleFileRepository";
|
||||
} else {
|
||||
repositoryArgs = findResource(repositoryArgs);
|
||||
repositoryImpl = "helma.framework.repository.FileRepository"; //$NON-NLS-1$
|
||||
repositoryImpl = "helma.framework.repository.FileRepository";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,27 +506,27 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
appContext.addServlet(holder, "/*");
|
||||
|
||||
if (this.cookieDomain != null) {
|
||||
holder.setInitParameter("cookieDomain", this.cookieDomain); //$NON-NLS-1$
|
||||
holder.setInitParameter("cookieDomain", this.cookieDomain);
|
||||
}
|
||||
|
||||
if (this.sessionCookieName != null) {
|
||||
holder.setInitParameter("sessionCookieName", this.sessionCookieName); //$NON-NLS-1$
|
||||
holder.setInitParameter("sessionCookieName", this.sessionCookieName);
|
||||
}
|
||||
|
||||
if (this.protectedSessionCookie != null) {
|
||||
holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie); //$NON-NLS-1$
|
||||
holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie);
|
||||
}
|
||||
|
||||
if (this.uploadLimit != null) {
|
||||
holder.setInitParameter("uploadLimit", this.uploadLimit); //$NON-NLS-1$
|
||||
holder.setInitParameter("uploadLimit", this.uploadLimit);
|
||||
}
|
||||
|
||||
if (this.uploadSoftfail != null) {
|
||||
holder.setInitParameter("uploadSoftfail", this.uploadSoftfail); //$NON-NLS-1$
|
||||
holder.setInitParameter("uploadSoftfail", this.uploadSoftfail);
|
||||
}
|
||||
|
||||
if (this.debug != null) {
|
||||
holder.setInitParameter("debug", this.debug); //$NON-NLS-1$
|
||||
holder.setInitParameter("debug", this.debug);
|
||||
}
|
||||
|
||||
if (protectedStaticDir != null) {
|
||||
|
@ -584,7 +584,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[AppDescriptor "+this.app+"]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return "[AppDescriptor "+this.app+"]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,16 +19,16 @@ public class JSONModuleSource extends ModuleSource {
|
|||
@Override
|
||||
public Reader getReader() {
|
||||
StringBuffer content = new StringBuffer();
|
||||
content.append("module.exports = "); //$NON-NLS-1$
|
||||
|
||||
content.append("module.exports = ");
|
||||
|
||||
try {
|
||||
content.append(IOUtils.toString(this.getUri().toURL().openStream(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
content.append("null"); //$NON-NLS-1$
|
||||
content.append("null");
|
||||
}
|
||||
|
||||
content.append(";"); //$NON-NLS-1$
|
||||
|
||||
|
||||
content.append(";");
|
||||
|
||||
return new StringReader(content.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
// check if the file exists and is a file
|
||||
if (file.exists() && file.isFile()) {
|
||||
// check if the file is a JSON file
|
||||
if (file.getAbsolutePath().toLowerCase().endsWith(".json")) { //$NON-NLS-1$
|
||||
if (file.getAbsolutePath().toLowerCase().endsWith(".json")) {
|
||||
// return a JSON module source
|
||||
return new JSONModuleSource(null, file.toURI(), base, validator);
|
||||
} else {
|
||||
|
@ -83,7 +83,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
}
|
||||
|
||||
// lets assume the module is a JS file
|
||||
file = new File(new File(uri).getPath() + ".js"); //$NON-NLS-1$
|
||||
file = new File(new File(uri).getPath() + ".js");
|
||||
// check if a file.js exists and is a file
|
||||
if (file.exists() && file.isFile()) {
|
||||
// do what would have been done anyways
|
||||
|
@ -91,7 +91,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
}
|
||||
|
||||
// lets assume the module is a JSON file
|
||||
file = new File(new File(uri).getPath() + ".json"); //$NON-NLS-1$
|
||||
file = new File(new File(uri).getPath() + ".json");
|
||||
// check if a file.json exists and is a file
|
||||
if (file.exists() && file.isFile()) {
|
||||
// return a JSON module source
|
||||
|
@ -135,7 +135,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
ModuleSource moduleSource;
|
||||
|
||||
// lets assume that there is a "package.json" file in the directory
|
||||
File packageFile = new File(directory, "package.json"); //$NON-NLS-1$
|
||||
File packageFile = new File(directory, "package.json");
|
||||
|
||||
// check if the there is a "package.json" file in the directory
|
||||
if (packageFile.exists() && packageFile.isFile()) {
|
||||
|
@ -143,9 +143,9 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
JsonObject json = JsonParser
|
||||
.parseString(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject();
|
||||
// check if the JSON file defines a main JS file
|
||||
if (json.has("main")) { //$NON-NLS-1$
|
||||
if (json.has("main")) {
|
||||
// get the main JS file, removing the filename extension
|
||||
String main = FilenameUtils.removeExtension(json.get("main").getAsString()); //$NON-NLS-1$
|
||||
String main = FilenameUtils.removeExtension(json.get("main").getAsString());
|
||||
|
||||
// load as file
|
||||
moduleSource = this.loadAsFile(new File(directory, main).toURI(), base, validator);
|
||||
|
@ -158,7 +158,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
}
|
||||
|
||||
// load as index
|
||||
moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator); //$NON-NLS-1$
|
||||
moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator);
|
||||
// check if something was loaded
|
||||
if (moduleSource != null) {
|
||||
// return the loaded module source
|
||||
|
|
|
@ -517,9 +517,9 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
checksum[i] = (byte) (n);
|
||||
n >>>= 8;
|
||||
}
|
||||
String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\""; //$NON-NLS-1$//$NON-NLS-2$
|
||||
res.setHeader("ETag", etag); //$NON-NLS-1$
|
||||
String etagHeader = req.getHeader("If-None-Match"); //$NON-NLS-1$
|
||||
String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\"";
|
||||
res.setHeader("ETag", etag);
|
||||
String etagHeader = req.getHeader("If-None-Match");
|
||||
if (etagHeader != null) {
|
||||
StringTokenizer st = new StringTokenizer(etagHeader, ", \r\n");
|
||||
while (st.hasMoreTokens()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue