1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 22:35:43 +02:00

[225988][api]need API to mark persisted profiles as migrated so they do not continue to be migrated

https://bugs.eclipse.org/bugs/show_bug.cgi?id=225988
This commit is contained in:
David Dykstal 2008-04-08 02:41:22 +00:00
parent 77e0b0e35b
commit 5c9058e0f4
8 changed files with 199 additions and 20 deletions

View file

@ -0,0 +1,58 @@
/*********************************************************************************
* Copyright (c) 2008 IBM Corporation. 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 http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
*********************************************************************************/
package org.eclipse.rse.core;
/**
* Codes for use in constructing IStatus objects.
* These are unique across org.eclipse.rse.core
* @since 3.0
*/
public interface IRSECoreStatusCodes {
/*
* General codes (1 to 100)
*/
/**
* A code used for constructing IStatus objects.
* Value 1. An exception occurred during the operation.
* @since 3.0
*/
public static final int EXCEPTION_OCCURRED = 1;
/**
* A code used for constructing IStatus objects.
* Value 2. An invalid format was encountered operation.
* The object in question must be assumed to be corrupted.
* @since 3.0
*/
public static final int INVALID_FORMAT = 2;
/*
* Persistence manager and provider codes (101 to 200)
*/
/**
* A code used for constructing IStatus objects.
* Value 101. A persistent form of a profile is not found.
* @since 3.0
*/
public static final int PROFILE_NOT_FOUND = 101;
/**
* A code used for constructing IStatus objects.
* Value 102.
* The marking of profiles as migrated is not supported by this provider.
* @since 3.0
*/
public static final int MIGRATION_NOT_SUPPORTED = 102;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* Copyright (c) 2007, 2008 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
@ -7,8 +7,8 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* David Dykstal (IBM) - [189858] delayed the creation of the remote systems project by
* using handle-only operations.
* David Dykstal (IBM) - [189858] delayed the creation of the remote systems project by using handle-only operations.
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
*******************************************************************************/
package org.eclipse.rse.internal.persistence;
@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.IRSECoreStatusCodes;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.internal.core.RSECoreMessages;
@ -66,7 +67,7 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
try {
profileFolder.delete(IResource.FORCE, monitor);
} catch (CoreException e) {
result = new Status(IStatus.ERROR, null, 0, RSECoreMessages.PropertyFileProvider_UnexpectedException, e);
result = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, IRSECoreStatusCodes.EXCEPTION_OCCURRED, RSECoreMessages.PropertyFileProvider_UnexpectedException, e);
}
}
return result;

View file

