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 82011 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]
Resolved nits, using Date()
clipboard.txt (text/plain), 11.73 KB, created by
maarten meijer
on 2007-11-02 18:19:37 EDT
(
hide
)
Description:
Resolved nits, using Date()
Filename:
MIME Type:
Creator:
maarten meijer
Created:
2007-11-02 18:19:37 EDT
Size:
11.73 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.26 >diff -u -r1.26 ScheduledTaskListSynchJob.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 6 Sep 2007 03:19:29 -0000 1.26 >+++ src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 2 Nov 2007 22:18:25 -0000 >@@ -8,7 +8,6 @@ > > package org.eclipse.mylyn.internal.tasks.ui; > >-import java.util.Calendar; > import java.util.List; > import java.util.Set; > >@@ -41,10 +40,11 @@ > > private TaskList taskList = null; > >+ /** >+ * for testing ONLY! >+ */ > private static long count = 0; > >- private static Calendar lastRepositoryRefresh; >- > private TaskListManager taskListManager; > > private List<TaskRepository> repositories = null; >@@ -94,9 +94,7 @@ > 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) { >+ if (repository.configUpdateNeeded() && queries != null && queries.size() > 0) { > Job updateJob = new Job("Updating attributes for " + repository.getUrl()) { > > @Override >@@ -104,13 +102,13 @@ > try { > if (connector.isRepositoryConfigurationStale(repository)) { > 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 > } > return Status.OK_STATUS; > } >@@ -118,18 +116,15 @@ > //updateJob.setSystem(true); > updateJob.setPriority(Job.LONG); > updateJob.schedule(); >- lastRepositoryRefresh = null; >+ // only persist if actually changed >+ repository.touchConfigurationTimestamp(); > } >- > synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false); > > monitor.worked(1); > } > } finally { > count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; >- if (lastRepositoryRefresh == null) { >- lastRepositoryRefresh = Calendar.getInstance(); >- } > if (monitor != null) { > monitor.done(); > } >@@ -146,13 +141,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) { >#P org.eclipse.mylyn.tasks.core >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.42 >diff -u -r1.42 TaskRepository.java >--- src/org/eclipse/mylyn/tasks/core/TaskRepository.java 26 Oct 2007 01:34:55 -0000 1.42 >+++ src/org/eclipse/mylyn/tasks/core/TaskRepository.java 2 Nov 2007 22:18:26 -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; >@@ -34,7 +35,7 @@ > * <li>The solution we have come up with thus far is not to interpret the date as a DATE object but rather simply use > * the date string given to us by the repository itself.</li> > * </ul> >- * >+ * > * @author Mik Kersten > * @author Rob Elves > * @author Eugene Kuleshov >@@ -144,10 +145,14 @@ > 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; > >+ public static final String LAST_CONFIG_REFRESH = "config.lastupdate"; >+ >+ private static final long LONG_AGO = 1000L * 3600L * 24L; // 24 hrs ago >+ > /** > * for testing purposes > */ >@@ -569,4 +574,56 @@ > return transientProperties.get(authType + PASSWORD); > } > >+ >+ /** >+ * Get the last refresh date as initialized {@link Date} object.<br /> >+ * Internal representation is {@link String} determined by {@link TimestampUtils}.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=207660">bug >+ * 207660: do not update repository configuration on every startup</a> >+ * @return {@link Date} set to last config update OR LONG_AGO if not found >+ */ >+ final public Date getConfigurationTimestamp() { >+ String value = this.getProperty(LAST_CONFIG_REFRESH); >+ Date stamp = null; >+ if(null != value) { >+ stamp = TimestampUtils.stringToDate(value); >+ } else { >+ stamp = new Date((new Date()).getTime() - LONG_AGO); >+ } >+ return stamp; >+ } >+ >+ /** >+ * Utility method, set the Configuration Timestamp to now AND return it. >+ */ >+ final public Date touchConfigurationTimestamp() { >+ Date now = new Date(); >+ this.setConfigurationTimestamp(now); >+ return now; >+ } >+ >+ /** >+ * set the Configuration Timestamp to the {@link Date} indicated. >+ * >+ * The last config update day is persisted as {@link String} determined in {@link TimestampUtils}.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=207660">bug >+ * 207660: do not update repository configuration on every startup</a> >+ * @param {@link {@link Date}} setting the day >+ */ >+ final public void setConfigurationTimestamp(final Date timeStamp) { >+ this.setProperty(LAST_CONFIG_REFRESH, TimestampUtils.dateToString(timeStamp)); >+ // should persist here, but that can only be done by the TaskRepositoryManager >+ // However this is also included when persisting ordinary sync time >+ } >+ >+ >+ /** >+ * This determines the configuration update policy of this repository.<br /> >+ * This says yes when it is more than 24 hours ago. Future update policies may be set on a per repository basis. >+ * @return true when configuration update needed. >+ */ >+ public boolean configUpdateNeeded() { >+ return TimestampUtils.moreThanAgo(getConfigurationTimestamp(), TimestampUtils.DAY); >+ } >+ > } >#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.6 >diff -u -r1.6 TaskRepositoryTest.java >--- src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java 26 Oct 2007 01:34:54 -0000 1.6 >+++ src/org/eclipse/mylyn/tasks/tests/TaskRepositoryTest.java 2 Nov 2007 22:18:27 -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; >@@ -38,14 +39,14 @@ > taskRepository.setCredentials(TaskRepository.AUTH_DEFAULT, "user", "pwd"); > assertEquals("user", taskRepository.getUserName()); > assertEquals("pwd", taskRepository.getPassword()); >- >+ > assertEquals(null, taskRepository.getHttpUser()); > assertEquals(null, taskRepository.getHttpPassword()); > } >- >+ > public void testHttpPassword() throws Exception { > password(TaskRepository.AUTH_HTTP); >- >+ > TaskRepository taskRepository = new TaskRepository("kind", "url"); > taskRepository.setCredentials(TaskRepository.AUTH_HTTP, "user", "pwd"); > assertEquals("user", taskRepository.getHttpUser()); >@@ -66,23 +67,23 @@ > TaskRepository taskRepository = new TaskRepository("kind", url.toString()); > assertNull(taskRepository.getPassword(authType)); > assertTrue(taskRepository.getSavePassword(authType)); >- >+ > taskRepository.setCredentials(authType, "user", "pwd"); > assertEquals("user", taskRepository.getUserName(authType)); > assertEquals("pwd", taskRepository.getPassword(authType)); >- >+ > Map<?, ?> map = Platform.getAuthorizationInfo(url, "", "Basic"); > assertNotNull(map); > assertTrue(map.containsValue("user")); > assertTrue(map.containsValue("pwd")); >- >+ > // test not saving password > taskRepository.setSavePassword(authType, false); > assertFalse(taskRepository.getSavePassword(authType)); > taskRepository.setCredentials(authType, "user1", "pwd1"); > assertEquals("user1", taskRepository.getUserName(authType)); > assertEquals("pwd1", taskRepository.getPassword(authType)); >- >+ > // make sure not old passwords are in the key ring > map = Platform.getAuthorizationInfo(url, "", "Basic"); > assertNotNull(map); >@@ -90,7 +91,7 @@ > assertFalse(map.containsValue("pwd1")); > assertFalse(map.containsValue("user")); > assertFalse(map.containsValue("pwd")); >- >+ > taskRepository.setSavePassword(authType, true); > assertTrue(taskRepository.getSavePassword(authType)); > taskRepository.setCredentials(authType, "user2", "pwd2"); >@@ -98,4 +99,19 @@ > assertEquals("pwd2", taskRepository.getPassword(authType)); > } > >+ public void testConfigUpdateStoring() throws Exception { >+ URL url = new URL("http://url"); >+ TaskRepository taskRepository = new TaskRepository("kind", url.toString()); >+ >+ Date stamp = taskRepository.getConfigurationTimestamp(); >+ assertTrue("unset stap returns long ago", stamp.before(new Date())); >+ >+ stamp = taskRepository.touchConfigurationTimestamp(); >+ assertEquals("Time stamp touched", stamp.getTime(), taskRepository.getConfigurationTimestamp().getTime()); >+ >+ stamp.setTime(stamp.getTime() - 1000000L); >+ taskRepository.setConfigurationTimestamp(stamp); >+ assertEquals("Time stamp set", stamp.getTime(), taskRepository.getConfigurationTimestamp().getTime()); >+ } >+ > } >#P org.eclipse.mylyn.bugzilla.core >Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java,v >retrieving revision 1.20 >diff -u -r1.20 BugzillaCorePlugin.java >--- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java 17 Oct 2007 19:44:29 -0000 1.20 >+++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java 2 Nov 2007 22:18:29 -0000 >@@ -141,8 +141,9 @@ > RepositoryConfiguration config = client.getRepositoryConfiguration(); > if (config != null) { > addRepositoryConfiguration(config); >+ // remember just updated, bug 207498 >+ repository.touchConfigurationTimestamp(); > } >- > } > return repositoryConfigurations.get(repository.getUrl()); > } catch (IOException e) { >@@ -245,7 +246,7 @@ > > /** > * Convenience method for logging statuses to the plugin log >- * >+ * > * @param status > * the status to log > */ >@@ -255,7 +256,7 @@ > > /** > * Convenience method for logging exceptions to the plugin log >- * >+ * > * @param e > * the exception to log > */ >@@ -394,7 +395,7 @@ > > private static void readBugzillaLanguageSettingsFile() { > setDefaultBugzillaLanguageSettings(); >-// >+// > // if (!languageSettingsFile.exists()) { > // setDefaultBugzillaLanguageSettings(); > // return;
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