View | Details | Raw Unified | Return to bug 253606 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/datatools/connectivity/IConnectionProfile.java (+5 lines)
Lines 61-66 Link Here
61
	 */
61
	 */
62
	static final String INSTANCE_ID_PROPERTY_ID = "instanceID"; //$NON-NLS-1$
62
	static final String INSTANCE_ID_PROPERTY_ID = "instanceID"; //$NON-NLS-1$
63
	
63
	
64
	/**
65
	 * Transient marker for profile instance.
66
	 */
67
	static final String TRANSIENT_PROPERTY_ID = "isTransient"; //$NON-NLS-1$
68
64
	// Connection states
69
	// Connection states
65
	
70
	
66
	/**
71
	/**
(-)src/org/eclipse/datatools/connectivity/ProfileManager.java (-6 / +11 lines)
Lines 134-139 Link Here
134
	public IConnectionProfile getProfileByFullPath(String path ) {
134
	public IConnectionProfile getProfileByFullPath(String path ) {
135
		return InternalProfileManager.getInstance().getProfileByFullPath(path);
135
		return InternalProfileManager.getInstance().getProfileByFullPath(path);
136
	}
136
	}
137
138
	public IConnectionProfile createTransientProfile(String providerID, Properties baseProperties) throws ConnectionProfileException {
139
		return InternalProfileManager.getInstance().createTransientProfile(null, null, providerID, baseProperties);
140
	}
141
	
137
	/**
142
	/**
138
	 * Create connection profile
143
	 * Create connection profile
139
	 * 
144
	 * 
Lines 143-152 Link Here
143
	 * @param baseProperties
148
	 * @param baseProperties
144
	 * @throws ConnectionProfileException
149
	 * @throws ConnectionProfileException
145
	 */
150
	 */
146
	public void createProfile(String name, String description,
151
	public IConnectionProfile createProfile(String name, String description,
147
			String providerID, Properties baseProperties)
152
			String providerID, Properties baseProperties)
148
			throws ConnectionProfileException {
153
			throws ConnectionProfileException {
149
		InternalProfileManager.getInstance().createProfile(name, description,
154
		return InternalProfileManager.getInstance().createProfile(name, description,
150
				providerID, baseProperties);
155
				providerID, baseProperties);
151
	}
156
	}
152
157
Lines 160-169 Link Here
160
	 * @param parentProfile
165
	 * @param parentProfile
161
	 * @throws ConnectionProfileException
166
	 * @throws ConnectionProfileException
162
	 */
167
	 */
163
	public void createProfile(String name, String description,
168
	public IConnectionProfile createProfile(String name, String description,
164
			String providerID, Properties baseProperties, String parentProfile)
169
			String providerID, Properties baseProperties, String parentProfile)
165
			throws ConnectionProfileException {
170
			throws ConnectionProfileException {
166
		InternalProfileManager.getInstance().createProfile(name, description,
171
		return InternalProfileManager.getInstance().createProfile(name, description,
167
				providerID, baseProperties, parentProfile);
172
				providerID, baseProperties, parentProfile);
168
	}
173
	}
169
174
Lines 178-187 Link Here
178
	 * @param autoConnect
183
	 * @param autoConnect
179
	 * @throws ConnectionProfileException
184
	 * @throws ConnectionProfileException
180
	 */
185
	 */
181
	public void createProfile(String name, String description,
186
	public IConnectionProfile createProfile(String name, String description,
182
			String providerID, Properties baseProperties, String parentProfile,
187
			String providerID, Properties baseProperties, String parentProfile,
183
			boolean autoConnect) throws ConnectionProfileException {
188
			boolean autoConnect) throws ConnectionProfileException {
184
		InternalProfileManager.getInstance().createProfile(name, description,
189
		return InternalProfileManager.getInstance().createProfile(name, description,
185
				providerID, baseProperties, parentProfile, autoConnect);
190
				providerID, baseProperties, parentProfile, autoConnect);
186
	}
191
	}
