diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/META-INF/MANIFEST.MF b/bundles/ru.arsysop.svn.connector.svnkit1_10/META-INF/MANIFEST.MF index 812501c..8444eb7 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/META-INF/MANIFEST.MF +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/META-INF/MANIFEST.MF @@ -6,8 +6,11 @@ Bundle-Version: 0.1.0.qualifier Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: org.apache.subversion.javahl.types;version="1.10.11", +Import-Package: org.apache.subversion.javahl;version="1.10.11", + org.apache.subversion.javahl.callback;version="1.10.11", + org.apache.subversion.javahl.types;version="1.10.11", org.tmatesoft.sqljet.core;version="1.1.15", + org.tmatesoft.svn.core.internal.wc;version="1.10.11", org.tmatesoft.svn.core.javahl17;version="1.10.11", org.tmatesoft.svn.util;version="1.10.11" Require-Bundle: org.eclipse.core.runtime;bundle-version="3.18.0", diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java new file mode 100644 index 0000000..3cdcbf2 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +import org.apache.subversion.javahl.ClientException; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.team.svn.core.connector.ISVNCallListener; +import org.eclipse.team.svn.core.connector.SVNConnectorAuthenticationException; +import org.eclipse.team.svn.core.connector.SVNConnectorCancelException; +import org.eclipse.team.svn.core.connector.SVNConnectorException; +import org.eclipse.team.svn.core.connector.SVNConnectorUnresolvedConflictException; +import org.eclipse.team.svn.core.connector.SVNErrorCodes; +import org.eclipse.team.svn.core.utility.SVNNotificationComposite; + +final class CallWatch { + + final SVNNotificationComposite notifications = new SVNNotificationComposite(); + private final ListenerList listeners = new ListenerList<>(); + + void addListener(ISVNCallListener listener) { + listeners.add(listener); + } + + void removeListener(ISVNCallListener listener) { + listeners.remove(listener); + } + + V query(String method, Map parameters, Query query) throws SVNConnectorException { + asked(method, parameters); + try { + V value = query.query(parameters); + succeeded(method, parameters, value); + return value; + } catch (ClientException ex) { + SVNConnectorException wrap = wrap(ex); + failed(method, parameters, wrap); + throw wrap; + } + } + + V querySafe(String method, Map parameters, QuerySafe query) { + asked(method, parameters); + V value = query.query(parameters); + succeeded(method, parameters, value); + return value; + } + + void command(String method, Map parameters, Command command) throws SVNConnectorException { + asked(method, parameters); + try { + command.command(parameters); + succeeded(method, parameters, null);//oh, no! we need to change this interface + } catch (ClientException ex) { + SVNConnectorException wrap = wrap(ex); + failed(method, parameters, wrap); + throw wrap; + } + } + + void commandSafe(String method, Map parameters, CommandSafe command) { + asked(method, parameters); + command.command(parameters); + succeeded(method, parameters, null);//oh, no! we need to change this interface + } + + private void asked(String method, Map parameters) { + for (ISVNCallListener listener : listeners) { + listener.asked(method, parameters); + } + } + + private void succeeded(String method, Map parameters, Object value) { + for (ISVNCallListener listener : listeners) { + listener.succeeded(method, parameters, value); + } + } + + private void failed(String method, Map parameters, SVNConnectorException exception) { + for (ISVNCallListener listener : listeners) { + listener.failed(method, parameters, exception); + } + } + + private SVNConnectorException wrap(ClientException ex) { + if (authenticationFailure(ex)) { + return new SVNConnectorAuthenticationException(ex.getMessage(), ex); + } + if (wasCancelled(ex)) { + return new SVNConnectorCancelException(ex.getMessage(), ex); + } + if (unresolvedConflict(ex)) { + return new SVNConnectorUnresolvedConflictException(ex.getMessage(), ex); + } + return new SVNConnectorException(ex.getMessage(), ex.getAprError(), ex); + } + + private boolean authenticationFailure(ClientException t) { + return t.getAprError() == SVNErrorCodes.raNotAuthorized; + } + + private boolean wasCancelled(ClientException t) { + return t.getAprError() == SVNErrorCodes.cancelled; + } + + private boolean unresolvedConflict(ClientException t) { + return t.getAprError() == SVNErrorCodes.fsConflict || t.getAprError() == SVNErrorCodes.fsTxnOutOfDate; + } + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Cancel.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Cancel.java new file mode 100644 index 0000000..29bf849 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Cancel.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + + +@FunctionalInterface +interface Cancel { + + void cancel() throws Exception; + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Command.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Command.java new file mode 100644 index 0000000..8510637 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Command.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +import org.apache.subversion.javahl.ClientException; + +@FunctionalInterface +public interface Command { + + void command(Map parameters) throws ClientException; + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandSafe.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandSafe.java new file mode 100644 index 0000000..f2f5fa0 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandSafe.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +@FunctionalInterface +public interface CommandSafe { + + void command(Map parameters); + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Query.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Query.java new file mode 100644 index 0000000..4006724 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Query.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +import org.apache.subversion.javahl.ClientException; + +@FunctionalInterface +public interface Query { + + V query(Map parameters) throws ClientException; + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QuerySafe.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QuerySafe.java new file mode 100644 index 0000000..23936ec --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QuerySafe.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) ArSysOp 2020-2024 + * + * ArSysOp and its affiliates make no warranty of any kind + * with regard to this material. + * + * ArSysOp expressly disclaims all warranties as to the material, express, + * and implied, including but not limited to the implied warranties of + * merchantability, fitness for a particular purpose and non-infringement of third + * party rights. + * + * In no event shall ArSysOp be liable to you or any other person for any damages, + * including, without limitation, any direct, indirect, incidental or consequential + * damages, expenses, lost profits, lost data or other damages arising out of the use, + * misuse or inability to use the material and any derived software, even if ArSysOp, + * its affiliate or an authorized dealer has been advised of the possibility of such damages. + * + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +@FunctionalInterface +public interface QuerySafe { + + V query(Map parameters); + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java index be36c01..52b08c4 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java @@ -22,6 +22,8 @@ package ru.arsysop.svn.connector.internal.svnkit1_10; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -53,50 +55,73 @@ import org.eclipse.team.svn.core.connector.SVNRevision; import org.eclipse.team.svn.core.connector.SVNRevisionRange; import org.eclipse.team.svn.core.connector.configuration.ISVNConfigurationEventHandler; +import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; +import org.tmatesoft.svn.core.javahl17.SVNClientImpl; //TODO final class SvnKit1_10Connector implements ISVNConnector { + private final CallWatch watch = new CallWatch(); + private final SVNClientImpl client; +//FIXME: AF: not sure why do we need this + private final List handlers = new ArrayList<>(); + + public SvnKit1_10Connector() { + SVNFileUtil.setSleepForTimestamp(false);// not time to relax + client = SVNClientImpl.newInstance(); + //FIXME: AF: not yet +// client.notification2(new ClientNotifyCallbackAdapter(watch.notifications)); + } + @Override public void addCallListener(ISVNCallListener listener) { - //TODO + watch.addListener(listener); } @Override public void removeCallListener(ISVNCallListener listener) { - //TODO + watch.removeListener(listener); } @Override public String getConfigDirectory() throws SVNConnectorException { - //TODO - return null; + return watch.query(ISVNCallListener.GET_CONFIG_DIRECTORY, // + Collections.emptyMap(), // + p -> client.getConfigDirectory()); } @Override - public void setConfigDirectory(String configDir) throws SVNConnectorException { - //TODO + public void setConfigDirectory(String directory) throws SVNConnectorException { + watch.command(ISVNCallListener.SET_CONFIG_DIRECTORY, // + Map.of("configDir", directory), // //$NON-NLS-1$ + p -> client.setConfigDirectory(directory)); } @Override - public void setConfigurationEventHandler(ISVNConfigurationEventHandler configHandler) throws SVNConnectorException { - //TODO + public void setConfigurationEventHandler(ISVNConfigurationEventHandler handler) throws SVNConnectorException { + handlers.clear(); + watch.commandSafe(ISVNCallListener.SET_CONFIGURATION_EVENT_HANDLER, // + Map.of("configHandler", handler), //$NON-NLS-1$ + p -> handlers.add(handler)); } @Override public ISVNConfigurationEventHandler getConfigurationEventHandler() throws SVNConnectorException { - //TODO - return null; + return watch.querySafe(ISVNCallListener.GET_CONFIGURATION_EVENT_HANDLER, // + Collections.emptyMap(), + p -> handlers.stream().findAny().orElse(null)); } @Override public void setUsername(String username) { - //TODO + Map parameters = Map.of("username", username); //$NON-NLS-1$ + watch.commandSafe(ISVNCallListener.SET_USERNAME, parameters, p -> client.username(username)); } @Override public void setPassword(String password) { - //TODO + Map parameters = Map.of("password", password); //$NON-NLS-1$ + watch.commandSafe(ISVNCallListener.SET_PASSWORD, parameters, p -> client.username(password)); } @Override @@ -462,7 +487,7 @@ public void vacuum(String path, long options, ISVNProgressMonitor monitor) throw @Override public void dispose() { - //TODO + client.dispose(); } } diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10ConnectorFactory.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10ConnectorFactory.java index cd9f1c2..e225255 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10ConnectorFactory.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10ConnectorFactory.java @@ -47,7 +47,7 @@ public String getName() { } public String getId() { - return "org.eclipse.team.svn.connector.svnkit18"; //$NON-NLS-1$ + return "org.eclipse.team.svn.connector.svnkit1_10"; //$NON-NLS-1$ } public String getClientVersion() { @@ -62,7 +62,7 @@ public String getVersion() { } public String getCompatibilityVersion() { - return "4.0.0.I20160427-1700"; //$NON-NLS-1$ + return "5.0.0"; //$NON-NLS-1$ } public int getSupportedFeatures() { @@ -73,7 +73,7 @@ public int getSupportedFeatures() { } public int getSVNAPIVersion() { - return APICompatibility.SVNAPI_1_8_x; + return APICompatibility.SVNAPI_1_10_x; } @Override diff --git a/releng/ru.arsysop.svn.target/ru.arsysop.svn.target.target b/releng/ru.arsysop.svn.target/ru.arsysop.svn.target.target index 543286c..4ae3605 100644 --- a/releng/ru.arsysop.svn.target/ru.arsysop.svn.target.target +++ b/releng/ru.arsysop.svn.target/ru.arsysop.svn.target.target @@ -60,7 +60,7 @@ - + com.jcraft @@ -155,13 +155,13 @@ Bundle-Name:${mvnGroupId}:${mvnArtifactId}:${mvnVersion} org.tmatesoft.svnkit - svnkit + svnkit-javahl16 1.10.11 jar org.tmatesoft.svnkit - svnkit-javahl16 + svnkit 1.10.11 jar diff --git a/tests/ru.arsysop.svn.connector.svnkit1_10.tests/OSGI-INF/l10n/bundle.properties b/tests/ru.arsysop.svn.connector.svnkit1_10.tests/OSGI-INF/l10n/bundle.properties index e592733..41e1d25 100644 --- a/tests/ru.arsysop.svn.connector.svnkit1_10.tests/OSGI-INF/l10n/bundle.properties +++ b/tests/ru.arsysop.svn.connector.svnkit1_10.tests/OSGI-INF/l10n/bundle.properties @@ -19,5 +19,5 @@ # ArSysOp - initial API and implementation ### -Bundle-Name = ArSysOp SVN Connector Tests +Bundle-Name = ArSysOp SVN Connector with SVNKit 1.10 Tests Bundle-Vendor = ArSysOp