Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java6
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java11
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java2
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java3
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java11
5 files changed, 27 insertions, 6 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java
index 4f20f4c5394..ce5101b4f8e 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java
@@ -24,6 +24,12 @@ import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
*/
public interface IInternalPapyrusRepositoryManager extends IPapyrusRepositoryManager {
+ /** Managed container product group key for model repository-related elements. */
+ String PRODUCT_GROUP = Activator.PLUGIN_ID + ".repositories"; //$NON-NLS-1$
+
+ /** Managed container product factory key for the repository manager. */
+ String MANAGER_FACTORY = "manager"; //$NON-NLS-1$
+
IManagedContainer getSessionsContainer();
void setURL(IPapyrusRepository repository, String url);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
index c44e878c3a5..45fe9106943 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
@@ -250,7 +250,7 @@ public class PapyrusRepository extends Container<CDOResourceNode> implements IIn
String uuid = session.getRepositoryInfo().getUUID();
if(!Objects.equal(uuid, model.getUUID())) {
model.setUUID(uuid);
- PapyrusRepositoryManager.INSTANCE.saveRepositories();
+ getManager().saveRepositories();
}
}
} finally {
@@ -258,17 +258,22 @@ public class PapyrusRepository extends Container<CDOResourceNode> implements IIn
if(oldCreds != null) {
container.putElement(CredentialsProviderFactory.PRODUCT_GROUP, "interactive", null, oldCreds); //$NON-NLS-1$
} else {
- container/* IPluginContainer.INSTANCE */.removeElement(CredentialsProviderFactory.PRODUCT_GROUP, "interactive", null); //$NON-NLS-1$
+ container.removeElement(CredentialsProviderFactory.PRODUCT_GROUP, "interactive", null); //$NON-NLS-1$
}
}
}
}
}
+ protected final IInternalPapyrusRepositoryManager getManager() {
+ return (IInternalPapyrusRepositoryManager)container.getElement(IInternalPapyrusRepositoryManager.PRODUCT_GROUP, IInternalPapyrusRepositoryManager.MANAGER_FACTORY, null);
+ }
+
private ICredentialsProvider2 getCredentialsProvider() {
ICredentialsProvider2 result = null;
- ICredentialsProviderFactory factory = PapyrusRepositoryManager.INSTANCE.getCredentialsProviderFactory();
+ ICredentialsProviderFactory factory = getManager().getCredentialsProviderFactory();
+
if(factory != null) {
result = factory.createCredentialsProvider(this);
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java
index d3fc0db52e0..81c429c784f 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java
@@ -71,6 +71,8 @@ public class PapyrusRepositoryManager extends Container<IPapyrusRepository> impl
this.repositories = initializeRepositories();
activate();
+
+ container.putElement(PRODUCT_GROUP, MANAGER_FACTORY, null, this);
}
public void dispose() {
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
index 01fd56634d4..73f3b43018a 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
@@ -109,6 +109,9 @@ public abstract class AbstractPapyrusCDOTest {
repository.disconnect();
PapyrusRepositoryManager.INSTANCE.removeRepository(repository);
repository = null;
+
+ // persist the removal (the new new repository saved its UUID when opened)
+ PapyrusRepositoryManager.INSTANCE.saveRepositories();
}
LifecycleUtil.deactivate(container);
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
index b940e0a1056..655f9fac00b 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
@@ -178,6 +178,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.NONE;
@@ -207,6 +208,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.SAVE;
@@ -237,6 +239,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.CLOSE;
@@ -270,13 +273,12 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
@Before
public void createRepositoryManager() throws Exception {
-
- fixture = new PapyrusRepositoryManager();
+ // make sure that any saves are ephemeral
+ fixture = new PapyrusRepositoryManager(new StringStorage());
}
@After
public void disposeRepositoryManager() throws Exception {
-
if(fixture != null) {
fixture.dispose();
fixture = null;
@@ -379,6 +381,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
return result;
}
+ @Override
public void notifyEvent(IEvent event) {
if(event instanceof CDOTransactionFinishedEvent) {
committed = true;
@@ -390,11 +393,13 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
String storage = null;
+ @Override
public InputStream createInputStream() throws IOException {
return (storage == null ? null : new ByteArrayInputStream(storage.getBytes("UTF-8")));
}
+ @Override
public OutputStream createOutputStream() throws IOException {
return new ByteArrayOutputStream() {

Back to the top