Bug 420110: API does not allow to permanently store or change
usersession passwords
https://bugs.eclipse.org/bugs/show_bug.cgi?id=420110, wrapped delete
in command, additionally added convience classes to run callables
diff --git a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallable.java b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallable.java
index 6afc6ff..53d2fb9 100644
--- a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallable.java
+++ b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallable.java
@@ -18,6 +18,8 @@
*
* @author emueller
*
+ * @since 1.1
+ *
*/
public abstract class ESVoidCallable implements Callable<Void> {
diff --git a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallableWithException.java b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallableWithException.java
new file mode 100644
index 0000000..d1078b9
--- /dev/null
+++ b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/client/util/ESVoidCallableWithException.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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
+ *
+ * Contributors:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.util;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Convenience class for using {@link RunESCommand} without a return value,
+ * but possibly throwing an exception.
+ *
+ * @param <E> the type of exception thrown by {@code run}
+ */
+public abstract class ESVoidCallableWithException<E extends Exception> implements Callable<Void> {
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.concurrent.Callable#call()
+ */
+ public Void call() throws Exception {
+ run();
+ return null;
+ }
+
+ // BEGIN SUPRESS CATCH EXCEPTION
+ public abstract void run() throws Exception;
+ // END SUPRESS CATCH EXCEPTION
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/api/ESUsersessionImpl.java b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/api/ESUsersessionImpl.java
index befc29b..41d9269 100644
--- a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/api/ESUsersessionImpl.java
+++ b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/api/ESUsersessionImpl.java
@@ -17,6 +17,7 @@
import org.eclipse.emf.emfstore.client.ESUsersession;
import org.eclipse.emf.emfstore.client.ESWorkspace;
import org.eclipse.emf.emfstore.client.ESWorkspaceProvider;
+import org.eclipse.emf.emfstore.client.util.ESVoidCallableWithException;
import org.eclipse.emf.emfstore.client.util.RunESCommand;
import org.eclipse.emf.emfstore.internal.client.model.Usersession;
import org.eclipse.emf.emfstore.internal.client.model.util.EMFStoreCommand;
@@ -212,6 +213,11 @@
public void delete() throws ESException {
final ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
final ESWorkspaceImpl workspaceImpl = ESWorkspaceImpl.class.cast(workspace);
- workspaceImpl.toInternalAPI().removeUsersession(toInternalAPI());
+ RunESCommand.WithException.run(ESException.class, new ESVoidCallableWithException<ESException>() {
+ @Override
+ public void run() throws ESException {
+ workspaceImpl.toInternalAPI().removeUsersession(toInternalAPI());
+ }
+ });
}
}