diff options
author | relves | 2007-01-13 01:15:10 +0000 |
---|---|---|
committer | relves | 2007-01-13 01:15:10 +0000 |
commit | de7711ea47b22a82bd4b7625c2411f84f00886fc (patch) | |
tree | bc5f206bc93d2744a5709a18aa5b8e933ecfc080 /org.eclipse.mylyn.tasks.core | |
parent | 3f510792b58032c055dffa6fe14cf3832ef5bebf (diff) | |
download | org.eclipse.mylyn.tasks-de7711ea47b22a82bd4b7625c2411f84f00886fc.tar.gz org.eclipse.mylyn.tasks-de7711ea47b22a82bd4b7625c2411f84f00886fc.tar.xz org.eclipse.mylyn.tasks-de7711ea47b22a82bd4b7625c2411f84f00886fc.zip |
NEW - bug 165498: [api] Create unified abstract support for task submission to repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=165498
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
6 files changed, 224 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java index 6d431ff99..cdf925f1b 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java @@ -25,7 +25,7 @@ import org.eclipse.mylar.tasks.core.AbstractRepositoryTask.RepositoryTaskSyncSta /** * Operations on a task repository - * + * * @author Mik Kersten * @author Rob Elves */ @@ -62,11 +62,11 @@ public abstract class AbstractRepositoryConnector { public abstract String getTaskIdFromTaskUrl(String taskFullUrl); public abstract String getTaskWebUrl(String repositoryUrl, String taskId); - + public String[] getTaskIdsFromComment(TaskRepository repository, String comment) { return null; } - + public abstract boolean canCreateTaskFromKey(TaskRepository repository); public abstract boolean canCreateNewTask(TaskRepository repository); @@ -83,7 +83,7 @@ public abstract class AbstractRepositoryConnector { /** * Implementors must execute query synchronously. - * + * * @param query * @param repository * TODO @@ -94,6 +94,9 @@ public abstract class AbstractRepositoryConnector { public abstract IStatus performQuery(AbstractRepositoryQuery query, TaskRepository repository, IProgressMonitor monitor, QueryHitCollector resultCollector); + /** + * The connector's description i.e. "JIRA (supports 3.3.1 and later)" + */ public abstract String getLabel(); /** @@ -134,7 +137,7 @@ public abstract class AbstractRepositoryConnector { * Implementors of this repositoryOperations must perform it locally without * going to the server since it is used for frequent repositoryOperations * such as decoration. - * + * * @return an empty set if no contexts */ public final Set<RepositoryAttachment> getContextAttachments(TaskRepository repository, AbstractRepositoryTask task) { @@ -161,7 +164,7 @@ public abstract class AbstractRepositoryConnector { /** * Attaches the associated context to <code>task</code>. - * + * * @return false, if operation is not supported by repository */ public final boolean attachContext(TaskRepository repository, AbstractRepositoryTask task, String longComment) @@ -177,7 +180,7 @@ public abstract class AbstractRepositoryConnector { try { task.setSyncState(RepositoryTaskSyncState.OUTGOING); - if(task.getTaskData() != null) { + if (task.getTaskData() != null) { task.getTaskData().setHasLocalChanges(true); } handler.uploadAttachment(repository, task, longComment, MYLAR_CONTEXT_DESCRIPTION, sourceContextFile, @@ -197,7 +200,7 @@ public abstract class AbstractRepositoryConnector { /** * Retrieves a context stored in <code>attachment</code> from * <code>task</code>. - * + * * @return false, if operation is not supported by repository */ public final boolean retrieveContext(TaskRepository repository, AbstractRepositoryTask task, @@ -249,7 +252,7 @@ public abstract class AbstractRepositoryConnector { /** * Reset and update the repository attributes from the server (e.g. * products, components) - * + * * TODO: remove? */ public abstract void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException; diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IMylarStatusConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IMylarStatusConstants.java new file mode 100644 index 000000000..cfce663e7 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IMylarStatusConstants.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.tasks.core; + + +/** + * @author Rob Elves + */ +public interface IMylarStatusConstants { + + public final static int REPOSITORY_ERROR = 1; + + /** + * Operation failed with html error from repository. + * + */ + public final static int REPOSITORY_ERROR_HTML = 2; + + public final static int REPOSITORY_LOGIN_ERROR = 3; + + public final static int REPOSITORY_NOT_FOUND = 4; + + public final static int IO_ERROR = 5; + +// public final static int NETWORK_LOGIN_ERROR = 6; + + public final static int INTERNAL_ERROR = 7; + + public final static int OPERATION_CANCELLED = 8; + + public final static int COMMENT_REQUIRED = 9; + + public final static int LOGGED_OUT_OF_REPOSITORY = 10; + + public final static int NETWORK_ERROR = 11; + +} diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskDataHandler.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskDataHandler.java index 43e1e248a..070e63ffd 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskDataHandler.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskDataHandler.java @@ -11,7 +11,6 @@ package org.eclipse.mylar.tasks.core; -import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.Set; @@ -32,10 +31,11 @@ public interface ITaskDataHandler { public String postTaskData(TaskRepository repository, RepositoryTaskData taskData) throws CoreException; /** + * TODO: Move to AbstractRepositoyConnector? This looks like task level api not taskdata. * returns all tasks if date is null or an error occurs */ public abstract Set<AbstractRepositoryTask> getChangedSinceLastSync(TaskRepository repository, - Set<AbstractRepositoryTask> tasks) throws CoreException, UnsupportedEncodingException; + Set<AbstractRepositoryTask> tasks) throws CoreException; /** * @return null if date cannot be parsed diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.java new file mode 100644 index 000000000..ec7e625ac --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.tasks.core; + +import org.eclipse.osgi.util.NLS; + +/** + * @author Rob Elves + */ +public class MylarMessages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.mylar.tasks.core.MylarMessages";//$NON-NLS-1$ + + static { + NLS.initializeMessages(BUNDLE_NAME, MylarMessages.class); + } + + private MylarMessages() { + // Do not instantiate + } + + public static String repository_login_failure; + + public static String repository_not_found; + + public static String operation_cancelled; + + public static String network_error; + + public static String io_error; + + public static String internal_error; + + public static String comment_required; + + public static String repository_error; + +} diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.properties b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.properties new file mode 100644 index 000000000..78e27d95e --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarMessages.properties @@ -0,0 +1,15 @@ +### Mylar messages. + +### repository +### {0} generally is the repository url +repository_error = Repository error from {0}:\n\n{1} +repository_login_failure = Unable to login to {0}.\n\n{1}\n\nPlease validate credentials via Task Repositories view. +repository_not_found = Repository {0} could not be found. +### repositoryUrl, class.simpleName, class.getMessage +io_error = I/O Error occurred while communicating with {0}.\n\n{1}: {2} +network_error = A network error occurred connecting to {0}.\n\n{1} +internal_error = An internal error has occurred: {0} +operation_cancelled = {0} was canceled by the user. +comment_required = You have to specify a new comment when making this change. Please comment on the reason for this change. + + diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarStatus.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarStatus.java new file mode 100644 index 000000000..806830ee1 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/MylarStatus.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.tasks.core; + +import org.eclipse.core.runtime.Status; + +/** + * @author Rob Elves + */ +public class MylarStatus extends Status implements IMylarStatusConstants { + + private String errorMessage; + + private String repsitoryUrl = ""; + + public MylarStatus(int severity, String pluginId, int code) { + super(severity, pluginId, code, "MylarStatus", null); + this.errorMessage = null; + } + + public MylarStatus(int severity, String pluginId, int code, String errorMessage) { + super(severity, pluginId, code, "MylarStatus", null); + this.errorMessage = errorMessage; + } + + public MylarStatus(int severity, String pluginId, int code, String repositoryUrl, Throwable e) { + super(severity, pluginId, code, "MylarStatus", e); + this.repsitoryUrl = repositoryUrl; + this.errorMessage = e.getMessage(); + } + + public MylarStatus(int severity, String pluginId, int code, String repositoryUrl, String errorMessage) { + super(severity, pluginId, code, "MylarStatus", null); + this.errorMessage = errorMessage; + this.repsitoryUrl = repositoryUrl; + } + + public MylarStatus(int severity, String pluginId, int code, String repositoryUrl, String errorMessage, Throwable e) { + super(severity, pluginId, code, "MylarStatus", e); + this.errorMessage = errorMessage; + this.repsitoryUrl = repositoryUrl; + } + + /** + * Returns the message that is relevant to the code of this status. + */ + public String getMessage() { + + switch (getCode()) { + case REPOSITORY_LOGIN_ERROR: + return MylarMessages + .bind(MylarMessages.repository_login_failure, this.getRepsitoryUrl(), this.errorMessage); + case REPOSITORY_NOT_FOUND: + return MylarMessages.bind(MylarMessages.repository_not_found, this.errorMessage); + case REPOSITORY_ERROR: + return MylarMessages.bind(MylarMessages.repository_error, this.errorMessage); + case IO_ERROR: + String string1 = getException().getClass().getSimpleName(); + String string2 = getException().getMessage(); + Object[] strings = { getRepsitoryUrl(), string1, string2 }; + return MylarMessages.bind(MylarMessages.io_error, strings); + case INTERNAL_ERROR: + return MylarMessages.bind(MylarMessages.internal_error, this.errorMessage); + case OPERATION_CANCELLED: + return MylarMessages.bind(MylarMessages.operation_cancelled, this.errorMessage); + case COMMENT_REQUIRED: + if (errorMessage == null) { + return MylarMessages.comment_required; + } else { + return errorMessage; + } + } + if (errorMessage != null) { + return errorMessage; + } else if (getException() != null) { + String message = getException().getMessage(); + if (message != null) { + return message; + } else { + return getException().toString(); + } + } + return "Unknown"; + } + + public String getRepsitoryUrl() { + return repsitoryUrl; + } + + public void setRepsitoryUrl(String repsitoryUrl) { + this.repsitoryUrl = repsitoryUrl; + } +} |