diff options
13 files changed, 149 insertions, 417 deletions
diff --git a/org.eclipse.mylyn-feature/feature.properties b/org.eclipse.mylyn-feature/feature.properties index bf2fb4450..a3db07aaa 100644 --- a/org.eclipse.mylyn-feature/feature.properties +++ b/org.eclipse.mylyn-feature/feature.properties @@ -2,7 +2,7 @@ featureName=Mylyn Task List (Required) description=Provides the Task List for task and time management. providerName=Eclipse Mylyn copyright=Copyright (c) 2004, 2008 Tasktop Technologies and others. All rights reserved. -updateSiteName=Mylyn for Eclipse 3.4 +updateSiteName=Mylyn for Eclipse 3.3 discovery_Mylyn_Extras=Mylyn Extras discovery_Mylyn=Mylyn license=\ diff --git a/org.eclipse.mylyn-feature/feature.xml b/org.eclipse.mylyn-feature/feature.xml index b378b7c61..982582f12 100644 --- a/org.eclipse.mylyn-feature/feature.xml +++ b/org.eclipse.mylyn-feature/feature.xml @@ -19,16 +19,20 @@ </license> <url> - <update label="%updateSiteName" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/> - <discovery label="%discovery_Mylyn_Extras" url="http://download.eclipse.org/tools/mylyn/update/extras"/> - <discovery label="%discovery_Mylyn" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/> + <update label="%updateSiteName" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/> + <discovery label="Mylyn Extras" url="http://download.eclipse.org/tools/mylyn/update/extras"/> + <discovery label="Mylyn" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/> </url> <requires> <import plugin="org.eclipse.core.runtime"/> + <import plugin="org.eclipse.ui" version="3.3.0" match="equivalent"/> + <import plugin="org.eclipse.ui.forms"/> + <import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/> + <import plugin="org.eclipse.mylyn.tasks.ui" version="3.0.0" match="compatible"/> + <import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.mylyn.monitor.core" version="3.0.0" match="compatible"/> - <import plugin="org.eclipse.ui" version="3.4.0.I20070918" match="greaterOrEqual"/> <import plugin="org.eclipse.compare"/> <import plugin="org.eclipse.core.expressions"/> <import plugin="org.eclipse.core.net"/> @@ -37,26 +41,13 @@ <import plugin="org.eclipse.search"/> <import plugin="org.eclipse.ui.browser"/> <import plugin="org.eclipse.ui.editors"/> - <import plugin="org.eclipse.ui.forms"/> <import plugin="org.eclipse.ui.ide"/> <import plugin="org.eclipse.ui.views"/> <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.mylyn.context.core" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.mylyn.monitor.ui" version="3.0.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/> - <import plugin="org.apache.commons.logging" version="1.0.4" match="greaterOrEqual"/> - <import plugin="org.apache.commons.codec" version="1.3.0" match="greaterOrEqual"/> - <import plugin="org.apache.commons.httpclient" version="3.1.0" match="greaterOrEqual"/> - <import plugin="org.apache.commons.lang" version="2.3.0" match="greaterOrEqual"/> - <import plugin="org.eclipse.core.runtime" version="3.3.0" match="greaterOrEqual"/> - <import plugin="org.eclipse.mylyn.commons.core" version="3.1.0" match="greaterOrEqual"/> - <import plugin="org.eclipse.mylyn.commons.net" version="3.1.0" match="greaterOrEqual"/> - <import feature="org.eclipse.rcp" version="3.4.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.discovery.core" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.commons.core" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.commons.ui" version="3.2.0" match="compatible"/> + <import feature="org.eclipse.rcp" version="3.3.0" match="equivalent"/> </requires> <plugin @@ -157,18 +148,4 @@ version="0.0.0" unpack="false"/> - <plugin - id="org.eclipse.mylyn.discovery.core" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.mylyn.discovery.ui" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - </feature> diff --git a/org.eclipse.mylyn.bugzilla-feature/feature.properties b/org.eclipse.mylyn.bugzilla-feature/feature.properties index 33107d5ad..d96b815a7 100644 --- a/org.eclipse.mylyn.bugzilla-feature/feature.properties +++ b/org.eclipse.mylyn.bugzilla-feature/feature.properties @@ -2,7 +2,7 @@ featureName=Mylyn Connector: Bugzilla description=Provides Task List integration, offline support and rich editing for the open source Bugzilla bug tracker. providerName=Eclipse Mylyn copyright=Copyright (c) 2004, 2008 Tasktop Technologies and others. All rights reserved. -updateSiteName=Mylyn for Eclipse 3.4 +updateSiteName=Mylyn for Eclipse 3.3 license=\ Eclipse Foundation Software User Agreement\n\ \n\ diff --git a/org.eclipse.mylyn.bugzilla-feature/feature.xml b/org.eclipse.mylyn.bugzilla-feature/feature.xml index 0e3567faa..213e53eef 100644 --- a/org.eclipse.mylyn.bugzilla-feature/feature.xml +++ b/org.eclipse.mylyn.bugzilla-feature/feature.xml @@ -19,12 +19,14 @@ </license> <url> - <update label="%updateSiteName" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/> + <update label="%updateSiteName" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/> </url> <requires> <import plugin="org.eclipse.core.runtime"/> <import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/> + <import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/> + <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.core.net"/> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.core.resources"/> @@ -35,10 +37,9 @@ <import plugin="org.eclipse.ui.editors"/> <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.mylyn.tasks.ui" version="3.0.0" match="compatible"/> - <import feature="org.eclipse.mylyn_feature" version="3.2.0.qualifier" match="perfect"/> - <import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/> - <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/> <import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/> + <import feature="org.eclipse.mylyn_feature" version="3.2.0.qualifier" match="perfect"/> + <import plugin="org.eclipse.mylyn.bugzilla.core" version="3.0.0" match="compatible"/> </requires> <plugin diff --git a/org.eclipse.mylyn.tasks.bugs/.classpath b/org.eclipse.mylyn.tasks.bugs/.classpath index 6a357762a..40856a70b 100644 --- a/org.eclipse.mylyn.tasks.bugs/.classpath +++ b/org.eclipse.mylyn.tasks.bugs/.classpath @@ -3,7 +3,7 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> <accessrules> - <accessrule kind="accessible" pattern="org/eclipse/ui/internal/views/log/*"/> + <accessrule kind="accessible" pattern="org/eclipse/pde/internal/runtime/logview/*"/> <accessrule kind="accessible" pattern="org/eclipse/mylyn/internal/tasks/ui/**"/> </accessrules> </classpathentry> diff --git a/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF index f56f4c543..f85b284ab 100644 --- a/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF @@ -4,10 +4,8 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.mylyn.tasks.bugs;singleton:=true Bundle-Version: 3.2.0.qualifier Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.resources, org.eclipse.ui, - org.eclipse.ui.views.log;resolution:=optional, - org.eclipse.ui.ide, + org.eclipse.pde.runtime;resolution:=optional, org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.mylyn.tasks.ui;bundle-version="[3.0.0,4.0.0)", diff --git a/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif b/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif Binary files differdeleted file mode 100644 index e2cde50c2..000000000 --- a/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif +++ /dev/null diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.xml b/org.eclipse.mylyn.tasks.bugs/plugin.xml index 541e8bdca..e01386140 100644 --- a/org.eclipse.mylyn.tasks.bugs/plugin.xml +++ b/org.eclipse.mylyn.tasks.bugs/plugin.xml @@ -6,19 +6,16 @@ <extension-point id="taskContributors" name="Task Contributors" schema="schema/taskContributors.exsd"/> <extension point="org.eclipse.ui.popupMenus"> - <objectContribution - adaptable="false" - id="org.eclipse.mylyn.internal.provisional.tasks.bugs.objectContribution" - objectClass="org.eclipse.ui.internal.views.log.LogEntry"> - <action - class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromErrorAction" - enablesFor="1" - icon="icons/etool16/task-bug-new.gif" - menubarPath="org.eclipse.pde.runtime.LogView" - id="org.eclipse.mylyn.tasklist.actions.newTaskFromErrorLog" - label="%NewTaskFromErrorAction.label"> - </action> - </objectContribution> + <viewerContribution + id="org.eclipse.mylyn.bugzilla.ide.log.contribution" + targetID="org.eclipse.pde.runtime.LogView"> + <action + class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromErrorAction" + icon="icons/etool16/task-repository-new.gif" + menubarPath="org.eclipse.pde.runtime.LogView" + id="org.eclipse.mylyn.tasklist.actions.newTaskFromErrorLog" + label="%NewTaskFromErrorAction.label"/> + </viewerContribution> </extension> <extension point="org.eclipse.ui.actionSets"> @@ -38,61 +35,6 @@ </extension> <extension - point="org.eclipse.ui.handlers"> - <handler - class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromMarkerHandler" - commandId="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker"> - <activeWhen> - <with variable="activePart"> - <test - args="any" - property="org.eclipse.ui.ide.contentGenerator"> - </test> - </with> - </activeWhen> - <enabledWhen> - <and> - <count - value="1"> - </count> - <iterate - ifEmpty="false" - operator="and"> - <instanceof - value="org.eclipse.ui.internal.views.markers.MarkerEntry"> - </instanceof> - </iterate> - </and> - </enabledWhen> - </handler> - </extension> - - <extension - point="org.eclipse.ui.commands"> - <command - description="%commands.newTaskFromMarker.description" - id="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker" - name="%commands.newTaskFromMarker.name"> - </command> - </extension> - - <extension - point="org.eclipse.ui.menus"> - <menuContribution - locationURI="popup:org.eclipse.ui.ide.MarkersView?after=org.eclipse.ui.ide.markCompleted"> - <command - commandId="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker" - icon="icons/etool16/task-new.gif" - mnemonic="%commands.newTaskFromMarker.mnemonic" - style="push"> - <visibleWhen - checkEnabled="true"> - </visibleWhen> - </command> - </menuContribution> - </extension> - - <extension point="org.eclipse.mylyn.commons.core.errorReporters"> <errorReporter class="org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin$BugReporter" diff --git a/org.eclipse.mylyn.tasks.bugs/schema/support.exsd b/org.eclipse.mylyn.tasks.bugs/schema/support.exsd index 8ceb469b0..0946cc331 100644 --- a/org.eclipse.mylyn.tasks.bugs/schema/support.exsd +++ b/org.eclipse.mylyn.tasks.bugs/schema/support.exsd @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.mylyn.tasks.bugs" xmlns="http://www.w3.org/2001/XMLSchema"> +<schema targetNamespace="org.eclipse.mylyn.tasks.bugs"> <annotation> <appInfo> <meta.schema plugin="org.eclipse.mylyn.tasks.bugs" id="support" name="Integrated Support Extensions"/> @@ -11,11 +11,6 @@ </annotation> <element name="extension"> - <annotation> - <appInfo> - <meta.element internal="true" /> - </appInfo> - </annotation> <complexType> <sequence> <element ref="category" minOccurs="0" maxOccurs="unbounded"/> @@ -263,9 +258,6 @@ <documentation> </documentation> - <appInfo> - <meta.attribute kind="identifier"/> - </appInfo> </annotation> </attribute> <attribute name="class" type="string"> @@ -334,8 +326,6 @@ </documentation> </annotation> - - <annotation> <appInfo> <meta.section type="copyright"/> diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java index 5f0aafe7f..9d498634f 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java @@ -15,13 +15,17 @@ package org.eclipse.mylyn.internal.tasks.bugs.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.mylyn.internal.commons.core.ErrorReporterManager; import org.eclipse.mylyn.internal.tasks.bugs.wizards.ErrorLogStatus; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.internal.views.log.LogEntry; -import org.eclipse.ui.internal.views.log.LogSession; +import org.eclipse.pde.internal.runtime.logview.LogEntry; +import org.eclipse.pde.internal.runtime.logview.LogSession; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; /** * Creates a new task from the selected error log entry. @@ -29,11 +33,11 @@ import org.eclipse.ui.internal.views.log.LogSession; * @author Jeff Pound * @author Steffen Pingel */ -public class NewTaskFromErrorAction implements IObjectActionDelegate { +public class NewTaskFromErrorAction implements IViewActionDelegate, ISelectionChangedListener { public static final String ID = "org.eclipse.mylyn.tasklist.ui.repositories.actions.create"; //$NON-NLS-1$ - private LogEntry entry; + private TreeViewer treeViewer; /** * Fills a {@link StringBuilder} with {@link LogEntry} information, optionally including subentries too @@ -80,42 +84,29 @@ public class NewTaskFromErrorAction implements IObjectActionDelegate { // includeChildren = true; // } // StringBuilder sb = new StringBuilder(); -// buildDescriptionFromLogEntry(entry, sb, true); +// buildDescriptionFromLogEntry(entry, sb, includeChildren); - ErrorLogStatus status = createStatus(entry); - - new ErrorReporterManager().fail(status); - } - - private ErrorLogStatus createStatus(LogEntry entry) { ErrorLogStatus status = new ErrorLogStatus(entry.getSeverity(), entry.getPluginId(), entry.getCode(), entry.getMessage()); - try { - status.setDate(entry.getDate()); - status.setStack(entry.getStack()); - LogSession session = entry.getSession(); - if (session != null) { - status.setLogSessionData(session.getSessionData()); - } - - if (entry.hasChildren()) { - Object[] children = entry.getChildren(entry); - if (children != null) { - for (Object child : children) { - if (child instanceof LogEntry) { - ErrorLogStatus childStatus = createStatus((LogEntry) child); - status.add(childStatus); - } - } - } - } - } catch (Exception e) { - // ignore any errors for setting additional attributes + status.setDate(entry.getDate()); + status.setStack(entry.getStack()); + LogSession session = entry.getSession(); + if (session != null) { + status.setLogSessionData(session.getSessionData()); } - return status; + new ErrorReporterManager().fail(status); } public void run() { + TreeItem[] items = treeViewer.getTree().getSelection(); + LogEntry entry = null; + if (items.length > 0) { + entry = (LogEntry) items[0].getData(); + } + if (entry == null) { + return; + } + createTask(entry); } @@ -123,14 +114,19 @@ public class NewTaskFromErrorAction implements IObjectActionDelegate { run(); } + public void init(IViewPart view) { + ISelectionProvider sp = view.getViewSite().getSelectionProvider(); + sp.addSelectionChangedListener(this); + sp.setSelection(sp.getSelection()); + } + public void selectionChanged(IAction action, ISelection selection) { - Object object = ((IStructuredSelection) selection).getFirstElement(); - if (object instanceof LogEntry) { - entry = (LogEntry) object; - } + // this selection is always empty? explicitly register a listener in + // init() instead } - public void setActivePart(IAction action, IWorkbenchPart targetPart) { + public void selectionChanged(SelectionChangedEvent event) { + treeViewer = (TreeViewer) event.getSource(); } } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java deleted file mode 100644 index d164ada20..000000000 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 Frank Becker 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: - * Frank Becker - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.internal.tasks.bugs.actions; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil; -import org.eclipse.mylyn.tasks.core.TaskMapping; -import org.eclipse.mylyn.tasks.ui.TasksUiUtil; -import org.eclipse.ui.views.markers.MarkerViewHandler; -import org.eclipse.ui.views.markers.internal.MarkerType; -import org.eclipse.ui.views.markers.internal.MarkerTypesModel; - -/** - * Creates a new task from the selected marker entry. - * - * @author Frank Becker - * @since 3.0 - */ -@SuppressWarnings("restriction") -public class NewTaskFromMarkerHandler extends MarkerViewHandler { - - public Object execute(ExecutionEvent event) throws ExecutionException { - IMarker[] markers = getSelectedMarkers(event); - if (markers.length == 0 || markers[0] == null) { - MessageDialog.openInformation(null, Messages.NewTaskFromMarkerHandler_New_Task_from_Marker, - Messages.NewTaskFromMarkerHandler_No_marker_selected); - return null; - } - final IMarker marker = markers[0]; - TaskMapping mapping = new TaskMapping() { - - @Override - public String getSummary() { - StringBuilder sb = new StringBuilder(); - try { - MarkerType type = MarkerTypesModel.getInstance().getType(marker.getType()); - sb.append(type.getLabel() + ": "); //$NON-NLS-1$ - } catch (CoreException e) { - // ignore - } - - return sb.toString() + marker.getAttribute("message", ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - public String getDescription() { - return buildDescriptionFromMarkerItem(marker); - } - - }; - - TasksUiUtil.openNewTaskEditor(WorkbenchUtil.getShell(), mapping, null); - return null; - } - - private String buildDescriptionFromMarkerItem(IMarker marker) { - StringBuilder sb = new StringBuilder(); - sb.append(Messages.NewTaskFromMarkerHandler_Resource_ - + marker.getResource().getFullPath().removeLastSegments(1).toString().substring(1) + "/" //$NON-NLS-1$ - + marker.getResource().getName()); - int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, -1); - if (lineNumber != -1) { - sb.append(Messages.NewTaskFromMarkerHandler_LOCATION_LINE + lineNumber); - } - return sb.toString(); - } - -} diff --git a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF index cd603a2a5..a5c7c24cd 100644 --- a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF @@ -7,7 +7,6 @@ Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.net, - org.eclipse.equinox.security, org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.mylyn.commons.net;bundle-version="[3.0.0,4.0.0)" Export-Package: org.eclipse.mylyn.internal.provisional.tasks.core;x-internal:=true, diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java index a9da8d30c..e9dc273ac 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java @@ -30,10 +30,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; -import org.eclipse.equinox.security.storage.EncodingUtils; -import org.eclipse.equinox.security.storage.ISecurePreferences; -import org.eclipse.equinox.security.storage.SecurePreferencesFactory; -import org.eclipse.equinox.security.storage.StorageException; import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.commons.net.AuthenticationCredentials; import org.eclipse.mylyn.commons.net.AuthenticationType; @@ -238,87 +234,28 @@ public final class TaskRepository extends PlatformObject { this.setProperty(AUTH_PROXY + SAVE_PASSWORD, String.valueOf(true)); } - private ISecurePreferences getSecurePreferences() { - ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault() - .node(ITasksCoreConstants.ID_PLUGIN); - securePreferences = securePreferences.node(EncodingUtils.encodeSlashes(getRepositoryUrl())); - return securePreferences; - } - - private void addAuthInfo(String username, String password, String userProperty, String passwordProperty) { + // TODO e3.4 move to new api + private void addAuthInfo(Map<String, String> map) { synchronized (LOCK) { - if (Platform.isRunning()) { - if (useSecureStorage()) { + try { + if (Platform.isRunning()) { + // write the map to the keyring try { - ISecurePreferences securePreferences = getSecurePreferences(); - if (userProperty.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) { - this.setProperty(userProperty, username); - } else { - securePreferences.put(userProperty, username, false); - } - securePreferences.put(passwordProperty, password, true); - } catch (StorageException e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not store authorization credentials", e)); //$NON-NLS-1$ + Platform.addAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME, map); + } catch (MalformedURLException ex) { + Platform.addAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME, map); } } else { - Map<String, String> map = getAuthInfo(); - if (map == null) { - map = new HashMap<String, String>(); - } - try { - try { - map.put(userProperty, username); - map.put(passwordProperty, password); - Platform.addAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME, map); - } catch (MalformedURLException ex) { - Platform.addAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME, map); - } - } catch (CoreException e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not set authorization credentials", e)); //$NON-NLS-1$ - } - } - } else { - Map<String, String> headlessCreds = credentials.get(getRepositoryUrl()); - if (headlessCreds == null) { - headlessCreds = new HashMap<String, String>(); - credentials.put(getRepositoryUrl(), headlessCreds); - } - headlessCreds.put(userProperty, username); - headlessCreds.put(passwordProperty, password); - } - } - } - - @SuppressWarnings( { "unchecked" }) - private Map<String, String> getAuthInfo() { - synchronized (LOCK) { - if (Platform.isRunning()) { - try { - return Platform.getAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME); - } catch (MalformedURLException ex) { - return Platform.getAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME); - } catch (Exception e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not retrieve authorization credentials", e)); //$NON-NLS-1$ + Map<String, String> headlessCreds = getAuthInfo(); + headlessCreds.putAll(map); } - } else { - Map<String, String> headlessCreds = credentials.get(getRepositoryUrl()); - if (headlessCreds == null) { - headlessCreds = new HashMap<String, String>(); - credentials.put(getRepositoryUrl(), headlessCreds); - } - return headlessCreds; + } catch (CoreException e) { + StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, + "Could not set authorization credentials", e)); //$NON-NLS-1$ } - return null; } } - /** - * @deprecated use {@code flushAuthenticationCredentials()} - */ - @Deprecated public void clearCredentials() { } @@ -335,6 +272,7 @@ public final class TaskRepository extends PlatformObject { return false; } + // TODO e3.4 move to new api public void flushAuthenticationCredentials() { // legacy support for versions prior to 2.2 that did not set the enable flag setProperty(getKeyPrefix(AuthenticationType.HTTP) + ENABLED, null); @@ -343,91 +281,40 @@ public final class TaskRepository extends PlatformObject { synchronized (LOCK) { isCachedUserName = false; + transientProperties.clear(); - if (Platform.isRunning()) { - if (useSecureStorage()) { - if (Platform.isRunning()) { - ISecurePreferences securePreferences = getSecurePreferences(); - securePreferences.removeNode(); - this.setProperty(AuthenticationType.REPOSITORY + USERNAME, ""); //$NON-NLS-1$ - } else { - Map<String, String> headlessCreds = credentials.get(getRepositoryUrl()); - if (headlessCreds != null) { - headlessCreds.clear(); - } - } - } else { + try { + if (Platform.isRunning()) { try { - try { - Platform.flushAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME); - } catch (MalformedURLException ex) { - Platform.flushAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME); - } - } catch (CoreException e) { - // FIXME propagate exception? - StatusHandler.fail(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not flush authorization credentials", e)); //$NON-NLS-1$ + Platform.flushAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME); + } catch (MalformedURLException ex) { + Platform.flushAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME); } - } - } else { - Map<String, String> headlessCreds = credentials.get(getRepositoryUrl()); - if (headlessCreds != null) { + } else { + Map<String, String> headlessCreds = getAuthInfo(); headlessCreds.clear(); } + } catch (CoreException e) { + // FIXME propagate exception? + StatusHandler.fail(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, + "Could not flush authorization credentials", e)); //$NON-NLS-1$ } } } - private boolean useSecureStorage() { - String useSecure = getProperty(ITasksCoreConstants.PROPERTY_USE_SECURE_STORAGE); - if (useSecure != null) { - return "true".equals(useSecure); //$NON-NLS-1$ - } - return false; - } - - @SuppressWarnings("unchecked") - private String getAuthInfo(String property) { + // TODO e3.4 move to new api + @SuppressWarnings( { "unchecked" }) + private Map<String, String> getAuthInfo() { synchronized (LOCK) { if (Platform.isRunning()) { - if (useSecureStorage()) { - String propertyValue = null; - if (property.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) { - propertyValue = this.getProperty(property); - } else { - try { - ISecurePreferences securePreferences = getSecurePreferences(); - propertyValue = securePreferences.get(property, null); - } catch (StorageException e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not retrieve authorization credentials", e)); //$NON-NLS-1$ - } - if (propertyValue == null) { - propertyValue = getFromLegacyKeystore(property); - } - } - return propertyValue; - } else { - try { - Map<String, String> map = Platform.getAuthorizationInfo(new URL(getRepositoryUrl()), - AUTH_REALM, AUTH_SCHEME); - if (map != null) { - String propertyValue = map.get(property); - return propertyValue; - } - } catch (MalformedURLException ex) { - Map<String, String> map = Platform.getAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), - AUTH_SCHEME); - if (map != null) { - String propertyValue = map.get(property); - return propertyValue; - } - } catch (Exception e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not retrieve authorization credentials", e)); //$NON-NLS-1$ - } - return null; + try { + return Platform.getAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, AUTH_SCHEME); + } catch (MalformedURLException ex) { + return Platform.getAuthorizationInfo(DEFAULT_URL, getRepositoryUrl(), AUTH_SCHEME); + } catch (Exception e) { + StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, + "Could not retrieve authorization credentials", e)); //$NON-NLS-1$ } } else { Map<String, String> headlessCreds = credentials.get(getRepositoryUrl()); @@ -435,31 +322,15 @@ public final class TaskRepository extends PlatformObject { headlessCreds = new HashMap<String, String>(); credentials.put(getRepositoryUrl(), headlessCreds); } - return headlessCreds.get(property); + return headlessCreds; } + return null; } } - @SuppressWarnings("unchecked") - private String getFromLegacyKeystore(String property) { - String propertyValue = null; - try { - Map<String, String> map = Platform.getAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM, - AUTH_SCHEME); - if (map != null) { - propertyValue = map.get(property); - if (propertyValue != null) { - ISecurePreferences securePreferences = getSecurePreferences(); - securePreferences.put(property, propertyValue, property.endsWith(PASSWORD)); - map.remove(property); - } - } - } catch (Exception e) { - StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, - "Could not retrieve authorization credentials", e)); //$NON-NLS-1$ - } - return propertyValue; - + private String getAuthInfo(String property) { + Map<String, String> map = getAuthInfo(); + return map == null ? null : map.get(property); } public String getCharacterEncoding() { @@ -577,6 +448,29 @@ public final class TaskRepository extends PlatformObject { return this.properties.get(name); } +// /** +// * @deprecated use {@link TaskRepositoryLocation#getProxyForHost(String, String)} instead +// */ +// @Deprecated +// public Proxy getProxy() { +// Proxy proxy = Proxy.NO_PROXY; +// if (isDefaultProxyEnabled()) { +// proxy = WebClientUtil.getPlatformProxy(getRepositoryUrl()); +// } else { +// +// String proxyHost = getProperty(PROXY_HOSTNAME); +// String proxyPort = getProperty(PROXY_PORT); +// String proxyUsername = ""; +// String proxyPassword = ""; +// if (proxyHost != null && proxyHost.length() > 0) { +// proxyUsername = getProxyUsername(); +// proxyPassword = getProxyPassword(); +// } +// proxy = WebClientUtil.getProxy(proxyHost, proxyPort, proxyUsername, proxyPassword); +// } +// return proxy; +// } + /** * @deprecated use {@link #getCredentials(AuthenticationType)} instead */ @@ -755,14 +649,15 @@ public final class TaskRepository extends PlatformObject { if (credentials == null) { setProperty(key + ENABLED, String.valueOf(false)); transientProperties.remove(key + PASSWORD); - addAuthInfo("", "", key + USERNAME, key + PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ + setCredentialsInternal("", "", key + USERNAME, key + PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ } else { setProperty(key + ENABLED, String.valueOf(true)); if (savePassword) { - addAuthInfo(credentials.getUserName(), credentials.getPassword(), key + USERNAME, key + PASSWORD); + setCredentialsInternal(credentials.getUserName(), credentials.getPassword(), key + USERNAME, key + + PASSWORD); transientProperties.remove(key + PASSWORD); } else { - addAuthInfo(credentials.getUserName(), "", key + USERNAME, key + PASSWORD); //$NON-NLS-1$ + setCredentialsInternal(credentials.getUserName(), "", key + USERNAME, key + PASSWORD); //$NON-NLS-1$ transientProperties.put(key + PASSWORD, credentials.getPassword()); } } @@ -790,6 +685,21 @@ public final class TaskRepository extends PlatformObject { } + private void setCredentialsInternal(String username, String password, String userProperty, String passwordProperty) { + Map<String, String> map = getAuthInfo(); + if (map == null) { + map = new HashMap<String, String>(); + } + + if (username != null) { + map.put(userProperty, username); + } + if (password != null) { + map.put(passwordProperty, password); + } + addAuthInfo(map); + } + /** * @deprecated use esetCredentials(AuthenticationType, AuthenticationCredentials, boolean) */ |