@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* David Dykstal (IBM) - [188863] fix job conflict problems for save jobs, ignore bad profiles on restore
* David Dykstal (IBM) - [189274] provide import and export operations for profiles
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
********************************************************************************/
package org.eclipse.rse.internal.persistence;
@ -40,7 +41,9 @@ import java.util.regex.Pattern;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.IRSECoreStatusCodes;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.logging.Logger;
@ -223,6 +226,28 @@ public class PropertyFileProvider implements IRSEPersistenceProvider, IRSEImport
return providerId;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#setMigratedMark(java.lang.String, boolean)
*/
public IStatus setMigrationMark(String profileName, boolean migrated) {
String message = "PropertyFileProvider does not support profile migration"; //$NON-NLS-1$
return new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, IRSECoreStatusCodes.MIGRATION_NOT_SUPPORTED, message, null);
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#supportsMigration()
*/
public boolean supportsMigration() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#getMigratedProfileNames()
*/
public String[] getMigratedProfileNames() {
return new String[0];
}
/**
* Checks a profile name for validity. Currently all names are valid except for completely blank names.
* @param profileName the name to check

View file

@ -18,6 +18,7 @@
* Martin Oberhuber (Wind River) - [196919] Fix deadlock with workspace operations
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
* David Dykstal (IBM) - [189274] provide import and export operations for profiles
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
********************************************************************************/
package org.eclipse.rse.internal.persistence;
@ -39,6 +40,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.IRSEPreferenceNames;
import org.eclipse.rse.core.RSECorePlugin;
@ -178,6 +180,14 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#migrateProfile(org.eclipse.rse.core.model.ISystemProfile, org.eclipse.rse.persistence.IRSEPersistenceProvider)
*/
public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider) {
migrateProfile(profile, persistenceProvider, true);
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#migrateProfile(org.eclipse.rse.core.model.ISystemProfile, org.eclipse.rse.persistence.IRSEPersistenceProvider, boolean)
*/
public IStatus migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider, boolean delete) {
IStatus result = Status.OK_STATUS;
IRSEPersistenceProvider oldProvider = profile.getPersistenceProvider();
oldProvider = (oldProvider == null) ? getDefaultPersistenceProvider() : oldProvider;
IRSEPersistenceProvider newProvider = persistenceProvider;
@ -186,9 +196,14 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
String profileName = profile.getName();
profile.setPersistenceProvider(newProvider);
profile.commit();
if (delete) {
deleteProfile(oldProvider, profileName);
} else {
result = oldProvider.setMigrationMark(profileName, true);
}
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#deleteProfile(java.lang.String)

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
* Copyright (c) 2006, 2008 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 http://www.eclipse.org/legal/epl-v10.html
@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* David Dykstal (IBM) - [191130] use explicit getRemoteSystemsProject(boolean) method
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
********************************************************************************/
package org.eclipse.rse.internal.persistence;
@ -32,10 +33,13 @@ 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.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.IRSECoreStatusCodes;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -81,8 +85,9 @@ public class SerializingProvider implements IRSEPersistenceProvider {
}
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
IStatus status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, IRSECoreStatusCodes.EXCEPTION_OCCURRED, "Unexpected CoreException", e); //$NON-NLS-1$
ILog log = RSECorePlugin.getDefault().getLog();
log.log(status);
}
String[] result = new String[names.size()];
names.toArray(result);
@ -96,7 +101,6 @@ public class SerializingProvider implements IRSEPersistenceProvider {
RSEDOM dom = null;
IFile profileFile = getProfileFile(profileName, monitor);
if (profileFile.exists()) {
//System.out.println("loading "+ profileFile.getLocation().toOSString() + "..."); // DWD debugging
try {
InputStream iStream = profileFile.getContents();
@ -142,7 +146,6 @@ public class SerializingProvider implements IRSEPersistenceProvider {
IFile profileFile = getProfileFile(dom.getName(), monitor);
File osFile = profileFile.getLocation().toFile();
// System.out.println("saving "+ osFile.getAbsolutePath() + "..."); // DWD debugging
try {
OutputStream oStream = new FileOutputStream(osFile);
ObjectOutputStream outStream = new ObjectOutputStream(oStream);
@ -172,12 +175,33 @@ public class SerializingProvider implements IRSEPersistenceProvider {
try {
profileFile.delete(IResource.FORCE | IResource.KEEP_HISTORY, monitor);
} catch (CoreException e) {
result = new Status(IStatus.ERROR, null, 0, RSECoreMessages.SerializingProvider_UnexpectedException, e);
result = new Status(IStatus.ERROR, null, IRSECoreStatusCodes.EXCEPTION_OCCURRED, RSECoreMessages.SerializingProvider_UnexpectedException, e);
}
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#supportsMigration()
*/
public boolean supportsMigration() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#setMigratedMark(java.lang.String, boolean)
*/
public IStatus setMigrationMark(String profileName, boolean migrated) {
return new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, IRSECoreStatusCodes.MIGRATION_NOT_SUPPORTED, "Profile migration is not supported by the serializing provider.", null); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#getMigratedProfileNames()
*/
public String[] getMigratedProfileNames() {
return new String[0];
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#setProperties(java.util.Properties)
*/

View file

@ -19,6 +19,7 @@
* David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets
* David Dykstal (IBM) - [197036] respond to removal of SystemProfile.createHost()
* David Dykstal (IBM) - [217556] remove service subsystem types
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
********************************************************************************/
package org.eclipse.rse.internal.persistence.dom;
@ -26,6 +27,7 @@ package org.eclipse.rse.internal.persistence.dom;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.core.IRSECoreRegistry;
import org.eclipse.rse.core.IRSECoreStatusCodes;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.filters.ISystemFilter;
@ -581,12 +583,12 @@ public class RSEDOMImporter {
private void logException(Exception e) {
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, e.getMessage(), e));
new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), IRSECoreStatusCodes.EXCEPTION_OCCURRED, e.getMessage(), e));
}
private void logWarning(String msg) {
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, "RSEDOMImporter: "+msg, null)); //$NON-NLS-1$
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), 0, "RSEDOMImporter: "+msg, null)); //$NON-NLS-1$
}
private void logNullAttribute(RSEDOMNode node, String attributeName) {
@ -603,7 +605,7 @@ public class RSEDOMImporter {
}
msg.append(node.getName()==null ? "null" : node.getName()); //$NON-NLS-1$
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, msg.toString(), null));
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), 0, msg.toString(), null));
}
}

