diff options
author | guriguri <guriguri.kr@gmail.com> | 2013-08-01 00:20:49 +0900 |
---|---|---|
committer | guriguri <guriguri.kr@gmail.com> | 2013-08-01 00:20:49 +0900 |
commit | d80588d99511fac16495f8eaafa50e01a6b98995 (patch) | |
tree | 8a0fec207b79917d979db3a093a3062670cd0734 /src/main/java/com/gitblit/wicket/WicketUtils.java | |
parent | 289efbc850b4413bdcfd54d84e3813576cdc540d (diff) | |
download | gitblit-d80588d99511fac16495f8eaafa50e01a6b98995.tar.gz gitblit-d80588d99511fac16495f8eaafa50e01a6b98995.zip |
apply PageParameters(final Map<String, ?> parameterMap), encode filename of Content-Disposition
Diffstat (limited to 'src/main/java/com/gitblit/wicket/WicketUtils.java')
-rw-r--r-- | src/main/java/com/gitblit/wicket/WicketUtils.java | 154 |
1 files changed, 111 insertions, 43 deletions
diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index 87f2f3ff..aa86686c 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -20,7 +20,9 @@ import java.text.MessageFormat; import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
@@ -190,7 +192,7 @@ public class WicketUtils { return newImage(wicketId, "file_excel_16x16.png");
} else if (filename.endsWith(".doc") || filename.endsWith(".docx")) {
return newImage(wicketId, "file_doc_16x16.png");
- } else if (filename.endsWith(".ppt")) {
+ } else if (filename.endsWith(".ppt") || filename.endsWith(".pptx")) {
return newImage(wicketId, "file_ppt_16x16.png");
} else if (filename.endsWith(".zip")) {
return newImage(wicketId, "file_zip_16x16.png");
@@ -285,104 +287,170 @@ public class WicketUtils { }
public static PageParameters newTokenParameter(String token) {
- return new PageParameters("t=" + token);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("t", token);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newRegistrationParameter(String url, String name) {
- return new PageParameters("u=" + url + ",n=" + name);
+ public static PageParameters newRegistrationParameter(String url,
+ String name) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("u", url);
+ parameterMap.put("n", name);
+ return new PageParameters(parameterMap);
}
public static PageParameters newUsernameParameter(String username) {
- return new PageParameters("user=" + username);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("user", username);
+ return new PageParameters(parameterMap);
}
public static PageParameters newTeamnameParameter(String teamname) {
- return new PageParameters("team=" + teamname);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("team", teamname);
+ return new PageParameters(parameterMap);
}
public static PageParameters newProjectParameter(String projectName) {
- return new PageParameters("p=" + projectName);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("p", projectName);
+ return new PageParameters(parameterMap);
}
public static PageParameters newRepositoryParameter(String repositoryName) {
- return new PageParameters("r=" + repositoryName);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("r", repositoryName);
+ return new PageParameters(parameterMap);
}
public static PageParameters newObjectParameter(String objectId) {
- return new PageParameters("h=" + objectId);
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("h", objectId);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newObjectParameter(String repositoryName, String objectId) {
+ public static PageParameters newObjectParameter(String repositoryName,
+ String objectId) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (StringUtils.isEmpty(objectId)) {
return newRepositoryParameter(repositoryName);
}
- return new PageParameters("r=" + repositoryName + ",h=" + objectId);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", objectId);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newRangeParameter(String repositoryName, String startRange, String endRange) {
- return new PageParameters("r=" + repositoryName + ",h=" + startRange + ".." + endRange);
+ public static PageParameters newRangeParameter(String repositoryName,
+ String startRange, String endRange) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", startRange + ".." + endRange);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newPathParameter(String repositoryName, String objectId,
- String path) {
+ public static PageParameters newPathParameter(String repositoryName,
+ String objectId, String path) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (StringUtils.isEmpty(path)) {
return newObjectParameter(repositoryName, objectId);
}
if (StringUtils.isEmpty(objectId)) {
- return new PageParameters("r=" + repositoryName + ",f=" + path);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("f", path);
+ return new PageParameters(parameterMap);
}
- return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", objectId);
+ parameterMap.put("f", path);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newLogPageParameter(String repositoryName, String objectId,
- int pageNumber) {
+ public static PageParameters newLogPageParameter(String repositoryName,
+ String objectId, int pageNumber) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (pageNumber <= 1) {
return newObjectParameter(repositoryName, objectId);
}
if (StringUtils.isEmpty(objectId)) {
- return new PageParameters("r=" + repositoryName + ",pg=" + pageNumber);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
}
- return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",pg=" + pageNumber);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", objectId);
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
}
- public static PageParameters newHistoryPageParameter(String repositoryName, String objectId,
- String path, int pageNumber) {
+ public static PageParameters newHistoryPageParameter(String repositoryName,
+ String objectId, String path, int pageNumber) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (pageNumber <= 1) {
return newObjectParameter(repositoryName, objectId);
}
if (StringUtils.isEmpty(objectId)) {
- return new PageParameters("r=" + repositoryName + ",f=" + path + ",pg=" + pageNumber);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("f", path);
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
}
- return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path + ",pg="
- + pageNumber);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", objectId);
+ parameterMap.put("f", path);
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
}
- public static PageParameters newBlobDiffParameter(String repositoryName, String baseCommitId,
- String commitId, String path) {
+ public static PageParameters newBlobDiffParameter(String repositoryName,
+ String baseCommitId, String commitId, String path) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (StringUtils.isEmpty(commitId)) {
- return new PageParameters("r=" + repositoryName + ",f=" + path + ",hb=" + baseCommitId);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("f", path);
+ parameterMap.put("hb", baseCommitId);
+ return new PageParameters(parameterMap);
}
- return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",f=" + path + ",hb="
- + baseCommitId);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", commitId);
+ parameterMap.put("f", path);
+ parameterMap.put("hb", baseCommitId);
+ return new PageParameters(parameterMap);
}
- public static PageParameters newSearchParameter(String repositoryName, String commitId,
- String search, Constants.SearchType type) {
+ public static PageParameters newSearchParameter(String repositoryName,
+ String commitId, String search, Constants.SearchType type) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (StringUtils.isEmpty(commitId)) {
- return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name());
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("s", search);
+ parameterMap.put("st", type.name());
+ return new PageParameters(parameterMap);
}
- return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",s=" + search
- + ",st=" + type.name());
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", commitId);
+ parameterMap.put("s", search);
+ parameterMap.put("st", type.name());
+ return new PageParameters(parameterMap);
}
- public static PageParameters newSearchParameter(String repositoryName, String commitId,
- String search, Constants.SearchType type, int pageNumber) {
+ public static PageParameters newSearchParameter(String repositoryName,
+ String commitId, String search, Constants.SearchType type,
+ int pageNumber) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
if (StringUtils.isEmpty(commitId)) {
- return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name()
- + ",pg=" + pageNumber);
- }
- return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",s=" + search
- + ",st=" + type.name() + ",pg=" + pageNumber);
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("s", search);
+ parameterMap.put("st", type.name());
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
+ }
+ parameterMap.put("r", repositoryName);
+ parameterMap.put("h", commitId);
+ parameterMap.put("s", search);
+ parameterMap.put("st", type.name());
+ parameterMap.put("pg", String.valueOf(pageNumber));
+ return new PageParameters(parameterMap);
}
public static String getProjectName(PageParameters params) {
|