Author: snjeza
Date: 2011-11-22 18:13:41 -0500 (Tue, 22 Nov 2011)
New Revision: 36544
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
Log:
JBIDE-9850 feeds should be cached so it doesnt show blank when opening up the second time
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2011-11-22
21:08:43 UTC (rev 36543)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2011-11-22
23:13:41 UTC (rev 36544)
@@ -197,12 +197,13 @@
* destination stream will be closed by this method whether it succeeds
* to download or not.
*/
- public IStatus download(String name,String url, OutputStream destination,
IProgressMonitor monitor) {
+ public IStatus download(String name, String url, OutputStream destination,
IProgressMonitor monitor) {
+ IStatus status = null;
try {
IConnectContext context = getConnectionContext(url, false);
for (int i = 0; i < LOGIN_RETRIES; i++) {
try {
- IStatus status = performDownload(name,url, destination, context, monitor);
+ status = performDownload(name,url, destination, context, monitor);
if (status.isOK()) {
return status;
} else {
@@ -231,6 +232,9 @@
}
}
//reached maximum number of retries without success
+ if (status != null) {
+ return status;
+ }
return new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID,
Messages.ECFExamplesTransport_IO_error, null);
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-22
21:08:43 UTC (rev 36543)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-22
23:13:41 UTC (rev 36544)
@@ -38,10 +38,12 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
@@ -504,8 +506,24 @@
if (monitor.isCanceled()) {
return null;
}
- file = File.createTempFile(prefix, suffix);
- file.deleteOnExit();
+ long urlModified = -1;
+ file = getFile(url);
+ try {
+ urlModified = ECFExamplesTransport.getInstance().getLastModified(url);
+ } catch (CoreException e) {
+ if (file.exists()) {
+ return file;
+ }
+ }
+ if (file.exists()) {
+ long modified = file.lastModified();
+ if (urlModified == modified) {
+ return file;
+ }
+ }
+ //file = File.createTempFile(prefix, suffix);
+ //file.deleteOnExit();
+ file.getParentFile().mkdirs();
if (monitor.isCanceled()) {
return null;
}
@@ -519,18 +537,27 @@
if (!result.isOK()) {
ProjectExamplesActivator.getDefault().getLog().log(result);
return null;
+ } else {
+ if (file.exists()) {
+ file.setLastModified(urlModified);
+ }
}
} catch (FileNotFoundException e) {
ProjectExamplesActivator.log(e);
return null;
- } catch (IOException e) {
- ProjectExamplesActivator.log(e);
- return null;
- }
+ }
}
return file;
}
+ private static File getFile(java.net.URL url2) {
+ IPath location = ProjectExamplesActivator.getDefault().getStateLocation();
+ File root = location.toFile();
+ String urlFile = url2.getFile();
+ File file = new File(root, urlFile);
+ return file;
+ }
+
private static ECFExamplesTransport getTransport() {
return ECFExamplesTransport.getInstance();
}
Show replies by date