|
Lines 11-16
Link Here
|
| 11 |
import java.net.MalformedURLException; |
11 |
import java.net.MalformedURLException; |
| 12 |
import java.net.Proxy; |
12 |
import java.net.Proxy; |
| 13 |
import java.net.URL; |
13 |
import java.net.URL; |
|
|
14 |
import java.util.Date; |
| 14 |
import java.util.HashMap; |
15 |
import java.util.HashMap; |
| 15 |
import java.util.LinkedHashMap; |
16 |
import java.util.LinkedHashMap; |
| 16 |
import java.util.Map; |
17 |
import java.util.Map; |
|
Lines 20-25
Link Here
|
| 20 |
import org.eclipse.core.runtime.Platform; |
21 |
import org.eclipse.core.runtime.Platform; |
| 21 |
import org.eclipse.core.runtime.PlatformObject; |
22 |
import org.eclipse.core.runtime.PlatformObject; |
| 22 |
import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants; |
23 |
import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants; |
|
|
24 |
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil; |
| 23 |
import org.eclipse.mylyn.monitor.core.StatusHandler; |
25 |
import org.eclipse.mylyn.monitor.core.StatusHandler; |
| 24 |
import org.eclipse.mylyn.web.core.WebClientUtil; |
26 |
import org.eclipse.mylyn.web.core.WebClientUtil; |
| 25 |
import org.eclipse.mylyn.web.core.WebCredentials; |
27 |
import org.eclipse.mylyn.web.core.WebCredentials; |
|
Lines 36-42
Link Here
|
| 36 |
* <li>The solution we have come up with thus far is not to interpret the date as a DATE object but rather simply use |
38 |
* <li>The solution we have come up with thus far is not to interpret the date as a DATE object but rather simply use |
| 37 |
* the date string given to us by the repository itself.</li> |
39 |
* the date string given to us by the repository itself.</li> |
| 38 |
* </ul> |
40 |
* </ul> |
| 39 |
* |
41 |
* |
| 40 |
* @author Mik Kersten |
42 |
* @author Mik Kersten |
| 41 |
* @author Rob Elves |
43 |
* @author Rob Elves |
| 42 |
* @author Eugene Kuleshov |
44 |
* @author Eugene Kuleshov |
|
Lines 139-148
Link Here
|
| 139 |
private Map<String, String> transientProperties = new HashMap<String, String>(); |
141 |
private Map<String, String> transientProperties = new HashMap<String, String>(); |
| 140 |
|
142 |
|
| 141 |
/* |
143 |
/* |
| 142 |
* TODO: should be externalized and added to extension point, see bug 183606 |
144 |
* TODO: should be externalized and added to extension point, see bug 183606 |
| 143 |
*/ |
145 |
*/ |
| 144 |
private boolean isBugRepository = false; |
146 |
private boolean isBugRepository = false; |
| 145 |
|
147 |
|
|
|
148 |
public static final String LAST_CONFIG_REFRESH = "config.lastupdate"; |
| 149 |
|
| 150 |
private static final long LONG_AGO = 1000L * 3600L * 48L; // 48 hrs ago |
| 151 |
|
| 146 |
/** |
152 |
/** |
| 147 |
* for testing purposes |
153 |
* for testing purposes |
| 148 |
*/ |
154 |
*/ |
|
Lines 194-200
Link Here
|
| 194 |
|
200 |
|
| 195 |
/** |
201 |
/** |
| 196 |
* <b>Note: </b> This method will be deprecated in 2.3. |
202 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 197 |
* |
203 |
* |
| 198 |
* @see #getCredentials(Type) |
204 |
* @see #getCredentials(Type) |
| 199 |
*/ |
205 |
*/ |
| 200 |
public boolean hasCredentials() { |
206 |
public boolean hasCredentials() { |
|
Lines 221-227
Link Here
|
| 221 |
|
227 |
|
| 222 |
/** |
228 |
/** |
| 223 |
* <b>Note: </b> This method will be deprecated in 2.3. |
229 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 224 |
* |
230 |
* |
| 225 |
* @see #getCredentials(Type) |
231 |
* @see #getCredentials(Type) |
| 226 |
*/ |
232 |
*/ |
| 227 |
public String getProxyUsername() { |
233 |
public String getProxyUsername() { |
|
Lines 230-236
Link Here
|
| 230 |
|
236 |
|
| 231 |
/** |
237 |
/** |
| 232 |
* <b>Note: </b> This method will be deprecated in 2.3. |
238 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 233 |
* |
239 |
* |
| 234 |
* @see #getCredentials(Type) |
240 |
* @see #getCredentials(Type) |
| 235 |
*/ |
241 |
*/ |
| 236 |
public String getProxyPassword() { |
242 |
public String getProxyPassword() { |
|
Lines 239-245
Link Here
|
| 239 |
|
245 |
|
| 240 |
/** |
246 |
/** |
| 241 |
* <b>Note: </b> This method will be deprecated in 2.3. |
247 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 242 |
* |
248 |
* |
| 243 |
* @see #getCredentials(Type) |
249 |
* @see #getCredentials(Type) |
| 244 |
*/ |
250 |
*/ |
| 245 |
public String getHttpUser() { |
251 |
public String getHttpUser() { |
|
Lines 248-254
Link Here
|
| 248 |
|
254 |
|
| 249 |
/** |
255 |
/** |
| 250 |
* <b>Note: </b> This method will be deprecated in 2.3. |
256 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 251 |
* |
257 |
* |
| 252 |
* @see #getCredentials(Type) |
258 |
* @see #getCredentials(Type) |
| 253 |
*/ |
259 |
*/ |
| 254 |
public String getHttpPassword() { |
260 |
public String getHttpPassword() { |
|
Lines 257-263
Link Here
|
| 257 |
|
263 |
|
| 258 |
/** |
264 |
/** |
| 259 |
* <b>Note: </b> This method will be deprecated in 2.3. |
265 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 260 |
* |
266 |
* |
| 261 |
* @see #setCredentials(Type, WebCredentials, boolean) |
267 |
* @see #setCredentials(Type, WebCredentials, boolean) |
| 262 |
*/ |
268 |
*/ |
| 263 |
public void setAuthenticationCredentials(String username, String password) { |
269 |
public void setAuthenticationCredentials(String username, String password) { |
|
Lines 266-272
Link Here
|
| 266 |
|
272 |
|
| 267 |
/** |
273 |
/** |
| 268 |
* <b>Note: </b> This method will be deprecated in 2.3. |
274 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 269 |
* |
275 |
* |
| 270 |
* @see #setCredentials(Type, WebCredentials, boolean) |
276 |
* @see #setCredentials(Type, WebCredentials, boolean) |
| 271 |
*/ |
277 |
*/ |
| 272 |
public void setProxyAuthenticationCredentials(String username, String password) { |
278 |
public void setProxyAuthenticationCredentials(String username, String password) { |
|
Lines 275-281
Link Here
|
| 275 |
|
281 |
|
| 276 |
/** |
282 |
/** |
| 277 |
* <b>Note: </b> This method will be deprecated in 2.3. |
283 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 278 |
* |
284 |
* |
| 279 |
* @see #setCredentials(Type, WebCredentials, boolean) |
285 |
* @see #setCredentials(Type, WebCredentials, boolean) |
| 280 |
*/ |
286 |
*/ |
| 281 |
public void setHttpAuthenticationCredentials(String username, String password) { |
287 |
public void setHttpAuthenticationCredentials(String username, String password) { |
|
Lines 300-306
Link Here
|
| 300 |
public void flushAuthenticationCredentials() { |
306 |
public void flushAuthenticationCredentials() { |
| 301 |
synchronized (LOCK) { |
307 |
synchronized (LOCK) { |
| 302 |
isCachedUserName = false; |
308 |
isCachedUserName = false; |
| 303 |
|
309 |
|
| 304 |
transientProperties.clear(); |
310 |
transientProperties.clear(); |
| 305 |
|
311 |
|
| 306 |
// API30: legacy support for versions prior to 2.2 that did not set the enable flag, remove for 3.0 |
312 |
// API30: legacy support for versions prior to 2.2 that did not set the enable flag, remove for 3.0 |
|
Lines 533-539
Link Here
|
| 533 |
|
539 |
|
| 534 |
/** |
540 |
/** |
| 535 |
* <b>Note: </b> This method will be deprecated in 2.3. |
541 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 536 |
* |
542 |
* |
| 537 |
* @see #setCredentials(Type, WebCredentials, boolean) |
543 |
* @see #setCredentials(Type, WebCredentials, boolean) |
| 538 |
*/ |
544 |
*/ |
| 539 |
public void setAnonymous(boolean b) { |
545 |
public void setAnonymous(boolean b) { |
|
Lines 542-548
Link Here
|
| 542 |
|
548 |
|
| 543 |
/** |
549 |
/** |
| 544 |
* <b>Note: </b> This method will be deprecated in 2.3. |
550 |
* <b>Note: </b> This method will be deprecated in 2.3. |
| 545 |
* |
551 |
* |
| 546 |
* @see #getCredentials(Type) |
552 |
* @see #getCredentials(Type) |
| 547 |
*/ |
553 |
*/ |
| 548 |
public boolean isAnonymous() { |
554 |
public boolean isAnonymous() { |
|
Lines 571-577
Link Here
|
| 571 |
public boolean getSavePassword(Type authType) { |
577 |
public boolean getSavePassword(Type authType) { |
| 572 |
String value = getProperty(getKeyPrefix(authType) + SAVE_PASSWORD); |
578 |
String value = getProperty(getKeyPrefix(authType) + SAVE_PASSWORD); |
| 573 |
return value != null && "true".equals(value); |
579 |
return value != null && "true".equals(value); |
| 574 |
} |
580 |
} |
| 575 |
|
581 |
|
| 576 |
private static String getKeyPrefix(Type type) { |
582 |
private static String getKeyPrefix(Type type) { |
| 577 |
switch (type) { |
583 |
switch (type) { |
|
Lines 587-593
Link Here
|
| 587 |
|
593 |
|
| 588 |
/** |
594 |
/** |
| 589 |
* Returns the credentials for an authentication type. |
595 |
* Returns the credentials for an authentication type. |
| 590 |
* |
596 |
* |
| 591 |
* @param authType |
597 |
* @param authType |
| 592 |
* the type of authentication |
598 |
* the type of authentication |
| 593 |
* @return null, if no credentials are set for <code>authType</code> |
599 |
* @return null, if no credentials are set for <code>authType</code> |
|
Lines 628-634
Link Here
|
| 628 |
|
634 |
|
| 629 |
/** |
635 |
/** |
| 630 |
* Sets the credentials for <code>authType</code>. |
636 |
* Sets the credentials for <code>authType</code>. |
| 631 |
* |
637 |
* |
| 632 |
* @param authType |
638 |
* @param authType |
| 633 |
* the type of authentication |
639 |
* the type of authentication |
| 634 |
* @param credentials |
640 |
* @param credentials |
|
Lines 688-694
Link Here
|
| 688 |
private String getUserName(WebCredentials.Type authType) { |
694 |
private String getUserName(WebCredentials.Type authType) { |
| 689 |
WebCredentials credentials = getCredentials(authType); |
695 |
WebCredentials credentials = getCredentials(authType); |
| 690 |
return (credentials != null) ? credentials.getUserName() : null; |
696 |
return (credentials != null) ? credentials.getUserName() : null; |
| 691 |
} |
697 |
} |
|
|
698 |
|
| 692 |
|
699 |
|
| 693 |
/** |
700 |
/** |
| 694 |
* Legacy support for < 2.2. Remove in 2.3. |
701 |
* Legacy support for < 2.2. Remove in 2.3. |
|
Lines 698-701
Link Here
|
| 698 |
return (credentials != null) ? credentials.getPassword() : null; |
705 |
return (credentials != null) ? credentials.getPassword() : null; |
| 699 |
} |
706 |
} |
| 700 |
|
707 |
|
|
|
708 |
|
| 709 |
/** |
| 710 |
* Get the last <em>successful</em> refresh date as initialized {@link Date} object.<br /> |
| 711 |
* Internal representation is {@link String} determined by {@link TaskActivityUtil}.<br /> |
| 712 |
* See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=207660">bug |
| 713 |
* 207660: do not update repository configuration on every startup</a> |
| 714 |
* @return {@link Date} set to last config update OR LONG_AGO if not found |
| 715 |
* |
| 716 |
* @since 2.2 |
| 717 |
*/ |
| 718 |
final public Date getConfigurationDate() { |
| 719 |
String value = this.getProperty(LAST_CONFIG_REFRESH); |
| 720 |
Date stamp = null; |
| 721 |
if(null != value) { |
| 722 |
stamp = TaskActivityUtil.stringToDate(value); |
| 723 |
} else { |
| 724 |
stamp = new Date((new Date()).getTime() - LONG_AGO); |
| 725 |
} |
| 726 |
return stamp; |
| 727 |
} |
| 728 |
|
| 729 |
/** |
| 730 |
* Utility method, set the Configuration Timestamp to now AND return it. Use to set |
| 731 |
* date when <em>successful</em> update occurred. |
| 732 |
* |
| 733 |
* @since 2.2 |
| 734 |
*/ |
| 735 |
final public Date updateConfigurationDate() { |
| 736 |
Date now = new Date(); |
| 737 |
this.setConfigurationDate(now); |
| 738 |
return now; |
| 739 |
} |
| 740 |
|
| 741 |
/** |
| 742 |
* set the Configuration Timestamp to the {@link Date} indicated after a succesful update. |
| 743 |
* |
| 744 |
* The last <em>successful</em> configuration update day is persisted as {@link String} determined in {@link TaskActivityUtil}.<br /> |
| 745 |
* See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=207660">bug |
| 746 |
* 207660: do not update repository configuration on every startup</a> |
| 747 |
* @param {@link Date} setting the day |
| 748 |
* |
| 749 |
* @since 2.2 |
| 750 |
*/ |
| 751 |
final public void setConfigurationDate(final Date timeStamp) { |
| 752 |
this.setProperty(LAST_CONFIG_REFRESH, TaskActivityUtil.dateToString(timeStamp)); |
| 753 |
// should persist here, but that can only be done by the TaskRepositoryManager |
| 754 |
// However this is also included when persisting ordinary sync time |
| 755 |
} |
| 701 |
} |
756 |
} |