187
192
(-)src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java (-5 / +65 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004-2008 Sybase, Inc. and others.
2
 * Copyright (c) 2004-2009 Sybase, Inc. and others.
3
 * 
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
5
 * available under the terms of the Eclipse Public License v1.0 which
Lines 10-15 Link Here
10
 *     IBM Corporation -  fix for defect #223855
10
 *     IBM Corporation -  fix for defect #223855
11
 *     IBM Corporation -  fix for defect #241713
11
 *     IBM Corporation -  fix for defect #241713
12
 *     Actuate Corporation - fix for bug #247587
12
 *     Actuate Corporation - fix for bug #247587
13
 *     brianf - added Transient profile functionality for bug 253606
13
 ******************************************************************************/
14
 ******************************************************************************/
14
package org.eclipse.datatools.connectivity.internal;
15
package org.eclipse.datatools.connectivity.internal;
15
16
Lines 76-81 Link Here
76
77
77
	private IConnectionProfile[] mProfiles = null;
78
	private IConnectionProfile[] mProfiles = null;
78
	
79
	
80
	private ArrayList mTransientProfiles = null;
81
79
	private Set mRepositories = new HashSet();
82
	private Set mRepositories = new HashSet();
80
83
81
	private boolean mIsDirty = false;
84
	private boolean mIsDirty = false;
Lines 455-460 Link Here
455
	}
458
	}
456
459
457
	/**
460
	/**
461
	 * Create transient connection profile
462
	 * 
463
	 * @param name
464
	 * @param description
465
	 * @param providerID
466
	 * @param baseProperties
467
	 * @throws ConnectionProfileException
468
	 */
469
	public IConnectionProfile createTransientProfile(String name, String description,
470
			String providerID, Properties baseProperties) throws ConnectionProfileException {
471
		String transientName = name;
472
		if (transientName == null) {
473
			transientName = "Transient" + providerID;
474
		}
475
		transientName = findUniqueTransientProfileName(transientName, providerID);
476
		ConnectionProfile profile = new ConnectionProfile(transientName, description,
477
				providerID, "", false, UUID.createUUID()
478
						.toString());
479
		baseProperties.setProperty(IConnectionProfile.TRANSIENT_PROPERTY_ID, "");
480
		profile.setBaseProperties(baseProperties);
481
		profile.setCreated();
482
		if (mTransientProfiles == null) 
483
			mTransientProfiles = new ArrayList();
484
		mTransientProfiles.add(profile);
485
		return profile;
486
	}
487
	
488
	/**
489
	 * Private method to avoid name collisions
490
	 * @param name
491
	 * @param providerID
492
	 * @return
493
	 */
494
	private String findUniqueTransientProfileName(String name, String providerID) {
495
		if (mTransientProfiles != null) {
496
			Iterator iter = mTransientProfiles.iterator();
497
			int count = 0;
498
			while (iter.hasNext()) {
499
				IConnectionProfile profile = (IConnectionProfile) iter.next();
500
				if (profile.getProviderId().equalsIgnoreCase(providerID)) {
501
					count++;
502
				}
503
			}
504
			return name + count;
505
		}
506
		return name;
507
	}
508
509
	/**
458
	 * Create connection profile
510
	 * Create connection profile
459
	 * 
511
	 * 
460
	 * @param name
512
	 * @param name
Lines 856-865 Link Here
856
908
857
		// Changed to fix bug 247599
909
		// Changed to fix bug 247599
858
		//cps[index] = profile;
910
		//cps[index] = profile;
859
		if(cps[index] != profile) {
911
		removeProfile(cps[index]);
860
			removeProfile(cps[index]);
912
		addProfile(profile);
861
			addProfile(profile);			
862
		}
863
913
864
		mIsDirty = true;
914
		mIsDirty = true;
865
915
Lines 1097-1102 Link Here
1097
	}
1147
	}
1098
1148
1099
	/* package */void dispose() {
1149
	/* package */void dispose() {
1150
		if (mTransientProfiles != null) {
1151
			Iterator transientIter = mTransientProfiles.iterator();
1152
			while (transientIter.hasNext()) {
1153
//				((ConnectionProfile)transientIter.next()).dispose();
1154
				ConnectionProfile transientProfile = 
1155
					(ConnectionProfile) transientIter.next();
1156
				System.out.println("Disposing transient profile: " + transientProfile.getInstanceID());
1157
				transientProfile.dispose();
1158
			}
1159
		}
1100
		if (mProfiles == null) {
1160
		if (mProfiles == null) {
1101
			return;
1161
			return;
1102
		}
1162
		}

Return to bug 253606