Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-08-15 15:57:20 +0000
committerspingel2007-08-15 15:57:20 +0000
commit82ab2dfcf1a708068b2e55beea1b6939083956ea (patch)
tree4b35fa96c3272639c3cc2c95e40ab0b4809ad390 /org.eclipse.mylyn.trac.core/src/org/eclipse
parent3ccb4855582c7ebecfa14643b66a1baf07ee9c1a (diff)
downloadorg.eclipse.mylyn.tasks-82ab2dfcf1a708068b2e55beea1b6939083956ea.tar.gz
org.eclipse.mylyn.tasks-82ab2dfcf1a708068b2e55beea1b6939083956ea.tar.xz
org.eclipse.mylyn.tasks-82ab2dfcf1a708068b2e55beea1b6939083956ea.zip
NEW - bug 198733: create a Wiki page editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=198733
Diffstat (limited to 'org.eclipse.mylyn.trac.core/src/org/eclipse')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractWikiHandler.java7
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java40
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracWikiPage.java18
3 files changed, 63 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractWikiHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractWikiHandler.java
index 03ab138a8..d415c29ec 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractWikiHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractWikiHandler.java
@@ -10,6 +10,7 @@ package org.eclipse.mylyn.internal.trac.core;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.internal.trac.core.model.TracWikiPage;
import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
@@ -20,4 +21,10 @@ public abstract class AbstractWikiHandler {
public abstract String[] downloadAllPageNames(TaskRepository repository, IProgressMonitor monitor) throws CoreException;
public abstract String getWikiUrl(TaskRepository repository);
+
+ public abstract TracWikiPage getWikiPage(TaskRepository repository, String pageName, IProgressMonitor monitor)
+ throws CoreException;
+
+ public abstract void postWikiPage(TaskRepository repository, TracWikiPage page, IProgressMonitor monitor) throws CoreException;
+
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
index 6953eaa0d..ca7e8d9be 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
@@ -9,9 +9,12 @@
package org.eclipse.mylyn.internal.trac.core;
import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.internal.trac.core.model.TracWikiPage;
import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
@@ -38,6 +41,43 @@ public class TracWikiHandler extends AbstractWikiHandler {
}
}
+ @Override
+ public TracWikiPage getWikiPage(TaskRepository repository, String pageName, IProgressMonitor monitor)
+ throws CoreException {
+ monitor.beginTask("Download Wiki Page", IProgressMonitor.UNKNOWN);
+ try {
+ TracWikiPage page = getTracWikiClient(repository).getWikiPage(pageName);
+ return page;
+ } catch (TracException e) {
+ throw new CoreException(TracCorePlugin.toStatus(e, repository));
+ } finally {
+ monitor.done();
+ }
+ }
+
+ public void postWikiPage(TaskRepository repository, TracWikiPage newPage, IProgressMonitor monitor)
+ throws CoreException {
+ monitor.beginTask("Upload Wiki Page", IProgressMonitor.UNKNOWN);
+ try {
+ String pageName = newPage.getPageInfo().getPageName();
+ String content = newPage.getContent();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put("comment", newPage.getPageInfo().getComment());
+ attributes.put("author", newPage.getPageInfo().getAuthor());
+ boolean success = getTracWikiClient(repository).putWikipage(pageName, content, attributes);
+ if (success) {
+ return;
+ } else {
+ throw new CoreException(TracCorePlugin.toStatus(new TracException(
+ "Failed to upload wiki page. No further information available."), repository));
+ }
+ } catch (TracException e) {
+ throw new CoreException(TracCorePlugin.toStatus(e, repository));
+ } finally {
+ monitor.done();
+ }
+ }
+
private ITracWikiClient getTracWikiClient(TaskRepository repository) throws TracException {
try {
ITracClient client = connector.getClientManager().getRepository(repository);
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracWikiPage.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracWikiPage.java
index 07d1baf49..e064cbe3d 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracWikiPage.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracWikiPage.java
@@ -14,7 +14,7 @@ package org.eclipse.mylyn.internal.trac.core.model;
* @author Xiaoyang Guan
*/
public class TracWikiPage {
-
+
private TracWikiPageInfo pageInfo;
private String content;
@@ -23,7 +23,7 @@ public class TracWikiPage {
public TracWikiPage() {
}
-
+
public TracWikiPageInfo getPageInfo() {
return pageInfo;
}
@@ -47,4 +47,18 @@ public class TracWikiPage {
public void setPageHTML(String pageHTML) {
this.pageHTML = pageHTML;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ } else if (this == obj) {
+ return true;
+ } else if (getClass() != obj.getClass()) {
+ return false;
+ } else {
+ TracWikiPage other = (TracWikiPage) obj;
+ return content.equals(other.content) && pageInfo.toString().equals(other.pageInfo.toString());
+ }
+ }
}

Back to the top