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 82280 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]
New patch in response to comment 24
clipboard.txt (text/plain), 15.07 KB, created by
maarten meijer
on 2007-11-06 18:38:32 EST
(
hide
)
Description:
New patch in response to comment 24
Filename:
MIME Type:
Creator:
maarten meijer
Created:
2007-11-06 18:38:32 EST
Size:
15.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.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 6 Nov 2007 23:35:54 -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; >@@ -20,6 +21,7 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.PlatformObject; > import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants; >+import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil; > import org.eclipse.mylyn.monitor.core.StatusHandler; > import org.eclipse.mylyn.web.core.WebClientUtil; > import org.eclipse.mylyn.web.core.WebCredentials; >@@ -36,7 +38,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 >@@ -139,10 +141,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 > */ >@@ -194,7 +200,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public boolean hasCredentials() { >@@ -221,7 +227,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public String getProxyUsername() { >@@ -230,7 +236,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public String getProxyPassword() { >@@ -239,7 +245,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public String getHttpUser() { >@@ -248,7 +254,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public String getHttpPassword() { >@@ -257,7 +263,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #setCredentials(Type, WebCredentials, boolean) > */ > public void setAuthenticationCredentials(String username, String password) { >@@ -266,7 +272,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #setCredentials(Type, WebCredentials, boolean) > */ > public void setProxyAuthenticationCredentials(String username, String password) { >@@ -275,7 +281,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #setCredentials(Type, WebCredentials, boolean) > */ > public void setHttpAuthenticationCredentials(String username, String password) { >@@ -300,7 +306,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 >@@ -533,7 +539,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #setCredentials(Type, WebCredentials, boolean) > */ > public void setAnonymous(boolean b) { >@@ -542,7 +548,7 @@ > > /** > * <b>Note: </b> This method will be deprecated in 2.3. >- * >+ * > * @see #getCredentials(Type) > */ > public boolean isAnonymous() { >@@ -571,7 +577,7 @@ > public boolean getSavePassword(Type authType) { > String value = getProperty(getKeyPrefix(authType) + SAVE_PASSWORD); > return value != null && "true".equals(value); >- } >+ } > > private static String getKeyPrefix(Type type) { > switch (type) { >@@ -587,7 +593,7 @@ > > /** > * Returns the credentials for an authentication type. >- * >+ * > * @param authType > * the type of authentication > * @return null, if no credentials are set for <code>authType</code> >@@ -628,7 +634,7 @@ > > /** > * Sets the credentials for <code>authType</code>. >- * >+ * > * @param authType > * the type of authentication > * @param credentials >@@ -688,7 +694,8 @@ > private String getUserName(WebCredentials.Type authType) { > WebCredentials credentials = getCredentials(authType); > return (credentials != null) ? credentials.getUserName() : null; >- } >+ } >+ > > /** > * Legacy support for < 2.2. Remove in 2.3. >@@ -698,4 +705,57 @@ > return (credentials != null) ? credentials.getPassword() : null; > } > >+ >+ /** >+ * 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 = TaskActivityUtil.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 updateConfigurationTimestamp() { >+ 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, TaskActivityUtil.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 TaskActivityUtil.moreThanAgo(getConfigurationTimestamp(), TaskActivityUtil.DAY); >+ } >+ >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java,v >retrieving revision 1.4 >diff -u -r1.4 TaskActivityUtil.java >--- src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java 13 Sep 2007 03:49:29 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java 6 Nov 2007 23:35:54 -0000 >@@ -8,7 +8,11 @@ > > package org.eclipse.mylyn.internal.tasks.core; > >+import java.text.ParseException; >+import java.text.SimpleDateFormat; > import java.util.Calendar; >+import java.util.Date; >+import java.util.Locale; > > /** > * @author Rob Elves >@@ -159,4 +163,34 @@ > return (time.compareTo(start) >= 0 && time.compareTo(end) <= 0); > } > >+ // copied from Jira >+ public static final String TIMESTAMP_DATE_FORMAT = "dd MMM yyyy HH:mm:ss:S z"; >+ public static final long HOUR = 1000L * 3600L; >+ public static final long DAY = HOUR * 24L; >+ public static final long WEEK = DAY * 7L; >+ public static String dateToString(Date date) { >+ if (date == null) { >+ return ""; >+ } else { >+ return new SimpleDateFormat(TIMESTAMP_DATE_FORMAT, Locale.US).format(date); >+ } >+ } >+ >+ public static Date stringToDate(String dateString) { >+ if (dateString == null || dateString.length() == 0) { >+ return null; >+ } >+ try { >+ return new SimpleDateFormat(TIMESTAMP_DATE_FORMAT, Locale.US).parse(dateString); >+ } catch (ParseException e) { >+ return null; >+ } >+ } >+ >+ public static boolean moreThanAgo(Date stamp, long interval) { >+ if(null == stamp) >+ return true; >+ return new Date().getTime() - stamp.getTime() > interval; >+ } >+ > } >#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.27 >diff -u -r1.27 ScheduledTaskListSynchJob.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 2 Nov 2007 17:04:28 -0000 1.27 >+++ src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java 6 Nov 2007 23:35:55 -0000 >@@ -8,7 +8,6 @@ > > package org.eclipse.mylyn.internal.tasks.ui; > >-import java.util.Calendar; > import java.util.List; > import java.util.Set; > >@@ -43,15 +42,16 @@ > > private TaskList taskList = null; > >+ /** >+ * for testing ONLY! >+ */ > private static long count = 0; > >- private static Calendar lastRepositoryRefresh; >- > private TaskListManager taskListManager; > > private List<TaskRepository> repositories = null; > >- private boolean fullSynchronization; >+ private boolean fullSynchronization = true; > > public ScheduledTaskListSynchJob(long schedule, TaskListManager taskListManager) { > super(JOB_NAME); >@@ -112,9 +112,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 >@@ -122,9 +120,10 @@ > 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) { >@@ -136,7 +135,8 @@ > //updateJob.setSystem(true); > updateJob.setPriority(Job.LONG); > updateJob.schedule(); >- lastRepositoryRefresh = null; >+ // only persist if actually changed >+ repository.updateConfigurationTimestamp(); > } > > synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false, >@@ -146,9 +146,6 @@ > } > } finally { > count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; >- if (lastRepositoryRefresh == null) { >- lastRepositoryRefresh = Calendar.getInstance(); >- } > if (monitor != null) { > monitor.done(); > } >@@ -165,13 +162,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.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 6 Nov 2007 23:35:56 -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,19 @@ > 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.getConfigurationTimestamp(); >+ assertTrue("unset stap returns long ago", stamp.before(new Date())); >+ >+ stamp = taskRepository.updateConfigurationTimestamp(); >+ 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 6 Nov 2007 23:35:57 -0000 >@@ -141,8 +141,9 @@ > RepositoryConfiguration config = client.getRepositoryConfiguration(); > if (config != null) { > addRepositoryConfiguration(config); >+ // remember just updated, bug 207498 >+ repository.updateConfigurationTimestamp(); > } >- > } > 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