diff options
author | Martin Spielmann <martin.spielmann@pingunaut.com> | 2016-07-30 13:35:46 +0200 |
---|---|---|
committer | Martin Spielmann <martin.spielmann@pingunaut.com> | 2016-07-30 13:35:46 +0200 |
commit | d0bfa51c819bae8f96c90f81a0e335ca4fd0a027 (patch) | |
tree | 0b4876e416f5f2f2a871f9e326d3f2f992853abf /src | |
parent | 82046303f0f99b28b97cd7173d2fd94724c477d4 (diff) | |
download | gitblit-d0bfa51c819bae8f96c90f81a0e335ca4fd0a027.tar.gz gitblit-d0bfa51c819bae8f96c90f81a0e335ca4fd0a027.zip |
fix filter and plugin class resolver
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/wicket/GitblitWicketFilter.java | 198 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/PluginClassResolver.java | 4 |
2 files changed, 104 insertions, 98 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java b/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java index 8286acfc..2214cbc3 100644 --- a/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java +++ b/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java @@ -89,108 +89,110 @@ public class GitblitWicketFilter extends WicketFilter { }
};
}
-
+
/**
* Determines the last-modified date of the requested resource.
+ *
+ * TODO: check where to reimplement
*
* @param servletRequest
* @return The last modified time stamp
*/
- @Override
- protected long getLastModified(final HttpServletRequest servletRequest) {
- final String pathInfo = getRelativePath(servletRequest);
- if (Strings.isEmpty(pathInfo)) {
- return -1;
- }
- long lastModified = super.getLastModified(servletRequest);
- if (lastModified > -1) {
- return lastModified;
- }
-
- // try to match request against registered CacheControl pages
- String [] paths = pathInfo.split("/");
-
- String page = paths[0];
- String repo = "";
- String commitId = "";
- if (paths.length >= 2) {
- repo = paths[1];
- }
- if (paths.length >= 3) {
- commitId = paths[2];
- }
-
- if (!StringUtils.isEmpty(servletRequest.getParameter("r"))) {
- repo = servletRequest.getParameter("r");
- }
- if (!StringUtils.isEmpty(servletRequest.getParameter("h"))) {
- commitId = servletRequest.getParameter("h");
- }
-
- repo = repo.replace("%2f", "/").replace("%2F", "/").replace(settings.getChar(Keys.web.forwardSlashCharacter, '/'), '/');
-
- GitBlitWebApp app = (GitBlitWebApp) getApplication();
- int expires = settings.getInteger(Keys.web.pageCacheExpires, 0);
- if (!StringUtils.isEmpty(page) && app.isCacheablePage(page) && expires > 0) {
- // page can be cached by the browser
- CacheControl cacheControl = app.getCacheControl(page);
- Date bootDate = runtimeManager.getBootDate();
- switch (cacheControl.value()) {
- case ACTIVITY:
- // returns the last activity date of the server
- Date activityDate = repositoryManager.getLastActivityDate();
- if (activityDate != null) {
- return activityDate.after(bootDate) ? activityDate.getTime() : bootDate.getTime();
- }
- return bootDate.getTime();
- case BOOT:
- // return the boot date of the server
- return bootDate.getTime();
- case PROJECT:
- // return the latest change date for the project OR the boot date
- ProjectModel project = projectManager.getProjectModel(StringUtils.getRootPath(repo));
- if (project != null) {
- return project.lastChange.after(bootDate) ? project.lastChange.getTime() : bootDate.getTime();
- }
- break;
- case REPOSITORY:
- // return the lastest change date for the repository OR the boot
- // date, whichever is latest
- RepositoryModel repository = repositoryManager.getRepositoryModel(repo);
- if (repository != null && repository.lastChange != null) {
- return repository.lastChange.after(bootDate) ? repository.lastChange.getTime() : bootDate.getTime();
- }
- break;
- case COMMIT:
- // get the date of the specified commit
- if (StringUtils.isEmpty(commitId)) {
- // no commit id, use boot date
- return bootDate.getTime();
- } else {
- // last modified date is the commit date
- Repository r = null;
- try {
- // return the timestamp of the associated commit
- r = repositoryManager.getRepository(repo);
- if (r != null) {
- RevCommit commit = JGitUtils.getCommit(r, commitId);
- if (commit != null) {
- Date date = JGitUtils.getCommitDate(commit);
- return date.after(bootDate) ? date.getTime() : bootDate.getTime();
- }
- }
- } finally {
- if (r != null) {
- r.close();
- }
- }
- }
- break;
- default:
- break;
- }
- }
-
- return -1;
- }
+// @Override
+// protected long getLastModified(final HttpServletRequest servletRequest) {
+// final String pathInfo = getRelativePath(servletRequest);
+// if (Strings.isEmpty(pathInfo)) {
+// return -1;
+// }
+// long lastModified = super.getLastModified(servletRequest);
+// if (lastModified > -1) {
+// return lastModified;
+// }
+//
+// // try to match request against registered CacheControl pages
+// String [] paths = pathInfo.split("/");
+//
+// String page = paths[0];
+// String repo = "";
+// String commitId = "";
+// if (paths.length >= 2) {
+// repo = paths[1];
+// }
+// if (paths.length >= 3) {
+// commitId = paths[2];
+// }
+//
+// if (!StringUtils.isEmpty(servletRequest.getParameter("r"))) {
+// repo = servletRequest.getParameter("r");
+// }
+// if (!StringUtils.isEmpty(servletRequest.getParameter("h"))) {
+// commitId = servletRequest.getParameter("h");
+// }
+//
+// repo = repo.replace("%2f", "/").replace("%2F", "/").replace(settings.getChar(Keys.web.forwardSlashCharacter, '/'), '/');
+//
+// GitBlitWebApp app = (GitBlitWebApp) getApplication();
+// int expires = settings.getInteger(Keys.web.pageCacheExpires, 0);
+// if (!StringUtils.isEmpty(page) && app.isCacheablePage(page) && expires > 0) {
+// // page can be cached by the browser
+// CacheControl cacheControl = app.getCacheControl(page);
+// Date bootDate = runtimeManager.getBootDate();
+// switch (cacheControl.value()) {
+// case ACTIVITY:
+// // returns the last activity date of the server
+// Date activityDate = repositoryManager.getLastActivityDate();
+// if (activityDate != null) {
+// return activityDate.after(bootDate) ? activityDate.getTime() : bootDate.getTime();
+// }
+// return bootDate.getTime();
+// case BOOT:
+// // return the boot date of the server
+// return bootDate.getTime();
+// case PROJECT:
+// // return the latest change date for the project OR the boot date
+// ProjectModel project = projectManager.getProjectModel(StringUtils.getRootPath(repo));
+// if (project != null) {
+// return project.lastChange.after(bootDate) ? project.lastChange.getTime() : bootDate.getTime();
+// }
+// break;
+// case REPOSITORY:
+// // return the lastest change date for the repository OR the boot
+// // date, whichever is latest
+// RepositoryModel repository = repositoryManager.getRepositoryModel(repo);
+// if (repository != null && repository.lastChange != null) {
+// return repository.lastChange.after(bootDate) ? repository.lastChange.getTime() : bootDate.getTime();
+// }
+// break;
+// case COMMIT:
+// // get the date of the specified commit
+// if (StringUtils.isEmpty(commitId)) {
+// // no commit id, use boot date
+// return bootDate.getTime();
+// } else {
+// // last modified date is the commit date
+// Repository r = null;
+// try {
+// // return the timestamp of the associated commit
+// r = repositoryManager.getRepository(repo);
+// if (r != null) {
+// RevCommit commit = JGitUtils.getCommit(r, commitId);
+// if (commit != null) {
+// Date date = JGitUtils.getCommitDate(commit);
+// return date.after(bootDate) ? date.getTime() : bootDate.getTime();
+// }
+// }
+// } finally {
+// if (r != null) {
+// r.close();
+// }
+// }
+// }
+// break;
+// default:
+// break;
+// }
+// }
+//
+// return -1;
+// }
}
diff --git a/src/main/java/com/gitblit/wicket/PluginClassResolver.java b/src/main/java/com/gitblit/wicket/PluginClassResolver.java index 476f9611..0693891c 100644 --- a/src/main/java/com/gitblit/wicket/PluginClassResolver.java +++ b/src/main/java/com/gitblit/wicket/PluginClassResolver.java @@ -117,4 +117,8 @@ public class PluginClassResolver implements IClassResolver { } } } + + @Override + public ClassLoader getClassLoader() { + return getClass().getClassLoader(); } }
\ No newline at end of file |