diff --git a/rse/plugins/org.eclipse.rse.importexport/plugin.xml b/rse/plugins/org.eclipse.rse.importexport/plugin.xml index 9411762abb8..05b0d9e92f5 100644 --- a/rse/plugins/org.eclipse.rse.importexport/plugin.xml +++ b/rse/plugins/org.eclipse.rse.importexport/plugin.xml @@ -29,7 +29,7 @@ David McKnight (IBM) - [272708] [import/export] fix various bugs with t diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExportWizardPage1.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExportWizardPage1.java index 201673509b9..f665b41eb04 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExportWizardPage1.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExportWizardPage1.java @@ -12,6 +12,7 @@ * David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -102,6 +103,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste private static final int MY_SIZING_TEXT_FIELD_WIDTH = 250; // dialog store id constants private static final String STORE_DESTINATION_NAMES_ID = "RemoteExportWizard.STORE_DESTINATION_NAMES_ID"; //$NON-NLS-1$ + private static final String STORE_REVIEW_SYNCHRONIZE_ID = "RemoteExportWizard.STORE_REVIEW_SYNCHRONIZE_ID"; //$NON-NLS-1$ private static final String STORE_OVERWRITE_EXISTING_FILES_ID = "RemoteExportWizard.STORE_OVERWRITE_EXISTING_FILES_ID"; //$NON-NLS-1$ private static final String STORE_CREATE_STRUCTURE_ID = "RemoteExportWizard.STORE_CREATE_STRUCTURE_ID"; //$NON-NLS-1$ private static final String STORE_CREATE_DESCRIPTION_FILE_ID = "RemoteExportWizard.STORE_CREATE_DESCRIPTION_FILE_ID"; //$NON-NLS-1$ @@ -289,7 +291,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste overwriteExistingFilesCheckbox.setEnabled(!isReview); createDirectoryStructureButton.setEnabled(!isReview); createSelectionOnlyButton.setEnabled(!isReview); - } + } } /** @@ -404,7 +406,10 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste if (resourcesToExport.size() > 0) { // export data RemoteFileExportData data = new RemoteFileExportData(); + + data.setContainerPath( null); data.setElements(resourcesToExport); + data.setReviewSynchronize(reviewSynchronizeCheckbox.getSelection()); data.setCreateDirectoryStructure(createDirectoryStructureButton.getSelection()); data.setCreateSelectionOnly(createSelectionOnlyButton.getSelection()); data.setOverWriteExistingFiles(overwriteExistingFilesCheckbox.getSelection()); @@ -576,6 +581,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste directoryNames = addToHistory(directoryNames, getDestinationValue()); settings.put(STORE_DESTINATION_NAMES_ID, directoryNames); // options + settings.put(STORE_REVIEW_SYNCHRONIZE_ID, reviewSynchronizeCheckbox.getSelection()); settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection()); settings.put(STORE_CREATE_STRUCTURE_ID, createDirectoryStructureButton.getSelection()); settings.put(STORE_CREATE_DESCRIPTION_FILE_ID, isSaveSettings()); @@ -625,6 +631,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste // options // no export data to initialize from, so prefill from previous export if (!isInitializingFromExportData) { + reviewSynchronizeCheckbox.setSelection(settings.getBoolean(STORE_REVIEW_SYNCHRONIZE_ID)); overwriteExistingFilesCheckbox.setSelection(settings.getBoolean(STORE_OVERWRITE_EXISTING_FILES_ID)); boolean createDirectories = settings.getBoolean(STORE_CREATE_STRUCTURE_ID); createDirectoryStructureButton.setSelection(createDirectories); @@ -644,6 +651,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste // initialize from export data else { RemoteFileExportData data = parentWizard.getExportData(); + reviewSynchronizeCheckbox.setSelection(data.isReviewSynchronize()); overwriteExistingFilesCheckbox.setSelection(data.isOverWriteExistingFiles()); createDirectoryStructureButton.setSelection(data.isCreateDirectoryStructure()); createSelectionOnlyButton.setSelection(data.isCreateSelectionOnly()); diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportData.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportData.java index 05154ec8854..520077cf0ab 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportData.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -25,11 +26,15 @@ import org.eclipse.rse.ui.SystemBasePlugin; */ public class RemoteFileExportData { private String destination; + + private IPath containerPath; + private boolean reviewSynchronize; private boolean overWriteExistingFiles; private boolean createDirectoryStructure; private boolean createSelectionOnly; private boolean saveSettings; private String descriptionFilePath; + // export elements private List elements; @@ -37,6 +42,7 @@ public class RemoteFileExportData { * Constructor. */ public RemoteFileExportData() { + setContainerPath(null); setDestination(null); setOverWriteExistingFiles(false); setCreateDirectoryStructure(false); @@ -72,6 +78,14 @@ public class RemoteFileExportData { this.descriptionFilePath = descriptionFilePath; } + public void setContainerPath(IPath location){ + this.containerPath = location; + } + + public IPath getContainerPath(){ + return containerPath; + } + /** * @return Returns the destination. */ @@ -115,6 +129,15 @@ public class RemoteFileExportData { public void setOverWriteExistingFiles(boolean overWriteExistingFiles) { this.overWriteExistingFiles = overWriteExistingFiles; } + + + public boolean isReviewSynchronize(){ + return reviewSynchronize; + } + + public void setReviewSynchronize(boolean reviewSynchronize){ + this.reviewSynchronize = reviewSynchronize; + } /** * @return Returns the saveSettings. diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionReader.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionReader.java index fadf666536f..f4a0ca9f85e 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionReader.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [174945] split importexport icons from rse.ui + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -100,6 +101,7 @@ public class RemoteFileExportDescriptionReader implements IRemoteFileExportDescr private void xmlReadOptions(RemoteFileExportData exportData, Element element) throws IOException { if (element.getNodeName().equals("options")) { //$NON-NLS-1$ + exportData.setReviewSynchronize(getBooleanAttribute(element, "reviewSynchronize")); //$NON-NLS-1$ exportData.setOverWriteExistingFiles(getBooleanAttribute(element, "overWriteExistingFiles")); //$NON-NLS-1$ exportData.setCreateDirectoryStructure(getBooleanAttribute(element, "createDirectoryStructure")); //$NON-NLS-1$ exportData.setCreateSelectionOnly(getBooleanAttribute(element, "createSelectedOnly")); //$NON-NLS-1$ diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionWriter.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionWriter.java index 8ea72985e9b..860958f5bfd 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionWriter.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportDescriptionWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [174945] split importexport icons from rse.ui + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -108,6 +109,7 @@ public class RemoteFileExportDescriptionWriter implements IRemoteFileExportDescr private void xmlWriteOptions(RemoteFileExportData exportData, Document document, Element xmlFileDesc) throws DOMException { Element options = document.createElement("options"); //$NON-NLS-1$ xmlFileDesc.appendChild(options); + options.setAttribute("reviewSynchronize", "" + exportData.isReviewSynchronize()); //$NON-NLS-1$//$NON-NLS-2$ options.setAttribute("overWriteExistingFiles", "" + exportData.isOverWriteExistingFiles()); //$NON-NLS-1$ //$NON-NLS-2$ options.setAttribute("createDirectoryStructure", "" + exportData.isCreateDirectoryStructure()); //$NON-NLS-1$ //$NON-NLS-2$ options.setAttribute("createSelectedOnly", "" + exportData.isCreateSelectionOnly()); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportOperation.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportOperation.java index 2648d76b8b9..062fd99b3fd 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportOperation.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ * Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core * David McKnight (IBM) - [191479] refreshing destination directory after export * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -67,6 +68,9 @@ class RemoteFileExportOperation implements IRunnableWithProgress { private RemoteFileExportData exportData; private boolean saveSettings; private String descriptionFilePath; + + private boolean reviewSynchronize = true; + // the constants for the overwrite 3 state private static final int OVERWRITE_NOT_SET = 0; private static final int OVERWRITE_NONE = 1; @@ -86,7 +90,7 @@ class RemoteFileExportOperation implements IRunnableWithProgress { this.resourcesToExport = resources; this.path = new Path(destinationPath); this.overwriteCallback = overwriteImplementor; - this.exporter = new RemoteExporter(conn); + this.exporter = new RemoteExporter(conn); } public RemoteFileExportOperation(RemoteFileExportData data, IOverwriteQuery overwriteImplementor) { @@ -95,6 +99,7 @@ class RemoteFileExportOperation implements IRunnableWithProgress { this.saveSettings = data.isSaveSettings(); this.descriptionFilePath = data.getDescriptionFilePath(); setCreateLeadupStructure(data.isCreateDirectoryStructure()); + setReviewSynchronize(data.isReviewSynchronize()); setOverwriteFiles(data.isOverWriteExistingFiles()); } @@ -555,4 +560,14 @@ class RemoteFileExportOperation implements IRunnableWithProgress { overwriteState = OVERWRITE_ALL; } } + + /** + * Set this boolean indicating whether exported resources should automatically + * be reviewed/synchronized + * + * @param value boolean + */ + public void setReviewSynchronize(boolean value) { + reviewSynchronize = value; + } } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportData.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportData.java index ea93e4486c8..f5698fac116 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportData.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -36,6 +37,8 @@ public class RemoteFileImportData { private HashMap map; private List elements; + private boolean reviewSynchronize; + /** * Constructor. */ @@ -160,6 +163,14 @@ public class RemoteFileImportData { public void setOverWriteExistingFiles(boolean overWriteExistingFiles) { this.overWriteExistingFiles = overWriteExistingFiles; } + + public boolean isReviewSynchronize(){ + return reviewSynchronize; + } + + public void setReviewSynchronize(boolean reviewSynchronize){ + this.reviewSynchronize = reviewSynchronize; + } /** * @return Returns the saveSettings. diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportOperation.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportOperation.java index 0ca4a7be89d..fa5e56dccba 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportOperation.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -78,6 +79,8 @@ public class RemoteFileImportOperation extends WorkspaceModifyOperation { private static final int OVERWRITE_NONE = 1; private static final int OVERWRITE_ALL = 2; private int overwriteState = OVERWRITE_NOT_SET; + + private boolean reviewSynchronize = true; /** * Creates a new operation that recursively imports the entire contents of the @@ -158,6 +161,7 @@ public class RemoteFileImportOperation extends WorkspaceModifyOperation { this(data.getContainerPath(), data.getSource(), provider, overwriteImplementor); setFilesToImport(data.getElements()); setOverwriteResources(data.isOverWriteExistingFiles()); + setReviewSynchronize(data.isReviewSynchronize()); setCreateContainerStructure(data.isCreateDirectoryStructure()); this.importData = data; this.saveSettings = data.isSaveSettings(); @@ -639,4 +643,14 @@ public class RemoteFileImportOperation extends WorkspaceModifyOperation { public void setOverwriteResources(boolean value) { if (value) this.overwriteState = OVERWRITE_ALL; } + + /** + * Set this boolean indicating whether exported resources should automatically + * be reviewed/synchronized + * + * @param value boolean + */ + public void setReviewSynchronize(boolean value) { + reviewSynchronize = value; + } } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java index b2f3ea3f377..3d886012619 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java @@ -15,6 +15,7 @@ * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [219792][importexport][ftp] RSE hangs on FTP import * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -255,6 +256,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen protected boolean initSourceNameSet = false; // dialog store id constants private final static String STORE_SOURCE_NAMES_ID = "RemoteImportWizardPage1.STORE_SOURCE_NAMES_ID"; //$NON-NLS-1$ + private final static String STORE_REVIEW_SYNCHRONIZE_ID = "RemoteImportWizardPage1.STORE_REVIEW_SYNCHRONIZE_ID"; //$NON-NLS-1$ private final static String STORE_OVERWRITE_EXISTING_RESOURCES_ID = "RemoteImportWizardPage1.STORE_OVERWRITE_EXISTING_RESOURCES_ID"; //$NON-NLS-1$ private final static String STORE_CREATE_CONTAINER_STRUCTURE_ID = "RemoteImportWizardPage1.STORE_CREATE_CONTAINER_STRUCTURE_ID"; //$NON-NLS-1$ private static final String STORE_CREATE_DESCRIPTION_FILE_ID = "RemoteImportWizardPage1.STORE_CREATE_DESCRIPTION_FILE_ID"; //$NON-NLS-1$ @@ -1000,6 +1002,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen boolean isInitializingFromImportData = parentWizard.getInitializeFromImportData(); if (!isInitializingFromImportData) { // radio buttons and checkboxes + reviewSynchronizeCheckbox.setSelection(settings.getBoolean(STORE_REVIEW_SYNCHRONIZE_ID)); overwriteExistingResourcesCheckbox.setSelection(settings.getBoolean(STORE_OVERWRITE_EXISTING_RESOURCES_ID)); boolean createStructure = settings.getBoolean(STORE_CREATE_CONTAINER_STRUCTURE_ID); createContainerStructureButton.setSelection(createStructure); @@ -1019,6 +1022,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen setContainerFieldValue(containerPath); } // radio buttons and checkboxes + reviewSynchronizeCheckbox.setSelection(importData.isReviewSynchronize()); overwriteExistingResourcesCheckbox.setSelection(importData.isOverWriteExistingFiles()); createContainerStructureButton.setSelection(importData.isCreateDirectoryStructure()); createOnlySelectedButton.setSelection(importData.isCreateSelectionOnly()); @@ -1067,6 +1071,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen sourceNames = addToHistory(sourceNames, getSourceDirectoryName()); settings.put(STORE_SOURCE_NAMES_ID, sourceNames); // radio buttons and checkboxes + settings.put(STORE_REVIEW_SYNCHRONIZE_ID, reviewSynchronizeCheckbox.getSelection()); settings.put(STORE_OVERWRITE_EXISTING_RESOURCES_ID, overwriteExistingResourcesCheckbox.getSelection()); settings.put(STORE_CREATE_CONTAINER_STRUCTURE_ID, createContainerStructureButton.getSelection()); settings.put(STORE_CREATE_DESCRIPTION_FILE_ID, isSaveSettings()); diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java index 31060eaa111..1b8f497b8f7 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java @@ -12,6 +12,7 @@ * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -420,4 +421,12 @@ public class UniFilePlus extends File { return this.remoteFile.getParentRemoteFileSubSystem().getInputStream(this.remoteFile.getParentPath(), this.remoteFile.getName(), this.remoteFile.isBinary(), null); } + public void synchRemoteFile() { + // get the latest version of the remote file + remoteFile.markStale(true); + try { + remoteFile = remoteFile.getParentRemoteFileSubSystem().getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor()); + } + catch (Exception e){} + } } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/ISynchronizeData.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/ISynchronizeData.java index 063cb770e93..1ec97e00a6c 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/ISynchronizeData.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/ISynchronizeData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Takuya Miyamoto and others. + * Copyright (c) 2008, 2009 Takuya Miyamoto and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Takuya Miyamoto - initial API and implementation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize; @@ -14,6 +15,7 @@ import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; /** * Store synchronize information. This class is needed per each synchronize @@ -33,15 +35,29 @@ public interface ISynchronizeData { * * @return */ - public String getDestination(); + public String getRemoteLocation(); /** - * Set destination path + * Set the remote path * - * @param destinationPath + * @param location */ - public void setDestination(String destination); + public void setRemoteLocation(String location); + /** + * Return the local path. + * + * @return + */ + public IPath getLocalLocation(); + + /** + * Set the local path + * + * @param location + */ + public void setLocalLocation(IPath location); + /** * Return the synchronize type of this operation. * diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/RSEResourceVariantComparator.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/RSEResourceVariantComparator.java index 0016daf87a9..66161185eaa 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/RSEResourceVariantComparator.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/RSEResourceVariantComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Takuya Miyamoto and others. + * Copyright (c) 2008, 2009 Takuya Miyamoto and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,23 +7,131 @@ * * Contributors: * Takuya Miyamoto - initial API and implementation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemResourceVariant; +import org.eclipse.rse.subsystems.files.core.SystemIFileProperties; import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.core.variants.ThreeWayResourceComparator; import org.eclipse.team.core.variants.ThreeWaySynchronizer; +import org.eclipse.team.internal.core.mapping.LocalResourceVariant; public class RSEResourceVariantComparator extends ThreeWayResourceComparator { + private ThreeWaySynchronizer _synchronizer; public RSEResourceVariantComparator(ThreeWaySynchronizer synchronizer){ super(synchronizer); + _synchronizer = synchronizer; } + + public boolean compare(IResource local, IResourceVariant remote) { - return super.compare(local, remote) && equalSize(local, remote); + // return super.compare(local, remote) && equalSize(local, remote); + if(local instanceof IContainer) { + if(remote.isContainer()) { + return true; + } + return false; + } + if(local instanceof IFile && remote instanceof FileSystemResourceVariant) { + FileSystemResourceVariant myE2 = (FileSystemResourceVariant)remote; + myE2.synchRemoteFile(); // make sure we've got the latest remote file + + SystemIFileProperties properties = new SystemIFileProperties(local); + + long remoteTimeStamp = myE2.lastModified(); + + if (remoteTimeStamp == 0){ + // file no longer exists + properties.setRemoteFileTimeStamp(0); + properties.setDownloadFileTimeStamp(0); + return false; + } + + long storedTimeStamp = properties.getRemoteFileTimeStamp(); + long storedLocalTimeStamp = properties.getDownloadFileTimeStamp(); + long localTimeStamp = local.getLocalTimeStamp(); + + if (storedTimeStamp == 0){ + // never been stored before + // assuming up-to-date file and now marking this timestamp + properties.setRemoteFileTimeStamp(remoteTimeStamp); + properties.setDownloadFileTimeStamp(local.getLocalTimeStamp()); + + storedTimeStamp = remoteTimeStamp; + storedLocalTimeStamp = localTimeStamp; + } + + boolean result = storedTimeStamp == remoteTimeStamp && storedLocalTimeStamp == localTimeStamp; + return result; + } + else if (local instanceof IFile && remote instanceof LocalResourceVariant){ + return true; // local resource variant is for local + } + return false; } + + + /* + public boolean compare(IResource local, IResourceVariant remote) { + // First, ensure the resources are the same gender + if ((local.getType() == IResource.FILE) == remote.isContainer()) { + return false; + } + try { + // If the file is locally modified, it cannot be in sync + if (local.getType() == IResource.FILE && _synchronizer.isLocallyModified(local)) { + // return false; + } + + // If there is no base, the local cannot match the remote + if (_synchronizer.getBaseBytes(local) == null) return false; + + // Otherwise, assume they are the same if the remote equals the base + return equals(_synchronizer.getBaseBytes(local), getBytes(remote)); + } catch (TeamException e) { + TeamPlugin.log(e); + return false; + } + } + */ + + public boolean compare(IResourceVariant e1, IResourceVariant e2) { + if(e1.isContainer()) { + if(e2.isContainer()) { + return true; + } + return false; + } + if(e1 instanceof FileSystemResourceVariant && e2 instanceof FileSystemResourceVariant) { + FileSystemResourceVariant myE1 = (FileSystemResourceVariant)e1; + FileSystemResourceVariant myE2 = (FileSystemResourceVariant)e2; + return myE1.lastModified() == myE2.lastModified(); + } + return false; + } + + private byte[] getBytes(IResourceVariant remote) { + return remote.asBytes(); + } + + private boolean equals(byte[] syncBytes, byte[] oldBytes) { + if (syncBytes == null || oldBytes == null){ + return false; + } + + if (syncBytes.length != oldBytes.length) return false; + for (int i = 0; i < oldBytes.length; i++) { + if (oldBytes[i] != syncBytes[i]) return false; + } + return true; + } + /** * Return if the size of local and remote file are the same. diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/SynchronizeData.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/SynchronizeData.java index a33302a3491..c03d7b98f69 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/SynchronizeData.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/SynchronizeData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Takuya Miyamoto and others. + * Copyright (c) 2008, 2009 Takuya Miyamoto and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Takuya Miyamoto - initial API and implementation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize; @@ -32,7 +33,8 @@ import org.eclipse.rse.ui.SystemBasePlugin; public class SynchronizeData implements ISynchronizeData { private String descriptionFilePath; - private String destination; + private String remoteLocation; + private IPath localLocation; private List elements; private int synchronizeType; private boolean saveSettings; @@ -43,7 +45,8 @@ public class SynchronizeData implements ISynchronizeData { public SynchronizeData() { setDescriptionFilePath(null); - setDestination(null); + setRemoteLocation(null); + setLocalLocation(null); setElements(null); setSynchronizeType(0); setSaveSettings(false); @@ -54,12 +57,14 @@ public class SynchronizeData implements ISynchronizeData { public SynchronizeData(RemoteFileExportData data) { setDescriptionFilePath(data.getDescriptionFilePath()); - setDestination(data.getDestination()); - setElements(data.getElements()); + setRemoteLocation(data.getDestination()); + setElements(data.getElements()); // for an export, the elements determine the source + setLocalLocation(data.getContainerPath()); setSynchronizeType(ISynchronizeOperation.SYNC_MODE_OVERRIDE_DEST); setSaveSettings(data.isSaveSettings()); setCreateDirectoryStructure(data.isCreateDirectoryStructure()); setCreateSelectionOnly(data.isCreateSelectionOnly()); + setReviewSynchronzie(data.isReviewSynchronize()); setOverWriteExistingFiles(data.isOverWriteExistingFiles()); } @@ -78,9 +83,10 @@ public class SynchronizeData implements ISynchronizeData { ArrayList localResource = new ArrayList(); RSESyncUtils.getSynchronizeResources(localRoot, remoteRoot, remoteRoot, filter, localResource); - + + setLocalLocation(data.getContainerPath()); setDescriptionFilePath(data.getDescriptionFilePath()); - setDestination(((UniFilePlus)data.getSource()).getRemoteFile().getAbsolutePathPlusConnection()); + setRemoteLocation(((UniFilePlus)data.getSource()).getRemoteFile().getAbsolutePathPlusConnection()); setElements(localResource); setSynchronizeType(ISynchronizeOperation.SYNC_MODE_OVERRIDE_SOURCE); setSaveSettings(data.isSaveSettings()); @@ -110,14 +116,23 @@ public class SynchronizeData implements ISynchronizeData { this.descriptionFilePath = descriptionFilePath; } - public String getDestination() { - return destination; + public String getRemoteLocation() { + return remoteLocation; } - public void setDestination(String destination) { - this.destination = destination; + public void setRemoteLocation(String location) { + this.remoteLocation = location; } + public IPath getLocalLocation() { + return localLocation; + } + + public void setLocalLocation(IPath location) { + this.localLocation = location; + } + + public List getElements() { return elements; } @@ -182,7 +197,7 @@ public class SynchronizeData implements ISynchronizeData { data.setOverWriteExistingFiles(isOverWriteExistingFiles()); data.setSaveSettings(isSaveSettings()); data.setDescriptionFilePath(getDescriptionFilePath()); - data.setDestination(getDestination()); + data.setDestination(getRemoteLocation()); return data; } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemOperations.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemOperations.java index 5cfd7f68622..401ecddcf72 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemOperations.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemOperations.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Andreas Voss - Bug 181141 [Examples] Team: filesystem provider example can not handle deletions * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemOperations + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem; @@ -31,6 +32,8 @@ import org.eclipse.rse.internal.importexport.files.UniFilePlus; import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemResourceVariant; import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemSubscriber; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; +import org.eclipse.rse.subsystems.files.core.SystemIFileProperties; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.variants.IResourceVariant; @@ -345,12 +348,21 @@ public class FileSystemOperations { // remoteFile.getRemoteFile().getParentRemoteFileSubSystem().download(remoteFile.getRemoteFile(), parent.getLocation().toOSString(), localFile.getCharset(), progress); // Mark as read-only to force a checkout before editing - //System.out.println(localFile.getLocation() + " : accessible = " + localFile.isAccessible()+", existing = "+localFile.exists()); + //System.out.println(localFile.getLocation() + " : accessible = " + localFile.isAccessible()+", existing = "+localFile.exists()); if(localFile.isAccessible()){ localFile.getResourceAttributes().setReadOnly(true); } + + localFile.getParent().refreshLocal(IResource.DEPTH_ONE, progress); + // update sync status synchronizer.setBaseBytes(localFile, remote.asBytes()); + + // update stored timestamp + SystemIFileProperties properties = new SystemIFileProperties(localFile); + properties.setRemoteFileTimeStamp(remoteFile.lastModified()); + properties.setDownloadFileTimeStamp(localFile.getLocalTimeStamp()); + } catch (SystemMessageException e) { e.printStackTrace(); } @@ -404,6 +416,7 @@ public class FileSystemOperations { FileSystemProvider provider = getProvider(localFile); IResourceVariant base = provider.getResourceVariant(localFile, baseBytes); + overrideIncoming = true; // DKM - test // Check whether we are overriding a remote change if (base == null && remote != null && !overrideIncoming) { // The remote is an incoming (or conflicting) addition. @@ -453,6 +466,16 @@ public class FileSystemOperations { // Update the synchronizer base bytes remote = getExportResourceVariant(localFile); synchronizer.setBaseBytes(localFile, remote.asBytes()); + + // update stored timestamp + // make sure the remote file is up-to-date + remoteFile.getRemoteFile().markStale(true); + IRemoteFile updatedRemoteFile = remoteFile.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(remoteFile.getRemoteFile().getAbsolutePath(), progress); + + SystemIFileProperties properties = new SystemIFileProperties(localFile); + properties.setRemoteFileTimeStamp(updatedRemoteFile.getLastModified()); + properties.setDownloadFileTimeStamp(localFile.getLocalTimeStamp()); + } catch (CoreException e) { throw FileSystemPlugin.wrapException(e); } catch (Exception e) { @@ -490,8 +513,15 @@ public class FileSystemOperations { toDelete.add(diskFile); } else if (folder.exists() && remote == null) { // Create the remote directory and sync up the local - diskFile.mkdir(); - synchronizer.setBaseBytes(folder, provider.getExportResourceVariant(folder).asBytes()); + diskFile.mkdirs(); + + IResourceVariant variant = provider.getExportResourceVariant(folder); + if (variant == null){ + // remote directory does not exist + } + else { + synchronizer.setBaseBytes(folder, variant.asBytes()); + } } } else if (container.getType() == IResource.PROJECT) { IProject project = (IProject) container; diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProvider.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProvider.java index f8bbf3966ec..c637af19483 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProvider.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,10 +8,13 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemProvider + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem; import java.io.File; +import java.util.HashMap; +import java.util.Map; import org.eclipse.core.resources.IFileModificationValidator; import org.eclipse.core.resources.IResource; @@ -77,9 +80,12 @@ public class FileSystemProvider extends RepositoryProvider { }; // The location of the folder on file system where the repository is stored. - private IPath rootPath; + private IPath remoteRootPath; + private IPath localRootPath; private UniFilePlus remoteRoot; + private Map _resourceMap; + // The QualifiedName that is used to persist the location across workspace // as a persistent property on a resource private static QualifiedName FILESYSTEM_REPO_LOC = new QualifiedName(RSESyncUtils.PLUGIN_ID, "disk_location"); //$NON-NLS-1$ @@ -89,8 +95,14 @@ public class FileSystemProvider extends RepositoryProvider { */ public FileSystemProvider() { super(); + _resourceMap = new HashMap(); } + public void reset() + { + _resourceMap.clear(); + } + /** * This method is invoked when the provider is mapped to a project. Although * we have access to the project at this point (using @@ -135,11 +147,11 @@ public class FileSystemProvider extends RepositoryProvider { * be stored. * @throws TeamException */ - public void setTargetLocation(String location) throws TeamException { + public void setRemoteLocation(String location) throws TeamException { // location = transformRSEtoNormal(location); // set the instance variable to the provided path - rootPath = new Path(location); + remoteRootPath = new Path(location); // ensure that the location is a folder (if it exists) File file = new File(location); @@ -155,6 +167,10 @@ public class FileSystemProvider extends RepositoryProvider { throw FileSystemPlugin.wrapException(e); } } + + public void setLocalLocation(IPath location){ + localRootPath = location; + } /** * Returns the folder in the file system to which the provider is connected. @@ -163,14 +179,14 @@ public class FileSystemProvider extends RepositoryProvider { * * @return IPath The path to the root of the repository. */ - public IPath getRoot() { - if (rootPath == null) { + public IPath getRemoteRoot() { + if (remoteRootPath == null) { try { String location = getProject().getPersistentProperty(FILESYSTEM_REPO_LOC); if (location == null) { return null; } - rootPath = new Path(location); + remoteRootPath = new Path(location); } catch (CoreException e) { // log the problem and carry on FileSystemPlugin.log(e); @@ -178,7 +194,7 @@ public class FileSystemProvider extends RepositoryProvider { } } // System.out.println(root); - return rootPath; + return remoteRootPath; } /** @@ -264,39 +280,56 @@ public class FileSystemProvider extends RepositoryProvider { * @return the file that the resource maps to. */ public File getExportFile(IResource resource) { - UniFilePlus file = null; - try { - if (resource.getProject().equals(getProject())) { - UniFilePlus root = getRemoteRootFolder(); - String relativePath = transformInDependency(root.getRemoteFile().getHost(), resource.getFullPath().toString()); - // MOB BUGBUG//IRemoteFile remoteFile = - // root.getRemoteFile().getParentRemoteFileSubSystem - // ().getRemoteFileObject(root.getRemoteFile(),relativePath, - // null); - IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(root.getRemoteFile().getAbsolutePath() + relativePath, null); - file = new UniFilePlus(remoteFile); - + UniFilePlus file = (UniFilePlus)_resourceMap.get(resource); + //if (file == null) + { + try { + if (resource.getProject().equals(getProject())) { + UniFilePlus root = getRemoteRootFolder(); + + String relativePath = transformInDependency(root.getRemoteFile().getHost(), resource.getFullPath().toString()); + + + // MOB BUGBUG//IRemoteFile remoteFile = + // root.getRemoteFile().getParentRemoteFileSubSystem + // ().getRemoteFileObject(root.getRemoteFile(),relativePath, + // null); + + String path = root.getRemoteFile().getAbsolutePath() + relativePath; + IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(path,null); + //String remotePath = root.getAbsolutePath() + root.getRemoteFile().getParentRemoteFileSubSystem().getSeparatorChar() + resource.getName(); + //IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(remotePath, null); + file = new UniFilePlus(remoteFile); + _resourceMap.put(resource, file); + + } + } catch (SystemMessageException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - } catch (SystemMessageException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } return file; } public File getImportFile(IResource resource){ - UniFilePlus file = null; - try { - if (resource.getProject().equals(getProject())) { - UniFilePlus root = getRemoteRootFolder(); - String relativePath = transformInDependency(root.getRemoteFile().getHost(), IPath.SEPARATOR + resource.getProjectRelativePath().toString()); - IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(root.getRemoteFile().getAbsolutePath() + relativePath, null); - file = new UniFilePlus(remoteFile); - + UniFilePlus file = (UniFilePlus)_resourceMap.get(resource); + //if (file == null){ + { + try { + if (resource.getProject().equals(getProject())) { + UniFilePlus root = getRemoteRootFolder(); + String relativePath = transformInDependency(root.getRemoteFile().getHost(), resource.getFullPath().toString()); + //String relativePath = transformInDependency(root.getRemoteFile().getHost(), IPath.SEPARATOR + resource.getProjectRelativePath().toString()); + + String path = root.getRemoteFile().getAbsolutePath() + relativePath; + IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(path, null); + file = new UniFilePlus(remoteFile); + _resourceMap.put(resource, file); + } + } catch (SystemMessageException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - } catch (SystemMessageException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } return file; } @@ -356,7 +389,7 @@ public class FileSystemProvider extends RepositoryProvider { */ public UniFilePlus getRemoteRootFolder() { if (remoteRoot == null) { - IPath remoteRootDir = getRoot(); + IPath remoteRootDir = getRemoteRoot(); String remoteRootDirString = transformRSEtoNormal(remoteRootDir.toString()); IHost conn = Utilities.parseForSystemConnection(remoteRootDir.toString()); String absolutePath = transformInDependency(conn, remoteRootDirString); @@ -374,6 +407,29 @@ public class FileSystemProvider extends RepositoryProvider { } else { ret = original.replace("\\", "/"); } + + + // make sure the mapping corresponds to the correct local location + if (localRootPath != null){ + String[] lsegs = localRootPath.segments(); + String[] rsegs = ret.substring(1).split("/"); + + // relative path should not start with the localRoot path + StringBuffer newPath = new StringBuffer(); + for (int i = 0; i < rsegs.length; i++){ + if (lsegs.length > i){ + if (!lsegs[i].equals(rsegs[i])){ + newPath.append("/"); + newPath.append(rsegs[i]); + } + } + else { + newPath.append("/"); + newPath.append(rsegs[i]); + } + } + ret = newPath.toString(); + } return ret; } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java index c87aed48f7d..2d53f1448a9 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemRemoteTree + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.subscriber; @@ -71,4 +72,7 @@ public class FileSystemRemoteTree extends ThreeWayRemoteTree { } return null; } + + + } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java index 07e8195517a..b4189f3e8b3 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemResourceVariant + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.subscriber; @@ -171,4 +172,15 @@ public class FileSystemResourceVariant extends CachedResourceVariant { return ioFile; } + public long lastModified(){ + return ioFile.lastModified(); + } + + public String toString(){ + return ioFile.getAbsolutePath(); + } + + public void synchRemoteFile() { + ioFile.synchRemoteFile(); + } } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java index ad5b1e17883..5f275ac7ff8 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemSubscriber + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.subscriber; @@ -23,6 +24,7 @@ import org.eclipse.core.runtime.QualifiedName; import org.eclipse.rse.internal.synchronize.RSEResourceVariantComparator; import org.eclipse.rse.internal.synchronize.RSESyncUtils; import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider; +import org.eclipse.rse.subsystems.files.core.SystemIFileProperties; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfo; @@ -30,6 +32,7 @@ import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.core.variants.ThreeWayRemoteTree; import org.eclipse.team.core.variants.ThreeWaySubscriber; import org.eclipse.team.core.variants.ThreeWaySynchronizer; +import org.eclipse.team.internal.core.mapping.LocalResourceVariant; /** * This is an example file system subscriber that overrides ThreeWaySubscriber. @@ -148,8 +151,36 @@ public class FileSystemSubscriber extends ThreeWaySubscriber { */ @Override protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException { - // Override to use a custom sync info -// FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, this.getResourceComparator()); + + FileSystemResourceVariant rv = null; + + if (remote instanceof FileSystemResourceVariant){ + rv = (FileSystemResourceVariant)remote; + rv.synchRemoteFile(); + } + + if (base == null && local.exists()){ + base = remote; + } + if (base != null) { + boolean exists = rv.getFile().remoteFile.exists(); + if (!exists){ + base = null; + } + else { + + if (rv != null){ + long remoteModificationTime = rv.lastModified(); + SystemIFileProperties properties = new SystemIFileProperties(local); + long storedModificationTime = properties.getRemoteFileTimeStamp(); + + if (remoteModificationTime > storedModificationTime){ + base = new LocalResourceVariant(local); + } + } + } + } + FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, new RSEResourceVariantComparator(getSynchronizer())); info.init(); return info; diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java index f23fdde8a6a..dd2d74afc37 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemSyncInfo + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.subscriber; @@ -42,7 +43,13 @@ public class FileSystemSyncInfo extends SyncInfo { return IN_SYNC; } } - return super.calculateKind(); + int kind = super.calculateKind(); + if ((kind & SyncInfo.PSEUDO_CONFLICT) != 0){ + kind = IN_SYNC; + } + + + return kind; } /* diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/GetOperation.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/GetOperation.java index 3a5583837ee..ec68a6edf8c 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/GetOperation.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/GetOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,9 +8,11 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / GetOperation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.ui; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -51,6 +53,9 @@ public class GetOperation extends FileSystemOperation { if (!isOverwriteOutgoing() && hasIncomingChanges(traversals)) { throw new TeamException("Could not get all changes due to conflicts."); } + + provider.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/PutOperation.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/PutOperation.java index b2a3b932b70..80c4c3032c7 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/PutOperation.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/PutOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,15 +8,21 @@ * Contributors: * IBM Corporation - initial API and implementation * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / PutOperation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.filesystem.ui; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.events.ISystemResourceChangeEvents; +import org.eclipse.rse.core.events.SystemResourceChangeEvent; +import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider; import org.eclipse.rse.internal.synchronize.filesystem.Policy; import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemSubscriber; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.team.core.diff.IDiff; import org.eclipse.team.core.diff.IDiffVisitor; import org.eclipse.team.core.diff.IThreeWayDiff; @@ -54,6 +60,18 @@ public class PutOperation extends FileSystemOperation { @Override protected void execute(FileSystemProvider provider, ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException { provider.getOperations().checkin(traversals, isOverwriteIncoming(), monitor); + + // refresh RSE + IRemoteFile rootFolder = provider.getRemoteRootFolder().getRemoteFile(); + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + + try { + rootFolder = rootFolder.getParentRemoteFileSubSystem().getRemoteFileObject(rootFolder.getAbsolutePath(), monitor); + rootFolder.markStale(true); + sr.fireEvent(new SystemResourceChangeEvent(rootFolder, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, rootFolder.getAbsolutePath())); + } + catch (Exception e){} + // if (!isOverwriteIncoming() && hasOutgoingChanges(traversals)) { // throw new // TeamException("Could not put all changes due to conflicts."); diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/provisional/Synchronizer.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/provisional/Synchronizer.java index 84afa326b7c..8a6824c36be 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/provisional/Synchronizer.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/provisional/Synchronizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Takuya Miyamoto and others. + * Copyright (c) 2008, 2009 Takuya Miyamoto and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,16 +7,22 @@ * * Contributors: * Takuya Miyamoto - initial API and implementation + * David McKnight (IBM) - [272708] [import/export] fix various bugs with the synchronization support *******************************************************************************/ package org.eclipse.rse.internal.synchronize.provisional; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.rse.internal.importexport.files.UniFilePlus; import org.eclipse.rse.internal.synchronize.ISynchronizeData; import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider; @@ -44,6 +50,12 @@ public class Synchronizer implements ISynchronizer { for (IResource resource : elements) { projectSet.add(resource.getProject()); + if (!resource.exists()){ + IContainer parent = resource.getParent(); + if (!parent.exists()){ + createEmptyFolders(parent); + } + } } // get resources to synchronize in the type of Array. @@ -66,10 +78,15 @@ public class Synchronizer implements ISynchronizer { IProject project = projects[i]; connector.connect(project); FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project); - String destination = data.getDestination(); - provider.setTargetLocation(data.getDestination()); + provider.reset(); + String remoteLocation = data.getRemoteLocation(); + IPath localLocation = data.getLocalLocation(); + provider.setRemoteLocation(remoteLocation); + provider.setLocalLocation(localLocation); this.remoteRoot = provider.getRemoteRootFolder(); } + + // run actual synchronize operation. // TODO currently, not support last synchronization date. @@ -82,4 +99,35 @@ public class Synchronizer implements ISynchronizer { return true; } + + private void createEmptyFolders(IContainer container){ + List emptyParent = new ArrayList(); + boolean go = true; + + IContainer empty = container; + + //check to see which parent folders need to be created + while(go) { + if(!empty.exists() && empty instanceof IFolder){ + emptyParent.add(empty); + } + else { + go=false; + } + empty = empty.getParent(); + } + + IFolder emptyFolder = null; + + // create empty parent folders + for(int j=emptyParent.size()-1;j>=0;j--){ + emptyFolder = (IFolder) emptyParent.get(j); + if(!emptyFolder.exists()){ + try { + emptyFolder.create(true, true, new NullProgressMonitor()); + } + catch (CoreException e){} + } + } + } }