Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-23 20:49:57 -0500
committerSteffen Pingel2012-02-23 20:49:57 -0500
commitdd272410ed09dec302025f9fc5ffcf65ab092b77 (patch)
treed7d76c2fe2fbffb3a8af5857b412ebc57b2c7bef /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal
parent1bed15b209c561664004a4f075d4a3e46d63fc85 (diff)
downloadorg.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.tar.gz
org.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.tar.xz
org.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.zip
NEW - bug 358554: [api] provide an extensible store for task-related
information https://bugs.eclipse.org/bugs/show_bug.cgi?id=358554 Change-Id: Iebf65bc3560a3b3240ff86eb453f1c76391d972a
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java35
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java18
2 files changed, 29 insertions, 24 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java
index c35f23c4d..ea879ae38 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
/**
@@ -32,6 +33,8 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
public static final String CONTEXT_FILE_EXTENSION = ".xml.zip"; //$NON-NLS-1$
+ private File directory;
+
private File contextDirectory;
@Override
@@ -40,15 +43,19 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
}
@Override
- public void deleteContext(ITask task) {
+ public void clearContext(ITask task) {
File file = getFileForContext(task);
if (file.exists()) {
file.delete();
}
}
- public File getContextDirectory() {
- return contextDirectory;
+ @Override
+ public void deleteContext(ITask task) {
+ File file = getFileForContext(task);
+ if (file.exists()) {
+ file.delete();
+ }
}
@Override
@@ -84,11 +91,8 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
return null;
}
- /**
- * @since 3.7
- */
@Override
- public void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl) {
+ public void refactorRepositoryUrl(TaskRepository repository, String oldRepositoryUrl, String newRepositoryUrl) {
// ignore
}
@@ -98,8 +102,21 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
}
@Override
- public synchronized void setContextDirectory(File directory) {
- this.contextDirectory = directory;
+ public synchronized void setDirectory(File directory) {
+ this.directory = directory;
+
+ contextDirectory = new File(directory.getParent(), ITasksCoreConstants.CONTEXTS_DIRECTORY);
+ if (!contextDirectory.exists()) {
+ contextDirectory.mkdirs();
+ }
+ }
+
+ public File getDirectory() {
+ return directory;
+ }
+
+ private File getContextDirectory() {
+ return contextDirectory;
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
index 72d46ea83..36a06f1c6 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor;
import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor;
import org.eclipse.mylyn.commons.core.StatusHandler;
@@ -353,26 +354,13 @@ public class TaskDataManager implements ITaskDataManager {
// String pathName = task.getConnectorKind() + "-"
// + URLEncoder.encode(task.getRepositoryUrl(), ENCODING_UTF_8);
// String fileName = kind + "-" + URLEncoder.encode(task.getTaskId(), ENCODING_UTF_8) + EXTENSION;
- String repositoryPath = task.getConnectorKind() + "-" + encode(repositoryUrl); //$NON-NLS-1$
- String fileName = encode(task.getTaskId()) + EXTENSION;
+ String repositoryPath = task.getConnectorKind() + "-" + CoreUtil.asFileName(repositoryUrl); //$NON-NLS-1$
+ String fileName = CoreUtil.asFileName(task.getTaskId()) + EXTENSION;
File path = new File(dataPath + File.separator + FOLDER_TASKS + File.separator + repositoryPath
+ File.separator + FOLDER_DATA);
return new File(path, fileName);
}
- private static String encode(String text) {
- StringBuffer sb = new StringBuffer(text.length());
- char[] chars = text.toCharArray();
- for (char c : chars) {
- if (c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '.') {
- sb.append(c);
- } else {
- sb.append("%" + Integer.toHexString(c).toUpperCase()); //$NON-NLS-1$
- }
- }
- return sb.toString();
- }
-
private File getFile10(ITask task, String kind) {
try {
String pathName = URLEncoder.encode(task.getRepositoryUrl(), ENCODING_UTF_8);

Back to the top