Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java11
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java30
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java384
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFlagMapper.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java376
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java44
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfigurationFactory.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java61
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java16
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java15
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java9
24 files changed, 540 insertions, 522 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
index bdc2be37e..a96078108 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
@@ -42,8 +42,11 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
private final String dateFormat_3_TimeZone = "yyyy-MM-dd zzz"; //$NON-NLS-1$
- public BugzillaAttributeMapper(TaskRepository taskRepository) {
+ private final BugzillaRepositoryConnector connector;
+
+ public BugzillaAttributeMapper(TaskRepository taskRepository, BugzillaRepositoryConnector connector) {
super(taskRepository);
+ this.connector = connector;
}
@Override
@@ -93,7 +96,7 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
RepositoryConfiguration repositoryConfiguration;
BugzillaVersion bugzillaVersion = null;
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(getTaskRepository().getUrl());
+ repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
if (repositoryConfiguration != null) {
bugzillaVersion = repositoryConfiguration.getInstallVersion();
} else {
@@ -192,7 +195,7 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
RepositoryConfiguration repositoryConfiguration;
BugzillaVersion bugzillaVersion = null;
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(getTaskRepository().getUrl());
+ repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
if (repositoryConfiguration != null) {
bugzillaVersion = repositoryConfiguration.getInstallVersion();
} else {
@@ -353,7 +356,7 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
@Override
public Map<String, String> getOptions(TaskAttribute attribute) {
- RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(getTaskRepository().getRepositoryUrl());
+ RepositoryConfiguration configuration = connector.getRepositoryConfiguration(getTaskRepository().getRepositoryUrl());
if (configuration != null) {
TaskAttribute attributeProduct = attribute.getTaskData().getRoot().getMappedAttribute(
BugzillaAttribute.PRODUCT.getKey());
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 6a894081c..1074776d2 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -75,6 +75,7 @@ import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
@@ -171,6 +172,8 @@ public class BugzillaClient {
private final AbstractWebLocation location;
+ private BugzillaRepositoryConnector connector;
+
public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters,
BugzillaLanguageSettings languageSettings) throws MalformedURLException {
this.repositoryUrl = new URL(location.getUrl());
@@ -183,6 +186,24 @@ public class BugzillaClient {
}
+ public BugzillaClient(AbstractWebLocation location, TaskRepository taskRepository,
+ BugzillaRepositoryConnector connector) throws MalformedURLException {
+ String language = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING);
+ if (language == null || language.equals("")) { //$NON-NLS-1$
+ language = IBugzillaConstants.DEFAULT_LANG;
+ }
+
+ this.connector = connector;
+ this.repositoryUrl = new URL(location.getUrl());
+ this.location = location;
+ this.characterEncoding = taskRepository.getCharacterEncoding();
+ this.configParameters = taskRepository.getProperties();
+ this.bugzillaLanguageSettings = connector.getLanguageSetting(language);
+ this.proxy = location.getProxyForHost(location.getUrl(), IProxyData.HTTP_PROXY_TYPE);
+ WebUtil.configureHttpClient(httpClient, USER_AGENT);
+
+ }
+
public void validate(IProgressMonitor monitor) throws IOException, CoreException {
monitor = Policy.monitorFor(monitor);
GzipGetMethod method = null;
@@ -565,7 +586,7 @@ public class BugzillaClient {
for (String type : VALID_CONFIG_CONTENT_TYPES) {
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(
- stream, getCharacterEncoding());
+ stream, getCharacterEncoding(), connector);
repositoryConfiguration = configFactory.getConfiguration();
@@ -950,7 +971,7 @@ public class BugzillaClient {
if (repositoryConfiguration == null) {
getRepositoryConfiguration(new SubProgressMonitor(monitor, 1));
- BugzillaCorePlugin.addRepositoryConfiguration(repositoryConfiguration);
+ connector.addRepositoryConfiguration(repositoryConfiguration);
}
if (taskData == null) {
@@ -1687,7 +1708,7 @@ public class BugzillaClient {
if (repositoryConfiguration == null) {
getRepositoryConfiguration(new SubProgressMonitor(monitor, 1));
- BugzillaCorePlugin.addRepositoryConfiguration(repositoryConfiguration);
+ connector.addRepositoryConfiguration(repositoryConfiguration);
}
GzipPostMethod method = null;
@@ -1734,7 +1755,8 @@ public class BugzillaClient {
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
InputStream input = getResponseStream(method, monitor);
try {
- MultiBugReportFactory factory = new MultiBugReportFactory(input, getCharacterEncoding());
+ MultiBugReportFactory factory = new MultiBugReportFactory(input,
+ getCharacterEncoding(), connector);
List<BugzillaCustomField> customFields = new ArrayList<BugzillaCustomField>();
if (repositoryConfiguration != null) {
customFields = repositoryConfiguration.getCustomFields();
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
index 09fd7f879..7d2fe125f 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
@@ -25,15 +25,12 @@ public class BugzillaClientFactory {
protected static TaskRepositoryLocationFactory taskRepositoryLocationFactory = new TaskRepositoryLocationFactory();
- public static BugzillaClient createClient(TaskRepository taskRepository) throws MalformedURLException {
- String language = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING);
- if (language == null || language.equals("")) { //$NON-NLS-1$
- language = IBugzillaConstants.DEFAULT_LANG;
- }
- BugzillaLanguageSettings languageSettings = BugzillaRepositoryConnector.getLanguageSetting(language);
+ public static BugzillaClient createClient(TaskRepository taskRepository, BugzillaRepositoryConnector connector)
+ throws MalformedURLException {
AbstractWebLocation location = taskRepositoryLocationFactory.createWebLocation(taskRepository);
- BugzillaClient client = new BugzillaClient(location, taskRepository.getCharacterEncoding(),
- taskRepository.getProperties(), languageSettings);
+
+ BugzillaClient client = new BugzillaClient(location, taskRepository, connector);
+
return client;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
index 6c13f3d89..7ef42677c 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
@@ -30,7 +30,10 @@ public class BugzillaClientManager implements IRepositoryListener {
private final Map<String, BugzillaClient> clientByUrl = new HashMap<String, BugzillaClient>();
- public BugzillaClientManager() {
+ private final BugzillaRepositoryConnector connector;
+
+ public BugzillaClientManager(BugzillaRepositoryConnector connector) {
+ this.connector = connector;
}
public BugzillaClient getClient(TaskRepository taskRepository, IProgressMonitor monitor) throws CoreException {
@@ -50,14 +53,14 @@ public class BugzillaClientManager implements IRepositoryListener {
}
clientByUrl.put(taskRepository.getRepositoryUrl(), client);
}
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository.getUrl());
+ RepositoryConfiguration config = connector.getRepositoryConfiguration(taskRepository.getUrl());
client.setRepositoryConfiguration(config);
}
return client;
}
protected BugzillaClient createClient(TaskRepository taskRepository) throws MalformedURLException {
- return BugzillaClientFactory.createClient(taskRepository);
+ return BugzillaClientFactory.createClient(taskRepository, connector);
}
public void repositoryAdded(TaskRepository repository) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
index 23fbda154..cdd3db7f5 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
@@ -11,29 +11,9 @@
package org.eclipse.mylyn.internal.bugzilla.core;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.commons.net.Policy;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.osgi.framework.BundleContext;
/**
@@ -42,39 +22,16 @@ import org.osgi.framework.BundleContext;
*/
public class BugzillaCorePlugin extends Plugin {
- private static final String ERROR_DELETING_CONFIGURATION = "Error removing corrupt repository configuration file."; //$NON-NLS-1$
-
- private static final String ERROR_INCOMPATIBLE_CONFIGURATION = "Reset Bugzilla repository configuration cache due to format change"; //$NON-NLS-1$
-
public static final String CONNECTOR_KIND = "bugzilla"; //$NON-NLS-1$
public static final String ID_PLUGIN = "org.eclipse.mylyn.bugzilla"; //$NON-NLS-1$
private static BugzillaCorePlugin INSTANCE;
- private static boolean cacheFileRead = false;
-
- private static File repositoryConfigurationFile = null;
-
- private static BugzillaRepositoryConnector connector;
-
- private static final String OPTION_ALL = "All"; //$NON-NLS-1$
-
- // A Map from Java's Platform to Buzilla's
- private final Map<String, String> java2buzillaPlatformMap = new HashMap<String, String>();
-
- /** Product configuration for the current server */
- private static Map<String, RepositoryConfiguration> repositoryConfigurations = new HashMap<String, RepositoryConfiguration>();
+ private BugzillaRepositoryConnector connector;
public BugzillaCorePlugin() {
super();
- java2buzillaPlatformMap.put("x86", "PC"); // can be PC or Macintosh! //$NON-NLS-1$ //$NON-NLS-2$
- java2buzillaPlatformMap.put("x86_64", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
- java2buzillaPlatformMap.put("ia64", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
- java2buzillaPlatformMap.put("ia64_32", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
- java2buzillaPlatformMap.put("sparc", "Sun"); //$NON-NLS-1$ //$NON-NLS-2$
- java2buzillaPlatformMap.put("ppc", "Power PC"); // not Power! //$NON-NLS-1$ //$NON-NLS-2$
-
}
public static BugzillaCorePlugin getDefault() {
@@ -89,345 +46,26 @@ public class BugzillaCorePlugin extends Plugin {
@Override
public void stop(BundleContext context) throws Exception {
- writeRepositoryConfigFile();
+ if (connector != null) {
+ connector.stop();
+ connector = null;
+ }
INSTANCE = null;
super.stop(context);
}
- /**
- * public for testing
- */
- public static void setConnector(BugzillaRepositoryConnector theConnector) {
+ void setConnector(BugzillaRepositoryConnector theConnector) {
connector = theConnector;
}
- public static Map<String, RepositoryConfiguration> getConfigurations() {
- readRepositoryConfigurationFile();
- return repositoryConfigurations;
- }
-
- public static void setConfigurationCacheFile(File file) {
- repositoryConfigurationFile = file;
- }
-
- public static File getConfigurationCacheFile() {
- return repositoryConfigurationFile;
- }
-
/**
- * @since 2.1
- * @return cached repository configuration. If not already cached, null is returned.
+ * Returns the path to the file caching the product configuration.
*/
- public static RepositoryConfiguration getRepositoryConfiguration(String repositoryUrl) {
- readRepositoryConfigurationFile();
- return repositoryConfigurations.get(repositoryUrl);
+ IPath getConfigurationCachePath() {
+ IPath stateLocation = Platform.getStateLocation(getBundle());
+ IPath configFile = stateLocation.append("repositoryConfigurations"); //$NON-NLS-1$
+ return configFile;
}
- /**
- * Retrieves the latest repository configuration from the server
- */
- public static RepositoryConfiguration getRepositoryConfiguration(TaskRepository repository, boolean forceRefresh,
- IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- try {
- readRepositoryConfigurationFile();
- RepositoryConfiguration configuration;
- configuration = repositoryConfigurations.get(repository.getRepositoryUrl());
- if (configuration == null || forceRefresh) {
- synchronized (repositoryConfigurations) {
- // check if another thread already retrieved configuration
- configuration = repositoryConfigurations.get(repository.getRepositoryUrl());
- if (configuration == null || forceRefresh) {
- BugzillaClient client = connector.getClientManager().getClient(repository, monitor);
- configuration = client.getRepositoryConfiguration(monitor);
- if (configuration != null) {
- internalAddConfiguration(configuration);
- }
- }
- }
- }
- return configuration;//repositoryConfigurations.get(repository.getRepositoryUrl());
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 1,
- "Error retrieving task attributes from repository.\n\n" + e.getMessage(), e)); //$NON-NLS-1$
- }
- }
-
- public static void addRepositoryConfiguration(RepositoryConfiguration config) {
- if (config != null) {
- readRepositoryConfigurationFile();
- synchronized (repositoryConfigurations) {
- internalAddConfiguration(config);
- }
- }
- }
-
- private static void internalAddConfiguration(RepositoryConfiguration config) {
- repositoryConfigurations.remove(config.getRepositoryUrl());
- repositoryConfigurations.put(config.getRepositoryUrl(), config);
- }
-
- // /**
- // * Returns the path to the file cacheing the product configuration.
- // */
- // private static IPath getProductConfigurationCachePath() {
- // IPath stateLocation =
- // Platform.getStateLocation(BugzillaPlugin.getDefault().getBundle());
- // IPath configFile = stateLocation.append("repositoryConfigurations");
- // return configFile;
- // }
-
- /** public for testing */
- public static void removeConfiguration(RepositoryConfiguration config) {
- synchronized (repositoryConfigurations) {
- repositoryConfigurations.remove(config.getRepositoryUrl());
- }
- }
-
- /** public for testing */
- public static synchronized void readRepositoryConfigurationFile() {
-
- // IPath configFile = getProductConfigurationCachePath();
- if (cacheFileRead || repositoryConfigurationFile == null || !repositoryConfigurationFile.exists()) {
- return;
- }
-
- synchronized (repositoryConfigurations) {
- ObjectInputStream in = null;
- try {
- in = new ObjectInputStream(new FileInputStream(repositoryConfigurationFile));
- int size = in.readInt();
- for (int nX = 0; nX < size; nX++) {
- RepositoryConfiguration item = (RepositoryConfiguration) in.readObject();
- if (item != null) {
- repositoryConfigurations.put(item.getRepositoryUrl(), item);
- }
- }
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.INFO, BugzillaCorePlugin.ID_PLUGIN,
- ERROR_INCOMPATIBLE_CONFIGURATION));
- try {
- if (in != null) {
- in.close();
- }
- if (repositoryConfigurationFile != null && repositoryConfigurationFile.exists()) {
- if (repositoryConfigurationFile.delete()) {
- // successfully deleted
- } else {
- StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 0,
- ERROR_DELETING_CONFIGURATION, e));
- }
- }
-
- } catch (Exception ex) {
- StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 0,
- ERROR_DELETING_CONFIGURATION, e));
- }
- } finally {
- cacheFileRead = true;
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
- }
-
- /** public for testing */
- public static void writeRepositoryConfigFile() {
- if (repositoryConfigurationFile != null) {
- ObjectOutputStream out = null;
- try {
- Set<RepositoryConfiguration> tempConfigs;
- synchronized (repositoryConfigurations) {
- tempConfigs = new HashSet<RepositoryConfiguration>(repositoryConfigurations.values());
- }
- if (tempConfigs.size() > 0) {
- out = new ObjectOutputStream(new FileOutputStream(repositoryConfigurationFile));
- out.writeInt(tempConfigs.size());
- for (RepositoryConfiguration repositoryConfiguration : tempConfigs) {
- if (repositoryConfiguration != null) {
- out.writeObject(repositoryConfiguration);
- }
- }
- }
- } catch (IOException e) {
- StatusHandler.log(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, 0,
- "Failed to write repository configuration cache", e)); //$NON-NLS-1$
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
- }
-
- /**
- * Returns the path to the file caching bug reports created while offline.
- */
- protected IPath getCachedBugReportPath() {
- IPath stateLocation = Platform.getStateLocation(BugzillaCorePlugin.getDefault().getBundle());
- IPath bugFile = stateLocation.append("bugReports"); //$NON-NLS-1$
- return bugFile;
- }
-
- public void setPlatformDefaultsOrGuess(TaskRepository repository, TaskData newBugModel) {
-
- String platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
- String os = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_OS);
-
- // set both or none
- if (null != os && null != platform) {
- TaskAttribute opSysAttribute = newBugModel.getRoot().getAttribute(BugzillaAttribute.OP_SYS.getKey());
- TaskAttribute platformAttribute = newBugModel.getRoot().getAttribute(
- BugzillaAttribute.REP_PLATFORM.getKey());
-
- // TODO something can still go wrong when the allowed values on the repository change...
- opSysAttribute.setValue(os);
- platformAttribute.setValue(platform);
- return;
- }
- // fall through to old code
- setPlatformOptions(newBugModel);
- }
-
- public void setPlatformOptions(TaskData newBugModel) {
- try {
-
- // Get OS Lookup Map
- // Check that the result is in Values, if it is not, set it to other
- // Defaults to the first of each (sorted) list All, All
- TaskAttribute opSysAttribute = newBugModel.getRoot().getAttribute(BugzillaAttribute.OP_SYS.getKey());
- TaskAttribute platformAttribute = newBugModel.getRoot().getAttribute(
- BugzillaAttribute.REP_PLATFORM.getKey());
-
- String OS = Platform.getOS();
- String platform = Platform.getOSArch();
- String ws = Platform.getWS();
-
- String bugzillaOS = null; // Bugzilla String for OS
- String bugzillaPlatform = null; // Bugzilla String for Platform
- String[] wsExtentions = null;
-/*
- AIX -> AIX
- Linux -> Linux
- HP-UX -> HP-UX
- Solaris -> Solaris
- MacOS X -> Mac OS X
- */
-
- if (ws.length() > 1) {
- char first = ws.charAt(0);
- char firstLower = Character.toLowerCase(first);
- char firstUpper = Character.toUpperCase(first);
- String[] wsExtentionsTemp = { " - " + firstUpper + ws.substring(1, ws.length()), //$NON-NLS-1$
- " - " + firstLower + ws.substring(1, ws.length()), //$NON-NLS-1$
- " " + firstUpper + ws.substring(1, ws.length()), //$NON-NLS-1$
- " " + firstLower + ws.substring(1, ws.length()), "" }; //$NON-NLS-1$//$NON-NLS-2$
- wsExtentions = wsExtentionsTemp;
- } else if (ws.length() == 1) {
- char first = ws.charAt(0);
- char firstLower = Character.toLowerCase(first);
- char firstUpper = Character.toUpperCase(first);
- String[] wsExtentionsTemp = { " - " + firstUpper, " - " + firstLower, " " + firstUpper, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- " " + firstLower, "" }; //$NON-NLS-1$//$NON-NLS-2$
- wsExtentions = wsExtentionsTemp;
- } else {
- String[] wsExtentionsTemp = { "" }; //$NON-NLS-1$
- wsExtentions = wsExtentionsTemp;
- }
-
- bugzillaOS = System.getProperty("os.name") + " " + System.getProperty("os.version"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // We start with the most specific Value as the Search String.
- // If we didn't find it we remove the last part of the version String or the OS Name from
- // the Search String and continue with the test until we found it or the Search String is empty.
- //
- // The search in casesensitive.
- if (opSysAttribute != null) {
- for (String element : wsExtentions) {
- String bugzillaOSTemp = bugzillaOS;
- while (bugzillaOSTemp != null && opSysAttribute.getOption(bugzillaOSTemp + element) == null) {
- int dotindex = bugzillaOSTemp.lastIndexOf('.');
- if (dotindex > 0) {
- bugzillaOSTemp = bugzillaOSTemp.substring(0, dotindex);
- } else {
- int spaceindex = bugzillaOSTemp.lastIndexOf(' ');
- if (spaceindex > 0) {
- bugzillaOSTemp = bugzillaOSTemp.substring(0, spaceindex);
- } else {
- bugzillaOSTemp = null;
- }
- }
- }
- if (bugzillaOSTemp != null) {
- bugzillaOS = bugzillaOSTemp + element;
- break;
- }
- }
- } else {
- bugzillaOS = null;
- }
-
- if (platform != null && java2buzillaPlatformMap.containsKey(platform)) {
- bugzillaPlatform = java2buzillaPlatformMap.get(platform);
- // Bugzilla knows the following Platforms [All, Macintosh, Other, PC, Power PC, Sun]
- // Platform.getOSArch() returns "x86" on Intel Mac's and "ppc" on Power Mac's
- // so bugzillaPlatform is "Power" or "PC".
- //
- // If the OS is "macosx" we change the Platform to "Macintosh"
- //
- if (bugzillaPlatform != null
- && (bugzillaPlatform.compareTo("Power") == 0 || bugzillaPlatform.compareTo("PC") == 0) //$NON-NLS-1$ //$NON-NLS-2$
- && OS != null && OS.compareTo("macosx") == 0) { //$NON-NLS-1$
- // TODO: this may not even be a legal value in another repository!
- bugzillaPlatform = "Macintosh"; //$NON-NLS-1$
- } else if (platformAttribute != null && platformAttribute.getOption(bugzillaPlatform) == null) {
- // If the platform we found is not int the list of available
- // optinos, set the
- // Bugzilla Platform to null, and juse use "other"
- bugzillaPlatform = null;
- }
- }
- // Set the OS and the Platform in the taskData
- if (bugzillaOS != null && opSysAttribute != null) {
- opSysAttribute.setValue(bugzillaOS);
- } else if (opSysAttribute != null && opSysAttribute.getOption(OPTION_ALL) != null) {
- opSysAttribute.setValue(OPTION_ALL);
- }
-
- if (bugzillaPlatform != null && platformAttribute != null) {
- platformAttribute.setValue(bugzillaPlatform);
- } else if (opSysAttribute != null && platformAttribute != null
- && platformAttribute.getOption(OPTION_ALL) != null) {
- opSysAttribute.setValue(OPTION_ALL);
- }
-
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "could not set platform options", //$NON-NLS-1$
- e));
- }
- }
-
- public Set<BugzillaLanguageSettings> getLanguageSettings() {
- return BugzillaRepositoryConnector.getLanguageSettings();
- }
-
- public BugzillaLanguageSettings getLanguageSetting(String language) {
- return BugzillaRepositoryConnector.getLanguageSetting(language);
- }
-
- /**
- * this method is only for testing
- */
- public static void setCacheFileRead(boolean cacheFileRead) {
- BugzillaCorePlugin.cacheFileRead = cacheFileRead;
- }
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFlagMapper.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFlagMapper.java
index 995db308f..837f61858 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFlagMapper.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFlagMapper.java
@@ -35,6 +35,12 @@ public class BugzillaFlagMapper {
private int number;
+ private final BugzillaRepositoryConnector connector;
+
+ public BugzillaFlagMapper(BugzillaRepositoryConnector connector) {
+ this.connector = connector;
+ }
+
public String getRequestee() {
return requestee;
}
@@ -95,7 +101,7 @@ public class BugzillaFlagMapper {
BugzillaVersion bugzillaVersion = null;
RepositoryConfiguration repositoryConfiguration;
try {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(mapper.getTaskRepository(), false,
+ repositoryConfiguration = connector.getRepositoryConfiguration(mapper.getTaskRepository(), false,
new NullProgressMonitor());
bugzillaVersion = repositoryConfiguration.getInstallVersion();
} catch (CoreException e) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
index 9fff2fbc6..64b4d0e9d 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
@@ -11,7 +11,12 @@
package org.eclipse.mylyn.internal.bugzilla.core;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
@@ -25,11 +30,14 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.mylyn.commons.core.StatusHandler;
@@ -82,6 +90,65 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
protected static final Set<BugzillaLanguageSettings> languages = new LinkedHashSet<BugzillaLanguageSettings>();
+ private static final String ERROR_DELETING_CONFIGURATION = "Error removing corrupt repository configuration file."; //$NON-NLS-1$
+
+ private static final String ERROR_INCOMPATIBLE_CONFIGURATION = "Reset Bugzilla repository configuration cache due to format change"; //$NON-NLS-1$
+
+ private boolean cacheFileRead;
+
+ private File repositoryConfigurationFile;
+
+ private final Map<String, RepositoryConfiguration> repositoryConfigurations = new HashMap<String, RepositoryConfiguration>();
+
+ // A Map from Java's Platform to Buzilla's
+ private static final Map<String, String> java2buzillaPlatformMap = new HashMap<String, String>();
+
+ private static final String OPTION_ALL = "All"; //$NON-NLS-1$
+
+ static {
+ enSetting = new BugzillaLanguageSettings(IBugzillaConstants.DEFAULT_LANG);
+ enSetting.addLanguageAttribute("error_login", "Login"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_login", "log in"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_login", "check e-mail"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_login", "Invalid Username Or Password"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_collision", "Mid-air collision!"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_comment_required", "Comment Required"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("error_logged_out", "logged out"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bad_login", "Login"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bad_login", "log in"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bad_login", "check e-mail"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bad_login", "Invalid Username Or Password"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bad_login", "error"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("processed", "processed"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("changes_submitted", "Changes submitted"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("changes_submitted", "added to Bug"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bug", "Bug"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("bug", "Issue"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("submitted", "Submitted"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("submitted", "posted"); //$NON-NLS-1$ //$NON-NLS-2$
+ enSetting.addLanguageAttribute("suspicious_action", "Suspicious action"); //$NON-NLS-1$ //$NON-NLS-2$
+ languages.add(enSetting);
+
+ java2buzillaPlatformMap.put("x86", "PC"); // can be PC or Macintosh! //$NON-NLS-1$ //$NON-NLS-2$
+ java2buzillaPlatformMap.put("x86_64", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
+ java2buzillaPlatformMap.put("ia64", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
+ java2buzillaPlatformMap.put("ia64_32", "PC"); //$NON-NLS-1$ //$NON-NLS-2$
+ java2buzillaPlatformMap.put("sparc", "Sun"); //$NON-NLS-1$ //$NON-NLS-2$
+ java2buzillaPlatformMap.put("ppc", "Power PC"); // not Power! //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public BugzillaRepositoryConnector() {
+ if (BugzillaCorePlugin.getDefault() != null) {
+ BugzillaCorePlugin.getDefault().setConnector(this);
+ IPath path = BugzillaCorePlugin.getDefault().getConfigurationCachePath();
+ this.repositoryConfigurationFile = path.toFile();
+ }
+ }
+
+ public BugzillaRepositoryConnector(File repositoryConfigurationFile) {
+ this.repositoryConfigurationFile = repositoryConfigurationFile;
+ }
+
@Override
public String getLabel() {
return CLIENT_LABEL;
@@ -381,32 +448,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
public BugzillaClientManager getClientManager() {
if (clientManager == null) {
- clientManager = new BugzillaClientManager();
- // TODO: Move this initialization elsewhere
- BugzillaCorePlugin.setConnector(this);
- enSetting = new BugzillaLanguageSettings(IBugzillaConstants.DEFAULT_LANG);
- enSetting.addLanguageAttribute("error_login", "Login"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_login", "log in"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_login", "check e-mail"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_login", "Invalid Username Or Password"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_collision", "Mid-air collision!"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_comment_required", "Comment Required"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("error_logged_out", "logged out"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bad_login", "Login"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bad_login", "log in"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bad_login", "check e-mail"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bad_login", "Invalid Username Or Password"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bad_login", "error"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("processed", "processed"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("changes_submitted", "Changes submitted"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("changes_submitted", "added to Bug"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bug", "Bug"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("bug", "Issue"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("submitted", "Submitted"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("submitted", "posted"); //$NON-NLS-1$ //$NON-NLS-2$
- enSetting.addLanguageAttribute("suspicious_action", "Suspicious action"); //$NON-NLS-1$ //$NON-NLS-2$
- languages.add(enSetting);
-
+ clientManager = new BugzillaClientManager(this);
}
return clientManager;
}
@@ -414,7 +456,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
@Override
public void updateRepositoryConfiguration(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
if (repository != null) {
- BugzillaCorePlugin.getRepositoryConfiguration(repository, true, monitor);
+ getRepositoryConfiguration(repository, true, monitor);
}
}
@@ -608,4 +650,284 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
};
}
+ /** public for testing */
+ public synchronized void readRepositoryConfigurationFile() {
+ if (cacheFileRead || repositoryConfigurationFile == null || !repositoryConfigurationFile.exists()) {
+ return;
+ }
+
+ synchronized (repositoryConfigurations) {
+ ObjectInputStream in = null;
+ try {
+ in = new ObjectInputStream(new FileInputStream(repositoryConfigurationFile));
+ int size = in.readInt();
+ for (int nX = 0; nX < size; nX++) {
+ RepositoryConfiguration item = (RepositoryConfiguration) in.readObject();
+ if (item != null) {
+ repositoryConfigurations.put(item.getRepositoryUrl(), item);
+ }
+ }
+ } catch (Exception e) {
+ StatusHandler.log(new Status(IStatus.INFO, BugzillaCorePlugin.ID_PLUGIN,
+ ERROR_INCOMPATIBLE_CONFIGURATION));
+ try {
+ if (in != null) {
+ in.close();
+ }
+ if (repositoryConfigurationFile != null && repositoryConfigurationFile.exists()) {
+ if (repositoryConfigurationFile.delete()) {
+ // successfully deleted
+ } else {
+ StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 0,
+ ERROR_DELETING_CONFIGURATION, e));
+ }
+ }
+
+ } catch (Exception ex) {
+ StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 0,
+ ERROR_DELETING_CONFIGURATION, e));
+ }
+ } finally {
+ cacheFileRead = true;
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Retrieves the latest repository configuration from the server
+ */
+ public RepositoryConfiguration getRepositoryConfiguration(TaskRepository repository, boolean forceRefresh,
+ IProgressMonitor monitor) throws CoreException {
+ monitor = Policy.monitorFor(monitor);
+ try {
+ readRepositoryConfigurationFile();
+ RepositoryConfiguration configuration;
+ configuration = repositoryConfigurations.get(repository.getRepositoryUrl());
+ if (configuration == null || forceRefresh) {
+ synchronized (repositoryConfigurations) {
+ // check if another thread already retrieved configuration
+ configuration = repositoryConfigurations.get(repository.getRepositoryUrl());
+ if (configuration == null || forceRefresh) {
+ BugzillaClient client = clientManager.getClient(repository, monitor);
+ configuration = client.getRepositoryConfiguration(monitor);
+ if (configuration != null) {
+ internalAddConfiguration(configuration);
+ }
+ }
+ }
+ }
+ return configuration;//repositoryConfigurations.get(repository.getRepositoryUrl());
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 1,
+ "Error retrieving task attributes from repository.\n\n" + e.getMessage(), e)); //$NON-NLS-1$
+ }
+ }
+
+ public void addRepositoryConfiguration(RepositoryConfiguration config) {
+ if (config != null) {
+ readRepositoryConfigurationFile();
+ synchronized (repositoryConfigurations) {
+ internalAddConfiguration(config);
+ }
+ }
+ }
+
+ private void internalAddConfiguration(RepositoryConfiguration config) {
+ repositoryConfigurations.remove(config.getRepositoryUrl());
+ repositoryConfigurations.put(config.getRepositoryUrl(), config);
+ }
+
+ public RepositoryConfiguration getRepositoryConfiguration(String repositoryUrl) {
+ readRepositoryConfigurationFile();
+ return repositoryConfigurations.get(repositoryUrl);
+ }
+
+ /** public for testing */
+ public void removeConfiguration(RepositoryConfiguration config) {
+ synchronized (repositoryConfigurations) {
+ repositoryConfigurations.remove(config.getRepositoryUrl());
+ }
+ }
+
+ /** public for testing */
+ public void writeRepositoryConfigFile() {
+ if (repositoryConfigurationFile != null) {
+ ObjectOutputStream out = null;
+ try {
+ Set<RepositoryConfiguration> tempConfigs;
+ synchronized (repositoryConfigurations) {
+ tempConfigs = new HashSet<RepositoryConfiguration>(repositoryConfigurations.values());
+ }
+ if (tempConfigs.size() > 0) {
+ out = new ObjectOutputStream(new FileOutputStream(repositoryConfigurationFile));
+ out.writeInt(tempConfigs.size());
+ for (RepositoryConfiguration repositoryConfiguration : tempConfigs) {
+ if (repositoryConfiguration != null) {
+ out.writeObject(repositoryConfiguration);
+ }
+ }
+ }
+ } catch (IOException e) {
+ StatusHandler.log(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, 0,
+ "Failed to write repository configuration cache", e)); //$NON-NLS-1$
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
+ public void stop() {
+ writeRepositoryConfigFile();
+ }
+
+ public void setPlatformDefaultsOrGuess(TaskRepository repository, TaskData newBugModel) {
+
+ String platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
+ String os = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_OS);
+
+ // set both or none
+ if (null != os && null != platform) {
+ TaskAttribute opSysAttribute = newBugModel.getRoot().getAttribute(BugzillaAttribute.OP_SYS.getKey());
+ TaskAttribute platformAttribute = newBugModel.getRoot().getAttribute(
+ BugzillaAttribute.REP_PLATFORM.getKey());
+
+ // TODO something can still go wrong when the allowed values on the repository change...
+ opSysAttribute.setValue(os);
+ platformAttribute.setValue(platform);
+ return;
+ }
+ // fall through to old code
+ setPlatformOptions(newBugModel);
+ }
+
+ public void setPlatformOptions(TaskData newBugModel) {
+ try {
+
+ // Get OS Lookup Map
+ // Check that the result is in Values, if it is not, set it to other
+ // Defaults to the first of each (sorted) list All, All
+ TaskAttribute opSysAttribute = newBugModel.getRoot().getAttribute(BugzillaAttribute.OP_SYS.getKey());
+ TaskAttribute platformAttribute = newBugModel.getRoot().getAttribute(
+ BugzillaAttribute.REP_PLATFORM.getKey());
+
+ String OS = Platform.getOS();
+ String platform = Platform.getOSArch();
+ String ws = Platform.getWS();
+
+ String bugzillaOS = null; // Bugzilla String for OS
+ String bugzillaPlatform = null; // Bugzilla String for Platform
+ String[] wsExtentions = null;
+/*
+ AIX -> AIX
+ Linux -> Linux
+ HP-UX -> HP-UX
+ Solaris -> Solaris
+ MacOS X -> Mac OS X
+ */
+
+ if (ws.length() > 1) {
+ char first = ws.charAt(0);
+ char firstLower = Character.toLowerCase(first);
+ char firstUpper = Character.toUpperCase(first);
+ String[] wsExtentionsTemp = { " - " + firstUpper + ws.substring(1, ws.length()), //$NON-NLS-1$
+ " - " + firstLower + ws.substring(1, ws.length()), //$NON-NLS-1$
+ " " + firstUpper + ws.substring(1, ws.length()), //$NON-NLS-1$
+ " " + firstLower + ws.substring(1, ws.length()), "" }; //$NON-NLS-1$//$NON-NLS-2$
+ wsExtentions = wsExtentionsTemp;
+ } else if (ws.length() == 1) {
+ char first = ws.charAt(0);
+ char firstLower = Character.toLowerCase(first);
+ char firstUpper = Character.toUpperCase(first);
+ String[] wsExtentionsTemp = { " - " + firstUpper, " - " + firstLower, " " + firstUpper, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ " " + firstLower, "" }; //$NON-NLS-1$//$NON-NLS-2$
+ wsExtentions = wsExtentionsTemp;
+ } else {
+ String[] wsExtentionsTemp = { "" }; //$NON-NLS-1$
+ wsExtentions = wsExtentionsTemp;
+ }
+
+ bugzillaOS = System.getProperty("os.name") + " " + System.getProperty("os.version"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ // We start with the most specific Value as the Search String.
+ // If we didn't find it we remove the last part of the version String or the OS Name from
+ // the Search String and continue with the test until we found it or the Search String is empty.
+ //
+ // The search in casesensitive.
+ if (opSysAttribute != null) {
+ for (String element : wsExtentions) {
+ String bugzillaOSTemp = bugzillaOS;
+ while (bugzillaOSTemp != null && opSysAttribute.getOption(bugzillaOSTemp + element) == null) {
+ int dotindex = bugzillaOSTemp.lastIndexOf('.');
+ if (dotindex > 0) {
+ bugzillaOSTemp = bugzillaOSTemp.substring(0, dotindex);
+ } else {
+ int spaceindex = bugzillaOSTemp.lastIndexOf(' ');
+ if (spaceindex > 0) {
+ bugzillaOSTemp = bugzillaOSTemp.substring(0, spaceindex);
+ } else {
+ bugzillaOSTemp = null;
+ }
+ }
+ }
+ if (bugzillaOSTemp != null) {
+ bugzillaOS = bugzillaOSTemp + element;
+ break;
+ }
+ }
+ } else {
+ bugzillaOS = null;
+ }
+
+ if (platform != null && java2buzillaPlatformMap.containsKey(platform)) {
+ bugzillaPlatform = java2buzillaPlatformMap.get(platform);
+ // Bugzilla knows the following Platforms [All, Macintosh, Other, PC, Power PC, Sun]
+ // Platform.getOSArch() returns "x86" on Intel Mac's and "ppc" on Power Mac's
+ // so bugzillaPlatform is "Power" or "PC".
+ //
+ // If the OS is "macosx" we change the Platform to "Macintosh"
+ //
+ if (bugzillaPlatform != null
+ && (bugzillaPlatform.compareTo("Power") == 0 || bugzillaPlatform.compareTo("PC") == 0) //$NON-NLS-1$ //$NON-NLS-2$
+ && OS != null && OS.compareTo("macosx") == 0) { //$NON-NLS-1$
+ // TODO: this may not even be a legal value in another repository!
+ bugzillaPlatform = "Macintosh"; //$NON-NLS-1$
+ } else if (platformAttribute != null && platformAttribute.getOption(bugzillaPlatform) == null) {
+ // If the platform we found is not int the list of available
+ // optinos, set the
+ // Bugzilla Platform to null, and juse use "other"
+ bugzillaPlatform = null;
+ }
+ }
+ // Set the OS and the Platform in the taskData
+ if (bugzillaOS != null && opSysAttribute != null) {
+ opSysAttribute.setValue(bugzillaOS);
+ } else if (opSysAttribute != null && opSysAttribute.getOption(OPTION_ALL) != null) {
+ opSysAttribute.setValue(OPTION_ALL);
+ }
+
+ if (bugzillaPlatform != null && platformAttribute != null) {
+ platformAttribute.setValue(bugzillaPlatform);
+ } else if (opSysAttribute != null && platformAttribute != null
+ && platformAttribute.getOption(OPTION_ALL) != null) {
+ opSysAttribute.setValue(OPTION_ALL);
+ }
+
+ } catch (Exception e) {
+ StatusHandler.log(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "could not set platform options", //$NON-NLS-1$
+ e));
+ }
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
index f809568f8..7f8cb6c93 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
@@ -48,14 +48,14 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
VERSION_0(0f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
// ignore
}
},
VERSION_1_0(1.0f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
// 1: the value was stored in the attribute rather than the key
for (TaskAttribute attribute : new ArrayList<TaskAttribute>(data.getRoot().getAttributes().values())) {
if (attribute.getId().equals(BugzillaAttribute.DESC.getKey())) {
@@ -74,7 +74,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
for (TaskAttribute taskAttribute : operationsToRemove) {
data.getRoot().removeAttribute(taskAttribute.getId());
}
- RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
+ RepositoryConfiguration configuration = connector.getRepositoryConfiguration(repository.getRepositoryUrl());
if (configuration != null) {
configuration.addValidOperations(data);
}
@@ -82,26 +82,26 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
},
VERSION_2_0(2.0f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
updateAttribute(data, BugzillaAttribute.LONG_DESC);
}
},
VERSION_3_0(3.0f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
updateAttribute(data, BugzillaAttribute.NEW_COMMENT);
}
},
VERSION_4_0(4.0f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
updateAttribute(data, BugzillaAttribute.DEADLINE);
updateAttribute(data, BugzillaAttribute.ACTUAL_TIME);
}
},
VERSION_4_1(4.1f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
updateAttribute(data, BugzillaAttribute.VOTES);
TaskAttribute attrDeadline = data.getRoot().getMappedAttribute(BugzillaAttribute.VOTES.getKey());
if (attrDeadline != null) {
@@ -111,7 +111,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
},
VERSION_4_2(4.2f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
updateAttribute(data, BugzillaAttribute.CC);
updateAttribute(data, BugzillaAttribute.DEPENDSON);
updateAttribute(data, BugzillaAttribute.BLOCKED);
@@ -124,7 +124,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
},
VERSION_4_3(4.3f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
// migrate custom attributes
for (TaskAttribute attribute : data.getRoot().getAttributes().values()) {
if (attribute.getId().startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
@@ -141,16 +141,16 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
},
VERSION_4_4(4.4f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
// summary didn't have spell checking, update to short rich text
updateAttribute(data, BugzillaAttribute.SHORT_DESC);
}
},
VERSION_4_5(4.5f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
// migrate custom attributes
- RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
+ RepositoryConfiguration configuration = connector.getRepositoryConfiguration(repository.getRepositoryUrl());
if (configuration == null) {
return;
@@ -205,7 +205,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
},
VERSION_CURRENT(4.6f) {
@Override
- void migrate(TaskRepository repository, TaskData data) {
+ void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector) {
data.setVersion(TaskDataVersion.VERSION_CURRENT.toString());
}
};
@@ -220,7 +220,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
return versionNumber;
}
- abstract void migrate(TaskRepository repository, TaskData data);
+ abstract void migrate(TaskRepository repository, TaskData data, BugzillaRepositoryConnector connector);
@Override
public String toString() {
@@ -237,7 +237,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
}
}
- private final BugzillaRepositoryConnector connector;
+ protected final BugzillaRepositoryConnector connector;
public BugzillaTaskDataHandler(BugzillaRepositoryConnector connector) {
this.connector = connector;
@@ -356,7 +356,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
for (TaskDataVersion version : TaskDataVersion.values()) {
if (bugzillaTaskDataVersion <= version.getVersionNum()) {
- version.migrate(taskRepository, taskData);
+ version.migrate(taskRepository, taskData, connector);
}
}
}
@@ -397,8 +397,8 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
// fresh from the repository (not locally stored data that may not have been migrated).
taskData.setVersion(TaskDataVersion.VERSION_CURRENT.toString());
- RepositoryConfiguration repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository,
- false, monitor);
+ RepositoryConfiguration repositoryConfiguration = connector.getRepositoryConfiguration(repository, false,
+ monitor);
if (repositoryConfiguration == null) {
return false;
@@ -429,14 +429,14 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
}
initializeNewTaskDataAttributes(repositoryConfiguration, taskData, product, component, monitor);
- if (BugzillaCorePlugin.getDefault() != null) {
- BugzillaCorePlugin.getDefault().setPlatformDefaultsOrGuess(repository, taskData);
+ if (connector != null) {
+ connector.setPlatformDefaultsOrGuess(repository, taskData);
}
return true;
} else {
boolean shortLogin = Boolean.parseBoolean(repository.getProperty(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN));
- repositoryConfiguration.configureTaskData(taskData, shortLogin);
+ repositoryConfiguration.configureTaskData(taskData, shortLogin, connector);
}
return true;
}
@@ -662,7 +662,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
@Override
public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) {
- return new BugzillaAttributeMapper(taskRepository);
+ return new BugzillaAttributeMapper(taskRepository, connector);
}
public static TaskAttribute createAttribute(TaskData data, BugzillaAttribute key) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java
index d5e6a9d11..cbf4d5d33 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java
@@ -33,15 +33,18 @@ import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
*/
public class MultiBugReportFactory extends AbstractReportFactory {
- public MultiBugReportFactory(InputStream inStream, String encoding) {
+ private final BugzillaRepositoryConnector connector;
+
+ public MultiBugReportFactory(InputStream inStream, String encoding, BugzillaRepositoryConnector connector) {
super(inStream, encoding);
+ this.connector = connector;
}
public void populateReport(Map<String, TaskData> bugMap, TaskDataCollector collector, TaskAttributeMapper mapper,
List<BugzillaCustomField> customFields) throws IOException, CoreException {
SaxMultiBugReportContentHandler contentHandler = new SaxMultiBugReportContentHandler(mapper, collector, bugMap,
- customFields);
+ customFields, connector);
collectResults(contentHandler, false);
for (TaskData data : bugMap.values()) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
index fb159df79..e71062c52 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
@@ -71,7 +71,6 @@ public class RepositoryConfiguration implements Serializable {
private String encoding = null;
public RepositoryConfiguration() {
- super();
}
public void addStatus(String status) {
@@ -366,9 +365,9 @@ public class RepositoryConfiguration implements Serializable {
return customFields;
}
- public void configureTaskData(TaskData taskData, boolean localuser) {
+ public void configureTaskData(TaskData taskData, boolean localuser, BugzillaRepositoryConnector connector) {
if (taskData != null) {
- addMissingFlags(taskData);
+ addMissingFlags(taskData, connector);
updateAttributeOptions(taskData);
addValidOperations(taskData);
if (localuser) {
@@ -396,7 +395,7 @@ public class RepositoryConfiguration implements Serializable {
}
}
- private void addMissingFlags(TaskData taskData) {
+ private void addMissingFlags(TaskData taskData, BugzillaRepositoryConnector connector) {
List<String> existingFlags = new ArrayList<String>();
List<BugzillaFlag> flags = getFlags();
for (TaskAttribute attribute : new HashSet<TaskAttribute>(taskData.getRoot().getAttributes().values())) {
@@ -433,7 +432,7 @@ public class RepositoryConfiguration implements Serializable {
if (existingFlags.contains(bugzillaFlag.getName()) && !bugzillaFlag.isMultiplicable()) {
continue;
}
- BugzillaFlagMapper mapper = new BugzillaFlagMapper();
+ BugzillaFlagMapper mapper = new BugzillaFlagMapper(connector);
mapper.setRequestee(""); //$NON-NLS-1$
mapper.setSetter(""); //$NON-NLS-1$
mapper.setState(" "); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfigurationFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfigurationFactory.java
index ae8b26db3..f5da73228 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfigurationFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfigurationFactory.java
@@ -25,13 +25,15 @@ import org.xml.sax.SAXParseException;
* @author Rob Elves
*/
public class RepositoryConfigurationFactory extends AbstractReportFactory {
+ private final BugzillaRepositoryConnector connector;
- public RepositoryConfigurationFactory(InputStream inStream, String encoding) {
+ public RepositoryConfigurationFactory(InputStream inStream, String encoding, BugzillaRepositoryConnector connector) {
super(inStream, encoding);
+ this.connector = connector;
}
public RepositoryConfiguration getConfiguration() throws IOException, CoreException {
- SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler();
+ SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(connector);
collectResults(contentHandler, true);
RepositoryConfiguration config = contentHandler.getConfiguration();
return config;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java
index d13d9646a..292e251ff 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java
@@ -175,7 +175,7 @@ public class SaxConfigurationContentHandler extends DefaultHandler {
private String about;
- private final RepositoryConfiguration configuration = new RepositoryConfiguration();
+ private final RepositoryConfiguration configuration;
private final Map<String, List<String>> components = new HashMap<String, List<String>>();
@@ -199,6 +199,14 @@ public class SaxConfigurationContentHandler extends DefaultHandler {
private String currentCustomOptionName = ""; //$NON-NLS-1$
+ private final BugzillaRepositoryConnector connector;
+
+ public SaxConfigurationContentHandler(BugzillaRepositoryConnector connector) {
+ super();
+ this.connector = connector;
+ configuration = new RepositoryConfiguration();
+ }
+
public RepositoryConfiguration getConfiguration() {
return configuration;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
index 800860a61..3a3458ae4 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
@@ -74,11 +74,15 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
private boolean bugParseErrorOccurred;
+ private final BugzillaRepositoryConnector connector;
+
public SaxMultiBugReportContentHandler(TaskAttributeMapper mapper, TaskDataCollector collector,
- Map<String, TaskData> taskDataMap, List<BugzillaCustomField> customFields) {
+ Map<String, TaskData> taskDataMap, List<BugzillaCustomField> customFields,
+ BugzillaRepositoryConnector connector) {
this.taskDataMap = taskDataMap;
this.customFields = customFields;
this.collector = collector;
+ this.connector = connector;
}
public boolean errorOccurred() {
@@ -177,7 +181,7 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
if (attributes != null && attributes.getLength() > 0) {
String name = attributes.getValue(ATTRIBUTE_NAME);
if (name != null) {
- BugzillaFlagMapper mapper = new BugzillaFlagMapper();
+ BugzillaFlagMapper mapper = new BugzillaFlagMapper(connector);
String requestee = attributes.getValue("requestee"); //$NON-NLS-1$
mapper.setRequestee(requestee);
String setter = attributes.getValue("setter"); //$NON-NLS-1$
@@ -468,7 +472,7 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
}
private void updateCustomFields(TaskData taskData) {
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repositoryTaskData.getRepositoryUrl());
+ RepositoryConfiguration config = connector.getRepositoryConfiguration(repositoryTaskData.getRepositoryUrl());
if (config != null) {
for (BugzillaCustomField bugzillaCustomField : config.getCustomFields()) {
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index 5b36aa99b..0b0e1cb2b 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
@@ -134,7 +134,7 @@ public abstract class AbstractBugzillaTest extends TestCase {
connector = (BugzillaRepositoryConnector) abstractRepositoryClient;
try {
- BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor());
+ connector.getRepositoryConfiguration(repository, false, new NullProgressMonitor());
} catch (CoreException e) {
throw new RuntimeException(e);
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index 2ef47aa6f..517982801 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -1006,7 +1006,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
}
// test anonymous update of configuration
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null);
+ RepositoryConfiguration config = connector.getRepositoryConfiguration(repository, false, null);
assertNotNull(config);
assertTrue(config.getComponents().size() > 0);
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
index 0d1a596a4..e908055c4 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
@@ -24,12 +24,9 @@ import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeMapper;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -80,8 +77,7 @@ public class BugzillaClientTest extends TestCase {
public void testValidate() throws Exception {
TaskRepository repository = BugzillaFixture.current().repository();
AbstractWebLocation location = BugzillaFixture.current().location();
- client = new BugzillaClient(location, repository.getCharacterEncoding(), repository.getProperties(),
- BugzillaRepositoryConnector.getLanguageSetting(IBugzillaConstants.DEFAULT_LANG));
+ client = new BugzillaClient(location, repository, BugzillaFixture.current().connector());
client.validate(new NullProgressMonitor());
}
@@ -90,9 +86,7 @@ public class BugzillaClientTest extends TestCase {
AbstractWebLocation location = BugzillaFixture.current().location(PrivilegeLevel.USER,
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 12356)));
- client = BugzillaClientFactory.createClient(repository);
- client = new BugzillaClient(location, repository.getCharacterEncoding(), repository.getProperties(),
- BugzillaRepositoryConnector.getLanguageSetting(IBugzillaConstants.DEFAULT_LANG));
+ client = new BugzillaClient(location, repository, BugzillaFixture.current().connector());
try {
client.validate(new NullProgressMonitor());
fail("invalid proxy did not cause connection error");
@@ -102,11 +96,11 @@ public class BugzillaClientTest extends TestCase {
}
public void testCommentQuery() throws Exception {
- BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository);
+ BugzillaRepositoryConnector connector = BugzillaFixture.current().connector();
+ BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository, connector);
TaskData newData = new TaskData(mapper, BugzillaFixture.current().getConnectorKind(), BugzillaFixture.current()
.getRepositoryUrl(), "");
- AbstractRepositoryConnector connector = BugzillaFixture.current().connector();
connector.getTaskDataHandler().initializeTaskData(repository, newData, null, new NullProgressMonitor());
newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()");
newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct");
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java
index bcc9018ec..560bfe249 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java
@@ -19,7 +19,7 @@ import java.io.InputStreamReader;
import junit.framework.TestCase;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.core.SaxConfigurationContentHandler;
import org.eclipse.mylyn.internal.bugzilla.core.XmlCleaner;
@@ -36,12 +36,10 @@ import org.xml.sax.helpers.XMLReaderFactory;
public class BugzillaConfigurationTest extends TestCase {
public void testRepositoryConfigurationCachePersistance() throws Exception {
- if (BugzillaCorePlugin.getConfigurationCacheFile() == null) {
- File file = File.createTempFile("bugzilla", null);
- file.deleteOnExit();
- BugzillaCorePlugin.setConfigurationCacheFile(file);
- }
-
+ File file = File.createTempFile("bugzilla", null);
+ file.deleteOnExit();
+
+ BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector(file);
RepositoryConfiguration configuration1 = new RepositoryConfiguration();
configuration1.setRepositoryUrl("url1");
configuration1.addProduct("Test Product 1");
@@ -52,24 +50,42 @@ public class BugzillaConfigurationTest extends TestCase {
configuration2.addProduct("Test Product 2");
assertEquals(1, configuration2.getProducts().size());
- BugzillaCorePlugin.addRepositoryConfiguration(configuration1);
- BugzillaCorePlugin.addRepositoryConfiguration(configuration2);
- BugzillaCorePlugin.writeRepositoryConfigFile();
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- BugzillaCorePlugin.removeConfiguration(configuration1);
- BugzillaCorePlugin.removeConfiguration(configuration2);
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- BugzillaCorePlugin.setCacheFileRead(false);
- BugzillaCorePlugin.readRepositoryConfigurationFile();
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- RepositoryConfiguration testLoadedConfig = BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl());
+ connector.addRepositoryConfiguration(configuration1);
+ connector.addRepositoryConfiguration(configuration2);
+ connector.writeRepositoryConfigFile();
+ assertNotNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ assertNotNull(connector.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
+
+ connector.removeConfiguration(configuration1);
+ connector.removeConfiguration(configuration2);
+ assertNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ assertNull(connector.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
+
+ connector = new BugzillaRepositoryConnector(file);
+ connector.readRepositoryConfigurationFile();
+ assertNotNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ assertNotNull(connector.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
+ RepositoryConfiguration testLoadedConfig = connector.getRepositoryConfiguration(configuration1.getRepositoryUrl());
assertEquals(1, testLoadedConfig.getProducts().size());
assertEquals(configuration1.getProducts().get(0), testLoadedConfig.getProducts().get(0));
}
+ public void testNullCacheFile() {
+ BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector();
+ connector.readRepositoryConfigurationFile();
+ RepositoryConfiguration configuration1 = new RepositoryConfiguration();
+ configuration1.setRepositoryUrl("url1");
+ configuration1.addProduct("Test Product 1");
+ assertNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+
+ connector.addRepositoryConfiguration(configuration1);
+ assertNotNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+
+ connector = new BugzillaRepositoryConnector();
+ connector.readRepositoryConfigurationFile();
+ assertNull(connector.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ }
+
// FIXME re-enable?
// @SuppressWarnings("deprecation")
// public void testHtmlCleaner() throws IOException, BugzillaException, GeneralSecurityException {
@@ -104,7 +120,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
- SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler();
+ SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(
+ new BugzillaRepositoryConnector());
final XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(contentHandler);
reader.setErrorHandler(new ErrorHandler() {
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
index 49b94bb5c..27d5973e9 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
@@ -153,8 +153,7 @@ public class BugzillaFixture extends TestFixture {
BugzillaClientManager bugzillaClientManager = connector.getClientManager();
BugzillaClient client = bugzillaClientManager.getClient(taskRepository, null);
- BugzillaCorePlugin.setConnector(connector);
- BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, true, new NullProgressMonitor());
+ connector.getRepositoryConfiguration(taskRepository, true, new NullProgressMonitor());
return client;
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
index 0249717c3..567b6560c 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
@@ -23,11 +23,13 @@ import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.ui.tasklist.BugzillaRepositorySettingsPage;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tests.util.TestUtil;
import org.eclipse.mylyn.tests.util.TestUtil.Credentials;
import org.eclipse.ui.PlatformUI;
@@ -63,7 +65,9 @@ public class BugzillaRepositorySettingsPageTest extends TestCase {
AuthenticationCredentials webCredentials = new AuthenticationCredentials(htAuthUser, htAuthPass);
taskRepository.setCredentials(AuthenticationType.HTTP, webCredentials, false);
taskRepository.setCharacterEncoding(encoding);
- return BugzillaClientFactory.createClient(taskRepository);
+
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(repository.getConnectorKind());
+ return BugzillaClientFactory.createClient(taskRepository, connector);
}
public void testValidationInvalidPassword() throws Exception {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
index 4c5248a69..a4c8d376b 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
@@ -14,8 +14,6 @@ package org.eclipse.mylyn.internal.bugzilla.ui;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
@@ -88,11 +86,6 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
super.start(context);
getPreferenceStore().setDefault(IBugzillaConstants.MAX_RESULTS, 100);
- IPath repConfigCacheFile = getProductConfigurationCachePath();
- if (repConfigCacheFile != null) {
- BugzillaCorePlugin.setConfigurationCacheFile(repConfigCacheFile.toFile());
- }
-
BugzillaRepositoryConnector bugzillaConnector = (BugzillaRepositoryConnector) TasksUi.getRepositoryManager()
.getRepositoryConnector(BugzillaCorePlugin.CONNECTOR_KIND);
@@ -103,15 +96,6 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
BugzillaUiExtensionReader.initStartupExtensions();
}
- /**
- * Returns the path to the file cacheing the product configuration.
- */
- private static IPath getProductConfigurationCachePath() {
- IPath stateLocation = Platform.getStateLocation(BugzillaCorePlugin.getDefault().getBundle());
- IPath configFile = stateLocation.append("repositoryConfigurations"); //$NON-NLS-1$
- return configFile;
- }
-
public int getMaxResults() {
return getPreferenceStore().getInt(IBugzillaConstants.MAX_RESULTS);
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index 8432f00e5..61368eb8d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -27,6 +27,7 @@ import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryResponse;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
@@ -290,8 +291,10 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
if (taskAttribute.getId().equals(BugzillaAttribute.PRODUCT.getKey())) {
RepositoryConfiguration repositoryConfiguration = null;
try {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(
- getModel().getTaskRepository(), false, new NullProgressMonitor());
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getModel().getTaskRepository()
+ .getConnectorKind());
+ repositoryConfiguration = connector.getRepositoryConfiguration(getModel().getTaskRepository(),
+ false, new NullProgressMonitor());
} catch (CoreException e) {
StatusHandler.log(new RepositoryStatus(getTaskRepository(), IStatus.ERROR,
BugzillaUiPlugin.ID_PLUGIN, 0, "Failed to obtain repository configuration", e)); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
index 70811c5cb..897d27b5d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
@@ -40,7 +40,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
@@ -1061,7 +1061,8 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
// TODO: update status, resolution, severity etc if possible...
if (getTaskRepository() != null) {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(getTaskRepository().getUrl());
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
+ repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
updateAttributesFromConfiguration(null);
if (product.getItemCount() == 0) {
Display.getDefault().asyncExec(new Runnable() {
@@ -1873,8 +1874,9 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
try {
monitor.beginTask(Messages.BugzillaSearchPage_Updating_search_options_,
IProgressMonitor.UNKNOWN);
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(getTaskRepository(),
- force, monitor);
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
+ repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository(), force,
+ monitor);
} catch (final Exception e) {
throw new InvocationTargetException(e);
} finally {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
index 5a266029e..248556d0a 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
@@ -27,12 +27,14 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaLanguageSettings;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaStatus;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -113,7 +115,8 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
}
if (null != repository) {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(repository.getConnectorKind());
+ repositoryConfiguration = connector.getRepositoryConfiguration(repository.getRepositoryUrl());
platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
os = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_OS);
}
@@ -148,8 +151,9 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
monitor.beginTask(
Messages.BugzillaRepositorySettingsPage_Retrieving_repository_configuration,
IProgressMonitor.UNKNOWN);
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository,
- false, monitor);
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(repository.getConnectorKind());
+ repositoryConfiguration = connector.getRepositoryConfiguration(repository, false,
+ monitor);
if (repositoryConfiguration != null) {
platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
os = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_OS);
@@ -200,7 +204,7 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
new Label(parent, SWT.NONE).setText(Messages.BugzillaRepositorySettingsPage_Language_);
languageSettingCombo = new Combo(parent, SWT.DROP_DOWN);
- for (BugzillaLanguageSettings bugzillaLanguageSettings : BugzillaCorePlugin.getDefault().getLanguageSettings()) {
+ for (BugzillaLanguageSettings bugzillaLanguageSettings : BugzillaRepositoryConnector.getLanguageSettings()) {
languageSettingCombo.add(bugzillaLanguageSettings.getLanguageName());
}
if (repository != null) {
@@ -334,7 +338,8 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
IProgressMonitor.UNKNOWN);
BugzillaClient client = null;
- client = BugzillaClientFactory.createClient(repository);
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(repository.getConnectorKind());
+ client = BugzillaClientFactory.createClient(repository, connector);
client.validate(monitor);
} finally {
monitor.done();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java
index dab720840..755394231 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java
@@ -15,12 +15,13 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaFlag;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaFlagMapper;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.wizards.TaskAttachmentPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -61,7 +62,9 @@ public class BugzillaTaskAttachmentPage extends TaskAttachmentPage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
- RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(getModel().getTaskRepository()
+ BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getModel().getTaskRepository()
+ .getConnectorKind());
+ RepositoryConfiguration configuration = connector.getRepositoryConfiguration(getModel().getTaskRepository()
.getRepositoryUrl());
if (configuration != null) {
List<BugzillaFlag> flags = configuration.getFlags();
@@ -83,7 +86,7 @@ public class BugzillaTaskAttachmentPage extends TaskAttachmentPage {
if (flagComposite == null) {
flagComposite = createFlagSection(pageComposite);
}
- BugzillaFlagMapper mapper = new BugzillaFlagMapper();
+ BugzillaFlagMapper mapper = new BugzillaFlagMapper(connector);
mapper.setRequestee(""); //$NON-NLS-1$
mapper.setSetter(""); //$NON-NLS-1$
mapper.setState(" "); //$NON-NLS-1$

Back to the top