Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#127] Implement notification callback accessors #128

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.subversion.javahl.SubversionException;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.team.svn.core.connector.ISVNCallListener;
import org.eclipse.team.svn.core.connector.ISVNNotificationCallback;
import org.eclipse.team.svn.core.connector.SVNConnectorAuthenticationException;
import org.eclipse.team.svn.core.connector.SVNConnectorCancelException;
import org.eclipse.team.svn.core.connector.SVNConnectorException;
Expand All @@ -54,6 +55,14 @@ void removeListener(ISVNCallListener listener) {
listeners.remove(listener);
}

void addCallback(ISVNNotificationCallback listener) {
notifications.add(listener);
}

void removeCallback(ISVNNotificationCallback listener) {
notifications.remove(listener);
}

<V> V querySafe(String method, Map<String, Object> parameters, QuerySafe<V> query) {
asked(method, parameters);
V value = query.query(parameters);
Expand Down Expand Up @@ -83,7 +92,7 @@ <V, A> A queryAdapt(String method, Map<String, Object> parameters, ProgressCallb
Function<V, A> adapter) throws SVNConnectorException {
asked(method, parameters);
try {
notifications.add(progress);
addCallback(progress);
progress.start();
watchdog.add(progress);
A value = adapter.apply(query.query(parameters));
Expand All @@ -96,7 +105,7 @@ <V, A> A queryAdapt(String method, Map<String, Object> parameters, ProgressCallb
} finally {
progress.finish();
watchdog.remove(progress);
notifications.remove(progress);
removeCallback(progress);
}
}

Expand All @@ -122,7 +131,7 @@ void commandCallback(String method, Map<String, Object> parameters, ProgressCall
CommandCallback callback) throws SVNConnectorException {
asked(method, parameters);
try {
notifications.add(progress);
addCallback(progress);
progress.start();
watchdog.add(progress);
command.command(parameters);
Expand All @@ -139,7 +148,7 @@ void commandCallback(String method, Map<String, Object> parameters, ProgressCall
} finally {
progress.finish();
watchdog.remove(progress);
notifications.remove(progress);
removeCallback(progress);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ final class SvnKit1_10Connector implements ISVNConnector {
private final CallWatch watch;
private final SVNClientImpl client;
private final List<ISVNCredentialsPrompt> prompts = new ArrayList<>();
private final List<ISVNNotificationCallback> notifications = new ArrayList<>();
//FIXME: AF: not sure why do we need this
private final List<ISVNConfigurationEventHandler> handlers = new ArrayList<>();

Expand Down Expand Up @@ -179,15 +180,20 @@ public ISVNCredentialsPrompt getPrompt() {

@Override
public void setNotificationCallback(ISVNNotificationCallback notify) {
System.out.println("SvnKit1_10Connector.setNotificationCallback()");
//TODO
Map<String, Object> parameters = new HashMap<>();
parameters.put("notify", notify);
notifications.stream().forEach(watch::removeCallback);
notifications.clear();
notifications.add(notify);
watch.commandSafe(ISVNCallListener.SET_NOTIFICATION_CALLBACK, parameters,
p -> notifications.stream().forEach(watch::addCallback));
}

@Override
public ISVNNotificationCallback getNotificationCallback() {
System.out.println("SvnKit1_10Connector.getNotificationCallback()");
//TODO
return null;
return watch.querySafe(ISVNCallListener.GET_NOTIFICATION_CALLBACK, //
Collections.emptyMap(), //
p -> notifications.stream().findAny().orElse(null));
}

@Override
Expand Down
Loading