[160677] Remove duplicate info from publish.xml
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModulePublishInfo.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModulePublishInfo.java
index c47d79b..8324ffa 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModulePublishInfo.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModulePublishInfo.java
@@ -27,7 +27,6 @@
private static final String NAME = "name";
private static final String MODULE_TYPE_ID = "module-type-id";
private static final String MODULE_TYPE_VERSION = "module-type-version";
- private static final String PATH = "path";
private static final String STAMP = "stamp";
private static final String FILE = "file";
private static final String FOLDER = "folder";
@@ -93,7 +92,7 @@
*/
protected void load(IMemento memento) {
Trace.trace(Trace.FINEST, "Loading module publish info for: " + memento);
-
+
try {
moduleId = memento.getString(MODULE_ID);
name = memento.getString(NAME);
@@ -101,18 +100,18 @@
String mv = memento.getString(MODULE_TYPE_VERSION);
if (mt != null && mt.length() > 0)
moduleType = new ModuleType(mt, mv);
-
- resources = loadResource(memento);
+
+ resources = loadResource(memento, new Path(""));
} catch (Exception e) {
Trace.trace(Trace.WARNING, "Could not load module publish info information: " + e.getMessage());
}
}
- protected IModuleResource[] loadResource(IMemento memento) {
+ protected IModuleResource[] loadResource(IMemento memento, IPath path) {
if (memento == null)
return new IModuleResource[0];
- List list = new ArrayList(5);
+ List list = new ArrayList(10);
// load files
IMemento[] children = memento.getChildren(FILE);
@@ -120,7 +119,6 @@
int size = children.length;
for (int i = 0; i < size; i++) {
String name2 = children[i].getString(NAME);
- IPath path = new Path(children[i].getString(PATH));
long stamp = Long.parseLong(children[i].getString(STAMP));
ModuleFile file = new ModuleFile(name2, path, stamp);
list.add(file);
@@ -133,9 +131,8 @@
int size = children.length;
for (int i = 0; i < size; i++) {
String name2 = children[i].getString(NAME);
- IPath path = new Path(children[i].getString(PATH));
ModuleFolder folder = new ModuleFolder(null, name2, path);
- folder.setMembers(loadResource(children[i]));
+ folder.setMembers(loadResource(children[i], path.append(name2)));
list.add(folder);
}
}
@@ -174,13 +171,11 @@
IModuleFile file = (IModuleFile) resources2[i];
IMemento child = memento.createChild(FILE);
child.putString(NAME, file.getName());
- child.putString(PATH, file.getModuleRelativePath().toPortableString());
child.putString(STAMP, "" + file.getModificationStamp());
} else {
IModuleFolder folder = (IModuleFolder) resources2[i];
IMemento child = memento.createChild(FOLDER);
child.putString(NAME, folder.getName());
- child.putString(PATH, folder.getModuleRelativePath().toPortableString());
IModuleResource[] resources3 = folder.members();
saveResource(child, resources3);
}
@@ -193,6 +188,8 @@
protected void startCaching() {
useCache = true;
currentResources = null;
+ delta = null;
+ hasDelta = false;
}
/**
@@ -201,6 +198,9 @@
* @param module
*/
private void fillCache(IModule[] module) {
+ if (!useCache)
+ return;
+
if (currentResources != null)
return;
@@ -227,6 +227,7 @@
useCache = false;
currentResources = null;
delta = null;
+ hasDelta = false;
}
protected IModuleResource[] getModuleResources(IModule[] module) {
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java
index f3c3107..f1d313b 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java
@@ -32,6 +32,8 @@
* were published and when) for a single server.
*/
public class ServerPublishInfo {
+ private static final String VERSION = "version";
+
protected IPath path;
// map of module ids to ModulePublishInfo
@@ -69,7 +71,7 @@
private String getKey(String moduleId) {
return moduleId;
}
-
+
private IModule[] getModule(String moduleId) {
if (moduleId == null || moduleId.length() == 0)
return new IModule[0];
@@ -220,13 +222,17 @@
String filename = path.toOSString();
if (!(new File(filename).exists()))
return;
-
+
Trace.trace(Trace.FINEST, "Loading publish info from " + filename);
-
+
try {
IMemento memento2 = XMLMemento.loadMemento(filename);
+ Float f = memento2.getFloat(VERSION);
+ if (f != null && f.floatValue() >= 3)
+ return;
+
IMemento[] children = memento2.getChildren("module");
-
+
int size = children.length;
for (int i = 0; i < size; i++) {
ModulePublishInfo mpi = new ModulePublishInfo(children[i]);
@@ -243,10 +249,11 @@
public void save() {
String filename = path.toOSString();
Trace.trace(Trace.FINEST, "Saving publish info to " + filename);
-
+
try {
XMLMemento memento = XMLMemento.createWriteRoot("server");
-
+ memento.putString(VERSION, "2.0");
+
Iterator iterator = modulePublishInfo.keySet().iterator();
while (iterator.hasNext()) {
String controlRef = (String) iterator.next();