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 81642 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]
Patch to store last config update day to repository property store
clipboard.txt (text/plain), 5.03 KB, created by
maarten meijer
on 2007-10-30 16:31:39 EDT
(
hide
)
Description:
Patch to store last config update day to repository property store
Filename:
MIME Type:
Creator:
maarten meijer
Created:
2007-10-30 16:31:39 EDT
Size:
5.03 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 30 Oct 2007 20:30:10 -0000 >@@ -37,10 +37,15 @@ > > private static final String JOB_NAME = "Synchronizing repository tasks"; > >+ private static final String LAST_CONFIG_REFRESH = "config.lastupdate"; >+ > private long scheduleDelay = 1000 * 60 * 20;// 20 minutes default > > private TaskList taskList = null; > >+ /** >+ * for testing ONLY! >+ */ > private static long count = 0; > > private static Calendar lastRepositoryRefresh; >@@ -83,6 +88,12 @@ > continue; > } > >+ >+ if(null == lastRepositoryRefresh) { >+ getLastRefreshFromStore(repository); >+ } >+ >+ > final AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() > .getRepositoryConnector(repository.getConnectorKind()); > if (connector == null) { >@@ -104,7 +115,7 @@ > 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( > TasksUiPlugin.getDefault().getRepositoriesFilePath()); >@@ -120,6 +131,11 @@ > updateJob.schedule(); > lastRepositoryRefresh = null; > } >+ // only persist if actually changed >+ if (null == lastRepositoryRefresh) { >+ lastRepositoryRefresh = Calendar.getInstance(); >+ saveLastRefreshToStore(repository, lastRepositoryRefresh); >+ } > > synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false); > >@@ -127,9 +143,6 @@ > } > } finally { > count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; >- if (lastRepositoryRefresh == null) { >- lastRepositoryRefresh = Calendar.getInstance(); >- } > if (monitor != null) { > monitor.done(); > } >@@ -137,6 +150,58 @@ > return Status.OK_STATUS; > } > >+ >+ /** >+ * @param repository to save the last config update in the Repository persistent properties. >+ * To be called when doing manual update :-) >+ */ >+ public static void touch(TaskRepository repository) { >+ saveLastRefreshToStore(repository, Calendar.getInstance()); >+ } >+ >+ /** >+ * Save the last refresh date as <code>long</code> YYYYMMDD<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 repository >+ */ >+ private static void saveLastRefreshToStore(TaskRepository repository, Calendar lastRefresh) { >+ // ignore >+ long last = 10000L * lastRefresh.get(Calendar.YEAR) + 100L * lastRefresh.get(Calendar.MONTH) >+ + lastRefresh.get(Calendar.DAY_OF_MONTH); >+ // TasksUiPlugin.getDefault().getPreferenceStore().setValue(LAST_REFRESH, last); >+ repository.setProperty(LAST_CONFIG_REFRESH, Long.toString(last)); >+ } >+ >+ /** >+ * Get the last refresh date as <code>long</code> YYYYMMDD between invocations.<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 repository >+ */ >+ private static void getLastRefreshFromStore(TaskRepository repository) { >+ // Only DAY_OF_MONTH is used for the test, but lets save MONTH and YEAR as well >+ // long lastRefresh = TasksUiPlugin.getDefault().getPreferenceStore().getLong(LAST_REFRESH); >+ String value = repository.getProperty(LAST_CONFIG_REFRESH); >+ if(null != value) { >+ try { >+ long lastRefresh = Long.parseLong(value); >+ int year = (int) (lastRefresh / 10000L); >+ int month = (int) ((lastRefresh - 100L * year) / 100L); >+ int date = (int) (lastRefresh - 100L * month - 10000L * year);; >+ // get new calendar... >+ if( year > 0) { >+ lastRepositoryRefresh = Calendar.getInstance(); >+ lastRepositoryRefresh.set(year, month, date); >+ } >+ } catch (NumberFormatException e) { >+ // TODO Auto-generated catch block >+ ; // ignore e.printStackTrace(); >+ } >+ } >+ >+ } >+ > public void setSchedule(long schedule) { > this.scheduleDelay = schedule; > } >@@ -146,13 +211,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