View file

@ -14,10 +14,12 @@
* Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework
* David Dykstal (IBM) - [cleanup] adding noimplement tag
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
*******************************************************************************/
package org.eclipse.rse.persistence;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.rse.core.model.ISystemProfile;
/**
@ -76,13 +78,30 @@ public interface IRSEPersistenceManager {
public void deleteProfile(IRSEPersistenceProvider persistenceProvider, String profileName);
/**
* Migrates a profile to a new persistence provider. It will delete the persistent form known to its previous
* persistence provider. If the new provider and the previous provider are the same this does nothing.
* Migrates a profile to a new persistence provider.
* It will delete the persistent form known to its previous persistence provider.
* If the new provider and the previous provider are the same this does nothing.
* Exactly the same as <code>migrateProfile(profile, persistenceProvider, true);</code>
* @param profile the system profile to be migrated
* @param persistenceProvider the persistence provider to which this profile will be migrated.
*/
public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider);
/**
* Migrates a profile to a new persistence provider.
* It will mark the persistent form known to its previous
* persistence provider as migrated. This may, in fact, result
* in the persistent form of this profile being deleted.
* If the new provider and the previous provider are the same this does nothing.
* @param profile the system profile to be migrated
* @param persistenceProvider the persistence provider to which this profile will be migrated.
* @param delete true if the persistent form of this profile is to be deleted from the old provider,
* false if the persistent form of the profile is to be marked as migrated.
* @return an IStatus indicating the success of the migration.
* @since org.eclipse.rse.core 2.1
*/
public IStatus migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider, boolean delete);
/**
* Register the persistence provider to be used when saving and restoring RSE doms.
* The provider is registered under the provided id.

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation. All rights reserved.
* Copyright (c) 2006, 2008 IBM Corporation. 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 http://www.eclipse.org/legal/epl-v10.html
@ -13,6 +13,7 @@
* Contributors:
* David Dykstal (IBM) - 177329: added getSaveJob so that the persistence provider
* determines the job characteristics.
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
********************************************************************************/
package org.eclipse.rse.persistence;
@ -22,6 +23,7 @@ import java.util.Properties;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.IRSECoreStatusCodes;
import org.eclipse.rse.persistence.dom.RSEDOM;
/**
@ -76,6 +78,8 @@ public interface IRSEPersistenceProvider {
/**
* @return The names of the profiles that have been saved by this persistence provider.
* Profiles that have been marked as migrated are not returned in this list.
* This may be an empty array but will never be null.
*/
public String[] getSavedProfileNames();
@ -88,4 +92,35 @@ public interface IRSEPersistenceProvider {
*/
public IStatus deleteProfile(String profileName, IProgressMonitor monitor);
/**
* Sets the migration state of a profile.
* @param profileName the name of the profile of which to set the migration state
* @param migrated true if the profile is to be marked as migrated, false if it is to be marked as normal.
* Normal profiles are returned in {@link #getSavedProfileNames()}, migrated profiles are returned
* in {@link #getMigratedProfileNames()}.
* @return a status representing the resulting state of the migration. An OK status
* indicates a successful marking. An ERROR status indicates an unsuccessful marking.
* @see IRSECoreStatusCodes
* @since org.eclipse.rse.core 3.0
*/
public IStatus setMigrationMark(String profileName, boolean migrated);
/**
* @return The names of the profiles that have been migrated by this persistence provider.
* The names of profiles that have been marked as migrated are returned in this list.
* The appearance of a profile name in this list implies that the profile may be
* unmigrated by this provider by using {@link #setMigrationMark(String, boolean)}.
* This may be an empty array but will never be null.
* @since org.eclipse.rse.core 3.0
*/
public String[] getMigratedProfileNames();
/**
* Indicates whether or not this persistence provider supports migration.
* @return true if the provider supports marking of the persistence form of profiles
* as migrated, false otherwise.
* @since org.eclipse.rse.core 3.0
*/
public boolean supportsMigration();
}