Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 82408 Details for
Bug 207498
stop automatic configuration retrieval if already done
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch
clipboard.txt (text/plain), 11.88 KB, created by
Robert Elves
on 2007-11-07 22:56:57 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Robert Elves
Created:
2007-11-07 22:56:57 EST
Size:
11.88 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.bugzilla.core >Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java,v >retrieving revision 1.84 >diff -u -r1.84 BugzillaRepositoryConnector.java >--- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 11 Oct 2007 21:01:35 -0000 1.84 >+++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 8 Nov 2007 03:50:23 -0000 >@@ -465,24 +465,26 @@ > } > > public boolean isRepositoryConfigurationStale(TaskRepository repository) throws CoreException { >- >- boolean result = true; >- try { >- BugzillaClient client = getClientManager().getClient(repository); >- if (client != null) { >- String timestamp = client.getConfigurationTimestamp(); >- if (timestamp != null) { >- String oldTimestamp = repository.getProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP); >- if (oldTimestamp != null) { >- result = !timestamp.equals(oldTimestamp); >+ if (super.isRepositoryConfigurationStale(repository)) { >+ boolean result = true; >+ try { >+ BugzillaClient client = getClientManager().getClient(repository); >+ if (client != null) { >+ String timestamp = client.getConfigurationTimestamp(); >+ if (timestamp != null) { >+ String oldTimestamp = repository.getProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP); >+ if (oldTimestamp != null) { >+ result = !timestamp.equals(oldTimestamp); >+ } >+ repository.setProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP, timestamp); > } >- repository.setProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP, timestamp); > } >+ } catch (MalformedURLException e) { >+ StatusHandler.fail(e, "Error retrieving configuration timestamp for " + repository.getUrl(), false); > } >- } catch (MalformedURLException e) { >- StatusHandler.fail(e, "Error retrieving configuration timestamp for " + repository.getUrl(), false); >+ return result; > } >- return result; >+ return false; > } > > public void updateAttributeOptions(TaskRepository taskRepository, RepositoryTaskData existingReport) >#P org.eclipse.mylyn.tasks.core >Index: src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java,v >retrieving revision 1.59 >diff -u -r1.59 AbstractRepositoryConnector.java >--- src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java 1 Nov 2007 22:38:38 -0000 1.59 >+++ src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java 8 Nov 2007 03:50:24 -0000 >@@ -33,6 +33,10 @@ > > protected Set<RepositoryTemplate> templates = new LinkedHashSet<RepositoryTemplate>(); > >+ private static final long HOUR = 1000L * 3600L; >+ >+ private static final long DAY = HOUR * 24L; >+ > protected TaskList taskList; > > private boolean userManaged = true; >@@ -313,11 +317,23 @@ > public abstract void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException; > > /** >+ * Default implementation returns true every 24hrs >+ * > * @return true to indicate that the repository configuration is stale and requires update > * @throws CoreException > */ > public boolean isRepositoryConfigurationStale(TaskRepository repository) throws CoreException { >- return true; >+ boolean isStale = true; >+ Date configDate = repository.getConfigurationDate(); >+ if (configDate != null) { >+ isStale = (new Date().getTime() - configDate.getTime()) > DAY; >+ } >+ >+ if (isStale) { >+ repository.setConfigurationDate(new Date()); >+ } >+ >+ return isStale; > } > > public void setUserManaged(boolean userManaged) { >Index: src/org/eclipse/mylyn/tasks/core/TaskRepository.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java,v >retrieving revision 1.43 >diff -u -r1.43 TaskRepository.java >--- src/org/eclipse/mylyn/tasks/core/TaskRepository.java 5 Nov 2007 18:59:57 -0000 1.43 >+++ src/org/eclipse/mylyn/tasks/core/TaskRepository.java 8 Nov 2007 03:50:24 -0000 >@@ -11,6 +11,7 @@ > import java.net.MalformedURLException; > import java.net.Proxy; > import java.net.URL; >+import java.util.Date; > import java.util.HashMap; > import java.util.LinkedHashMap; > import java.util.Map; >@@ -89,6 +90,8 @@ > > private static final URL DEFAULT_URL; > >+ private static final String PROPERTY_CONFIG_TIMESTAMP = "org.eclipse.mylyn.tasklist.repositories.configuration.timestamp"; >+ > public static final String PROXY_USEDEFAULT = "org.eclipse.mylyn.tasklist.repositories.proxy.usedefault"; > > public static final String PROXY_HOSTNAME = "org.eclipse.mylyn.tasklist.repositories.proxy.hostname"; >@@ -139,7 +142,7 @@ > private Map<String, String> transientProperties = new HashMap<String, String>(); > > /* >- * TODO: should be externalized and added to extension point, see bug 183606 >+ * TODO: should be externalized and added to extension point, see bug 183606 > */ > private boolean isBugRepository = false; > >@@ -300,7 +303,7 @@ > public void flushAuthenticationCredentials() { > synchronized (LOCK) { > isCachedUserName = false; >- >+ > transientProperties.clear(); > > // API30: legacy support for versions prior to 2.2 that did not set the enable flag, remove for 3.0 >@@ -698,4 +701,33 @@ > return (credentials != null) ? credentials.getPassword() : null; > } > >+ /** >+ * Get the last refresh date as initialized {@link Date} object, null if not set<br /> >+ * >+ * @return {@link Date} configuration date, null if not set >+ */ >+ final public Date getConfigurationDate() { >+ Date configDate = null; >+ String value = this.getProperty(PROPERTY_CONFIG_TIMESTAMP); >+ try { >+ configDate = new Date(Long.valueOf(value).longValue()); >+ >+ } catch (Exception e) { >+ >+ } >+ return configDate; >+ } >+ >+ /** >+ * Set the Configuration date to the {@link Date} indicated. >+ * >+ * @param configuration >+ * date {@link {@link Date}} >+ */ >+ final public void setConfigurationDate(final Date date) { >+ this.setProperty(PROPERTY_CONFIG_TIMESTAMP, String.valueOf(date.getTime())); >+ // should persist here, but that can only be done by the TaskRepositoryManager >+ // However this is also included when persisting ordinary sync time >+ } >+ > } >#P org.eclipse.mylyn.tasks.tests >Index: src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskRepositoryTest.java >--- src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java 5 Nov 2007 18:59:57 -0000 1.7 >+++ src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java 8 Nov 2007 03:50:25 -0000 >@@ -9,6 +9,7 @@ > package org.eclipse.mylyn.tasks.tests; > > import java.net.URL; >+import java.util.Date; > import java.util.Map; > > import junit.framework.TestCase; >@@ -117,4 +118,16 @@ > assertEquals("pwd2", credentials.getPassword()); > } > >+ public void testConfigUpdateStoring() throws Exception { >+ URL url = new URL("http://url"); >+ TaskRepository taskRepository = new TaskRepository("kind", url.toString()); >+ Date stamp = taskRepository.getConfigurationDate(); >+ assertNull("unset configuration date returns null", stamp); >+ stamp = new Date(); >+ stamp.setTime(stamp.getTime() - 35000L); >+ >+ taskRepository.setConfigurationDate(stamp); >+ assertEquals("Time stamp set", stamp.getTime(), taskRepository.getConfigurationDate().getTime()); >+ } >+ > } >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java,v >retrieving revision 1.28 >diff -u -r1.28 ScheduledTaskListSynchJob.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 6 Nov 2007 04:23:44 -0000 1.28 >+++ src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 8 Nov 2007 03:50:26 -0000 >@@ -8,7 +8,6 @@ > > package org.eclipse.mylyn.internal.tasks.ui; > >-import java.util.Calendar; > import java.util.List; > import java.util.Set; > >@@ -45,8 +44,6 @@ > > private static long count = 0; > >- private static Calendar lastRepositoryRefresh; >- > private TaskListManager taskListManager; > > private List<TaskRepository> repositories = null; >@@ -110,33 +107,33 @@ > > RepositorySynchronizationManager synchronizationManager = TasksUiPlugin.getSynchronizationManager(); > Set<AbstractRepositoryQuery> queries = taskList.getRepositoryQueries(repository.getUrl()); >- >- // Occasionally request update of repository configuration attributes >- if ((lastRepositoryRefresh == null || lastRepositoryRefresh.get(Calendar.DAY_OF_MONTH) != Calendar.getInstance() >- .get(Calendar.DAY_OF_MONTH)) >- && queries != null && queries.size() > 0) { >- Job updateJob = new Job("Updating attributes for " + repository.getUrl()) { >- >- @Override >- protected IStatus run(IProgressMonitor monitor) { >- try { >- if (connector.isRepositoryConfigurationStale(repository)) { >+ try { >+ // Occasionally request update of repository configuration attributes >+ if (queries != null && queries.size() > 0 && connector.isRepositoryConfigurationStale(repository)) { >+ Job updateJob = new Job("Updating attributes for " + repository.getUrl()) { >+ >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ try { > connector.updateAttributes(repository, new SubProgressMonitor(monitor, 1)); >- // HACK: A configuration update occurred. Save on behalf of connector which >+ // HACK: A configuration update occurred. Save on behalf of connector which > // currently can't access the repository manager itself > TasksUiPlugin.getRepositoryManager().saveRepositories( >+ // ignore, since we might not be connected > TasksUiPlugin.getDefault().getRepositoriesFilePath()); >+ >+ } catch (Exception e) { >+ // ignore, since we might not be connected > } >- } catch (Exception e) { >- // ignore, since we might not be connected >+ return Status.OK_STATUS; > } >- return Status.OK_STATUS; >- } >- }; >- //updateJob.setSystem(true); >- updateJob.setPriority(Job.LONG); >- updateJob.schedule(); >- lastRepositoryRefresh = null; >+ }; >+ //updateJob.setSystem(true); >+ updateJob.setPriority(Job.LONG); >+ updateJob.schedule(); >+ } >+ } catch (Exception e) { >+ // ignore, since we might not be connected > } > > synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false, >@@ -146,9 +143,6 @@ > } > } finally { > count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; >- if (lastRepositoryRefresh == null) { >- lastRepositoryRefresh = Calendar.getInstance(); >- } > if (monitor != null) { > monitor.done(); > } >@@ -165,13 +159,15 @@ > } > > /** >- * for testing purposes >+ * for testing purposes ONLY! > */ > public static long getCount() { > return count; > } > >- /** for testing */ >+ /** >+ * for testing purposes ONLY! >+ */ > public static void resetCount() { > try { > if (TasksUiPlugin.getSynchronizationScheduler().getRefreshJob() != null) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207498
:
81642
|
81643
|
81647
|
81890
|
82010
|
82011
|
82012
|
82280
|
82281
| 82408 |
82409
|
82502
|
82503